WP_User_Query::get_cache_last_changed
Retrieves the last changed cache timestamp for users and optionally posts.
Метод класса: WP_User_Query{}
Хуков нет.
Возвращает
Строку[]. The last changed timestamp string for the relevant cache groups.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_cache_last_changed( $args );
- $args(массив) (обязательный)
- Query arguments.
Список изменений
| С версии 6.9.0 | Введена. |
Код WP_User_Query::get_cache_last_changed() WP User Query::get cache last changed WP 6.9
protected function get_cache_last_changed( array $args ) {
$last_changed = (array) wp_cache_get_last_changed( 'users' );
if ( empty( $args['orderby'] ) ) {
// Default order is by 'user_login'.
$ordersby = array( 'user_login' => '' );
} elseif ( is_array( $args['orderby'] ) ) {
$ordersby = $args['orderby'];
} else {
// 'orderby' values may be a comma- or space-separated list.
$ordersby = preg_split( '/[,\s]+/', $args['orderby'] );
}
$blog_id = 0;
if ( isset( $args['blog_id'] ) ) {
$blog_id = absint( $args['blog_id'] );
}
if ( $args['has_published_posts'] || in_array( 'post_count', $ordersby, true ) ) {
$switch = $blog_id && get_current_blog_id() !== $blog_id;
if ( $switch ) {
switch_to_blog( $blog_id );
}
$last_changed[] = wp_cache_get_last_changed( 'posts' );
if ( $switch ) {
restore_current_blog();
}
}
return $last_changed;
}