Opened 3 years ago
Last modified 6 weeks ago
#54376 new enhancement
Add `is_post_publicly_viewable` filter
Reported by: | peterwilsoncc | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | Cc: |
Change History (3)
This ticket was mentioned in PR #7475 on WordPress/wordpress-develop by @debarghyabanerjee.
6 weeks ago
#2
- Keywords has-patch added; needs-patch removed
Trac Ticket: Core-54376
## Summary
- This pull request introduces the is_post_publicly_viewable filter to enhance the flexibility of post visibility checks in WordPress. This allows developers to customize the publicly viewable status of posts, providing greater control over content accessibility without modifying core functionality.
## Features
- New Filter:
is_post_publicly_viewable
### Parameters:
bool $is_viewable
: The current visibility status of the post, strictly typed.
WP_Post $post
: The post object being evaluated.
### Implementation Details
- The filter is added within the
is_post_publicly_viewable
function, enabling developers to hook into the visibility logic.
A strict type check ensures that the return value is a boolean. If the returned value is not boolean, the function will default to false. This approach preserves backward compatibility and protects against potential type errors, particularly with PHP 8.1+.
## Benefits
Customization
: Developers can implement custom visibility logic based on specific criteria or business rules without altering core WordPress files.
Backward Compatibility
: By enforcing a boolean return type and handling non-boolean values appropriately, we ensure that existing implementations relying on this function remain stable and functional.
## Conclusion
- This enhancement aligns with the ongoing efforts to improve the extensibility of WordPress. By introducing the
is_post_publicly_viewable
filter, we empower developers to create more dynamic and tailored content experiences while maintaining the integrity and reliability of the core system.
@debarghyabanerjee commented on PR #7475:
6 weeks ago
#3
Hi @peterwilsoncc , I have added the i_post_publicly_viewable filter, can you please take a look into it.. Thanks.
Note: See
TracTickets for help on using
tickets.
I think developers can use is_post_status_viewable & is_post_type_viewable filter hook for modifications.