Message info
 
To:wp-svn@lists.automattic.com From:m@wordpress.org Subject:[wp-svn] [21046] trunk/wp-includes/capabilities.php: Make read_post more useful. Date:Sun, 10 Jun 2012 16:21:45 +0000 (UTC)
 

Revision
21046
Author
ryan
Date
2012-06-10 16:21:44 +0000 (Sun, 10 Jun 2012)

Log Message

Make read_post more useful. Map read_post to edit_post for posts with protected post states. This makes read_post work naturally for draft, future, and pending posts belonging to other users. If the current user cannot edit these non-public posts then the user should not be able to read them either.

Modified Paths

Diff

Modified: trunk/wp-includes/capabilities.php (21045 => 21046)


--- trunk/wp-includes/capabilities.php	2012-06-10 15:18:15 UTC (rev 21045)
+++ trunk/wp-includes/capabilities.php	2012-06-10 16:21:44 UTC (rev 21046)
@@ -1076,7 +1076,8 @@
 			break;
 		}
 
-		if ( 'private' != $post->post_status ) {
+		$status_obj = get_post_status_object( $post->post_status );
+		if ( $status_obj->public ) {
 			$caps[] = $post_type->cap->read;
 			break;
 		}
@@ -1090,8 +1091,10 @@
 
 		if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID )
 			$caps[] = $post_type->cap->read;
+		elseif ( $status_obj->private )
+			$caps[] = $post_type->cap->read_private_posts;
 		else
-			$caps[] = $post_type->cap->read_private_posts;
+			$caps[] = map_meta_cap( 'edit_post', $user_id, $post->ID );
 		break;
 	case 'edit_post_meta':
 	case 'delete_post_meta':