[wp-trac] [WordPress Trac] #51291: Add filter to show post list table `column_cb` even without `edit_post` capability
WordPress Trac
noreply at wordpress.org
Fri Sep 11 20:03:49 UTC 2020
#51291: Add filter to show post list table `column_cb` even without `edit_post`
capability
----------------------------+-----------------------------
Reporter: coreyw | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version:
Severity: normal | Keywords:
Focuses: |
----------------------------+-----------------------------
Right now the checkbox in the posts list table only shows if the user can
edit the post. I am working on a plugin that allows posts to be archived,
which means they are not visible publicly, and are no longer editable
(until unarchived).
To do this, I have used the `map_meta_cap` filter to disallow the
`edit_post` capability if the current `post_status` is `archive`. This is
great because the post in the table no longer has a link to edit or quick
edit, and if you use a direct URL to edit the post a message shows to user
saying they are not allowed (having a custom message here that says the
post is archived would be good, maybe there is already an easy way to do
so?).
The problem though, is that the checkbox also is gone in the list table.
This does not allow a user to select archived posts and then use the
"Unarchive" bulk action.
Currently to get around this, I am looping over `debug_backtrace()` to
check if the `current_user_can('edit_post', $id)` call is coming from the
`column_cb` function or not and returning the appropriate value. Obviously
this is not preferred though.
There may be a better way than simply allowing a filter for the
`column_cb` as well, but hopefully this explains the end goal.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51291>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list