PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.8
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.8
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 / conditionals / primary-category-conditional.php

primary-category-conditional.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.8, at src/conditionals/primary-category-conditional.php

43 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Conditionals;
4
5 use Yoast\WP\SEO\Helpers\Current_Page_Helper;
6
7 /**
8 * Conditional that is only met when in frontend or page is a post overview or post add/edit form.
9 */
10 class Primary_Category_Conditional implements Conditional {
11
12 /**
13 * The current page helper.
14 *
15 * @var Current_Page_Helper
16 */
17 private $current_page;
18
19 /**
20 * Primary_Category_Conditional constructor.
21 *
22 * @param Current_Page_Helper $current_page The current page helper.
23 */
24 public function __construct( Current_Page_Helper $current_page ) {
25 $this->current_page = $current_page;
26 }
27
28 /**
29 * Returns `true` when on the frontend,
30 * or when on the post overview, post edit or new post admin page.
31 *
32 * @return bool `true` when on the frontend, or when on the post overview,
33 * post edit or new post admin page.
34 */
35 public function is_met() {
36 if ( ! \is_admin() ) {
37 return true;
38 }
39
40 return \in_array( $this->current_page->get_current_admin_page(), [ 'edit.php', 'post.php', 'post-new.php' ], true );
41 }
42 }
43