WordPress.org

Make WordPress Core

Ticket #16714: 16714.2.diff

File 16714.2.diff, 16.6 KB (added by casben79, 7 years ago)

Most of my neat formatting removed and create_links and co removed

  • wp-admin/edit.php

     
    2020
    2121$post_type_object = get_post_type_object( $post_type );
    2222
    23 if ( !current_user_can($post_type_object->cap->edit_posts) )
     23if ( !current_user_can($post_type_object->cap->create_posts) )
    2424        wp_die(__('Cheatin’ uh?'));
    2525
    2626$wp_list_table = _get_list_table('WP_Posts_List_Table');
     
    190190?>
    191191<div class="wrap">
    192192<?php screen_icon(); ?>
    193 <h2><?php echo esc_html( $post_type_object->labels->name ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a> <?php
    194 if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
    195         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?>
     193<h2>
     194    <?php
     195        echo esc_html( $post_type_object->labels->name );
     196
     197        if( current_user_can( $post_type_object->cap->create_posts ) )
     198            echo '<a href="' . $post_new_file . '" class="button add-new-h2">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
     199
     200        if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
     201                printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() );
     202    ?>
    196203</h2>
    197204
    198205<?php
  • wp-admin/includes/dashboard.php

     
    6565                wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
    6666
    6767        // QuickPress Widget
    68         if ( is_blog_admin() && current_user_can('edit_posts') )
     68        if ( is_blog_admin() && current_user_can('create_posts') )
    6969                wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' );
    7070
    7171        // Recent Drafts
  • wp-admin/includes/post.php

     
    520520        else
    521521                $ptype = get_post_type_object('post');
    522522
    523         if ( !current_user_can( $ptype->cap->edit_posts ) ) {
     523        if ( !current_user_can( $ptype->cap->create_posts ) ) {
    524524                if ( 'page' == $ptype->name )
    525                         return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
     525                        return new WP_Error( 'create_pages', __( 'You are not allowed to create pages on this site.' ) );
    526526                else
    527                         return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
     527                        return new WP_Error( 'create_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
    528528        }
    529529
    530530        // Check for autosave collisions
  • wp-admin/menu.php

     
    6565$menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'div' );
    6666        $submenu['edit.php'][5]  = array( __('Posts'), 'edit_posts', 'edit.php' );
    6767        /* translators: add new post */
    68         $submenu['edit.php'][10]  = array( _x('Add New', 'post'), 'edit_posts', 'post-new.php' );
     68        $submenu['edit.php'][10]  = array( _x('Add New', 'post'), 'create_posts', 'post-new.php' );
    6969
    7070        $i = 15;
    7171        foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
     
    127127        while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) )
    128128                $ptype_menu_position++;
    129129
    130         $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-posts-' . $ptype_for_id, $menu_icon );
    131         $submenu["edit.php?post_type=$ptype"][5]  = array( $ptype_obj->labels->menu_name, $ptype_obj->cap->edit_posts,  "edit.php?post_type=$ptype");
    132         $submenu["edit.php?post_type=$ptype"][10]  = array( $ptype_obj->labels->add_new, $ptype_obj->cap->edit_posts, "post-new.php?post_type=$ptype" );
     130        $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->menu_name ), $ptype_obj->cap->create_posts, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-posts-' . $ptype_for_id, $menu_icon );
     131        $submenu["edit.php?post_type=$ptype"][5]  = array( $ptype_obj->labels->menu_name, $ptype_obj->cap->create_posts,  "edit.php?post_type=$ptype");
     132        $submenu["edit.php?post_type=$ptype"][10]  = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, "post-new.php?post_type=$ptype" );
    133133
    134134        $i = 15;
    135135        foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
     
    206206                $submenu['profile.php'][10] = array(__('Add New User'), 'promote_users', 'user-new.php');
    207207}
    208208
    209 $menu[75] = array( __('Tools'), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'div' );
    210         $submenu['tools.php'][5] = array( __('Tools'), 'edit_posts', 'tools.php' );
     209$menu[75] = array( __('Tools'), 'create_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'div' );
     210        $submenu['tools.php'][5] = array( __('Tools'), 'create_posts', 'tools.php' );
    211211        $submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' );
    212212        $submenu['tools.php'][15] = array( __('Export'), 'import', 'export.php' );
    213213        if ( is_multisite() && !is_main_site() )
  • wp-admin/post-new.php

     
    3030
    3131$editing = true;
    3232
    33 if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
     33if ( ! current_user_can( $post_type_object->cap->create_posts ) )
    3434        wp_die( __( 'Cheatin&#8217; uh?' ) );
    3535
    3636wp_enqueue_script('autosave');
  • wp-admin/press-this.php

     
    1313
    1414header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    1515
    16 if ( ! current_user_can('edit_posts') )
     16if ( ! current_user_can('create_posts') )
    1717        wp_die( __( 'Cheatin&#8217; uh?' ) );
    1818
    1919/**
  • wp-admin/tools.php

     
    2727<?php screen_icon(); ?>
    2828<h2><?php echo esc_html( $title ); ?></h2>
    2929
    30 <?php if ( current_user_can('edit_posts') ) : ?>
     30<?php if ( current_user_can('create_posts') ) : ?>
    3131<div class="tool-box">
    3232        <h3 class="title"><?php _e('Press This') ?></h3>
    3333        <p><?php _e('Press This is a bookmarklet: a little app that runs in your browser and lets you grab bits of the web.');?></p>
  • wp-app.php

     
    320320        function get_service() {
    321321                log_app('function','get_service()');
    322322
    323                 if ( !current_user_can( 'edit_posts' ) )
     323                if ( !current_user_can( 'create_posts' ) )
    324324                        $this->auth_required( __( 'Sorry, you do not have the right to access this site.' ) );
    325325
    326326                $entries_url = esc_attr($this->get_entries_url());
     
    361361        function get_categories_xml() {
    362362                log_app('function','get_categories_xml()');
    363363
    364                 if ( !current_user_can( 'edit_posts' ) )
     364                if ( !current_user_can( 'create_posts' ) )
    365365                        $this->auth_required( __( 'Sorry, you do not have the right to access this site.' ) );
    366366
    367367                $home = esc_attr(get_bloginfo_rss('url'));
  • wp-includes/admin-bar.php

     
    123123                $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname,  'href' => get_admin_url($blog->userblog_id) ) );
    124124                $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-d', 'title' => __( 'Dashboard' ), 'href' => get_admin_url($blog->userblog_id) ) );
    125125
    126                 if ( current_user_can_for_blog( $blog->userblog_id, 'edit_posts' ) ) {
     126                if ( current_user_can_for_blog( $blog->userblog_id, 'create_posts' ) ) {
    127127                        $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => get_admin_url($blog->userblog_id, 'post-new.php') ) );
    128128                        $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => get_admin_url($blog->userblog_id, 'edit-comments.php') ) );
    129129                }
     
    186186
    187187        $actions = array();
    188188        foreach ( (array) get_post_types( array( 'show_ui' => true ), 'objects' ) as $ptype_obj ) {
    189                 if ( true !== $ptype_obj->show_in_menu || ! current_user_can( $ptype_obj->cap->edit_posts ) )
     189                if ( true !== $ptype_obj->show_in_menu || ! current_user_can( $ptype_obj->cap->create_posts ) )
    190190                        continue;
    191191
    192                 $actions[ 'post-new.php?post_type=' . $ptype_obj->name ] = array( $ptype_obj->labels->singular_name, $ptype_obj->cap->edit_posts, 'new-' . $ptype_obj->name );
     192                $actions[ 'post-new.php?post_type=' . $ptype_obj->name ] = array( $ptype_obj->labels->singular_name, $ptype_obj->cap->create_posts, 'new-' . $ptype_obj->name );
    193193        }
    194194
    195195        if ( empty( $actions ) )
     
    210210function wp_admin_bar_comments_menu() {
    211211        global $wp_admin_bar;
    212212
    213         if ( !current_user_can('edit_posts') )
     213        if ( !current_user_can('create_posts') )
    214214                return;
    215215
    216216        $awaiting_mod = wp_count_comments();
  • wp-includes/capabilities.php

     
    859859                                $caps[] = $post_type->cap->delete_private_posts;
    860860                }
    861861                break;
     862        case 'create_posts':
     863            $caps[] = 'edit_posts';
     864            break;
    862865                // edit_post breaks down to edit_posts, edit_published_posts, or
    863866                // edit_others_posts
    864867        case 'edit_post':
  • wp-includes/class-wp-xmlrpc-server.php

     
    774774                if ( !$user = $this->login($username, $password) )
    775775                        return $this->error;
    776776
    777                 if ( !current_user_can("edit_posts") )
    778                         return(new IXR_Error(401, __("Sorry, you cannot edit posts on this site.")));
     777                if ( !current_user_can("create_posts") )
     778                        return(new IXR_Error(401, __("Sorry, you cannot create posts on this site.")));
    779779
    780780                do_action('xmlrpc_call', 'wp.getAuthors');
    781781
     
    809809                if ( !$user = $this->login($username, $password) )
    810810                        return $this->error;
    811811
    812                 if ( !current_user_can( 'edit_posts' ) )
    813                         return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) );
     812                if ( !current_user_can( 'create_posts' ) )
     813                        return new IXR_Error( 401, __( 'Sorry, you must be able to create posts on this site in order to view tags.' ) );
    814814
    815815                do_action( 'xmlrpc_call', 'wp.getKeywords' );
    816816
     
    938938                if ( !$user = $this->login($username, $password) )
    939939                        return $this->error;
    940940
    941                 if ( !current_user_can( 'edit_posts' ) )
    942                         return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this site in order to view categories.' ) );
     941                if ( !current_user_can( 'create_posts' ) )
     942                        return new IXR_Error( 401, __( 'Sorry, you must be able to create posts to this site in order to view categories.' ) );
    943943
    944944                do_action('xmlrpc_call', 'wp.suggestCategories');
    945945
     
    13101310                if ( !$user = $this->login($username, $password) )
    13111311                        return $this->error;
    13121312
    1313                 if ( !current_user_can( 'edit_posts' ) )
     1313                if ( !current_user_can( 'create_posts' ) )
    13141314                        return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) );
    13151315
    13161316                do_action('xmlrpc_call', 'wp.getCommentCount');
     
    13421342                if ( !$user = $this->login($username, $password) )
    13431343                        return $this->error;
    13441344
    1345                 if ( !current_user_can( 'edit_posts' ) )
     1345                if ( !current_user_can( 'create_posts' ) )
    13461346                        return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
    13471347
    13481348                do_action('xmlrpc_call', 'wp.getPostStatusList');
     
    17241724                if ( !$user = $this->login($username, $password) )
    17251725                        return $this->error;
    17261726
    1727                 if ( !current_user_can( 'edit_posts' ) )
     1727                if ( !current_user_can( 'create_posts' ) )
    17281728                        return new IXR_Error( 401, __( 'Sorry, you do not have access to user data on this site.' ) );
    17291729
    17301730                do_action('xmlrpc_call', 'blogger.getUserInfo');
     
    19451945
    19461946                do_action('xmlrpc_call', 'blogger.newPost');
    19471947
    1948                 $cap = ($publish) ? 'publish_posts' : 'edit_posts';
     1948                $cap = ($publish) ? 'publish_posts' : 'create_posts';
    19491949                if ( !current_user_can($cap) )
    19501950                        return new IXR_Error(401, __('Sorry, you are not allowed to post on this site.'));
    19511951
     
    21122112                                elseif ('publish' == $content_struct['post_status'])
    21132113                                        $cap  = 'publish_posts';
    21142114                                else
    2115                                         $cap = 'edit_posts';
     2115                                        $cap = 'create_posts';
    21162116                                $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
    21172117                                $post_type = 'post';
    21182118                        } else {
     
    21252125                        elseif ('publish' == $content_struct['post_status'])
    21262126                                $cap  = 'publish_posts';
    21272127                        else
    2128                                 $cap = 'edit_posts';
     2128                                $cap = 'create_posts';
    21292129                        $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
    21302130                        $post_type = 'post';
    21312131                }
     
    24052405
    24062406                do_action('xmlrpc_call', 'metaWeblog.editPost');
    24072407
    2408                 $cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
     2408                $cap = ( $publish ) ? 'publish_posts' : 'create_posts';
    24092409                $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
    24102410                $post_type = 'post';
    24112411                $page_template = '';
     
    24232423                                if ( $publish || 'publish' == $content_struct['post_status'] )
    24242424                                        $cap  = 'publish_posts';
    24252425                                else
    2426                                         $cap = 'edit_posts';
     2426                                        $cap = 'create_posts';
    24272427                                $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
    24282428                                $post_type = 'post';
    24292429                        } else {
     
    24342434                        if ( $publish || 'publish' == $content_struct['post_status'] )
    24352435                                $cap  = 'publish_posts';
    24362436                        else
    2437                                 $cap = 'edit_posts';
     2437                                $cap = 'create_posts';
    24382438                        $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
    24392439                        $post_type = 'post';
    24402440                }
     
    29092909                if ( !$user = $this->login($username, $password) )
    29102910                        return $this->error;
    29112911
    2912                 if ( !current_user_can( 'edit_posts' ) )
    2913                         return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
     2912                if ( !current_user_can( 'create_posts' ) )
     2913                        return new IXR_Error( 401, __( 'Sorry, you must be able to create posts on this site in order to view categories.' ) );
    29142914
    29152915                do_action('xmlrpc_call', 'metaWeblog.getCategories');
    29162916
     
    31003100                if ( !$user = $this->login($username, $password) )
    31013101                        return $this->error;
    31023102
    3103                 if ( !current_user_can( 'edit_posts' ) )
    3104                         return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
     3103                if ( !current_user_can( 'create_posts' ) )
     3104                        return new IXR_Error( 401, __( 'Sorry, you must be able to create posts on this site in order to view categories.' ) );
    31053105
    31063106                do_action('xmlrpc_call', 'mt.getCategoryList');
    31073107
  • wp-includes/post.php

     
    10861086                'read_post'          => 'read_'         . $singular_base,
    10871087                'delete_post'        => 'delete_'       . $singular_base,
    10881088                // Primitive capabilities used outside of map_meta_cap():
    1089                 'edit_posts'         => 'edit_'         . $plural_base,
     1089                'create_posts'       => 'create_'       . $plural_base,
     1090                'edit_posts'         => 'edit_'         . $plural_base,
    10901091                'edit_others_posts'  => 'edit_others_'  . $plural_base,
    10911092                'publish_posts'      => 'publish_'      . $plural_base,
    10921093                'read_private_posts' => 'read_private_' . $plural_base,