class-wpseo-advanced-settings.php 1.47 KB
Newer Older
imac's avatar
imac committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
<?php
/**
 * @package    WPSEO
 * @subpackage Internal
 */

/**
 * Class containing methods for WPSEO Advanced Settings.
 */
class WPSEO_Advanced_Settings {

	/**
	 * @var array The default advanced pages.
	 */
	private static $default_advanced_pages = array(
		'wpseo_titles',
		'wpseo_social',
		'wpseo_xml',
		'wpseo_advanced',
		'wpseo_tools',
	);

	/**
	 * @var array Additional advanced settings pages.
	 */
	private static $additional_advanced_pages = array();

	/**
	 * Gets the list of default advanced pages.
	 *
	 * @return array The default advanced pages.
	 */
	public static function get_advanced_pages() {
		return self::$default_advanced_pages;
	}

	/**
	 * Adds a page as an advanced settings page if it isn't already present or a default page.
	 *
	 * @param string $page The page to add.
	 *
	 * @returns void
	 */
	public static function add_advanced_page( $page ) {
		if ( ! in_array( $page, self::$default_advanced_pages ) && ! in_array( $page, self::$additional_advanced_pages ) ) {
			self::$additional_advanced_pages[] = $page;
		}
	}

	/**
	 * Checks if the current page is a Yoast SEO advanced settings page.
	 *
	 * @param string $page The page to check.
	 *
	 * @return bool Whether or not the page is considered an advanced settings page.
	 */
	public static function is_advanced_settings_page( $page ) {
		if ( is_string( $page ) ) {
			return in_array( $page, self::$default_advanced_pages ) || in_array( $page, self::$additional_advanced_pages );
		}

		return false;
	}
}