Make WordPress Core

Ticket #54375: 54375.3.diff

File 54375.3.diff, 1.5 KB (added by hellofromTonya, 3 years ago)

Explanation improvement in 54375.4.diff.

  • src/wp-includes/post.php

    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 ) { 
    21572157 * For all others, the 'publicly_queryable' value will be used.
    21582158 *
    21592159 * @since 5.7.0
     2160 * @since 5.9.0 Added `is_post_status_viewable` hook to filter the result.
    21602161 *
    21612162 * @param string|stdClass $post_status Post status name or object.
    21622163 * @return bool Whether the post status should be considered viewable.
    function is_post_status_viewable( $post_status ) { 
    21772178                return false;
    21782179        }
    21792180
    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 );
    21812198}
    21822199
    21832200/**