From ba7d103b61b1bd1a52087768a9661589c60c5b09 Mon Sep 17 00:00:00 2001 From: Darin Kotter Date: Thu, 22 Oct 2020 15:03:39 -0600 Subject: [PATCH 1/3] Add new helper function to build out the list of post types we want to show in our language processing settings. Remove attachments from this list by default --- includes/Classifai/Helpers.php | 28 +++++++++++++++++++++ includes/Classifai/Providers/Watson/NLU.php | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/includes/Classifai/Helpers.php b/includes/Classifai/Helpers.php index efc292355..c2bd9ecb3 100644 --- a/includes/Classifai/Helpers.php +++ b/includes/Classifai/Helpers.php @@ -171,6 +171,34 @@ function get_watson_password() { } } +/** + * Get post types we want to show in the language processing settings + * + * @since 1.6.0 + * + * @return array + */ +function get_post_types_for_language_settings() { + $post_types = get_post_types( [ 'public' => true ], 'objects' ); + + // Remove the attachment post type + unset( $post_types['attachment'] ); + + /** + * Filter post types shown in language processing settings. + * + * @since 1.6.0 + * @hook classifai_language_settings_post_types + * + * @param {array} $post_types Array of post types to show in language processing settings. + * + * @return {array} Array of post types. + */ + $post_types = apply_filters( 'classifai_language_settings_post_types', $post_types ); + + return $post_types; +} + /** * The list of post types that get the ClassifAI taxonomies. Defaults * to 'post'. diff --git a/includes/Classifai/Providers/Watson/NLU.php b/includes/Classifai/Providers/Watson/NLU.php index ef789ba47..2e39ca04c 100644 --- a/includes/Classifai/Providers/Watson/NLU.php +++ b/includes/Classifai/Providers/Watson/NLU.php @@ -8,6 +8,7 @@ use Classifai\Admin\SavePostHandler; use Classifai\Providers\Provider; use Classifai\Taxonomy\TaxonomyFactory; +use function Classifai\get_post_types_for_language_settings; class NLU extends Provider { @@ -390,7 +391,7 @@ class="" */ public function render_post_types_checkboxes( $args ) { echo '