_count_posts_cache_key()
Returns the cache key for wp_count_posts() based on the passed arguments.
Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.
Хуков нет.
Возвращает
Строку. The cache key.
Использование
_count_posts_cache_key( $type, $perm );
- $type(строка)
- Post type to retrieve count Default
'post'.
По умолчанию:'post' - $perm(строка)
'readable'or empty.
По умолчанию:''
Список изменений
| С версии 3.9.0 | Введена. |
Код _count_posts_cache_key() count posts cache key WP 7.0.2
function _count_posts_cache_key( $type = 'post', $perm = '' ) {
$cache_key = 'posts-' . $type;
if ( 'readable' === $perm && is_user_logged_in() ) {
$post_type_object = get_post_type_object( $type );
if ( $post_type_object && ! current_user_can( $post_type_object->cap->read_private_posts ) ) {
$cache_key .= '_' . $perm . '_' . get_current_user_id();
}
}
return $cache_key;
}