Make WordPress Core

Ticket #39157: 39157.2.patch

File 39157.2.patch, 3.5 KB (added by stevenkword, 8 years ago)

Updates doc

  • src/wp-includes/class-wp-query.php

     
    346346        public $is_comment_feed = false;
    347347
    348348        /**
     349         * Set if query is home feed display.
     350         *
     351         * @since 4.7.1
     352         * @access public
     353         * @var bool
     354         */
     355        public $is_home_feed = false;
     356
     357        /**
    349358         * Set if query is trackback.
    350359         *
    351360         * @since 1.5.0
     
    511520                $this->is_search = false;
    512521                $this->is_feed = false;
    513522                $this->is_comment_feed = false;
     523                $this->is_home_feed = false;
    514524                $this->is_trackback = false;
    515525                $this->is_home = false;
    516526                $this->is_404 = false;
     
    955965                if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) )
    956966                        $this->is_comment_feed = true;
    957967
    958                 if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) )
    959                         $this->is_home = true;
     968                if ( !( $this->is_singular || $this->is_archive || $this->is_search || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots ) ) {
     969                        if ( $this->is_feed ) {
     970                                $this->is_home_feed = true;
     971                        } else {
     972                                $this->is_home = true;
     973                        }
    960974
     975                }
     976
    961977                // Correct is_* for page_on_front and page_for_posts
    962978                if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') ) {
    963979                        $_query = wp_parse_args($this->query);
     
    36663682        }
    36673683
    36683684        /**
     3685         * Is the query for a hompage feed?
     3686         *
     3687         * @since 4.7.1
     3688         *
     3689         * @return bool
     3690         */
     3691        public function is_home_feed() {
     3692                return (bool) $this->is_home_feed;
     3693        }
     3694
     3695        /**
    36693696         * Is the query for the front page of the site?
    36703697         *
    36713698         * This is for what is displayed at your site's main URL.
  • src/wp-includes/functions.php

     
    12211221         * search result, or main comments. By checking for the absense of posts we can prevent rendering the feed
    12221222         * templates at invalid endpoints. e.g.) /wp-content/plugins/feed/
    12231223         */
    1224         if ( ! $wp_query->have_posts() && ! ( $wp_query->is_archive() || $wp_query->is_search() || $is_main_comments_feed ) ) {
     1224        if ( ! $wp_query->have_posts() && ! ( $wp_query->is_archive() || $wp_query->is_search() || $is_main_comments_feed || $wp_query->is_home_feed() ) ) {
    12251225                wp_die( __( 'ERROR: This is not a valid feed.' ), '', array( 'response' => 404 ) );
    12261226        }
    12271227
  • src/wp-includes/query.php

     
    383383}
    384384
    385385/**
     386 * Is the query for the blog homepage feed?
     387 *
     388 * @since 4.7.1
     389 *
     390 * @global WP_Query $wp_query Global WP_Query instance.
     391 *
     392 * @return bool
     393 */
     394function is_home_feed() {
     395        global $wp_query;
     396
     397        if ( ! isset( $wp_query ) ) {
     398                _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
     399                return false;
     400        }
     401
     402        return $wp_query->is_home_feed();
     403}
     404
     405/**
    386406 * Is the query for the front page of the site?
    387407 *
    388408 * This is for what is displayed at your site's main URL.