| 1 |
<?php // phpcs:ignore Yoast.Files.FileName.InvalidClassFileName -- Reason: this explicitly concerns the Yoast admin. |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Conditionals\Admin; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Conditionals\Conditional; |
| 6 |
use Yoast\WP\SEO\Helpers\Current_Page_Helper; |
| 7 |
|
| 8 |
/** |
| 9 |
* Conditional that is only met when on a Yoast SEO admin page. |
| 10 |
*/ |
| 11 |
class Yoast_Admin_Conditional implements Conditional { |
| 12 |
|
| 13 |
/** |
| 14 |
* Holds the Current_Page_Helper. |
| 15 |
* |
| 16 |
* @var Current_Page_Helper |
| 17 |
*/ |
| 18 |
private $current_page_helper; |
| 19 |
|
| 20 |
/** |
| 21 |
* Constructs the conditional. |
| 22 |
* |
| 23 |
* @param Current_Page_Helper $current_page_helper The current page helper. |
| 24 |
*/ |
| 25 |
public function __construct( Current_Page_Helper $current_page_helper ) { |
| 26 |
$this->current_page_helper = $current_page_helper; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Returns `true` when on the admin dashboard, update or Yoast SEO pages. |
| 31 |
* |
| 32 |
* @return bool `true` when on the admin dashboard, update or Yoast SEO pages. |
| 33 |
*/ |
| 34 |
public function is_met() { |
| 35 |
if ( ! \is_admin() ) { |
| 36 |
return false; |
| 37 |
} |
| 38 |
|
| 39 |
return $this->current_page_helper->is_yoast_seo_page(); |
| 40 |
} |
| 41 |
} |
| 42 |
|