Make WordPress Core

Ticket #23226: 23226.2.diff

File 23226.2.diff, 11.8 KB (added by kovshenin, 13 years ago)
  • wp-includes/admin-bar.php

     
    429429                if ( 'post' == $current_screen->base
    430430                        && 'add' != $current_screen->action
    431431                        && ( $post_type_object = get_post_type_object( $post->post_type ) )
    432                         && current_user_can( $post_type_object->cap->read_post, $post->ID )
     432                        && current_user_can( 'read_post', $post->ID )
    433433                        && ( $post_type_object->public )
    434434                        && ( $post_type_object->show_in_admin_bar ) )
    435435                {
     
    457457
    458458                if ( ! empty( $current_object->post_type )
    459459                        && ( $post_type_object = get_post_type_object( $current_object->post_type ) )
    460                         && current_user_can( $post_type_object->cap->edit_post, $current_object->ID )
     460                        && current_user_can( 'edit_post', $current_object->ID )
    461461                        && $post_type_object->show_ui && $post_type_object->show_in_admin_bar )
    462462                {
    463463                        $wp_admin_bar->add_menu( array(
  • wp-includes/class-wp-xmlrpc-server.php

     
    10011001                if ( $update ) {
    10021002                        if ( ! get_post( $post_data['ID'] ) )
    10031003                                return new IXR_Error( 401, __( 'Invalid post ID.' ) );
    1004                         if ( ! current_user_can( $post_type->cap->edit_post, $post_data['ID'] ) )
     1004                        if ( ! current_user_can( 'edit_post', $post_data['ID'] ) )
    10051005                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    10061006                        if ( $post_data['post_type'] != get_post_type( $post_data['ID'] ) )
    10071007                                return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
     
    13061306                if ( empty( $post['ID'] ) )
    13071307                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    13081308
    1309                 $post_type = get_post_type_object( $post['post_type'] );
    1310                 if ( ! current_user_can( $post_type->cap->delete_post, $post_id ) )
     1309                if ( ! current_user_can( 'delete_post', $post_id ) )
    13111310                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
    13121311
    13131312                $result = wp_delete_post( $post_id );
     
    13861385                if ( empty( $post['ID'] ) )
    13871386                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    13881387
    1389                 $post_type = get_post_type_object( $post['post_type'] );
    1390                 if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) )
     1388                if ( ! current_user_can( 'edit_post', $post_id ) )
    13911389                        return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
    13921390
    13931391                return $this->_prepare_post( $post, $fields );
     
    14801478                $struct = array();
    14811479
    14821480                foreach ( $posts_list as $post ) {
    1483                         $post_type = get_post_type_object( $post['post_type'] );
    1484                         if ( ! current_user_can( $post_type->cap->edit_post, $post['ID'] ) )
     1481                        if ( ! current_user_can( 'edit_post', $post['ID'] ) )
    14851482                                continue;
    14861483
    14871484                        $struct[] = $this->_prepare_post( $post, $fields );
  • wp-includes/query.php

     
    24262426                        $post_type_object = get_post_type_object ( 'post' );
    24272427                }
    24282428
     2429                $edit_cap = 'edit_post';
     2430                $read_cap = 'read_post';
     2431
    24292432                if ( ! empty( $post_type_object ) ) {
    2430                         $edit_cap = $post_type_object->cap->edit_post;
    2431                         $read_cap = $post_type_object->cap->read_post;
    24322433                        $edit_others_cap = $post_type_object->cap->edit_others_posts;
    24332434                        $read_private_cap = $post_type_object->cap->read_private_posts;
    24342435                } else {
    2435                         $edit_cap = 'edit_' . $post_type_cap;
    2436                         $read_cap = 'read_' . $post_type_cap;
    24372436                        $edit_others_cap = 'edit_others_' . $post_type_cap . 's';
    24382437                        $read_private_cap = 'read_private_' . $post_type_cap . 's';
    24392438                }
  • wp-includes/link-template.php

     
    905905        if ( !$post_type_object )
    906906                return;
    907907
    908         if ( !current_user_can( $post_type_object->cap->edit_post, $post->ID ) )
     908        if ( !current_user_can( 'edit_post', $post->ID ) )
    909909                return;
    910910
    911911        return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context );
     
    959959        if ( !$post_type_object )
    960960                return;
    961961
    962         if ( !current_user_can( $post_type_object->cap->delete_post, $post->ID ) )
     962        if ( !current_user_can( 'delete_post', $post->ID ) )
    963963                return;
    964964
    965965        $action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
  • wp-admin/includes/class-wp-posts-list-table.php

     
    474474                $edit_link = get_edit_post_link( $post->ID );
    475475                $title = _draft_or_post_title();
    476476                $post_type_object = get_post_type_object( $post->post_type );
    477                 $can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
     477                $can_edit_post = current_user_can( 'edit_post', $post->ID );
    478478
    479479                $alternate = 'alternate' == $alternate ? '' : 'alternate';
    480480                $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
     
    566566                                        $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
    567567                                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
    568568                                }
    569                                 if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) {
     569                                if ( current_user_can( 'delete_post', $post->ID ) ) {
    570570                                        if ( 'trash' == $post->post_status )
    571571                                                $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
    572572                                        elseif ( EMPTY_TRASH_DAYS )
  • wp-admin/includes/post.php

     
    2828
    2929        $ptype = get_post_type_object( $post_data['post_type'] );
    3030
    31         if ( $update && ! current_user_can( $ptype->cap->edit_post, $post_data['ID'] ) ) {
     31        if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) {
    3232                if ( 'page' == $post_data['post_type'] )
    3333                        return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
    3434                else
     
    161161        $post_data['post_mime_type'] = $post->post_mime_type;
    162162
    163163        $ptype = get_post_type_object($post_data['post_type']);
    164         if ( !current_user_can( $ptype->cap->edit_post, $post_ID ) ) {
     164        if ( !current_user_can( 'edit_post', $post_ID ) ) {
    165165                if ( 'page' == $post_data['post_type'] )
    166166                        wp_die( __('You are not allowed to edit this page.' ));
    167167                else
     
    363363        foreach ( $post_IDs as $post_ID ) {
    364364                $post_type_object = get_post_type_object( get_post_type( $post_ID ) );
    365365
    366                 if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( $post_type_object->cap->edit_post, $post_ID ) ) {
     366                if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( 'edit_post', $post_ID ) ) {
    367367                        $skipped[] = $post_ID;
    368368                        continue;
    369369                }
  • wp-admin/includes/template.php

     
    240240 */
    241241function get_inline_data($post) {
    242242        $post_type_object = get_post_type_object($post->post_type);
    243         if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) )
     243        if ( ! current_user_can( 'edit_post', $post->ID ) )
    244244                return;
    245245
    246246        $title = esc_textarea( trim( $post->post_title ) );
  • wp-admin/includes/media.php

     
    447447                $attachment = wp_unslash( $attachment );
    448448       
    449449                $post = $_post = get_post($attachment_id, ARRAY_A);
    450                 $post_type_object = get_post_type_object( $post[ 'post_type' ] );
    451450
    452                 if ( !current_user_can( $post_type_object->cap->edit_post, $attachment_id ) )
     451                if ( !current_user_can( 'edit_post', $attachment_id ) )
    453452                        continue;
    454453
    455454                if ( isset($attachment['post_content']) )
  • wp-admin/post.php

     
    141141        if ( null == $post_type_object )
    142142                wp_die( __('Unknown post type.') );
    143143
    144         if ( !current_user_can($post_type_object->cap->edit_post, $post_id) )
     144        if ( !current_user_can( 'edit_post', $post_id ) )
    145145                wp_die( __('You are not allowed to edit this item.') );
    146146
    147147        if ( 'trash' == $post->post_status )
     
    214214
    215215        $post = get_post($post_id);
    216216
    217         if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
     217        if ( !current_user_can( 'delete_post', $post_id ) )
    218218                wp_die( __('You are not allowed to move this item to the Trash.') );
    219219
    220220        if ( ! wp_trash_post($post_id) )
     
    227227case 'untrash':
    228228        check_admin_referer('untrash-post_' . $post_id);
    229229
    230         if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
     230        if ( !current_user_can( 'delete_post', $post_id ) )
    231231                wp_die( __('You are not allowed to move this item out of the Trash.') );
    232232
    233233        if ( ! wp_untrash_post($post_id) )
     
    240240case 'delete':
    241241        check_admin_referer('delete-post_' . $post_id);
    242242
    243         if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
     243        if ( !current_user_can( 'delete_post', $post_id ) )
    244244                wp_die( __('You are not allowed to delete this item.') );
    245245
    246246        $force = !EMPTY_TRASH_DAYS;
  • wp-admin/async-upload.php

     
    4747        $post = get_post( $id );
    4848        if ( 'attachment' != $post->post_type )
    4949                wp_die( __( 'Unknown post type.' ) );
    50         $post_type_object = get_post_type_object( 'attachment' );
    51         if ( ! current_user_can( $post_type_object->cap->edit_post, $id ) )
     50        if ( ! current_user_can( 'edit_post', $id ) )
    5251                wp_die( __( 'You are not allowed to edit this item.' ) );
    5352
    5453        switch ( $_REQUEST['fetch'] ) {
  • wp-admin/edit.php

     
    7777                case 'trash':
    7878                        $trashed = 0;
    7979                        foreach( (array) $post_ids as $post_id ) {
    80                                 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
     80                                if ( !current_user_can( 'delete_post', $post_id) )
    8181                                        wp_die( __('You are not allowed to move this item to the Trash.') );
    8282
    8383                                if ( !wp_trash_post($post_id) )
     
    9090                case 'untrash':
    9191                        $untrashed = 0;
    9292                        foreach( (array) $post_ids as $post_id ) {
    93                                 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
     93                                if ( !current_user_can( 'delete_post', $post_id) )
    9494                                        wp_die( __('You are not allowed to restore this item from the Trash.') );
    9595
    9696                                if ( !wp_untrash_post($post_id) )
     
    105105                        foreach( (array) $post_ids as $post_id ) {
    106106                                $post_del = get_post($post_id);
    107107
    108                                 if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
     108                                if ( !current_user_can( 'delete_post', $post_id ) )
    109109                                        wp_die( __('You are not allowed to delete this item.') );
    110110
    111111                                if ( $post_del->post_type == 'attachment' ) {