Make WordPress Core

Changeset 29694


Ignore:
Timestamp:
09/03/2014 10:37:21 AM (11 years ago)
Author:
ocean90
Message:

Language Pack Upgrader: Allow to disable asynchronously translation updates.

  • Don't touch VCS installs.
  • Use the async_update_translation filter (which corresponds exactly to auto_update_translation) to entirely disable it, or based on the update offer.

props nacin, ocean90.
fixes #28571.

File:
1 edited

Legend:

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

    r29685 r29694  
    11971197    public static function async_upgrade( $upgrader = false ) {
    11981198        // Avoid recursion.
    1199         if ( $upgrader && $upgrader instanceof Language_Pack_Upgrader )
     1199        if ( $upgrader && $upgrader instanceof Language_Pack_Upgrader ) {
    12001200            return;
     1201        }
    12011202
    12021203        // Nothing to do?
    12031204        $language_updates = wp_get_translation_updates();
    1204         if ( ! $language_updates )
     1205        if ( ! $language_updates ) {
    12051206            return;
     1207        }
     1208
     1209        // Avoid messing with VCS installs, at least for now.
     1210        // Noted: this is not the ideal way to accomplish this.
     1211        $check_vcs = new WP_Automatic_Updater;
     1212        if ( $check_vcs->is_vcs_checkout( WP_CONTENT_DIR ) ) {
     1213            return;
     1214        }
     1215
     1216        foreach ( $language_updates as $key => $language_update ) {
     1217            $update = ! empty( $language_update->autoupdate );
     1218
     1219            /**
     1220             * Filter whether to asynchronously update translation for core, a plugin, or a theme.
     1221             *
     1222             * @since 4.0.0
     1223             *
     1224             * @param bool   $update          Whether to update.
     1225             * @param object $language_update The update offer.
     1226             */
     1227            $update = apply_filters( 'async_update_translation', $update, $language_update );
     1228
     1229            if ( ! $update ) {
     1230                unset( $language_updates[ $key ] );
     1231            }
     1232        }
     1233
     1234        if ( empty( $language_updates ) ) {
     1235            return;
     1236        }
    12061237
    12071238        $skin = new Language_Pack_Upgrader_Skin( array(
     
    12101241
    12111242        $lp_upgrader = new Language_Pack_Upgrader( $skin );
    1212         $lp_upgrader->upgrade();
     1243        $lp_upgrader->bulk_upgrade( $language_updates );
    12131244    }
    12141245
Note: See TracChangeset for help on using the changeset viewer.