diff --git a/wp-includes/js/api-request.js b/wp-includes/js/api-request.js index f0a84ef48f..4b299beb69 100644 --- a/wp-includes/js/api-request.js +++ b/wp-includes/js/api-request.js @@ -22,7 +22,7 @@ apiRequest.buildAjaxOptions = function( options ) { var url = options.url; var path = options.path; - var namespaceTrimmed, endpointTrimmed; + var namespaceTrimmed, endpointTrimmed, apiRoot; var headers, addNonceHeader, headerName; if ( @@ -38,7 +38,16 @@ } } if ( typeof path === 'string' ) { - url = wpApiSettings.root + path.replace( /^\//, '' ); + apiRoot = wpApiSettings.root; + path = path.replace( /^\//, '' ); + + // API root may already include query parameter prefix if site is + // configured to use plain permalinks. + if ( 'string' === typeof apiRoot && -1 !== apiRoot.indexOf( '?' ) ) { + path = path.replace( '?', '&' ); + } + + url = apiRoot + path; } // If ?_wpnonce=... is present, no need to add a nonce header. diff --git a/wp-includes/js/api-request.min.js b/wp-includes/js/api-request.min.js index 1776661e81..527a55fa23 100644 --- a/wp-includes/js/api-request.min.js +++ b/wp-includes/js/api-request.min.js @@ -1 +1 @@ -!function(a){function b(a){return a=b.buildAjaxOptions(a),b.transport(a)}var c=window.wpApiSettings;b.buildAjaxOptions=function(b){var d,e,f,g,h,i=b.url,j=b.path;if("string"==typeof b.namespace&&"string"==typeof b.endpoint&&(d=b.namespace.replace(/^\/|\/$/g,""),e=b.endpoint.replace(/^\//,""),j=e?d+"/"+e:d),"string"==typeof j&&(i=c.root+j.replace(/^\//,"")),g=!(b.data&&b.data._wpnonce),f=b.headers||{},g)for(h in f)if(f.hasOwnProperty(h)&&"x-wp-nonce"===h.toLowerCase()){g=!1;break}return g&&(f=a.extend({"X-WP-Nonce":c.nonce},f)),b=a.extend({},b,{headers:f,url:i}),delete b.path,delete b.namespace,delete b.endpoint,b},b.transport=a.ajax,window.wp=window.wp||{},window.wp.apiRequest=b}(jQuery); \ No newline at end of file +!function(a){function b(a){return a=b.buildAjaxOptions(a),b.transport(a)}var c=window.wpApiSettings;b.buildAjaxOptions=function(b){var d,e,f,g,h,i,j=b.url,k=b.path;if("string"==typeof b.namespace&&"string"==typeof b.endpoint&&(d=b.namespace.replace(/^\/|\/$/g,""),e=b.endpoint.replace(/^\//,""),k=e?d+"/"+e:d),"string"==typeof k&&(f=c.root,k=k.replace(/^\//,""),"string"==typeof f&&-1!==f.indexOf("?")&&(k=k.replace("?","&")),j=f+k),h=!(b.data&&b.data._wpnonce),g=b.headers||{},h)for(i in g)if(g.hasOwnProperty(i)&&"x-wp-nonce"===i.toLowerCase()){h=!1;break}return h&&(g=a.extend({"X-WP-Nonce":c.nonce},g)),b=a.extend({},b,{headers:g,url:j}),delete b.path,delete b.namespace,delete b.endpoint,b},b.transport=a.ajax,window.wp=window.wp||{},window.wp.apiRequest=b}(jQuery); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 4bbdb43f97..85a48efe14 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-42964'; +$wp_version = '5.0-alpha-42965'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.