Changeset 38790
- Timestamp:
- 10/14/2016 07:29:08 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api.php
r38310 r38790 92 92 * 93 93 * @see add_rewrite_rule() 94 * @global WP_Rewrite $wp_rewrite 94 95 */ 95 96 function rest_api_register_rewrites() { 97 global $wp_rewrite; 98 96 99 add_rewrite_rule( '^' . rest_get_url_prefix() . '/?$','index.php?rest_route=/','top' ); 97 100 add_rewrite_rule( '^' . rest_get_url_prefix() . '/(.*)?','index.php?rest_route=/$matches[1]','top' ); 101 add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/?$','index.php?rest_route=/','top' ); 102 add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/(.*)?','index.php?rest_route=/$matches[1]','top' ); 98 103 } 99 104 … … 177 182 * 178 183 * @todo Check if this is even necessary 184 * @global WP_Rewrite $wp_rewrite 179 185 * 180 186 * @param int $blog_id Optional. Blog ID. Default of null returns URL for current blog. … … 189 195 190 196 if ( is_multisite() && get_blog_option( $blog_id, 'permalink_structure' ) || get_option( 'permalink_structure' ) ) { 191 $url = get_home_url( $blog_id, rest_get_url_prefix(), $scheme ); 197 global $wp_rewrite; 198 199 if ( $wp_rewrite->using_index_permalinks() ) { 200 $url = get_home_url( $blog_id, $wp_rewrite->index . '/' . rest_get_url_prefix(), $scheme ); 201 } else { 202 $url = get_home_url( $blog_id, rest_get_url_prefix(), $scheme ); 203 } 204 192 205 $url .= '/' . ltrim( $path, '/' ); 193 206 } else { -
trunk/tests/phpunit/tests/rest-api.php
r38771 r38790 276 276 public function test_rest_url_generation() { 277 277 // In pretty permalinks case, we expect a path of wp-json/ with no query. 278 update_option( 'permalink_structure','/%year%/%monthnum%/%day%/%postname%/' );278 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 279 279 $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/wp-json/', get_rest_url() ); 280 280 281 update_option( 'permalink_structure', '' ); 281 // In index permalinks case, we expect a path of index.php/wp-json/ with no query. 282 $this->set_permalink_structure( '/index.php/%year%/%monthnum%/%day%/%postname%/' ); 283 $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/index.php/wp-json/', get_rest_url() ); 284 282 285 // In non-pretty case, we get a query string to invoke the rest router. 286 $this->set_permalink_structure( '' ); 283 287 $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?rest_route=/', get_rest_url() ); 284 288
Note: See TracChangeset
for help on using the changeset viewer.