wp/wp-includes/js/api-request.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     6  *
     6  *
     7  * - Allows overriding these requests as needed by customized WP installations.
     7  * - Allows overriding these requests as needed by customized WP installations.
     8  * - Sends the REST API nonce as a request header.
     8  * - Sends the REST API nonce as a request header.
     9  * - Allows specifying only an endpoint namespace/path instead of a full URL.
     9  * - Allows specifying only an endpoint namespace/path instead of a full URL.
    10  *
    10  *
    11  * @since     4.9.0
    11  * @since 4.9.0
    12  * @output wp-includes/js/api-request.js
    12  * @output wp-includes/js/api-request.js
    13  */
    13  */
    14 
    14 
    15 ( function( $ ) {
    15 ( function( $ ) {
    16 	var wpApiSettings = window.wpApiSettings;
    16 	var wpApiSettings = window.wpApiSettings;
    40 		}
    40 		}
    41 		if ( typeof path === 'string' ) {
    41 		if ( typeof path === 'string' ) {
    42 			apiRoot = wpApiSettings.root;
    42 			apiRoot = wpApiSettings.root;
    43 			path = path.replace( /^\//, '' );
    43 			path = path.replace( /^\//, '' );
    44 
    44 
    45 			// API root may already include query parameter prefix if site is
    45 			// API root may already include query parameter prefix
    46 			// configured to use plain permalinks.
    46 			// if site is configured to use plain permalinks.
    47 			if ( 'string' === typeof apiRoot && -1 !== apiRoot.indexOf( '?' ) ) {
    47 			if ( 'string' === typeof apiRoot && -1 !== apiRoot.indexOf( '?' ) ) {
    48 				path = path.replace( '?', '&' );
    48 				path = path.replace( '?', '&' );
    49 			}
    49 			}
    50 
    50 
    51 			url = apiRoot + path;
    51 			url = apiRoot + path;