Changeset 7638
- Timestamp:
- 04/09/2008 08:09:45 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post.php
r7614 r7638 507 507 508 508 function get_available_post_statuses($type = 'post') { 509 global $wpdb; 510 511 $stati = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = %s", $type)); 512 return $stati; 509 $stati = wp_count_posts($type); 510 511 return array_keys(get_object_vars($stati)); 513 512 } 514 513 -
trunk/wp-includes/post.php
r7601 r7638 829 829 $user = wp_get_current_user(); 830 830 831 $cache_key = $type; 832 if ( !empty($perm) ) 833 $cache_key .= '_' . $perm; 834 831 835 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 832 836 if ( 'readable' == $perm && is_user_logged_in() ) { 833 if ( !current_user_can("read_private_{$type}s") ) 837 if ( !current_user_can("read_private_{$type}s") ) { 838 $cache_key .= '_' . $user->ID; 834 839 $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))"; 840 } 835 841 } 836 842 $query .= ' GROUP BY post_status'; 843 844 $count = wp_cache_get($cache_key, 'counts'); 845 if ( false !== $count ) 846 return $count; 847 837 848 $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 838 849 … … 842 853 } 843 854 844 return (object) $stats; 845 } 855 $stats = (object) $stats; 856 wp_cache_set($cache_key, $stats, 'counts'); 857 858 return $stats; 859 } 860 846 861 847 862 /**
Note: See TracChangeset
for help on using the changeset viewer.