Changeset 32293
- Timestamp:
- 04/24/2015 04:37:12 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rewrite.php
r31964 r32293 244 244 * 245 245 * @since 2.1.0 246 * @since 4.3.0 Added support for skipping query var registration by passing `false` to `$query_var`. 247 * 246 248 * @see WP_Rewrite::add_endpoint() 247 249 * @global object $wp_rewrite 248 250 * 249 * @param string $name Name of the endpoint. 250 * @param int $places Endpoint mask describing the places the endpoint should be added. 251 * @param string $query_var Name of the corresponding query variable. Defaults to $name. 252 */ 253 function add_rewrite_endpoint( $name, $places, $query_var = null ) { 251 * @param string $name Name of the endpoint. 252 * @param int $places Endpoint mask describing the places the endpoint should be added. 253 * @param string|bool $query_var Name of the corresponding query variable. Pass `false` to skip registering a query_var 254 * for this endpoint. Defaults to the value of `$name`. 255 */ 256 function add_rewrite_endpoint( $name, $places, $query_var = true ) { 254 257 global $wp_rewrite; 255 258 $wp_rewrite->add_endpoint( $name, $places, $query_var ); … … 1960 1963 * @since 2.1.0 1961 1964 * @since 3.9.0 $query_var parameter added. 1965 * @since 4.3.0 Added support for skipping query var registration by passing `false` to `$query_var`. 1962 1966 * @access public 1963 1967 * … … 1965 1969 * @uses WP::add_query_var() 1966 1970 * 1967 * @param string $name Name of the endpoint. 1968 * @param int $places Endpoint mask describing the places the endpoint should be added. 1969 * @param string $query_var Name of the corresponding query variable. Default is value of $name. 1970 */ 1971 public function add_endpoint( $name, $places, $query_var = null ) { 1971 * @param string $name Name of the endpoint. 1972 * @param int $places Endpoint mask describing the places the endpoint should be added. 1973 * @param string|bool $query_var Name of the corresponding query variable. Pass `false` to skip registering 1974 * a query_var for this endpoint. Defaults to the value of `$name`. 1975 */ 1976 public function add_endpoint( $name, $places, $query_var = true ) { 1972 1977 global $wp; 1973 if ( null === $query_var ) { 1978 1979 // For backward compatibility, if `null` has explicitly been passed as `$query_var`, assume `true`. 1980 if ( true === $query_var || null === func_get_arg( 2 ) ) { 1974 1981 $query_var = $name; 1975 1982 } 1976 1983 $this->endpoints[] = array( $places, $name, $query_var ); 1977 $wp->add_query_var( $query_var ); 1984 1985 if ( $query_var ) { 1986 $wp->add_query_var( $query_var ); 1987 } 1978 1988 } 1979 1989 -
trunk/tests/phpunit/tests/rewrite.php
r31623 r32293 122 122 restore_current_blog(); 123 123 } 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 } 124 142 }
Note: See TracChangeset
for help on using the changeset viewer.