本文整理汇总了PHP中get_available_languages函数的典型用法代码示例。如果您正苦于以下问题:PHP get_available_languages函数的具体用法?PHP get_available_languages怎么用?PHP get_available_languages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_available_languages函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: pre_set_site_transient
/**
* Add language translations to update_plugins or update_themes transients.
*
* @param $transient
*
* @return mixed
*/
public function pre_set_site_transient($transient)
{
$locales = get_available_languages();
$locales = !empty($locales) ? $locales : array(get_locale());
$repos = array();
if (!isset($transient->translations)) {
return $transient;
}
if ('pre_set_site_transient_update_plugins' === current_filter()) {
$repos = Plugin::instance()->get_plugin_configs();
$translations = wp_get_installed_translations('plugins');
}
if ('pre_set_site_transient_update_themes' === current_filter()) {
$repos = Theme::instance()->get_theme_configs();
$translations = wp_get_installed_translations('themes');
}
$repos = array_filter($repos, function ($e) {
return isset($e->language_packs);
});
foreach ($repos as $repo) {
foreach ($locales as $locale) {
$lang_pack_mod = isset($repo->language_packs->{$locale}) ? strtotime($repo->language_packs->{$locale}->updated) : 0;
$translation_mod = isset($translations[$repo->repo][$locale]) ? strtotime($translations[$repo->repo][$locale]['PO-Revision-Date']) : 0;
if ($lang_pack_mod > $translation_mod) {
$transient->translations[] = (array) $repo->language_packs->{$locale};
}
}
}
$transient->translations = array_unique($transient->translations, SORT_REGULAR);
return $transient;
}
开发者ID:afragen,项目名称:github-updater,代码行数:38,代码来源:Language_Pack.php
示例2: getLanguageMutation
protected function getLanguageMutation()
{
$i84676540daef1510ea5729a183290848a9e7accb = 0;
$i05355412b857f5174e9a2f71b1e936a86ad60cd22621e8ed49bfcd8c8447959e1a834cd7df379456 = $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900 = array();
if (file_exists(ABSPATH . 'wp-admin/includes/translation-install.php')) {
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
$i05355412b857f5174e9a2f71b1e936a86ad60cd22621e8ed49bfcd8c8447959e1a834cd7df379456 = get_available_languages();
$i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900 = wp_get_available_translations();
}
if (isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[SMS_DEFAULT_MUTATION]) && isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[SMS_DEFAULT_MUTATION]["native_name"])) {
$iced8cbcfca3c880f0f157e119d1cc6f8691e7e89 = array(SMS_DEFAULT_MUTATION => $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[SMS_DEFAULT_MUTATION]["native_name"], "en_US" => "English (United States)");
$this->mutationColors[SMS_DEFAULT_MUTATION] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors);
$this->mutationColors["en_US"] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors);
} else {
$iced8cbcfca3c880f0f157e119d1cc6f8691e7e89 = array("en_US" => "English (United States)");
$this->mutationColors["en_US"] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors);
}
foreach ($i05355412b857f5174e9a2f71b1e936a86ad60cd22621e8ed49bfcd8c8447959e1a834cd7df379456 as $i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772) {
if ($i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772 != SMS_DEFAULT_MUTATION) {
$this->mutationColors[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772] = $i84676540daef1510ea5729a183290848a9e7accb++ % count(self::$colors);
if (isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772]) && isset($i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772]["native_name"])) {
$iced8cbcfca3c880f0f157e119d1cc6f8691e7e89[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772] = $i05355412b857f5174e9a2f71b1e936a86ad60cd20469dd29d7fc00508902b5648b5460a24be01900[$i05355412b857f5174e9a2f71b1e936a86ad60cd2572358132e4515581ad210b23e0ca988f93e9772]["native_name"];
}
}
}
return $iced8cbcfca3c880f0f157e119d1cc6f8691e7e89;
}
开发者ID:etondeengole,项目名称:Store_Application,代码行数:27,代码来源:smsAdapter.php
示例3: wp_user_profiles_language_metabox
/**
* Render the language metabox for user profile screen
*
* @since 0.1.0
*
* @param WP_User $user The WP_User object to be edited.
*/
function wp_user_profiles_language_metabox($user = null)
{
// Defaults
$languages = get_available_languages();
$user_locale = $user->locale;
$fallback = get_locale();
// Already en_US
if ('en_US' === $user->locale) {
$user_locale = false;
// Language not available
} elseif (!in_array($user->locale, $languages, true)) {
$user_locale = $fallback;
}
?>
<table class="form-table">
<tr class="user-language-wrap">
<th scope="row">
<label for="locale"><?php
esc_html_e('Language', 'wp-user-profiles');
?>
</label>
</th>
<td><?php
// Drop it down
wp_dropdown_languages(array('name' => 'locale', 'id' => 'locale', 'selected' => $user_locale, 'languages' => $languages, 'show_available_translations' => false));
?>
</td>
</tr>
</table>
<?php
}
开发者ID:stuttter,项目名称:wp-user-profiles,代码行数:40,代码来源:account-language.php
示例4: mlang_languages
function mlang_languages()
{
$languages = get_available_languages();
if (!in_array('en', $languages)) {
array_unshift($languages, 'en');
}
return $languages;
}
开发者ID:EaseCloud,项目名称:WP-MLang,代码行数:8,代码来源:index.php
示例5: getPicklistOptions
/**
*
* @return array;
*/
public function getPicklistOptions()
{
$languages = get_available_languages();
foreach ($languages as $language) {
$options[$language] = $language;
}
return $options;
}
开发者ID:TeamCodeStudio,项目名称:fpmoz,代码行数:12,代码来源:LanguagePopulator.php
示例6: test_get_available_languages
/**
* @ticket 35950
*/
function test_get_available_languages()
{
$array = get_available_languages();
$this->assertInternalType('array', $array);
$array = get_available_languages('.');
$this->assertEmpty($array);
$array = get_available_languages(DIR_TESTDATA . '/languages/');
$this->assertEquals(array('en_GB', 'es_ES'), $array);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:12,代码来源:l10n.php
示例7: markup
/**
* Returns the markup for the user setting.
*
* @since 3.0.0
*
* @param WP_User $user User object.
*
* @return string The markup for the user setting.
*/
public function markup(WP_User $user)
{
$languages = get_available_languages();
if (!$languages) {
return esc_html__('No languages available.', 'multilingual-press');
}
// Add English manually, because it won't get added by WordPress itself.
$languages[] = 'en_US';
return sprintf('<select name="%2$s" id="%2$s" autocomplete="off">%1$s</select>%3$s', $this->get_language_options($languages, $this->language_repository->get_user_language($user->ID)), esc_attr($this->meta_key), \Inpsyde\MultilingualPress\nonce_field($this->nonce));
}
开发者ID:inpsyde,项目名称:multilingual-press,代码行数:19,代码来源:Setting.php
示例8: languages_options
function languages_options()
{
// Initialization
global $locale;
$return = array(is_eng_array('Detect', 'language', ' - ') => 'Detect');
$languages = get_available_languages();
$languages_list = languages_list();
$languages_self_list = languages_self_list();
$is_en = substr($locale, 0, 2) == 'en';
foreach ($languages as $language) {
$return[] = array(isset($languages_self_list[$language]) ? $languages_self_list[$language] : $languages_list[$language] => array((isset($languages_list[$language]) ? $languages_list[$language] : $language) . ($is_en ? '' : ' - ' . $language) => $language));
}
if (!in_array('en', $languages) && !in_array('en_US', $languages) && !in_array('en_GB', $languages)) {
$return[] = array('English' => array(is_eng_array('English', 'language', ' - ') => 'en_US'));
}
return $return;
}
开发者ID:PONBBS,项目名称:WEIPDCRM,代码行数:17,代码来源:settings.php
示例9: bogo_available_locales
function bogo_available_locales($args = '')
{
$defaults = array('exclude' => array(), 'current_user_can_access' => false);
$args = wp_parse_args($args, $defaults);
$installed_locales = get_available_languages();
$installed_locales[] = bogo_get_default_locale();
$installed_locales[] = 'en_US';
$installed_locales = array_unique($installed_locales);
$installed_locales = array_filter($installed_locales);
$available_locales = array();
foreach ($installed_locales as $locale) {
if (in_array($locale, (array) $args['exclude'])) {
continue;
}
if ($args['current_user_can_access'] && !current_user_can('bogo_access_locale', $locale)) {
continue;
}
$available_locales[] = $locale;
}
return $available_locales;
}
开发者ID:karthikakamalanathan,项目名称:wp-cookieLawInfo,代码行数:21,代码来源:functions.php
示例10: existing
public static function existing($all = false, $translate = false)
{
if (empty(self::$items)) {
$languages = array();
$langs = get_available_languages();
if (!in_array(get_locale(), $langs)) {
$langs[] = get_locale();
}
$i = 0;
foreach ($langs as $lang) {
$languages[$i] = new stdClass();
$languages[$i]->value = $lang;
$languages[$i]->text = $lang;
$i++;
}
self::$items = $languages;
if ($all) {
array_unshift(self::$items, new MObject(array('value' => '*', 'text' => $translate ? MText::alt('MALL', 'language') : 'MALL_LANGUAGE')));
}
}
return self::$items;
}
开发者ID:vanie3,项目名称:appland,代码行数:22,代码来源:contentlanguage.php
示例11: getLanguages
public static function getLanguages($key = 'default')
{
static $languages;
if (empty($languages)) {
// Installation uses available languages
if (MFactory::getApplication()->getClientId() == 2) {
$languages[$key] = array();
$knownLangs = MLanguage::getKnownLanguages(MPATH_BASE);
foreach ($knownLangs as $metadata) {
// Take off 3 letters iso code languages as they can't match browsers' languages and default them to en
$languages[$key][] = new MObject(array('lang_code' => $metadata['tag']));
}
} else {
$cache = MFactory::getCache('com_languages', '');
if (!($languages = $cache->get('languages'))) {
$langs = get_available_languages();
$i = 0;
$lngs = array();
foreach ($langs as $lang) {
$lngs[$i] = new stdClass();
$lngs[$i]->title = $lang;
$i++;
}
$languages['default'] = $lngs;
$languages['lang_code'] = array();
if (isset($languages['default'][0])) {
foreach ($languages['default'] as $lang) {
$languages['lang_code'][$lang->title] = $lang;
}
}
$cache->store($languages, 'languages');
}
}
}
return $languages[$key];
}
开发者ID:vanie3,项目名称:appland,代码行数:36,代码来源:helper.php
示例12: vp_register_hooks
function vp_register_hooks()
{
global $wpdb, $versionPressContainer;
/** @var Committer $committer */
$committer = $versionPressContainer->resolve(VersionPressServices::COMMITTER);
/** @var Mirror $mirror */
$mirror = $versionPressContainer->resolve(VersionPressServices::MIRROR);
/** @var DbSchemaInfo $dbSchemaInfo */
$dbSchemaInfo = $versionPressContainer->resolve(VersionPressServices::DB_SCHEMA);
/** @var VpidRepository $vpidRepository */
$vpidRepository = $versionPressContainer->resolve(VersionPressServices::VPID_REPOSITORY);
/** @var WpdbMirrorBridge $wpdbMirrorBridge */
$wpdbMirrorBridge = $versionPressContainer->resolve(VersionPressServices::WPDB_MIRROR_BRIDGE);
/**
* Hook for saving taxonomies into files
* WordPress creates plain INSERT query and executes it using wpdb::query method instead of wpdb::insert.
* It's too difficult to parse every INSERT query, that's why the WordPress hook is used.
*/
add_action('save_post', createUpdatePostTermsHook($mirror, $vpidRepository));
add_filter('update_feedback', function () {
touch(ABSPATH . 'versionpress.maintenance');
});
add_action('_core_updated_successfully', function () use($committer, $mirror) {
require ABSPATH . 'wp-includes/version.php';
// load constants (like $wp_version)
/** @var string $wp_version */
$changeInfo = new WordPressUpdateChangeInfo($wp_version);
$committer->forceChangeInfo($changeInfo);
$mirror->save('option', array('option_name' => 'db_version', 'option_value' => get_option('db_version')));
// We have to re-save the option because WP upgrader uses $wpdb->query()
if (!WpdbReplacer::isReplaced()) {
WpdbReplacer::replaceMethods();
}
});
add_action('activated_plugin', function ($pluginName) use($committer) {
$committer->forceChangeInfo(new PluginChangeInfo($pluginName, 'activate'));
});
add_action('deactivated_plugin', function ($pluginName) use($committer) {
$committer->forceChangeInfo(new PluginChangeInfo($pluginName, 'deactivate'));
});
add_action('upgrader_process_complete', function ($upgrader, $hook_extra) use($committer) {
if ($hook_extra['type'] === 'theme') {
$themes = isset($hook_extra['bulk']) && $hook_extra['bulk'] === true ? $hook_extra['themes'] : array($upgrader->result['destination_name']);
foreach ($themes as $theme) {
$themeName = wp_get_theme($theme)->get('Name');
if ($themeName === $theme && isset($upgrader->skin->api, $upgrader->skin->api->name)) {
$themeName = $upgrader->skin->api->name;
}
$action = $hook_extra['action'];
// can be "install" or "update", see WP_Upgrader and search for `'hook_extra' =>`
$committer->forceChangeInfo(new ThemeChangeInfo($theme, $action, $themeName));
}
}
if (!($hook_extra['type'] === 'plugin' && $hook_extra['action'] === 'update')) {
return;
}
// handled by different hook
if (isset($hook_extra['bulk']) && $hook_extra['bulk'] === true) {
$plugins = $hook_extra['plugins'];
} else {
$plugins = array($hook_extra['plugin']);
}
foreach ($plugins as $plugin) {
$committer->forceChangeInfo(new PluginChangeInfo($plugin, 'update'));
}
}, 10, 2);
add_action('added_option', function ($name) use($wpdb, $mirror) {
$option = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}options WHERE option_name='{$name}'", ARRAY_A);
$mirror->save("option", $option);
});
add_filter('upgrader_pre_install', function ($_, $hook_extra) use($committer) {
if (!(isset($hook_extra['type']) && $hook_extra['type'] === 'plugin' && $hook_extra['action'] === 'install')) {
return;
}
$pluginsBeforeInstallation = get_plugins();
$postInstallHook = function ($_, $hook_extra) use($pluginsBeforeInstallation, $committer, &$postInstallHook) {
if (!($hook_extra['type'] === 'plugin' && $hook_extra['action'] === 'install')) {
return;
}
wp_cache_delete('plugins', 'plugins');
$pluginsAfterInstallation = get_plugins();
$installedPlugin = array_diff_key($pluginsAfterInstallation, $pluginsBeforeInstallation);
reset($installedPlugin);
$pluginName = key($installedPlugin);
$committer->forceChangeInfo(new PluginChangeInfo($pluginName, 'install'));
remove_filter('upgrader_post_install', $postInstallHook);
};
add_filter('upgrader_post_install', $postInstallHook, 10, 2);
}, 10, 2);
add_filter('upgrader_pre_download', function ($reply, $_, $upgrader) use($committer) {
if (!isset($upgrader->skin->language_update)) {
return $reply;
}
$languages = get_available_languages();
$postInstallHook = function ($_, $hook_extra) use($committer, $languages, &$postInstallHook) {
if (!isset($hook_extra['language_update_type'])) {
return;
}
$translations = wp_get_available_translations();
$type = $hook_extra['language_update_type'];
//.........这里部分代码省略.........
开发者ID:wp-cpm,项目名称:versionpress,代码行数:101,代码来源:versionpress.php
示例13: change_language
/**
* change language : if language file not exist return false
* if language file not in THEME_LANGUAGE_PATH copy it from DEFAULT_LANG to THEME_LANGUAGE_PATH
* @since 1.0
*/
function change_language()
{
$lang = $_REQUEST['lang_name'];
if (!in_array($lang, $this->get_language_list())) {
wp_send_json(array('success' => false));
}
if (!in_array($lang, get_available_languages(THEME_LANGUAGE_PATH))) {
$mo = new MO();
$mo->set_header('Project-Id-Version', THEME_NAME . 'v' . ET_VERSION);
$mo->set_header('Report-Msgid-Bugs-To', ET_URL);
$mo->set_header('MO-Creation-Date', gmdate('Y-m-d H:i:s+00:00'));
$mo->set_header('MIME-Version', '1.0');
$mo->set_header('Content-Type', 'text/plain; charset=UTF-8');
$mo->set_header('Content-Transfer-Encoding', '8bit');
$mo->set_header('MO-Revision-Date', '2010-MO-DA HO:MI+ZONE');
$mo->set_header('Last-Translator', 'JOB <EMAIL@ADDRESS>');
$mo->set_header('Language-Team', 'ENGINETHEMES.COM <[email protected]>');
$mo->import_from_file(DEFAULT_LANGUAGE_PATH . '/' . $lang . '.mo');
$mo->export_to_file(THEME_LANGUAGE_PATH . '/' . $lang . '.mo');
}
$this->set_site_language($lang);
wp_send_json(array('success' => true, 'data' => array('ID' => $lang, 'lang_name' => $lang)));
}
开发者ID:rinodung,项目名称:wp-question,代码行数:28,代码来源:class-ae-languages.php
示例14: translation_updates
public function translation_updates($locales)
{
$languages = get_available_languages();
return array_values($languages);
}
开发者ID:daanbakker1995,项目名称:vanteun,代码行数:5,代码来源:config.php
示例15: wp_update_themes
/**
* Check theme versions against the latest versions hosted on WordPress.org.
*
* A list of all themes installed in sent to WP. Checks against the
* WordPress server at api.wordpress.org. Will only check if WordPress isn't
* installing.
*
* @since 2.7.0
*
* @param array $extra_stats Extra statistics to report to the WordPress.org API.
*/
function wp_update_themes($extra_stats = array())
{
if (wp_installing()) {
return;
}
// include an unmodified $wp_version
include ABSPATH . WPINC . '/version.php';
$installed_themes = wp_get_themes();
$translations = wp_get_installed_translations('themes');
$last_update = get_site_transient('update_themes');
if (!is_object($last_update)) {
$last_update = new stdClass();
}
$themes = $checked = $request = array();
// Put slug of current theme into request.
$request['active'] = get_option('stylesheet');
foreach ($installed_themes as $theme) {
$checked[$theme->get_stylesheet()] = $theme->get('Version');
$themes[$theme->get_stylesheet()] = array('Name' => $theme->get('Name'), 'Title' => $theme->get('Name'), 'Version' => $theme->get('Version'), 'Author' => $theme->get('Author'), 'Author URI' => $theme->get('AuthorURI'), 'Template' => $theme->get_template(), 'Stylesheet' => $theme->get_stylesheet());
}
// Check for update on a different schedule, depending on the page.
switch (current_filter()) {
case 'upgrader_process_complete':
$timeout = 0;
break;
case 'load-update-core.php':
$timeout = MINUTE_IN_SECONDS;
break;
case 'load-themes.php':
case 'load-update.php':
$timeout = HOUR_IN_SECONDS;
break;
default:
if (defined('DOING_CRON') && DOING_CRON) {
$timeout = 0;
} else {
$timeout = 12 * HOUR_IN_SECONDS;
}
}
$time_not_changed = isset($last_update->last_checked) && $timeout > time() - $last_update->last_checked;
if ($time_not_changed && !$extra_stats) {
$theme_changed = false;
foreach ($checked as $slug => $v) {
if (!isset($last_update->checked[$slug]) || strval($last_update->checked[$slug]) !== strval($v)) {
$theme_changed = true;
}
}
if (isset($last_update->response) && is_array($last_update->response)) {
foreach ($last_update->response as $slug => $update_details) {
if (!isset($checked[$slug])) {
$theme_changed = true;
break;
}
}
}
// Bail if we've checked recently and if nothing has changed
if (!$theme_changed) {
return;
}
}
// Update last_checked for current to prevent multiple blocking requests if request hangs
$last_update->last_checked = time();
set_site_transient('update_themes', $last_update);
$request['themes'] = $themes;
$locales = array_values(get_available_languages());
/**
* Filter the locales requested for theme translations.
*
* @since 3.7.0
* @since 4.5.0 Changed default value of `$locales` to include all locales.
*
* @param array $locales Theme locales. Default is all available locales of the site.
*/
$locales = apply_filters('themes_update_check_locales', $locales);
$locales = array_unique($locales);
if (defined('DOING_CRON') && DOING_CRON) {
$timeout = 30;
} else {
// Three seconds, plus one extra second for every 10 themes
$timeout = 3 + (int) (count($themes) / 10);
}
$options = array('timeout' => $timeout, 'body' => array('themes' => wp_json_encode($request), 'translations' => wp_json_encode($translations), 'locale' => wp_json_encode($locales)), 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'));
if ($extra_stats) {
$options['body']['update_stats'] = wp_json_encode($extra_stats);
}
$url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/';
if ($ssl = wp_http_supports(array('ssl'))) {
$url = set_url_scheme($url, 'https');
}
//.........这里部分代码省略.........
开发者ID:andylow,项目名称:WordPress,代码行数:101,代码来源:update.php
示例16: parse_available_languages
/**
* Parse the files in wp-content/languages and work out what
* languages we've got available. Populates self::available_langs
* with an array of language objects which look like:
* 'ar' =>
* object(stdClass)
* public 'name' => string 'Arabic'
* public 'code' => string 'ar'
* public 'url_prefix' => string 'ar'
* public 'text_direction' => string 'rtl'
*
* @return void
**/
protected function parse_available_languages()
{
unset($this->available_langs);
$this->available_langs = array();
foreach (get_available_languages() as $lang_code) {
list($prefix) = explode('_', $lang_code);
$lang = array('name' => $this->format_code_lang($prefix), 'code' => $lang_code, 'url_prefix' => $prefix, 'text_direction' => self::is_rtl($lang_code) ? 'rtl' : 'ltr');
// Cast to an object, in case we want to start using actual classes
// at some point in the future.
$this->available_langs[$lang_code] = (object) $lang;
}
// Add in US English, which is the default on WordPress and has no language files
$en = new stdClass();
$en->name = 'English (US)';
$en->code = 'en_US';
$en->url_prefix = 'en';
$en->text_direction = 'ltr';
$this->available_langs['en_US'] = $en;
$this->available_langs = apply_filters('bbl_available_langs', $this->available_langs);
ksort($this->available_langs);
$this->update_option('available_langs', $this->available_langs);
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:35,代码来源:class-languages.php
示例17: update_wplang
/**
* Update option WPLANG in DB for new sites.
*
* @param int $blog_id
* @return void
*/
private function update_wplang($blog_id)
{
$posted = $this->get_posted_language();
if (!$posted) {
return;
}
// search for wp_locale where search = $http_name
$search = array('fields' => array('wp_locale'), 'where' => array(array('field' => 'http_name', 'search' => $posted)));
$available_language = $this->language_api->get_db()->get_items($search, OBJECT);
// no results found? -> return
if (empty($available_language)) {
return;
}
// getting the first wp_locale
$wp_locale = $available_language[0]->wp_locale;
$available_lang_files = get_available_languages();
if (!in_array($wp_locale, $available_lang_files)) {
return;
}
update_blog_option($blog_id, 'WPLANG', $wp_locale);
}
开发者ID:luisarn,项目名称:multilingual-press,代码行数:27,代码来源:Mlp_Network_New_Site_Controller.php
示例18: defined
<?php
/*
All Emoncms code is released under the GNU Affero General Public License.
See COPYRIGHT.txt and LICENSE.txt.
---------------------------------------------------------------------
Emoncms - open source energy visualisation
Part of the OpenEnergyMonitor project:
http://openenergymonitor.org
*/
// no direct access
defined('EMONCMS_EXEC') or die('Restricted access');
global $path;
$languages = get_available_languages();
$languages_name = languagecode_to_name($languages);
//languages order by language name
$languages_new = array();
foreach ($languages_name as $key => $lang) {
$languages_new[$key] = $languages[$key];
}
$languages = array_values($languages_new);
$languages_name = array_values($languages_name);
function languagecode_to_name($langs)
{
static $lang_names = null;
if ($lang_names === null) {
$json_data = file_get_contents(__DIR__ . '/language_country.json');
$lang_names = json_decode($json_data, true);
}
foreach ($langs as $key => $val) {
开发者ID:TrystanLea,项目名称:emoncms,代码行数:31,代码来源:profile.php
示例19: upgrade_400
/**
* Execute changes made in WordPress 4.0.0.
*
* @since 4.0.0
*/
function upgrade_400()
{
global $wp_current_db_version;
if ($wp_current_db_version < 29630) {
if (!is_multisite() && false === get_option('WPLANG')) {
if (defined('WPLANG') && '' !== WPLANG && in_array(WPLANG, get_available_languages())) {
update_option('WPLANG', WPLANG);
} else {
update_option('WPLANG', '');
}
}
}
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:18,代码来源:upgrade.php
示例20: wp_download_language_pack
/**
* Download a language pack.
*
* @since 4.0.0
*
* @see wp_get_available_translations()
*
* @param string $download Language code to download.
* @return string|bool Returns the language code if successfully downloaded
* (or already installed), or false on failure.
*/
function wp_download_language_pack($download)
{
// Check if the translation is already installed.
if (in_array($download, get_available_languages())) {
return $download;
}
if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
return false;
}
// Confirm the translation is one we can download.
$translations = wp_get_available_translations();
if (!$translations) {
return false;
}
foreach ($translations as $translation) {
if ($translation['language'] === $download) {
$translation_to_load = true;
break;
}
}
if (empty($translation_to_load)) {
return false;
}
$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 (!$result || is_wp_error($result)) {
return false;
}
return $translation->language;
}
开发者ID:johnpbloch,项目名称:wordpress,代码行数:45,代码来源:translation-install.php
注:本文中的get_available_languages函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论