Make WordPress Core

Opened 10 years ago

Closed 8 years ago

#30352 closed defect (bug) (duplicate)

Prevent an editor to move the front page / posts page to trash

Reported by: benoitchantre's profile benoitchantre Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

When an admin choose to use static pages for the front page and the posts page in the reading settings, an editor should not be able to unpublish them.

Attachments (1)

30352.patch (1.3 KB) - added by mrahmadawais 10 years ago.
prevent_front_page_delete_by_editor function added to wp-includes/pluggable.php

Download all attachments as: .zip

Change History (15)

#1 @benoitchantre
10 years ago

  • Summary changed from Prevent an editor to move the homepage / blog page to trash to Prevent an editor to move the front page / posts page to trash

#2 @SergeyBiryukov
10 years ago

  • Component changed from Role/Capability to Posts, Post Types

Related: #17470, #21665, #30190.

#3 @helen
10 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

I almost wonder if we shouldn't allow those pages to be unpublished by anybody while they're still set for those options, but certainly it seems to make sense not to allow somebody to alter that unless they have the capability to edit the setting.

#4 @DrewAPicture
10 years ago

  • Keywords good-first-bug added

#5 @mrahmadawais
10 years ago

Started working on it.

Last edited 10 years ago by mrahmadawais (previous) (diff)

#6 @mrahmadawais
10 years ago

I have the logic ready, just unable to figure out where to add it.
Can't do it in wp-admin/edit.php.
Reviewed wp-admin/includes/class-wp-post-list-table.php and added the check and it works, but an editor can always go inside the page and trash it from there.

So, I figured the better way to stop editor from deleting a page which is being used as front page should be editing the user's capability of

delete_pages

Now unable to figure it out where to do that. Looking inside /wp-admin/includes/schema.php but I think it's not right. Looking for pointers.

@mrahmadawais
10 years ago

prevent_front_page_delete_by_editor function added to wp-includes/pluggable.php

#7 @mrahmadawais
10 years ago

  • Keywords has-patch added; needs-patch good-first-bug removed

I have added a function to prevent the editor user role from deleting any page which has been selected as the front page.
Awaiting review.

This ticket was mentioned in Slack in #core by mrahmadawais. View the logs.


10 years ago

#9 @benoitchantre
9 years ago

An improvement for Wordpress 4.3 ?

This ticket was mentioned in Slack in #core by jorbin. View the logs.


9 years ago

#11 @jorbin
9 years ago

I wonder if it might be simpler to add this into the delete_post section of map_meta_cap

This ticket was mentioned in Slack in #core by chriscct7. View the logs.


9 years ago

This ticket was mentioned in Slack in #core by benoitchantre. View the logs.


9 years ago

#14 @johnbillion
8 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Closing in favour of #37580 as it has a cleaner approach and tests.

Note: See TracTickets for help on using tickets.