Ticket #39157: 39157.3.patch
File 39157.3.patch, 4.6 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 /** 358 * Set if query is custom feed display. 359 * 360 * @since 4.7.1 361 * @access public 362 * @var bool 363 */ 364 public $is_custom_feed = false; 365 366 /** 349 367 * Set if query is trackback. 350 368 * 351 369 * @since 1.5.0 … … 511 529 $this->is_search = false; 512 530 $this->is_feed = false; 513 531 $this->is_comment_feed = false; 532 $this->is_home_feed = false; 533 $this->is_custom_feed = false; 514 534 $this->is_trackback = false; 515 535 $this->is_home = false; 516 536 $this->is_404 = false; … … 925 945 $this->is_archive = true; 926 946 } 927 947 928 if ( '' != $qv['feed'] ) 948 if ( '' != $qv['feed'] ) { 929 949 $this->is_feed = true; 950 if ( ! in_array( $qv['feed'], array( 'feed', 'rss', 'rss2', 'atom', 'rdf' ) ) ) { 951 $this->is_custom_feed = true; 952 } 953 } 930 954 931 955 if ( '' != $qv['embed'] ) { 932 956 $this->is_embed = true; … … 955 979 if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) ) 956 980 $this->is_comment_feed = true; 957 981 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;960 982 983 984 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 ) ) { 985 if ( $this->is_feed ) { 986 $this->is_home_feed = true; 987 } else { 988 $this->is_home = true; 989 } 990 991 } 992 961 993 // Correct is_* for page_on_front and page_for_posts 962 994 if ( $this->is_home && 'page' == get_option('show_on_front') && get_option('page_on_front') ) { 963 995 $_query = wp_parse_args($this->query); … … 3666 3698 } 3667 3699 3668 3700 /** 3701 * Is the query for a hompage feed? 3702 * 3703 * @since 4.7.1 3704 * 3705 * @return bool 3706 */ 3707 public function is_home_feed() { 3708 return (bool) $this->is_home_feed; 3709 } 3710 3711 /** 3712 * Is the query for a custom feed? 3713 * 3714 * @since 4.7.1 3715 * 3716 * @return bool 3717 */ 3718 public function is_custom_feed() { 3719 return (bool) $this->is_custom_feed; 3720 } 3721 3722 /** 3669 3723 * Is the query for the front page of the site? 3670 3724 * 3671 3725 * 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() || $wp_query->is_custom_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 /** 406 * Is the query for the custom feed? 407 * 408 * @since 4.7.1 409 * 410 * @global WP_Query $wp_query Global WP_Query instance. 411 * 412 * @return bool 413 */ 414 function is_custom_feed() { 415 global $wp_query; 416 417 if ( ! isset( $wp_query ) ) { 418 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' ); 419 return false; 420 } 421 422 return $wp_query->is_custom_feed(); 423 } 424 425 /** 386 426 * Is the query for the front page of the site? 387 427 * 388 428 * This is for what is displayed at your site's main URL.