Make WordPress Core


Ignore:
Timestamp:
04/24/2015 04:37:12 PM (10 years ago)
Author:
boonebgorges
Message:

Allow rewrite endpoints to be registered without also registering query vars.

Passing false to add_rewrite_endpoint() will now allow you to take
advantage of the rewrite API without thereby modifying the way that WP sets up
the main query from the request URI.

This new functionality allows developers to work around certain edge-case bugs,
such as when a proper endpoint request (such as /test/1/) would short-
circuit is_home() calculation when a static front page is set.

Props mordauk, boonebgorges.
Fixes #25143.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rewrite.php

    r31623 r32293  
    122122        restore_current_blog();
    123123    }
     124
     125    /**
     126     * @ticket 25143
     127     */
     128    public function test_is_home_should_be_false_when_visiting_custom_endpoint_without_a_registered_query_var_and_page_on_front_is_set() {
     129
     130        $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
     131        update_option( 'show_on_front', 'page' );
     132        update_option( 'page_on_front', $page_id );
     133
     134        add_rewrite_endpoint( 'test', EP_ALL, false );
     135        flush_rewrite_rules();
     136
     137        $this->go_to( home_url( '/test/1' ) );
     138
     139        $this->assertQueryTrue( 'is_front_page', 'is_page', 'is_singular' );
     140        $this->assertFalse( is_home() );
     141    }
    124142}
Note: See TracChangeset for help on using the changeset viewer.