本文整理汇总了PHP中wp_dropdown_languages函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_dropdown_languages函数的具体用法?PHP wp_dropdown_languages怎么用?PHP wp_dropdown_languages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_dropdown_languages函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
}
示例2: test_wp_dropdown_languages
/**
* @ticket 35294
*/
function test_wp_dropdown_languages()
{
$args = array('id' => 'foo', 'name' => 'bar', 'languages' => array('de_DE'), 'translations' => $this->wp_dropdown_languages_filter(), 'selected' => 'de_DE', 'echo' => false);
$actual = wp_dropdown_languages($args);
$this->assertContains('id="foo"', $actual);
$this->assertContains('name="bar"', $actual);
$this->assertContains('<option value="" lang="en" data-installed="1">English (United States)</option>', $actual);
$this->assertContains('<option value="de_DE" lang="de" selected=\'selected\' data-installed="1">Deutsch</option>', $actual);
$this->assertContains('<option value="it_IT" lang="it">Italiano</option>', $actual);
}
示例3: _e
$languages[] = WPLANG;
}
if (!empty($languages) || !empty($translations)) {
?>
<tr>
<th width="33%" scope="row"><label for="WPLANG"><?php
_e('Site Language');
?>
</label></th>
<td>
<?php
$locale = get_locale();
if (!in_array($locale, $languages)) {
$locale = '';
}
wp_dropdown_languages(array('name' => 'WPLANG', 'id' => 'WPLANG', 'selected' => $locale, 'languages' => $languages, 'translations' => $translations, 'show_available_translations' => (!is_multisite() || is_super_admin()) && wp_can_install_language_pack()));
// Add note about deprecated WPLANG constant.
if (defined('WPLANG') && '' !== WPLANG && $locale !== WPLANG) {
if (is_super_admin()) {
?>
<p class="description">
<strong><?php
_e('Note:');
?>
</strong> <?php
printf(__('The %s constant in your %s file is no longer needed.'), '<code>WPLANG</code>', '<code>wp-config.php</code>');
?>
</p>
<?php
}
_deprecated_argument('define()', '4.0', sprintf(__('The %s constant in your %s file is no longer needed.'), 'WPLANG', 'wp-config.php'));
示例4: _e
_e('Language Settings');
?>
</h3>
<table class="form-table">
<tr>
<th><label for="WPLANG"><?php
_e('Default Language');
?>
</label></th>
<td>
<?php
$lang = get_site_option('WPLANG');
if (!in_array($lang, $languages)) {
$lang = '';
}
wp_dropdown_languages(array('name' => 'WPLANG', 'id' => 'WPLANG', 'selected' => $lang, 'languages' => $languages));
?>
</td>
</tr>
</table>
<?php
}
?>
<h3><?php
_e('Menu Settings');
?>
</h3>
<table id="menu" class="form-table">
<tr>
<th scope="row"><?php
示例5: _e
_e('Language Settings');
?>
</h3>
<table class="form-table">
<tr>
<th><label for="WPLANG"><?php
_e('Default Language');
?>
</label></th>
<td>
<?php
$lang = get_site_option('WPLANG');
if (!in_array($lang, $languages)) {
$lang = '';
}
wp_dropdown_languages(array('name' => 'WPLANG', 'id' => 'WPLANG', 'selected' => $lang, 'languages' => $languages, 'translations' => $translations, 'show_available_translations' => wp_can_install_language_pack()));
?>
</td>
</tr>
</table>
<?php
}
?>
<h3><?php
_e('Menu Settings');
?>
</h3>
<table id="menu" class="form-table">
<tr>
<th scope="row"><?php
示例6: _e
<th scope="row">
<label for="site_language"><?php
_e('Site Language');
?>
</label>
</th>
<td>
<?php
$user_locale = get_user_option('locale', $profileuser->ID);
if ('en_US' === $user_locale) {
// en_US
$user_locale = false;
} elseif (!in_array($user_locale, $languages, true)) {
$user_locale = get_locale();
}
wp_dropdown_languages(array('name' => 'locale', 'id' => 'locale', 'selected' => $user_locale, 'languages' => $languages, 'show_available_translations' => false));
?>
</td>
</tr>
<?php
}
?>
<?php
/**
* Fires at the end of the 'Personal Options' settings table on the user editing screen.
*
* @since 2.7.0
*
* @param WP_User $profileuser The current WP_User object.
*/
示例7: show_blog_form
/**
* Generates and displays the Signup and Create Site forms
*
* @since MU
*
* @param string $blogname The new site name.
* @param string $blog_title The new site title.
* @param WP_Error|string $errors A WP_Error object containing existing errors. Defaults to empty string.
*/
function show_blog_form($blogname = '', $blog_title = '', $errors = '')
{
if (!is_wp_error($errors)) {
$errors = new WP_Error();
}
$current_network = get_network();
// Blog name
if (!is_subdomain_install()) {
echo '<label for="blogname">' . __('Site Name:') . '</label>';
} else {
echo '<label for="blogname">' . __('Site Domain:') . '</label>';
}
if ($errmsg = $errors->get_error_message('blogname')) {
?>
<p class="error"><?php
echo $errmsg;
?>
</p>
<?php
}
if (!is_subdomain_install()) {
echo '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span><input name="blogname" type="text" id="blogname" value="' . esc_attr($blogname) . '" maxlength="60" /><br />';
} else {
echo '<input name="blogname" type="text" id="blogname" value="' . esc_attr($blogname) . '" maxlength="60" /><span class="suffix_address">.' . ($site_domain = preg_replace('|^www\\.|', '', $current_network->domain)) . '</span><br />';
}
if (!is_user_logged_in()) {
if (!is_subdomain_install()) {
$site = $current_network->domain . $current_network->path . __('sitename');
} else {
$site = __('domain') . '.' . $site_domain . $current_network->path;
}
/* translators: %s: site address */
echo '<p>(<strong>' . sprintf(__('Your address will be %s.'), $site) . '</strong>) ' . __('Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!') . '</p>';
}
// Blog Title
?>
<label for="blog_title"><?php
_e('Site Title:');
?>
</label>
<?php
if ($errmsg = $errors->get_error_message('blog_title')) {
?>
<p class="error"><?php
echo $errmsg;
?>
</p>
<?php
}
echo '<input name="blog_title" type="text" id="blog_title" value="' . esc_attr($blog_title) . '" />';
?>
<?php
// Site Language.
$languages = signup_get_available_languages();
if (!empty($languages)) {
?>
<p>
<label for="site-language"><?php
_e('Site Language:');
?>
</label>
<?php
// Network default.
$lang = get_site_option('WPLANG');
if (isset($_POST['WPLANG'])) {
$lang = $_POST['WPLANG'];
}
// Use US English if the default isn't available.
if (!in_array($lang, $languages)) {
$lang = '';
}
wp_dropdown_languages(array('name' => 'WPLANG', 'id' => 'site-language', 'selected' => $lang, 'languages' => $languages, 'show_available_translations' => false));
?>
</p>
<?php
}
// Languages.
?>
<div id="privacy">
<p class="privacy-intro">
<label for="blog_public_on"><?php
_e('Privacy:');
?>
</label>
<?php
_e('Allow search engines to index this site.');
?>
<br style="clear:both" />
<label class="checkbox" for="blog_public_on">
//.........这里部分代码省略.........
示例8: _e
<?php
namespace admin_language_per_user;
?>
<table class="form-table">
<tr>
<th scope="row">
<label for="<?php
echo self::meta_name;
?>
"><?php
_e('Site Language');
?>
</label>
</th>
<td>
<?php
wp_dropdown_languages(array('name' => self::meta_name, 'id' => self::meta_name, 'selected' => $locale, 'languages' => $languages, 'translations' => $translations, 'show_available_translations' => false));
?>
</td>
</tr>
</table><?php
示例9: locale_dropdown_meta_box_callback
/**
* Print language locale dropdown meta-box
*
* @from 1.0
*/
public function locale_dropdown_meta_box_callback($post)
{
global $sublanguage_admin;
wp_nonce_field('language_locale_dropdown_action', 'language_locale_dropdown_nonce');
wp_dropdown_languages(array('selected' => '', 'languages' => array_filter($sublanguage_admin->get_language_column('post_content')), 'name' => 'language_locale_dropdown', 'id' => 'language_locale_dropdown'));
}
示例10: fallback_locale_field
/**
* Download the chosen fallback language on save and create the language dropdown similar to the default language dropdown
*/
public function fallback_locale_field()
{
$languages = get_available_languages();
$translations = wp_get_available_translations();
$fallback_locale = $this->fallback_locale;
// Handle translation install.
if (!empty($fallback_locale) && !in_array($fallback_locale, $languages) && (!is_multisite() || is_super_admin())) {
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
if (wp_can_install_language_pack()) {
$language = wp_download_language_pack($fallback_locale);
if ($language) {
$fallback_locale = $language;
}
}
}
wp_dropdown_languages(array('name' => 'fallback_locale', 'id' => 'fallback_locale', 'selected' => $fallback_locale, 'languages' => $languages, 'translations' => $translations, 'show_available_translations' => (!is_multisite() || is_super_admin()) && wp_can_install_language_pack()));
}