Make WordPress Core

Ticket #22417: 22417.diff

File 22417.diff, 2.1 KB (added by ryan, 12 years ago)
  • wp-admin/includes/post.php

     
    2626        if ( $update )
    2727                $post_data['ID'] = (int) $post_data['post_ID'];
    2828
     29        $ptype = get_post_type_object( $post_data['post_type'] );
     30        if ( $update && ! current_user_can( $ptype->cap->edit_post, $post_data['ID'] ) ) {
     31                if ( 'page' == $post_data['post_type'] ) {
     32                        return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
     33                } else {
     34                        return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) );
     35                }
     36        }
     37
    2938        if ( isset( $post_data['content'] ) )
    3039                $post_data['post_content'] = $post_data['content'];
    3140
     
    5160                }
    5261        }
    5362
    54         $ptype = get_post_type_object( $post_data['post_type'] );
    55         if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) {
    56                 if ( $update ) {
    57                         if ( ! current_user_can( $ptype->cap->edit_post, $post_data['ID'] ) ) {
    58                                 if ( 'page' == $post_data['post_type'] ) {
    59                                         return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
    60                                 } else {
    61                                         return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) );
    62                                 }
    63                         }
     63        if ( ! $update && isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] )
     64                 && ! current_user_can( $ptype->cap->edit_others_posts ) ) {
     65                if ( 'page' == $post_data['post_type'] ) {
     66                        return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
    6467                } else {
    65                         if ( ! current_user_can( $ptype->cap->edit_others_posts )  ) {
    66                                 if ( 'page' == $post_data['post_type'] ) {
    67                                         return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
    68                                 } else {
    69                                         return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) );
    70                                 }
    71                         }
     68                        return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) );
    7269                }
    7370        }
    7471