WPSEO_Author_Sitemap_Provider::get_index_links()publicYoast 1.0

Get the links for the sitemap index.

{} Это метод класса: WPSEO_Author_Sitemap_Provider{}

Хуков нет.

Возвращает

Массив.

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

$WPSEO_Author_Sitemap_Provider = new WPSEO_Author_Sitemap_Provider();
$WPSEO_Author_Sitemap_Provider->get_index_links( $max_entries );
$max_entries(int) (обязательный)
Entries per sitemap.

Код WPSEO_Author_Sitemap_Provider::get_index_links() Yoast 18.8

public function get_index_links( $max_entries ) {

	if ( ! $this->handles_type( 'author' ) ) {
		return [];
	}

	// @todo Consider doing this less often / when necessary. R.
	$this->update_user_meta();

	$has_exclude_filter = has_filter( 'wpseo_sitemap_exclude_author' );

	$query_arguments = [];

	if ( ! $has_exclude_filter ) { // We only need full users if legacy filter(s) hooked to exclusion logic. R.
		$query_arguments['fields'] = 'ID';
	}

	$users = $this->get_users( $query_arguments );

	if ( $has_exclude_filter ) {
		$users = $this->exclude_users( $users );
		$users = wp_list_pluck( $users, 'ID' );
	}

	if ( empty( $users ) ) {
		return [];
	}

	$index      = [];
	$user_pages = array_chunk( $users, $max_entries );

	foreach ( $user_pages as $page_counter => $users_page ) {

		$current_page = ( $page_counter === 0 ) ? '' : ( $page_counter + 1 );

		$user_id = array_shift( $users_page ); // Time descending, first user on page is most recently updated.
		$user    = get_user_by( 'id', $user_id );
		$index[] = [
			'loc'     => WPSEO_Sitemaps_Router::get_base_url( 'author-sitemap' . $current_page . '.xml' ),
			'lastmod' => ( $user->_yoast_wpseo_profile_updated ) ? YoastSEO()->helpers->date->format_timestamp( $user->_yoast_wpseo_profile_updated ) : null,
		];
	}

	return $index;
}