WordPress.org

Make WordPress Core

Changeset 29757


Ignore:
Timestamp:
09/23/2014 02:57:43 AM (7 years ago)
Author:
wonderboymusic
Message:

If the current user does not have the delete_posts cap on the current post type, don't list delete or trash as bulk actions for the relevant context of Post list table.

Props mvd7793.
Fixes #20175.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r29707 r29757  
    199199    protected function get_bulk_actions() {
    200200        $actions = array();
    201 
    202         if ( $this->is_trash )
     201        $post_type_obj = get_post_type_object( $this->screen->post_type );
     202
     203        if ( $this->is_trash ) {
    203204            $actions['untrash'] = __( 'Restore' );
    204         else
     205        } else {
    205206            $actions['edit'] = __( 'Edit' );
    206 
    207         if ( $this->is_trash || !EMPTY_TRASH_DAYS )
    208             $actions['delete'] = __( 'Delete Permanently' );
    209         else
    210             $actions['trash'] = __( 'Move to Trash' );
     207        }
     208
     209        if ( current_user_can( $post_type_obj->cap->delete_posts ) ) {
     210            if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
     211                $actions['delete'] = __( 'Delete Permanently' );
     212            } else {
     213                $actions['trash'] = __( 'Move to Trash' );
     214            }
     215        }
    211216
    212217        return $actions;
Note: See TracChangeset for help on using the changeset viewer.