Make WordPress Core

Ticket #22417: 22417-part1.diff

File 22417-part1.diff, 1.6 KB (added by westi, 12 years ago)

Patch to make the first cap check post_ID aware

  • wp-admin/includes/post.php

     
    5353
    5454        $ptype = get_post_type_object( $post_data['post_type'] );
    5555        if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) {
    56                 if ( !current_user_can( $ptype->cap->edit_others_posts ) ) {
    57                         if ( 'page' == $post_data['post_type'] ) {
    58                                 return new WP_Error( 'edit_others_pages', $update ?
    59                                         __( 'You are not allowed to edit pages as this user.' ) :
    60                                         __( 'You are not allowed to create pages as this user.' )
    61                                 );
    62                         } else {
    63                                 return new WP_Error( 'edit_others_posts', $update ?
    64                                         __( 'You are not allowed to edit posts as this user.' ) :
    65                                         __( 'You are not allowed to create posts as this user.' )
    66                                 );
     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                                }
    6763                        }
     64                } 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                        }
    6872                }
    6973        }
    7074