Skip to content
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

Merged
merged 6 commits into from
Dec 11, 2024

Conversation

iamdharmesh
Copy link
Member

@iamdharmesh iamdharmesh commented Dec 11, 2024

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

  1. Verify that taxonomies are now filterable via the classifai_feature_classification_setting_taxonomies filter in the Classification feature settings.
  2. Verify that post types are now filterable via the classifai_language_settings_post_types filter in the Classification, Excerpt Generation, and Text-to-Speech feature settings.
  3. Verify that tag taxonomies are now filterable via the classifai_feature_image_tags_generator_setting_taxonomies filter in the Image Tags Generator feature settings.
  4. Confirm that all the above feature settings function as expected.

Changelog Entry

Fixed - Ensure post type and taxonomy options are filterable via existing filters in the new React settings

Credits

Props @dkotter, @iamdharmesh, @Sidsector9

Checklist:

@iamdharmesh iamdharmesh requested review from dkotter, jeffpaul and a team as code owners December 11, 2024 13:48
@github-actions github-actions bot added this to the 3.2.0 milestone Dec 11, 2024
@github-actions github-actions bot added the needs:feedback This requires reporter feedback to better understand the request. label Dec 11, 2024
Copy link

@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?

@iamdharmesh iamdharmesh marked this pull request as draft December 11, 2024 13:49
@github-actions github-actions bot removed the needs:feedback This requires reporter feedback to better understand the request. label Dec 11, 2024
@iamdharmesh iamdharmesh changed the title [F] Ensure post type and taxonomy options are filterable via existing filters in the new React settings Dec 11, 2024
'settings' => $this->get_settings(),
'dashboardUrl' => admin_url( '/' ),
'nonce' => wp_create_nonce( 'classifai-previewer-action' ),
'postTypes' => $post_type_options,
Copy link
Member Author

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.

Comment on lines +64 to +74
/*
* 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 ];
} );
}
Copy link
Member Author

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.

@iamdharmesh iamdharmesh marked this pull request as ready for review December 11, 2024 14:33
@github-actions github-actions bot added the needs:code-review This requires code review. label Dec 11, 2024
@dkotter dkotter merged commit 7cebdf1 into develop Dec 11, 2024
19 checks passed
@dkotter dkotter deleted the fix/filters branch December 11, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants