PHP 8.1.33
Preview: application-passwords.js Size: 6.24 KB
/home/jambtst2015/public_html/www.securiskbrokers.com/wp-admin/js/application-passwords.js

/**
 * @output wp-admin/js/application-passwords.js
 */

( function( $ ) {
	var $appPassSection = $( '#application-passwords-section' ),
		$newAppPassForm = $appPassSection.find( '.create-application-password' ),
		$newAppPassField = $newAppPassForm.find( '.input' ),
		$newAppPassButton = $newAppPassForm.find( '.button' ),
		$appPassTwrapper = $appPassSection.find( '.application-passwords-list-table-wrapper' ),
		$appPassTbody = $appPassSection.find( 'tbody' ),
		$appPassTrNoItems = $appPassTbody.find( '.no-items' ),
		$removeAllBtn = $( '#revoke-all-application-passwords' ),
		tmplNewAppPass = wp.template( 'new-application-password' ),
		tmplAppPassRow = wp.template( 'application-password-row' ),
		userId = $( '#user_id' ).val();

	$newAppPassButton.on( 'click', function( e ) {
		e.preventDefault();

		if ( $newAppPassButton.prop( 'aria-disabled' ) ) {
			return;
		}

		var name = $newAppPassField.val();

		if ( 0 === name.length ) {
			$newAppPassField.trigger( 'focus' );
			return;
		}

		clearNotices();
		$newAppPassButton.prop( 'aria-disabled', true ).addClass( 'disabled' );

		var request = {
			name: name
		};

		/**
		 * Filters the request data used to create a new Application Password.
		 *
		 * @since 5.6.0
		 *
		 * @param {Object} request The request data.
		 * @param {number} userId  The id of the user the password is added for.
		 */
		request = wp.hooks.applyFilters( 'wp_application_passwords_new_password_request', request, userId );

		wp.apiRequest( {
			path: '/wp/v2/users/' + userId + '/application-passwords?_locale=user',
			method: 'POST',
			data: request
		} ).always( function() {
			$newAppPassButton.removeProp( 'aria-disabled' ).removeClass( 'disabled' );
		} ).done( function( response ) {
			$newAppPassField.val( '' );
			$newAppPassButton.prop( 'disabled', false );

			$newAppPassForm.after( tmplNewAppPass( {
				name: response.name,
				password: response.password
			} ) );
			$( '.new-application-password-notice' ).attr( 'tabindex', '-1' ).trigger( 'focus' );

			$appPassTbody.prepend( tmplAppPassRow( response ) );

			$appPassTwrapper.show();
			$appPassTrNoItems.remove();

			/**
			 * Fires after an application password has been successfully created.
			 *
			 * @since 5.6.0
			 *
			 * @param {Object} response The response data from the REST API.
			 * @param {Object} request  The request data used to create the password.
			 */
			wp.hooks.doAction( 'wp_application_passwords_created_password', response, request );
		} ).fail( handleErrorResponse );
	} );

	$appPassTbody.on( 'click', '.delete', function( e ) {
		e.preventDefault();

		if ( ! window.confirm( wp.i18n.__( 'Are you sure you want to revoke this password? This action cannot be undone.' ) ) ) {
			return;
		}

		var $submitButton = $( this ),
			$tr = $submitButton.closest( 'tr' ),
			uuid = $tr.data( 'uuid' );

		clearNotices();
		$submitButton.prop( 'disabled', true );

		wp.apiRequest( {
			path: '/wp/v2/users/' + userId + '/application-passwords/' + uuid + '?_locale=user',
			method: 'DELETE'
		} ).always( function() {
			$submitButton.prop( 'disabled', false );
		} ).done( function( response ) {
			if ( response.deleted ) {
				if ( 0 === $tr.siblings().length ) {
					$appPassTwrapper.hide();
				}
				$tr.remove();

				addNotice( wp.i18n.__( 'Application password revoked.' ), 'success' ).trigger( 'focus' );
			}
		} ).fail( handleErrorResponse );
	} );

	$removeAllBtn.on( 'click', function( e ) {
		e.preventDefault();

		if ( ! window.confirm( wp.i18n.__( 'Are you sure you want to revoke all passwords? This action cannot be undone.' ) ) ) {
			return;
		}

		var $submitButton = $( this );

		clearNotices();
		$submitButton.prop( 'disabled', true );

		wp.apiRequest( {
			path: '/wp/v2/users/' + userId + '/application-passwords?_locale=user',
			method: 'DELETE'
		} ).always( function() {
			$submitButton.prop( 'disabled', false );
		} ).done( function( response ) {
			if ( response.deleted ) {
				$appPassTbody.children().remove();
				$appPassSection.children( '.new-application-password' ).remove();
				$appPassTwrapper.hide();

				addNotice( wp.i18n.__( 'All application passwords revoked.' ), 'success' ).trigger( 'focus' );
			}
		} ).fail( handleErrorResponse );
	} );

	$appPassSection.on( 'click', '.notice-dismiss', function( e ) {
		e.preventDefault();
		var $el = $( this ).parent();
		$el.removeAttr( 'role' );
		$el.fadeTo( 100, 0, function () {
			$el.slideUp( 100, function () {
				$el.remove();
				$newAppPassField.trigger( 'focus' );
			} );
		} );
	} );

	$newAppPassField.on( 'keypress', function ( e ) {
		if ( 13 === e.which ) {
			e.preventDefault();
			$newAppPassButton.trigger( 'click' );
		}
	} );

	// If there are no items, don't display the table yet.  If there are, show it.
	if ( 0 === $appPassTbody.children( 'tr' ).not( $appPassTrNoItems ).length ) {
		$appPassTwrapper.hide();
	}

	/**
	 * Handles an error response from the REST API.
	 *
	 * @since 5.6.0
	 *
	 * @param {jqXHR} xhr The XHR object from the ajax call.
	 * @param {string} textStatus The string categorizing the ajax request's status.
	 * @param {string} errorThrown The HTTP status error text.
	 */
	function handleErrorResponse( xhr, textStatus, errorThrown ) {
		var errorMessage = errorThrown;

		if ( xhr.responseJSON && xhr.responseJSON.message ) {
			errorMessage = xhr.responseJSON.message;
		}

		addNotice( errorMessage, 'error' );
	}

	/**
	 * Displays a message in the Application Passwords section.
	 *
	 * @since 5.6.0
	 *
	 * @param {string} message The message to display.
	 * @param {string} type    The notice type. Either 'success' or 'error'.
	 * @returns {jQuery} The notice element.
	 */
	function addNotice( message, type ) {
		var $notice = $( '<div></div>' )
			.attr( 'role', 'alert' )
			.attr( 'tabindex', '-1' )
			.addClass( 'is-dismissible notice notice-' + type )
			.append( $( '<p></p>' ).text( message ) )
			.append(
				$( '<button></button>' )
					.attr( 'type', 'button' )
					.addClass( 'notice-dismiss' )
					.append( $( '<span></span>' ).addClass( 'screen-reader-text' ).text( wp.i18n.__( 'Dismiss this notice.' ) ) )
			);

		$newAppPassForm.after( $notice );

		return $notice;
	}

	/**
	 * Clears notice messages from the Application Passwords section.
	 *
	 * @since 5.6.0
	 */
	function clearNotices() {
		$( '.notice', $appPassSection ).remove();
	}
}( jQuery ) );

