@@ 97-121 (lines=25) @@ | ||
94 | } |
|
95 | ||
96 | // If the post author is set and the user is the author... |
|
97 | if ( $post->post_author && $user_id == $post->post_author ) { |
|
98 | // If the post is published or scheduled... |
|
99 | if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
100 | $caps[] = $post_type->cap->delete_published_posts; |
|
101 | } elseif ( 'trash' == $post->post_status ) { |
|
102 | $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); |
|
103 | if ( in_array( $status, array( 'publish', 'future' ), true ) ) { |
|
104 | $caps[] = $post_type->cap->delete_published_posts; |
|
105 | } else { |
|
106 | $caps[] = $post_type->cap->delete_posts; |
|
107 | } |
|
108 | } else { |
|
109 | // If the post is draft... |
|
110 | $caps[] = $post_type->cap->delete_posts; |
|
111 | } |
|
112 | } else { |
|
113 | // The user is trying to edit someone else's post. |
|
114 | $caps[] = $post_type->cap->delete_others_posts; |
|
115 | // The post is published or scheduled, extra cap required. |
|
116 | if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
117 | $caps[] = $post_type->cap->delete_published_posts; |
|
118 | } elseif ( 'private' == $post->post_status ) { |
|
119 | $caps[] = $post_type->cap->delete_private_posts; |
|
120 | } |
|
121 | } |
|
122 | break; |
|
123 | // edit_post breaks down to edit_posts, edit_published_posts, or |
|
124 | // edit_others_posts |
|
@@ 158-182 (lines=25) @@ | ||
155 | } |
|
156 | ||
157 | // If the post author is set and the user is the author... |
|
158 | if ( $post->post_author && $user_id == $post->post_author ) { |
|
159 | // If the post is published or scheduled... |
|
160 | if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
161 | $caps[] = $post_type->cap->edit_published_posts; |
|
162 | } elseif ( 'trash' == $post->post_status ) { |
|
163 | $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true ); |
|
164 | if ( in_array( $status, array( 'publish', 'future' ), true ) ) { |
|
165 | $caps[] = $post_type->cap->edit_published_posts; |
|
166 | } else { |
|
167 | $caps[] = $post_type->cap->edit_posts; |
|
168 | } |
|
169 | } else { |
|
170 | // If the post is draft... |
|
171 | $caps[] = $post_type->cap->edit_posts; |
|
172 | } |
|
173 | } else { |
|
174 | // The user is trying to edit someone else's post. |
|
175 | $caps[] = $post_type->cap->edit_others_posts; |
|
176 | // The post is published or scheduled, extra cap required. |
|
177 | if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { |
|
178 | $caps[] = $post_type->cap->edit_published_posts; |
|
179 | } elseif ( 'private' == $post->post_status ) { |
|
180 | $caps[] = $post_type->cap->edit_private_posts; |
|
181 | } |
|
182 | } |
|
183 | break; |
|
184 | case 'read_post': |
|
185 | case 'read_page': |