当前位置: 首页>>代码示例>>PHP>>正文


PHP Language_Pack_Upgrader类代码示例

本文整理汇总了PHP中Language_Pack_Upgrader的典型用法代码示例。如果您正苦于以下问题:PHP Language_Pack_Upgrader类的具体用法?PHP Language_Pack_Upgrader怎么用?PHP Language_Pack_Upgrader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Language_Pack_Upgrader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: download_woocommerce_translations

 /**
  * Automatically download translations for WC ( when user install WCML ( from 3.3.3) / add new language in WPML )
  *
  * @param  string $lang_code Language code
  *
  */
 function download_woocommerce_translations($lang_code, $wc_version)
 {
     global $sitepress;
     $locale = $sitepress->get_locale($lang_code);
     if ($locale != 'en_US' && $this->has_available_update($locale)) {
         $wc_version = $wc_version ? $wc_version : WC_VERSION;
         include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         require_once ABSPATH . 'wp-admin/includes/file.php';
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
         require_once ABSPATH . 'wp-admin/includes/template.php';
         $url = 'update-core.php?action=do-translation-upgrade';
         $nonce = 'upgrade-translations';
         $title = '';
         $context = WP_LANG_DIR;
         $upgrader = new Language_Pack_Upgrader(new Automatic_Upgrader_Skin(compact('url', 'nonce', 'title', 'context')));
         // use Language_Pack_Upgrader_Skin instead of Automatic_Upgrader_Skin to display upgrade process
         $upgr_object = array();
         $upgr_object[0] = new stdClass();
         $upgr_object[0]->type = 'plugin';
         $upgr_object[0]->slug = 'woocommerce';
         $upgr_object[0]->language = $locale;
         $upgr_object[0]->version = $wc_version;
         $upgr_object[0]->updated = date('Y-m-d H:i:s');
         $upgr_object[0]->package = $this->get_language_pack_uri($locale, $wc_version);
         $upgr_object[0]->autoupdate = 1;
         $upgrader->bulk_upgrade($upgr_object);
         $this->save_translation_version($locale, false, $wc_version);
     }
 }
开发者ID:brfigueiredo,项目名称:htdocs,代码行数:35,代码来源:class-wcml-languages-upgrader.php

示例2: qtranxf_updateGettextDatabasesEx

/**
 * return 'true', if no update needed,
 * or 'false', if update is impossible to do,
 * or 0, if all languages were updated successfully,
 * or positive integer number of errors occurred on languages update.
 */
function qtranxf_updateGettextDatabasesEx($force = false, $only_for_language = '')
{
    global $q_config;
    if ($only_for_language && !qtranxf_isEnabled($only_for_language)) {
        return false;
    }
    if (!is_dir(WP_LANG_DIR)) {
        if (!@mkdir(WP_LANG_DIR)) {
            return false;
        }
    }
    $next_update = get_option('qtranslate_next_update_mo');
    if (time() < $next_update && !$force) {
        return true;
    }
    update_option('qtranslate_next_update_mo', time() + 7 * 24 * 60 * 60);
    require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    require_once ABSPATH . 'wp-admin/includes/file.php';
    include ABSPATH . WPINC . '/version.php';
    // include an unmodified $wp_version
    $result = translations_api('core', array('version' => $wp_version));
    if (is_wp_error($result)) {
        qtranxf_add_error(__('Gettext databases <strong>not</strong> updated:', 'qtranslate') . ' ' . $result->get_error_message());
        return false;
    }
    set_time_limit(300);
    $langs = empty($only_for_language) ? $q_config['enabled_languages'] : array($only_for_language);
    $errcnt = 0;
    foreach ($result['translations'] as $translation) {
        $locale = $translation['language'];
        $lang = null;
        foreach ($langs as $lng) {
            if ($q_config['locale'][$lng] != $locale) {
                continue;
            }
            $lang = $lng;
            break;
        }
        if (!$lang) {
            continue;
        }
        $translation = (object) $translation;
        $skin = new Automatic_Upgrader_Skin();
        $upgrader = new Language_Pack_Upgrader($skin);
        $translation->type = 'core';
        $result = $upgrader->upgrade($translation, array('clear_update_cache' => false));
        if (is_wp_error($result)) {
            qtranxf_add_error(sprintf(__('Failed to update gettext database for "%s": %s', 'qtranslate'), $q_config['language_name'][$lang], $result->get_error_message()));
            ++$errcnt;
        }
    }
    return $errcnt;
}
开发者ID:danmilon,项目名称:donation-box,代码行数:60,代码来源:qtx_update_gettext_db.php

