WP_Sitemaps_Registry::add_provider( string $name, WP_Sitemaps_Provider $provider ): bool

In this article

Adds a new sitemap provider.

Parameters

$namestringrequired
Name of the sitemap provider.
$providerWP_Sitemaps_Providerrequired
Instance of a WP_Sitemaps_Provider.

Return

bool Whether the provider was added successfully.

Source

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;
}

Hooks

apply_filters( ‘wp_sitemaps_add_provider’, WP_Sitemaps_Provider $provider, string $name )

Filters the sitemap provider before it is added.

Changelog

VersionDescription
5.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.