WPSEO_Author_Sitemap_Provider::get_sitemap_links
Get set of sitemap link data.
Метод класса: WPSEO_Author_Sitemap_Provider{}
Хуки из метода
Возвращает
Массив.
Использование
$WPSEO_Author_Sitemap_Provider = new WPSEO_Author_Sitemap_Provider(); $WPSEO_Author_Sitemap_Provider->get_sitemap_links( $type, $max_entries, $current_page );
- $type(строка) (обязательный)
- Sitemap type.
- $max_entries(int) (обязательный)
- Entries per sitemap.
- $current_page(int) (обязательный)
- Current page of the sitemap.
Код WPSEO_Author_Sitemap_Provider::get_sitemap_links() WPSEO Author Sitemap Provider::get sitemap links Yoast 27.4
public function get_sitemap_links( $type, $max_entries, $current_page ) {
$links = [];
if ( ! $this->handles_type( 'author' ) ) {
return $links;
}
$user_criteria = [
'offset' => ( ( $current_page - 1 ) * $max_entries ),
'number' => $max_entries,
];
$users = $this->get_users( $user_criteria );
// Throw an exception when there are no users in the sitemap.
if ( count( $users ) === 0 ) {
throw new OutOfBoundsException( 'Invalid sitemap page requested' );
}
$users = $this->exclude_users( $users );
if ( empty( $users ) ) {
$users = [];
}
$time = time();
foreach ( $users as $user ) {
$author_link = get_author_posts_url( $user->ID );
if ( empty( $author_link ) ) {
continue;
}
$mod = $time;
if ( isset( $user->_yoast_wpseo_profile_updated ) ) {
$mod = $user->_yoast_wpseo_profile_updated;
}
$url = [
'loc' => $author_link,
'mod' => date( DATE_W3C, $mod ),
// Deprecated, kept for backwards data compat. R.
'chf' => 'daily',
'pri' => 1,
];
/** This filter is documented at inc/sitemaps/class-post-type-sitemap-provider.php */
$url = apply_filters( 'wpseo_sitemap_entry', $url, 'user', $user );
if ( ! empty( $url ) ) {
$links[] = $url;
}
}
return $links;
}