Don't let contributors to re-publish their trashed posts, props caesarsgrunt, see #4529

git-svn-id: https://develop.svn.wordpress.org/trunk@11873 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2009-08-24 20:48:31 +00:00
parent 00de237f0c
commit ca608e336a
1 changed files with 14 additions and 4 deletions

View File

@ -773,11 +773,16 @@ function map_meta_cap( $cap, $user_id ) {
// If the user is the author...
if ( $user_id == $post_author_data->ID ) {
// If the post is published...
if ( 'publish' == $post->post_status )
if ( 'publish' == $post->post_status ) {
$caps[] = 'delete_published_posts';
else
} elseif ( 'trash' == $post->post_status ) {
$trash_meta = get_option('wp_trash_meta');
if (is_array($trash_meta) && isset($trash_meta['posts'][$post->ID]['status']) && $trash_meta['posts'][$post->ID]['status'] == 'publish')
$caps[] = 'delete_published_posts';
} else {
// If the post is draft...
$caps[] = 'delete_posts';
}
} else {
// The user is trying to edit someone else's post.
$caps[] = 'delete_others_posts';
@ -797,11 +802,16 @@ function map_meta_cap( $cap, $user_id ) {
// If the user is the author...
if ( $user_id == $page_author_data->ID ) {
// If the page is published...
if ( $page->post_status == 'publish' )
if ( $page->post_status == 'publish' ) {
$caps[] = 'delete_published_pages';
else
} elseif ( 'trash' == $page->post_status ) {
$trash_meta = get_option('wp_trash_meta');
if (is_array($trash_meta) && isset($trash_meta['posts'][$page->ID]['status']) && $trash_meta['posts'][$page->ID]['status'] == 'publish')
$caps[] = 'delete_published_pages';
} else {
// If the page is draft...
$caps[] = 'delete_pages';
}
} else {
// The user is trying to edit someone else's page.
$caps[] = 'delete_others_pages';