Changeset 50130 for trunk/src/wp-includes/post.php
- Timestamp:
- 02/01/2021 11:31:54 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r50120 r50130 2020 2020 } 2021 2021 2022 if ( ! is_object( $post_type ) ) { 2023 return false; 2024 } 2025 2022 2026 return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public ); 2027 } 2028 2029 /** 2030 * Determine whether a post status is considered "viewable". 2031 * 2032 * For built-in post statuses such as publish and private, the 'public' value will be evaluted. 2033 * For all others, the 'publicly_queryable' value will be used. 2034 * 2035 * @since 5.7.0 2036 * 2037 * @param string|stdClass $post_status Post status name or object. 2038 * @return bool Whether the post status should be considered viewable. 2039 */ 2040 function is_post_status_viewable( $post_status ) { 2041 if ( is_scalar( $post_status ) ) { 2042 $post_status = get_post_status_object( $post_status ); 2043 if ( ! $post_status ) { 2044 return false; 2045 } 2046 } 2047 2048 if ( 2049 ! is_object( $post_status ) || 2050 $post_status->internal || 2051 $post_status->protected 2052 ) { 2053 return false; 2054 } 2055 2056 return $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public ); 2057 } 2058 2059 /** 2060 * Determine whether a post is publicly viewable. 2061 * 2062 * Posts are considered publicly viewable if both the post status and post type 2063 * are viewable. 2064 * 2065 * @since 5.7.0 2066 * 2067 * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 2068 * @return bool Whether the post is publicly viewable. 2069 */ 2070 function is_post_publicly_viewable( $post = null ) { 2071 $post = get_post( $post ); 2072 2073 if ( ! $post ) { 2074 return false; 2075 } 2076 2077 $post_type = get_post_type( $post ); 2078 $post_status = get_post_status( $post ); 2079 2080 return is_post_type_viewable( $post_type ) && is_post_status_viewable( $post_status ); 2023 2081 } 2024 2082
Note: See TracChangeset
for help on using the changeset viewer.