Make WordPress Core

Changeset 37687


Ignore:
Timestamp:
06/11/2016 05:43:17 PM (8 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.

Location:
trunk/src/wp-admin/includes
Files:
2 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();
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r37558 r37687  
    763763             * @since 3.6.0
    764764             * @since 3.7.0 Added to WP_Upgrader::run().
     765             * @since 4.6.0 `$translations` was added as a possible argument to `$hook_extra`.
    765766             *
    766767             * @param WP_Upgrader $this WP_Upgrader instance. In other contexts, $this, might be a
    767              *                          Theme_Upgrader, Plugin_Upgrader or Core_Upgrade instance.
     768             *                          Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance.
    768769             * @param array       $hook_extra {
    769770             *     Array of bulk item update data.
    770771             *
    771              *     @type string $action  Type of action. Default 'update'.
    772              *     @type string $type    Type of update process. Accepts 'plugin', 'theme', or 'core'.
    773              *     @type bool   $bulk    Whether the update process is a bulk update. Default true.
    774              *     @type array  $plugins Array of the basename paths of the plugins' main files.
    775              *     @type array  $themes  The theme slugs.
     772             *     @type string $action       Type of action. Default 'update'.
     773             *     @type string $type         Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
     774             *     @type bool   $bulk         Whether the update process is a bulk update. Default true.
     775             *     @type array  $plugins      Array of the basename paths of the plugins' main files.
     776             *     @type array  $themes       The theme slugs.
     777             *     @type array  $translations {
     778             *         Array of translations update data.
     779             *
     780             *         @type string $language The locale the translation is for.
     781             *         @type string $type     Type of translation. Accepts 'plugin', 'theme', or 'core'.
     782             *         @type string $slug     Text domain the translation is for. The slug of a theme/plugin or
     783             *                                'default' for core translations.
     784             *         @type string $version  The version of a theme, plugin, or core.
     785             *     }
    776786             * }
    777787             */
Note: See TracChangeset for help on using the changeset viewer.