_count_posts_cache_key() WP 3.9.0
Return the cache key for wp_count_posts() based on the passed arguments.
This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.
No Hooks.
Return
String
. The cache key.
Usage
_count_posts_cache_key( $type, $perm );
- $type(string)
- Post type to retrieve count Default 'post'.
- $perm(string)
- 'readable' or empty.
Default: ''
Changelog
Since 3.9.0 | Introduced. |
Code of _count_posts_cache_key() count posts cache key WP 5.7.1
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;
}