When a post is scheduled for publication, treat it the same as a published post when calculating the capabilities required to edit or delete it.

Fixes #33694

Built from https://develop.svn.wordpress.org/trunk@35747


git-svn-id: http://core.svn.wordpress.org/trunk@35711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2015-11-29 02:27:18 +00:00
parent 2b81411a0d
commit 6f37afb6ec
2 changed files with 17 additions and 11 deletions

View File

@ -83,12 +83,15 @@ function map_meta_cap( $cap, $user_id ) {
// If the post author is set and the user is the author... // If the post author is set and the user is the author...
if ( $post->post_author && $user_id == $post->post_author ) { if ( $post->post_author && $user_id == $post->post_author ) {
// If the post is published... // If the post is published or scheduled...
if ( 'publish' == $post->post_status ) { if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
$caps[] = $post_type->cap->delete_published_posts; $caps[] = $post_type->cap->delete_published_posts;
} elseif ( 'trash' == $post->post_status ) { } elseif ( 'trash' == $post->post_status ) {
if ( 'publish' == get_post_meta( $post->ID, '_wp_trash_meta_status', true ) ) { $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
$caps[] = $post_type->cap->delete_published_posts; $caps[] = $post_type->cap->delete_published_posts;
} else {
$caps[] = $post_type->cap->delete_posts;
} }
} else { } else {
// If the post is draft... // If the post is draft...
@ -97,8 +100,8 @@ function map_meta_cap( $cap, $user_id ) {
} else { } else {
// The user is trying to edit someone else's post. // The user is trying to edit someone else's post.
$caps[] = $post_type->cap->delete_others_posts; $caps[] = $post_type->cap->delete_others_posts;
// The post is published, extra cap required. // The post is published or scheduled, extra cap required.
if ( 'publish' == $post->post_status ) { if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
$caps[] = $post_type->cap->delete_published_posts; $caps[] = $post_type->cap->delete_published_posts;
} elseif ( 'private' == $post->post_status ) { } elseif ( 'private' == $post->post_status ) {
$caps[] = $post_type->cap->delete_private_posts; $caps[] = $post_type->cap->delete_private_posts;
@ -141,12 +144,15 @@ function map_meta_cap( $cap, $user_id ) {
// If the post author is set and the user is the author... // If the post author is set and the user is the author...
if ( $post->post_author && $user_id == $post->post_author ) { if ( $post->post_author && $user_id == $post->post_author ) {
// If the post is published... // If the post is published or scheduled...
if ( 'publish' == $post->post_status ) { if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
$caps[] = $post_type->cap->edit_published_posts; $caps[] = $post_type->cap->edit_published_posts;
} elseif ( 'trash' == $post->post_status ) { } elseif ( 'trash' == $post->post_status ) {
if ( 'publish' == get_post_meta( $post->ID, '_wp_trash_meta_status', true ) ) { $status = get_post_meta( $post->ID, '_wp_trash_meta_status', true );
if ( in_array( $status, array( 'publish', 'future' ), true ) ) {
$caps[] = $post_type->cap->edit_published_posts; $caps[] = $post_type->cap->edit_published_posts;
} else {
$caps[] = $post_type->cap->edit_posts;
} }
} else { } else {
// If the post is draft... // If the post is draft...
@ -155,8 +161,8 @@ function map_meta_cap( $cap, $user_id ) {
} else { } else {
// The user is trying to edit someone else's post. // The user is trying to edit someone else's post.
$caps[] = $post_type->cap->edit_others_posts; $caps[] = $post_type->cap->edit_others_posts;
// The post is published, extra cap required. // The post is published or scheduled, extra cap required.
if ( 'publish' == $post->post_status ) { if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
$caps[] = $post_type->cap->edit_published_posts; $caps[] = $post_type->cap->edit_published_posts;
} elseif ( 'private' == $post->post_status ) { } elseif ( 'private' == $post->post_status ) {
$caps[] = $post_type->cap->edit_private_posts; $caps[] = $post_type->cap->edit_private_posts;

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-RC1-35746'; $wp_version = '4.4-RC1-35747';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.