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

Hide Comments and Terms by default #3691

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"wp-content/plugins/filter-instant-results-per-page.php": "./tests/cypress/wordpress-files/test-plugins/filter-instant-results-per-page.php",
"wp-content/plugins/filter-instant-results-args-schema.php": "./tests/cypress/wordpress-files/test-plugins/filter-instant-results-args-schema.php",
"wp-content/plugins/filter-autosuggest-navigate-callback.php": "./tests/cypress/wordpress-files/test-plugins/filter-autosuggest-navigate-callback.php",
"wp-content/plugins/show-comments-and-terms.php": "./tests/cypress/wordpress-files/test-plugins/show-comments-and-terms.php",
"wp-content/uploads/content-example.xml": "./tests/cypress/wordpress-files/test-docs/content-example.xml"
}
}
Expand Down
7 changes: 7 additions & 0 deletions includes/classes/Feature/Comments/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
* Comments feature class
*/
class Comments extends Feature {
/**
* Whether the feature should be always visible in the dashboard
*
* @since 5.0.0
* @var boolean
*/
protected $is_visible = false;

/**
* Initialize feature, setting it's config
Expand Down
7 changes: 7 additions & 0 deletions includes/classes/Feature/Terms/Terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
* Terms feature class
*/
class Terms extends Feature {
/**
* Whether the feature should be always visible in the dashboard
*
* @since 5.0.0
* @var boolean
*/
protected $is_visible = false;

/**
* Initialize feature, setting it's config
Expand Down
1 change: 1 addition & 0 deletions tests/cypress/integration/features/comments.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Comments Feature', { tags: '@slow' }, () => {
cy.get('#comment_previously_approved').check();
cy.get('#submit').click();
cy.maybeEnableFeature('comments');
cy.activatePlugin('show-comments-and-terms', 'wpCli');
});

/**
Expand Down
1 change: 1 addition & 0 deletions tests/cypress/integration/features/terms.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('Terms Feature', { tags: '@slow' }, () => {

before(() => {
cy.visitAdminPage('edit-tags.php?taxonomy=post_tag');
cy.activatePlugin('show-comments-and-terms', 'wpCli');

/**
* Delete all tags.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Plugin Name: Make Comments and Terms features visible
* Version: 1.0.0
* Author: 10up Inc.
* License: GPLv2 or later
*
* @package ElasticPress_Tests_E2e
*/

add_filter(
'ep_feature_is_visible',
function ( $is_visible, $feature_slug ) {
return in_array( $feature_slug, [ 'comments', 'terms' ], true ) ? true : $is_visible;
},
10,
2
);
16 changes: 8 additions & 8 deletions tests/php/features/TestComments.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ public function testRequirementsStatus() {
* @group comments
*/
public function testIsVisible() {
$this->assertTrue( $this->get_feature()->is_visible() );
$this->assertFalse( $this->get_feature()->is_visible() );

$change_visibility = function ( $is_visible, $feature_slug, $feature ) {
$this->assertTrue( $is_visible );
$this->assertFalse( $is_visible );
$this->assertSame( 'comments', $feature_slug );
$this->assertInstanceOf( '\ElasticPress\Feature\Comments\Comments', $feature );
return false;
return true;
};
add_filter( 'ep_feature_is_visible', $change_visibility, 10, 3 );

$this->assertFalse( $this->get_feature()->is_visible() );
$this->assertTrue( $this->get_feature()->is_visible() );
}

/**
Expand All @@ -188,16 +188,16 @@ public function testIsVisible() {
* @group comments
*/
public function testIsAvailable() {
$this->assertTrue( $this->get_feature()->is_available() );
$this->assertFalse( $this->get_feature()->is_available() );

$change_availability = function ( $is_available, $feature_slug, $feature ) {
$this->assertTrue( $is_available );
$this->assertFalse( $is_available );
$this->assertSame( 'comments', $feature_slug );
$this->assertInstanceOf( '\ElasticPress\Feature\Comments\Comments', $feature );
return false;
return true;
};
add_filter( 'ep_feature_is_available', $change_availability, 10, 3 );

$this->assertFalse( $this->get_feature()->is_available() );
$this->assertTrue( $this->get_feature()->is_available() );
}
}
Loading