Theme_Upgrader
- Since
- 2.8.0, 4.6.0
- Source
wp-admin/includes/class-theme-upgrader.php:21
Core class used for upgrading/installing themes.
Description
It is designed to upgrade/install themes from a local zip, remote zip URL, or uploaded zip file.
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 · 2
Every hook that fires from inside Theme_Upgrader, in the order it appears in the class, grouped by the method that fires it.
Properties · 3
$resultarray|WP_Errorpublic- Result of the theme upgrade offer.
$bulkboolpublic- Whether multiple themes are being upgraded/installed in bulk.
$new_theme_dataarraypublic- New theme info.
Methods · 12
- upgrade_strings()Initializes the upgrade strings.
- install_strings()Initializes the installation strings.
- check_parent_theme_filter()Checks if a child theme is being installed and its parent also needs to be installed.
- hide_activate_preview_actions()Don't display the activate and preview actions to the user.
- install()Install a theme package.
- upgrade()Upgrades a theme.
- bulk_upgrade()Upgrades several themes at once.
- check_package()Checks that the package source contains a valid theme.
- current_before()Turns on maintenance mode before attempting to upgrade the active theme.
- current_after()Turns off maintenance mode after upgrading the active theme.
- delete_old_theme()Deletes the old theme during an upgrade.
- theme_info()Gets the WP_Theme object for a theme.
Source code
class Theme_Upgrader extends WP_Upgrader { /** * Result of the theme upgrade offer. * * @since 2.8.0 * @var array|WP_Error $result * @see WP_Upgrader::$result */ public $result; /** * Whether multiple themes are being upgraded/installed in bulk. * * @since 2.9.0 * @var bool $bulk */ public $bulk = false; /** * New theme info. * * @since 5.5.0 * @var array $new_theme_data * * @see check_package() */ public $new_theme_data = array(); /** * Initializes the upgrade strings. * * @since 2.8.0 */ public function upgrade_strings() { $this->strings['up_to_date'] = __( 'The theme is at the latest version.' ); $this->strings['no_package'] = __( 'Update package not available.' ); /* translators: %s: Package URL. */ $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code pre">%s</span>' ); $this->strings['unpack_package'] = __( 'Unpacking the update…' ); $this->strings['remove_old'] = __( 'Removing the old version of the theme…' ); $this->strings['remove_old_failed'] = __( 'Could not remove the old theme.' ); $this->strings['process_failed'] = __( 'Theme update failed.' ); $this->strings['process_success'] = __( 'Theme updated successfully.' ); } /** * Initializes the installation strings. * * @since 2.8.0 */ public function install_strings() { $this->strings['no_package'] = __( 'Installation package not available.' ); /* translators: %s: Package URL. */ $this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code pre">%s</span>' ); $this->strings['unpack_package'] = __( 'Unpacking the package…' ); $this->strings['installing_package'] = __( 'Installing the theme…' ); $this->strings['remove_old'] = __( 'Removing the old version of the theme…' ); $this->strings['remove_old_failed'] = __( 'Could not remove the old theme.' ); $this->strings['no_files'] = __( 'The theme contains no files.' ); $this->strings['process_failed'] = __( 'Theme installation failed.' ); $this->strings['process_success'] = __( 'Theme installed successfully.' ); /* translators: 1: Theme name, 2: Theme version. */ $this->strings['process_success_specific'] = __( 'Successfully installed the theme <strong>%1$s %2$s</strong>.' ); $this->strings['parent_theme_search'] = __( 'This theme requires a parent theme. Checking if it is installed…' ); /* translators: 1: Theme name, 2: Theme version. */ $this->strings['parent_theme_prepare_install'] = __( 'Preparing to install <strong>%1$s %2$s</strong>…' ); /* translators: 1: Theme name, 2: Theme version. */ $this->strings['parent_theme_currently_installed'] = __( 'The parent theme, <strong>%1$s %2$s</strong>, is currently installed.' ); /* translators: 1: Theme name, 2: Theme version. */ $this->strings['parent_theme_install_success'] = __( 'Successfully installed the parent theme, <strong>%1$s %2$s</strong>.' ); /* translators: %s: Theme name. */ $this->strings['parent_theme_not_found'] = sprintf( __( '<strong>The parent theme could not be found.</strong> You will need to install the parent theme, %s, before you can use this child theme.' ), '<strong>%s</strong>' ); /* translators: %s: Theme error. */ $this->strings['current_theme_has_errors'] = __( 'The active theme has the following error: "%s".' ); if ( ! empty( $this->skin->overwrite ) ) { if ( 'update-theme' === $this->skin->overwrite ) { $this->strings['installing_package'] = __( 'Updating the theme…' ); $this->strings['process_failed'] = __( 'Theme update failed.' );Changelog
Introduced in 2.8.0. Unchanged from 6.7.7 through 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 7.1.0 tag, from
src/wp-admin/includes/class-theme-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.