
站长必备技能:浏览器缓存数据怎么清理?
_count_posts_cache_key ( $type = 'post', $perm = '' )
count_posts_cache_key: 这个函数用来生成一个用于计算文章的缓存密钥。它接受一个可选的$type参数来指定文章类型,并返回一个包含缓存密钥的字符串。
根据传递的参数,返回wp_count_posts()的缓存密钥。
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; }