wppaste
WordPress

Core_Upgrader

Since
2.8.0, 4.6.0
Source
wp-admin/includes/class-core-upgrader.php:25
Core class used for updating core.

Description

It allows for WordPress to upgrade itself in combination with the wp-admin/includes/update-core.php file.

Note: Newly introduced functions and methods cannot be used here.
All functions must be present in the previous version being upgraded from as this file is used there too.

Compatibility

WordPress
since 4.6.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 7

Every hook that fires from inside Core_Upgrader, in the order it appears in the class, grouped by the method that fires it.

Methods · 4

Source code

class Core_Upgrader extends WP_Upgrader { 	/**	 * Initializes the upgrade strings.	 *	 * @since 2.8.0	 */	public function upgrade_strings() {		$this->strings['up_to_date'] = __( 'WordPress is at the latest version.' );		$this->strings['locked']     = __( 'Another update is currently in progress.' );		$this->strings['no_package'] = __( 'Update package not available.' );		/* translators: %s: Package URL. */		$this->strings['downloading_package']   = sprintf( __( 'Downloading update from %s&#8230;' ), '<span class="code pre">%s</span>' );		$this->strings['unpack_package']        = __( 'Unpacking the update&#8230;' );		$this->strings['copy_failed']           = __( 'Could not copy files.' );		$this->strings['copy_failed_space']     = __( 'Could not copy files. You may have run out of disk space.' );		$this->strings['start_rollback']        = __( 'Attempting to restore the previous version.' );		$this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has been restored to your previous version.' );	} 	/**	 * Upgrades WordPress core.	 *	 * @since 2.8.0	 *	 * @global WP_Filesystem_Base $wp_filesystem                WordPress filesystem subclass.	 * @global callable           $_wp_filesystem_direct_method	 *	 * @param object $current Response object for whether WordPress is current.	 * @param array  $args {	 *     Optional. Arguments for upgrading WordPress core. Default empty array.	 *	 *     @type bool $pre_check_md5    Whether to check the file checksums before	 *                                  attempting the upgrade. Default true.	 *     @type bool $attempt_rollback Whether to attempt to rollback the chances if	 *                                  there is a problem. Default false.	 *     @type bool $do_rollback      Whether to perform this "upgrade" as a rollback.	 *                                  Default false.	 * }	 * @return string|false|WP_Error New WordPress version on success, false or WP_Error on failure.	 */	public function upgrade( $current, $args = array() ) {		global $wp_filesystem; 		require ABSPATH . WPINC . '/version.php'; // $wp_version; 		$start_time = time(); 		$defaults    = array(			'pre_check_md5'                => true,			'attempt_rollback'             => false,			'do_rollback'                  => false,			'allow_relaxed_file_ownership' => false,		);		$parsed_args = wp_parse_args( $args, $defaults ); 		$this->init();		$this->upgrade_strings(); 		// Is an update available?		if ( ! isset( $current->response ) || 'latest' === $current->response ) {			return new WP_Error( 'up_to_date', $this->strings['up_to_date'] );		} 		$res = $this->fs_connect( array( ABSPATH, WP_CONTENT_DIR ), $parsed_args['allow_relaxed_file_ownership'] );		if ( ! $res || is_wp_error( $res ) ) {			return $res;		} 		$wp_dir = trailingslashit( $wp_filesystem->abspath() ); 		$partial = true;		if ( $parsed_args['do_rollback'] ) {			$partial = false;		} elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() ) {			$partial = false;		} 		/*		 * If partial update is returned from the API, use that, unless we're doing

Changelog

Introduced in 2.8.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

4.6.0
Moved to its own file from wp-admin/includes/class-wp-upgrader.php.from the docblock
2.8.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-admin/includes/class-core-upgrader.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.