Changeset 7109 for trunk/wp-includes/post.php
- Timestamp:
- 02/29/2008 09:49:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r7100 r7109 823 823 * @return array Number of posts for each status 824 824 */ 825 function wp_count_posts( $type = 'post' ) {825 function wp_count_posts( $type = 'post', $perm = '' ) { 826 826 global $wpdb; 827 827 828 $count = $wpdb->get_results( $wpdb->prepare( "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s GROUP BY post_status", $type ), ARRAY_A ); 828 $user = wp_get_current_user(); 829 830 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 831 if ( 'readable' == $perm && is_user_logged_in() ) { 832 if ( !current_user_can("read_private_{$type}s") ) 833 $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))"; 834 } 835 $query .= ' GROUP BY post_status'; 836 $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 829 837 830 838 $stats = array( );
Note: See TracChangeset
for help on using the changeset viewer.