WP_Automatic_Updater::run() WordPress Method
The WP_Automatic_Updater::run() method is responsible for handling the actual updating of WordPress. This includes checking the current version against the version required by the update, downloading the update files, and running the update process.
WP_Automatic_Updater::run() #
Kicks off the background update process, looping through all pending updates.
Source
File: wp-admin/includes/class-wp-automatic-updater.php
public function run() { if ( $this->is_disabled() ) { return; } if ( ! is_main_network() || ! is_main_site() ) { return; } if ( ! 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->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->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->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->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->send_debug_email(); } if ( ! empty( $this->update_results['core'] ) ) { $this->after_core_update( $this->update_results['core'][0] ); } elseif ( ! empty( $this->update_results['plugin'] ) || ! empty( $this->update_results['theme'] ) ) { $this->after_plugin_theme_update( $this->update_results ); } /** * Fires after all automatic updates have run. * * @since 3.8.0 * * @param array $update_results The results of all attempted updates. */ do_action( 'automatic_updates_complete', $this->update_results ); } WP_Upgrader::release_lock( 'auto_updater' ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.7.0 | Introduced. |