diff --git a/src/wp-admin/update-core.php b/src/wp-admin/update-core.php
index c08e57f6e9..7e77bfdbdf 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 | $upgrade_dev = get_site_option( 'auto_update_core_dev', 'enabled' ); |
| 320 | $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ); |
| 321 | $upgrade_major = get_site_option( 'auto_update_core_major', 'disabled' ); |
324 | 322 | |
| 323 | $upgrade_major_optin_enabled = true; |
325 | 324 | // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'minor', false. |
326 | 325 | if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { |
327 | 326 | if ( false === WP_AUTO_UPDATE_CORE ) { |
328 | 327 | // Defaults to turned off, unless a filter allows it. |
329 | | $upgrade_dev = false; |
330 | | $upgrade_minor = false; |
331 | | $upgrade_major = false; |
| 328 | $upgrade_dev = 'disabled'; |
| 329 | $upgrade_minor = 'disabled'; |
| 330 | $upgrade_major = 'disabled'; |
332 | 331 | } elseif ( true === WP_AUTO_UPDATE_CORE |
333 | 332 | || 'beta' === WP_AUTO_UPDATE_CORE |
334 | 333 | || 'rc' === WP_AUTO_UPDATE_CORE |
335 | 334 | ) { |
336 | 335 | // ALL updates for core. |
337 | | $upgrade_dev = true; |
338 | | $upgrade_minor = true; |
339 | | $upgrade_major = true; |
| 336 | $upgrade_dev = 'enabled'; |
| 337 | $upgrade_minor = 'enabled'; |
| 338 | $upgrade_major = 'enabled'; |
340 | 339 | } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { |
341 | 340 | // Only minor updates for core. |
342 | | $upgrade_dev = false; |
343 | | $upgrade_minor = true; |
344 | | $upgrade_major = false; |
| 341 | $upgrade_dev = 'disabled'; |
| 342 | $upgrade_minor = 'enabled'; |
| 343 | $upgrade_major = 'disabled'; |
| 344 | } |
| 345 | |
| 346 | // The UI is overriden by the WP_AUTO_UPDATE_CORE constant. |
| 347 | $upgrade_major_optin_enabled = false; |
| 348 | } |
| 349 | if ( defined( 'AUTOMATIC_UPDATER_DISABLED' ) ) { |
| 350 | if ( true === AUTOMATIC_UPDATER_DISABLED ) { |
| 351 | $upgrade_dev = 'disabled'; |
| 352 | $upgrade_minor = 'disabled'; |
| 353 | $upgrade_major = 'disabled'; |
345 | 354 | } |
| 355 | // The UI is overriden by the AUTOMATIC_UPDATER_DISABLED constant. |
| 356 | $upgrade_major_optin_enabled = false; |
| 357 | } |
| 358 | |
| 359 | // Is the UI overriden by a plugin using the allow_major_auto_core_updates filter? |
| 360 | if ( has_filter( 'allow_major_auto_core_updates' ) ) { |
| 361 | $upgrade_major_optin_enabled = false; |
346 | 362 | } |
347 | 363 | |
348 | 364 | /** This filter is documented in wp-admin/includes/class-core-upgrader.php */ |
… |
… |
function core_auto_updates_settings() { |
357 | 373 | 'minor' => $upgrade_minor, |
358 | 374 | 'major' => $upgrade_major, |
359 | 375 | ); |
| 376 | |
| 377 | if ( $auto_update_settings['major'] ) { |
| 378 | $wp_version = get_bloginfo( 'version' ); |
| 379 | $updates = get_core_updates(); |
| 380 | if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { |
| 381 | echo '<p>' . wp_get_auto_update_message() . '</p>'; |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | $action_url = self_admin_url( 'update-core.php?action=core-major-auto-updates-settings' ); |
360 | 386 | ?> |
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> |
| 387 | |
| 388 | <?php if ( $upgrade_major_optin_enabled ) : ?> |
364 | 389 | <p> |
365 | 390 | <?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 | | } |
| 391 | if ( 'enabled' === $upgrade_major ) { |
| 392 | echo sprintf( |
| 393 | /* Translators: Action link to disable core auto-updates. */ |
| 394 | __( 'Auto-updates for regular feature updates are on. You can <a href="%s">turn them off.</a>' ), |
| 395 | wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ) |
| 396 | ); |
| 397 | } else { |
| 398 | echo sprintf( |
| 399 | /* Translators: Action link to enable core auto-updates. */ |
| 400 | __( 'You are invited to <a href="%s">automatically keep this site up-to-date with regular feature updates.</a>' ), |
| 401 | wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ) |
| 402 | ); |
372 | 403 | } |
373 | 404 | ?> |
374 | 405 | </p> |
| 406 | <?php elseif ( 'enabled' === $upgrade_major ) : ?> |
375 | 407 | <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> |
| 408 | <?php _e( 'This website is set to keep itself up-to-date with regular feature updates.' ); ?> |
380 | 409 | </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 | | ?> |
| 410 | <?php else: ?> |
389 | 411 | <p> |
390 | | <input id="core-auto-updates-settings" class="button" type="submit" value="<?php esc_attr_e( 'Save' ); ?>" name="core-auto-updates-settings" /> |
| 412 | <?php _e( 'Auto-updates for regular feature updates are not available for this website.' ); ?> |
391 | 413 | </p> |
392 | | </form> |
| 414 | <?php endif; ?> |
| 415 | |
393 | 416 | <?php |
| 417 | /** |
| 418 | * Fires after the major core auto-update settings. |
| 419 | * |
| 420 | * @since 5.6.0 |
| 421 | */ |
| 422 | do_action( 'after_core_auto_updates_settings', $auto_update_settings ); |
394 | 423 | } |
395 | 424 | |
396 | 425 | /** |
… |
… |
if ( 'upgrade-core' === $action ) { |
957 | 986 | ?> |
958 | 987 | <div class="wrap"> |
959 | 988 | <h1><?php _e( 'WordPress Updates' ); ?></h1> |
| 989 | <p><?php _e( 'Here you can find information about updates, set auto-updates and see what plugins or themes need updating.' ); ?></p> |
| 990 | |
960 | 991 | <?php |
961 | 992 | if ( $upgrade_error ) { |
962 | 993 | echo '<div class="error"><p>'; |
… |
… |
if ( 'upgrade-core' === $action ) { |
982 | 1013 | echo '</p>'; |
983 | 1014 | |
984 | 1015 | if ( current_user_can( 'update_core' ) ) { |
985 | | core_upgrade_preamble(); |
986 | 1016 | core_auto_updates_settings(); |
| 1017 | core_upgrade_preamble(); |
987 | 1018 | } |
988 | 1019 | if ( current_user_can( 'update_plugins' ) ) { |
989 | 1020 | list_plugin_updates(); |
… |
… |
if ( 'upgrade-core' === $action ) { |
1158 | 1189 | |
1159 | 1190 | require_once ABSPATH . 'wp-admin/admin-footer.php'; |
1160 | 1191 | |
| 1192 | } elseif ( 'core-major-auto-updates-settings' === $action ) { |
| 1193 | $redirect_url = self_admin_url( 'update-core.php' ); |
| 1194 | |
| 1195 | if ( isset( $_GET['value'] ) ) { |
| 1196 | check_admin_referer( 'core-major-auto-updates-nonce' ); |
| 1197 | |
| 1198 | if ( 'enable' === $_GET['value'] ) { |
| 1199 | update_site_option( 'auto_update_core_major', 'enabled' ); |
| 1200 | $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'enabled', $redirect_url ); |
| 1201 | } elseif ( 'disable' === $_GET['value'] ) { |
| 1202 | update_site_option( 'auto_update_core_major', 'disabled' ); |
| 1203 | $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'disabled', $redirect_url ); |
| 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | wp_redirect( $redirect_url ); |
| 1208 | exit; |
1161 | 1209 | } else { |
1162 | 1210 | /** |
1163 | 1211 | * Fires for each custom update action on the WordPress Updates screen. |