diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index 841f61c77f..41c0c4664c 100644
a
|
b
|
function is_post_type_viewable( $post_type ) { |
2157 | 2157 | * For all others, the 'publicly_queryable' value will be used. |
2158 | 2158 | * |
2159 | 2159 | * @since 5.7.0 |
| 2160 | * @since 5.9.0 Added `is_post_status_viewable` hook to filter the result. |
2160 | 2161 | * |
2161 | 2162 | * @param string|stdClass $post_status Post status name or object. |
2162 | 2163 | * @return bool Whether the post status should be considered viewable. |
… |
… |
function is_post_status_viewable( $post_status ) { |
2177 | 2178 | return false; |
2178 | 2179 | } |
2179 | 2180 | |
2180 | | return $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public ); |
| 2181 | $is_viewable = $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public ); |
| 2182 | |
| 2183 | /** |
| 2184 | * Filters whether a post status is considered "viewable". |
| 2185 | * |
| 2186 | * The returned filtered value must be a boolean type to ensure |
| 2187 | * `is_post_status_viewable()` only returns a boolean. This strictness |
| 2188 | * is by design to maintain backwards-compatibility and guard against |
| 2189 | * potential type errors in PHP 8.1+. Non-boolean values (even falsey |
| 2190 | * and truthy values) will result in the function returning false. |
| 2191 | * |
| 2192 | * @since 5.9.0 |
| 2193 | * |
| 2194 | * @param bool $is_viewable Whether the post status is "viewable" (strict type). |
| 2195 | * @param stdClass $post_status Post status object. |
| 2196 | */ |
| 2197 | return true === apply_filters( 'is_post_status_viewable', $is_viewable, $post_status ); |
2181 | 2198 | } |
2182 | 2199 | |
2183 | 2200 | /** |