Ticket #24803: 24803.2.diff
File 24803.2.diff, 1.4 KB (added by , 11 years ago) |
---|
-
wp-includes/post.php
2032 2032 * The $perm parameter checks for 'readable' value and if the user can read 2033 2033 * private posts, it will display that for the user that is signed in. 2034 2034 * 2035 * This function will return a WP_Error object if the post type is invalid 2036 * 2035 2037 * @since 2.5.0 2036 2038 * @link http://codex.wordpress.org/Template_Tags/wp_count_posts 2037 2039 * 2038 2040 * @param string $type Optional. Post type to retrieve count 2039 2041 * @param string $perm Optional. 'readable' or empty. 2040 * @return object Number of posts for each status2042 * @return object|WP_Error Number of posts for each status, WP_Error if $type is invalid 2041 2043 */ 2042 2044 function wp_count_posts( $type = 'post', $perm = '' ) { 2043 2045 global $wpdb; 2044 2046 2047 if ( ! post_type_exists( $type ) ) { 2048 return new WP_Error( 'invalid_post_type', __( 'Invalid post type' ) ); 2049 } 2050 2045 2051 $user = wp_get_current_user(); 2046 2052 2047 2053 $cache_key = $type; 2048 2054 2049 $query = " SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";2055 $query = "xSELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 2050 2056 if ( 'readable' == $perm && is_user_logged_in() ) { 2051 2057 $post_type_object = get_post_type_object($type); 2052 2058 if ( !current_user_can( $post_type_object->cap->read_private_posts ) ) {