core_auto_updates_settings() – Display WordPress auto-updates settings.

You appear to be a bot. Output may be restricted

Description

Display WordPress auto-updates settings.

Usage

core_auto_updates_settings();

Parameters

Returns

void

Source

File name: wordpress/wp-admin/update-core.php
Lines:

1 to 100 of 138
function core_auto_updates_settings() {
  if ( isset( $_GET['core-major-auto-updates-saved'] ) ) {
    if ( 'enabled' === $_GET['core-major-auto-updates-saved'] ) {
      $notice_text = __( 'Automatic updates for all WordPress versions have been enabled. Thank you!' );
      echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>';
    } elseif ( 'disabled' === $_GET['core-major-auto-updates-saved'] ) {
      $notice_text = __( 'WordPress will only receive automatic security and maintenance releases from now on.' );
      echo '<div class="notice notice-success is-dismissible"><p>' . $notice_text . '</p></div>';
    }
  }

  require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
  $updater = new WP_Automatic_Updater();

  // Defaults:
  $upgrade_dev   = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled';
  $upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled';
  $upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled';

  $can_set_update_option = true;
  // WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'development', 'branch-development', 'minor', false.
  if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) {
    if ( false === WP_AUTO_UPDATE_CORE ) {
      // Defaults to turned off, unless a filter allows it.
      $upgrade_dev   = false;
      $upgrade_minor = false;
      $upgrade_major = false;
    } elseif ( true === WP_AUTO_UPDATE_CORE
      || in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc', 'development', 'branch-development' ), true )
    ) {
      // ALL updates for core.
      $upgrade_dev   = true;
      $upgrade_minor = true;
      $upgrade_major = true;
    } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) {
      // Only minor updates for core.
      $upgrade_dev   = false;
      $upgrade_minor = true;
      $upgrade_major = false;
    }

    // The UI is overridden by the `WP_AUTO_UPDATE_CORE` constant.
    $can_set_update_option = false;
  }

  if ( $updater->is_disabled() ) {
    $upgrade_dev   = false;
    $upgrade_minor = false;
    $upgrade_major = false;

    /*
		 * The UI is overridden by the `AUTOMATIC_UPDATER_DISABLED` constant
		 * or the `automatic_updater_disabled` filter,
		 * or by `wp_is_file_mod_allowed( 'automatic_updater' )`.
		 * See `WP_Automatic_Updater::is_disabled()`.
		 */
    $can_set_update_option = false;
  }

  // Is the UI overridden by a plugin using the `allow_major_auto_core_updates` filter?
  if ( has_filter( 'allow_major_auto_core_updates' ) ) {
    $can_set_update_option = false;
  }

  
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */
  $upgrade_dev = apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev );
  
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */
  $upgrade_minor = apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor );
  
/** This filter is documented in wp-admin/includes/class-core-upgrader.php */
  $upgrade_major = apply_filters( 'allow_major_auto_core_updates', $upgrade_major );

  $auto_update_settings = array(
    'dev'   => $upgrade_dev,
    'minor' => $upgrade_minor,
    'major' => $upgrade_major,
  );

  if ( $upgrade_major ) {
    $wp_version = get_bloginfo( 'version' );
    $updates    = get_core_updates();

    if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {
      echo '<p>' . wp_get_auto_update_message() . '</p>';
    }
  }

  $action_url = self_admin_url( 'update-core.php?action=core-major-auto-updates-settings' );
  ?>

	<p class="auto-update-status">
		<?php

    if ( $updater->is_vcs_checkout( ABSPATH ) ) {
      _e( 'This site appears to be under version control. Automatic updates are disabled.' );
    } elseif ( $upgrade_major ) {
      _e( 'This site is automatically kept up to date with each new version of WordPress.' );

      if ( $can_set_update_option ) {
        echo '<br>';
        printf(
 

 View on GitHub View on Trac