diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index b6ca7c24d3..9feace039a 100644
a
|
b
|
function set_post_type( $post_id = 0, $post_type = 'post' ) { |
2086 | 2086 | * @since 4.4.0 |
2087 | 2087 | * @since 4.5.0 Added the ability to pass a post type name in addition to object. |
2088 | 2088 | * @since 4.6.0 Converted the `$post_type` parameter to accept a `WP_Post_Type` object. |
| 2089 | * @since 5.9.0 Added `is_post_type_viewable` hook to filter the result. |
2089 | 2090 | * |
2090 | 2091 | * @param string|WP_Post_Type $post_type Post type name or object. |
2091 | 2092 | * @return bool Whether the post type should be considered viewable. |
… |
… |
function is_post_type_viewable( $post_type ) { |
2102 | 2103 | return false; |
2103 | 2104 | } |
2104 | 2105 | |
2105 | | return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public ); |
| 2106 | $is_viewable = $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public ); |
| 2107 | |
| 2108 | /** |
| 2109 | * Filters whether a post type is considered "viewable". |
| 2110 | * |
| 2111 | * @since 5.9.0 |
| 2112 | * |
| 2113 | * @param bool $is_viewable Whether the post type is "viewable". |
| 2114 | * @param WP_Post_Type $post_type Post type object. |
| 2115 | */ |
| 2116 | $is_viewable = apply_filters( 'is_post_type_viewable', $is_viewable, $post_type ); |
| 2117 | |
| 2118 | // Make sure the filtered value is a boolean type before returning it. |
| 2119 | if ( ! is_bool( $is_viewable ) { |
| 2120 | return false; |
| 2121 | } |
| 2122 | |
| 2123 | return $is_viewable; |
2106 | 2124 | } |
2107 | 2125 | |
2108 | 2126 | /** |