Upgrade: Trigger the `upgrader_process_complete` action for translation updates.

This brings `Language_Pack_Upgrader` in line with the core, theme, and plugin upgrader.

Props ronalfy.
Fixes #36872.

git-svn-id: https://develop.svn.wordpress.org/trunk@37687 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2016-06-11 17:43:17 +00:00
parent 3348efa466
commit 0461e41927
2 changed files with 47 additions and 7 deletions

View File

@ -222,6 +222,8 @@ class Language_Pack_Upgrader extends WP_Upgrader {
if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) )
return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination );
$language_updates_results = array();
foreach ( $language_updates as $language_update ) {
$this->skin->language_update = $language_update;
@ -252,10 +254,38 @@ class Language_Pack_Upgrader extends WP_Upgrader {
$results[] = $this->result;
// Prevent credentials auth screen from displaying multiple times.
if ( false === $result )
if ( false === $result ) {
break;
}
$language_updates_results[] = array(
'language' => $language_update->language,
'type' => $language_update->type,
'slug' => isset( $language_update->slug ) ? $language_update->slug : 'default',
'version' => $language_update->version,
);
}
// Remove upgrade hooks which are not required for translation updates.
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' );
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
do_action( 'upgrader_process_complete', $this, array(
'action' => 'update',
'type' => 'translation',
'bulk' => true,
'translations' => $language_updates_results
) );
// Re-add upgrade hooks.
add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
add_action( 'upgrader_process_complete', 'wp_version_check' );
add_action( 'upgrader_process_complete', 'wp_update_plugins' );
add_action( 'upgrader_process_complete', 'wp_update_themes' );
$this->skin->bulk_footer();
$this->skin->footer();

View File

@ -762,17 +762,27 @@ class WP_Upgrader {
*
* @since 3.6.0
* @since 3.7.0 Added to WP_Upgrader::run().
* @since 4.6.0 `$translations` was added as a possible argument to `$hook_extra`.
*
* @param WP_Upgrader $this WP_Upgrader instance. In other contexts, $this, might be a
* Theme_Upgrader, Plugin_Upgrader or Core_Upgrade instance.
* Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance.
* @param array $hook_extra {
* Array of bulk item update data.
*
* @type string $action Type of action. Default 'update'.
* @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'.
* @type bool $bulk Whether the update process is a bulk update. Default true.
* @type array $plugins Array of the basename paths of the plugins' main files.
* @type array $themes The theme slugs.
* @type string $action Type of action. Default 'update'.
* @type string $type Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
* @type bool $bulk Whether the update process is a bulk update. Default true.
* @type array $plugins Array of the basename paths of the plugins' main files.
* @type array $themes The theme slugs.
* @type array $translations {
* Array of translations update data.
*
* @type string $language The locale the translation is for.
* @type string $type Type of translation. Accepts 'plugin', 'theme', or 'core'.
* @type string $slug Text domain the translation is for. The slug of a theme/plugin or
* 'default' for core translations.
* @type string $version The version of a theme, plugin, or core.
* }
* }
*/
do_action( 'upgrader_process_complete', $this, $options['hook_extra'] );