| | 304 | * Display WordPress auto-updates settings. |
| | 305 | * |
| | 306 | * @since 5.6.0 |
| | 307 | */ |
| | 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-info is-dismissible"><p>'; |
| | 317 | _e( 'WordPress auto-updates settings updated.' ); |
| | 318 | echo '</p></div>'; |
| | 319 | } |
| | 320 | |
| | 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 ); |
| | 324 | |
| | 325 | if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { |
| | 326 | if ( false === WP_AUTO_UPDATE_CORE ) { |
| | 327 | // Defaults to turned off, unless a filter allows it. |
| | 328 | $upgrade_dev = false; |
| | 329 | $upgrade_minor = false; |
| | 330 | $upgrade_major = false; |
| | 331 | } elseif ( true === WP_AUTO_UPDATE_CORE ) { |
| | 332 | // ALL updates for core. |
| | 333 | $upgrade_dev = true; |
| | 334 | $upgrade_minor = true; |
| | 335 | $upgrade_major = true; |
| | 336 | } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { |
| | 337 | // Only minor updates for core. |
| | 338 | $upgrade_dev = false; |
| | 339 | $upgrade_minor = true; |
| | 340 | $upgrade_major = false; |
| | 341 | } |
| | 342 | } |
| | 343 | |
| | 344 | $upgrade_dev = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ); |
| | 345 | $upgrade_minor = apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor ); |
| | 346 | $upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major ); |
| | 347 | |
| | 348 | $auto_update_settings = array( |
| | 349 | 'dev' => $upgrade_dev, |
| | 350 | 'minor' => $upgrade_minor, |
| | 351 | 'major' => $upgrade_major, |
| | 352 | ); |
| | 353 | ?> |
| | 354 | <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" name="core-auto-updates" class="form-core-auto-updates"> |
| | 355 | <?php wp_nonce_field( 'core-auto-updates-nonce', 'set_core_auto_updates_settings' ); ?> |
| | 356 | <h2><?php _e( 'Auto-update settings' ); ?></h2> |
| | 357 | <p> |
| | 358 | <?php |
| | 359 | if ( $auto_update_settings['major'] ) { |
| | 360 | $wp_version = get_bloginfo( 'version' ); |
| | 361 | $updates = get_core_updates(); |
| | 362 | if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) { |
| | 363 | echo wp_get_auto_update_message(); |
| | 364 | } |
| | 365 | } |
| | 366 | ?> |
| | 367 | </p> |
| | 368 | <p> |
| | 369 | <input type="checkbox" name="core-auto-updates-major" id="core-auto-updates-major" value="1" <?php checked( $auto_update_settings['major'], 1 ); ?> /> |
| | 370 | <label for="core-auto-updates-major"> |
| | 371 | <?php _e( 'Keep my site up-to-date with regular feature updates (major versions).' ); ?> |
| | 372 | </label> |
| | 373 | </p> |
| | 374 | <?php |
| | 375 | /** |
| | 376 | * Fires after the major core auto-update checkbox. |
| | 377 | * |
| | 378 | * @since 5.6.0 |
| | 379 | */ |
| | 380 | do_action( 'after_core_auto_updates_settings_fields', $auto_update_settings ); |
| | 381 | ?> |
| | 382 | <p> |
| | 383 | <input id="core-auto-updates-settings" class="button" type="submit" value="<?php esc_attr_e( 'Save' ); ?>" name="core-auto-updates-settings" /> |
| | 384 | </p> |
| | 385 | <?php |
| | 386 | } |
| | 387 | |
| | 388 | /** |