WPML support
-
Hi DoubleSharp,,
I have added WPML support to the unique-option of this plugin. Since I was unable to add a file here I sent you an email to your info-address.
Please consider adding this to the mainstream version of your plugin.
Thanks!
Günther
-
I just got an error message back from your info-email-address….. here is a copy & paste version of the DIFF
213c213 < --- > 217,228d216 < < // get code list of active languages < if (function_exists('icl_object_id')) { < $languages = $wpdb->get_results("SELECT code FROM {$wpdb->prefix}icl_languages WHERE active = 1", ARRAY_A); < $wpml_ids = array(); < foreach($languages as $lang) < $wpml_ids[] = (int)icl_object_id($post_id, $post_type, true, $lang['code']); < $post_ids = implode(",", array_unique($wpml_ids)); < } else { < $post_ids = (int)$post_id; < } < 231c219 < switch ( $unique ) { --- > switch ( $unique ){ 235c223,224 < "{$sql_prefix} AND post_id NOT IN ({$post_ids}) WHERE meta_value = %s", --- > "{$sql_prefix} AND post_id != %d WHERE meta_value = %s", > $post_id, 242c231 < "{$sql_prefix} AND p.post_type = %s AND post_id NOT IN ({$post_ids}) WHERE meta_value = %s", --- > "{$sql_prefix} AND p.post_type = %s AND post_id != %d WHERE meta_value = %s", 243a233 > $post_id, 251a242 > $sql = "{$sql_prefix} AND p.post_type = %s WHERE ( ( post_id = %d AND meta_key != %s AND meta_key LIKE %s ) OR ( post_id != %d AND meta_key LIKE %s ) ) AND meta_value = %s"; 253c244 < "{$sql_prefix} AND p.post_type = %s WHERE ( ( post_id = %d AND meta_key != %s AND meta_key LIKE %s ) OR ( post_id NOT IN ({$post_ids}) AND meta_key LIKE %s ) ) AND meta_value = %s", --- > "{$sql_prefix} AND p.post_type = %s WHERE ( ( post_id = %d AND meta_key != %s AND meta_key LIKE %s ) OR ( post_id != %d AND meta_key LIKE %s ) ) AND meta_value = %s", 257a249 > $post_id, 263c255 < "{$sql_prefix} AND p.post_type = %s AND post_id NOT IN ({$post_ids}) WHERE meta_key = %s AND meta_value = %s", --- > "{$sql_prefix} AND p.post_type = %s AND post_id != %d WHERE meta_key = %s AND meta_value = %s", 264a257 > $post_id,
Thanks! I’ll see if I can get it merged into the next version. Would you be able to test it out as I don’t have any WPML sites?
It’s not easy to share with the WordPress svn repo, so i might set up a github repo as well for pull requests like these. I’ll post the info if I do.
Thanks also for catching the email issue… Not sure what went wrong but it should be working now (if you used info@doublesharp).
Hi!
Sure, just let me know and I’ll test it. Btw. I sent you an email as well (and didn’t get an error back this time), so you can update me that way. Whatever is more convenient to you.
Cheers
Günther
Hi Günther,
Finally got a chance to merge your code. Some other changes had been made to the plugin as well, so I had to modify your code a bit. I was able to test the non-WPML version just passing
array( (int) $post_id )
which works, so I suspect the WPML version will as well. The other change I made was to pass theNOT IN
values through$wpml->prepare()
viacall_user_func_array()
. Please let me know how it works for you.Hi Justin,
on little issue on line 330 – you’ll have to change:
$post_ids = implode( ',', array_unique( $wpml_ids ) );
to
$post_ids = array_unique( $wpml_ids );
now I’ll give it a try and let you know!
Cheers
Günther
This is resolved in the master build on GitHub: https://github.com/doublesharp/validated-field-for-acf/archive/master.zip
Marking resolved as a new version is imminent.
@gunnyst can you please validate that Validated Field 3.4 Beta is compatible with WPML? Thanks!
Hi Justin, currently I’m no longer working on the site where I had this running together with WPML, so I’m now unable to test this in any useful manner. But maybe someone else can jump in? I do guess WPML is quite wide-spread…
- The topic ‘WPML support’ is closed to new replies.