Skip to content

Commit

Permalink
Merge pull request #21465 from Yoast/1667-fix-deprecation
Browse files Browse the repository at this point in the history
Deprecate old introduction and fix deprecation messages
  • Loading branch information
vraja-pro committed Jul 8, 2024
2 parents b961a40 + 7caba1d commit e5483f9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 22 deletions.
20 changes: 11 additions & 9 deletions config/dependency-injection/deprecated-classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@
use Yoast\WP\SEO\Integrations\Third_Party\Wincher;
use Yoast\WP\SEO\Integrations\Third_Party\Wordproof;
use Yoast\WP\SEO\Integrations\Third_Party\Wordproof_Integration_Toggle;
use Yoast\WP\SEO\Introductions\Application\Ai_Generate_Titles_And_Descriptions_Introduction_Upsell;

$deprecated_classes = [
Old_Premium_Integration::class => '20.10',
Wincher::class => '21.6',
Wordproof_Integration_Toggle::class => '21.6',
Wordproof::class => '22.10',
Wordproof_Integration_Active_Conditional::class => '22.10',
Wordproof_Plugin_Inactive_Conditional::class => '22.10',
Wordproof_App_Config::class => '22.10',
Wordproof_Translations::class => '22.10',
Wordproof_Helper::class => '22.10',
Old_Premium_Integration::class => '20.10',
Wincher::class => '21.6',
Wordproof_Integration_Toggle::class => '21.6',
Wordproof::class => '22.10',
Wordproof_Integration_Active_Conditional::class => '22.10',
Wordproof_Plugin_Inactive_Conditional::class => '22.10',
Wordproof_App_Config::class => '22.10',
Wordproof_Translations::class => '22.10',
Wordproof_Helper::class => '22.10',
Ai_Generate_Titles_And_Descriptions_Introduction_Upsell::class => '23.2',
];

foreach ( $deprecated_classes as $original_class => $version ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
<?php
/**
* Graceful deprecation of the Ai_Generate_Titles_And_Descriptions_Introduction_Upsell class.
*
* {@internal As this file is just (temporarily) put in place to warn extending
* plugins about the class name changes, it is exempt from select CS standards.}
*
* @deprecated 23.2
*
* @codeCoverageIgnore
*
* @phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound
* @phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound
* @phpcs:disable Yoast.Commenting.CodeCoverageIgnoreDeprecated
* @phpcs:disable Yoast.Commenting.FileComment.Unnecessary
* @phpcs:disable Yoast.Files.FileName.InvalidClassFileName
*/

namespace Yoast\WP\SEO\Introductions\Application;

use Yoast\WP\SEO\Helpers\Options_Helper;
use Yoast\WP\SEO\Helpers\Product_Helper;
use Yoast\WP\SEO\Introductions\Domain\Introduction_Interface;

/**
* Represents the introduction for the AI generate titles and introduction upsell.
*
* @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
* @deprecated 23.2 Use {@see \Yoast\WP\SEO\Introductions\Application\Ai_Fix_Assessments_Upsell} instead.
*/
class Ai_Generate_Titles_And_Descriptions_Introduction_Upsell implements Introduction_Interface {
class Ai_Generate_Titles_And_Descriptions_Introduction_Upsell extends Ai_Fix_Assessments_Upsell {

use Current_Page_Trait;
use User_Allowed_Trait;
Expand All @@ -34,6 +49,8 @@ class Ai_Generate_Titles_And_Descriptions_Introduction_Upsell implements Introdu
/**
* Constructs the introduction.
*
* @deprecated 23.2
*
* @param Product_Helper $product_helper The product helper.
* @param Options_Helper $options_helper The options' helper.
*/
Expand All @@ -48,13 +65,13 @@ public function __construct(
/**
* Returns the ID.
*
* @deprecated 23.0
* @deprecated 23.2
* @codeCoverageIgnore
*
* @return string
*/
public function get_id() {
\_deprecated_function( __METHOD__, 'Yoast SEO 23.0' );
\_deprecated_function( __METHOD__, 'Yoast SEO 23.2' );
return 'ai-generate-titles-and-descriptions-upsell';
}

Expand All @@ -75,26 +92,26 @@ public function get_name() {
/**
* Returns the requested pagination priority. Lower means earlier.
*
* @deprecated 23.0
* @deprecated 23.2
* @codeCoverageIgnore
*
* @return int
*/
public function get_priority() {
\_deprecated_function( __METHOD__, 'Yoast SEO 23.0' );
\_deprecated_function( __METHOD__, 'Yoast SEO 23.2' );
return 10;
}

/**
* Returns whether this introduction should show.
*
* @deprecated 23.0
* @deprecated 23.2
* @codeCoverageIgnore
*
* @return bool
*/
public function should_show() {
\_deprecated_function( __METHOD__, 'Yoast SEO 23.0' );
\_deprecated_function( __METHOD__, 'Yoast SEO 23.2' );
// Outdated feature introduction.
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/introductions/application/ai-fix-assessments-upsell.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct( User_Helper $user_helper, Product_Helper $product_h
*
* @return string The ID.
*/
public function get_id(): string {
public function get_id() {
return self::ID;
}

Expand All @@ -55,7 +55,7 @@ public function get_id(): string {
*
* @return string The name.
*/
public function get_name(): string {
public function get_name() {
\_deprecated_function( __METHOD__, 'Yoast SEO Premium 21.6', 'Please use get_id() instead' );

return self::ID;
Expand All @@ -66,7 +66,7 @@ public function get_name(): string {
*
* @return int The priority.
*/
public function get_priority(): int {
public function get_priority() {
return 10;
}

Expand All @@ -75,7 +75,7 @@ public function get_priority(): int {
*
* @return bool Whether this introduction should show.
*/
public function should_show(): bool {
public function should_show() {

if ( $this->product_helper->is_premium() ) {
return false;
Expand Down

0 comments on commit e5483f9

Please sign in to comment.