-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Hello!
First of all – great work with this plugin. It solved some issues really quick and easy. Thank you for creating it.
But we have encountered a bug when using Polylang Pro, WP API Polylang and Yoast SEO Premium (not Yoast SEO).
When editing a post then Yoast SEO Premium calls some REST-related functions that triggers the "rest_api_init"-event. Then the function "polylang_json_api_init" (located in the WP API Polylang-plugin) gets executed. This function then looks for a "lang"-parameter which it cannot find one and then falls back to the default language. Then the wrong language gets selected when editing a post in a non-default language. In our case this affected the term selection metabox for both custom and native taxonomies. None of the terms stay selected, even tho they are stored in the database.
How to trigger the bug:
- Install Yoast SEO Premium, Polylang Pro and WP API Polylang
- Set up Polylang, add a primary language + an additional language
- Create terms in the category taxonomy
- Create a post in the additional language
- Selecting terms for the newly created post and save
The terms will then not be shown as selected, but stored correctly in the database.
We solved this by adding this mu-plugin:
/**
* Disable the WP API Polylang functionality when using WP Admin.
*/
add_action('rest_api_init', function() {
if ( is_admin() ) {
remove_action( 'rest_api_init', 'polylang_json_api_init' );
}
}, 1 );
As far as I see this can be solved multiple ways:
- Implement parts of the code in the snippet above
- Change the plugin to use a different action than "rest_api_init"
What do you think? :)