PHP 8.1.33
Preview: wp-util.js Size: 4.57 KB
/home/jambtst2015/public_html/cccng.org/wp-includes/js/wp-util.js

/**
 * @output wp-includes/js/wp-util.js
 */

/* global _wpUtilSettings */

/** @namespace wp */
window.wp = window.wp || {};

(function ($) {
	// Check for the utility settings.
	var settings = typeof _wpUtilSettings === 'undefined' ? {} : _wpUtilSettings;

	/**
	 * wp.template( id )
	 *
	 * Fetch a JavaScript template for an id, and return a templating function for it.
	 *
	 * @param {string} id A string that corresponds to a DOM element with an id prefixed with "tmpl-".
	 *                    For example, "attachment" maps to "tmpl-attachment".
	 * @return {function} A function that lazily-compiles the template requested.
	 */
	wp.template = _.memoize(function ( id ) {
		var compiled,
			/*
			 * Underscore's default ERB-style templates are incompatible with PHP
			 * when asp_tags is enabled, so WordPress uses Mustache-inspired templating syntax.
			 *
			 * @see trac ticket #22344.
			 */
			options = {
				evaluate:    /<#([\s\S]+?)#>/g,
				interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
				escape:      /\{\{([^\}]+?)\}\}(?!\})/g,
				variable:    'data'
			};

		return function ( data ) {
			if ( ! document.getElementById( 'tmpl-' + id ) ) {
				throw new Error( 'Template not found: ' + '#tmpl-' + id );
			}
			compiled = compiled || _.template( $( '#tmpl-' + id ).html(),  options );
			return compiled( data );
		};
	});

	/*
	 * wp.ajax
	 * ------
	 *
	 * Tools for sending ajax requests with JSON responses and built in error handling.
	 * Mirrors and wraps jQuery's ajax APIs.
	 */
	wp.ajax = {
		settings: settings.ajax || {},

		/**
		 * wp.ajax.post( [action], [data] )
		 *
		 * Sends a POST request to WordPress.
		 *
		 * @param {(string|Object)} action The slug of the action to fire in WordPress or options passed
		 *                                 to jQuery.ajax.
		 * @param {Object=}         data   Optional. The data to populate $_POST with.
		 * @return {$.promise} A jQuery promise that represents the request,
		 *                     decorated with an abort() method.
		 */
		post: function( action, data ) {
			return wp.ajax.send({
				data: _.isObject( action ) ? action : _.extend( data || {}, { action: action })
			});
		},

		/**
		 * wp.ajax.send( [action], [options] )
		 *
		 * Sends a POST request to WordPress.
		 *
		 * @param {(string|Object)} action  The slug of the action to fire in WordPress or options passed
		 *                                  to jQuery.ajax.
		 * @param {Object=}         options Optional. The options passed to jQuery.ajax.
		 * @return {$.promise} A jQuery promise that represents the request,
		 *                     decorated with an abort() method.
		 */
		send: function( action, options ) {
			var promise, deferred;
			if ( _.isObject( action ) ) {
				options = action;
			} else {
				options = options || {};
				options.data = _.extend( options.data || {}, { action: action });
			}

			options = _.defaults( options || {}, {
				type:    'POST',
				url:     wp.ajax.settings.url,
				context: this
			});

			deferred = $.Deferred( function( deferred ) {
				// Transfer success/error callbacks.
				if ( options.success ) {
					deferred.done( options.success );
				}

				if ( options.error ) {
					deferred.fail( options.error );
				}

				delete options.success;
				delete options.error;

				// Use with PHP's wp_send_json_success() and wp_send_json_error().
				deferred.jqXHR = $.ajax( options ).done( function( response ) {
					// Treat a response of 1 as successful for backward compatibility with existing handlers.
					if ( response === '1' || response === 1 ) {
						response = { success: true };
					}

					if ( _.isObject( response ) && ! _.isUndefined( response.success ) ) {

						// When handling a media attachments request, get the total attachments from response headers.
						var context = this;
						deferred.done( function() {
							if (
								action &&
								action.data &&
								'query-attachments' === action.data.action &&
								deferred.jqXHR.hasOwnProperty( 'getResponseHeader' ) &&
								deferred.jqXHR.getResponseHeader( 'X-WP-Total' )
							) {
								context.totalAttachments = parseInt( deferred.jqXHR.getResponseHeader( 'X-WP-Total' ), 10 );
							} else {
								context.totalAttachments = 0;
							}
						} );
						deferred[ response.success ? 'resolveWith' : 'rejectWith' ]( this, [response.data] );
					} else {
						deferred.rejectWith( this, [response] );
					}
				}).fail( function() {
					deferred.rejectWith( this, arguments );
				});
			});

			promise = deferred.promise();
			promise.abort = function() {
				deferred.jqXHR.abort();
				return this;
			};

			return promise;
		}
	};

}(jQuery));

