diff --git a/src/wp-admin/update-core.php b/src/wp-admin/update-core.php
index c08e57f6e9..ea41a8c6c3 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 next 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 next 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 | // TODO: set these to strings: `enabled` or `disabled`. |
| 320 | // Better than saving the bool `true/false` as string `1/0` in the DB. |
| 321 | $upgrade_dev = get_site_option( 'auto_update_core_dev', 'enabled' ); |
| 322 | $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ); |
| 323 | $upgrade_major = get_site_option( 'auto_update_core_major', 'disabled' ); |
324 | 324 | |
| 325 | $upgrade_major_optin_enabled = true; |
325 | 326 | // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'minor', false. |
326 | 327 | if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { |
327 | 328 | if ( false === WP_AUTO_UPDATE_CORE ) { |
328 | 329 | // Defaults to turned off, unless a filter allows it. |
329 | | $upgrade_dev = false; |
330 | | $upgrade_minor = false; |
331 | | $upgrade_major = false; |
| 330 | $upgrade_dev = 'disabled'; |
| 331 | $upgrade_minor = 'disabled'; |
| 332 | $upgrade_major = 'disabled'; |
332 | 333 | } elseif ( true === WP_AUTO_UPDATE_CORE |
333 | 334 | || 'beta' === WP_AUTO_UPDATE_CORE |
334 | 335 | || 'rc' === WP_AUTO_UPDATE_CORE |
335 | 336 | ) { |
336 | 337 | // ALL updates for core. |
337 | | $upgrade_dev = true; |
338 | | $upgrade_minor = true; |
339 | | $upgrade_major = true; |
| 338 | $upgrade_dev = 'enabled'; |
| 339 | $upgrade_minor = 'enabled'; |
| 340 | $upgrade_major = 'enabled'; |
340 | 341 | } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { |
341 | 342 | // Only minor updates for core. |
342 | | $upgrade_dev = false; |
343 | | $upgrade_minor = true; |
344 | | $upgrade_major = false; |
| 343 | $upgrade_dev = 'disabled'; |
| 344 | $upgrade_minor = 'enabled'; |
| 345 | $upgrade_major = 'disabled'; |
345 | 346 | } |
| 347 | $upgrade_major_optin_enabled = false; |
346 | 348 | } |
347 | 349 | |
348 | 350 | /** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
… |
… |
function core_auto_updates_settings() { |
352 | 354 | /** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
353 | 355 | $upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major ); |
354 | 356 | |
| 357 | $is_major_optin_disabled = apply_filters( 'allow_major_auto_core_updates', null ); |
| 358 | if ( isset( $is_major_optin_disabled ) ) { |
| 359 | $upgrade_major_optin_enabled = false; |
| 360 | } |
| 361 | |
355 | 362 | $auto_update_settings = array( |
356 | 363 | 'dev' => $upgrade_dev, |
357 | 364 | 'minor' => $upgrade_minor, |
358 | 365 | 'major' => $upgrade_major, |
359 | 366 | ); |
| 367 | |
| 368 | if ( $auto_update_settings['major'] ) { |
| 369 | $wp_version = get_bloginfo( 'version' ); |
| 370 | $updates = get_core_updates(); |
| 371 | if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { |
| 372 | echo '<p>' . wp_get_auto_update_message() . '</p>'; |
| 373 | } |
| 374 | } |
360 | 375 | ?> |
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> |
| 376 | |
| 377 | <?php if ( 1 === (int) $upgrade_major_optin_enabled ) : ?> |
364 | 378 | <p> |
365 | 379 | <?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 | | } |
| 380 | if ( 'enabled' === $upgrade_major ) { |
| 381 | echo sprintf( |
| 382 | /* Translators: Action link to disable core auto-updates. */ |
| 383 | __( 'Auto-updates for regular feature updates are on. You can <a href="%s">turn them off.</a>' ), |
| 384 | wp_nonce_url( 'update-core.php?core-major-auto-updates=disable', 'core-major-auto-updates-nonce' ) |
| 385 | ); |
| 386 | } else { |
| 387 | echo sprintf( |
| 388 | /* Translators: Action link to enable core auto-updates. */ |
| 389 | __( 'You are invited to <a href="%s">automatically keep this site up-to-date with regular feature updates.</a>' ), |
| 390 | wp_nonce_url( 'update-core.php?core-major-auto-updates=enable', 'core-major-auto-updates-nonce' ) |
| 391 | ); |
372 | 392 | } |
373 | 393 | ?> |
374 | 394 | </p> |
| 395 | <?php elseif ( 'enabled' === $upgrade_major ) : ?> |
375 | 396 | <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> |
| 397 | <?php _e( 'This website is set to keep itself up-to-date with regular feature updates.' ); ?> |
380 | 398 | </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 | | ?> |
| 399 | <?php else: ?> |
389 | 400 | <p> |
390 | | <input id="core-auto-updates-settings" class="button" type="submit" value="<?php esc_attr_e( 'Save' ); ?>" name="core-auto-updates-settings" /> |
| 401 | <?php _e( 'Auto-updates for regular feature updates are not available for this website.' ); ?> |
391 | 402 | </p> |
392 | | </form> |
| 403 | <?php endif; ?> |
| 404 | |
393 | 405 | <?php |
| 406 | /** |
| 407 | * Fires after the major core auto-update settings. |
| 408 | * |
| 409 | * @since 5.6.0 |
| 410 | */ |
| 411 | do_action( 'after_core_auto_updates_settings', $auto_update_settings ); |
394 | 412 | } |
395 | 413 | |
396 | 414 | /** |
… |
… |
function do_undismiss_core_update() { |
886 | 904 | exit; |
887 | 905 | } |
888 | 906 | |
| 907 | if ( isset( $_GET['core-major-auto-updates'] ) ) { |
| 908 | check_admin_referer( 'core-major-auto-updates-nonce' ); |
| 909 | |
| 910 | if ( 'enable' === $_GET['core-major-auto-updates'] ) { |
| 911 | update_site_option( 'auto_update_core_major', 'enabled' ); |
| 912 | wp_redirect( add_query_arg( 'core-major-auto-updates-saved', 'enabled', self_admin_url( 'update-core.php' ) ) ); |
| 913 | exit; |
| 914 | } elseif ( 'disable' === $_GET['core-major-auto-updates'] ) { |
| 915 | update_site_option( 'auto_update_core_major', 'disabled' ); |
| 916 | wp_redirect( add_query_arg( 'core-major-auto-updates-saved', 'disabled', self_admin_url( 'update-core.php' ) ) ); |
| 917 | exit; |
| 918 | } |
| 919 | } |
| 920 | |
889 | 921 | $action = isset( $_GET['action'] ) ? $_GET['action'] : 'upgrade-core'; |
890 | 922 | |
891 | 923 | $upgrade_error = false; |
… |
… |
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(); |