Skip to content

Commit

Permalink
Merge pull request #245 from 10up/feature/remove-media-option
Browse files Browse the repository at this point in the history
Remove media from language processing settings
  • Loading branch information
jeffpaul committed Oct 26, 2020
2 parents 403907e + c18fe6a commit 578c3d9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 39 deletions.
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

0 comments on commit 578c3d9

Please sign in to comment.