示例3: qtranxf_updateGettextDatabasesEx

function qtranxf_updateGettextDatabasesEx($force = false, $only_for_language = '')
{
    global $q_config;
    if ($only_for_language && !qtranxf_isEnabled($only_for_language)) {
        return false;
    }
    if (!is_dir(WP_LANG_DIR)) {
        if (!@mkdir(WP_LANG_DIR)) {
            return false;
        }
    }
    $next_update = get_option('qtranslate_next_update_mo');
    if (time() < $next_update && !$force) {
        return true;
    }
    update_option('qtranslate_next_update_mo', time() + 7 * 24 * 60 * 60);
    require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    require_once ABSPATH . 'wp-admin/includes/file.php';
    include ABSPATH . WPINC . '/version.php';
    // include an unmodified $wp_version
    $result = translations_api('core', array('version' => $wp_version));
    if (is_wp_error($result)) {
        return $result;
    } else {
        foreach ($result['translations'] as $translation) {
            $locale = substr($translation['language'], 0, 2);
            if (isset($q_config['locale'][$locale]) && $q_config['locale'][$locale] == $translation['language'] && qtranxf_isEnabled($locale)) {
                $translation = (object) $translation;
                $skin = new Automatic_Upgrader_Skin();
                $upgrader = new Language_Pack_Upgrader($skin);
                $translation->type = 'core';
                $result = $upgrader->upgrade($translation, array('clear_update_cache' => false));
            }
        }
        return true;
    }
}
开发者ID:ycms,项目名称:qtranslate-x,代码行数:38,代码来源:qtx_update_gettext_db.php

示例4: qtranxf_updateGettextDatabasesEx

/**
 * return 'true', if no update needed,
 * or 'false', if update is impossible to do,
 * or 0, if all languages were updated successfully,
 * or positive integer number of errors occurred on languages update.
 */
function qtranxf_updateGettextDatabasesEx($force = false, $only_for_language = '')
{
    if (empty($only_for_language)) {
        if (!$force) {
            $next_update = get_option('qtranslate_next_update_mo');
            if (time() < $next_update) {
                return true;
            }
        }
        update_option('qtranslate_next_update_mo', time() + 7 * 24 * 60 * 60);
    }
    if (!is_dir(WP_LANG_DIR)) {
        if (!@mkdir(WP_LANG_DIR)) {
            return false;
        }
    }
    require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    require_once ABSPATH . 'wp-admin/includes/file.php';
    //include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
    //$result = translations_api( 'core', array( 'version' => $wp_version ));
    //if ( is_wp_error( $result ) ){
    //	qtranxf_add_warning(__('Gettext databases <strong>not</strong> updated:', 'qtranslate') . ' ' . $result->get_error_message());
    //	return false;
    //}
    //$translations = $result['translations'];
    $translations = wp_get_available_translations();
    if (empty($translations)) {
        qtranxf_add_warning(__('Gettext databases <strong>not</strong> updated:', 'qtranslate') . ' ' . __('Failed to fetch the list of available translations.', 'qtranslate'));
        return false;
    }
    set_time_limit(300);
    if (empty($only_for_language)) {
        global $q_config;
        $langs = $q_config['enabled_languages'];
        $locales = $q_config['locale'];
    } else {
        $langs = array($only_for_language);
        $locales = qtranxf_language_configured('locale');
    }
    $errcnt = 0;
    /*
    	//qtranxf_dbg_log('qtranxf_updateGettextDatabasesEx: count($translations): ',count($translations));
    	//qtranxf_dbg_log('qtranxf_updateGettextDatabasesEx: $translations: ',$translations);
    	foreach ( $translations as $loc => $translation ) {
    		$locale = $translation['language'];
    		$lang = null;
    		foreach($langs as $lng) {
    			if(!isset($locales[$lng])){
    				$locales = qtranxf_language_configured('locale');
    				if(!isset($locales[$lng])) continue;
    			}
    			if($locales[$lng] != $locale) continue;
    			$lang = $lng;
    			break;
    		}
    		if(!$lang) continue;
    */
    foreach ($langs as $lang) {
        $loc = $locales[$lang];
        if (!isset($translations[$loc])) {
            continue;
        }
        $mo = WP_LANG_DIR . '/' . $loc . '.mo';
        $mo_ok = file_exists($mo);
        //qtranxf_dbg_log('qtranxf_updateGettextDatabasesEx: $mo_ok for '.$mo.': ',$mo_ok);
        if ($mo_ok) {
            continue;
        }
        //WP now takes care of translations updates on its own
        $translation = (object) $translations[$loc];
        $skin = new Automatic_Upgrader_Skin();
        $upgrader = new Language_Pack_Upgrader($skin);
        $translation->type = 'core';
        $result = $upgrader->upgrade($translation, array('clear_update_cache' => false));
        if (is_wp_error($result)) {
            qtranxf_add_warning(sprintf(__('Failed to update gettext database for "%s": %s', 'qtranslate'), $lang, $result->get_error_message()));
            ++$errcnt;
        }
    }
    return $errcnt;
}
开发者ID:dmitriyvi,项目名称:qtranslate-x,代码行数:88,代码来源:qtx_update_gettext_db.php

