• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress core a2z

WordPress core a2z

WordPress core only

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / WP_Automatic_Updater::run() – Kicks off the background update process, looping through all pending updates.

You appear to be a bot. Output may be restricted

Description

Kicks off the background update process, looping through all pending updates.

Usage

WP_Automatic_Updater::run();

Parameters

Returns

void

Source

File name: wordpress/wp-admin/includes/class-wp-automatic-updater.php
Lines:

1 to 100 of 117
  public function run() {
    if ( $this->WP_Automatic_Updater::is_disabled() ) {
      return;
    }

    if ( ! is_main_network() || ! is_main_site() ) {
      return;
    }

    if ( ! WP_Upgrader::WP_Upgrader::create_lock( 'auto_updater' ) ) {
      return;
    }

    // Don't automatically run these things, as we'll handle it ourselves.
    remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
    remove_action( 'upgrader_process_complete', 'wp_version_check' );
    remove_action( 'upgrader_process_complete', 'wp_update_plugins' );
    remove_action( 'upgrader_process_complete', 'wp_update_themes' );

    // Next, plugins.
    wp_update_plugins(); // Check for plugin updates.
    $plugin_updates = get_site_transient( 'update_plugins' );
    if ( $plugin_updates && ! empty( $plugin_updates->response ) ) {
      foreach ( $plugin_updates->response as $plugin ) {
        $this->WP_Automatic_Updater::update( 'plugin', $plugin );
      }
      // Force refresh of plugin update information.
      wp_clean_plugins_cache();
    }

    // Next, those themes we all love.
    wp_update_themes();  // Check for theme updates.
    $theme_updates = get_site_transient( 'update_themes' );
    if ( $theme_updates && ! empty( $theme_updates->response ) ) {
      foreach ( $theme_updates->response as $theme ) {
        $this->WP_Automatic_Updater::update( 'theme', (object) $theme );
      }
      // Force refresh of theme update information.
      wp_clean_themes_cache();
    }

    // Next, process any core update.
    wp_version_check(); // Check for core updates.
    $core_update = find_core_auto_update();

    if ( $core_update ) {
      $this->WP_Automatic_Updater::update( 'core', $core_update );
    }

    // Clean up, and check for any pending translations.
    // (Core_Upgrader checks for core updates.)
    $theme_stats = array();
    if ( isset( $this->update_results['theme'] ) ) {
      foreach ( $this->update_results['theme'] as $upgrade ) {
        $theme_stats[ $upgrade->item->theme ] = ( true === $upgrade->result );
      }
    }
    wp_update_themes( $theme_stats ); // Check for theme updates.

    $plugin_stats = array();
    if ( isset( $this->update_results['plugin'] ) ) {
      foreach ( $this->update_results['plugin'] as $upgrade ) {
        $plugin_stats[ $upgrade->item->plugin ] = ( true === $upgrade->result );
      }
    }
    wp_update_plugins( $plugin_stats ); // Check for plugin updates.

    // Finally, process any new translations.
    $language_updates = wp_get_translation_updates();
    if ( $language_updates ) {
      foreach ( $language_updates as $update ) {
        $this->WP_Automatic_Updater::update( 'translation', $update );
      }

      // Clear existing caches.
      wp_clean_update_cache();

      wp_version_check();  // Check for core updates.
      wp_update_themes();  // Check for theme updates.
      wp_update_plugins(); // Check for plugin updates.
    }

    // Send debugging email to admin for all development installations.
    if ( ! empty( $this->update_results ) ) {
      $development_version = false !== strpos( get_bloginfo( 'version' ), '-' );

      
/**
 * Filters whether to send a debugging email for each automatic background update.
 *
 * @since 3.7.0
 *
 * @param bool $development_version By default, emails are sent if the
 *                                  install is a development version.
 *                                  Return false to avoid the email.
 */
      if ( apply_filters( 'automatic_updates_send_debug_email', $development_version ) ) {
        $this->WP_Automatic_Updater::send_debug_email();
      }

      if ( ! empty( $this->update_results['core'] ) ) {
 
[1] [2] Next »

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 21st August 2020

Primary Sidebar

Information

Function name: WP_Automatic_Updater::run
Class ref: WP_Automatic_Updater
Plugin ref: WordPress
Version: 5.6.2
Sourcefile: wp-admin/includes/class-wp-automatic-updater.php
File ref: wp-admin/includes/class-wp-automatic-updater.php
Deprecated?: No
API Letters: A,R,U,W

Footer

WP-a2z
WordPress core a2z
WordPress core only
WordPress 5.6.2
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  core.wp-a2z.org
© Copyright WP-a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites