Changeset 49587 for trunk/src/wp-admin/update-core.php
- Timestamp:
- 11/12/2020 10:35:54 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/update-core.php
r49490 r49587 63 63 64 64 if ( 'development' === $update->response ) { 65 $message = __( 'You are using a development version of WordPress. You can update to the latest nightly build automatically:' );65 $message = __( 'You are using a development version of WordPress. You can update to the latest nightly build manually:' ); 66 66 } else { 67 67 if ( $current ) { … … 128 128 $message = sprintf( 129 129 /* translators: 1: Installed WordPress version number, 2: URL to WordPress release notes, 3: New WordPress version number, including locale if necessary. */ 130 __( 'You can update from WordPress %1$s to <a href="%2$s">WordPress %3$s</a> automatically:' ),130 __( 'You can update from WordPress %1$s to <a href="%2$s">WordPress %3$s</a> manually:' ), 131 131 $wp_version, 132 132 $version_url, … … 255 255 256 256 if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { 257 echo '<div class="notice notice-warning"><p>'; 257 echo '<h2 class="response">'; 258 _e( 'An updated version of WordPress is available.' ); 259 echo '</h2>'; 260 261 echo '<div class="notice notice-warning inline"><p>'; 258 262 printf( 259 263 /* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */ … … 263 267 ); 264 268 echo '</p></div>'; 265 266 echo '<h2 class="response">';267 _e( 'An updated version of WordPress is available.' );268 echo '</h2>';269 269 } 270 270 … … 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);315 }316 echo '<div class="notice notice-success is-dismissible"><p>';317 _e( 'WordPress auto-update settings updated.' );318 echo '</p></div>'; 319 }320 321 $upgrade_ dev = get_site_option( 'auto_update_core_dev', true );322 $upgrade_m inor = get_site_option( 'auto_update_core_minor', true );323 $upgrade_major = get_site_option( 'auto_update_core_major', false ); 324 309 if ( isset( $_GET['core-major-auto-updates-saved'] ) ) { 310 if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) { 311 $notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' ); 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 only receive automatic security and maintenance releases from now on.' ); 315 echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>'; 316 } 317 } 318 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'; 323 324 $can_set_update_option = true; 325 325 // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'minor', false. 326 326 if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { … … 344 344 $upgrade_major = false; 345 345 } 346 347 // The UI is overridden by the WP_AUTO_UPDATE_CORE constant. 348 $can_set_update_option = 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 $can_set_update_option = 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 $can_set_update_option = false; 346 364 } 347 365 … … 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> 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 } 372 } 373 ?> 374 </p> 375 <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> 380 </p> 390 391 <p class="auto-update-status"> 381 392 <?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 ); 393 if ( $upgrade_major ) { 394 _e( 'This site is automatically kept up to date with each new version of WordPress.' ); 395 396 if ( $can_set_update_option ) { 397 echo '<br>'; 398 echo sprintf( 399 /* Translators: Action link to disable core auto-updates. */ 400 __( '<a href="%s">Switch to automatic updates for maintenance and security releases only.</a>' ), 401 wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ) 402 ); 403 } 404 } elseif ( $upgrade_minor ) { 405 _e( 'This site is automatically kept up to date with maintenance and security releases of WordPress.' ); 406 407 if ( $can_set_update_option ) { 408 echo '<br>'; 409 echo sprintf( 410 /* Translators: Action link to enable core auto-updates. */ 411 __( '<a href="%s">Enable automatic updates for all new versions of WordPress.</a>' ), 412 wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ) 413 ); 414 } 415 } else { 416 _e( 'This site will not receive automatic updates for new versions of WordPress.' ); 417 } 388 418 ?> 389 <p> 390 <input id="core-auto-updates-settings" class="button" type="submit" value="<?php esc_attr_e( 'Save' ); ?>" name="core-auto-updates-settings" /> 391 </p> 392 </form> 419 </p> 420 393 421 <?php 422 /** 423 * Fires after the major core auto-update settings. 424 * 425 * @since 5.6.0 426 */ 427 do_action( 'after_core_auto_updates_settings', $auto_update_settings ); 394 428 } 395 429 … … 958 992 <div class="wrap"> 959 993 <h1><?php _e( 'WordPress Updates' ); ?></h1> 994 <p><?php _e( 'Here you can find information about updates, set auto-updates and see what plugins or themes need updating.' ); ?></p> 995 960 996 <?php 961 997 if ( $upgrade_error ) { … … 976 1012 } 977 1013 978 echo '<p>'; 1014 echo '<h2 class="wp-current-version">'; 1015 /* translators: Current version of WordPress. */ 1016 printf( __( 'Current version: %s' ), get_bloginfo( 'version' ) ); 1017 echo '</h2>'; 1018 1019 echo '<p class="update-last-checked">'; 979 1020 /* translators: 1: Date, 2: Time. */ 980 1021 printf( __( 'Last checked on %1$s at %2$s.' ), date_i18n( __( 'F j, Y' ), $last_update_check ), date_i18n( __( 'g:i a' ), $last_update_check ) ); … … 983 1024 984 1025 if ( current_user_can( 'update_core' ) ) { 1026 core_auto_updates_settings(); 985 1027 core_upgrade_preamble(); 986 core_auto_updates_settings();987 1028 } 988 1029 if ( current_user_can( 'update_plugins' ) ) { … … 1159 1200 require_once ABSPATH . 'wp-admin/admin-footer.php'; 1160 1201 1202 } elseif ( 'core-major-auto-updates-settings' === $action ) { 1203 $redirect_url = self_admin_url( 'update-core.php' ); 1204 1205 if ( isset( $_GET['value'] ) ) { 1206 check_admin_referer( 'core-major-auto-updates-nonce' ); 1207 1208 if ( 'enable' === $_GET['value'] ) { 1209 update_site_option( 'auto_update_core_major', 'enabled' ); 1210 $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'enabled', $redirect_url ); 1211 } elseif ( 'disable' === $_GET['value'] ) { 1212 update_site_option( 'auto_update_core_major', 'disabled' ); 1213 $redirect_url = add_query_arg( 'core-major-auto-updates-saved', 'disabled', $redirect_url ); 1214 } 1215 } 1216 1217 wp_redirect( $redirect_url ); 1218 exit; 1161 1219 } else { 1162 1220 /**
Note: See TracChangeset
for help on using the changeset viewer.