Skip to content

Commit

Permalink
Merge pull request #20785 from Yoast/cleanup-unused-toggles-code
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsoo authored Oct 23, 2023
2 parents 009c121 + f6ccfd2 commit cfab584
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 265 deletions.
4 changes: 4 additions & 0 deletions config/dependency-injection/deprecated-classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
use Yoast\WP\SEO\Integrations\Schema_Blocks;
use Yoast\WP\SEO\Integrations\Third_Party\CoAuthors_Plus;
use Yoast\WP\SEO\Integrations\Third_Party\The_Events_Calendar;
use Yoast\WP\SEO\Integrations\Third_Party\Wincher;
use Yoast\WP\SEO\Integrations\Third_Party\Wordproof_Integration_Toggle;
use Yoast\WP\SEO\Routes\Indexables_Page_Route;
use Yoast\WP\SEO\Schema_Templates\Assets\Icons;

Expand All @@ -56,6 +58,8 @@
Schema_Blocks::class => '20.5',
Icons::class => '20.5',
Old_Premium_Integration::class => '20.10',
Wincher::class => '21.6',
Wordproof_Integration_Toggle::class => '21.6',
];

foreach ( $deprecated_classes as $original_class => $version ) {
Expand Down
8 changes: 0 additions & 8 deletions packages/js/src/initializers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,6 @@ export default function initAdmin( jQuery ) {
}
} ).trigger( "change" );

// Toggle the Wincher section.
jQuery( "#wincher_integration_active input[type='radio']" ).on( "change", function() {
// The value on is enabled, off is disabled.
if ( jQuery( this ).is( ":checked" ) ) {
jQuery( "#wincher-connection" ).toggle( jQuery( this ).val() === "on" );
}
} ).trigger( "change" );

