WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/11/2016 05:43:17 PM (5 years ago)
Author:
ocean90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-language-pack-upgrader.php

    r37635 r37687  
    222222            if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) )
    223223                return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination );
     224
     225        $language_updates_results = array();
    224226
    225227        foreach ( $language_updates as $language_update ) {
     
    253255
    254256            // Prevent credentials auth screen from displaying multiple times.
    255             if ( false === $result )
     257            if ( false === $result ) {
    256258                break;
    257         }
     259            }
     260
     261            $language_updates_results[] = array(
     262                'language' => $language_update->language,
     263                'type'     => $language_update->type,
     264                'slug'     => isset( $language_update->slug ) ? $language_update->slug : 'default',
     265                'version'  => $language_update->version,
     266            );
     267        }
     268
     269        // Remove upgrade hooks which are not required for translation updates.
     270        remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
     271        remove_action( 'upgrader_process_complete', 'wp_version_check' );
     272        remove_action( 'upgrader_process_complete', 'wp_update_plugins' );
     273        remove_action( 'upgrader_process_complete', 'wp_update_themes' );
     274
     275        /** This action is documented in wp-admin/includes/class-wp-upgrader.php */
     276        do_action( 'upgrader_process_complete', $this, array(
     277            'action'       => 'update',
     278            'type'         => 'translation',
     279            'bulk'         => true,
     280            'translations' => $language_updates_results
     281        ) );
     282
     283        // Re-add upgrade hooks.
     284        add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
     285        add_action( 'upgrader_process_complete', 'wp_version_check' );
     286        add_action( 'upgrader_process_complete', 'wp_update_plugins' );
     287        add_action( 'upgrader_process_complete', 'wp_update_themes' );
    258288
    259289        $this->skin->bulk_footer();
Note: See TracChangeset for help on using the changeset viewer.