Language_Pack_Upgrader::async_upgrade() – Asynchronously upgrades language packs after other upgrades have been made.

You appear to be a bot. Output may be restricted

Description

Asynchronously upgrades language packs after other upgrades have been made.

Hooked to the upgrader_process_completeupgrader_process_complete action by default.

Usage

Language_Pack_Upgrader::async_upgrade( $upgrader );

Parameters

$upgrader
( false|WP_Upgrader ) optional – Optional. WP_Upgrader instance or false. If $upgrader is a Language_Pack_Upgrader instance, the method will bail to avoid recursion. Otherwise unused. Default false.

Returns

void

Source

File name: wordpress/wp-admin/includes/class-language-pack-upgrader.php
Lines:

1 to 57 of 57
  public static function async_upgrade( $upgrader = false ) {
    // Avoid recursion.
    if ( $upgrader && $upgrader instanceof Language_Pack_Upgrader ) {
      return;
    }

    // Nothing to do?
    $language_updates = wp_get_translation_updates();
    if ( ! $language_updates ) {
      return;
    }

    /*
		 * Avoid messing with VCS installations, at least for now.
		 * Noted: this is not the ideal way to accomplish this.
		 */
    $check_vcs = new WP_Automatic_Updater;
    if ( $check_vcs->is_vcs_checkout( WP_CONTENT_DIR ) ) {
      return;
    }

    foreach ( $language_updates as $key => $language_update ) {
      $update = ! empty( $language_update->autoupdate );

      
/**
 * Filters whether to asynchronously update translation for core, a plugin, or a theme.
 *
 * @since 4.0.0
 *
 * @param bool   $update          Whether to update.
 * @param object $language_update The update offer.
 */
      $update = apply_filters( 'async_update_translation', $update, $language_update );

      if ( ! $update ) {
        unset( $language_updates[ $key ] );
      }
    }

    if ( empty( $language_updates ) ) {
      return;
    }

    // Re-use the automatic upgrader skin if the parent upgrader is using it.
    if ( $upgrader && $upgrader->skin instanceof Automatic_Upgrader_Skin ) {
      $skin = $upgrader->skin;
    } else {
      $skin = new Language_Pack_Upgrader_Skin(
        array(
          'skip_header_footer' => true,
        )
      );
    }

    $lp_upgrader = new Language_Pack_Upgrader( $skin );
    $lp_upgrader->Language_Pack_Upgrader::bulk_upgrade( $language_updates );
  }
 

 View on GitHub View on Trac