Check the correct global in get_page and also ensure that the cap check for deleting pages copes for the default page we edit when adding new. Fixes #11203.

git-svn-id: https://develop.svn.wordpress.org/trunk@12332 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood 2009-12-07 18:01:02 +00:00
parent 8b72be4ed2
commit 4701dd33f6
2 changed files with 10 additions and 2 deletions

View File

@ -818,6 +818,14 @@ function map_meta_cap( $cap, $user_id ) {
$page_author_data = get_userdata( $page->post_author );
//echo "current user id : $user_id, page author id: " . $page_author_data->ID . "<br />";
// If the user is the author...
if ('' != $page->post_author) {
$page_author_data = get_userdata( $page->post_author );
} else {
//No author set yet so default to current user for cap checks
$page_author_data = $author_data;
}
if ( $user_id == $page_author_data->ID ) {
// If the page is published...
if ( $page->post_status == 'publish' ) {

View File

@ -2279,8 +2279,8 @@ function get_all_page_ids() {
*/
function &get_page(&$page, $output = OBJECT, $filter = 'raw') {
if ( empty($page) ) {
if ( isset( $GLOBALS['page'] ) && isset( $GLOBALS['page']->ID ) ) {
return get_post($GLOBALS['page'], $output, $filter);
if ( isset( $GLOBALS['post'] ) && isset( $GLOBALS['post']->ID ) ) {
return get_post($GLOBALS['post'], $output, $filter);
} else {
$page = null;
return $page;