#54375 closed enhancement (fixed)
Add is_post_status_viewable filter
Reported by: | peterwilsoncc | Owned by: | hellofromTonya |
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | needs-patch commit has-dev-note |
Focuses: | Cc: |
Description
Related to #49628.
Add a filter to the is_post_status_viewable()
function to allow theme and plugin developers to override the default value.
In some circumstances a developer may require the checks use different conditions to the default.
Attachments (4)
Change History (12)
#3
@
3 years ago
Functional changes in 54375.1.diff look good to me.
In 54375.2.diff I've added an explanation that the filter must return true
, for the same reasons as discussed on #49628.
#5
@
3 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
It seems like this is a more common pattern in core to ensure a boolean return type from a filter:
return (bool) apply_filters( ... );
It's used in at least five other instances and appears to achieve the same goal. Is there a reason not follow that pattern here? Personally, I find it much easier to navigate the code later when similar things are done in a consistent way :)
The same applies to [52045].
#6
follow-up:
↓ 7
@
3 years ago
@SergeyBiryukov See the explanation here as to why type casting is unpredictable and why a strict boolean check is used instead. Please note, strict boolean checks are also in Core. This types of checks are more future proof, predictable, and stable than type casting.
#7
in reply to:
↑ 6
@
3 years ago
- Resolution set to fixed
- Status changed from reopened to closed
Replying to hellofromTonya:
See the explanation here as to why type casting is unpredictable and why a strict boolean check is used instead.
Thank you for pointing me to that discussion! Knowing the context helps a lot, I appreciate the explanation.
Re-closing this to keep the discussion in one place. Will comment on the other ticket once I have an informed opinion.
Posts, Post Types: Introduce
is_post_status_viewable
hook to filter the result of theis_post_status_viewable()
function.