Directory Contents

Dirs: 12 × Files: 102

Name Size Perms Modified Actions
.hm DIR
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
crop DIR
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
dist DIR
- drwxr-xr-x 2025-10-08 17:06:32
Edit Download
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
jcrop DIR
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
jquery DIR
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
plupload DIR
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
swfupload DIR
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
thickbox DIR
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
tinymce DIR
- drwxr-xr-x 2024-12-30 07:14:41
Edit Download
10.30 KB lrw-r--r-- 2024-05-12 03:58:08
Edit Download
3.41 KB lrw-r--r-- 2024-05-12 03:58:08
Edit Download
3.25 KB lrw-r--r-- 2020-12-01 14:14:06
Edit Download
1023 B lrw-r--r-- 2022-04-09 05:37:18
Edit Download
21.95 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
5.67 KB lrw-r--r-- 2023-02-03 03:06:32
Edit Download
78.51 KB lrw-r--r-- 2024-12-17 21:37:28
Edit Download
23.73 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
26.18 KB lrw-r--r-- 2022-10-05 01:25:24
Edit Download
8.80 KB lrw-r--r-- 2024-06-27 23:21:44
Edit Download
28.40 KB lrw-r--r-- 2012-11-18 01:41:30
Edit Download
16.11 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
12.22 KB lrw-r--r-- 2024-12-17 21:37:28
Edit Download
2.96 KB lrw-r--r-- 2024-12-17 21:37:28
Edit Download
25.22 KB lrw-r--r-- 2023-05-20 19:49:24
Edit Download
7.67 KB lrw-r--r-- 2023-02-03 03:06:32
Edit Download
7.72 KB lrw-r--r-- 2024-04-13 03:17:14
Edit Download
3.47 KB lrw-r--r-- 2023-02-03 03:06:32
Edit Download
6.66 KB lrw-r--r-- 2020-06-25 22:13:08
Edit Download
3.59 KB lrw-r--r-- 2023-02-03 03:06:32
Edit Download
14.67 KB lrw-r--r-- 2020-07-28 09:05:02
Edit Download
4.92 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
22.71 KB lrw-r--r-- 2020-06-20 22:28:10
Edit Download
7.64 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
27.30 KB lrw-r--r-- 2020-07-28 09:05:02
Edit Download
10.45 KB lrw-r--r-- 2023-02-03 03:06:32
Edit Download
32.55 KB lrw-r--r-- 2024-04-13 03:17:14
Edit Download
10.44 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
4.95 KB lrw-r--r-- 2018-06-28 12:00:16
Edit Download
2.39 KB lrw-r--r-- 2021-01-07 01:59:24
Edit Download
2.21 KB lrw-r--r-- 2024-04-09 06:44:14
Edit Download
23.49 KB lrw-r--r-- 2024-12-17 21:37:28
Edit Download
5.81 KB lrw-r--r-- 2024-12-17 21:37:28
Edit Download
1.68 KB lrw-r--r-- 2019-12-10 11:33:02
Edit Download
7.06 KB lrw-r--r-- 2022-01-04 01:33:18
Edit Download
1.46 KB lrw-r--r-- 2024-06-27 23:21:44
Edit Download
5.39 KB lrw-r--r-- 2023-08-12 03:48:26
Edit Download
17.99 KB lrw-r--r-- 2015-10-06 23:32:26
Edit Download
3.07 KB lrw-r--r-- 2024-06-27 23:21:44
Edit Download
23.57 KB lrw-r--r-- 2020-06-14 04:23:28
Edit Download
25.24 KB lrw-r--r-- 2023-10-10 07:01:28
Edit Download
9.54 KB lrw-r--r-- 2024-06-27 23:21:44
Edit Download
24.24 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
11.77 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
28.44 KB lrw-r--r-- 2020-07-28 09:05:02
Edit Download
10.63 KB lrw-r--r-- 2023-02-03 03:06:32
Edit Download
26.03 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
12.95 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
42.58 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
12.97 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
266.92 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
108.12 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
2.08 KB lrw-r--r-- 2024-04-09 06:44:14
Edit Download
22.07 KB lrw-r--r-- 2021-09-09 08:59:58
Edit Download
10.87 KB lrw-r--r-- 2023-02-03 03:06:32
Edit Download
10.51 KB lrw-r--r-- 2020-01-29 11:15:18
Edit Download
2.58 KB lrw-r--r-- 2022-09-24 05:25:30
Edit Download
9.99 KB lrw-r--r-- 2012-04-18 08:39:30
Edit Download
4.85 KB lrw-r--r-- 2012-08-23 09:34:18
Edit Download
3.21 KB lrw-r--r-- 2022-04-09 05:37:18
Edit Download
32.67 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
15.93 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
67.12 KB lrw-r--r-- 2024-12-17 21:37:28
Edit Download
18.46 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
4.56 KB lrw-r--r-- 2020-01-29 11:15:18
Edit Download
1.82 KB lrw-r--r-- 2022-09-24 05:25:30
Edit Download
3.81 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
2.51 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
45.88 KB lrw-r--r-- 2023-01-10 20:00:14
Edit Download
14.34 KB lrw-r--r-- 2024-06-27 23:21:44
Edit Download
4.11 KB lrw-r--r-- 2021-03-19 04:31:04
Edit Download
1.62 KB lrw-r--r-- 2021-03-19 04:31:04
Edit Download
14.88 KB lrw-r--r-- 2024-04-13 03:17:14
Edit Download
2.97 KB lrw-r--r-- 2022-04-09 05:37:18
Edit Download
10.22 KB lrw-r--r-- 2021-04-10 22:10:06
Edit Download
4.34 KB lrw-r--r-- 2023-02-03 03:06:32
Edit Download
6.62 KB lrw-r--r-- 2021-11-11 13:19:18
Edit Download
3.10 KB lrw-r--r-- 2024-06-27 23:21:44
Edit Download
3.14 KB lrw-r--r-- 2023-08-11 05:19:18
Edit Download
1.22 KB lrw-r--r-- 2024-06-27 23:21:44
Edit Download
13.68 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
3.02 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
18.80 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
8.76 KB lrw-r--r-- 2023-02-02 11:23:26
Edit Download
2.82 KB lrw-r--r-- 2023-02-02 11:23:26
Edit Download
970 B lrw-r--r-- 2018-06-28 12:00:16
Edit Download
597 B lrw-r--r-- 2021-01-07 01:59:24
Edit Download
24.72 KB lrw-r--r-- 2023-06-25 00:02:20
Edit Download
7.34 KB lrw-r--r-- 2023-06-25 00:02:20
Edit Download
9.99 KB lrw-r--r-- 2021-02-17 06:55:04
Edit Download
3.54 KB lrw-r--r-- 2022-04-09 05:37:18
Edit Download
1.31 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
458 B lrw-r--r-- 2022-04-09 05:37:18
Edit Download
4.57 KB lrw-r--r-- 2022-09-20 13:22:10
Edit Download
1.39 KB lrw-r--r-- 2022-09-20 13:22:10
Edit Download
569 B lrw-r--r-- 2023-01-25 07:43:12
Edit Download
281 B lrw-r--r-- 2023-01-25 07:43:12
Edit Download
20.74 KB lrw-r--r-- 2025-10-08 17:06:31
Edit Download
11.05 KB lrw-r--r-- 2024-12-17 21:37:28
Edit Download
821 B lrw-r--r-- 2018-06-28 12:00:16
Edit Download
351 B lrw-r--r-- 2021-02-24 03:15:20
Edit Download
802.97 KB lrw-r--r-- 2019-10-26 09:47:08
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).