diff --git a/src/js/_enqueues/wp/updates.js b/src/js/_enqueues/wp/updates.js index c422fcf64c05f..8b52bfcdd6b32 100644 --- a/src/js/_enqueues/wp/updates.js +++ b/src/js/_enqueues/wp/updates.js @@ -2470,18 +2470,13 @@ * @since 4.2.0 */ $( window ).on( 'beforeunload', wp.updates.beforeunload ); - } ); - /** - * Click handler for enabling and disabling plugin and theme auto-updates. - * - * @since 5.5.0 - * - * TODO: this needs to be refactored to be like the remainder of the handlers - * in this file. - */ - $( document ).ready( function() { - $( $document ).on( 'click', '.column-auto-updates a.toggle-auto-update, .theme-overlay a.toggle-auto-update', function( event ) { + /** + * Click handler for enabling and disabling plugin and theme auto-updates. + * + * @since 5.5.0 + */ + $document.on( 'click', '.column-auto-updates a.toggle-auto-update, .theme-overlay a.toggle-auto-update', function( event ) { var data, asset, type, $parent; var $anchor = $( this ), action = $anchor.attr( 'data-wp-action' ), @@ -2522,14 +2517,12 @@ $parent.find( '.notice.error' ).addClass( 'hidden' ); // Show loading status. - // TODO: make it readable when network is fast, or possibly remove the interim text change. if ( 'enable' === action ) { $label.text( wp.updates.l10n.autoUpdatesEnabling ); } else { $label.text( wp.updates.l10n.autoUpdatesDisabling ); } - // TODO: Needs design review - the link text jumps under the mouse (part may get selected). $anchor.find( '.dashicons-update' ).removeClass( 'hidden' ); data = { @@ -2546,9 +2539,8 @@ var href = $anchor.attr( 'href' ); if ( ! response.success ) { - // if WP returns 0 for response (which can happen in a few cases - // that aren't quite failures), output the general error message, - // since we won't have response.data.error. + // 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 { diff --git a/src/wp-admin/includes/class-wp-automatic-updater.php b/src/wp-admin/includes/class-wp-automatic-updater.php index 71adac3f2c494..20f1847de7797 100644 --- a/src/wp-admin/includes/class-wp-automatic-updater.php +++ b/src/wp-admin/includes/class-wp-automatic-updater.php @@ -159,10 +159,12 @@ public function should_update( $type, $item, $context ) { if ( 'core' === $type ) { $update = Core_Upgrader::should_update_to_version( $item->current ); } elseif ( 'plugin' === $type || 'theme' === $type ) { - $update = false; - if ( wp_is_auto_update_enabled_for_type( $type ) ) { + $update = ! empty( $item->autoupdate ); + + if ( ! $update && wp_is_auto_update_enabled_for_type( $type ) ) { + // Check if the site admin has enabled auto-updates by default for the specific item. $auto_updates = (array) get_site_option( "auto_update_{$type}s", array() ); - $update = in_array( $item->{$type}, $auto_updates, true ) || ! empty( $item->autoupdate ); + $update = in_array( $item->{$type}, $auto_updates, true ); } } else { $update = ! empty( $item->autoupdate ); @@ -976,8 +978,7 @@ protected function send_plugin_theme_email( $type, $successful_updates, $failed_ $body[] = __( 'The following plugins failed to update:' ); // List failed updates. foreach ( $failed_updates['plugin'] as $item ) { - /* translators: %s: Name of the related plugin. */ - $body[] = ' ' . sprintf( __( '- %s' ), $item->name ); + $body[] = "- {$item->name}"; } $body[] = "\n"; } @@ -986,8 +987,7 @@ protected function send_plugin_theme_email( $type, $successful_updates, $failed_ $body[] = __( 'The following themes failed to update:' ); // List failed updates. foreach ( $failed_updates['theme'] as $item ) { - /* translators: %s: Name of the related plugin. */ - $body[] = ' ' . sprintf( __( '- %s' ), $item->name ); + $body[] = "- {$item->name}"; } $body[] = "\n"; } @@ -996,8 +996,7 @@ protected function send_plugin_theme_email( $type, $successful_updates, $failed_ $body[] = __( 'The following plugins were successfully updated:' ); // List successful updates. foreach ( $successful_updates['plugin'] as $item ) { - /* translators: %s: Name of the related plugin. */ - $body[] = ' ' . sprintf( __( '- %s' ), $item->name ); + $body[] = "- {$item->name}"; } $body[] = "\n"; } @@ -1006,8 +1005,7 @@ protected function send_plugin_theme_email( $type, $successful_updates, $failed_ $body[] = __( 'The following themes were successfully updated:' ); // List successful updates. foreach ( $successful_updates['theme'] as $item ) { - /* translators: %s: Name of the related plugin. */ - $body[] = ' ' . sprintf( __( '- %s' ), $item->name ); + $body[] = "- {$item->name}"; } $body[] = "\n"; } diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index b9854839fb32d..41ce09ef84c5d 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -856,10 +856,14 @@ static function debug_data() { } // List all available plugins. - $plugins = get_plugins(); - $plugin_updates = get_plugin_updates(); - $auto_updates = array(); - $auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'plugin' ); + $plugins = get_plugins(); + $plugin_updates = get_plugin_updates(); + $auto_updates = array(); + + $auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'plugin' ); + $auto_updates_enabled_str = __( 'Auto-updates enabled' ); + $auto_updates_disabled_str = __( 'Auto-updates disabled' ); + if ( $auto_updates_enabled ) { $auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); } @@ -899,11 +903,11 @@ static function debug_data() { if ( $auto_updates_enabled ) { if ( in_array( $plugin_path, $auto_updates, true ) ) { - $plugin_version_string .= ' | ' . __( 'Auto-updates enabled' ); - $plugin_version_string_debug .= ', ' . __( 'Auto-updates enabled' ); + $plugin_version_string .= ' | ' . $auto_updates_enabled_str; + $plugin_version_string_debug .= ', ' . $auto_updates_enabled_str; } else { - $plugin_version_string .= ' | ' . __( 'Auto-updates disabled' ); - $plugin_version_string_debug .= ', ' . __( 'Auto-updates disabled' ); + $plugin_version_string .= ' | ' . $auto_updates_disabled_str; + $plugin_version_string_debug .= ', ' . $auto_updates_disabled_str; } } @@ -1123,11 +1127,11 @@ static function debug_data() { if ( $auto_updates_enabled ) { if ( in_array( $theme_slug, $auto_updates ) ) { - $theme_version_string .= ' | ' . __( 'Auto-updates enabled' ); - $theme_version_string_debug .= ',' . __( 'Auto-updates enabled' ); + $theme_version_string .= ' | ' . $auto_updates_enabled_str; + $theme_version_string_debug .= ',' . $auto_updates_enabled_str; } else { - $theme_version_string .= ' | ' . __( 'Auto-updates disabled' ); - $theme_version_string_debug .= ', ' . __( 'Auto-updates disabled' ); + $theme_version_string .= ' | ' . $auto_updates_disabled_str; + $theme_version_string_debug .= ', ' . $auto_updates_disabled_str; } } diff --git a/src/wp-admin/includes/class-wp-ms-themes-list-table.php b/src/wp-admin/includes/class-wp-ms-themes-list-table.php index 1809c10d5fb8b..dabcb5689de29 100644 --- a/src/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -718,27 +718,39 @@ function column_autoupdates( $theme ) { $stylesheet = $theme->get_stylesheet(); if ( in_array( $stylesheet, $auto_updates, true ) ) { - $text = __( 'Disable auto-updates', 'wp-autoupdates' ); - $auto_update_time_class = ''; - $action = 'disable'; + $text = __( 'Disable auto-updates' ); + $action = 'disable'; + $time_class = ''; } else { - $text = __( 'Enable auto-updates', 'wp-autoupdates' ); - $action = 'enable'; - $auto_update_time_class = ' hidden'; + $text = __( 'Enable auto-updates' ); + $action = 'enable'; + $time_class = ' hidden'; } + $query_args = array( + 'action' => "{$action}-auto-update", + 'theme' => $stylesheet, + 'paged' => $page, + 'theme_status' => $status, + ); + + $url = add_query_arg( $query_args, 'themes.php' ); + printf( - '%s', - wp_nonce_url( 'themes.php?action=' . $action . '-auto-update&theme=' . urlencode( $stylesheet ) . '&paged=' . $page . '&theme_status=' . $status, 'updates' ), - $action, - $text + '', + wp_nonce_url( $url, 'updates' ), + $action ); + echo ''; + echo '' . $text . ''; + echo ''; + $available_updates = get_site_transient( 'update_themes' ); if ( isset( $available_updates->response[ $stylesheet ] ) ) { printf( '
' . sprintf( $message, number_format_i18n( $enabled ) ) . '
'; } elseif ( isset( $_GET['disabled'] ) ) { $disabled = absint( $_GET['disabled'] ); - if ( 1 == $disabled ) { + if ( 1 === $disabled ) { $message = __( 'Theme disabled.' ); } else { /* translators: %s: Number of themes. */ @@ -390,7 +363,7 @@ echo '' . sprintf( $message, number_format_i18n( $disabled ) ) . '
' . sprintf( $message, number_format_i18n( $deleted ) ) . '
' . sprintf( $message, number_format_i18n( $enabled ) ) . '
' . sprintf( $message, number_format_i18n( $disabled ) ) . '
' . __( 'No theme selected.' ) . '
' . __( 'You cannot delete a theme while it is active on the main site.' ) . '
' . __( 'No theme selected.' ) . '
' . __( 'Theme will no longer be auto-updated.' ) . '
' . __( 'Themes will be auto-updated.' ) . '
' . __( 'Themes will no longer be auto-updated.' ) . '
' . __( 'The following themes are installed but incomplete.' ) . '
'; } ?> diff --git a/src/wp-admin/plugins.php b/src/wp-admin/plugins.php index dc484a25e1272..62726ba12f632 100644 --- a/src/wp-admin/plugins.php +++ b/src/wp-admin/plugins.php @@ -22,7 +22,21 @@ $s = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : ''; // Clean up request URI from temporary args for screen options/paging uri's to work as expected. -$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', 'enable-auto-update', 'disable-auto-update', 'enable-auto-update-multi', 'disable-auto-update-multi', '_error_nonce' ), $_SERVER['REQUEST_URI'] ); +$query_args_to_remove = array( + 'error', + 'deleted', + 'activate', + 'activate-multi', + 'deactivate', + 'deactivate-multi', + 'enabled-auto-update', + 'disabled-auto-update', + 'enabled-auto-update-multi', + 'disabled-auto-update-multi', + '_error_nonce', +); + +$_SERVER['REQUEST_URI'] = remove_query_arg( $query_args_to_remove, $_SERVER['REQUEST_URI'] ); wp_enqueue_script( 'updates' ); @@ -284,11 +298,14 @@ if ( ! isset( $_REQUEST['verify-delete'] ) ) { wp_enqueue_script( 'jquery' ); require_once ABSPATH . 'wp-admin/admin-header.php'; + ?> -
-