Directory Contents

Dirs: 1 × Files: 97

Name Size Perms Modified Actions
widgets DIR
- drwxr-xr-x 2024-12-09 13:54:39
Edit Download
2.86 KB lrw-r--r-- 2024-10-13 23:09:12
Edit Download
758 B lrw-r--r-- 2024-10-13 23:09:12
Edit Download
6.24 KB lrw-r--r-- 2023-09-18 02:51:24
Edit Download
2.95 KB lrw-r--r-- 2023-09-18 02:51:24
Edit Download
5.66 KB lrw-r--r-- 2021-02-24 00:45:04
Edit Download
2.04 KB lrw-r--r-- 2022-04-09 00:07:18
Edit Download
11.32 KB lrw-r--r-- 2020-07-28 03:35:02
Edit Download
3.01 KB lrw-r--r-- 2024-06-27 16:55:22
Edit Download
9.54 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
3.40 KB lrw-r--r-- 2022-04-09 00:07:18
Edit Download
2.85 KB lrw-r--r-- 2024-02-12 00:14:20
Edit Download
1.28 KB lrw-r--r-- 2022-04-09 00:07:18
Edit Download
61.00 KB lrw-r--r-- 2025-02-04 08:26:20
Edit Download
23.03 KB lrw-r--r-- 2025-02-04 08:26:20
Edit Download
3.35 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
1.18 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
1.98 KB lrw-r--r-- 2021-02-24 00:45:04
Edit Download
287.36 KB lrw-r--r-- 2025-02-04 08:03:16
Edit Download
109.16 KB lrw-r--r-- 2025-02-04 08:03:16
Edit Download
109.90 KB lrw-r--r-- 2025-09-30 21:02:50
Edit Download
46.24 KB lrw-r--r-- 2025-09-30 21:02:50
Edit Download
70.05 KB lrw-r--r-- 2024-06-21 22:17:14
Edit Download
27.41 KB lrw-r--r-- 2024-06-21 22:17:14
Edit Download
26.92 KB lrw-r--r-- 2024-04-12 21:47:14
Edit Download
8.59 KB lrw-r--r-- 2024-06-27 16:55:22
Edit Download
36.67 KB lrw-r--r-- 2024-08-26 02:37:20
Edit Download
15.01 KB lrw-r--r-- 2024-08-26 02:37:20
Edit Download
41.61 KB lrw-r--r-- 2024-04-12 21:47:14
Edit Download
13.14 KB lrw-r--r-- 2024-06-27 16:55:22
Edit Download
43.98 KB lrw-r--r-- 2024-10-07 20:57:16
Edit Download
12.76 KB lrw-r--r-- 2024-10-07 20:57:16
Edit Download
7.67 KB lrw-r--r-- 2023-07-18 02:03:26
Edit Download
5.41 KB lrw-r--r-- 2023-10-10 01:31:28
Edit Download
3.65 KB lrw-r--r-- 2023-10-10 01:31:28
Edit Download
39.98 KB lrw-r--r-- 2024-08-28 20:45:12
Edit Download
15.15 KB lrw-r--r-- 2024-08-28 20:45:12
Edit Download
20.17 KB lrw-r--r-- 2024-09-30 22:24:14
Edit Download
9.41 KB lrw-r--r-- 2024-09-30 22:24:14
Edit Download
7.61 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
2.93 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
23.09 KB lrw-r--r-- 2021-11-03 23:40:00
Edit Download
890 B lrw-r--r-- 2021-02-24 00:45:04
Edit Download
423 B lrw-r--r-- 2021-02-24 00:45:04
Edit Download
3.89 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
1.70 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
1.27 KB lrw-r--r-- 2021-02-24 00:45:04
Edit Download
611 B lrw-r--r-- 2022-04-09 00:07:18
Edit Download
3.38 KB lrw-r--r-- 2021-01-22 17:32:04
Edit Download
1.13 KB lrw-r--r-- 2023-02-02 21:36:32
Edit Download
6.61 KB lrw-r--r-- 2024-10-07 06:49:18
Edit Download
2.38 KB lrw-r--r-- 2024-10-07 06:49:18
Edit Download
59.07 KB lrw-r--r-- 2025-09-30 21:02:50
Edit Download
29.29 KB lrw-r--r-- 2025-09-30 21:02:50
Edit Download
4.14 KB lrw-r--r-- 2021-01-22 17:32:04
Edit Download
1.10 KB lrw-r--r-- 2021-01-22 17:32:04
Edit Download
1.31 KB lrw-r--r-- 2023-06-24 03:09:30
Edit Download
847 B lrw-r--r-- 2023-06-24 03:09:30
Edit Download
6.92 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
2.35 KB lrw-r--r-- 2023-02-02 21:36:32
Edit Download
38.68 KB lrw-r--r-- 2024-11-28 02:23:16
Edit Download
18.40 KB lrw-r--r-- 2024-11-28 02:23:16
Edit Download
18.40 KB lrw-r--r-- 2023-01-10 14:30:14
Edit Download
6.55 KB lrw-r--r-- 2022-09-23 23:55:30
Edit Download
10.67 KB lrw-r--r-- 2024-06-21 22:17:14
Edit Download
5.03 KB lrw-r--r-- 2024-06-21 22:17:14
Edit Download
33.92 KB lrw-r--r-- 2024-10-14 00:49:14
Edit Download
17.97 KB lrw-r--r-- 2024-10-14 00:49:14
Edit Download
876 B lrw-r--r-- 2020-07-07 22:55:04
Edit Download
620 B lrw-r--r-- 2020-07-07 22:55:04
Edit Download
13.15 KB lrw-r--r-- 2023-12-28 20:27:16
Edit Download
6.13 KB lrw-r--r-- 2023-12-28 20:27:16
Edit Download
6.10 KB lrw-r--r-- 2024-08-24 02:47:16
Edit Download
2.20 KB lrw-r--r-- 2024-08-24 02:47:16
Edit Download
3.20 KB lrw-r--r-- 2024-09-08 02:44:18
Edit Download
1.53 KB lrw-r--r-- 2024-09-08 02:44:18
Edit Download
10.88 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
3.00 KB lrw-r--r-- 2023-02-02 21:36:32
Edit Download
5.64 KB lrw-r--r-- 2024-02-19 03:16:14
Edit Download
2.22 KB lrw-r--r-- 2024-02-19 03:16:14
Edit Download
4.77 KB lrw-r--r-- 2022-04-12 23:37:14
Edit Download
1.96 KB lrw-r--r-- 2022-04-12 23:37:14
Edit Download
24.79 KB lrw-r--r-- 2024-04-12 21:47:14
Edit Download
11.46 KB lrw-r--r-- 2024-06-27 16:55:22
Edit Download
54.65 KB lrw-r--r-- 2024-08-19 23:19:18
Edit Download
26.40 KB lrw-r--r-- 2024-08-19 23:19:18
Edit Download
109.29 KB lrw-r--r-- 2024-09-30 22:24:14
Edit Download
47.23 KB lrw-r--r-- 2024-09-30 22:24:14
Edit Download
15.00 KB lrw-r--r-- 2024-09-18 04:14:14
Edit Download
6.70 KB lrw-r--r-- 2024-09-18 04:14:14
Edit Download
2.25 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
676 B lrw-r--r-- 2021-03-18 23:01:04
Edit Download
22.56 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
12.31 KB lrw-r--r-- 2023-02-02 21:36:32
Edit Download
7.52 KB lrw-r--r-- 2020-07-28 03:35:02
Edit Download
1.49 KB lrw-r--r-- 2023-02-02 21:36:32
Edit Download
740 B lrw-r--r-- 2021-03-18 23:01:04
Edit Download
458 B lrw-r--r-- 2021-03-18 23:01:04
Edit Download

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