diff -r c7c34916027a -r 177826044cd9 wp/wp-admin/js/updates.js --- a/wp/wp-admin/js/updates.js Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-admin/js/updates.js Mon Oct 14 18:28:13 2019 +0200 @@ -2,9 +2,7 @@ * Functions for ajaxified updates, deletions and installs inside the WordPress admin. * * @version 4.2.0 - * - * @package WordPress - * @subpackage Administration + * @output wp-admin/js/updates.js */ /* global pagenow */ @@ -38,7 +36,7 @@ * * @since 4.2.0 * - * @type {object} + * @namespace wp.updates */ wp.updates = {}; @@ -84,19 +82,19 @@ * @since 4.2.0 * @since 4.6.0 Added `available` property to indicate whether credentials have been provided. * - * @type {object} filesystemCredentials Holds filesystem credentials. - * @type {object} filesystemCredentials.ftp Holds FTP credentials. - * @type {string} filesystemCredentials.ftp.host FTP host. Default empty string. - * @type {string} filesystemCredentials.ftp.username FTP user name. Default empty string. - * @type {string} filesystemCredentials.ftp.password FTP password. Default empty string. - * @type {string} filesystemCredentials.ftp.connectionType Type of FTP connection. 'ssh', 'ftp', or 'ftps'. - * Default empty string. - * @type {object} filesystemCredentials.ssh Holds SSH credentials. - * @type {string} filesystemCredentials.ssh.publicKey The public key. Default empty string. - * @type {string} filesystemCredentials.ssh.privateKey The private key. Default empty string. - * @type {string} filesystemCredentials.fsNonce Filesystem credentials form nonce. - * @type {bool} filesystemCredentials.available Whether filesystem credentials have been provided. - * Default 'false'. + * @type {Object} + * @property {Object} filesystemCredentials.ftp Holds FTP credentials. + * @property {string} filesystemCredentials.ftp.host FTP host. Default empty string. + * @property {string} filesystemCredentials.ftp.username FTP user name. Default empty string. + * @property {string} filesystemCredentials.ftp.password FTP password. Default empty string. + * @property {string} filesystemCredentials.ftp.connectionType Type of FTP connection. 'ssh', 'ftp', or 'ftps'. + * Default empty string. + * @property {Object} filesystemCredentials.ssh Holds SSH credentials. + * @property {string} filesystemCredentials.ssh.publicKey The public key. Default empty string. + * @property {string} filesystemCredentials.ssh.privateKey The private key. Default empty string. + * @property {string} filesystemCredentials.fsNonce Filesystem credentials form nonce. + * @property {bool} filesystemCredentials.available Whether filesystem credentials have been provided. + * Default 'false'. */ wp.updates.filesystemCredentials = { ftp: { @@ -128,7 +126,7 @@ * * @since 4.6.0 * - * @type {function} A function that lazily-compiles the template requested. + * @type {function} */ wp.updates.adminNotice = wp.template( 'wp-updates-admin-notice' ); @@ -170,7 +168,9 @@ * */ wp.updates.addAdminNotice = function( data ) { - var $notice = $( data.selector ), $adminNotice; + var $notice = $( data.selector ), + $headerEnd = $( '.wp-header-end' ), + $adminNotice; delete data.selector; $adminNotice = wp.updates.adminNotice( data ); @@ -182,6 +182,8 @@ if ( $notice.length ) { $notice.replaceWith( $adminNotice ); + } else if ( $headerEnd.length ) { + $headerEnd.after( $adminNotice ); } else { if ( 'customize' === pagenow ) { $( '.customize-themes-notifications' ).append( $adminNotice ); @@ -260,7 +262,8 @@ if ( 'undefined' !== typeof response.debug && window.console && window.console.log ) { _.map( response.debug, function( message ) { - window.console.log( $( '

' ).html( message ).text() ); + // Remove all HTML tags and write a message to the console. + window.console.log( wp.sanitize.stripTagsAndEncodeText( message ) ); } ); } }; @@ -407,7 +410,6 @@ * @since 4.2.0 * @since 4.6.0 More accurately named `updatePluginSuccess`. * - * @typedef {object} updatePluginSuccess * @param {object} response Response from the server. * @param {string} response.slug Slug of the plugin to be updated. * @param {string} response.plugin Basename of the plugin to be updated. @@ -452,7 +454,6 @@ * @since 4.2.0 * @since 4.6.0 More accurately named `updatePluginError`. * - * @typedef {object} updatePluginError * @param {object} response Response from the server. * @param {string} response.slug Slug of the plugin to be updated. * @param {string} response.plugin Basename of the plugin to be updated. @@ -574,7 +575,6 @@ * * @since 4.6.0 * - * @typedef {object} installPluginSuccess * @param {object} response Response from the server. * @param {string} response.slug Slug of the installed plugin. * @param {string} response.pluginName Name of the installed plugin. @@ -585,16 +585,10 @@ $message .removeClass( 'updating-message' ) - .addClass( 'updated-message installed' ) + .addClass( 'updated-message installed button-disabled' ) .attr( 'aria-label', wp.updates.l10n.pluginInstalledLabel.replace( '%s', response.pluginName ) ) .text( wp.updates.l10n.pluginInstalled ); - if ( $message.hasClass( 'button-primary' ) ) { - $message.addClass( 'button-primary-disabled' ); - } else { - $message.addClass( 'button-disabled' ); - } - wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' ); $document.trigger( 'wp-plugin-install-success', response ); @@ -603,11 +597,10 @@ setTimeout( function() { // Transform the 'Install' button into an 'Activate' button. - $message.removeClass( 'install-now installed button-primary-disabled button-secondary-disabled button-disabled updated-message' ) - .addClass( 'activate-now' ) + $message.removeClass( 'install-now installed button-disabled updated-message' ).addClass( 'activate-now button-primary' ) .attr( 'href', response.activateUrl ) .attr( 'aria-label', wp.updates.l10n.activatePluginLabel.replace( '%s', response.pluginName ) ) - .text( response.activateLabel || wp.updates.l10n.activatePlugin ); + .text( wp.updates.l10n.activatePlugin ); }, 1000 ); } }; @@ -617,7 +610,6 @@ * * @since 4.6.0 * - * @typedef {object} installPluginError * @param {object} response Response from the server. * @param {string} response.slug Slug of the plugin to be installed. * @param {string=} response.pluginName Optional. Name of the plugin to be installed. @@ -668,7 +660,6 @@ * * @since 4.6.0 * - * @typedef {object} installImporterSuccess * @param {object} response Response from the server. * @param {string} response.slug Slug of the installed plugin. * @param {string} response.pluginName Name of the installed plugin. @@ -700,7 +691,6 @@ * * @since 4.6.0 * - * @typedef {object} installImporterError * @param {object} response Response from the server. * @param {string} response.slug Slug of the plugin to be installed. * @param {string=} response.pluginName Optional. Name of the plugin to be installed. @@ -729,7 +719,7 @@ $installLink .removeClass( 'updating-message' ) .text( wp.updates.l10n.installNow ) - .attr( 'aria-label', wp.updates.l10n.installNowLabel.replace( '%s', pluginName ) ); + .attr( 'aria-label', wp.updates.l10n.pluginInstallNowLabel.replace( '%s', pluginName ) ); wp.a11y.speak( errorMessage, 'assertive' ); @@ -775,8 +765,7 @@ * * @since 4.6.0 * - * @typedef {object} deletePluginSuccess - * @param {object} response Response from the server. + * @param {Object} response Response from the server. * @param {string} response.slug Slug of the plugin that was deleted. * @param {string} response.plugin Base name of the plugin that was deleted. * @param {string} response.pluginName Name of the plugin that was deleted. @@ -790,7 +779,11 @@ $pluginRow = $( this ), columnCount = $form.find( 'thead th:not(.hidden), thead td' ).length, pluginDeletedRow = wp.template( 'item-deleted-row' ), - /** @type {object} plugins Base names of plugins in their different states. */ + /** + * Plugins Base names of plugins in their different states. + * + * @type {Object} + */ plugins = settings.plugins; // Add a success message after deleting a plugin. @@ -865,7 +858,6 @@ * * @since 4.6.0 * - * @typedef {object} deletePluginError * @param {object} response Response from the server. * @param {string} response.slug Slug of the plugin to be deleted. * @param {string} response.plugin Base name of the plugin to be deleted @@ -978,7 +970,6 @@ * * @since 4.6.0 * - * @typedef {object} updateThemeSuccess * @param {object} response * @param {string} response.slug Slug of the theme to be updated. * @param {object} response.theme Updated theme. @@ -1040,7 +1031,6 @@ * * @since 4.6.0 * - * @typedef {object} updateThemeError * @param {object} response Response from the server. * @param {string} response.slug Slug of the theme to be updated. * @param {string} response.errorCode Error code for the error that occurred. @@ -1126,7 +1116,6 @@ * * @since 4.6.0 * - * @typedef {object} installThemeSuccess * @param {object} response Response from the server. * @param {string} response.slug Slug of the theme to be installed. * @param {string} response.customizeUrl URL to the Customizer for the just installed theme. @@ -1177,7 +1166,6 @@ * * @since 4.6.0 * - * @typedef {object} installThemeError * @param {object} response Response from the server. * @param {string} response.slug Slug of the theme to be installed. * @param {string} response.errorCode Error code for the error that occurred. @@ -1275,7 +1263,6 @@ * * @since 4.6.0 * - * @typedef {object} deleteThemeSuccess * @param {object} response Response from the server. * @param {string} response.slug Slug of the theme that was deleted. */ @@ -1334,7 +1321,6 @@ * * @since 4.6.0 * - * @typedef {object} deleteThemeError * @param {object} response Response from the server. * @param {string} response.slug Slug of the theme to be deleted. * @param {string} response.errorCode Error code for the error that occurred. @@ -1608,7 +1594,6 @@ * * @since 4.6.0 * - * @typedef {object} maybeHandleCredentialError * @param {object} response Response from the server. * @param {string} response.errorCode Error code for the error that occurred. * @param {string} response.errorMessage The error that occurred. @@ -1947,7 +1932,7 @@ $button .removeClass( 'updating-message' ) .text( wp.updates.l10n.installNow ) - .attr( 'aria-label', wp.updates.l10n.installNowLabel.replace( '%s', pluginName ) ); + .attr( 'aria-label', wp.updates.l10n.pluginInstallNowLabel.replace( '%s', pluginName ) ); wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' ); } ); @@ -2339,14 +2324,14 @@ $( 'input.wp-filter-search' ).trigger( 'input' ); } ); - /** - * Trigger a search event when the "Try Again" button is clicked. - * + /** + * Trigger a search event when the "Try Again" button is clicked. + * * @since 4.9.0 - */ - $document.on( 'click', '.try-again', function( event ) { - event.preventDefault(); - $pluginInstallSearch.trigger( 'input' ); + */ + $document.on( 'click', '.try-again', function( event ) { + event.preventDefault(); + $pluginInstallSearch.trigger( 'input' ); } ); /**