Ticket #39157: 39157.2.patch
File 39157.2.patch, 3.5 KB (added by , 8 years ago) |
---|
-
src/wp-includes/class-wp-query.php
346 346 public $is_comment_feed = false; 347 347 348 348 /** 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 /** 349 358 * Set if query is trackback. 350 359 * 351 360 * @since 1.5.0 … … 511 520 $this->is_search = false; 512 521 $this->is_feed = false; 513 522 $this->is_comment_feed = false; 523 $this->is_home_feed = false; 514 524 $this->is_trackback = false; 515 525 $this->is_home = false; 516 526 $this->is_404 = false; … … 955 965 if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) ) 956 966 $this->is_comment_feed = true; 957 967 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 } 960 974 975 } 976 961 977 // Correct is_* for page_on_front and page_for_posts 962 978 if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') ) { 963 979 $_query = wp_parse_args($this->query); … … 3666 3682 } 3667 3683 3668 3684 /** 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 /** 3669 3696 * Is the query for the front page of the site? 3670 3697 * 3671 3698 * This is for what is displayed at your site's main URL. -
src/wp-includes/functions.php
1221 1221 * search result, or main comments. By checking for the absense of posts we can prevent rendering the feed 1222 1222 * templates at invalid endpoints. e.g.) /wp-content/plugins/feed/ 1223 1223 */ 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() ) ) { 1225 1225 wp_die( __( 'ERROR: This is not a valid feed.' ), '', array( 'response' => 404 ) ); 1226 1226 } 1227 1227 -
src/wp-includes/query.php
383 383 } 384 384 385 385 /** 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 */ 394 function 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 /** 386 406 * Is the query for the front page of the site? 387 407 * 388 408 * This is for what is displayed at your site's main URL.