mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-02 17:40:01 +00:00
Security: Add user interface to auto-update themes and plugins.
Building on core update mechanisms, this adds the ability to enable automatic updates for themes and plugins to the WordPress admin. Fixes: #50052. Props: afercia, afragen, audrasjb, azaozz, bookdude13, davidperonne, desrosj, gmays, gmays, javiercasares, karmatosed, knutsp, mapk, mukesh27, netweb, nicolaskulka, nielsdeblaauw, paaljoachim, passoniate, pbiron, pedromendonca, whodunitagency, whyisjake, wpamitkumar, and xkon. git-svn-id: https://develop.svn.wordpress.org/trunk@47835 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -858,6 +858,15 @@ class WP_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' );
|
||||
$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 ) {
|
||||
$plugin_part = ( is_plugin_active( $plugin_path ) ) ? 'wp-plugins-active' : 'wp-plugins-inactive';
|
||||
@@ -892,6 +901,16 @@ class WP_Debug_Data {
|
||||
$plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version );
|
||||
}
|
||||
|
||||
if ( $auto_updates_enabled ) {
|
||||
if ( in_array( $plugin_path, $auto_updates, true ) ) {
|
||||
$plugin_version_string .= ' | ' . $auto_updates_enabled_str;
|
||||
$plugin_version_string_debug .= ', ' . $auto_updates_enabled_str;
|
||||
} else {
|
||||
$plugin_version_string .= ' | ' . $auto_updates_disabled_str;
|
||||
$plugin_version_string_debug .= ', ' . $auto_updates_disabled_str;
|
||||
}
|
||||
}
|
||||
|
||||
$info[ $plugin_part ]['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
|
||||
'label' => $plugin['Name'],
|
||||
'value' => $plugin_version_string,
|
||||
@@ -915,6 +934,12 @@ class WP_Debug_Data {
|
||||
$active_theme_version = $active_theme->version;
|
||||
$active_theme_version_debug = $active_theme_version;
|
||||
|
||||
$auto_updates = array();
|
||||
$auto_updates_enabled = wp_is_auto_update_enabled_for_type( 'theme' );
|
||||
if ( $auto_updates_enabled ) {
|
||||
$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
|
||||
}
|
||||
|
||||
if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) {
|
||||
$theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version'];
|
||||
|
||||
@@ -980,7 +1005,19 @@ class WP_Debug_Data {
|
||||
'value' => get_stylesheet_directory(),
|
||||
),
|
||||
);
|
||||
if ( $auto_updates_enabled ) {
|
||||
if ( in_array( $active_theme->stylesheet, $auto_updates ) ) {
|
||||
$theme_auto_update_string = __( 'Enabled' );
|
||||
} else {
|
||||
$theme_auto_update_string = __( 'Disabled' );
|
||||
}
|
||||
|
||||
$info['wp-active-theme']['fields']['auto_update'] = array(
|
||||
'label' => __( 'Auto-update' ),
|
||||
'value' => $theme_auto_update_string,
|
||||
'debug' => $theme_auto_update_string,
|
||||
);
|
||||
}
|
||||
$parent_theme = $active_theme->parent();
|
||||
|
||||
if ( $parent_theme ) {
|
||||
@@ -1026,6 +1063,19 @@ class WP_Debug_Data {
|
||||
'value' => get_template_directory(),
|
||||
),
|
||||
);
|
||||
if ( $auto_updates_enabled ) {
|
||||
if ( in_array( $parent_theme->stylesheet, $auto_updates ) ) {
|
||||
$parent_theme_auto_update_string = __( 'Enabled' );
|
||||
} else {
|
||||
$parent_theme_auto_update_string = __( 'Disabled' );
|
||||
}
|
||||
|
||||
$info['wp-parent-theme']['fields']['auto_update'] = array(
|
||||
'label' => __( 'Auto-update' ),
|
||||
'value' => $parent_theme_auto_update_string,
|
||||
'debug' => $parent_theme_auto_update_string,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Populate a list of all themes available in the install.
|
||||
@@ -1075,6 +1125,16 @@ class WP_Debug_Data {
|
||||
$theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] );
|
||||
}
|
||||
|
||||
if ( $auto_updates_enabled ) {
|
||||
if ( in_array( $theme_slug, $auto_updates ) ) {
|
||||
$theme_version_string .= ' | ' . $auto_updates_enabled_str;
|
||||
$theme_version_string_debug .= ',' . $auto_updates_enabled_str;
|
||||
} else {
|
||||
$theme_version_string .= ' | ' . $auto_updates_disabled_str;
|
||||
$theme_version_string_debug .= ', ' . $auto_updates_disabled_str;
|
||||
}
|
||||
}
|
||||
|
||||
$info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->name ) ] = array(
|
||||
'label' => sprintf(
|
||||
/* translators: 1: Theme name. 2: Theme slug. */
|
||||
|
||||
Reference in New Issue
Block a user