WP_Sitemaps_Registry::add_provider()publicWP 5.5.0

Adds a new sitemap provider.

Метод класса: WP_Sitemaps_Registry{}

Хуки из метода

Возвращает

true|false. Whether the provider was added successfully.

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

$WP_Sitemaps_Registry = new WP_Sitemaps_Registry();
$WP_Sitemaps_Registry->add_provider( $name, $provider );
$name(строка) (обязательный)
Name of the sitemap provider.
$provider(WP_Sitemaps_Provider) (обязательный)
Instance of a WP_Sitemaps_Provider.

Список изменений

С версии 5.5.0 Введена.

Код WP_Sitemaps_Registry::add_provider() WP 6.1.1

public function add_provider( $name, WP_Sitemaps_Provider $provider ) {
	if ( isset( $this->providers[ $name ] ) ) {
		return false;
	}

	/**
	 * Filters the sitemap provider before it is added.
	 *
	 * @since 5.5.0
	 *
	 * @param WP_Sitemaps_Provider $provider Instance of a WP_Sitemaps_Provider.
	 * @param string               $name     Name of the sitemap provider.
	 */
	$provider = apply_filters( 'wp_sitemaps_add_provider', $provider, $name );
	if ( ! $provider instanceof WP_Sitemaps_Provider ) {
		return false;
	}

	$this->providers[ $name ] = $provider;

	return true;
}