Yoast\WP\SEO\Abilities\User_Interface\Abilities

Set_Xml_Sitemap_Status_Ability{} │ Yoast 1.0└─ Abstract_Set_Option_Status_Ability

The ability that enables or disables the XML sitemap feature.

Хуков нет.

Использование

$Set_Xml_Sitemap_Status_Ability = new Set_Xml_Sitemap_Status_Ability();
// use class methods

Методы

  1. public __construct(
  2. public is_available()
  3. protected get_description()
  4. protected get_feature_name()
  5. protected get_label()
  6. protected get_option_name()
  7. protected get_slug()

Код Set_Xml_Sitemap_Status_Ability{} Yoast 28.8

class Set_Xml_Sitemap_Status_Ability extends Abstract_Set_Option_Status_Ability {

	/**
	 * The options helper.
	 *
	 * @var Options_Helper
	 */
	private $options_helper;

	/**
	 * Constructor.
	 *
	 * @param Capability_Helper      $capability_helper      The capability helper.
	 * @param Feature_Status_Updater $feature_status_updater The feature status updater.
	 * @param Options_Helper         $options_helper         The options helper.
	 */
	public function __construct(
		Capability_Helper $capability_helper,
		Feature_Status_Updater $feature_status_updater,
		Options_Helper $options_helper
	) {
		parent::__construct( $capability_helper, $feature_status_updater );

		$this->options_helper = $options_helper;
	}

	/**
	 * Returns whether the ability is available.
	 *
	 * A network admin can forbid the XML sitemap for the sites of a multisite network. When
	 * that is the case, the option validation silently forces the feature back off on save,
	 * so the ability is not offered instead of failing on every call. Outside of a multisite
	 * the network option does not exist and the feature is always allowed.
	 *
	 * @return bool Whether the ability is available.
	 */
	public function is_available(): bool {
		return (bool) $this->options_helper->get( 'allow_enable_xml_sitemap', true );
	}

	/**
	 * Returns the part of the ability name that follows the category slug.
	 *
	 * @return string The ability slug.
	 */
	protected function get_slug(): string {
		return 'set-xml-sitemap-status';
	}

	/**
	 * Returns the name of the option that enables the XML sitemap feature.
	 *
	 * @return string The option name.
	 */
	protected function get_option_name(): string {
		return 'enable_xml_sitemap';
	}

	/**
	 * Returns the human-readable name of the feature.
	 *
	 * @return string The feature name.
	 */
	protected function get_feature_name(): string {
		return 'XML sitemap';
	}

	/**
	 * Returns the label of the ability.
	 *
	 * @return string The label.
	 */
	protected function get_label(): string {
		return \__( 'Set XML Sitemap Status', 'wordpress-seo' );
	}

	/**
	 * Returns the description of the ability.
	 *
	 * @return string The description.
	 */
	protected function get_description(): string {
		return \sprintf(
			/* translators: %s expands to Yoast SEO */
			\__( 'Enable or disable %s\'s XML sitemap feature. Enabling it serves the sitemap index at /sitemap_index.xml and its sub-sitemaps, and replaces the WordPress core sitemaps; disabling it stops serving them.', 'wordpress-seo' ),
			'Yoast SEO',
		);
	}
}