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


PHP Language_Pack_Upgrader::bulk_upgrade方法代码示例

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


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

示例1: array

 /**
  * 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: async_upgrade

 /**
  * Asynchronously upgrade language packs after other upgrades have been made.
  *
  * Hooked to the {@see 'upgrader_process_complete'} action by default.
  *
  * @since 3.7.0
  */
 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);
         /**
          * Filter 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;
     }
     $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:sunyang3721,项目名称:wp-for-sae,代码行数:46,代码来源:class-wp-upgrader.php

示例3: foreach

 static function download_language_packs()
 {
     $languages = pll_languages_list(array('fields' => 'locale'));
     // prevents upgrade if the .po file is already here. Let WP manage the upgrades :)
     foreach ($languages as $key => $locale) {
         if (file_exists(WP_LANG_DIR . "/{$locale}.po")) {
             unset($languages[$key]);
         }
     }
     if (empty($languages)) {
         return;
     }
     require_once ABSPATH . 'wp-admin/includes/translation-install.php';
     $translations = wp_get_available_translations();
     if (!$translations) {
         return;
     }
     foreach ($translations as $translation) {
         if (in_array($translation['language'], $languages)) {
             $translation['type'] = 'core';
             $translations_to_load[] = (object) $translation;
         }
     }
     if (!empty($translations_to_load)) {
         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
         $upgrader = new Language_Pack_Upgrader(new Automatic_Upgrader_Skin());
         $upgrader->bulk_upgrade($translations_to_load, array('clear_update_cache' => false));
     }
 }
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:29,代码来源:upgrade.php

示例4: 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

示例5: foreach

 /**
  * 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

示例6: 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

示例7: foreach

 /**
  * Upgrades WordPress locally
  *
  */
 function upgrade_translations($current, $userid)
 {
     global $iwp_activities_log_post_type, $iwp_mmb_activities_log;
     $GLOBALS['iwp_client_plugin_translations'] = 1;
     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) {
             $details = array();
             $iwp_mmb_activities_log->iwp_mmb_save_iwp_activities('translations', 'update', $iwp_activities_log_post_type, (object) $details, $userid);
             $return = 'updated';
         }
         return array('upgraded' => $return);
     } else {
         return array('error' => 'Upgrade failed.', 'error_code' => 'unable_to_update_translations_files');
     }
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:30,代码来源:installer.class.php

示例8: 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

示例9: 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

示例10: 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


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