Language_Pack_Upgrader
- Since
- 3.7.0, 4.6.0
- Source
wp-admin/includes/class-language-pack-upgrader.php:19
Core class used for updating/installing language packs (translations) for plugins, themes, and core.
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 Language_Pack_Upgrader, in the order it appears in the class, grouped by the method that fires it.
Properties · 2
$resultarray|WP_Errorpublic- Result of the language pack upgrade.
$bulkboolpublic- Whether a bulk upgrade/installation is being performed.
Methods · 7
- async_upgrade()Asynchronously upgrades language packs after other upgrades have been made.
- upgrade_strings()Initializes the upgrade strings.
- upgrade()Upgrades a language pack.
- bulk_upgrade()Upgrades several language packs at once.
- check_package()Checks that the package source contains .mo and .po files.
- get_name_for_update()Gets the name of an item being updated.
- clear_destination()Clears existing translations where this item is going to be installed into.
Source code
class Language_Pack_Upgrader extends WP_Upgrader { /** * Result of the language pack upgrade. * * @since 3.7.0 * @var array|WP_Error $result * @see WP_Upgrader::$result */ public $result; /** * Whether a bulk upgrade/installation is being performed. * * @since 3.7.0 * @var bool $bulk */ public $bulk = true; /** * Asynchronously upgrades language packs after other upgrades have been made. * * Hooked to the {@see 'upgrader_process_complete'} action by default. * * @since 3.7.0 * * @param false|WP_Upgrader $upgrader Optional. WP_Upgrader instance or false. If `$upgrader` is * a Language_Pack_Upgrader instance, the method will bail to * avoid recursion. Otherwise unused. Default false. */ public static function async_upgrade( $upgrader = false ) { // Avoid recursion. if ( $upgrader && $upgrader instanceof Language_Pack_Upgrader ) { return; } // Nothing to do? $language_updates = wp_get_translation_updates(); if ( ! $language_updates ) { return; } /* * Avoid messing with VCS installations, at least for now. * Noted: this is not the ideal way to accomplish this. */ $check_vcs = new WP_Automatic_Updater(); if ( $check_vcs->is_vcs_checkout( WP_CONTENT_DIR ) ) { return; } foreach ( $language_updates as $key => $language_update ) { $update = ! empty( $language_update->autoupdate ); /** * Filters whether to asynchronously update translation for core, a plugin, or a theme. * * @since 4.0.0 * * @param bool $update Whether to update. * @param object $language_update The update offer. */ $update = apply_filters( 'async_update_translation', $update, $language_update ); if ( ! $update ) { unset( $language_updates[ $key ] ); } } if ( empty( $language_updates ) ) { return; } // Re-use the automatic upgrader skin if the parent upgrader is using it. if ( $upgrader && $upgrader->skin instanceof Automatic_Upgrader_Skin ) { $skin = $upgrader->skin; } else { $skin = new Language_Pack_Upgrader_Skin( array( 'skip_header_footer' => true,Changelog
Introduced in 3.7.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
3.7.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-language-pack-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.