wp/wp-admin/js/updates.js
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
     1 /**
     1 /**
     2  * Functions for ajaxified updates, deletions and installs inside the WordPress admin.
     2  * Functions for ajaxified updates, deletions and installs inside the WordPress admin.
     3  *
     3  *
     4  * @version 4.2.0
     4  * @version 4.2.0
     5  *
     5  * @output wp-admin/js/updates.js
     6  * @package WordPress
       
     7  * @subpackage Administration
       
     8  */
     6  */
     9 
     7 
    10 /* global pagenow */
     8 /* global pagenow */
    11 
     9 
    12 /**
    10 /**
    36 	/**
    34 	/**
    37 	 * The WP Updates object.
    35 	 * The WP Updates object.
    38 	 *
    36 	 *
    39 	 * @since 4.2.0
    37 	 * @since 4.2.0
    40 	 *
    38 	 *
    41 	 * @type {object}
    39 	 * @namespace wp.updates
    42 	 */
    40 	 */
    43 	wp.updates = {};
    41 	wp.updates = {};
    44 
    42 
    45 	/**
    43 	/**
    46 	 * User nonce for ajax calls.
    44 	 * User nonce for ajax calls.
    82 	 * Filesystem credentials to be packaged along with the request.
    80 	 * Filesystem credentials to be packaged along with the request.
    83 	 *
    81 	 *
    84 	 * @since 4.2.0
    82 	 * @since 4.2.0
    85 	 * @since 4.6.0 Added `available` property to indicate whether credentials have been provided.
    83 	 * @since 4.6.0 Added `available` property to indicate whether credentials have been provided.
    86 	 *
    84 	 *
    87 	 * @type {object} filesystemCredentials                    Holds filesystem credentials.
    85 	 * @type {Object}
    88 	 * @type {object} filesystemCredentials.ftp                Holds FTP credentials.
    86 	 * @property {Object} filesystemCredentials.ftp                Holds FTP credentials.
    89 	 * @type {string} filesystemCredentials.ftp.host           FTP host. Default empty string.
    87 	 * @property {string} filesystemCredentials.ftp.host           FTP host. Default empty string.
    90 	 * @type {string} filesystemCredentials.ftp.username       FTP user name. Default empty string.
    88 	 * @property {string} filesystemCredentials.ftp.username       FTP user name. Default empty string.
    91 	 * @type {string} filesystemCredentials.ftp.password       FTP password. Default empty string.
    89 	 * @property {string} filesystemCredentials.ftp.password       FTP password. Default empty string.
    92 	 * @type {string} filesystemCredentials.ftp.connectionType Type of FTP connection. 'ssh', 'ftp', or 'ftps'.
    90 	 * @property {string} filesystemCredentials.ftp.connectionType Type of FTP connection. 'ssh', 'ftp', or 'ftps'.
    93 	 *                                                         Default empty string.
    91 	 *                                                             Default empty string.
    94 	 * @type {object} filesystemCredentials.ssh                Holds SSH credentials.
    92 	 * @property {Object} filesystemCredentials.ssh                Holds SSH credentials.
    95 	 * @type {string} filesystemCredentials.ssh.publicKey      The public key. Default empty string.
    93 	 * @property {string} filesystemCredentials.ssh.publicKey      The public key. Default empty string.
    96 	 * @type {string} filesystemCredentials.ssh.privateKey     The private key. Default empty string.
    94 	 * @property {string} filesystemCredentials.ssh.privateKey     The private key. Default empty string.
    97 	 * @type {string} filesystemCredentials.fsNonce            Filesystem credentials form nonce.
    95 	 * @property {string} filesystemCredentials.fsNonce            Filesystem credentials form nonce.
    98 	 * @type {bool}   filesystemCredentials.available          Whether filesystem credentials have been provided.
    96 	 * @property {bool}   filesystemCredentials.available          Whether filesystem credentials have been provided.
    99 	 *                                                         Default 'false'.
    97 	 *                                                             Default 'false'.
   100 	 */
    98 	 */
   101 	wp.updates.filesystemCredentials = {
    99 	wp.updates.filesystemCredentials = {
   102 		ftp:       {
   100 		ftp:       {
   103 			host:           '',
   101 			host:           '',
   104 			username:       '',
   102 			username:       '',
   126 	/**
   124 	/**
   127 	 * Admin notice template.
   125 	 * Admin notice template.
   128 	 *
   126 	 *
   129 	 * @since 4.6.0
   127 	 * @since 4.6.0
   130 	 *
   128 	 *
   131 	 * @type {function} A function that lazily-compiles the template requested.
   129 	 * @type {function}
   132 	 */
   130 	 */
   133 	wp.updates.adminNotice = wp.template( 'wp-updates-admin-notice' );
   131 	wp.updates.adminNotice = wp.template( 'wp-updates-admin-notice' );
   134 
   132 
   135 	/**
   133 	/**
   136 	 * Update queue.
   134 	 * Update queue.
   168 	 * @param {number=} data.errors        Optional. The amount of failed operations.
   166 	 * @param {number=} data.errors        Optional. The amount of failed operations.
   169 	 * @param {Array=}  data.errorMessages Optional. Error messages of failed operations.
   167 	 * @param {Array=}  data.errorMessages Optional. Error messages of failed operations.
   170 	 *
   168 	 *
   171 	 */
   169 	 */
   172 	wp.updates.addAdminNotice = function( data ) {
   170 	wp.updates.addAdminNotice = function( data ) {
   173 		var $notice = $( data.selector ), $adminNotice;
   171 		var $notice = $( data.selector ),
       
   172 			$headerEnd = $( '.wp-header-end' ),
       
   173 			$adminNotice;
   174 
   174 
   175 		delete data.selector;
   175 		delete data.selector;
   176 		$adminNotice = wp.updates.adminNotice( data );
   176 		$adminNotice = wp.updates.adminNotice( data );
   177 
   177 
   178 		// Check if this admin notice already exists.
   178 		// Check if this admin notice already exists.
   180 			$notice = $( '#' + data.id );
   180 			$notice = $( '#' + data.id );
   181 		}
   181 		}
   182 
   182 
   183 		if ( $notice.length ) {
   183 		if ( $notice.length ) {
   184 			$notice.replaceWith( $adminNotice );
   184 			$notice.replaceWith( $adminNotice );
       
   185 		} else if ( $headerEnd.length ) {
       
   186 			$headerEnd.after( $adminNotice );
   185 		} else {
   187 		} else {
   186 			if ( 'customize' === pagenow ) {
   188 			if ( 'customize' === pagenow ) {
   187 				$( '.customize-themes-notifications' ).append( $adminNotice );
   189 				$( '.customize-themes-notifications' ).append( $adminNotice );
   188 			} else {
   190 			} else {
   189 				$( '.wrap' ).find( '> h1' ).after( $adminNotice );
   191 				$( '.wrap' ).find( '> h1' ).after( $adminNotice );
   258 			wp.updates.queueChecker();
   260 			wp.updates.queueChecker();
   259 		}
   261 		}
   260 
   262 
   261 		if ( 'undefined' !== typeof response.debug && window.console && window.console.log ) {
   263 		if ( 'undefined' !== typeof response.debug && window.console && window.console.log ) {
   262 			_.map( response.debug, function( message ) {
   264 			_.map( response.debug, function( message ) {
   263 				window.console.log( $( '<p />' ).html( message ).text() );
   265 				// Remove all HTML tags and write a message to the console.
       
   266 				window.console.log( wp.sanitize.stripTagsAndEncodeText( message ) );
   264 			} );
   267 			} );
   265 		}
   268 		}
   266 	};
   269 	};
   267 
   270 
   268 	/**
   271 	/**
   405 	 * Updates the UI appropriately after a successful plugin update.
   408 	 * Updates the UI appropriately after a successful plugin update.
   406 	 *
   409 	 *
   407 	 * @since 4.2.0
   410 	 * @since 4.2.0
   408 	 * @since 4.6.0 More accurately named `updatePluginSuccess`.
   411 	 * @since 4.6.0 More accurately named `updatePluginSuccess`.
   409 	 *
   412 	 *
   410 	 * @typedef {object} updatePluginSuccess
       
   411 	 * @param {object} response            Response from the server.
   413 	 * @param {object} response            Response from the server.
   412 	 * @param {string} response.slug       Slug of the plugin to be updated.
   414 	 * @param {string} response.slug       Slug of the plugin to be updated.
   413 	 * @param {string} response.plugin     Basename of the plugin to be updated.
   415 	 * @param {string} response.plugin     Basename of the plugin to be updated.
   414 	 * @param {string} response.pluginName Name of the plugin to be updated.
   416 	 * @param {string} response.pluginName Name of the plugin to be updated.
   415 	 * @param {string} response.oldVersion Old version of the plugin.
   417 	 * @param {string} response.oldVersion Old version of the plugin.
   450 	 * Updates the UI appropriately after a failed plugin update.
   452 	 * Updates the UI appropriately after a failed plugin update.
   451 	 *
   453 	 *
   452 	 * @since 4.2.0
   454 	 * @since 4.2.0
   453 	 * @since 4.6.0 More accurately named `updatePluginError`.
   455 	 * @since 4.6.0 More accurately named `updatePluginError`.
   454 	 *
   456 	 *
   455 	 * @typedef {object} updatePluginError
       
   456 	 * @param {object}  response              Response from the server.
   457 	 * @param {object}  response              Response from the server.
   457 	 * @param {string}  response.slug         Slug of the plugin to be updated.
   458 	 * @param {string}  response.slug         Slug of the plugin to be updated.
   458 	 * @param {string}  response.plugin       Basename of the plugin to be updated.
   459 	 * @param {string}  response.plugin       Basename of the plugin to be updated.
   459 	 * @param {string=} response.pluginName   Optional. Name of the plugin to be updated.
   460 	 * @param {string=} response.pluginName   Optional. Name of the plugin to be updated.
   460 	 * @param {string}  response.errorCode    Error code for the error that occurred.
   461 	 * @param {string}  response.errorCode    Error code for the error that occurred.
   572 	/**
   573 	/**
   573 	 * Updates the UI appropriately after a successful plugin install.
   574 	 * Updates the UI appropriately after a successful plugin install.
   574 	 *
   575 	 *
   575 	 * @since 4.6.0
   576 	 * @since 4.6.0
   576 	 *
   577 	 *
   577 	 * @typedef {object} installPluginSuccess
       
   578 	 * @param {object} response             Response from the server.
   578 	 * @param {object} response             Response from the server.
   579 	 * @param {string} response.slug        Slug of the installed plugin.
   579 	 * @param {string} response.slug        Slug of the installed plugin.
   580 	 * @param {string} response.pluginName  Name of the installed plugin.
   580 	 * @param {string} response.pluginName  Name of the installed plugin.
   581 	 * @param {string} response.activateUrl URL to activate the just installed plugin.
   581 	 * @param {string} response.activateUrl URL to activate the just installed plugin.
   582 	 */
   582 	 */
   583 	wp.updates.installPluginSuccess = function( response ) {
   583 	wp.updates.installPluginSuccess = function( response ) {
   584 		var $message = $( '.plugin-card-' + response.slug ).find( '.install-now' );
   584 		var $message = $( '.plugin-card-' + response.slug ).find( '.install-now' );
   585 
   585 
   586 		$message
   586 		$message
   587 			.removeClass( 'updating-message' )
   587 			.removeClass( 'updating-message' )
   588 			.addClass( 'updated-message installed' )
   588 			.addClass( 'updated-message installed button-disabled' )
   589 			.attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) )
   589 			.attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) )
   590 			.text( wp.updates.l10n.pluginInstalled );
   590 			.text( wp.updates.l10n.pluginInstalled );
   591 
   591 
   592 		if ( $message.hasClass( 'button-primary' ) ) {
       
   593 			$message.addClass( 'button-primary-disabled' );
       
   594 		} else {
       
   595 			$message.addClass( 'button-disabled' );
       
   596 		}
       
   597 
       
   598 		wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' );
   592 		wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' );
   599 
   593 
   600 		$document.trigger( 'wp-plugin-install-success', response );
   594 		$document.trigger( 'wp-plugin-install-success', response );
   601 
   595 
   602 		if ( response.activateUrl ) {
   596 		if ( response.activateUrl ) {
   603 			setTimeout( function() {
   597 			setTimeout( function() {
   604 
   598 
   605 				// Transform the 'Install' button into an 'Activate' button.
   599 				// Transform the 'Install' button into an 'Activate' button.
   606 				$message.removeClass( 'install-now installed button-primary-disabled button-secondary-disabled button-disabled updated-message' )
   600 				$message.removeClass( 'install-now installed button-disabled updated-message' ).addClass( 'activate-now button-primary' )
   607 					.addClass( 'activate-now' )
       
   608 					.attr( 'href', response.activateUrl )
   601 					.attr( 'href', response.activateUrl )
   609 					.attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) )
   602 					.attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) )
   610 					.text( response.activateLabel || wp.updates.l10n.activatePlugin );
   603 					.text( wp.updates.l10n.activatePlugin );
   611 			}, 1000 );
   604 			}, 1000 );
   612 		}
   605 		}
   613 	};
   606 	};
   614 
   607 
   615 	/**
   608 	/**
   616 	 * Updates the UI appropriately after a failed plugin install.
   609 	 * Updates the UI appropriately after a failed plugin install.
   617 	 *
   610 	 *
   618 	 * @since 4.6.0
   611 	 * @since 4.6.0
   619 	 *
   612 	 *
   620 	 * @typedef {object} installPluginError
       
   621 	 * @param {object}  response              Response from the server.
   613 	 * @param {object}  response              Response from the server.
   622 	 * @param {string}  response.slug         Slug of the plugin to be installed.
   614 	 * @param {string}  response.slug         Slug of the plugin to be installed.
   623 	 * @param {string=} response.pluginName   Optional. Name of the plugin to be installed.
   615 	 * @param {string=} response.pluginName   Optional. Name of the plugin to be installed.
   624 	 * @param {string}  response.errorCode    Error code for the error that occurred.
   616 	 * @param {string}  response.errorCode    Error code for the error that occurred.
   625 	 * @param {string}  response.errorMessage The error that occurred.
   617 	 * @param {string}  response.errorMessage The error that occurred.
   666 	/**
   658 	/**
   667 	 * Updates the UI appropriately after a successful importer install.
   659 	 * Updates the UI appropriately after a successful importer install.
   668 	 *
   660 	 *
   669 	 * @since 4.6.0
   661 	 * @since 4.6.0
   670 	 *
   662 	 *
   671 	 * @typedef {object} installImporterSuccess
       
   672 	 * @param {object} response             Response from the server.
   663 	 * @param {object} response             Response from the server.
   673 	 * @param {string} response.slug        Slug of the installed plugin.
   664 	 * @param {string} response.slug        Slug of the installed plugin.
   674 	 * @param {string} response.pluginName  Name of the installed plugin.
   665 	 * @param {string} response.pluginName  Name of the installed plugin.
   675 	 * @param {string} response.activateUrl URL to activate the just installed plugin.
   666 	 * @param {string} response.activateUrl URL to activate the just installed plugin.
   676 	 */
   667 	 */
   698 	/**
   689 	/**
   699 	 * Updates the UI appropriately after a failed importer install.
   690 	 * Updates the UI appropriately after a failed importer install.
   700 	 *
   691 	 *
   701 	 * @since 4.6.0
   692 	 * @since 4.6.0
   702 	 *
   693 	 *
   703 	 * @typedef {object} installImporterError
       
   704 	 * @param {object}  response              Response from the server.
   694 	 * @param {object}  response              Response from the server.
   705 	 * @param {string}  response.slug         Slug of the plugin to be installed.
   695 	 * @param {string}  response.slug         Slug of the plugin to be installed.
   706 	 * @param {string=} response.pluginName   Optional. Name of the plugin to be installed.
   696 	 * @param {string=} response.pluginName   Optional. Name of the plugin to be installed.
   707 	 * @param {string}  response.errorCode    Error code for the error that occurred.
   697 	 * @param {string}  response.errorCode    Error code for the error that occurred.
   708 	 * @param {string}  response.errorMessage The error that occurred.
   698 	 * @param {string}  response.errorMessage The error that occurred.
   727 		} );
   717 		} );
   728 
   718 
   729 		$installLink
   719 		$installLink
   730 			.removeClass( 'updating-message' )
   720 			.removeClass( 'updating-message' )
   731 			.text( wp.updates.l10n.installNow )
   721 			.text( wp.updates.l10n.installNow )
   732 			.attr( 'aria-label', wp.updates.l10n.installNowLabel.replace( '%s', pluginName ) );
   722 			.attr( 'aria-label', wp.updates.l10n.pluginInstallNowLabel.replace( '%s', pluginName ) );
   733 
   723 
   734 		wp.a11y.speak( errorMessage, 'assertive' );
   724 		wp.a11y.speak( errorMessage, 'assertive' );
   735 
   725 
   736 		$document.trigger( 'wp-importer-install-error', response );
   726 		$document.trigger( 'wp-importer-install-error', response );
   737 	};
   727 	};
   773 	/**
   763 	/**
   774 	 * Updates the UI appropriately after a successful plugin deletion.
   764 	 * Updates the UI appropriately after a successful plugin deletion.
   775 	 *
   765 	 *
   776 	 * @since 4.6.0
   766 	 * @since 4.6.0
   777 	 *
   767 	 *
   778 	 * @typedef {object} deletePluginSuccess
   768 	 * @param {Object} response            Response from the server.
   779 	 * @param {object} response            Response from the server.
       
   780 	 * @param {string} response.slug       Slug of the plugin that was deleted.
   769 	 * @param {string} response.slug       Slug of the plugin that was deleted.
   781 	 * @param {string} response.plugin     Base name of the plugin that was deleted.
   770 	 * @param {string} response.plugin     Base name of the plugin that was deleted.
   782 	 * @param {string} response.pluginName Name of the plugin that was deleted.
   771 	 * @param {string} response.pluginName Name of the plugin that was deleted.
   783 	 */
   772 	 */
   784 	wp.updates.deletePluginSuccess = function( response ) {
   773 	wp.updates.deletePluginSuccess = function( response ) {
   788 			var $form            = $( '#bulk-action-form' ),
   777 			var $form            = $( '#bulk-action-form' ),
   789 				$views           = $( '.subsubsub' ),
   778 				$views           = $( '.subsubsub' ),
   790 				$pluginRow       = $( this ),
   779 				$pluginRow       = $( this ),
   791 				columnCount      = $form.find( 'thead th:not(.hidden), thead td' ).length,
   780 				columnCount      = $form.find( 'thead th:not(.hidden), thead td' ).length,
   792 				pluginDeletedRow = wp.template( 'item-deleted-row' ),
   781 				pluginDeletedRow = wp.template( 'item-deleted-row' ),
   793 				/** @type {object} plugins Base names of plugins in their different states. */
   782 				/**
       
   783 				 * Plugins Base names of plugins in their different states.
       
   784 				 *
       
   785 				 * @type {Object}
       
   786 				 */
   794 				plugins          = settings.plugins;
   787 				plugins          = settings.plugins;
   795 
   788 
   796 			// Add a success message after deleting a plugin.
   789 			// Add a success message after deleting a plugin.
   797 			if ( ! $pluginRow.hasClass( 'plugin-update-tr' ) ) {
   790 			if ( ! $pluginRow.hasClass( 'plugin-update-tr' ) ) {
   798 				$pluginRow.after(
   791 				$pluginRow.after(
   863 	/**
   856 	/**
   864 	 * Updates the UI appropriately after a failed plugin deletion.
   857 	 * Updates the UI appropriately after a failed plugin deletion.
   865 	 *
   858 	 *
   866 	 * @since 4.6.0
   859 	 * @since 4.6.0
   867 	 *
   860 	 *
   868 	 * @typedef {object} deletePluginError
       
   869 	 * @param {object}  response              Response from the server.
   861 	 * @param {object}  response              Response from the server.
   870 	 * @param {string}  response.slug         Slug of the plugin to be deleted.
   862 	 * @param {string}  response.slug         Slug of the plugin to be deleted.
   871 	 * @param {string}  response.plugin       Base name of the plugin to be deleted
   863 	 * @param {string}  response.plugin       Base name of the plugin to be deleted
   872 	 * @param {string=} response.pluginName   Optional. Name of the plugin to be deleted.
   864 	 * @param {string=} response.pluginName   Optional. Name of the plugin to be deleted.
   873 	 * @param {string}  response.errorCode    Error code for the error that occurred.
   865 	 * @param {string}  response.errorCode    Error code for the error that occurred.
   976 	/**
   968 	/**
   977 	 * Updates the UI appropriately after a successful theme update.
   969 	 * Updates the UI appropriately after a successful theme update.
   978 	 *
   970 	 *
   979 	 * @since 4.6.0
   971 	 * @since 4.6.0
   980 	 *
   972 	 *
   981 	 * @typedef {object} updateThemeSuccess
       
   982 	 * @param {object} response
   973 	 * @param {object} response
   983 	 * @param {string} response.slug       Slug of the theme to be updated.
   974 	 * @param {string} response.slug       Slug of the theme to be updated.
   984 	 * @param {object} response.theme      Updated theme.
   975 	 * @param {object} response.theme      Updated theme.
   985 	 * @param {string} response.oldVersion Old version of the theme.
   976 	 * @param {string} response.oldVersion Old version of the theme.
   986 	 * @param {string} response.newVersion New version of the theme.
   977 	 * @param {string} response.newVersion New version of the theme.
  1038 	/**
  1029 	/**
  1039 	 * Updates the UI appropriately after a failed theme update.
  1030 	 * Updates the UI appropriately after a failed theme update.
  1040 	 *
  1031 	 *
  1041 	 * @since 4.6.0
  1032 	 * @since 4.6.0
  1042 	 *
  1033 	 *
  1043 	 * @typedef {object} updateThemeError
       
  1044 	 * @param {object} response              Response from the server.
  1034 	 * @param {object} response              Response from the server.
  1045 	 * @param {string} response.slug         Slug of the theme to be updated.
  1035 	 * @param {string} response.slug         Slug of the theme to be updated.
  1046 	 * @param {string} response.errorCode    Error code for the error that occurred.
  1036 	 * @param {string} response.errorCode    Error code for the error that occurred.
  1047 	 * @param {string} response.errorMessage The error that occurred.
  1037 	 * @param {string} response.errorMessage The error that occurred.
  1048 	 */
  1038 	 */
  1124 	/**
  1114 	/**
  1125 	 * Updates the UI appropriately after a successful theme install.
  1115 	 * Updates the UI appropriately after a successful theme install.
  1126 	 *
  1116 	 *
  1127 	 * @since 4.6.0
  1117 	 * @since 4.6.0
  1128 	 *
  1118 	 *
  1129 	 * @typedef {object} installThemeSuccess
       
  1130 	 * @param {object} response              Response from the server.
  1119 	 * @param {object} response              Response from the server.
  1131 	 * @param {string} response.slug         Slug of the theme to be installed.
  1120 	 * @param {string} response.slug         Slug of the theme to be installed.
  1132 	 * @param {string} response.customizeUrl URL to the Customizer for the just installed theme.
  1121 	 * @param {string} response.customizeUrl URL to the Customizer for the just installed theme.
  1133 	 * @param {string} response.activateUrl  URL to activate the just installed theme.
  1122 	 * @param {string} response.activateUrl  URL to activate the just installed theme.
  1134 	 */
  1123 	 */
  1175 	/**
  1164 	/**
  1176 	 * Updates the UI appropriately after a failed theme install.
  1165 	 * Updates the UI appropriately after a failed theme install.
  1177 	 *
  1166 	 *
  1178 	 * @since 4.6.0
  1167 	 * @since 4.6.0
  1179 	 *
  1168 	 *
  1180 	 * @typedef {object} installThemeError
       
  1181 	 * @param {object} response              Response from the server.
  1169 	 * @param {object} response              Response from the server.
  1182 	 * @param {string} response.slug         Slug of the theme to be installed.
  1170 	 * @param {string} response.slug         Slug of the theme to be installed.
  1183 	 * @param {string} response.errorCode    Error code for the error that occurred.
  1171 	 * @param {string} response.errorCode    Error code for the error that occurred.
  1184 	 * @param {string} response.errorMessage The error that occurred.
  1172 	 * @param {string} response.errorMessage The error that occurred.
  1185 	 */
  1173 	 */
  1273 	/**
  1261 	/**
  1274 	 * Updates the UI appropriately after a successful theme deletion.
  1262 	 * Updates the UI appropriately after a successful theme deletion.
  1275 	 *
  1263 	 *
  1276 	 * @since 4.6.0
  1264 	 * @since 4.6.0
  1277 	 *
  1265 	 *
  1278 	 * @typedef {object} deleteThemeSuccess
       
  1279 	 * @param {object} response      Response from the server.
  1266 	 * @param {object} response      Response from the server.
  1280 	 * @param {string} response.slug Slug of the theme that was deleted.
  1267 	 * @param {string} response.slug Slug of the theme that was deleted.
  1281 	 */
  1268 	 */
  1282 	wp.updates.deleteThemeSuccess = function( response ) {
  1269 	wp.updates.deleteThemeSuccess = function( response ) {
  1283 		var $themeRows = $( '[data-slug="' + response.slug + '"]' );
  1270 		var $themeRows = $( '[data-slug="' + response.slug + '"]' );
  1332 	/**
  1319 	/**
  1333 	 * Updates the UI appropriately after a failed theme deletion.
  1320 	 * Updates the UI appropriately after a failed theme deletion.
  1334 	 *
  1321 	 *
  1335 	 * @since 4.6.0
  1322 	 * @since 4.6.0
  1336 	 *
  1323 	 *
  1337 	 * @typedef {object} deleteThemeError
       
  1338 	 * @param {object} response              Response from the server.
  1324 	 * @param {object} response              Response from the server.
  1339 	 * @param {string} response.slug         Slug of the theme to be deleted.
  1325 	 * @param {string} response.slug         Slug of the theme to be deleted.
  1340 	 * @param {string} response.errorCode    Error code for the error that occurred.
  1326 	 * @param {string} response.errorCode    Error code for the error that occurred.
  1341 	 * @param {string} response.errorMessage The error that occurred.
  1327 	 * @param {string} response.errorMessage The error that occurred.
  1342 	 */
  1328 	 */
  1606 	/**
  1592 	/**
  1607 	 * Handles credentials errors if it could not connect to the filesystem.
  1593 	 * Handles credentials errors if it could not connect to the filesystem.
  1608 	 *
  1594 	 *
  1609 	 * @since 4.6.0
  1595 	 * @since 4.6.0
  1610 	 *
  1596 	 *
  1611 	 * @typedef {object} maybeHandleCredentialError
       
  1612 	 * @param {object} response              Response from the server.
  1597 	 * @param {object} response              Response from the server.
  1613 	 * @param {string} response.errorCode    Error code for the error that occurred.
  1598 	 * @param {string} response.errorCode    Error code for the error that occurred.
  1614 	 * @param {string} response.errorMessage The error that occurred.
  1599 	 * @param {string} response.errorMessage The error that occurred.
  1615 	 * @param {string} action                The type of request to perform.
  1600 	 * @param {string} action                The type of request to perform.
  1616 	 * @returns {boolean} Whether there is an error that needs to be handled or not.
  1601 	 * @returns {boolean} Whether there is an error that needs to be handled or not.
  1945 				$document.on( 'credential-modal-cancel', function() {
  1930 				$document.on( 'credential-modal-cancel', function() {
  1946 
  1931 
  1947 					$button
  1932 					$button
  1948 						.removeClass( 'updating-message' )
  1933 						.removeClass( 'updating-message' )
  1949 						.text( wp.updates.l10n.installNow )
  1934 						.text( wp.updates.l10n.installNow )
  1950 						.attr( 'aria-label', wp.updates.l10n.installNowLabel.replace( '%s', pluginName ) );
  1935 						.attr( 'aria-label', wp.updates.l10n.pluginInstallNowLabel.replace( '%s', pluginName ) );
  1951 
  1936 
  1952 					wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
  1937 					wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' );
  1953 				} );
  1938 				} );
  1954 			}
  1939 			}
  1955 
  1940 
  2337 			event.preventDefault();
  2322 			event.preventDefault();
  2338 
  2323 
  2339 			$( 'input.wp-filter-search' ).trigger( 'input' );
  2324 			$( 'input.wp-filter-search' ).trigger( 'input' );
  2340 		} );
  2325 		} );
  2341 
  2326 
  2342 		/** 
  2327 		/**
  2343 		 * Trigger a search event when the "Try Again" button is clicked. 
  2328 		 * Trigger a search event when the "Try Again" button is clicked.
  2344 		 * 
  2329 		 *
  2345 		 * @since 4.9.0
  2330 		 * @since 4.9.0
  2346 		 */ 
  2331 		 */
  2347 		$document.on( 'click', '.try-again', function( event ) { 
  2332 		$document.on( 'click', '.try-again', function( event ) {
  2348 			event.preventDefault(); 
  2333 			event.preventDefault();
  2349 			$pluginInstallSearch.trigger( 'input' ); 
  2334 			$pluginInstallSearch.trigger( 'input' );
  2350 		} );
  2335 		} );
  2351 
  2336 
  2352 		/**
  2337 		/**
  2353 		 * Trigger a search event when the search type gets changed.
  2338 		 * Trigger a search event when the search type gets changed.
  2354 		 *
  2339 		 *