Make WordPress Core

Ticket #54375: 54375.2.diff

File 54375.2.diff, 1.4 KB (added by peterwilsoncc, 3 years ago)
  • src/wp-includes/post.php

    diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
    index 91edacf76f..a7af977c1d 100644
    a b function is_post_type_viewable( $post_type ) { 
    21302130 * For all others, the 'publicly_queryable' value will be used.
    21312131 *
    21322132 * @since 5.7.0
     2133 * @since 5.9.0 Added `is_post_status_viewable` hook to filter the result.
    21332134 *
    21342135 * @param string|stdClass $post_status Post status name or object.
    21352136 * @return bool Whether the post status should be considered viewable.
    function is_post_status_viewable( $post_status ) { 
    21502151                return false;
    21512152        }
    21522153
    2153         return $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public );
     2154        $is_viewable = $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public );
     2155
     2156        /**
     2157         * Filters whether a post status is considered "viewable".
     2158         *
     2159         * To avoid the potential for type errors in PHP 8.1 or later, this filter
     2160         * must return a boolean true for the post status to be considered viewable.
     2161         *
     2162         * All other values (even truthy values) will result in the function
     2163         * is_post_status_viewable() returning false.
     2164         *
     2165         * @since 5.9.0
     2166         *
     2167         * @param bool     $is_viewable Whether the post status is "viewable".
     2168         * @param stdClass $post_status Post status object.
     2169         */
     2170        return true === apply_filters( 'is_post_status_viewable', $is_viewable, $post_status );
    21542171}
    21552172
    21562173/**