From 11fe34deb8abe32cb016c58ac1f11215852bf596 Mon Sep 17 00:00:00 2001 From: Jake Spurlock Date: Tue, 21 Jul 2020 16:52:47 +0000 Subject: [PATCH] Site Health: Add auto-update information to for plugins and themes. New filters: * `plugin_auto_update_debug_str` * `theme_auto_update_debug_str` Fixes #50663. Props pbiron, audrasjb, davidbaumwald. git-svn-id: https://develop.svn.wordpress.org/trunk@48546 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-debug-data.php | 63 +++++++++++++++++-- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index f3793a0118..ab72f94241 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -907,15 +907,16 @@ class WP_Debug_Data { $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' ); + $auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'plugin' ); if ( $auto_updates_enabled ) { $auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); } foreach ( $plugins as $plugin_path => $plugin ) { + $auto_updates_enabled_str = __( 'Auto-updates enabled' ); + $auto_updates_disabled_str = __( 'Auto-updates disabled' ); + $plugin_part = ( is_plugin_active( $plugin_path ) ) ? 'wp-plugins-active' : 'wp-plugins-inactive'; $plugin_version = $plugin['Version']; @@ -950,9 +951,28 @@ class WP_Debug_Data { if ( $auto_updates_enabled ) { if ( in_array( $plugin_path, $auto_updates, true ) ) { + $enabled = true; + + /** + * Filters the text string of the auto-updates setting for each plugin in the Site Health debug data. + * + * @since 5.5.0 + * + * @param string $auto_updates_enabled_str The string output for the auto-updates column. + * @param array $plugin An array of plugin data. + * @param bool $enabled True if auto-updates are enabled for this item, + * false otherwise. + */ + $auto_updates_enabled_str = apply_filters( 'plugin_auto_update_debug_str', $auto_updates_enabled_str, $plugin, $enabled ); + $plugin_version_string .= ' | ' . $auto_updates_enabled_str; $plugin_version_string_debug .= ', ' . $auto_updates_enabled_str; } else { + $enabled = false; + + /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ + $auto_updates_disabled_str = apply_filters( 'plugin_auto_update_debug_str', $auto_updates_disabled_str, $plugin, $enabled ); + $plugin_version_string .= ' | ' . $auto_updates_disabled_str; $plugin_version_string_debug .= ', ' . $auto_updates_disabled_str; } @@ -1054,10 +1074,30 @@ class WP_Debug_Data { ); if ( $auto_updates_enabled ) { if ( in_array( $active_theme->stylesheet, $auto_updates, true ) ) { - $theme_auto_update_string = __( 'Enabled' ); + $auto_updates_enabled_str = __( 'Enabled' ); + $enabled = true; + + /** + * Filters the text string of the auto-updates setting for each theme in the Site Health debug data. + * + * @since 5.5.0 + * + * @param string $auto_updates_enabled_str The string output for the auto-updates column. + * @param object $theme An object of theme data. + * @param bool $enabled True if auto-updates are enabled for this item, + * false otherwise. + */ + $auto_updates_enabled_str = apply_filters( 'theme_auto_update_debug_str', $auto_updates_enabled_str, $active_theme, $enabled ); + } else { - $theme_auto_update_string = __( 'Disabled' ); + $auto_updates_disabled_str = __( 'Disabled' ); + $enabled = false; + + /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ + $auto_updates_disabled_str = apply_filters( 'theme_auto_update_debug_str', $auto_updates_disabled_str, $active_theme, $enabled ); + } + $theme_auto_update_string = $enabled ? $auto_updates_enabled_str : $auto_updates_disabled_str; $info['wp-active-theme']['fields']['auto_update'] = array( 'label' => __( 'Auto-update' ), @@ -1139,6 +1179,9 @@ class WP_Debug_Data { continue; } + $auto_updates_enabled_str = __( 'Auto-updates enabled' ); + $auto_updates_disabled_str = __( 'Auto-updates disabled' ); + $theme_version = $theme->version; $theme_author = $theme->author; @@ -1174,9 +1217,19 @@ class WP_Debug_Data { if ( $auto_updates_enabled ) { if ( in_array( $theme_slug, $auto_updates, true ) ) { + $enabled = true; + + /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ + $auto_updates_enabled_str = apply_filters( 'theme_auto_update_debug_str', $auto_updates_enabled_str, $theme, $enabled ); + $theme_version_string .= ' | ' . $auto_updates_enabled_str; $theme_version_string_debug .= ',' . $auto_updates_enabled_str; } else { + $enabled = false; + + /** This filter is documented in wp-admin/includes/class-wp-debug-data.php */ + $auto_updates_disabled_str = apply_filters( 'theme_auto_update_debug_str', $auto_updates_disabled_str, $theme, $enabled ); + $theme_version_string .= ' | ' . $auto_updates_disabled_str; $theme_version_string_debug .= ', ' . $auto_updates_disabled_str; }