示例5: update_language_packs

 /**
  * Update language packs for plugins & themes
  *
  * @return array|bool
  */
 private function update_language_packs()
 {
     if ('en_US' === get_locale()) {
         return false;
     }
     if (!function_exists('wp_clean_update_cache')) {
         require_once ABSPATH . 'wp-includes/update.php';
     }
     if (!class_exists('\\Language_Pack_Upgrader')) {
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     }
     if (!class_exists('\\Automatic_Upgrader_Skin')) {
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader-skins.php';
     }
     wp_clean_update_cache();
     wp_update_themes();
     wp_update_plugins();
     $upgrader = new \Language_Pack_Upgrader(new \Automatic_Upgrader_Skin());
     return $upgrader->bulk_upgrade();
 }
开发者ID:ChrisSargent,项目名称:moodesignz,代码行数:25,代码来源:class-done.php

示例6: wp_oracle_get_translation_upgrade

 public function wp_oracle_get_translation_upgrade()
 {
     include_once ABSPATH . 'wp-admin/includes/admin.php';
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-wordpress-oracle-language-upgrader-skin.php';
     $skin = new Wordpress_Oracle_Language_Pack_Upgrader_Skin();
     $upgrader = new Language_Pack_Upgrader($skin);
     // Do the upgrade
     ob_start();
     $result = $upgrader->bulk_upgrade();
     $data = ob_get_contents();
     ob_clean();
     if (is_wp_error($result)) {
         return $result;
     }
     return array('status' => 'success');
 }
开发者ID:raqqun,项目名称:wordpress-oracle,代码行数:17,代码来源:class-wordpress-oracle-api-controllers.php

示例7: wp_can_install_language_pack

/**
 * Check if WordPress has access to the filesystem without asking for
 * credentials.
 *
 * @since 4.0.0
 *
 * @return bool Returns true on success, false on failure.
 */
function wp_can_install_language_pack()
{
    if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
        return false;
    }
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $skin = new Automatic_Upgrader_Skin();
    $upgrader = new Language_Pack_Upgrader($skin);
    $upgrader->init();
    $check = $upgrader->fs_connect(array(WP_CONTENT_DIR, WP_LANG_DIR));
    if (!$check || is_wp_error($check)) {
        return false;
    }
    return true;
}
开发者ID:johnpbloch,项目名称:wordpress,代码行数:23,代码来源:translation-install.php

示例8: elseif

    ?>
" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>
	</div>
	<?php 
    include ABSPATH . 'wp-admin/admin-footer.php';
} elseif ('do-translation-upgrade' == $action) {
    if (!current_user_can('update_core') && !current_user_can('update_plugins') && !current_user_can('update_themes')) {
        wp_die(__('You do not have sufficient permissions to update this site.'));
    }
    check_admin_referer('upgrade-translations');
    require_once ABSPATH . 'wp-admin/admin-header.php';
    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $url = 'update-core.php?action=do-translation-upgrade';
    $nonce = 'upgrade-translations';
    $title = __('Update Translations');
    $context = WP_LANG_DIR;
    $upgrader = new Language_Pack_Upgrader(new Language_Pack_Upgrader_Skin(compact('url', 'nonce', 'title', 'context')));
    $result = $upgrader->bulk_upgrade();
    require_once ABSPATH . 'wp-admin/admin-footer.php';
} else {
    /**
     * Fires for each custom update action on the WordPress Updates screen.
     *
     * The dynamic portion of the hook name, `$action`, refers to the
     * passed update action. The hook fires in lieu of all available
     * default update actions.
     *
     * @since 3.2.0
     */
    do_action("update-core-custom_{$action}");
}
开发者ID:leonardopires,项目名称:projectnami,代码行数:31,代码来源:update-core.php

