Make WordPress Core

Changeset 48698

Timestamp:
07/30/2020 10:02:54 PM (4 years ago)
Author:
whyisjake
Message:

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.

This brings the changes from [48688] to the 5.5 branch.

See #50280.
Props dd32.

Location:
branches/5.5
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/src/js/_enqueues/wp/theme.js

    r48650 r48698  
    803803        // Support concurrent clicks in different Theme Details overlays.
    804804        callback = function( event, data ) {
     805
    805806            if ( _this.model.get( 'id' ) === data.asset ) {
    806                 _this.model.set( { autoupdate: 'enable' === data.state } );
     807                autoupdate = _this.model.get( 'autoupdate' );
     808                autoupdate.enabled = 'enable' === data.state;
     809                _this.model.set( { autoupdate: autoupdate } );
    807810                $( document ).off( 'wp-auto-update-setting-changed', callback );
    808811            }
  • branches/5.5/src/wp-admin/includes/theme.php

    r48659 r48698  
    648648    }
    649649
    650     $updates = array();
     650    $updates    = array();
     651    $no_updates = array();
    651652    if ( current_user_can( 'update_themes' ) ) {
    652653        $updates_transient = get_site_transient( 'update_themes' );
    653654        if ( isset( $updates_transient->response ) ) {
    654655            $updates = $updates_transient->response;
     656
     657
     658
    655659        }
    656660    }
     
    690694        $auto_update        = in_array( $slug, $auto_updates, true );
    691695        $auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update';
     696
     697
     698
     699
     700
     701
     702
     703
     704
     705
     706
     707
     708
     709
     710
     711
     712
     713
     714
     715
     716
     717
     718
     719
     720
    692721
    693722        $prepared_themes[ $slug ] = array(
     
    711740            'hasPackage'     => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
    712741            'update'         => get_theme_update_available( $theme ),
    713             'autoupdate'     => $auto_update,
     742            'autoupdate'     => array(
     743                'enabled'   => $auto_update || $auto_update_forced,
     744                'supported' => $auto_update_supported,
     745                'forced'    => $auto_update_forced,
     746            ),
    714747            'actions'        => array(
    715748                'activate'   => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
  • branches/5.5/src/wp-admin/themes.php

    r48659 r48698  
    676676    $template = '
    677677        <div class="theme-autoupdate">
    678             <# if ( data.autoupdate ) { #>
    679                 <button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="disable">
    680                     <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Disable auto-updates' ) . '</span>
    681                 </button>
    682             <# } else { #>
    683                 <button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="enable">
    684                     <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Enable auto-updates' ) . '</span>
    685                 </button>
     678            <# if ( data.autoupdate.supported ) { #>
     679                <# if ( data.autoupdate.forced === false ) { #>
     680                    ' . __( 'Auto-updates disabled' ) . '
     681                <# } else if ( data.autoupdate.forced ) { #>
     682                    ' . __( 'Auto-updates enabled' ) . '
     683                <# } else if ( data.autoupdate.enabled ) { #>
     684                    <button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="disable">
     685                        <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Disable auto-updates' ) . '</span>
     686                    </button>
     687                <# } else { #>
     688                    <button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="enable">
     689                        <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Enable auto-updates' ) . '</span>
     690                    </button>
     691                <# } #>
    686692            <# } #>
    687693            <# if ( data.hasUpdate ) { #>
    688                 <# if ( data.autoupdate ) { #>
     694                <# if ( data.autoupdate ) { #>
    689695                    <span class="auto-update-time">
    690696                <# } else { #>
  • branches/5.5/src/wp-includes/update.php

    r48344 r48698  
    622622    if ( is_array( $response ) ) {
    623623        $new_update->response     = $response['themes'];
     624
    624625        $new_update->translations = $response['translations'];
    625626    }
Note: See TracChangeset for help on using the changeset viewer.