WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 10 months ago

Last modified 10 months ago

#20175 closed defect (bug) (fixed)

"Trash" should not be a bulk action when user can't delete a post at all

Reported by: markoheijnen Owned by: wonderboymusic
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.3.1
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

When a user can't delete posts at all for a certain post type the bulk action to delete posts is useless.

Not sure if the following check is correct:

		if ( current_user_can( $post_type_object->cap->delete_post ) ) {
			if ( $this->is_trash || !EMPTY_TRASH_DAYS )
				$actions['delete'] = __( 'Delete Permanently' );
			else
				$actions['trash'] = __( 'Move to Trash' );
		}

Maybe the edit/restore functionality should have some similar check

Attachments (1)

trash-patch.patch (811 bytes) - added by mvd7793 2 years ago.
Fixes the bug in ticket 20175

Download all attachments as: .zip

Change History (9)

comment:1 @coffee2code3 years ago

  • Keywords needs-patch added
  • Version set to 3.3.1

comment:2 @nacin3 years ago

delete_posts should be plural. Otherwise, seems good at a glance.

@mvd77932 years ago

Fixes the bug in ticket 20175

comment:3 @mvd77932 years ago

  • Keywords has-patch added; needs-patch removed

comment:4 @mvd77932 years ago

  • Cc mvd7793 added

comment:5 @nacin17 months ago

  • Component changed from Trash to Posts, Post Types

comment:6 @danielbachhuber10 months ago

  • Milestone changed from Awaiting Review to 4.1

I just stumbled upon this too. Patch looks good.

comment:7 @wonderboymusic10 months ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 29757:

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.

comment:8 @nacin10 months ago

Looks good.

Note: See TracTickets for help on using tickets.