| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 4 |
namespace Yoast\WP\SEO\Plugins_Tab\User_Interface; |
| 5 |
|
| 6 |
use Yoast\WP\SEO\Conditionals\Admin_Conditional; |
| 7 |
use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 8 |
use Yoast\WP\SEO\Plugins_Tab\Application\Plugins_List_Handler; |
| 9 |
|
| 10 |
/** |
| 11 |
* Registers the Yoast tab on the WordPress Plugins screen. |
| 12 |
* |
| 13 |
* @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded |
| 14 |
*/ |
| 15 |
class Plugins_Tab_Integration implements Integration_Interface { |
| 16 |
|
| 17 |
/** |
| 18 |
* The plugins list handler. |
| 19 |
* |
| 20 |
* @var Plugins_List_Handler |
| 21 |
*/ |
| 22 |
private $handler; |
| 23 |
|
| 24 |
/** |
| 25 |
* Constructs the integration. |
| 26 |
* |
| 27 |
* @param Plugins_List_Handler $handler The plugins list handler. |
| 28 |
*/ |
| 29 |
public function __construct( Plugins_List_Handler $handler ) { |
| 30 |
$this->handler = $handler; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Returns the conditionals based on which this loadable should be active. |
| 35 |
* |
| 36 |
* @return array<string> The conditionals. |
| 37 |
*/ |
| 38 |
public static function get_conditionals(): array { |
| 39 |
return [ |
| 40 |
Admin_Conditional::class, |
| 41 |
]; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Registers the hooks for the Yoast plugins tab. |
| 46 |
* |
| 47 |
* @return void |
| 48 |
*/ |
| 49 |
public function register_hooks(): void { |
| 50 |
global $wp_version; |
| 51 |
|
| 52 |
if ( \version_compare( $wp_version, '7.0-alpha0', '<' ) ) { |
| 53 |
return; |
| 54 |
} |
| 55 |
|
| 56 |
\add_filter( 'plugins_list', [ $this->handler, 'filter_plugins_list' ] ); |
| 57 |
\add_filter( 'plugins_list_status_text', [ $this->handler, 'get_status_text' ], 10, 3 ); |
| 58 |
} |
| 59 |
} |
| 60 |
|