_count_posts_cache_key

The timeline below displays how wordpress function _count_posts_cache_key has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Returns the cache key for wp_count_posts() based on the passed arguments.
 *
 * @since 3.9.0
 * @access private
 *
 * @param string $type Optional. Post type to retrieve count Default 'post'.
 * @param string $perm Optional. 'readable' or empty. Default empty.
 * @return string The cache key.
 */
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;
}

WordPress Version: 5.5

/**
 * Return the cache key for wp_count_posts() based on the passed arguments.
 *
 * @since 3.9.0
 * @access private
 *
 * @param string $type Optional. Post type to retrieve count Default 'post'.
 * @param string $perm Optional. 'readable' or empty. Default empty.
 * @return string The cache key.
 */
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;
}

WordPress Version: 5.1

/**
 * Return the cache key for wp_count_posts() based on the passed arguments.
 *
 * @since 3.9.0
 * @access private
 *
 * @param string $type Optional. Post type to retrieve count Default 'post'.
 * @param string $perm Optional. 'readable' or empty. Default empty.
 * @return string The cache key.
 */
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;
}

WordPress Version: 4.0

/**
 * Return the cache key for wp_count_posts() based on the passed arguments.
 *
 * @since 3.9.0
 *
 * @param string $type Optional. Post type to retrieve count Default 'post'.
 * @param string $perm Optional. 'readable' or empty. Default empty.
 * @return string The cache key.
 */
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;
}

WordPress Version: 3.9

/**
 * Return the cache key for wp_count_posts() based on the passed arguments
 *
 * @since 3.9.0
 *
 * @param string $type Optional. Post type to retrieve count
 * @param string $perm Optional. 'readable' or empty.
 * @return string The cache key.
 */
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 (!current_user_can($post_type_object->cap->read_private_posts)) {
            $cache_key .= '_' . $perm . '_' . get_current_user_id();
        }
    }
    return $cache_key;
}