Make WordPress Core

Ticket #28571: 28571.2.patch

File 28571.2.patch, 2.1 KB (added by ocean90, 12 years ago)
  • src/wp-admin/includes/class-wp-upgrader.php

     
    11961196
    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
     1203                $disabled = false; // Maybe a constant for translators?
     1204
     1205                /**
     1206                 * Filter whether to entirely disable asynchronous translation updates.
     1207                 *
     1208                 * There are more fine-grained filters and controls for selective disabling.
     1209                 *
     1210                 * @since 4.0.0
     1211                 *
     1212                 * @param bool $disabled Whether the async updater should be disabled.
     1213                 */
     1214                if ( apply_filters( 'async_update_translation_disabled', $disabled ) ) {
     1215                        return;
     1216                }
     1217
    12021218                // Nothing to do?
    12031219                $language_updates = wp_get_translation_updates();
    1204                 if ( ! $language_updates )
     1220                if ( ! $language_updates ) {
    12051221                        return;
     1222                }
    12061223
     1224                foreach ( $language_updates as $key => $language_update ) {
     1225                        $type = $language_update->type;
     1226                        $update = ! empty( $language_update->autoupdate );
     1227
     1228                        /**
     1229                         * Filter whether to asynchronously update translation for core, a plugin, or a theme.
     1230                         *
     1231                         * The dynamic portion of the hook name, $type, refers to the type of update
     1232                         * being checked. Can be 'core', 'theme', or 'plugin'.
     1233                         *
     1234                         * @since 4.0.0
     1235                         *
     1236                         * @param bool   $update          Whether to update.
     1237                         * @param object $language_update The update offer.
     1238                         */
     1239                        $update = apply_filters( 'async_update_translation_for_' . $type, $update, $language_update );
     1240
     1241                        if ( ! $update ) {
     1242                                unset( $language_updates[ $key ] );
     1243                        }
     1244                }
     1245
     1246                if ( empty( $language_updates ) ) {
     1247                        return;
     1248                }
     1249
    12071250                $skin = new Language_Pack_Upgrader_Skin( array(
    12081251                        'skip_header_footer' => true,
    12091252                ) );
    12101253
    12111254                $lp_upgrader = new Language_Pack_Upgrader( $skin );
    1212                 $lp_upgrader->upgrade();
     1255                $lp_upgrader->bulk_upgrade( $language_updates );
    12131256        }
    12141257
    12151258        public function upgrade_strings() {