示例9: async_upgrade

 /**
  * Asynchronously upgrades language packs after other upgrades have been made.
  *
  * Hooked to the {@see 'upgrader_process_complete'} action by default.
  *
  * @since 3.7.0
  * @access public
  * @static
  *
  * @param false|WP_Upgrader $upgrader 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.
  */
 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 installs, 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->bulk_upgrade($language_updates);
 }
开发者ID:BoldGrid,项目名称:WordPress,代码行数:59,代码来源:class-language-pack-upgrader.php

示例10: wp_can_install_language_pack

/**
 * Check if WordPress has access to the filesystem without asking for
 * credentials.
 *
 * @since 4.0.0
 *
 * @return bool Returns true on success, false on failure.
 */
function wp_can_install_language_pack()
{
    if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
        return false;
    }
    $skin = new Automatic_Upgrader_Skin();
    $upgrader = new Language_Pack_Upgrader($skin);
    $upgrader->init();
    $check = $upgrader->fs_connect(array(WP_CONTENT_DIR, WP_LANG_DIR));
    if (!$check || is_wp_error($check)) {
        return false;
    }
    return true;
}
开发者ID:inpsyde,项目名称:wordpress-dev,代码行数:22,代码来源:translation-install.php

示例11: su_update_all

/**
 * Install all available updates.
 *
 * Updates themes, plugins, core and translations.
 */
function su_update_all()
{
    if (!current_user_can('update_core') && !current_user_can('update_plugins') && !current_user_can('update_themes')) {
        wp_die(__('You do not have sufficient permissions to update this site.'));
    }
    check_admin_referer('upgrade-core');
    require_once ABSPATH . 'wp-admin/admin-header.php';
    // Update themes.
    $themes = array_keys(get_theme_updates());
    if (!empty($themes)) {
        $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
        $url = wp_nonce_url($url, 'bulk-update-themes');
        ?>
		<div class="wrap">
			<h1><?php 
        _e('Update Themes');
        ?>
</h1>
			<iframe src="<?php 
        echo $url;
        ?>
" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php 
        esc_attr_e('Update progress');
        ?>
"></iframe>
		</div>
		<?php 
    }
    // Update plugins.
    $plugins = array_keys(get_plugin_updates());
    if (!empty($plugins)) {
        $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
        $url = wp_nonce_url($url, 'bulk-update-plugins');
        ?>
		<div class="wrap">
			<h1><?php 
        _e('Update Plugins');
        ?>
</h1>
			<iframe src="<?php 
        echo $url;
        ?>
" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0" title="<?php 
        esc_attr_e('Update progress');
        ?>
"></iframe>
		</div>
		<?php 
    }
    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    // Update translations.
    $url = 'update-core.php?action=do-translation-upgrade';
    $nonce = 'upgrade-translations';
    $title = __('Update Translations');
    $context = WP_LANG_DIR;
    $upgrader = new Language_Pack_Upgrader(new Language_Pack_Upgrader_Skin(compact('url', 'nonce', 'title', 'context')));
    $upgrader->bulk_upgrade();
    // Update core.
    do_core_upgrade();
    include ABSPATH . 'wp-admin/admin-footer.php';
}
开发者ID:ethitter,项目名称:shiny-updates,代码行数:66,代码来源:update.php

示例12: update_translations

 function update_translations()
 {
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     // Clear the cache.
     wp_update_themes();
     $available_themes_updates = get_site_transient('update_themes');
     if (!isset($available_themes_updates->translations) || empty($available_themes_updates->translations)) {
         return new WP_Error('nothing_to_translate');
     }
     foreach ($available_themes_updates->translations as $translation) {
         $theme = $translation['slug'];
         if (!in_array($translation['slug'], $this->themes)) {
             $this->log[$theme][] = __('No update needed', 'jetpack');
             continue;
         }
         /**
          * Pre-upgrade action
          *
          * @since 4.4
          *
          * @param object $theme WP_Theme object
          * @param array $themes Array of theme objects
          */
         do_action('jetpack_pre_theme_upgrade_translations', $theme, $this->themes);
         // Objects created inside the for loop to clean the messages for each theme
         $skin = new Automatic_Upgrader_Skin();
         $upgrader = new Language_Pack_Upgrader($skin);
         $upgrader->init();
         $result = $upgrader->upgrade((object) $translation);
         $this->log[$theme] = $upgrader->skin->get_upgrade_messages();
     }
     if (!$this->bulk && !$result) {
         return new WP_Error('update_fail', __('There was an error updating your theme', 'jetpack'), 400);
     }
     return true;
 }
