Ticket #12987: post.php.diff

File post.php.diff, 2.0 KB (added by duck_, 3 years ago)
Line 
1Index: wp-admin/includes/post.php
2===================================================================
3--- wp-admin/includes/post.php  (revision 14075)
4+++ wp-admin/includes/post.php  (working copy)
5@@ -44,16 +44,15 @@
6                }
7        }
8 
9+       $ptype = get_post_type_object( $post_data['post_type'] );
10        if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) {
11-               if ( 'page' == $post_data['post_type'] ) {
12-                       if ( !current_user_can( 'edit_others_pages' ) ) {
13+               if ( !current_user_can( $ptype->edit_others_cap ) ) {
14+                       if ( 'page' == $post_data['post_type'] ) {
15                                return new WP_Error( 'edit_others_pages', $update ?
16                                        __( 'You are not allowed to edit pages as this user.' ) :
17                                        __( 'You are not allowed to create pages as this user.' )
18                                );
19-                       }
20-               } else {
21-                       if ( !current_user_can( 'edit_others_posts' ) ) {
22+                       } else {
23                                return new WP_Error( 'edit_others_posts', $update ?
24                                        __( 'You are not allowed to edit posts as this user.' ) :
25                                        __( 'You are not allowed to post as this user.' )
26@@ -82,15 +81,8 @@
27 
28        // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
29        // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
30-       if ( isset( $post_data['post_type'] ) && 'page' == $post_data['post_type'] ) {
31-               $publish_cap = 'publish_pages';
32-               $edit_cap = 'edit_published_pages';
33-       } else {
34-               $publish_cap = 'publish_posts';
35-               $edit_cap = 'edit_published_posts';
36-       }
37-       if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $publish_cap )) )
38-               if ( $previous_status != 'publish' || !current_user_can( $edit_cap ) )
39+       if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->publish_cap )) )
40+               if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) )
41                        $post_data['post_status'] = 'pending';
42 
43        if ( ! isset($post_data['post_status']) )