Make WordPress Core

Ticket #21463: wp-capabilities-patch.diff

File wp-capabilities-patch.diff, 7.6 KB (added by eternalsword, 13 years ago)

fixed typo

Line 
1diff --git wp-admin/edit-form-advanced.php wp-admin/edit-form-advanced.php
2index 823a7a2..a56d848 100644
3--- wp-admin/edit-form-advanced.php
4+++ wp-admin/edit-form-advanced.php
5@@ -245,7 +245,7 @@ require_once('./admin-header.php');
6<div class="wrap">
7<?php screen_icon(); ?>
8-<h2><?php echo esc_html( $title ); ?><?php if ( isset( $post_new_file ) ) : ?> <a href="<?php echo esc_url( $post_new_file ) ?>" class="add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a><?php endif; ?></h2>
9+<h2><?php echo esc_html( $title ); ?><?php if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) ) : ?> <a href="<?php echo esc_url( $post_new_file ) ?>" class="add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a><?php endif; ?></h2>
10<?php if ( $notice ) : ?>
11<div id="notice" class="error"><p><?php echo $notice ?></p></div>
12<?php endif; ?>
13diff --git wp-admin/edit.php wp-admin/edit.php
14index 671311c..962431c 100644
15--- wp-admin/edit.php
16+++ wp-admin/edit.php
17@@ -221,7 +221,14 @@ require_once('./admin-header.php');
18?>
19<div class="wrap">
20<?php screen_icon(); ?>
21-<h2><?php echo esc_html( $post_type_object->labels->name ); ?> <a href="<?php echo $post_new_file ?>" class="add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a> <?php
22+<h2><?php echo esc_html( $post_type_object->labels->name );
23+
24+if( current_user_can( $post_type_object->cap->publish_posts ) ) {
25+?>
26+<a href="<?php echo $post_new_file ?>" class="add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a>
27+<?php
28+}
29+
30if ( ! empty( $_REQUEST['s'] ) )
31        printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?>
32</h2>
33diff --git wp-admin/includes/plugin.php wp-admin/includes/plugin.php
34index 941f545..c6c0e1c 100644
35--- wp-admin/includes/plugin.php
36+++ wp-admin/includes/plugin.php
37@@ -1423,6 +1423,14 @@ function get_admin_page_parent( $parent = '' ) {
38                }
39        }
40+       // if user only has read and edit capabilities there is no submenu
41+       foreach ($menu as $menu_item) {
42+               if ( !empty($typenow) && ($menu_item[2] == "$pagenow?post_type=$typenow") ) {
43+                       $parent_file = $parent;
44+                       return $parent;
45+               }
46+       }
47+
48        if ( empty($parent_file) )
49                $parent_file = '';
50        return '';
51diff --git wp-admin/includes/schema.php wp-admin/includes/schema.php
52index bba0871..e523230 100644
53--- wp-admin/includes/schema.php
54+++ wp-admin/includes/schema.php
55@@ -553,6 +553,7 @@ function populate_roles() {
56        populate_roles_270();
57        populate_roles_280();
58        populate_roles_300();
59+       populate_roles_360();
60}
61/**
62@@ -795,6 +796,45 @@ function populate_roles_300() {
63}
64/**
65+ * Create and modify WordPress roles for Wordpress 3.6.
66+ *
67+ * @since 3.6.0
68+ */
69+function populate_roles_360() {
70+       // Add caps for Administrator role
71+       $role =& get_role('administrator');
72+
73+       if ( !empty( $role ) ) {
74+               $role->add_cap('create_posts');
75+               $role->add_cap('create_pages');
76+       }
77+
78+       // Add caps for Editor role
79+       $role =& get_role('editor');
80+
81+       if ( !empty( $role ) ) {
82+               $role->add_cap('create_posts');
83+               $role->add_cap('create_pages');
84+       }
85+
86+       // Add caps for Author role
87+       $role =& get_role('author');
88+
89+       if ( !empty( $role ) ) {
90+               $role->add_cap('create_posts');
91+               $role->add_cap('create_pages');
92+       }
93+
94+       // Add caps for Contributor role
95+       $role =& get_role('contributor');
96+
97+       if ( !empty( $role ) ) {
98+               $role->add_cap('create_posts');
99+               $role->add_cap('create_pages');
100+       }
101+}
102+
103+/**
104  * Install Network.
105  *
106  * @since 3.0.0
107diff --git wp-admin/includes/upgrade.php wp-admin/includes/upgrade.php
108index 0053d99..4b58be7 100644
109--- wp-admin/includes/upgrade.php
110+++ wp-admin/includes/upgrade.php
111@@ -461,6 +461,9 @@ function upgrade_all() {
112        if ( $wp_current_db_version < 20080 )
113                upgrade_340();
114+       if ( $wp_current_db_version < 21462 )
115+               upgrade_360();
116+
117        maybe_disable_automattic_widgets();
118        update_option( 'db_version', $wp_db_version );
119@@ -1244,6 +1247,18 @@ function upgrade_340() {
120}
121/**
122+ * Execute changes made in Wordpress 3.6.
123+ *
124+ * @since 3.6.0
125+ */
126+function upgrade_360() {
127+       global $wp_current_db_version;
128+
129+       if ( $wp_current_db_version < 21462 )
130+               populate_roles_360();
131+}
132+
133+/**
134  * Execute network level changes
135  *
136  * @since 3.0.0
137diff --git wp-admin/menu.php wp-admin/menu.php
138index bf914e5..f5ece69 100644
139--- wp-admin/menu.php
140+++ wp-admin/menu.php
141@@ -49,7 +49,7 @@ $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
142$menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu-top menu-icon-post', 'menu-posts', 'div' );
143        $submenu['edit.php'][5]  = array( __('All Posts'), 'edit_posts', 'edit.php' );
144        /* translators: add new post */
145-       $submenu['edit.php'][10]  = array( _x('Add New', 'post'), 'edit_posts', 'post-new.php' );
146+       $submenu['edit.php'][10]  = array( _x('Add New', 'post'), 'create_posts', 'post-new.php' );
147        $i = 15;
148        foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
149@@ -74,7 +74,7 @@ $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-to
150$menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'div' );
151        $submenu['edit.php?post_type=page'][5] = array( __('All Pages'), 'edit_pages', 'edit.php?post_type=page' );
152        /* translators: add new page */
153-       $submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' );
154+       $submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), 'create_pages', 'post-new.php?post_type=page' );
155        $i = 15;
156        foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
157                if ( ! $tax->show_ui || ! in_array('page', (array) $tax->object_type, true) )
158@@ -115,7 +115,7 @@ foreach ( (array) get_post_types( array('show_ui' => true, '_builtin' => false,
159        $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 );
160        $submenu["edit.php?post_type=$ptype"][5]  = array( $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts,  "edit.php?post_type=$ptype");
161-       $submenu["edit.php?post_type=$ptype"][10]  = array( $ptype_obj->labels->add_new, $ptype_obj->cap->edit_posts, "post-new.php?post_type=$ptype" );
162+       $submenu["edit.php?post_type=$ptype"][10]  = array( $ptype_obj->labels->add_new, $ptype_obj->cap->create_posts, "post-new.php?post_type=$ptype" );
163        $i = 15;
164        foreach ( get_taxonomies( array(), 'objects' ) as $tax ) {
165diff --git wp-admin/post-new.php wp-admin/post-new.php
166index deb4190..2d996df 100644
167--- wp-admin/post-new.php
168+++ wp-admin/post-new.php
169@@ -36,7 +36,7 @@ $title = $post_type_object->labels->add_new_item;
170$editing = true;
171-if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
172+if ( ! current_user_can( $post_type_object->cap->create_posts ) )
173        wp_die( __( 'Cheatin&#8217; uh?' ) );
174// Schedule auto-draft cleanup
175diff --git wp-includes/post.php wp-includes/post.php
176index b22abf6..5d79c6b 100644
177--- wp-includes/post.php
178+++ wp-includes/post.php
179@@ -1177,6 +1177,7 @@ function get_post_type_capabilities( $args ) {
180                'edit_posts'         => 'edit_'         . $plural_base,
181                'edit_others_posts'  => 'edit_others_'  . $plural_base,
182                'publish_posts'      => 'publish_'      . $plural_base,
183+               'create_posts'       => 'create_'       . $plural_base,
184                'read_private_posts' => 'read_private_' . $plural_base,
185        );
186diff --git wp-includes/version.php wp-includes/version.php
187index b44816b..fe857af 100644
188--- wp-includes/version.php
189+++ wp-includes/version.php
190@@ -11,7 +11,7 @@ $wp_version = '3.5-alpha-21460';
191  *
192  * @global int $wp_db_version
193  */
194-$wp_db_version = 20596;
195+$wp_db_version = 21462;
196/**
197  * Holds the TinyMCE version