wpseek.com
WordPress开发者和主题制作者的搜索引擎



_count_posts_cache_key › WordPress Function

Since3.9.0
已弃用n/a
_count_posts_cache_key ( $type = 'post', $perm = '' )
访问:
  • private
参数: (2)
  • (string) $type Optional. Post type to retrieve count Default 'post'.
    Required: No
    默认: 'post'
  • (string) $perm Optional. 'readable' or empty. Default empty.
    Required: No
    默认: (empty)
返回:
  • (string) The cache key.
定义在:
文档:

Returns the cache key for wp_count_posts() based on the passed arguments.



源码

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;
}