-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure post type and taxonomy options are filterable via existing filters in the new React settings #831
Conversation
@iamdharmesh thanks for the PR! Could you please fill out the PR template with description, changelog, and credits information so that we can properly review and merge this? |
'settings' => $this->get_settings(), | ||
'dashboardUrl' => admin_url( '/' ), | ||
'nonce' => wp_create_nonce( 'classifai-previewer-action' ), | ||
'postTypes' => $post_type_options, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be moved under features
, but since we are using the get_post_types_for_language_settings
helper function to retrieve post types, it has been kept here to continue using the same filter and avoid introducing unnecessary loop in the features data.
/* | ||
* Add NLU-specific taxonomies to the list if IBM Watson NLU is selected as the provider. | ||
* | ||
* This ensures that the NLU taxonomies are available in the settings, | ||
* as NLU-specific taxonomies are registered only if the Classification feature is enabled and IBM Watson NLU is selected as the provider. | ||
*/ | ||
if ( 'ibm_watson_nlu' === featureSettings.provider ) { | ||
Object.keys( nluTaxonomies ).forEach( ( taxonomy ) => { | ||
optionsObjects[ taxonomy ] = nluTaxonomies[ taxonomy ]; | ||
} ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since IBM Watson NLU-specific taxonomies are registered only when the Classification feature is enabled and IBM Watson NLU is selected as the provider (saved in the database), and the page is no longer being reloaded, this ensures that those taxonomies are available in the settings. Open to discussing better alternative approaches to this.
Description of the Change
This PR updates feature settings to ensure that the post type and taxonomy options are filterable via existing PHP filters. In the new React settings, these post types and taxonomy options were fetched using
wp.data
to enable easier filtration based on selections in the settings (e.g., hiding taxonomies of unchecked post types). However, as reported here, we identified that this JavaScript-based approach no longer supports the existing PHP filters. This PR revises how data is retrieved and used in the settings to maintain backward compatibility.How to test the Change
classifai_feature_classification_setting_taxonomies
filter in the Classification feature settings.classifai_language_settings_post_types
filter in the Classification, Excerpt Generation, and Text-to-Speech feature settings.classifai_feature_image_tags_generator_setting_taxonomies
filter in the Image Tags Generator feature settings.Changelog Entry
Credits
Props @dkotter, @iamdharmesh, @Sidsector9
Checklist: