• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP unload_textdomain函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: wpcf7_load_textdomain

function wpcf7_load_textdomain($locale = null)
{
    global $l10n;
    $domain = 'contact-form-7';
    if (get_locale() == $locale) {
        $locale = null;
    }
    if (empty($locale)) {
        if (is_textdomain_loaded($domain)) {
            return true;
        } else {
            return load_plugin_textdomain($domain, false, $domain . '/languages');
        }
    } else {
        $mo_orig = $l10n[$domain];
        unload_textdomain($domain);
        $mofile = $domain . '-' . $locale . '.mo';
        $path = WP_PLUGIN_DIR . '/' . $domain . '/languages';
        if ($loaded = load_textdomain($domain, $path . '/' . $mofile)) {
            return $loaded;
        } else {
            $mofile = WP_LANG_DIR . '/plugins/' . $mofile;
            return load_textdomain($domain, $mofile);
        }
        $l10n[$domain] = $mo_orig;
    }
    return false;
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:28,代码来源:l10n.php


示例2: test_is_textdomain_loaded_for_no_translations

 /**
  * @ticket 21319
  */
 function test_is_textdomain_loaded_for_no_translations()
 {
     $this->assertFalse(load_textdomain('wp-tests-domain', DIR_TESTDATA . '/non-existent-file'));
     $this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
     $this->assertInstanceOf('NOOP_Translations', get_translations_for_domain('wp-tests-domain'));
     // Ensure that we don't confuse NOOP_Translations to be a loaded text domain.
     $this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
     $this->assertFalse(unload_textdomain('wp-tests-domain'));
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:12,代码来源:l10n.php


示例3: test_load_unload_textdomain

 function test_load_unload_textdomain()
 {
     $this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
     $this->assertFalse(unload_textdomain('wp-tests-domain'));
     $file = DIR_TESTDATA . '/pomo/simple.mo';
     $this->assertTrue(load_textdomain('wp-tests-domain', $file));
     $this->assertTrue(is_textdomain_loaded('wp-tests-domain'));
     $this->assertTrue(unload_textdomain('wp-tests-domain'));
     $this->assertFalse(is_textdomain_loaded('wp-tests-domain'));
 }
开发者ID:nkeat12,项目名称:dv,代码行数:10,代码来源:l10n.php


示例4: test_theme_translation_should_be_translated_without_calling_load_theme_textdomain

 /**
  * @ticket 34114
  */
 public function test_theme_translation_should_be_translated_without_calling_load_theme_textdomain()
 {
     add_filter('locale', array($this, 'filter_set_locale_to_german'));
     switch_theme('internationalized-theme');
     include_once get_stylesheet_directory() . '/functions.php';
     $is_textdomain_loaded_before = is_textdomain_loaded('internationalized-theme');
     $expected_output = i18n_theme_test();
     $is_textdomain_loaded_after = is_textdomain_loaded('internationalized-theme');
     unload_textdomain('internationalized-theme');
     remove_filter('locale', array($this, 'filter_set_locale_to_german'));
     $this->assertFalse($is_textdomain_loaded_before);
     $this->assertSame('Das ist ein Dummy Theme', $expected_output);
     $this->assertTrue($is_textdomain_loaded_after);
 }
开发者ID:ntwb,项目名称:wordpress-travis,代码行数:17,代码来源:loadTextdomainJustInTime.php


示例5: set_language

 public function set_language($lang)
 {
     global $sitepress, $woocommerce;
     $sitepress->switch_lang($lang, true);
     $this->locale = $sitepress->get_locale($lang);
     add_filter('plugin_locale', array($this, 'set_locale'), 10, 2);
     unload_textdomain('woocommerce');
     unload_textdomain('woocommerce-germanized');
     unload_textdomain('woocommerce-germanized-pro');
     unload_textdomain('default');
     $woocommerce->load_plugin_textdomain();
     WC_germanized()->load_plugin_textdomain();
     do_action('woocommerce_gzd_wpml_lang_changed', $lang);
     load_default_textdomain();
     global $wp_locale;
     $wp_locale = new WP_Locale();
 }
开发者ID:ronzeiller,项目名称:woocommerce-germanized,代码行数:17,代码来源:class-wc-gzd-wpml-helper.php


示例6: load_textdomain

 /**
  * Bootstrap localisation of self
  */
 public static function load_textdomain($locale = null)
 {
     if (is_null($locale)) {
         $locale = get_locale();
     }
     if (!$locale || 0 === strpos($locale, 'en')) {
         self::$locale and unload_textdomain(Loco::NS);
         $locale = 'en_US';
     } else {
         if (self::$locale !== $locale) {
             $plugin_rel_path = basename(self::basedir());
             load_plugin_textdomain(Loco::NS, false, $plugin_rel_path . '/languages');
         }
     }
     // detect changes in plugin locale, binding once only
     isset(self::$locale) or add_filter('plugin_locale', array(__CLASS__, 'filter_plugin_locale'), 10, 2);
     self::$locale = $locale;
 }
开发者ID:josejoaosantos,项目名称:wp-loco,代码行数:21,代码来源:loco-boot.php


示例7: test_switches_to_es

 function test_switches_to_es()
 {
     // We need to something in order to set the Global $l10n
     $file = DIR_TESTDATA . '/pomo/simple.mo';
     load_textdomain('wp-tests-domain', $file);
     $this->assertEquals('es_ES', switch_to_locale('es_ES'));
     $this->assertEquals('es_ES', get_locale());
     $this->assertEquals('en_GB', switch_to_locale('en_GB'));
     $this->assertEquals('en_GB', get_locale());
     // return early if you try to switch to the same locale
     $this->assertEquals('en_GB', switch_to_locale('en_GB'));
     $this->assertEquals('en_GB', get_locale());
     $this->assertEquals('es_ES', restore_locale());
     $this->assertEquals('es_ES', get_locale());
     $this->assertEquals('en_US', restore_locale(true));
     $this->assertEquals('en_US', get_locale());
     $this->assertEquals('xx_XX', switch_to_locale('xx_XX'));
     $this->assertEquals('xx_XX', get_locale());
     // tidy up
     unload_textdomain('wp-tests-domain');
     global $l10n;
     $l10n = null;
 }
开发者ID:pbearne,项目名称:contrib2core,代码行数:23,代码来源:class-wp-switch-locale.php


示例8: k12nn_locale_func

function k12nn_locale_func($atts, $content = null)
{
    $a = shortcode_atts(array('locale' => 'en_US'), $atts);
    global $k12nn_locale;
    global $k12nn_previous_locale;
    $k12nn_previous_locale = get_locale();
    $k12nn_locale = $a['locale'];
    add_filter('locale', 'k12nn_redefine_locale');
    setlocale(LC_ALL, $k12nn_locale);
    if (function_exists('dk_speakout_translate')) {
        unload_textdomain('dk_speakout');
        dk_speakout_translate();
    }
    $return = do_shortcode($content);
    $k12nn_locale = $k12nn_previous_locale;
    remove_filter('locale', 'k12nn_redefine_locale');
    setlocale(LC_ALL, $k12nn_locale);
    if (function_exists('dk_speakout_translate')) {
        unload_textdomain('dk_speakout');
        dk_speakout_translate();
    }
    return $return;
}
开发者ID:k12newsnetwork,项目名称:k12nn-locale,代码行数:23,代码来源:k12nn-locale.php


示例9: trim

         $value = null;
         if (isset($_POST[$option])) {
             $value = $_POST[$option];
             if (!is_array($value)) {
                 $value = trim($value);
             }
             $value = wp_unslash($value);
         }
         update_option($option, $value);
     }
     // Switch translation in case WPLANG was changed.
     $language = get_option('WPLANG');
     if ($language) {
         load_default_textdomain($language);
     } else {
         unload_textdomain('default');
     }
 }
 /**
  * Handle settings errors and return to options page
  */
 // If no settings errors were registered add a general 'updated' message.
 if (!count(get_settings_errors())) {
     add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
 }
 set_transient('settings_errors', get_settings_errors(), 30);
 /**
  * Redirect back to the settings page that was submitted
  */
 $goback = add_query_arg('settings-updated', 'true', wp_get_referer());
 wp_redirect($goback);
开发者ID:hadywisam,项目名称:WordPress,代码行数:31,代码来源:options.php


示例10: create_missing_store_pages

 /**
  * create missing pages
  */
 function create_missing_store_pages()
 {
     global $sitepress, $wp_rewrite, $woocommerce_wpml, $woocommerce;
     $miss_lang = $this->get_missing_store_pages();
     //dummy array for names
     $names = array(__('Cart', 'woocommerce-multilingual'), __('Checkout', 'woocommerce-multilingual'), __('Checkout → Pay', 'woocommerce-multilingual'), __('Order Received', 'woocommerce-multilingual'), __('My Account', 'woocommerce-multilingual'), __('Change Password', 'woocommerce-multilingual'), __('Edit My Address', 'woocommerce-multilingual'), __('Logout', 'woocommerce-multilingual'), __('Lost Password', 'woocommerce-multilingual'), __('View Order', 'woocommerce-multilingual'), __('Shop', 'woocommerce-multilingual'));
     if (isset($miss_lang['codes'])) {
         $wp_rewrite = new WP_Rewrite();
         $check_pages = $this->get_wc_pages();
         $default_language = $sitepress->get_default_language();
         if (in_array($default_language, $miss_lang['codes'])) {
             $miss_lang['codes'] = array_merge(array($default_language), array_diff($miss_lang['codes'], array($default_language)));
         }
         foreach ($miss_lang['codes'] as $mis_lang) {
             $args = array();
             unload_textdomain('woocommerce-multilingual');
             $sitepress->switch_lang($mis_lang);
             load_textdomain('woocommerce-multilingual', WCML_LOCALE_PATH . '/woocommerce-multilingual-' . $sitepress->get_locale($mis_lang) . '.mo');
             foreach ($check_pages as $page) {
                 $orig_id = get_option($page);
                 $trid = $sitepress->get_element_trid($orig_id, 'post_page');
                 $translations = $sitepress->get_element_translations($trid, 'post_page', true);
                 if (!isset($translations[$mis_lang]) || !is_null($translations[$mis_lang]->element_id) && get_post_status($translations[$mis_lang]->element_id) != 'publish') {
                     $orig_page = get_post($orig_id);
                     switch ($page) {
                         case 'woocommerce_shop_page_id':
                             $page_title = __('Shop', 'woocommerce-multilingual');
                             break;
                         case 'woocommerce_cart_page_id':
                             $page_title = __('Cart', 'woocommerce-multilingual');
                             break;
                         case 'woocommerce_checkout_page_id':
                             $page_title = __('Checkout', 'woocommerce-multilingual');
                             break;
                         case 'woocommerce_myaccount_page_id':
                             $page_title = __('My Account', 'woocommerce-multilingual');
                             break;
                         default:
                             $page_title = __($orig_page->post_title, 'woocommerce-multilingual');
                             break;
                     }
                     $args['post_title'] = $page_title;
                     $args['post_type'] = $orig_page->post_type;
                     $args['post_content'] = $orig_page->post_content;
                     $args['post_excerpt'] = $orig_page->post_excerpt;
                     $args['post_status'] = isset($translations[$mis_lang]->element_id) && get_post_status($translations[$mis_lang]->element_id) != 'publish' ? 'publish' : $orig_page->post_status;
                     $args['menu_order'] = $orig_page->menu_order;
                     $args['ping_status'] = $orig_page->ping_status;
                     $args['comment_status'] = $orig_page->comment_status;
                     $post_parent = apply_filters('translate_object_id', $orig_page->post_parent, 'page', false, $mis_lang);
                     $args['post_parent'] = is_null($post_parent) ? 0 : $post_parent;
                     $new_page_id = wp_insert_post($args);
                     if (isset($translations[$mis_lang]->element_id) && get_post_status($translations[$mis_lang]->element_id) == 'trash' && $mis_lang == $default_language) {
                         update_option($page, $new_page_id);
                     }
                     if (isset($translations[$mis_lang]->element_id) && !is_null($translations[$mis_lang]->element_id)) {
                         $sitepress->set_element_language_details($translations[$mis_lang]->element_id, 'post_page', false, $mis_lang);
                     }
                     $trid = $sitepress->get_element_trid($orig_id, 'post_page');
                     $sitepress->set_element_language_details($new_page_id, 'post_page', $trid, $mis_lang);
                 }
             }
             unload_textdomain('woocommerce-multilingual');
             $sitepress->switch_lang($default_language);
             load_textdomain('woocommerce-multilingual', WCML_LOCALE_PATH . '/woocommerce-multilingual-' . $sitepress->get_locale($default_language) . '.mo');
         }
         wp_redirect(admin_url('admin.php?page=wpml-wcml'));
         exit;
     }
 }
开发者ID:helgatheviking,项目名称:woocommerce-multilingual,代码行数:73,代码来源:store-pages.class.php


示例11: wp_timezone_choice

/**
 * Gives a nicely-formatted list of timezone strings.
 *
 * @since 2.9.0
 * @since 4.7.0 Added the `$locale` parameter.
 *
 * @staticvar bool $mo_loaded
 * @staticvar string $locale_loaded
 *
 * @param string $selected_zone Selected timezone.
 * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
 * @return string
 */
function wp_timezone_choice($selected_zone, $locale = null)
{
    static $mo_loaded = false, $locale_loaded = null;
    $continents = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
    // Load translations for continents and cities.
    if (!$mo_loaded || $locale !== $locale_loaded) {
        $locale_loaded = $locale ? $locale : get_locale();
        $mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
        unload_textdomain('continents-cities');
        load_textdomain('continents-cities', $mofile);
        $mo_loaded = true;
    }
    $zonen = array();
    foreach (timezone_identifiers_list() as $zone) {
        $zone = explode('/', $zone);
        if (!in_array($zone[0], $continents)) {
            continue;
        }
        // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
        $exists = array(0 => isset($zone[0]) && $zone[0], 1 => isset($zone[1]) && $zone[1], 2 => isset($zone[2]) && $zone[2]);
        $exists[3] = $exists[0] && 'Etc' !== $zone[0];
        $exists[4] = $exists[1] && $exists[3];
        $exists[5] = $exists[2] && $exists[3];
        $zonen[] = array('continent' => $exists[0] ? $zone[0] : '', 'city' => $exists[1] ? $zone[1] : '', 'subcity' => $exists[2] ? $zone[2] : '', 't_continent' => $exists[3] ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities') : '', 't_city' => $exists[4] ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities') : '', 't_subcity' => $exists[5] ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities') : '');
    }
    usort($zonen, '_wp_timezone_choice_usort_callback');
    $structure = array();
    if (empty($selected_zone)) {
        $structure[] = '<option selected="selected" value="">' . __('Select a city') . '</option>';
    }
    foreach ($zonen as $key => $zone) {
        // Build value in an array to join later
        $value = array($zone['continent']);
        if (empty($zone['city'])) {
            // It's at the continent level (generally won't happen)
            $display = $zone['t_continent'];
        } else {
            // It's inside a continent group
            // Continent optgroup
            if (!isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) {
                $label = $zone['t_continent'];
                $structure[] = '<optgroup label="' . esc_attr($label) . '">';
            }
            // Add the city to the value
            $value[] = $zone['city'];
            $display = $zone['t_city'];
            if (!empty($zone['subcity'])) {
                // Add the subcity to the value
                $value[] = $zone['subcity'];
                $display .= ' - ' . $zone['t_subcity'];
            }
        }
        // Build the value
        $value = join('/', $value);
        $selected = '';
        if ($value === $selected_zone) {
            $selected = 'selected="selected" ';
        }
        $structure[] = '<option ' . $selected . 'value="' . esc_attr($value) . '">' . esc_html($display) . "</option>";
        // Close continent optgroup
        if (!empty($zone['city']) && (!isset($zonen[$key + 1]) || isset($zonen[$key + 1]) && $zonen[$key + 1]['continent'] !== $zone['continent'])) {
            $structure[] = '</optgroup>';
        }
    }
    // Do UTC
    $structure[] = '<optgroup label="' . esc_attr__('UTC') . '">';
    $selected = '';
    if ('UTC' === $selected_zone) {
        $selected = 'selected="selected" ';
    }
    $structure[] = '<option ' . $selected . 'value="' . esc_attr('UTC') . '">' . __('UTC') . '</option>';
    $structure[] = '</optgroup>';
    // Do manual UTC offsets
    $structure[] = '<optgroup label="' . esc_attr__('Manual Offsets') . '">';
    $offset_range = array(-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14);
    foreach ($offset_range as $offset) {
        if (0 <= $offset) {
            $offset_name = '+' . $offset;
        } else {
            $offset_name = (string) $offset;
        }
        $offset_value = $offset_name;
        $offset_name = str_replace(array('.25', '.5', '.75'), array(':15', ':30', ':45'), $offset_name);
        $offset_name = 'UTC' . $offset_name;
        $offset_value = 'UTC' . $offset_value;
        $selected = '';
        if ($offset_value === $selected_zone) {
//.........这里部分代码省略.........
开发者ID:johnpbloch,项目名称:wordpress,代码行数:101,代码来源:functions.php


示例12: wcml_refresh_text_domain

 function wcml_refresh_text_domain()
 {
     global $woocommerce;
     $domain = 'woocommerce';
     unload_textdomain($domain);
     $woocommerce->load_plugin_textdomain();
 }
开发者ID:heaptrace,项目名称:onlineshop,代码行数:7,代码来源:products.class.php


示例13: change_email_language

 function change_email_language($lang)
 {
     global $sitepress, $woocommerce;
     $sitepress->switch_lang($lang, true);
     $this->locale = $sitepress->get_locale($lang);
     unload_textdomain('woocommerce');
     unload_textdomain('default');
     $woocommerce->load_plugin_textdomain();
     load_default_textdomain();
     global $wp_locale;
     $wp_locale = new WP_Locale();
 }
开发者ID:helgatheviking,项目名称:woocommerce-multilingual,代码行数:12,代码来源:emails.class.php


示例14: switchLanguage

 /**
  * Reload text domains with order locale.
  *
  * @param string $language Language slug (e.g. en, de )
  */
 public function switchLanguage($language)
 {
     if (class_exists('Polylang')) {
         global $locale, $polylang, $woocommerce;
         static $cache;
         // Polylang string translations cache object to avoid loading the same translations object several times
         // Cache object not found. Create one...
         if (empty($cache)) {
             $cache = new \PLL_Cache();
         }
         //$current_language = pll_current_language( 'locale' );
         // unload plugin's textdomains
         unload_textdomain('default');
         unload_textdomain('woocommerce');
         // set locale to order locale
         $locale = apply_filters('locale', $language);
         $polylang->curlang->locale = $language;
         // Cache miss
         if (false === ($mo = $cache->get($language))) {
             $mo = new \PLL_MO();
             $mo->import_from_db($GLOBALS['polylang']->model->get_language($language));
             $GLOBALS['l10n']['pll_string'] =& $mo;
             // Add to cache
             $cache->set($language, $mo);
         }
         // (re-)load plugin's textdomain with order locale
         load_default_textdomain($language);
         $woocommerce->load_plugin_textdomain();
         $wp_locale = new \WP_Locale();
     }
 }
开发者ID:hyyan,项目名称:woo-poly-integration,代码行数:36,代码来源:Emails.php


示例15: twitter_api_load_textdomain

/**
 * Enable localisation
 * @internal
 */
function twitter_api_load_textdomain($locale = null, $domain = 'twitter-api')
{
    static $current_locale;
    if (is_null($locale)) {
        $locale = get_locale();
    }
    if (!$locale || 0 === strpos($locale, 'en')) {
        $current_locale and unload_textdomain($domain);
        $locale = 'en_US';
    } else {
        if ($current_locale !== $locale) {
            // purposefully not calling load_plugin_textdomain, due to symlinking
            // and not knowing what plugin this could be called from.
            $mofile = realpath(twitter_api_basedir() . '/lang/' . $domain . '-' . $locale . '.mo');
            if (!load_textdomain($domain, $mofile)) {
                $mofile = WP_LANG_DIR . '/plugins/' . $domain . '-' . $locale . '.mo';
                load_textdomain($domain, $mofile);
            }
        }
    }
    // detect changes in plugin locale, binding once only
    if (!isset($current_locale)) {
        add_filter('plugin_locale', '_twitter_api_filter_plugin_locale', 10, 2);
    }
    $current_locale = $locale;
}
开发者ID:shellygraham,项目名称:green-building-services,代码行数:30,代码来源:twitter-api.php


示例16: ab_deactivate

function ab_deactivate()
{
    // unload l10n
    unload_textdomain('ab');
}
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:5,代码来源:main.php


示例17: test_override_load_textdomain_custom_mofile

 function test_override_load_textdomain_custom_mofile()
 {
     add_filter('override_load_textdomain', array($this, '_override_load_textdomain_filter'), 10, 3);
     $load_textdomain = load_textdomain('wp-tests-domain', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo');
     remove_filter('override_load_textdomain', array($this, '_override_load_textdomain_filter'));
     $is_textdomain_loaded = is_textdomain_loaded('wp-tests-domain');
     unload_textdomain('wp-tests-domain');
     $is_textdomain_loaded_after = is_textdomain_loaded('wp-tests-domain');
     $this->assertTrue($load_textdomain);
     $this->assertTrue($is_textdomain_loaded);
     $this->assertFalse($is_textdomain_loaded_after);
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:12,代码来源:loadTextdomain.php


示例18: json_api

 function json_api($args = array())
 {
     $json_api_args = $args[0];
     $verify_api_user_args = $args[1];
     $method = (string) $json_api_args[0];
     $url = (string) $json_api_args[1];
     $post_body = is_null($json_api_args[2]) ? null : (string) $json_api_args[2];
     $user_details = (array) $json_api_args[4];
     $locale = (string) $json_api_args[5];
     if (!$verify_api_user_args) {
         $user_id = 0;
     } elseif ('internal' === $verify_api_user_args[0]) {
         $user_id = (int) $verify_api_user_args[1];
         if ($user_id) {
             $user = get_user_by('id', $user_id);
             if (!$user || is_wp_error($user)) {
                 return false;
             }
         }
     } else {
         $user_id = call_user_func(array($this, 'test_api_user_code'), $verify_api_user_args);
         if (!$user_id) {
             return false;
         }
     }
     /* debugging
     		error_log( "-- begin json api via jetpack debugging -- " );
     		error_log( "METHOD: $method" );
     		error_log( "URL: $url" );
     		error_log( "POST BODY: $post_body" );
     		error_log( "VERIFY_ARGS: " . print_r( $verify_api_user_args, 1 ) );
     		error_log( "VERIFIED USER_ID: " . (int) $user_id );
     		error_log( "-- end json api via jetpack debugging -- " );
     		*/
     if ('en' !== $locale) {
         // .org mo files are named slightly different from .com, and all we have is this the locale -- try to guess them.
         $new_locale = $locale;
         if (strpos($locale, '-') !== false) {
             $pieces = explode('-', $locale);
             $new_locale = $locale_pieces[0];
             $new_locale .= !empty($locale_pieces[1]) ? '_' . strtoupper($locale_pieces[1]) : '';
         } else {
             // .com might pass 'fr' because thats what our language files are named as, where core seems
             // to do fr_FR - so try that if we don't think we can load the file.
             if (!file_exists(WP_LANG_DIR . '/' . $locale . '.mo')) {
                 $new_locale = $locale . '_' . strtoupper($locale);
             }
         }
         if (file_exists(WP_LANG_DIR . '/' . $new_locale . '.mo')) {
             unload_textdomain('default');
             load_textdomain('default', WP_LANG_DIR . '/' . $new_locale . '.mo');
         }
     }
     $old_user = wp_get_current_user();
     wp_set_current_user($user_id);
     $token = Jetpack_Data::get_access_token(get_current_user_id());
     if (!$token || is_wp_error($token)) {
         return false;
     }
     define('REST_API_REQUEST', true);
     define('WPCOM_JSON_API__BASE', 'public-api.wordpress.com/rest/v1');
     // needed?
     require_once ABSPATH . 'wp-admin/includes/admin.php';
     require_once JETPACK__PLUGIN_DIR . 'class.json-api.php';
     $api = WPCOM_JSON_API::init($method, $url, $post_body);
     $api->token_details['user'] = $user_details;
     require_once JETPACK__PLUGIN_DIR . 'class.json-api-endpoints.php';
     $display_errors = ini_set('display_errors', 0);
     ob_start();
     $content_type = $api->serve(false);
     $output = ob_get_clean();
     ini_set('display_errors', $display_errors);
     $nonce = wp_generate_password(10, false);
     $hmac = hash_hmac('md5', $nonce . $output, $token->secret);
     wp_set_current_user(isset($old_user->ID) ? $old_user->ID : 0);
     return array((string) $output, (string) $nonce, (string) $hmac);
 }
开发者ID:jordankoschei,项目名称:jordankoschei-dot-com,代码行数:77,代码来源:class.jetpack-xmlrpc-server.php


示例19: switch_to_locale

 /**
  * Switches the translations according to the given locale.
  *
  * @since 4.6.0
  *
  * @param string $locale The locale.
  *
  * @return string $locale |false
  */
 public function switch_to_locale($locale)
 {
     $current_locale = get_locale();
     if ($current_locale === $locale) {
         return $locale;
     }
     if (!in_array($locale, get_available_languages())) {
         return false;
     }
     // add here so not to record duplicate switches
     $this->locales[] = $locale;
     /**
      * @global MO[] $l10n
      */
     global $l10n;
     // return early if on no language to switch from
     if (null === $l10n) {
         return false;
     }
     $textdomains = array_keys($l10n);
     if (!$this->has_translations_for_locale($current_locale)) {
         foreach ($textdomains as $textdomain) {
             $this->translations[$current_locale][$textdomain] = get_translations_for_domain($textdomain);
         }
     }
     $this->remove_filters();
     $this->add_filter_for_locale($locale);
     if ($this->has_translations_for_locale($locale)) {
         foreach ($textdomains as $textdomain) {
             if (isset($this->translations[$locale][$textdomain])) {
                 $l10n[$textdomain] = $this->translations[$locale][$textdomain];
             }
         }
     } else {
         foreach ($l10n as $textdomain => $mo) {
             if ('default' === $textdomain) {
                 load_default_textdomain();
                 continue;
             }
             unload_textdomain($textdomain);
             if ($mofile = $mo->get_filename()) {
                 load_textdomain($textdomain, $mofile);
             }
             $this->translations[$locale][$textdomain] = get_translations_for_domain($textdomain);
         }
     }
     /**
      * @global WP_Locale $wp_locale
      */
     $GLOBALS['wp_locale'] = new WP_Locale();
     return $locale;
 }
开发者ID:pbearne,项目名称:contrib2core,代码行数:61,代码来源:class-wp-locale-switcher.php


示例20: test_should_allow_unloading_of_text_domain

 /**
  * @ticket 37113
  */
 public function test_should_allow_unloading_of_text_domain()
 {
     add_filter('locale', array($this, 'filter_set_locale_to_german'));
     require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
     $expected_output_before = i18n_plugin_test();
     $is_textdomain_loaded_before = is_textdomain_loaded('internationalized-plugin');
     unload_textdomain('internationalized-plugin');
     remove_filter('locale', array($this, 'filter_set_locale_to_german'));
     $expected_output_after = i18n_plugin_test();
     $is_textdomain_loaded_after = is_textdomain_loaded('internationalized-plugin');
     add_filter('locale', array($this, 'filter_set_locale_to_german'));
     load_textdomain('internationalized-plugin', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo');
     $expected_output_final = i18n_plugin_test();
     $is_textdomain_loaded_final = is_textdomain_loaded('internationalized-plugin');
     unload_textdomain('internationalized-plugin');
     remove_filter('locale', array($this, 'filter_set_locale_to_german'));
     // Text domain loaded just in time.
     $this->assertSame('Das ist ein Dummy Plugin', $expected_output_before);
     $this->assertTrue($is_textdomain_loaded_before);
     // Text domain unloaded.
     $this->assertSame('This is a dummy plugin', $expected_output_after);
     $this->assertFalse($is_textdomain_loaded_after);
     // Text domain loaded manually again.
     $this->assertSame('Das ist ein Dummy Plugin', $expected_output_final);
     $this->assertTrue($is_textdomain_loaded_final);
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:29,代码来源:loadTextdomainJustInTime.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP unlock函数代码示例发布时间:2022-05-23
下一篇:
PHP unlink_if_exists函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap