' + errorMessage + '
' + message + '
' ).html( $message.find( 'p' ).data( 'originaltext' ) ); } $message .removeClass( 'updating-message' ) .html( originalText ); if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) { if ( 'update-plugin' === job.action ) { $message.attr( 'aria-label', sprintf( /* translators: %s: Plugin name and version. */ _x( 'Update %s now', 'plugin' ), $message.data( 'name' ) ) ); } else if ( 'install-plugin' === job.action ) { $message.attr( 'aria-label', sprintf( /* translators: %s: Plugin name. */ _x( 'Install %s now', 'plugin' ), $message.data( 'name' ) ) ); } } } wp.a11y.speak( __( 'Update canceled.' ) ); } ); /** * Click handler for plugin updates in List Table view. * * @since 4.2.0 * * @param {Event} event Event interface. */ $bulkActionForm.on( 'click', '[data-plugin] .update-link', function( event ) { var $message = $( event.target ), $pluginRow = $message.parents( 'tr' ); event.preventDefault(); if ( $message.hasClass( 'updating-message' ) || $message.hasClass( 'button-disabled' ) ) { return; } wp.updates.maybeRequestFilesystemCredentials( event ); // Return the user to the input box of the plugin's table row after closing the modal. wp.updates.$elToReturnFocusToFromCredentialsModal = $pluginRow.find( '.check-column input' ); wp.updates.updatePlugin( { plugin: $pluginRow.data( 'plugin' ), slug: $pluginRow.data( 'slug' ) } ); } ); /** * Click handler for plugin updates in plugin install view. * * @since 4.2.0 * * @param {Event} event Event interface. */ $pluginFilter.on( 'click', '.update-now', function( event ) { var $button = $( event.target ); event.preventDefault(); if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) { return; } wp.updates.maybeRequestFilesystemCredentials( event ); wp.updates.updatePlugin( { plugin: $button.data( 'plugin' ), slug: $button.data( 'slug' ) } ); } ); /** * Click handler for plugin installs in plugin install view. * * @since 4.6.0 * * @param {Event} event Event interface. */ $pluginFilter.on( 'click', '.install-now', function( event ) { var $button = $( event.target ); event.preventDefault(); if ( $button.hasClass( 'updating-message' ) || $button.hasClass( 'button-disabled' ) ) { return; } if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) { wp.updates.requestFilesystemCredentials( event ); $document.on( 'credential-modal-cancel', function() { var $message = $( '.install-now.updating-message' ); $message .removeClass( 'updating-message' ) .text( _x( 'Install Now', 'plugin' ) ); wp.a11y.speak( __( 'Update canceled.' ) ); } ); } wp.updates.installPlugin( { slug: $button.data( 'slug' ) } ); } ); /** * Click handler for plugin activations in plugin activation modal view. * * @since 6.5.0 * @since 6.5.4 Redirect the parent window to the activation URL. * * @param {Event} event Event interface. */ $document.on( 'click', '#plugin-information-footer .activate-now', function( event ) { event.preventDefault(); window.parent.location.href = $( event.target ).attr( 'href' ); }); /** * Click handler for importer plugins installs in the Import screen. * * @since 4.6.0 * * @param {Event} event Event interface. */ $document.on( 'click', '.importer-item .install-now', function( event ) { var $button = $( event.target ), pluginName = $( this ).data( 'name' ); event.preventDefault(); if ( $button.hasClass( 'updating-message' ) ) { return; } if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) { wp.updates.requestFilesystemCredentials( event ); $document.on( 'credential-modal-cancel', function() { $button .removeClass( 'updating-message' ) .attr( 'aria-label', sprintf( /* translators: %s: Plugin name. */ _x( 'Install %s now', 'plugin' ), pluginName ) ) .text( _x( 'Install Now', 'plugin' ) ); wp.a11y.speak( __( 'Update canceled.' ) ); } ); } wp.updates.installPlugin( { slug: $button.data( 'slug' ), pagenow: pagenow, success: wp.updates.installImporterSuccess, error: wp.updates.installImporterError } ); } ); /** * Click handler for plugin deletions. * * @since 4.6.0 * * @param {Event} event Event interface. */ $bulkActionForm.on( 'click', '[data-plugin] a.delete', function( event ) { var $pluginRow = $( event.target ).parents( 'tr' ), confirmMessage; if ( $pluginRow.hasClass( 'is-uninstallable' ) ) { confirmMessage = sprintf( /* translators: %s: Plugin name. */ __( 'Are you sure you want to delete %s and its data?' ), $pluginRow.find( '.plugin-title strong' ).text() ); } else { confirmMessage = sprintf( /* translators: %s: Plugin name. */ __( 'Are you sure you want to delete %s?' ), $pluginRow.find( '.plugin-title strong' ).text() ); } event.preventDefault(); if ( ! window.confirm( confirmMessage ) ) { return; } wp.updates.maybeRequestFilesystemCredentials( event ); wp.updates.deletePlugin( { plugin: $pluginRow.data( 'plugin' ), slug: $pluginRow.data( 'slug' ) } ); } ); /** * Click handler for theme updates. * * @since 4.6.0 * * @param {Event} event Event interface. */ $document.on( 'click', '.themes-php.network-admin .update-link', function( event ) { var $message = $( event.target ), $themeRow = $message.parents( 'tr' ); event.preventDefault(); if ( $message.hasClass( 'updating-message' ) || $message.hasClass( 'button-disabled' ) ) { return; } wp.updates.maybeRequestFilesystemCredentials( event ); // Return the user to the input box of the theme's table row after closing the modal. wp.updates.$elToReturnFocusToFromCredentialsModal = $themeRow.find( '.check-column input' ); wp.updates.updateTheme( { slug: $themeRow.data( 'slug' ) } ); } ); /** * Click handler for theme deletions. * * @since 4.6.0 * * @param {Event} event Event interface. */ $document.on( 'click', '.themes-php.network-admin a.delete', function( event ) { var $themeRow = $( event.target ).parents( 'tr' ), confirmMessage = sprintf( /* translators: %s: Theme name. */ __( 'Are you sure you want to delete %s?' ), $themeRow.find( '.theme-title strong' ).text() ); event.preventDefault(); if ( ! window.confirm( confirmMessage ) ) { return; } wp.updates.maybeRequestFilesystemCredentials( event ); wp.updates.deleteTheme( { slug: $themeRow.data( 'slug' ) } ); } ); /** * Bulk action handler for plugins and themes. * * Handles both deletions and updates. * * @since 4.6.0 * * @param {Event} event Event interface. */ $bulkActionForm.on( 'click', '[type="submit"]:not([name="clear-recent-list"])', function( event ) { var bulkAction = $( event.target ).siblings( 'select' ).val(), itemsSelected = $bulkActionForm.find( 'input[name="checked[]"]:checked' ), success = 0, error = 0, errorMessages = [], type, action; // Determine which type of item we're dealing with. switch ( pagenow ) { case 'plugins': case 'plugins-network': type = 'plugin'; break; case 'themes-network': type = 'theme'; break; default: return; } // Bail if there were no items selected. if ( ! itemsSelected.length ) { bulkAction = false; } // Determine the type of request we're dealing with. switch ( bulkAction ) { case 'update-selected': action = bulkAction.replace( 'selected', type ); break; case 'delete-selected': var confirmMessage = 'plugin' === type ? __( 'Are you sure you want to delete the selected plugins and their data?' ) : __( 'Caution: These themes may be active on other sites in the network. Are you sure you want to proceed?' ); if ( ! window.confirm( confirmMessage ) ) { event.preventDefault(); return; } action = bulkAction.replace( 'selected', type ); break; default: return; } wp.updates.maybeRequestFilesystemCredentials( event ); event.preventDefault(); // Un-check the bulk checkboxes. $bulkActionForm.find( '.manage-column [type="checkbox"]' ).prop( 'checked', false ); $document.trigger( 'wp-' + type + '-bulk-' + bulkAction, itemsSelected ); // Find all the checkboxes which have been checked. itemsSelected.each( function( index, element ) { var $checkbox = $( element ), $itemRow = $checkbox.parents( 'tr' ); // Only add update-able items to the update queue. if ( 'update-selected' === bulkAction && ( ! $itemRow.hasClass( 'update' ) || $itemRow.find( 'notice-error' ).length ) ) { // Un-check the box. $checkbox.prop( 'checked', false ); return; } // Don't add items to the update queue again, even if the user clicks the update button several times. if ( 'update-selected' === bulkAction && $itemRow.hasClass( 'is-enqueued' ) ) { return; } $itemRow.addClass( 'is-enqueued' ); // Add it to the queue. wp.updates.queue.push( { action: action, data: { plugin: $itemRow.data( 'plugin' ), slug: $itemRow.data( 'slug' ) } } ); } ); // Display bulk notification for updates of any kind. $document.on( 'wp-plugin-update-success wp-plugin-update-error wp-theme-update-success wp-theme-update-error', function( event, response ) { var $itemRow = $( '[data-slug="' + response.slug + '"]' ), $bulkActionNotice, itemName; if ( 'wp-' + response.update + '-update-success' === event.type ) { success++; } else { itemName = response.pluginName ? response.pluginName : $itemRow.find( '.column-primary strong' ).text(); error++; errorMessages.push( itemName + ': ' + response.errorMessage ); } $itemRow.find( 'input[name="checked[]"]:checked' ).prop( 'checked', false ); wp.updates.adminNotice = wp.template( 'wp-bulk-updates-admin-notice' ); var successMessage = null; if ( success ) { if ( 'plugin' === response.update ) { successMessage = sprintf( /* translators: %s: Number of plugins. */ _n( '%s plugin successfully updated.', '%s plugins successfully updated.', success ), success ); } else { successMessage = sprintf( /* translators: %s: Number of themes. */ _n( '%s theme successfully updated.', '%s themes successfully updated.', success ), success ); } } var errorMessage = null; if ( error ) { errorMessage = sprintf( /* translators: %s: Number of failed updates. */ _n( '%s update failed.', '%s updates failed.', error ), error ); } wp.updates.addAdminNotice( { id: 'bulk-action-notice', className: 'bulk-action-notice', successMessage: successMessage, errorMessage: errorMessage, errorMessages: errorMessages, type: response.update } ); $bulkActionNotice = $( '#bulk-action-notice' ).on( 'click', 'button', function() { // $( this ) is the clicked button, no need to get it again. $( this ) .toggleClass( 'bulk-action-errors-collapsed' ) .attr( 'aria-expanded', ! $( this ).hasClass( 'bulk-action-errors-collapsed' ) ); // Show the errors list. $bulkActionNotice.find( '.bulk-action-errors' ).toggleClass( 'hidden' ); } ); if ( error > 0 && ! wp.updates.queue.length ) { $( 'html, body' ).animate( { scrollTop: 0 } ); } } ); // Reset admin notice template after #bulk-action-notice was added. $document.on( 'wp-updates-notice-added', function() { wp.updates.adminNotice = wp.template( 'wp-updates-admin-notice' ); } ); // Check the queue, now that the event handlers have been added. wp.updates.queueChecker(); } ); if ( $pluginInstallSearch.length ) { $pluginInstallSearch.attr( 'aria-describedby', 'live-search-desc' ); } // Track the previous search string length. var previousSearchStringLength = 0; wp.updates.shouldSearch = function( searchStringLength ) { var shouldSearch = searchStringLength >= wp.updates.searchMinCharacters || previousSearchStringLength > wp.updates.searchMinCharacters; previousSearchStringLength = searchStringLength; return shouldSearch; }; /** * Handles changes to the plugin search box on the new-plugin page, * searching the repository dynamically. * * @since 4.6.0 */ $pluginInstallSearch.on( 'keyup input', _.debounce( function( event, eventtype ) { var $searchTab = $( '.plugin-install-search' ), data, searchLocation, searchStringLength = $pluginInstallSearch.val().length; data = { _ajax_nonce: wp.updates.ajaxNonce, s: encodeURIComponent( event.target.value ), tab: 'search', type: $( '#typeselector' ).val(), pagenow: pagenow }; searchLocation = location.href.split( '?' )[ 0 ] + '?' + $.param( _.omit( data, [ '_ajax_nonce', 'pagenow' ] ) ); // Set the autocomplete attribute, turning off autocomplete 1 character before ajax search kicks in. if ( wp.updates.shouldSearch( searchStringLength ) ) { $pluginInstallSearch.attr( 'autocomplete', 'off' ); } else { $pluginInstallSearch.attr( 'autocomplete', 'on' ); return; } // Clear on escape. if ( 'keyup' === event.type && 27 === event.which ) { event.target.value = ''; } if ( wp.updates.searchTerm === data.s && 'typechange' !== eventtype ) { return; } else { $pluginFilter.empty(); wp.updates.searchTerm = data.s; } if ( window.history && window.history.replaceState ) { window.history.replaceState( null, '', searchLocation ); } if ( ! $searchTab.length ) { $searchTab = $( '
' ) .append( $( '', { 'class': 'current', 'href': searchLocation, 'text': __( 'Search Results' ) } ) ); $( '.wp-filter .filter-links .current' ) .removeClass( 'current' ) .parents( '.filter-links' ) .prepend( $searchTab ); $pluginFilter.prev( 'p' ).remove(); $( '.plugins-popular-tags-wrapper' ).remove(); } if ( 'undefined' !== typeof wp.updates.searchRequest ) { wp.updates.searchRequest.abort(); } $( 'body' ).addClass( 'loading-content' ); wp.updates.searchRequest = wp.ajax.post( 'search-install-plugins', data ).done( function( response ) { $( 'body' ).removeClass( 'loading-content' ); $pluginFilter.append( response.items ); delete wp.updates.searchRequest; if ( 0 === response.count ) { wp.a11y.speak( __( 'You do not appear to have any plugins available at this time.' ) ); } else { wp.a11y.speak( sprintf( /* translators: %s: Number of plugins. */ __( 'Number of plugins found: %d' ), response.count ) ); } } ); }, 1000 ) ); if ( $pluginSearch.length ) { $pluginSearch.attr( 'aria-describedby', 'live-search-desc' ); } /** * Handles changes to the plugin search box on the Installed Plugins screen, * searching the plugin list dynamically. * * @since 4.6.0 */ $pluginSearch.on( 'keyup input', _.debounce( function( event ) { var data = { _ajax_nonce: wp.updates.ajaxNonce, s: encodeURIComponent( event.target.value ), pagenow: pagenow, plugin_status: 'all' }, queryArgs, searchStringLength = $pluginSearch.val().length; // Set the autocomplete attribute, turning off autocomplete 1 character before ajax search kicks in. if ( wp.updates.shouldSearch( searchStringLength ) ) { $pluginSearch.attr( 'autocomplete', 'off' ); } else { $pluginSearch.attr( 'autocomplete', 'on' ); return; } // Clear on escape. if ( 'keyup' === event.type && 27 === event.which ) { event.target.value = ''; } if ( wp.updates.searchTerm === data.s ) { return; } else { wp.updates.searchTerm = data.s; } queryArgs = _.object( _.compact( _.map( location.search.slice( 1 ).split( '&' ), function( item ) { if ( item ) return item.split( '=' ); } ) ) ); data.plugin_status = queryArgs.plugin_status || 'all'; if ( window.history && window.history.replaceState ) { window.history.replaceState( null, '', location.href.split( '?' )[ 0 ] + '?s=' + data.s + '&plugin_status=' + data.plugin_status ); } if ( 'undefined' !== typeof wp.updates.searchRequest ) { wp.updates.searchRequest.abort(); } $bulkActionForm.empty(); $( 'body' ).addClass( 'loading-content' ); $( '.subsubsub .current' ).removeClass( 'current' ); wp.updates.searchRequest = wp.ajax.post( 'search-plugins', data ).done( function( response ) { // Can we just ditch this whole subtitle business? var $subTitle = $( '' ).addClass( 'subtitle' ).html( sprintf( /* translators: %s: Search query. */ __( 'Search results for: %s' ), '' + _.escape( decodeURIComponent( data.s ) ) + '' ) ), $oldSubTitle = $( '.wrap .subtitle' ); if ( ! data.s.length ) { $oldSubTitle.remove(); $( '.subsubsub .' + data.plugin_status + ' a' ).addClass( 'current' ); } else if ( $oldSubTitle.length ) { $oldSubTitle.replaceWith( $subTitle ); } else { $( '.wp-header-end' ).before( $subTitle ); } $( 'body' ).removeClass( 'loading-content' ); $bulkActionForm.append( response.items ); delete wp.updates.searchRequest; if ( 0 === response.count ) { wp.a11y.speak( __( 'No plugins found. Try a different search.' ) ); } else { wp.a11y.speak( sprintf( /* translators: %s: Number of plugins. */ __( 'Number of plugins found: %d' ), response.count ) ); } } ); }, 500 ) ); /** * Trigger a search event when the search form gets submitted. * * @since 4.6.0 */ $document.on( 'submit', '.search-plugins', function( event ) { event.preventDefault(); $( 'input.wp-filter-search' ).trigger( 'input' ); } ); /** * 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' ); } ); /** * Trigger a search event when the search type gets changed. * * @since 4.6.0 */ $( '#typeselector' ).on( 'change', function() { var $search = $( 'input[name="s"]' ); if ( $search.val().length ) { $search.trigger( 'input', 'typechange' ); } } ); /** * Click handler for updating a plugin from the details modal on `plugin-install.php`. * * @since 4.2.0 * * @param {Event} event Event interface. */ $( '#plugin_update_from_iframe' ).on( 'click', function( event ) { var target = window.parent === window ? null : window.parent, update; $.support.postMessage = !! window.postMessage; if ( false === $.support.postMessage || null === target || -1 !== window.parent.location.pathname.indexOf( 'update-core.php' ) ) { return; } event.preventDefault(); update = { action: 'update-plugin', data: { plugin: $( this ).data( 'plugin' ), slug: $( this ).data( 'slug' ) } }; target.postMessage( JSON.stringify( update ), window.location.origin ); } ); /** * Handles postMessage events. * * @since 4.2.0 * @since 4.6.0 Switched `update-plugin` action to use the queue. * * @param {Event} event Event interface. */ $( window ).on( 'message', function( event ) { var originalEvent = event.originalEvent, expectedOrigin = document.location.protocol + '//' + document.location.host, message; if ( originalEvent.origin !== expectedOrigin ) { return; } try { message = JSON.parse( originalEvent.data ); } catch ( e ) { return; } if ( ! message ) { return; } if ( 'undefined' !== typeof message.status && 'undefined' !== typeof message.slug && 'undefined' !== typeof message.text && 'undefined' !== typeof message.ariaLabel ) { var $card = $( '.plugin-card-' + message.slug ), $message = $card.find( '[data-slug="' + message.slug + '"]' ); if ( 'undefined' !== typeof message.removeClasses ) { $message.removeClass( message.removeClasses ); } if ( 'undefined' !== typeof message.addClasses ) { $message.addClass( message.addClasses ); } if ( '' === message.ariaLabel ) { $message.removeAttr( 'aria-label' ); } else { $message.attr( 'aria-label', message.ariaLabel ); } if ( 'dependencies-check-success' === message.status ) { $message .attr( 'data-name', message.pluginName ) .attr( 'data-slug', message.slug ) .attr( 'data-plugin', message.plugin ) .attr( 'href', message.href ); } $message.text( message.text ); } if ( 'undefined' === typeof message.action ) { return; } switch ( message.action ) { // Called from `wp-admin/includes/class-wp-upgrader-skins.php`. case 'decrementUpdateCount': /** @property {string} message.upgradeType */ wp.updates.decrementCount( message.upgradeType ); break; case 'install-plugin': case 'update-plugin': if ( 'undefined' === typeof message.data || 'undefined' === typeof message.data.slug ) { return; } message.data = wp.updates._addCallbacks( message.data, message.action ); wp.updates.queue.push( message ); wp.updates.queueChecker(); break; } } ); /** * Adds a callback to display a warning before leaving the page. * * @since 4.2.0 */ $( window ).on( 'beforeunload', wp.updates.beforeunload ); /** * Prevents the page form scrolling when activating auto-updates with the Spacebar key. * * @since 5.5.0 */ $document.on( 'keydown', '.column-auto-updates .toggle-auto-update, .theme-overlay .toggle-auto-update', function( event ) { if ( 32 === event.which ) { event.preventDefault(); } } ); /** * Click and keyup handler for enabling and disabling plugin and theme auto-updates. * * These controls can be either links or buttons. When JavaScript is enabled, * we want them to behave like buttons. An ARIA role `button` is added via * the JavaScript that targets elements with the CSS class `aria-button-if-js`. * * @since 5.5.0 */ $document.on( 'click keyup', '.column-auto-updates .toggle-auto-update, .theme-overlay .toggle-auto-update', function( event ) { var data, asset, type, $parent, $toggler = $( this ), action = $toggler.attr( 'data-wp-action' ), $label = $toggler.find( '.label' ); if ( 'keyup' === event.type && 32 !== event.which ) { return; } if ( 'themes' !== pagenow ) { $parent = $toggler.closest( '.column-auto-updates' ); } else { $parent = $toggler.closest( '.theme-autoupdate' ); } event.preventDefault(); // Prevent multiple simultaneous requests. if ( $toggler.attr( 'data-doing-ajax' ) === 'yes' ) { return; } $toggler.attr( 'data-doing-ajax', 'yes' ); switch ( pagenow ) { case 'plugins': case 'plugins-network': type = 'plugin'; asset = $toggler.closest( 'tr' ).attr( 'data-plugin' ); break; case 'themes-network': type = 'theme'; asset = $toggler.closest( 'tr' ).attr( 'data-slug' ); break; case 'themes': type = 'theme'; asset = $toggler.attr( 'data-slug' ); break; } // Clear any previous errors. $parent.find( '.notice.notice-error' ).addClass( 'hidden' ); // Show loading status. if ( 'enable' === action ) { $label.text( __( 'Enabling...' ) ); } else { $label.text( __( 'Disabling...' ) ); } $toggler.find( '.dashicons-update' ).removeClass( 'hidden' ); data = { action: 'toggle-auto-updates', _ajax_nonce: settings.ajax_nonce, state: action, type: type, asset: asset }; $.post( window.ajaxurl, data ) .done( function( response ) { var $enabled, $disabled, enabledNumber, disabledNumber, errorMessage, href = $toggler.attr( 'href' ); if ( ! response.success ) { // if WP returns 0 for response (which can happen in a few cases), // output the general error message since we won't have response.data.error. if ( response.data && response.data.error ) { errorMessage = response.data.error; } else { errorMessage = __( 'The request could not be completed.' ); } $parent.find( '.notice.notice-error' ).removeClass( 'hidden' ).find( 'p' ).text( errorMessage ); wp.a11y.speak( errorMessage, 'assertive' ); return; } // Update the counts in the enabled/disabled views if on a screen // with a list table. if ( 'themes' !== pagenow ) { $enabled = $( '.auto-update-enabled span' ); $disabled = $( '.auto-update-disabled span' ); enabledNumber = parseInt( $enabled.text().replace( /[^\d]+/g, '' ), 10 ) || 0; disabledNumber = parseInt( $disabled.text().replace( /[^\d]+/g, '' ), 10 ) || 0; switch ( action ) { case 'enable': ++enabledNumber; --disabledNumber; break; case 'disable': --enabledNumber; ++disabledNumber; break; } enabledNumber = Math.max( 0, enabledNumber ); disabledNumber = Math.max( 0, disabledNumber ); $enabled.text( '(' + enabledNumber + ')' ); $disabled.text( '(' + disabledNumber + ')' ); } if ( 'enable' === action ) { // The toggler control can be either a link or a button. if ( $toggler[ 0 ].hasAttribute( 'href' ) ) { href = href.replace( 'action=enable-auto-update', 'action=disable-auto-update' ); $toggler.attr( 'href', href ); } $toggler.attr( 'data-wp-action', 'disable' ); $label.text( __( 'Disable auto-updates' ) ); $parent.find( '.auto-update-time' ).removeClass( 'hidden' ); wp.a11y.speak( __( 'Auto-updates enabled' ) ); } else { // The toggler control can be either a link or a button. if ( $toggler[ 0 ].hasAttribute( 'href' ) ) { href = href.replace( 'action=disable-auto-update', 'action=enable-auto-update' ); $toggler.attr( 'href', href ); } $toggler.attr( 'data-wp-action', 'enable' ); $label.text( __( 'Enable auto-updates' ) ); $parent.find( '.auto-update-time' ).addClass( 'hidden' ); wp.a11y.speak( __( 'Auto-updates disabled' ) ); } $document.trigger( 'wp-auto-update-setting-changed', { state: action, type: type, asset: asset } ); } ) .fail( function() { $parent.find( '.notice.notice-error' ) .removeClass( 'hidden' ) .find( 'p' ) .text( __( 'The request could not be completed.' ) ); wp.a11y.speak( __( 'The request could not be completed.' ), 'assertive' ); } ) .always( function() { $toggler.removeAttr( 'data-doing-ajax' ).find( '.dashicons-update' ).addClass( 'hidden' ); } ); } ); } ); })( jQuery, window.wp, window._wpUpdatesSettings );