PluginProbe
Polylang / 3.8.6
Polylang v3.8.6
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / js / build / admin.js

admin.js in Polylang 3.8.6, at js/build/admin.js

59 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ "use strict";
2
3 ;// ./js/src/lib/ajax-filter/index.js
4 /**
5 * @package Polylang
6 */
7
8 /**
9 * Adds data to all ajax requests made with jQuery.
10 *
11 * @since 3.7
12 *
13 * @param {Object} data The data to add.
14 * @returns {void}
15 */
16 function ajaxFilter( data ) {
17 if ( 'undefined' === typeof jQuery || ! data ) {
18 return;
19 }
20
21 const dataStr = jQuery.param( data );
22
23 jQuery.ajaxPrefilter( function ( options ) {
24 if ( -1 === options.url.indexOf( ajaxurl ) && -1 === ajaxurl.indexOf( options.url ) ) {
25 return;
26 }
27
28 if (
29 'undefined' === typeof options.data ||
30 null === options.data ||
31 'string' === typeof options.data && '' === options.data.trim()
32 ) {
33 // An empty string or null/undefined.
34 options.data = dataStr;
35 } else if ( 'string' === typeof options.data ) {
36 // A non-empty string: can be a JSON string or a query string.
37 try {
38 options.data = JSON.stringify( Object.assign( JSON.parse( options.data ), data ) );
39 } catch ( exception ) {
40 // A non-empty non-JSON string is considered a query string.
41 options.data = `${ options.data }&${ dataStr }`;
42 }
43 } else if ( jQuery.isPlainObject( options.data ) ) {
44 // An object.
45 options.data = Object.assign( options.data, data );
46 }
47 } );
48 }
49
50 ;// ./js/src/admin.js
51 /**
52 * @package Polylang
53 */
54
55
56
57 ajaxFilter( pll_admin?.ajax_filter );
58
59