Changeset 31653
- Timestamp:
- 03/07/2015 01:14:31 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/author-template.php
r31168 r31653 338 338 339 339 $author_count = array(); 340 foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND" . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author" ) as $row ) {340 foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author" ) as $row ) { 341 341 $author_count[$row->post_author] = $row->count; 342 342 } -
trunk/src/wp-includes/post.php
r31647 r31653 5345 5345 } 5346 5346 5347 if ( $full ) { 5348 if ( null === $post_author ) { 5349 $sql = $wpdb->prepare( 'WHERE post_type = %s AND ', $post_type ); 5350 } else { 5351 $sql = $wpdb->prepare( 'WHERE post_author = %d AND post_type = %s AND ', $post_author, $post_type ); 5352 } 5353 } else { 5354 $sql = ''; 5355 } 5356 5357 $sql .= "(post_status = 'publish'"; 5347 $sql = $wpdb->prepare( 'post_type = %s', $post_type ); 5348 5349 if ( null !== $post_author ) { 5350 $sql .= $wpdb->prepare( ' AND post_author = %d', $post_author ); 5351 } 5358 5352 5359 5353 // Only need to check the cap if $public_only is false. 5354 $post_status_sql = "post_status = 'publish'"; 5360 5355 if ( false === $public_only ) { 5361 5356 if ( current_user_can( $cap ) ) { 5362 5357 // Does the user have the capability to view private posts? Guess so. 5363 $ sql .= " OR post_status = 'private'";5358 $post_status_sql .= " OR post_status = 'private'"; 5364 5359 } elseif ( is_user_logged_in() ) { 5365 5360 // Users can view their own private posts. 5366 5361 $id = get_current_user_id(); 5367 5362 if ( null === $post_author || ! $full ) { 5368 $ sql .= " OR post_status = 'private' AND post_author = $id";5363 $post_status_sql .= " OR post_status = 'private' AND post_author = $id"; 5369 5364 } elseif ( $id == (int) $post_author ) { 5370 $ sql .= " OR post_status = 'private'";5365 $post_status_sql .= " OR post_status = 'private'"; 5371 5366 } // else none 5372 5367 } // else none 5373 5368 } 5374 5369 5375 $sql .= ')'; 5370 $sql .= " AND ($post_status_sql)"; 5371 5372 if ( $full ) { 5373 $sql = 'WHERE ' . $sql; 5374 } 5376 5375 5377 5376 return $sql;
Note: See TracChangeset
for help on using the changeset viewer.