mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@32293 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -121,4 +121,22 @@ class Tests_Rewrite extends WP_UnitTestCase {
|
||||
|
||||
restore_current_blog();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 25143
|
||||
*/
|
||||
public function test_is_home_should_be_false_when_visiting_custom_endpoint_without_a_registered_query_var_and_page_on_front_is_set() {
|
||||
|
||||
$page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
|
||||
update_option( 'show_on_front', 'page' );
|
||||
update_option( 'page_on_front', $page_id );
|
||||
|
||||
add_rewrite_endpoint( 'test', EP_ALL, false );
|
||||
flush_rewrite_rules();
|
||||
|
||||
$this->go_to( home_url( '/test/1' ) );
|
||||
|
||||
$this->assertQueryTrue( 'is_front_page', 'is_page', 'is_singular' );
|
||||
$this->assertFalse( is_home() );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user