Lionel Pointet
Forum Replies Created
-
Hi @ninjateamwp
I had a look at the screencast, and it seems this is the same problem I’m facing right now, which is due to Polylang compatibility.
Indeed, the SQL query generated by the CompatiblePolylang class (in “all_folders_and_count_query” method), has an alias for fbva.folder_id field (“as id”), and this causes issues later on in the Tree class (“getAllFoldersAndCount” method) when it tries to access the folder_id field which doesn’t exist.I applied this workaround that seems to work:
function my_fix_filebird_polylang( $query ) { return str_replace( 'as id', '', $query ); } add_filter( 'fbv_all_folders_and_count', 'my_fix_filebird_polylang', PHP_INT_MAX );Don’t hesitate to come back to me if needed.
Regards.Forum: Plugins
In reply to: [Qubely - Advanced Gutenberg Blocks] Tabs/Accordion presetsHi @creativeartbd
I just wanted to add here a possible solution for those who could have the same problem. I’m actually working with @karkuro and we figured we could use the “blocks.registerBlockType” filter to force attributes default values with our custom ones.
Here is an example:addFilter( 'blocks.registerBlockType', 'my-plugin/qubely/tabs/applyDefaultSettings', myPluginQubelyTabsApplyDefaultSettings ); function myPluginQubelyTabsApplyDefaultSettings( settings, name ) { if( 'qubely/tabs' !== name ) { return settings; } settings.attributes.navAlignment.default = "center"; return settings; }I hope it helps!
Regards.Forum: Plugins
In reply to: [Import and export users and customers] ACF multiple select field typeHi,
Thank you for this update. It works as expected!
I can see the “get_post_id_by_slug” method has been moved but its call from ACUI_ACF class hasn’t been updated though.
I guess$this->get_post_id_by_slug( $slug );should beACUI_Helper::get_post_id_by_slug( $slug );on line 68.Thanks anyway for your prompt responses.
Forum: Plugins
In reply to: [Import and export users and customers] ACF multiple select field typeHello @carazo,
Thanks for your quick reply. Since I cannot upload any file here, I will paste the code directly.
The corresponding git patch:From dc1f839aa1ca913ad5455af07a26ea4b12181d85 Mon Sep 17 00:00:00 2001 From: Lionel Pointet <lpointet@centrepatronal.ch> Date: Wed, 10 Mar 2021 08:38:22 +0100 Subject: [PATCH] Fix ACUI_ACF class for multiple select ACF fields --- .../addons/advanced-custom-fields.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/wp-content/plugins/import-users-from-csv-with-meta/addons/advanced-custom-fields.php b/wp-content/plugins/import-users-from-csv-with-meta/addons/advanced-custom-fields.php index 4bd0272..e02af36 100644 --- a/wp-content/plugins/import-users-from-csv-with-meta/addons/advanced-custom-fields.php +++ b/wp-content/plugins/import-users-from-csv-with-meta/addons/advanced-custom-fields.php @@ -43,7 +43,6 @@ class ACUI_ACF{ function import( $headers, $row, $user_id ){ $fields_positions = array(); $types = $this->get_user_fields_types(); - $types_multiple = array( 'select', 'checkbox', 'radio', 'button_group' ); foreach ( $types as $key => $type ) { $pos = array_search( $key, $headers ); @@ -62,14 +61,14 @@ class ACUI_ACF{ }*/ // slugs in relationship - if( $types[ $key ] == 'relationship' && (string)(int)$data[0] != $data[0] ){ + if( $types[ $key ][ 'type' ] == 'relationship' && (string)(int)$data[0] != $data[0] ){ // @todo $data is undefined here, maybe $row was meant instead? $data = explode( ',', $row[ $pos ] ); foreach ( $data as $it => $slug ) { $data[ $it ] = $this->get_post_id_by_slug( $slug ); } } - elseif( in_array( $types[ $key ], $types_multiple ) ){ + elseif( $types[ $key ][ 'multiple' ] ){ $data = explode( ',', $row[ $pos ] ); array_filter( $data, function( $value ){ return $value !== ''; } ); } @@ -123,13 +122,18 @@ class ACUI_ACF{ function get_user_fields_types(){ $fields = $this->get_user_fields(); $fields_keys = array(); + $types_multiple = array( 'select', 'checkbox', 'radio', 'button_group' ); if( empty( $fields ) ) return array(); foreach ( $fields as $group => $fields_of_group ){ foreach ( $fields_of_group as $field ){ - $fields_keys[ $field['name'] ] = $field['type']; + $fields_keys[ $field['name'] ] = [ + 'type' => $field['type'], + // 'select' type has a 'multiple' key which can be 0 or 1 + 'multiple' => !empty( $field['multiple'] ) || ( !isset( $field['multiple'] ) && in_array( $field['type'], $types_multiple ) ), + ]; } } @@ -172,6 +176,7 @@ class ACUI_ACF{ if ( 0 == $p->post_parent && count( $revparts ) == $count + 1 && $p->post_name == $revparts[ $count ] ) { $foundid = $page->ID; + // @todo $post_type is undefined here if ( $page->post_type == $post_type ) { break; } -- 2.28.0.windows.1And the complete file:
<?php if ( ! defined( 'ABSPATH' ) ) exit; if( !is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) && !is_plugin_active( 'advanced-custom-fields/acf.php' ) ){ return; } class ACUI_ACF{ function __construct(){ add_filter( 'acui_restricted_fields', array( $this, 'restricted_fields' ), 10, 1 ); add_filter( 'acui_not_meta_fields', array( $this, 'restricted_fields' ), 10, 1 ); add_action( 'acui_documentation_after_plugins_activated', array( $this, 'documentation' ) ); add_action( 'post_acui_import_single_user', array( $this, 'import' ), 10, 3 ); } function restricted_fields( $acui_restricted_fields ){ return array_merge( $acui_restricted_fields, $this->get_user_fields_keys() ); } function documentation(){ $fields = $this->get_user_fields(); ?> <tr valign="top"> <th scope="row"><?php _e( "Advaced Custom Fields is activated", 'import-users-from-csv-with-meta' ); ?></th> <td> <?php _e( "You can import those fields, look at every group which fields you can import using the column names shown below.", 'import-users-from-csv-with-meta' ); ?>. <ul style="list-style:disc outside none; margin-left:2em;"> <?php foreach ( $this->get_user_fields() as $group => $fields ): ?> <li><?php _e( "Group name", 'import-users-from-csv-with-meta' ); ?>: <em><?php echo $group; ?></em></li> <ul style="list-style:square inside none; margin-left:2em;"> <?php foreach ( $fields as $field ): ?> <li><?php echo $field['label']; ?> <em>(type: <?php echo $field['type']; ?>)</em> - Column name in the CSV: <strong><?php echo $field['name']; ?></strong></li> <?php endforeach; ?> </ul> <?php endforeach; ?> </ul> </td> </tr> <?php } function import( $headers, $row, $user_id ){ $fields_positions = array(); $types = $this->get_user_fields_types(); foreach ( $types as $key => $type ) { $pos = array_search( $key, $headers ); if( $pos === FALSE ) continue; $fields_positions[ $pos ] = $key; } foreach ( $fields_positions as $pos => $key ) { /*$preexisting_values = get_field( $key, "user_" . $user_id ); if( !empty( $preexisting_values ) ){ $data = array_unique( array_merge( $preexisting_values, $data ) ); $data = array_filter( $data, function( $value ) { return !is_null( $value ) && $value !== '' && $value != 0; } ); }*/ // slugs in relationship if( $types[ $key ][ 'type' ] == 'relationship' && (string)(int)$data[0] != $data[0] ){ // @todo $data is undefined here, maybe $row was meant instead? $data = explode( ',', $row[ $pos ] ); foreach ( $data as $it => $slug ) { $data[ $it ] = $this->get_post_id_by_slug( $slug ); } } elseif( $types[ $key ][ 'multiple' ] ){ $data = explode( ',', $row[ $pos ] ); array_filter( $data, function( $value ){ return $value !== ''; } ); } else{ $data = $row[ $pos ]; } update_field( $key, $data, "user_" . $user_id ); } } function get_user_fields(){ $post_id = "user_new"; $fields = array(); $args = array( 'user_id' => 'new', 'user_form' => '#your-profile' ); $field_groups = acf_get_field_groups( array( 'user_id' => 'new', 'user_form' => '#your-profile' ) ); if( empty($field_groups) ) return; acf_form_data( array( 'post_id' => "user_new", 'nonce' => 'user' ) ); foreach( $field_groups as $field_group ) { $fields[ $field_group['title'] ] = acf_get_fields( $field_group ); } return $fields; } function get_user_fields_keys(){ $fields = $this->get_user_fields(); $fields_keys = array(); if( empty( $fields ) ) return array(); foreach ( $fields as $group => $fields_of_group ){ foreach ( $fields_of_group as $field ){ $fields_keys[] = $field['name']; } } return $fields_keys; } function get_user_fields_types(){ $fields = $this->get_user_fields(); $fields_keys = array(); $types_multiple = array( 'select', 'checkbox', 'radio', 'button_group' ); if( empty( $fields ) ) return array(); foreach ( $fields as $group => $fields_of_group ){ foreach ( $fields_of_group as $field ){ $fields_keys[ $field['name'] ] = [ 'type' => $field['type'], // 'select' type has a 'multiple' key which can be 0 or 1 'multiple' => !empty( $field['multiple'] ) || ( !isset( $field['multiple'] ) && in_array( $field['type'], $types_multiple ) ), ]; } } return $fields_keys; } function get_post_id_by_slug( $slug ){ global $wpdb; $page_path = rawurlencode( urldecode( $slug ) ); $page_path = str_replace( '%2F', '/', $page_path ); $page_path = str_replace( '%20', ' ', $page_path ); $parts = explode( '/', trim( $page_path, '/' ) ); $parts = array_map( 'sanitize_title_for_query', $parts ); $escaped_parts = esc_sql( $parts ); $in_string = "'" . implode( "','", $escaped_parts ) . "'"; $sql = "SELECT ID, post_name, post_parent, post_type FROM $wpdb->posts WHERE post_name IN ($in_string)"; $pages = $wpdb->get_results( $sql, OBJECT_K ); $revparts = array_reverse( $parts ); $foundid = 0; foreach ( (array) $pages as $page ) { if ( $page->post_name == $revparts[0] ) { $count = 0; $p = $page; while ( 0 != $p->post_parent && isset( $pages[ $p->post_parent ] ) ) { $count++; $parent = $pages[ $p->post_parent ]; if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) { break; } $p = $parent; } if ( 0 == $p->post_parent && count( $revparts ) == $count + 1 && $p->post_name == $revparts[ $count ] ) { $foundid = $page->ID; // @todo $post_type is undefined here if ( $page->post_type == $post_type ) { break; } } } } return $foundid; } } new ACUI_ACF();FYI, I added 2 “@todo” comments in places where some variables are undefined, I’m not sure what were the use cases and it was not part of mine anyway.
I’m using a workaround before you fix this issue by filtering the value before ACF updates the value:
/** * Ensure we import correctly data from ACF field groups. * Import users and customers with meta plugin incorrectly stores serialized arrays for non-multiple select field type values. * * @param mixed $value * @param string|int $post_id * @param array $field * * @return mixed */ function multiple_select_acf_values( $value, $post_id, $field ) { if( 'select' === $field['type'] && !$field['multiple'] && is_array( $value ) ) { $value = array_shift( $value ); } return $value; } add_filter( 'acf/update_value', 'multiple_select_acf_values', 10, 3 );Don’t hesitate to contact me if you need.
Forum: Plugins
In reply to: [WP-AppKit - Mobile apps and PWA for WordPress] PhoneGap 0.1 not supportedHello,
Did you put a value in the “PhoneGap > Version” field available in your app edit panel? If so, is it a value from the currently supported versions (see this page)?
Try to export without any value in this field, this will ensure the default behaviour from PhoneGap Build.If it didn’t help, please send an email to our support: see this post.
Best regards.
Forum: Plugins
In reply to: [WP-AppKit - Mobile apps and PWA for WordPress] activation errorHello,
You probably have an old PHP version (< 5.4). I recommend you upgrade (be sure to do it carefully) or you might encounter other problems.
Please also note we don’t regularly answer here, so feel free to send us an email to get our support.
Regards.
Forum: Plugins
In reply to: [WP-AppKit - Mobile apps and PWA for WordPress] Visual composer supportrHi,
Unfortunately, your link now leads to a “suspended account” page, so I cannot see anything.
Regarding mobix, if you can directly get the HTML/CSS/JS theme, then it will be easier to integrate it in a WP-AppKit theme. There is still some development needed though, as the theme itself needs to be “attached” to the WP-AppKit theme API to run correctly in your app.
Everything you are talking about is possible with our plugin, even if some features may need more development than others (typically, login/register and post creation ones). Many tutorials on our webstie could guide you through this process, as well as the documentation.
Happy App Coding,
LionelHi,
Could you please send a message to our support email (see this post for an explanation)?
In short, it seems you might not have any theme associated with your app, maybe because you don’t have any WP-AppKit themes installed yet.
- This reply was modified 8 years, 8 months ago by Lionel Pointet.
Forum: Plugins
In reply to: [WP-AppKit - Mobile apps and PWA for WordPress] Visual composer supportrHello,
Unfortunately, your link shows an app where you must login before seeing the content, so I cannot see what you’re talking about.
My guess is that pointfinder theme uses Visual Composer shortcodes, which are not WordPress native shortcodes, and thus are not handled by WP-AppKit. You can contact us at support [at] uncategorized-creations.com and we’ll try to guide you through this.Regarding mobix theme, it seems to be a WordPress (PHP) theme. It means it cannot be used as a WP-AppKit (JavaScript) theme as is. However, you probably could use it as a base, taking all HTML/CSS/JS files and re-create a WP-AppKit theme from them.
We can support you in the App creation process if you send us an email: you can read this post for more information about that. Also, you can find help on our website.
Happy App Coding,
LionelForum: Plugins
In reply to: [WP-AppKit - Mobile apps and PWA for WordPress] WP-AppKit and WooCommerceHi Sandra,
Thanks for your interest in WP-AppKit.
Regarding WooCommerce integration with WP-AppKit, short answer is: technically, it’s possible.To be honest, default themes embedded with the plugin are not meant to display products from a shop. Also, the whole cart system is not handled by default, and I’m not even talking about payment.
For all of these shop-related features, you will have to dig into WP-AppKit theme customization, meaning JavaScript/HTML/CSS development.
Of course, depending on the level of integration you want, this may be tricky, but not impossible.
WP-AppKit comes with native Custom Post Types support and a bunch of useful hooks to modify its API with what you need.I hope this helps, don’t hesitate to read the doc or contact us for any specific question.
Happy App Coding,
LionelThanks for our website, actually it’s a temporary version, still a bit buggy, but we’re working on it ;).
Regarding the new version, thank you to have deployed it, this worked for me: I was able to display percentages on axis for my Bar charts.
Thanks for your reply. Do you have any date planned to release this 1.4.3 version?
Could I help you somehow?Hi!
Same here, your plugin is great and very efficient.
I would also like to be able to format my vertical and horizontal axis labels with percentages for Bar charts. For now, I’m able to format tooltips, but not axis legend. 🙁Do you have any idea about the date you could release this improvement?
Thank you for all.
Forum: Fixing WordPress
In reply to: Assign Custom List Type to Custom Post TypeTom,
One way of doing it is to “hide” that filter (with CSS) or remove it with JS. Indeed, you can easily add an extra class to the body with ‘admin_body_class’ filter (depending on the $pagenow and $post_type global vars for example) to only target your CPT list.
To add one or more filters after those included by WordPress, you can use the ‘restrict_manage_posts’ action.
Unfortunately, I think that John is right on that, you cannot extend the list table classes for now.
Hope that helps.
LionelForum: Networking WordPress
In reply to: Pb with ajax requests and multiple themeHi Willy,
Some questions for you:
Can you tell us which WP version it is?
Are your themes custom ones or did you buy them somewhere? What are those themes?
I suppose your Ajax requests work well in the admin area? (for example, approve a comment)
Do you know the params sent with your request?