Commit 92edaa39 authored by Jake Spurlock's avatar Jake Spurlock
Browse files

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.

Built from https://develop.svn.wordpress.org/trunk@48546


git-svn-id: https://core.svn.wordpress.org/trunk@48308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
parent f63bdd33
Loading
Loading
Loading
Loading
+58 −5
Original line number Diff line number Diff line
@@ -908,14 +908,15 @@ class WP_Debug_Data {
		$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() );
		}

		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;
				}
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
 *
 * @global string $wp_version
 */
$wp_version = '5.5-beta2-48545';
$wp_version = '5.5-beta2-48546';

/**
 * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.