From 143d456a7f9d91e0da9a0ea748ccca54461f5b71 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 14 Feb 2006 01:10:51 +0000 Subject: [PATCH] If requesting post caps for a page, redirect to equivalent page caps. git-svn-id: https://develop.svn.wordpress.org/trunk@3526 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/capabilities.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 8a1866365e..e72f0d1184 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -257,6 +257,10 @@ function map_meta_cap($cap, $user_id) { $author_data = get_userdata($user_id); //echo "post ID: {$args[0]}
"; $post = get_post($args[0]); + if ( 'page' == $post->post_type ) { + $args = array_merge(array('delete_page', $user_id), $args); + return call_user_func_array('map_meta_cap', $args); + } $post_author_data = get_userdata($post->post_author); //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
"; // If the user is the author... @@ -303,6 +307,10 @@ function map_meta_cap($cap, $user_id) { $author_data = get_userdata($user_id); //echo "post ID: {$args[0]}
"; $post = get_post($args[0]); + if ( 'page' == $post->post_type ) { + $args = array_merge(array('edit_page', $user_id), $args); + return call_user_func_array('map_meta_cap', $args); + } $post_author_data = get_userdata($post->post_author); //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
"; // If the user is the author... @@ -345,6 +353,10 @@ function map_meta_cap($cap, $user_id) { break; case 'read_post': $post = get_post($args[0]); + if ( 'page' == $post->post_type ) { + $args = array_merge(array('read_page', $user_id), $args); + return call_user_func_array('map_meta_cap', $args); + } if ( 'private' != $post->post_status ) { $caps[] = 'read'; @@ -358,6 +370,21 @@ function map_meta_cap($cap, $user_id) { else $caps[] = 'read_private_posts'; break; + case 'read_page': + $page = get_page($args[0]); + + if ( 'private' != $page->post_status ) { + $caps[] = 'read'; + break; + } + + $author_data = get_userdata($user_id); + $page_author_data = get_userdata($post->post_author); + if ($user_id == $page_author_data->ID) + $caps[] = 'read'; + else + $caps[] = 'read_private_pages'; + break; default: // If no meta caps match, return the original cap. $caps[] = $cap;