Changeset 31058
- Timestamp:
- 01/06/2015 04:57:12 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r31042 r31058 2352 2352 $cache_key = _count_posts_cache_key( $type, $perm ); 2353 2353 2354 $counts = wp_cache_get( $cache_key, 'counts' ); 2355 if ( false !== $counts ) { 2356 /** This filter is documented in wp-includes/post.php */ 2357 return apply_filters( 'wp_count_posts', $counts, $type, $perm ); 2358 } 2359 2354 2360 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 2355 2361 if ( 'readable' == $perm && is_user_logged_in() ) { … … 2363 2369 $query .= ' GROUP BY post_status'; 2364 2370 2365 $counts = wp_cache_get( $cache_key, 'counts' ); 2366 if ( false === $counts ) { 2367 $results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 2368 $counts = array_fill_keys( get_post_stati(), 0 ); 2369 2370 foreach ( $results as $row ) 2371 $counts[ $row['post_status'] ] = $row['num_posts']; 2372 2373 $counts = (object) $counts; 2374 wp_cache_set( $cache_key, $counts, 'counts' ); 2375 } 2371 $results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 2372 $counts = array_fill_keys( get_post_stati(), 0 ); 2373 2374 foreach ( $results as $row ) { 2375 $counts[ $row['post_status'] ] = $row['num_posts']; 2376 } 2377 2378 $counts = (object) $counts; 2379 wp_cache_set( $cache_key, $counts, 'counts' ); 2376 2380 2377 2381 /**
Note: See TracChangeset
for help on using the changeset viewer.