WordPress.org

Make WordPress Core

Ticket #23226: 23226.diff

File 23226.diff, 12.0 KB (added by markjaquith, 5 years ago)
  • wp-admin/async-upload.php

    if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id 
    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

    if ( $doaction ) { 
    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) )
    if ( $doaction ) { 
    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) )
    if ( $doaction ) { 
    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' ) {
  • wp-admin/includes/class-wp-posts-list-table.php

    class WP_Posts_List_Table extends WP_List_Table { 
    471471                $edit_link = get_edit_post_link( $post->ID );
    472472                $title = _draft_or_post_title();
    473473                $post_type_object = get_post_type_object( $post->post_type );
    474                 $can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
     474                $can_edit_post = current_user_can( 'edit_post', $post->ID );
    475475
    476476                $alternate = 'alternate' == $alternate ? '' : 'alternate';
    477477                $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
    class WP_Posts_List_Table extends WP_List_Table { 
    545545                                        $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
    546546                                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
    547547                                }
    548                                 if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) {
     548                                if ( current_user_can( 'delete_post', $post->ID ) ) {
    549549                                        if ( 'trash' == $post->post_status )
    550550                                                $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>";
    551551                                        elseif ( EMPTY_TRASH_DAYS )
  • wp-admin/includes/media.php

    function media_upload_form_handler() { 
    445445
    446446        if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
    447447                $post = $_post = get_post($attachment_id, ARRAY_A);
    448                 $post_type_object = get_post_type_object( $post[ 'post_type' ] );
    449448
    450                 if ( !current_user_can( $post_type_object->cap->edit_post, $attachment_id ) )
     449                if ( !current_user_can( 'edit_post', $attachment_id ) )
    451450                        continue;
    452451
    453452                if ( isset($attachment['post_content']) )
  • wp-admin/includes/post.php

    function _wp_translate_postdata( $update = false, $post_data = null ) { 
    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
    function edit_post( $post_data = null ) { 
    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
    function bulk_edit_posts( $post_data = null ) { 
    356356        foreach ( $post_IDs as $post_ID ) {
    357357                $post_type_object = get_post_type_object( get_post_type( $post_ID ) );
    358358
    359                 if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( $post_type_object->cap->edit_post, $post_ID ) ) {
     359                if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( 'edit_post', $post_ID ) ) {
    360360                        $skipped[] = $post_ID;
    361361                        continue;
    362362                }
  • wp-admin/includes/template.php

    function wp_link_category_checklist( $link_id = 0 ) { 
    244244 */
    245245function get_inline_data($post) {
    246246        $post_type_object = get_post_type_object($post->post_type);
    247         if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) )
     247        if ( ! current_user_can( 'edit_post', $post->ID ) )
    248248                return;
    249249
    250250        $title = esc_textarea( trim( $post->post_title ) );
  • wp-admin/post.php

    case 'edit': 
    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 )
    case 'trash': 
    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) )
    case 'trash': 
    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) )
    case 'untrash': 
    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-includes/admin-bar.php

    function wp_admin_bar_edit_menu( $wp_admin_bar ) { 
    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                {
    function wp_admin_bar_edit_menu( $wp_admin_bar ) { 
    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

    class wp_xmlrpc_server extends IXR_Server { 
    10071007                if ( $update ) {
    10081008                        if ( ! get_post( $post_data['ID'] ) )
    10091009                                return new IXR_Error( 401, __( 'Invalid post ID.' ) );
    1010                         if ( ! current_user_can( $post_type->cap->edit_post, $post_data['ID'] ) )
     1010                        if ( ! current_user_can( 'edit_post', $post_data['ID'] ) )
    10111011                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
    10121012                        if ( $post_data['post_type'] != get_post_type( $post_data['ID'] ) )
    10131013                                return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
    class wp_xmlrpc_server extends IXR_Server { 
    13171317                if ( empty( $post['ID'] ) )
    13181318                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    13191319
    1320                 $post_type = get_post_type_object( $post['post_type'] );
    1321                 if ( ! current_user_can( $post_type->cap->delete_post, $post_id ) )
     1320                if ( ! current_user_can( 'delete_post', $post_id ) )
    13221321                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
    13231322
    13241323                $result = wp_delete_post( $post_id );
    class wp_xmlrpc_server extends IXR_Server { 
    13991398                if ( empty( $post['ID'] ) )
    14001399                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    14011400
    1402                 $post_type = get_post_type_object( $post['post_type'] );
    1403                 if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) )
     1401                if ( ! current_user_can( 'edit_post', $post_id ) )
    14041402                        return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
    14051403
    14061404                return $this->_prepare_post( $post, $fields );
    class wp_xmlrpc_server extends IXR_Server { 
    14951493                $struct = array();
    14961494
    14971495                foreach ( $posts_list as $post ) {
    1498                         $post_type = get_post_type_object( $post['post_type'] );
    1499                         if ( ! current_user_can( $post_type->cap->edit_post, $post['ID'] ) )
     1496                        if ( ! current_user_can( 'edit_post', $post['ID'] ) )
    15001497                                continue;
    15011498
    15021499                        $struct[] = $this->_prepare_post( $post, $fields );
  • wp-includes/link-template.php

    function get_edit_post_link( $id = 0, $context = 'display' ) { 
    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 );
    function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false 
    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';