WPSEO_Sitemaps::build_sitemap()publicYoast 1.0

Attempts to build the requested sitemap.

Sets $bad_sitemap if this isn't for the root sitemap, a post type or taxonomy.

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

Возвращает

null. Ничего (null).

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

$WPSEO_Sitemaps = new WPSEO_Sitemaps();
$WPSEO_Sitemaps->build_sitemap( $type );
$type(строка) (обязательный)
The requested sitemap's identifier.

Код WPSEO_Sitemaps::build_sitemap() Yoast 22.3

public function build_sitemap( $type ) {

	/**
	 * Filter the type of sitemap to build.
	 *
	 * @param string $type Sitemap type, determined by the request.
	 */
	$type = apply_filters( 'wpseo_build_sitemap_post_type', $type );

	if ( $type === '1' ) {
		$this->build_root_map();

		return;
	}

	$entries_per_page = $this->get_entries_per_page();

	foreach ( $this->providers as $provider ) {
		if ( ! $provider->handles_type( $type ) ) {
			continue;
		}

		try {
			$links = $provider->get_sitemap_links( $type, $entries_per_page, $this->current_page );
		} catch ( OutOfBoundsException $exception ) {
			$this->bad_sitemap = true;

			return;
		}

		$this->sitemap = $this->renderer->get_sitemap( $links, $type, $this->current_page );

		return;
	}

	if ( has_action( 'wpseo_do_sitemap_' . $type ) ) {
		/**
		 * Fires custom handler, if hooked to generate sitemap for the type.
		 */
		do_action( 'wpseo_do_sitemap_' . $type );

		return;
	}

	$this->bad_sitemap = true;
}