From 9d6bb11571f7fc80f1e2c550dc3305f759fbee62 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Wed, 8 Jun 2011 18:06:43 +0000 Subject: [PATCH] Check parent caps for revisions. props aaroncampbell. fixes #17668 git-svn-id: https://develop.svn.wordpress.org/trunk@18200 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/capabilities.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 902b233154..28e7541552 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -820,6 +820,11 @@ function map_meta_cap( $cap, $user_id ) { case 'delete_page': $author_data = get_userdata( $user_id ); $post = get_post( $args[0] ); + + if ( 'revision' == $post->post_type ) { + $post = get_post( $post->post_parent ); + } + $post_type = get_post_type_object( $post->post_type ); if ( ! $post_type->map_meta_cap ) { @@ -865,6 +870,11 @@ function map_meta_cap( $cap, $user_id ) { case 'edit_page': $author_data = get_userdata( $user_id ); $post = get_post( $args[0] ); + + if ( 'revision' == $post->post_type ) { + $post = get_post( $post->post_parent ); + } + $post_type = get_post_type_object( $post->post_type ); if ( ! $post_type->map_meta_cap ) { @@ -909,6 +919,11 @@ function map_meta_cap( $cap, $user_id ) { case 'read_page': $author_data = get_userdata( $user_id ); $post = get_post( $args[0] ); + + if ( 'revision' == $post->post_type ) { + $post = get_post( $post->post_parent ); + } + $post_type = get_post_type_object( $post->post_type ); if ( ! $post_type->map_meta_cap ) {