diff --git src/wp-includes/class-wp-query.php src/wp-includes/class-wp-query.php
index 5a90618..acfba61 100644
|
|
class WP_Query { |
960 | 960 | if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) ) |
961 | 961 | $this->is_comment_feed = true; |
962 | 962 | |
963 | | 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 ) ) |
| 963 | 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 ) ) |
964 | 964 | $this->is_home = true; |
965 | 965 | |
966 | 966 | // Correct is_* for page_on_front and page_for_posts |
… |
… |
class WP_Query { |
3670 | 3670 | */ |
3671 | 3671 | public function is_front_page() { |
3672 | 3672 | // most likely case |
3673 | | if ( 'posts' == get_option( 'show_on_front') && $this->is_home() ) |
| 3673 | if ( 'posts' == get_option( 'show_on_front') && $this->is_home() && ! $this->is_feed() ) |
3674 | 3674 | return true; |
3675 | 3675 | elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) ) |
3676 | 3676 | return true; |
diff --git tests/phpunit/tests/query/conditionals.php tests/phpunit/tests/query/conditionals.php
index 21963c7..438864e 100644
|
|
class Tests_Query_Conditionals extends WP_UnitTestCase { |
251 | 251 | $feeds = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
252 | 252 | |
253 | 253 | // long version |
254 | | foreach ($feeds as $feed) { |
255 | | $this->go_to("/feed/{$feed}/"); |
256 | | $this->assertQueryTrue('is_feed'); |
| 254 | foreach ( $feeds as $feed ) { |
| 255 | $this->go_to( "/feed/{$feed}/" ); |
| 256 | $this->assertQueryTrue( 'is_home', 'is_feed' ); |
257 | 257 | } |
258 | 258 | |
259 | 259 | // short version |
260 | | foreach ($feeds as $feed) { |
261 | | $this->go_to("/{$feed}/"); |
262 | | $this->assertQueryTrue('is_feed'); |
| 260 | foreach ( $feeds as $feed ) { |
| 261 | $this->go_to( "/{$feed}/" ); |
| 262 | $this->assertQueryTrue( 'is_home', 'is_feed' ); |
263 | 263 | } |
264 | | |
265 | 264 | } |
266 | 265 | |
267 | 266 | function test_main_feed() { |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
269 | 268 | $types = array('rss2', 'rss', 'atom'); |
270 | 269 | foreach ($types as $type) { |
271 | 270 | $this->go_to(get_feed_link($type)); |
272 | | $this->assertQueryTrue('is_feed'); |
| 271 | $this->assertQueryTrue( 'is_home', 'is_feed' ); |
273 | 272 | } |
274 | 273 | } |
275 | 274 | |
| 275 | /** |
| 276 | * @ticket 20899 |
| 277 | */ |
| 278 | function test_main_feed_is_home() { |
| 279 | $this->go_to( '/?feed=rss2' ); |
| 280 | |
| 281 | $this->assertQueryTrue( 'is_feed', 'is_home' ); |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * @ticket 20899 |
| 286 | */ |
| 287 | function test_main_feed_is_home_page_on_front() { |
| 288 | $page_on_front = self::factory()->post->create( array( |
| 289 | 'post_type' => 'page', |
| 290 | ) ); |
| 291 | |
| 292 | $page_for_posts = self::factory()->post->create( array( |
| 293 | 'post_type' => 'page', |
| 294 | ) ); |
| 295 | |
| 296 | update_option( 'show_on_front', 'page' ); |
| 297 | update_option( 'page_on_front', $page_on_front ); |
| 298 | update_option( 'page_for_posts', $page_for_posts ); |
| 299 | |
| 300 | $this->go_to( '/?feed=rss2' ); |
| 301 | $this->assertQueryTrue( 'is_feed', 'is_home' ); |
| 302 | |
| 303 | update_option( 'show_on_front', 'posts' ); |
| 304 | delete_option( 'page_on_front' ); |
| 305 | delete_option( 'page_for_posts' ); |
| 306 | } |
| 307 | |
276 | 308 | // 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]', |
277 | 309 | function test_paged() { |
278 | 310 | update_option( 'posts_per_page', 2 ); |
… |
… |
class Tests_Query_Conditionals extends WP_UnitTestCase { |
295 | 327 | |
296 | 328 | // check the long form |
297 | 329 | $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
298 | | foreach ($types as $type) { |
299 | | $this->go_to("/comments/feed/{$type}"); |
300 | | $this->assertQueryTrue('is_feed', 'is_comment_feed'); |
| 330 | foreach ( $types as $type ) { |
| 331 | $this->go_to( "/comments/feed/{$type}" ); |
| 332 | $this->assertQueryTrue( 'is_feed', 'is_comment_feed', 'is_home' ); |
301 | 333 | } |
302 | 334 | |
303 | 335 | // check the short form |
304 | | $types = array('feed', 'rdf', 'rss', 'rss2', 'atom'); |
305 | | foreach ($types as $type) { |
306 | | $this->go_to("/comments/{$type}"); |
307 | | $this->assertQueryTrue('is_feed', 'is_comment_feed'); |
| 336 | $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); |
| 337 | foreach ( $types as $type ) { |
| 338 | $this->go_to( "/comments/{$type}" ); |
| 339 | $this->assertQueryTrue( 'is_feed', 'is_comment_feed', 'is_home' ); |
308 | 340 | } |
309 | | |
310 | 341 | } |
311 | 342 | |
312 | 343 | // 'search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]', |