diff --git a/src/wp-admin/includes/class-core-upgrader.php b/src/wp-admin/includes/class-core-upgrader.php
index 6ffb98a7ec..b57a13fd7b 100644
|
a
|
b
|
class Core_Upgrader extends WP_Upgrader { |
| 279 | 279 | $current_is_development_version = (bool) strpos( $wp_version, '-' ); |
| 280 | 280 | |
| 281 | 281 | // Defaults: |
| 282 | | $upgrade_dev = get_site_option( 'auto_update_core_dev', true ); |
| 283 | | $upgrade_minor = get_site_option( 'auto_update_core_minor', true ); |
| 284 | | $upgrade_major = get_site_option( 'auto_update_core_major', false ); |
| | 282 | $upgrade_dev = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled'; |
| | 283 | $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled'; |
| | 284 | $upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled'; |
| 285 | 285 | |
| 286 | 286 | // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'minor', false. |
| 287 | 287 | if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { |
diff --git a/src/wp-admin/update-core.php b/src/wp-admin/update-core.php
index c08e57f6e9..a9618cccb1 100644
|
a
|
b
|
function core_upgrade_preamble() { |
| 306 | 306 | * @since 5.6.0 |
| 307 | 307 | */ |
| 308 | 308 | function core_auto_updates_settings() { |
| 309 | | $upgrade_major_value = ''; |
| 310 | | if ( isset( $_POST['core-auto-updates-settings'] ) && wp_verify_nonce( $_POST['set_core_auto_updates_settings'], 'core-auto-updates-nonce' ) ) { |
| 311 | | if ( isset( $_POST['core-auto-updates-major'] ) && 1 === (int) $_POST['core-auto-updates-major'] ) { |
| 312 | | update_site_option( 'auto_update_core_major', 1 ); |
| 313 | | } else { |
| 314 | | update_site_option( 'auto_update_core_major', 0 ); |
| | 309 | if ( isset( $_GET['core-major-auto-updates-saved'] ) ) { |
| | 310 | if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) { |
| | 311 | $notice_text = __( 'WordPress will auto-update to new major versions.' ); |
| | 312 | echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>'; |
| | 313 | } elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) { |
| | 314 | $notice_text = __( 'WordPress will no longer auto-update to new major versions.' ); |
| | 315 | echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>'; |
| 315 | 316 | } |
| 316 | | echo '<div class="notice notice-success is-dismissible"><p>'; |
| 317 | | _e( 'WordPress auto-update settings updated.' ); |
| 318 | | echo '</p></div>'; |
| 319 | 317 | } |
| 320 | 318 | |
| 321 | | $upgrade_dev = get_site_option( 'auto_update_core_dev', true ); |
| 322 | | $upgrade_minor = get_site_option( 'auto_update_core_minor', true ); |
| 323 | | $upgrade_major = get_site_option( 'auto_update_core_major', false ); |
| | 319 | // Defaults: |
| | 320 | $upgrade_dev = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled'; |
| | 321 | $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled'; |
| | 322 | $upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled'; |
| 324 | 323 | |
| | 324 | $upgrade_major_optin_enabled = true; |
| 325 | 325 | // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'minor', false. |
| 326 | 326 | if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { |
| 327 | 327 | if ( false === WP_AUTO_UPDATE_CORE ) { |
| … |
… |
function core_auto_updates_settings() { |
| 343 | 343 | $upgrade_minor = true; |
| 344 | 344 | $upgrade_major = false; |
| 345 | 345 | } |
| | 346 | |
| | 347 | // The UI is overridden by the WP_AUTO_UPDATE_CORE constant. |
| | 348 | $upgrade_major_optin_enabled = false; |
| | 349 | } |
| | 350 | |
| | 351 | if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) ) { |
| | 352 | if ( true === AUTOMATIC_UPDATER_DISABLED ) { |
| | 353 | $upgrade_dev = false; |
| | 354 | $upgrade_minor = false; |
| | 355 | $upgrade_major = false; |
| | 356 | } |
| | 357 | // The UI is overridden by the AUTOMATIC_UPDATER_DISABLED constant. |
| | 358 | $upgrade_major_optin_enabled = false; |
| | 359 | } |
| | 360 | |
| | 361 | // Is the UI overridden by a plugin using the allow_major_auto_core_updates filter? |
| | 362 | if ( has_filter( 'allow_major_auto_core_updates' ) ) { |
| | 363 | $upgrade_major_optin_enabled = false; |
| 346 | 364 | } |
| 347 | 365 | |
| 348 | 366 | /** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
| … |
… |
function core_auto_updates_settings() { |
| 357 | 375 | 'minor' => $upgrade_minor, |
| 358 | 376 | 'major' => $upgrade_major, |
| 359 | 377 | ); |
| | 378 | |
| | 379 | if ( $upgrade_major ) { |
| | 380 | $wp_version = get_bloginfo( 'version' ); |
| | 381 | $updates = get_core_updates(); |
| | 382 | |
| | 383 | if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { |
| | 384 | echo '<p>' . wp_get_auto_update_message() . '</p>'; |
| | 385 | } |
| | 386 | } |
| | 387 | |
| | 388 | $action_url = self_admin_url( 'update-core.php?action=core-major-auto-updates-settings' ); |
| 360 | 389 | ?> |
| 361 | | <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" name="core-auto-updates" class="form-core-auto-updates"> |
| 362 | | <?php wp_nonce_field( 'core-auto-updates-nonce', 'set_core_auto_updates_settings' ); ?> |
| 363 | | <h2><?php _e( 'Auto-update settings' ); ?></h2> |
| | 390 | |
| | 391 | <?php if ( $upgrade_major_optin_enabled ) : ?> |
| 364 | 392 | <p> |
| 365 | 393 | <?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 | | } |
| | 394 | if ( $upgrade_major ) { |
| | 395 | echo sprintf( |
| | 396 | /* Translators: Action link to disable core auto-updates. */ |
| | 397 | __( 'Automatic updates to new versions of WordPress are enabled. You can <a href="%s">turn this off</a>.' ), |
| | 398 | wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ) |
| | 399 | ); |
| | 400 | } else { |
| | 401 | echo sprintf( |
| | 402 | /* Translators: Action link to enable core auto-updates. */ |
| | 403 | __( 'If you want you can <a href="%s">automatically update your WordPress site</a>.' ), |
| | 404 | wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ) |
| | 405 | ); |
| 372 | 406 | } |
| 373 | 407 | ?> |
| 374 | 408 | </p> |
| | 409 | <?php elseif ( $upgrade_major ) : ?> |
| 375 | 410 | <p> |
| 376 | | <input type="checkbox" name="core-auto-updates-major" id="core-auto-updates-major" value="1" <?php checked( $auto_update_settings['major'], 1 ); ?> /> |
| 377 | | <label for="core-auto-updates-major"> |
| 378 | | <?php _e( 'Automatically keep this site up-to-date with regular feature updates.' ); ?> |
| 379 | | </label> |
| | 411 | <?php _e( 'Your WordPress site will be kept updated automatically.' ); ?> |
| 380 | 412 | </p> |
| 381 | | <?php |
| 382 | | /** |
| 383 | | * Fires after the major core auto-update checkbox. |
| 384 | | * |
| 385 | | * @since 5.6.0 |
| 386 | | */ |
| 387 | | do_action( 'after_core_auto_updates_settings_fields', $auto_update_settings ); |
| 388 | | ?> |
| | 413 | <?php else: ?> |
| 389 | 414 | <p> |
| 390 | | <input id="core-auto-updates-settings" class="button" type="submit" value="<?php esc_attr_e( 'Save' ); ?>" name="core-auto-updates-settings" /> |
| | 415 | <?php _e( 'Automatic WordPress updates have been disabled for this site.' ); ?> |
| 391 | 416 | </p> |
| 392 | | </form> |
| | 417 | <?php endif; ?> |
| | 418 | |
| 393 | 419 | <?php |
| | 420 | /** |
| | 421 | * Fires after the major core auto-update settings. |
| | 422 | * |
| | 423 | * @since 5.6.0 |
| | 424 | */ |
| | 425 | do_action( 'after_core_auto_updates_settings', $auto_update_settings ); |
| 394 | 426 | } |
| 395 | 427 | |
| 396 | 428 | /** |
| … |
… |
if ( 'upgrade-core' === $action ) { |
| 957 | 989 | ?> |
| 958 | 990 | <div class="wrap"> |
| 959 | 991 | <h1><?php _e( 'WordPress Updates' ); ?></h1> |
| | 992 | <p><?php _e( 'Here you can find information about updates, set auto-updates and see what plugins or themes need updating.' ); ?></p> |
| | 993 | |
| 960 | 994 | <?php |
| 961 | 995 | if ( $upgrade_error ) { |
| 962 | 996 | echo '<div class="error"><p>'; |
| … |
… |
if ( 'upgrade-core' === $action ) { |
| 982 | 1016 | echo '</p>'; |
| 983 | 1017 | |
| 984 | 1018 | if ( current_user_can( 'update_core' ) ) { |
| 985 | | core_upgrade_preamble(); |
| 986 | 1019 | core_auto_updates_settings(); |
| | 1020 | core_upgrade_preamble(); |
| 987 | 1021 | } |
| 988 | 1022 | if ( current_user_can( 'update_plugins' ) ) { |
| 989 | 1023 | list_plugin_updates(); |
| … |
… |
if ( 'upgrade-core' === $action ) { |
| 1158 | 1192 | |
| 1159 | 1193 | require_once ABSPATH . 'wp-admin/admin-footer.php'; |
| 1160 | 1194 | |
| | 1195 | } elseif ( 'core-major-auto-updates-settings' === $action ) { |
| | 1196 | $redirect_url = self_admin_url( 'update-core.php' ); |
| | 1197 | |
| | 1198 | if ( isset( $_GET['value'] ) ) { |
| | 1199 | check_admin_referer( 'core-major-auto-updates-nonce' ); |
| | 1200 | |
| | 1201 | if ( 'enable' === $_GET['value'] ) { |
| | 1202 | update_site_option( 'auto_update_core_major', 'enabled' ); |
| | 1203 | $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'enabled', $redirect_url ); |
| | 1204 | } elseif ( 'disable' === $_GET['value'] ) { |
| | 1205 | update_site_option( 'auto_update_core_major', 'disabled' ); |
| | 1206 | $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'disabled', $redirect_url ); |
| | 1207 | } |
| | 1208 | } |
| | 1209 | |
| | 1210 | wp_redirect( $redirect_url ); |
| | 1211 | exit; |
| 1161 | 1212 | } else { |
| 1162 | 1213 | /** |
| 1163 | 1214 | * Fires for each custom update action on the WordPress Updates screen. |