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

Remove media from language processing settings #245

Merged
merged 5 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions includes/Classifai/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,32 @@ 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.
*/
return apply_filters( 'classifai_language_settings_post_types', $post_types );
}

/**
* The list of post types that get the ClassifAI taxonomies. Defaults
* to 'post'.
Expand Down
3 changes: 2 additions & 1 deletion includes/Classifai/Providers/Watson/NLU.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -390,7 +391,7 @@ class="<?php echo esc_attr( $class ); ?>"
*/
public function render_post_types_checkboxes( $args ) {
echo '<ul>';
$post_types = get_post_types( [ 'public' => true ], 'objects' );
$post_types = get_post_types_for_language_settings();
foreach ( $post_types as $post_type ) {
$args = [
'label_for' => $post_type->name,
Expand Down
38 changes: 0 additions & 38 deletions tests/e2e/wpacceptance/NaturalLanguageProcessing.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,44 +187,6 @@ public function testTogglePage() {

}

/**
* @testdox When the user enables/disables Media under Post Types to Classify, it shows/hides Watson Keywords and other submenus under Media menu.
*/
public function testToggleMedia() {

$I = $this->openBrowserPage();

$I->login();

$I->moveTo( 'wp-admin/upload.php' );

$I->dontSeeLink( 'Watson Categories', 'edit-tags.php?taxonomy=watson-category&post_type=attachment' );

$I->dontSeeLink( 'Watson Keywords', 'edit-tags.php?taxonomy=watson-keyword&post_type=attachment' );

$I->dontSeeLink( 'Watson Concepts', 'edit-tags.php?taxonomy=watson-concept&post_type=attachment' );

$I->dontSeeLink( 'Watson Entities', 'edit-tags.php?taxonomy=watson-entity&post_type=attachment' );

$I->moveTo( 'wp-admin/admin.php?page=language_processing' );

$I->checkOptions( '#classifai-settings-attachment' );

$I->click( '#submit' );

$I->waitUntilNavigation();

$I->moveTo( 'wp-admin/upload.php' );

$I->seeLink( 'Watson Categories', 'edit-tags.php?taxonomy=watson-category&post_type=attachment' );

$I->seeLink( 'Watson Keywords', 'edit-tags.php?taxonomy=watson-keyword&post_type=attachment' );

$I->seeLink( 'Watson Concepts', 'edit-tags.php?taxonomy=watson-concept&post_type=attachment' );

$I->seeLink( 'Watson Entities', 'edit-tags.php?taxonomy=watson-entity&post_type=attachment' );
}

public function testWatsonWorks() {
$I = $this->openBrowserPage();

Expand Down