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
This commit is contained in:
Jake Spurlock 2020-07-21 16:52:47 +00:00
parent e10083b7de
commit 11fe34deb8

View File

@ -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;
}