mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-14 04:01:54 +01:00
REST API: Ensure rest_url() consistently has leading slash.
`rest_url()` inconsistent addes slashes to the passed path depending on whether the site has pretty permalinks enabled. Apart from being inconsistent, this also caused the unit tests to fail when pretty permalinks are enabled. Props frank-klein. Merges [42250] to the 5.0 branch. Partially reverts [43720]. Fixes #42452. See #41451, #45017. Built from https://develop.svn.wordpress.org/branches/5.0@43766 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43595 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
326cd6af15
commit
7edc3e2b98
@ -325,6 +325,8 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) {
|
||||
$path = '/';
|
||||
}
|
||||
|
||||
$path = '/' . ltrim( $path, '/' );
|
||||
|
||||
if ( is_multisite() && get_blog_option( $blog_id, 'permalink_structure' ) || get_option( 'permalink_structure' ) ) {
|
||||
global $wp_rewrite;
|
||||
|
||||
@ -334,7 +336,7 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) {
|
||||
$url = get_home_url( $blog_id, rest_get_url_prefix(), $scheme );
|
||||
}
|
||||
|
||||
$url .= '/' . ltrim( $path, '/' );
|
||||
$url .= $path;
|
||||
} else {
|
||||
$url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
|
||||
// nginx only allows HTTP/1.0 methods when redirecting from / to /index.php
|
||||
@ -343,8 +345,6 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) {
|
||||
$url .= 'index.php';
|
||||
}
|
||||
|
||||
$path = '/' . ltrim( $path, '/' );
|
||||
|
||||
$url = add_query_arg( 'rest_route', $path, $url );
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-43765';
|
||||
$wp_version = '5.0-alpha-43766';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user