// Handle the settings pages tabs.
jQuery( "#wpseo-tabs" ).find( "a" ).on( "click", function( event ) {
var canChangeTab = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

/**
* Adds the Wincher integration.
*
* @deprecated 21.6
* @codeCoverageIgnore
*/
class Wincher implements Integration_Interface {

Expand All @@ -22,6 +25,9 @@ class Wincher implements Integration_Interface {
/**
* The Wincher integration toggle constructor.
*
* @deprecated 21.6
* @codeCoverageIgnore
*
* @param Wincher_Helper $wincher The Wincher helper instance.
*/
public function __construct( Wincher_Helper $wincher ) {
Expand All @@ -31,23 +37,21 @@ public function __construct( Wincher_Helper $wincher ) {
/**
* Initializes the integration.
*
* @deprecated 21.6
* @codeCoverageIgnore
*
* @return void
*/
public function register_hooks() {
/**
* Called by Yoast_Integration_Toggles to add extra toggles to the ones defined there.
*/
\add_filter( 'wpseo_integration_toggles', [ $this, 'add_integration_toggle' ] );

/**
* Add extra text after the network integration toggle if the toggle is disabled.
*/
\add_action( 'Yoast\WP\SEO\admin_network_integration_after', [ $this, 'after_network_integration_toggle' ] );
\_deprecated_function( __METHOD__, 'Yoast SEO 21.6' );
}

/**
* Returns the conditionals based in which this loadable should be active.
*
* @deprecated 21.6
* @codeCoverageIgnore
*
* @return array The conditionals.
*/
public static function get_conditionals() {
Expand All @@ -57,69 +61,40 @@ public static function get_conditionals() {
/**
* Adds the Wincher integration toggle to the $integration_toggles array.
*
* @deprecated 21.6
* @codeCoverageIgnore
*
* @param array $integration_toggles The integration toggles array.
*
* @return array The updated integration toggles array.
*/
public function add_integration_toggle( $integration_toggles ) {
if ( \is_array( $integration_toggles ) ) {
$integration_toggles[] = (object) [
/* translators: %s: 'Wincher' */
'name' => \sprintf( \__( '%s integration', 'wordpress-seo' ), 'Wincher' ),
'setting' => 'wincher_integration_active',
'label' => \sprintf(
/* translators: %s: 'Wincher' */
\__( 'The %s integration offers the option to track specific keyphrases and gain insights in their positions.', 'wordpress-seo' ),
'Wincher'
),
'order' => 11,
'disabled' => \is_multisite(),
];
}
\_deprecated_function( __METHOD__, 'Yoast SEO 21.6' );

return $integration_toggles;
}

/**
* Adds the disabled note when the integration toggle is disabled.
*
* @deprecated 20.3
* @deprecated 21.6
* @codeCoverageIgnore
*
* @param Yoast_Feature_Toggle $integration The integration toggle class.
*/
public function after_integration_toggle( $integration ) {
\_deprecated_function( __METHOD__, 'Yoast SEO 20.3' );
if ( $integration->setting === 'wincher_integration_active' ) {
if ( \is_multisite() ) {
$this->get_disabled_note();
}
}
\_deprecated_function( __METHOD__, 'Yoast SEO 21.6' );
}

/**
* Adds the disabled note to the network integration toggle.
*
* @param Yoast_Feature_Toggle $integration The integration toggle class.
*/
public function after_network_integration_toggle( $integration ) {
if ( $integration->setting === 'wincher_integration_active' ) {
$this->get_disabled_note();
}
}

/**
* Outputs the disabled note.
*
* @deprecated 21.6
* @codeCoverageIgnore
*
* @return void
* @param Yoast_Feature_Toggle $integration The integration toggle class.
*/
protected function get_disabled_note() {
echo '<p>', \sprintf(
/* translators: %s expands to Wincher */
\esc_html__( 'Currently, the %s integration is not available for multisites.', 'wordpress-seo' ),
'Wincher'
), '</p>';
public function after_network_integration_toggle( $integration ) {
\_deprecated_function( __METHOD__, 'Yoast SEO 21.6' );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
/**
* Class WordProofIntegrationToggle.
*
* @deprecated 21.6
* @codeCoverageIgnore
*
* @package Yoast\WP\SEO\Integrations\Third_Party
*/
class Wordproof_Integration_Toggle implements Integration_Interface {
Expand All @@ -24,6 +27,9 @@ class Wordproof_Integration_Toggle implements Integration_Interface {
/**
* The WordProof integration toggle constructor.
*
* @deprecated 21.6
* @codeCoverageIgnore
*
* @param Wordproof_Helper $wordproof The WordProof helper instance.
*/
public function __construct( Wordproof_Helper $wordproof ) {
Expand All @@ -33,6 +39,9 @@ public function __construct( Wordproof_Helper $wordproof ) {
/**
* Returns the conditionals based in which this loadable should be active.
*
* @deprecated 21.6
* @codeCoverageIgnore
*
* @return array
*/
public static function get_conditionals() {
Expand All @@ -44,51 +53,27 @@ public static function get_conditionals() {
*
* This is the place to register hooks and filters.
*
* @deprecated 21.6
* @codeCoverageIgnore
*
* @return void
*/
public function register_hooks() {
/**
* Called by Yoast_Integration_Toggles to add extra toggles to the ones defined there.
*/
\add_filter( 'wpseo_integration_toggles', [ $this, 'add_integration_toggle' ] );

/**
* Update the default wordproof_integration_active depending if the integration is disabled or not.
*/
\add_filter( 'wpseo_option_wpseo_defaults', [ $this, 'default_values' ] );

/**
* Add extra text after the network integration toggle if the toggle is disabled.
*/
\add_action( 'Yoast\WP\SEO\admin_network_integration_after', [ $this, 'after_network_integration_toggle' ] );
\_deprecated_function( __METHOD__, 'Yoast SEO 21.6' );
}

/**
* Adds the WordProof integration toggle to the array.
*
* @deprecated 21.6
* @codeCoverageIgnore
*
* @param array $integration_toggles The integration toggles array.
*
* @return array The updated integration toggles array.
*/
public function add_integration_toggle( $integration_toggles ) {
if ( \is_array( $integration_toggles ) ) {
$integration_toggles[] = (object) [
/* translators: %s expands to WordProof */
'name' => \sprintf( \__( '%s integration', 'wordpress-seo' ), 'WordProof' ),
'setting' => 'wordproof_integration_active',
'label' => \sprintf(
/* translators: %s expands to WordProof */
\__( '%1$s can be used to timestamp your privacy page.', 'wordpress-seo' ),
'WordProof'
),
/* translators: %s expands to WordProof */
'read_more_label' => \sprintf( \__( 'Read more about how %s works.', 'wordpress-seo' ), 'WordProof ' ),
'read_more_url' => 'https://yoa.st/wordproof-integration',
'order' => 16,
'disabled' => $this->wordproof->integration_is_disabled(),
'new' => true,
];
}
\_deprecated_function( __METHOD__, 'Yoast SEO 21.6' );

return $integration_toggles;
}
Expand Down Expand Up @@ -144,14 +129,6 @@ public function after_integration_toggle( $integration ) {
* @param Yoast_Feature_Toggle $integration The integration toggle class.
*/
public function after_network_integration_toggle( $integration ) {
if ( $integration->setting === 'wordproof_integration_active' ) {
if ( $integration->disabled ) {
echo '<p>' . \sprintf(
/* translators: %s expands to WordProof */
\esc_html__( 'Currently, the %s integration is not available for multisites.', 'wordpress-seo' ),
'WordProof'
) . '</p>';
}
}
\_deprecated_function( __METHOD__, 'Yoast SEO 21.6' );
}
}
Loading

0 comments on commit cfab584

Please sign in to comment.