WPSEO_Post_Type_Sitemap_Provider::get_all_dates
Get all dates for a post type.
Метод класса: WPSEO_Post_Type_Sitemap_Provider{}
Хуков нет.
Возвращает
Массив. Array of dates.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_all_dates( $post_type, $max_entries );
- $post_type(строка) (обязательный)
- Post type to retrieve dates for.
- $max_entries(int) (обязательный)
- Maximum number of entries to retrieve.
Код WPSEO_Post_Type_Sitemap_Provider::get_all_dates() WPSEO Post Type Sitemap Provider::get all dates Yoast 27.4
private function get_all_dates( $post_type, $max_entries ) {
global $wpdb;
$post_statuses = array_map( 'esc_sql', WPSEO_Sitemaps::get_post_statuses( $post_type ) );
$replacements = array_merge(
[
'post_modified_gmt',
$wpdb->posts,
'type_status_date',
'post_status',
],
$post_statuses,
[
'post_type',
$post_type,
$max_entries,
'post_modified_gmt',
],
);
return $wpdb->get_col(
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
$wpdb->prepare(
'
SELECT %i
FROM ( SELECT @rownum:=0 ) init
JOIN %i USE INDEX( %i )
WHERE %i IN (' . implode( ', ', array_fill( 0, count( $post_statuses ), '%s' ) ) . ')
AND %i = %s
AND ( @rownum:=@rownum+1 ) %% %d = 0
ORDER BY %i ASC
',
$replacements,
),
);
}