Make WordPress Core

Ticket #54375: 54375.1.diff

File 54375.1.diff, 1.1 KB (added by hellofromTonya, 3 years ago)

Simplifies the strict boolean type check to conserve memory and processing.

  • src/wp-includes/post.php

    diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
    index 91edacf76f..cf72a892a4 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         * @since 5.9.0
     2160         *
     2161         * @param bool     $is_viewable Whether the post status is "viewable".
     2162         * @param stdClass $post_status Post status object.
     2163         */
     2164        return true === apply_filters( 'is_post_status_viewable', $is_viewable, $post_status );
    21542165}
    21552166
    21562167/**