File Editor
Directories:
.. (Back)
codemirror
crop
dist
imgareaselect
jcrop
jquery
mediaelement
plupload
swfupload
thickbox
tinymce
Files:
admin-bar.js
admin-bar.min.js
api-request.js
api-request.min.js
autosave.js
autosave.min.js
backbone.js
backbone.min.js
clipboard.js
clipboard.min.js
colorpicker.js
colorpicker.min.js
comment-reply.js
comment-reply.min.js
customize-base.js
customize-base.min.js
customize-loader.js
customize-loader.min.js
customize-models.js
customize-models.min.js
customize-preview-nav-menus.js
customize-preview-nav-menus.min.js
customize-preview-widgets.js
customize-preview-widgets.min.js
customize-preview.js
customize-preview.min.js
customize-selective-refresh.js
customize-selective-refresh.min.js
customize-views.js
customize-views.min.js
heartbeat.js
heartbeat.min.js
hoverIntent.js
hoverIntent.min.js
hoverintent-js.min.js
imagesloaded.min.js
json2.js
json2.min.js
masonry.min.js
mce-view.js
mce-view.min.js
media-audiovideo.js
media-audiovideo.min.js
media-editor.js
media-editor.min.js
media-grid.js
media-grid.min.js
media-models.js
media-models.min.js
media-views.js
media-views.min.js
quicktags.js
quicktags.min.js
shortcode.js
shortcode.min.js
swfobject.js
tw-sack.js
tw-sack.min.js
twemoji.js
twemoji.min.js
underscore.js
underscore.min.js
utils.js
utils.min.js
wp-ajax-response.js
wp-ajax-response.min.js
wp-api.js
wp-api.min.js
wp-auth-check.js
wp-auth-check.min.js
wp-backbone.js
wp-backbone.min.js
wp-custom-header.js
wp-custom-header.min.js
wp-embed-template.js
wp-embed-template.min.js
wp-embed.js
wp-embed.min.js
wp-emoji-loader.js
wp-emoji-loader.min.js
wp-emoji-release.min.js
wp-emoji.js
wp-emoji.min.js
wp-list-revisions.js
wp-list-revisions.min.js
wp-lists.js
wp-lists.min.js
wp-pointer.js
wp-pointer.min.js
wp-sanitize.js
wp-sanitize.min.js
wp-util.js
wp-util.min.js
wpdialog.js
wpdialog.min.js
wplink.js
wplink.min.js
zxcvbn-async.js
zxcvbn-async.min.js
zxcvbn.min.js
Create New File
Create
Edit File: api-request.js
/** * Thin jQuery.ajax wrapper for WP REST API requests. * * Currently only applies to requests that do not use the `wp-api.js` Backbone * client library, though this may change. Serves several purposes: * * - Allows overriding these requests as needed by customized WP installations. * - Sends the REST API nonce as a request header. * - Allows specifying only an endpoint namespace/path instead of a full URL. * * @since 4.9.0 * @output wp-includes/js/api-request.js */ ( function( $ ) { var wpApiSettings = window.wpApiSettings; function apiRequest( options ) { options = apiRequest.buildAjaxOptions( options ); return apiRequest.transport( options ); } apiRequest.buildAjaxOptions = function( options ) { var url = options.url; var path = options.path; var namespaceTrimmed, endpointTrimmed, apiRoot; var headers, addNonceHeader, headerName; if ( typeof options.namespace === 'string' && typeof options.endpoint === 'string' ) { namespaceTrimmed = options.namespace.replace( /^\/|\/$/g, '' ); endpointTrimmed = options.endpoint.replace( /^\//, '' ); if ( endpointTrimmed ) { path = namespaceTrimmed + '/' + endpointTrimmed; } else { path = namespaceTrimmed; } } if ( typeof path === 'string' ) { 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. addNonceHeader = ! ( options.data && options.data._wpnonce ); headers = options.headers || {}; // If an 'X-WP-Nonce' header (or any case-insensitive variation // thereof) was specified, no need to add a nonce header. if ( addNonceHeader ) { for ( headerName in headers ) { if ( headers.hasOwnProperty( headerName ) ) { if ( headerName.toLowerCase() === 'x-wp-nonce' ) { addNonceHeader = false; break; } } } } if ( addNonceHeader ) { // Do not mutate the original headers object, if any. headers = $.extend( { 'X-WP-Nonce': wpApiSettings.nonce }, headers ); } // Do not mutate the original options object. options = $.extend( {}, options, { headers: headers, url: url } ); delete options.path; delete options.namespace; delete options.endpoint; return options; }; apiRequest.transport = $.ajax; /** @namespace wp */ window.wp = window.wp || {}; window.wp.apiRequest = apiRequest; } )( jQuery );
Save Changes
Rename File
Rename