开发者ID:automattic,项目名称:jetpack,代码行数:36,代码来源:class.jetpack-json-api-themes-modify-endpoint.php

示例13: wp_ajax_update_translations

/**
 * AJAX handler for updating translations.
 *
 * @since 4.6.0
 *
 * @see Language_Pack_Upgrader
 */
function wp_ajax_update_translations()
{
    check_ajax_referer('updates');
    if (!current_user_can('update_core') && !current_user_can('update_plugins') && !current_user_can('update_themes')) {
        $status['error'] = __('You do not have sufficient permissions to update this site.');
        wp_send_json_error($status);
    }
    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $url = 'update-core.php?action=do-translation-upgrade';
    $nonce = 'upgrade-translations';
    $title = __('Update Translations');
    $context = WP_CONTENT_DIR;
    $skin = new Automatic_Upgrader_Skin(compact('url', 'nonce', 'title', 'context'));
    $upgrader = new Language_Pack_Upgrader($skin);
    $result = $upgrader->bulk_upgrade();
    $status = array('update' => 'translation');
    if (is_array($result) && is_wp_error($skin->result)) {
        $result = $skin->result;
    }
    if (is_array($result) && !empty($result[0])) {
        wp_send_json_success($status);
    } else {
        if (is_wp_error($result)) {
            $status['error'] = $result->get_error_message();
            wp_send_json_error($status);
        } else {
            if (false === $result) {
                global $wp_filesystem;
                $status['errorCode'] = 'unable_to_connect_to_filesystem';
                $status['error'] = __('Unable to connect to the filesystem. Please confirm your credentials.');
                // Pass through the error from WP_Filesystem if one was raised.
                if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
                    $status['error'] = $wp_filesystem->errors->get_error_message();
                }
                wp_send_json_error($status);
            }
        }
    }
    // An unhandled error occurred.
    $status['error'] = __('Translations update failed.');
    wp_send_json_error($status);
}
开发者ID:ethitter,项目名称:shiny-updates,代码行数:49,代码来源:ajax-actions.php

示例14: upgrade_translations

 /**
  * Upgrades WordPress locally
  *
  */
 function upgrade_translations($current)
 {
     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     $upgrader = new Language_Pack_Upgrader(new Language_Pack_Upgrader_Skin(compact('url', 'nonce', 'title', 'context')));
     $result = $upgrader->bulk_upgrade();
     $upgradeFailed = false;
     if (!empty($result)) {
         foreach ($result as $translate_tmp => $translate_info) {
             if (is_wp_error($translate_info) || empty($translate_info)) {
                 $upgradeFailed = true;
                 $return = array('error' => $this->iwp_mmb_get_error($translate_info), 'error_code' => 'upgrade_translations_wp_error');
                 break;
             }
         }
         if (!$upgradeFailed) {
             $return = 'updated';
         }
         return array('upgraded' => $return);
     } else {
         return array('error' => 'Upgrade failed.', 'error_code' => 'unable_to_update_translations_files');
     }
 }
开发者ID:Trideon,项目名称:gigolo,代码行数:26,代码来源:installer.class.php

示例15: download_language_pack

 /**
  * Download a language pack.
  *
  * @see wp_download_language_pack()
  *
  * @param string $download Language code to download.
  * @return string|WP_Error Returns the language code if successfully downloaded, or a WP_Error object on failure.
  */
 private function download_language_pack($download)
 {
     $translations = $this->get_all_languages();
     foreach ($translations as $translation) {
         if ($translation['language'] === $download) {
             $translation_to_load = true;
             break;
         }
     }
     if (empty($translation_to_load)) {
         return new \WP_Error('not_found', "Language '{$download}' not found.");
     }
     $translation = (object) $translation;
     require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     $skin = new \Automatic_Upgrader_Skin();
     $upgrader = new \Language_Pack_Upgrader($skin);
     $translation->type = 'core';
     $result = $upgrader->upgrade($translation, array('clear_update_cache' => false));
     if (is_wp_error($result)) {
         return $result;
     } else {
         if (!$result) {
             return new \WP_Error('not_installed', "Could not install language '{$download}'.");
         }
     }
     return $translation->language;
 }
开发者ID:staylor,项目名称:wp-cli,代码行数:35,代码来源:CommandWithTranslation.php


注:本文中的Language_Pack_Upgrader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。