Make WordPress Core

Ticket #51742: 51742.2.diff

File 51742.2.diff, 2.9 KB (added by audrasjb, 4 years ago)

Upgrade/Install: Disable major auto-updates checkbox and display a message when WP_AUTO_UPDATE_CORE constant and/or allow_major_auto_core_updates filter are defined

  • src/wp-admin/update-core.php

    diff --git a/src/wp-admin/update-core.php b/src/wp-admin/update-core.php
    index c08e57f6e9..5366785bfb 100644
    a b function core_auto_updates_settings() { 
    322322        $upgrade_minor = get_site_option( 'auto_update_core_minor', true );
    323323        $upgrade_major = get_site_option( 'auto_update_core_major', false );
    324324
     325        $major_optin_disabled = '';
    325326        // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'minor', false.
    326327        if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) {
    327328                if ( false === WP_AUTO_UPDATE_CORE ) {
    function core_auto_updates_settings() { 
    343344                        $upgrade_minor = true;
    344345                        $upgrade_major = false;
    345346                }
     347                $major_optin_disabled = ' disabled';
    346348        }
    347349
    348350        /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
    function core_auto_updates_settings() { 
    352354        /** This filter is documented in wp-admin/includes/class-core-upgrader.php */
    353355        $upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major );
    354356
     357        $is_major_optin_disabled = apply_filters( 'allow_major_auto_core_updates', null );
     358        if ( isset( $is_major_optin_disabled ) ) {
     359                $major_optin_disabled = 'disabled';
     360        }
     361
    355362        $auto_update_settings = array(
    356363                'dev'   => $upgrade_dev,
    357364                'minor' => $upgrade_minor,
    function core_auto_updates_settings() { 
    361368        <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" name="core-auto-updates" class="form-core-auto-updates">
    362369                <?php wp_nonce_field( 'core-auto-updates-nonce', 'set_core_auto_updates_settings' ); ?>
    363370                <h2><?php _e( 'Auto-update settings' ); ?></h2>
    364                 <p>
    365                         <?php
    366                         if ( $auto_update_settings['major'] ) {
    367                                 $wp_version = get_bloginfo( 'version' );
    368                                 $updates    = get_core_updates();
    369                                 if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
    370                                         echo wp_get_auto_update_message();
    371                                 }
     371                <?php
     372                if ( $auto_update_settings['major'] ) {
     373                        $wp_version = get_bloginfo( 'version' );
     374                        $updates    = get_core_updates();
     375                        if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
     376                                echo '<p>' . wp_get_auto_update_message() . '</p>';
    372377                        }
    373                         ?>
    374                 </p>
     378                }
     379                ?>
    375380                <p>
    376                         <input type="checkbox" name="core-auto-updates-major" id="core-auto-updates-major" value="1" <?php checked( $auto_update_settings['major'], 1 ); ?> />
     381                        <input type="checkbox" name="core-auto-updates-major" id="core-auto-updates-major" value="1" <?php checked( $auto_update_settings['major'], 1 ); ?> <?php echo $major_optin_disabled; ?> />
    377382                        <label for="core-auto-updates-major">
    378383                                <?php _e( 'Automatically keep this site up-to-date with regular feature updates.' ); ?>
     384                                <?php if ( ! empty( $major_optin_disabled ) ) : ?>
     385                                        <em><?php _e( 'This setting was overridden programmatically.' ); ?></em>
     386                                <?php endif; ?>
    379387                        </label>
    380388                </p>
    381389                <?php