Upgrade/Install: Only show auto-update for themes that support the feature.
Similar to the changes for plugins in [48669], let's only show the UI for themes when updates are supported for that theme. See #50280. Props dd32. git-svn-id: https://develop.svn.wordpress.org/trunk@48688 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a4927249a8
commit
20ac5dd62d
@ -802,8 +802,11 @@ themes.view.Details = wp.Backbone.View.extend({
|
|||||||
|
|
||||||
// Support concurrent clicks in different Theme Details overlays.
|
// Support concurrent clicks in different Theme Details overlays.
|
||||||
callback = function( event, data ) {
|
callback = function( event, data ) {
|
||||||
|
var autoupdate;
|
||||||
if ( _this.model.get( 'id' ) === data.asset ) {
|
if ( _this.model.get( 'id' ) === data.asset ) {
|
||||||
_this.model.set( { autoupdate: 'enable' === data.state } );
|
autoupdate = _this.model.get( 'autoupdate' );
|
||||||
|
autoupdate.enabled = 'enable' === data.state;
|
||||||
|
_this.model.set( { autoupdate: autoupdate } );
|
||||||
$( document ).off( 'wp-auto-update-setting-changed', callback );
|
$( document ).off( 'wp-auto-update-setting-changed', callback );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -647,12 +647,16 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$updates = array();
|
$updates = array();
|
||||||
|
$no_updates = array();
|
||||||
if ( current_user_can( 'update_themes' ) ) {
|
if ( current_user_can( 'update_themes' ) ) {
|
||||||
$updates_transient = get_site_transient( 'update_themes' );
|
$updates_transient = get_site_transient( 'update_themes' );
|
||||||
if ( isset( $updates_transient->response ) ) {
|
if ( isset( $updates_transient->response ) ) {
|
||||||
$updates = $updates_transient->response;
|
$updates = $updates_transient->response;
|
||||||
}
|
}
|
||||||
|
if ( isset( $updates_transient->no_update ) ) {
|
||||||
|
$no_updates = $updates_transient->no_update;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WP_Theme::sort_by_name( $themes );
|
WP_Theme::sort_by_name( $themes );
|
||||||
@ -690,6 +694,31 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
|||||||
$auto_update = in_array( $slug, $auto_updates, true );
|
$auto_update = in_array( $slug, $auto_updates, true );
|
||||||
$auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update';
|
$auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update';
|
||||||
|
|
||||||
|
if ( isset( $updates[ $slug ] ) ) {
|
||||||
|
$auto_update_supported = true;
|
||||||
|
$auto_update_filter_payload = (object) $updates[ $slug ];
|
||||||
|
} elseif ( isset( $no_updates[ $slug ] ) ) {
|
||||||
|
$auto_update_supported = true;
|
||||||
|
$auto_update_filter_payload = (object) $no_updates[ $slug ];
|
||||||
|
} else {
|
||||||
|
$auto_update_supported = false;
|
||||||
|
/*
|
||||||
|
* Create the expected payload for the auto_update_theme filter, this is the same data
|
||||||
|
* as contained within $updates or $no_updates but used when the Theme is not known.
|
||||||
|
*/
|
||||||
|
$auto_update_filter_payload = (object) array(
|
||||||
|
'theme' => $slug,
|
||||||
|
'new_version' => $theme->get( 'Version' ),
|
||||||
|
'url' => '',
|
||||||
|
'package' => '',
|
||||||
|
'requires' => $theme->get( 'RequiresWP' ),
|
||||||
|
'requires_php' => $theme->get( 'RequiresPHP' ),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */
|
||||||
|
$auto_update_forced = apply_filters( 'auto_update_theme', null, $auto_update_filter_payload );
|
||||||
|
|
||||||
$prepared_themes[ $slug ] = array(
|
$prepared_themes[ $slug ] = array(
|
||||||
'id' => $slug,
|
'id' => $slug,
|
||||||
'name' => $theme->display( 'Name' ),
|
'name' => $theme->display( 'Name' ),
|
||||||
@ -710,7 +739,11 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
|||||||
'hasUpdate' => isset( $updates[ $slug ] ),
|
'hasUpdate' => isset( $updates[ $slug ] ),
|
||||||
'hasPackage' => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
|
'hasPackage' => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
|
||||||
'update' => get_theme_update_available( $theme ),
|
'update' => get_theme_update_available( $theme ),
|
||||||
'autoupdate' => $auto_update,
|
'autoupdate' => array(
|
||||||
|
'enabled' => $auto_update || $auto_update_forced,
|
||||||
|
'supported' => $auto_update_supported,
|
||||||
|
'forced' => $auto_update_forced,
|
||||||
|
),
|
||||||
'actions' => array(
|
'actions' => array(
|
||||||
'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
|
'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
|
||||||
'customize' => $customize_action,
|
'customize' => $customize_action,
|
||||||
|
@ -675,17 +675,23 @@ if ( ! is_multisite() && $broken_themes ) {
|
|||||||
function wp_theme_auto_update_setting_template() {
|
function wp_theme_auto_update_setting_template() {
|
||||||
$template = '
|
$template = '
|
||||||
<div class="theme-autoupdate">
|
<div class="theme-autoupdate">
|
||||||
<# if ( data.autoupdate ) { #>
|
<# if ( data.autoupdate.supported ) { #>
|
||||||
<button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="disable">
|
<# if ( data.autoupdate.forced === false ) { #>
|
||||||
<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Disable auto-updates' ) . '</span>
|
' . __( 'Auto-updates disabled' ) . '
|
||||||
</button>
|
<# } else if ( data.autoupdate.forced ) { #>
|
||||||
<# } else { #>
|
' . __( 'Auto-updates enabled' ) . '
|
||||||
<button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="enable">
|
<# } else if ( data.autoupdate.enabled ) { #>
|
||||||
<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Enable auto-updates' ) . '</span>
|
<button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="disable">
|
||||||
</button>
|
<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Disable auto-updates' ) . '</span>
|
||||||
|
</button>
|
||||||
|
<# } else { #>
|
||||||
|
<button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="enable">
|
||||||
|
<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Enable auto-updates' ) . '</span>
|
||||||
|
</button>
|
||||||
|
<# } #>
|
||||||
<# } #>
|
<# } #>
|
||||||
<# if ( data.hasUpdate ) { #>
|
<# if ( data.hasUpdate ) { #>
|
||||||
<# if ( data.autoupdate ) { #>
|
<# if ( data.autoupdate.supported && data.autoupdate.enabled ) { #>
|
||||||
<span class="auto-update-time">
|
<span class="auto-update-time">
|
||||||
<# } else { #>
|
<# } else { #>
|
||||||
<span class="auto-update-time hidden">
|
<span class="auto-update-time hidden">
|
||||||
|
@ -621,6 +621,7 @@ function wp_update_themes( $extra_stats = array() ) {
|
|||||||
|
|
||||||
if ( is_array( $response ) ) {
|
if ( is_array( $response ) ) {
|
||||||
$new_update->response = $response['themes'];
|
$new_update->response = $response['themes'];
|
||||||
|
$new_update->no_update = $response['no_update'];
|
||||||
$new_update->translations = $response['translations'];
|
$new_update->translations = $response['translations'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user