| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Conditionals; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Helpers\Product_Helper; |
| 6 |
|
| 7 |
/** |
| 8 |
* Conditional that is met when an older Yoast SEO Premium that predates the AI module restructure is active. |
| 9 |
* |
| 10 |
* Used to gate the legacy `src/ai-*` integrations and routes so they only run when an older Premium relies on them. |
| 11 |
*/ |
| 12 |
class Old_Premium_AI_Conditional implements Conditional { |
| 13 |
|
| 14 |
/** |
| 15 |
* The Premium version that ships with the new AI module structure. |
| 16 |
* |
| 17 |
* @var string |
| 18 |
*/ |
| 19 |
private const NEW_AI_STRUCTURE_PREMIUM_VERSION = '27.5-RC0'; |
| 20 |
|
| 21 |
/** |
| 22 |
* Holds the Product_Helper. |
| 23 |
* |
| 24 |
* @var Product_Helper |
| 25 |
*/ |
| 26 |
private $product_helper; |
| 27 |
|
| 28 |
/** |
| 29 |
* Constructs Old_Premium_AI_Conditional. |
| 30 |
* |
| 31 |
* @param Product_Helper $product_helper The Product_Helper. |
| 32 |
*/ |
| 33 |
public function __construct( Product_Helper $product_helper ) { |
| 34 |
$this->product_helper = $product_helper; |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Returns whether the legacy AI code paths should load. |
| 39 |
* |
| 40 |
* @return bool `true` when Premium is active and predates the AI restructure. |
| 41 |
*/ |
| 42 |
public function is_met() { |
| 43 |
if ( ! $this->product_helper->is_premium() ) { |
| 44 |
return false; |
| 45 |
} |
| 46 |
|
| 47 |
$premium_version = $this->product_helper->get_premium_version(); |
| 48 |
if ( $premium_version === null ) { |
| 49 |
return false; |
| 50 |
} |
| 51 |
|
| 52 |
return \version_compare( $premium_version, self::NEW_AI_STRUCTURE_PREMIUM_VERSION, '<' ); |
| 53 |
} |
| 54 |
} |
| 55 |
|