Make WordPress Core


Ignore:
Timestamp:
05/20/2020 06:47:24 PM (6 years ago)
Author:
whyisjake
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/theme.php

    r47819 r47835  
    661661        $parents = array();
    662662
     663        $auto_updates = (array) get_site_option( 'auto_update_themes', array() );
     664
    663665        foreach ( $themes as $theme ) {
    664666                $slug         = $theme->get_stylesheet();
    … …  
    683685                        );
    684686                }
     687
     688                $auto_update        = in_array( $slug, $auto_updates, true );
     689                $auto_update_action = $auto_update ? 'disable-auto-update' : 'enable-auto-update';
    685690
    686691                $prepared_themes[ $slug ] = array(
    … …  
    700705                        'hasPackage'    => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
    701706                        'update'        => get_theme_update_available( $theme ),
     707                        'autoupdate'    => $auto_update,
    702708                        'actions'       => array(
    703                                 'activate'  => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
    704                                 'customize' => $customize_action,
    705                                 'delete'    => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
     709                                'activate'   => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
     710                                'customize'  => $customize_action,
     711                                'delete'     => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
     712                                'autoupdate' => wp_is_auto_update_enabled_for_type( 'theme' ) && ! is_multisite() && current_user_can( 'update_themes' )
     713                                        ? wp_nonce_url( admin_url( 'themes.php?action=' . $auto_update_action . '&stylesheet=' . $encoded_slug ), 'updates' )
     714                                        : null,
    706715                        ),
    707716                );
Note: See TracChangeset for help on using the changeset viewer.