# wordpress-seo/18.2/src/conditionals/primary-category-conditional.php

Yoast SEO – Advanced SEO with real-time guidance and built-in AI, version 18.2. 43 lines.

- Page: https://pluginprobe.com/plugins/wordpress-seo/18.2/code/src/conditionals/primary-category-conditional.php
- Raw: https://pluginprobe.com/plugins/wordpress-seo/18.2/raw/src/conditionals/primary-category-conditional.php
- Modified: 2021-05-18T13:42:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wordpress-seo/18.2/code/src/conditionals/primary-category-conditional.php#L10-L20`.

```php
<?php

namespace Yoast\WP\SEO\Conditionals;

use Yoast\WP\SEO\Helpers\Current_Page_Helper;

/**
 * Conditional that is only met when in frontend or page is a post overview or post add/edit form.
 */
class Primary_Category_Conditional implements Conditional {

	/**
	 * The current page helper.
	 *
	 * @var Current_Page_Helper
	 */
	private $current_page;

	/**
	 * Primary_Category_Conditional constructor.
	 *
	 * @param Current_Page_Helper $current_page The current page helper.
	 */
	public function __construct( Current_Page_Helper $current_page ) {
		$this->current_page = $current_page;
	}

	/**
	 * Returns `true` when on the frontend,
	 * or when on the post overview, post edit or new post admin page.
	 *
	 * @return bool `true` when on the frontend, or when on the post overview,
	 *          post edit or new post admin page.
	 */
	public function is_met() {
		if ( ! \is_admin() ) {
			return true;
		}

		return \in_array( $this->current_page->get_current_admin_page(), [ 'edit.php', 'post.php', 'post-new.php' ], true );
	}
}

```
