 JasonB1
|
Hi Guys,
I think I may have found a slight bug with WP 3.5 and the get_ls_languages function of the main SitePress class, and I just wanted to let you guys know about it.
I have a plugin where I register different sets of options based on the WPML languages the user has setup, and so I have a function that is hooked to admin_init where I call icl_get_languages.
function my_options(){
$langs = icl_get_languages();
// do stuff with $langs...
}
add_action( 'admin_init', 'my_options' );
Since upgrading to WP 3.5, any page in the admin panel that has a query of posts is now broken. For example, when I go to the "Posts" admin panel, it tells me there are no posts on my site (see attached screenshot).
So, I had a look at the get_ls_languages of the SitePress class, and it appears to be some kind of issue with how the query is being reset after determining the languages. I was able to fix the issue from my plugin by calling wp_reset_query after retrieving the languages:
function my_options(){
$langs = icl_get_languages();
wp_reset_query();
// do stuff with $langs...
}
add_action( 'admin_init', 'my_options' );
|
 Harshad
|
Dear Jason,
Thanks for sharing this information, I will pass this information to our development team and check it gets fixed.
|
 JasonB1
|
So after the upgrade to v2.6.3, it appears the icl_get_languages function no longer works within the admin panel at all. It simply returns a blank array no matter where it's hooked in.
This is how I'm able to retrieve the languages in v2.6.3, but I'm not sure if making icl_get_languages not work was WPML's intention.
function example(){
global $sitepress;
$langs = $sitepress->get_active_languages();
}
add_action( 'admin_init', 'example' );
|
 Harshad
|
We have updated the get_ls_languages function of the main SitePress class.
|
 johan
|
Hello!
Is the new behaviour of icl_get_languages (not returning languages inside admin panel) intended or is it a bug?
If intended: Is JasonB1's method the recommended way to retrieve languages?
Need to know, one of my plugins uses icl_get_languages and will stop working if I upgrade!
best regards Johan Linderoth
|