PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.6
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / plans / infrastructure / add-ons / managed-add-on.php

managed-add-on.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.6, at src/plans/infrastructure/add-ons/managed-add-on.php

63 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4 namespace Yoast\WP\SEO\Plans\Infrastructure\Add_Ons;
5
6 use InvalidArgumentException;
7 use WPSEO_Addon_Manager;
8 use Yoast\WP\SEO\Plans\Domain\Add_Ons\Add_On_Interface;
9
10 /**
11 * Represents a managed add-on.
12 * Uses the WPSEO_Addon_Manager to check if the add-on is installed and activated, and if it has a valid license.
13 */
14 abstract class Managed_Add_On implements Add_On_Interface {
15
16 /**
17 * The slug of the add-on.
18 *
19 * @var string
20 */
21 protected const SLUG = '';
22
23 /**
24 * Holds the WPSEO_Addon_Manager.
25 *
26 * @var WPSEO_Addon_Manager
27 */
28 private $addon_manager;
29
30 /**
31 * Constructs the instance.
32 *
33 * @param WPSEO_Addon_Manager $addon_manager The WPSEO_Addon_Manager.
34 *
35 * @throws InvalidArgumentException If the slug is not set.
36 */
37 public function __construct( WPSEO_Addon_Manager $addon_manager ) {
38 if ( static::SLUG === '' ) {
39 throw new InvalidArgumentException( 'The add-on slug must be set.' );
40 }
41
42 $this->addon_manager = $addon_manager;
43 }
44
45 /**
46 * Returns whether the add-on is installed and activated.
47 *
48 * @return bool
49 */
50 public function is_active(): bool {
51 return $this->addon_manager->is_installed( static::SLUG );
52 }
53
54 /**
55 * Returns whether the add-on has an valid license.
56 *
57 * @return bool
58 */
59 public function has_license(): bool {
60 return $this->addon_manager->has_valid_subscription( static::SLUG );
61 }
62 }
63