WordPress.org

Make WordPress Core

Changeset 11873


Ignore:
Timestamp:
08/24/09 20:48:31 (6 years ago)
Author:
azaozz
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/capabilities.php

    r11841 r11873  
    774774        if ( $user_id == $post_author_data->ID ) { 
    775775            // If the post is published... 
    776             if ( 'publish' == $post->post_status ) 
     776            if ( 'publish' == $post->post_status ) { 
    777777                $caps[] = 'delete_published_posts'; 
    778             else 
     778            } elseif ( 'trash' == $post->post_status ) { 
     779                $trash_meta = get_option('wp_trash_meta'); 
     780                if (is_array($trash_meta) && isset($trash_meta['posts'][$post->ID]['status']) && $trash_meta['posts'][$post->ID]['status'] == 'publish') 
     781                    $caps[] = 'delete_published_posts'; 
     782            } else { 
    779783                // If the post is draft... 
    780784                $caps[] = 'delete_posts'; 
     785            } 
    781786        } else { 
    782787            // The user is trying to edit someone else's post. 
     
    798803        if ( $user_id == $page_author_data->ID ) { 
    799804            // If the page is published... 
    800             if ( $page->post_status == 'publish' ) 
     805            if ( $page->post_status == 'publish' ) { 
    801806                $caps[] = 'delete_published_pages'; 
    802             else 
     807            } elseif ( 'trash' == $page->post_status ) { 
     808                $trash_meta = get_option('wp_trash_meta'); 
     809                if (is_array($trash_meta) && isset($trash_meta['posts'][$page->ID]['status']) && $trash_meta['posts'][$page->ID]['status'] == 'publish') 
     810                    $caps[] = 'delete_published_pages'; 
     811            } else { 
    803812                // If the page is draft... 
    804813                $caps[] = 'delete_pages'; 
     814            } 
    805815        } else { 
    806816            // The user is trying to edit someone else's page. 
Note: See TracChangeset for help on using the changeset viewer.