is_post_status_viewable
Filter HookDescription
Filters whether a post status is considered "viewable". The returned filtered value must be a boolean type to ensure `is_post_status_viewable()` only returns a boolean. This strictness is by design to maintain backwards-compatibility and guard against potential type errors in PHP 8.1+. Non-boolean values (even falsey and truthy values) will result in the function returning false.Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2451 |
Hook Parameters
Type | Name | Description |
---|---|---|
bool
|
$is_viewable
|
Whether the post status is "viewable" (strict type). |
stdClass
|
$post_status
|
Post status object. |
Usage Examples
Basic Usage
<?php
// Hook into is_post_status_viewable
add_filter('is_post_status_viewable', 'my_custom_filter', 10, 2);
function my_custom_filter($is_viewable, $post_status) {
// Your custom filtering logic here
return $is_viewable;
}
Source Code Context
wp-includes/post.php:2451
- How this hook is used in WordPress core
<?php
2446 * @since 5.9.0
2447 *
2448 * @param bool $is_viewable Whether the post status is "viewable" (strict type).
2449 * @param stdClass $post_status Post status object.
2450 */
2451 return true === apply_filters( 'is_post_status_viewable', $is_viewable, $post_status );
2452 }
2453
2454 /**
2455 * Determines whether a post is publicly viewable.
2456 *
PHP Documentation
<?php
/**
* Filters whether a post status is considered "viewable".
*
* The returned filtered value must be a boolean type to ensure
* `is_post_status_viewable()` only returns a boolean. This strictness
* is by design to maintain backwards-compatibility and guard against
* potential type errors in PHP 8.1+. Non-boolean values (even falsey
* and truthy values) will result in the function returning false.
*
* @since 5.9.0
*
* @param bool $is_viewable Whether the post status is "viewable" (strict type).
* @param stdClass $post_status Post status object.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.