Skip to content

Commit

Permalink
Merge pull request #3749 from 10up/fix/deactivate-feature-in-draft
Browse files Browse the repository at this point in the history
Deactivate a feature that is only in draft
  • Loading branch information
felipeelia authored Nov 1, 2023
2 parents 41b9891 + 64a63c6 commit 47aa554
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions includes/classes/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,16 @@ public function deactivate_feature( $args, $assoc_args ) {
WP_CLI::error( esc_html__( 'No feature with that slug is registered', 'elasticpress' ) );
}

$active_features = Utils\get_option( 'ep_feature_settings', [] );
$active_features = (array) Features::factory()->get_feature_settings();
$active_features_draft = (array) Features::factory()->get_feature_settings_draft();

$key = array_search( $feature->slug, array_keys( $active_features ), true );
$key_current = array_search( $feature->slug, array_keys( $active_features ), true );
$key_draft = array_search( $feature->slug, array_keys( $active_features_draft ), true );

if ( false === $key || empty( $active_features[ $feature->slug ]['active'] ) ) {
$in_current = false !== $key_current && ! empty( $active_features[ $feature->slug ]['active'] );
$in_draft = false !== $key_draft && ! empty( $active_features_draft[ $feature->slug ]['active'] );

if ( ! $in_current && ! $in_draft ) {
WP_CLI::error( esc_html__( 'Feature is not active', 'elasticpress' ) );
}

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

cy.visitAdminPage('admin.php?page=elasticpress');
cy.get('#tab-panel-0-woocommerce').click();
cy.get('.components-form-toggle__input').should('be.checked');
});

Expand Down

0 comments on commit 47aa554

Please sign in to comment.