Opened 9 years ago
Closed 2 months ago
#37775 closed defect (bug) (worksforme)
Capabilities inconsistence when registering CPT
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Posts, Post Types | Keywords: | |
| Focuses: | Cc: |
Description
When registering CPT I can define capabilities, and some of them can be "turned off", so I can disable, for example, creating a new CPT object with 'create_posts' => false.
But here is the interesting part:
'delete_post' => null, 'delete_posts' => false,
To prevent deletion, I need to specify exactly like above, otherwise I will get notices from WP.
In my opinion, we should have 1 approach, like false
Change History (3)
This ticket was mentioned in Slack in #core by sirlouen. View the logs.
2 months ago
#3
@
2 months ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
Technically, for how capabilities are designed, false is just treated as an empty value.
If you really want to disable a capability, there is a default value do_not_allow meant for this purpose.
The capabilities array, is meant to set specific capabilities for certain actions, not as a switch for such actions. I can't remember if this was different long time ago, and I'm not going to review the log, but basically this issue is not a trouble anymore, so I'm going to be closing this as worksforme
Related: #30991