本文整理汇总了PHP中qtrans_getSortedLanguages函数的典型用法代码示例。如果您正苦于以下问题:PHP qtrans_getSortedLanguages函数的具体用法?PHP qtrans_getSortedLanguages怎么用?PHP qtrans_getSortedLanguages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qtrans_getSortedLanguages函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_languages
/**
* get actived languages
* @return array
*/
public static function get_languages()
{
$active_langs = array();
if (function_exists('qtrans_getSortedLanguages')) {
$active_langs = qtrans_getSortedLanguages();
}
return $active_langs;
}
示例2: get_active_language
/**
* Get the active language.
*/
public function get_active_language($language)
{
if (empty($_COOKIE['qtrans_edit_language']) === false) {
$enabledLanguages = qtrans_getSortedLanguages();
if (in_array($_COOKIE['qtrans_edit_language'], $enabledLanguages)) {
$language = $_COOKIE['qtrans_edit_language'];
}
}
return $language;
}
示例3: render_field
function render_field($field)
{
global $q_config;
$languages = qtrans_getSortedLanguages(true);
$values = qtrans_split($field['value'], $quicktags = true);
$currentLanguage = $this->plugin->get_active_language();
// vars
$o = array('id', 'class', 'name', 'placeholder', 'rows');
$s = array('readonly', 'disabled');
$e = '';
// maxlength
if ($field['maxlength'] !== '') {
$o[] = 'maxlength';
}
// rows
if (empty($field['rows'])) {
$field['rows'] = 8;
}
// populate atts
$atts = array();
foreach ($o as $k) {
$atts[$k] = $field[$k];
}
// special atts
foreach ($s as $k) {
if ($field[$k]) {
$atts[$k] = $k;
}
}
// render
$e .= '<div class="acf-input-wrap multi-language-field">';
foreach ($languages as $language) {
$class = $language === $currentLanguage ? 'wp-switch-editor current-language' : 'wp-switch-editor';
$e .= '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
}
foreach ($languages as $language) {
$atts['class'] = $field['class'];
if ($language === $currentLanguage) {
$atts['class'] .= ' current-language';
}
$atts['name'] = $field['name'] . "[{$language}]";
$atts['data-language'] = $language;
$e .= '<textarea ' . acf_esc_attr($atts) . ' >';
$e .= esc_textarea($values[$language]);
$e .= '</textarea>';
}
$e .= '</div>';
// return
echo $e;
}
示例4: showLangSwitcher
/**
* Показывает переключатель языков в виде ненумерованного списка
*
* @param $ulClasses
* @param string $linkActiveClass
* @param bool $echo
*
* @return string
*/
public function showLangSwitcher($ulClasses, $linkActiveClass = 'active', $echo = TRUE)
{
$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$result = '<ul class="' . $ulClasses . '">';
foreach (qtrans_getSortedLanguages() as $lang) {
$isActive = $lang == $GLOBALS['q_config']['language'] ? ' class="' . $linkActiveClass . '" ' : '';
$result .= '<li><a href="' . qtrans_convertURL($url, $lang) . '" ' . $isActive . '>' . $lang . '</a></li>';
}
$result .= '</ul>';
if ($echo) {
echo $result;
return;
}
return $result;
}
示例5: create_field
function create_field($field)
{
global $q_config;
$languages = qtrans_getSortedLanguages(true);
$values = qtrans_split($field['value'], $quicktags = true);
$currentLanguage = $this->plugin->get_active_language();
echo '<div class="multi-language-field">';
foreach ($languages as $language) {
$class = $language === $currentLanguage ? 'wp-switch-editor current-language' : 'wp-switch-editor';
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
}
foreach ($languages as $language) {
$class = $language === $currentLanguage ? $field['class'] . ' current-language' : $field['class'];
echo '<textarea data-language="' . esc_attr($language) . '" id="' . esc_attr($field['id']) . '" rows="4" class="' . esc_attr($class) . '" name="' . esc_attr($field['name'] . "[{$language}]") . '">' . esc_textarea($values[$language]) . '</textarea>';
}
echo '</div>';
}
示例6: create_field
function create_field($field)
{
if (!acf_qtranslate_enabled()) {
acf_field_textarea::create_field($field);
return;
}
global $q_config;
$languages = qtrans_getSortedLanguages(true);
$values = qtrans_split($field['value'], $quicktags = true);
echo '<div class="multi-language-field">';
foreach ($languages as $language) {
$class = $language === end($languages) ? 'wp-switch-editor current-language' : 'wp-switch-editor';
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
}
foreach ($languages as $language) {
$class = $language === end($languages) ? $field['class'] . ' current-language' : $field['class'];
echo '<textarea data-language="' . esc_attr($language) . '" id="' . esc_attr($field['id']) . '" rows="4" class="' . esc_attr($class) . '" name="' . esc_attr($field['name'] . "[{$language}]") . '">' . esc_textarea($values[$language]) . '</textarea>';
}
echo '</div>';
}
示例7: html
/**
* Get field HTML
*
* @param string $html
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($html, $meta, $field)
{
$html = '';
//$getall ='';
$i = 0;
if (!is_array($meta)) {
$meta['default'] = isset($meta['defalut']) ? $meta['defalut'] : '';
if (function_exists(qtrans_getSortedLanguages)) {
$languages = qtrans_getSortedLanguages();
foreach ($languages as $lang) {
$meta[$lang] = isset($meta[$lang]) ? $meta[$lang] : '';
}
}
}
$html .= sprintf('<span style="display: block;">Default</span> <input type="text" name="%s[default]" id="%s[default]" value="%s" size="%s" class="rwmb-text %s"/>' . '<br />', $field['field_name'], $field['id'], $meta['default'], $field['size'], $field['class']);
if (function_exists(qtrans_getSortedLanguages)) {
$languages = qtrans_getSortedLanguages();
//print_r($languages);
foreach ($languages as $lang) {
//$meta = $lang;
$i++;
// $html .= 'jfslfjsldfj '.$i++;
// $html .= 'xxx '.$i++;
$html .= sprintf('<span style="display: block;">' . qtrans_getLanguageName($lang) . '</span> <input type="text" class="rwmb-text" name="%s[' . $lang . ']" id="%s[' . $lang . ']" value="%s" size="%s" />' . '<br />', $field['field_name'], $field['id'], $meta[$lang], $field['size']);
//$getall .= '[:'.$lang.']'.$meta[$lang].' ';
//save( $new, $old, $post_id, $field )
//save( $new, $old, $post_id, $field );
}
}
//$html .=$field['id'];
//$html .=$field['field_name'];
//$field['field_name['translate']'] = 'paijo';
/* $html .= sprintf('<input type="hidden" name="%s['."translate".']" id="%s" value="'.$getall.'" />',
$field['field_name'],
$field['id']
); */
//var_dump($getall);
return $html;
}
示例8: qtrans_getLanguageLinks
function qtrans_getLanguageLinks($style = '', $id = '')
{
if (function_exists('qtrans_init')) {
global $q_config;
if ($style == '') {
$style = 'text';
}
if (is_bool($style) && $style) {
$style = 'image';
}
if (is_404()) {
$url = get_option('home');
} else {
$url = '';
}
if ($id == '') {
$id = 'qtranslate';
}
$id .= '-chooser';
switch ($style) {
case 'image':
case 'text':
case 'dropdown':
echo '<ul class="qtrans_language_chooser" id="' . $id . '">';
foreach (qtrans_getSortedLanguages() as $language) {
echo '<li';
if ($language == $q_config['language']) {
echo ' class="active"';
}
echo '><a href="' . qtrans_convertURL($url, $language) . '"';
// set hreflang
echo ' hreflang="' . $language . '" title="' . $q_config['language_name'][$language] . '"';
echo '><span';
echo '>' . $q_config['language_name'][$language] . '</span></a></li>';
}
echo "</ul><div class=\"qtrans_widget_end\"></div>";
}
}
}
示例9: qtrans_generate_language_list
/**
* Language list Code for non-Widget users
*
* @global array $q_config
* @param string $sep
*/
function qtrans_generate_language_list($sep = " | ")
{
global $q_config;
$languages = qtrans_getSortedLanguages();
$num_langs = count($languages);
$id = 'qtranslate-chooser';
$url = is_404() ? get_option('home') : '';
echo '<div class="qtrans_language_chooser" id="' . $id . '">';
foreach ($languages as $language) {
$classes = array('lang-' . $language);
if ($language == $q_config['language']) {
$classes[] = 'active';
}
echo '<span class="' . implode(' ', $classes) . '"><a href="' . qtrans_convertURL($url, $language) . '"';
echo ' hreflang="' . $language . '" title="' . $q_config['language_name'][$language] . '"';
echo '>' . $q_config['language_name'][$language] . '</a></span>';
if (--$num_langs > 0) {
echo '<span class="qtrans_separator">' . $sep . '</span>';
}
}
echo "</div>";
}
示例10: qtrans_showAllSeperated
function qtrans_showAllSeperated($text)
{
if (empty($text)) {
return $text;
}
global $q_config;
$result = "";
foreach (qtrans_getSortedLanguages() as $language) {
$result .= $q_config['language_name'][$language] . ":\n" . qtrans_use($language, $text) . "\n\n";
}
return $result;
}
示例11: check
/**
* Check for qTranslate existance
*
* @return boolean Indicates if the plugin is enabled.
*/
static function check()
{
# Check for qTranslate's existance
return function_exists('qtrans_getSortedLanguages') && count(qtrans_getSortedLanguages()) > 1;
}
示例12: alo_em_get_all_languages
/**
* Return an array with availables languages
* @param by_users if true and no other translation plugins get all langs chosen by users, if not only langs installed on blog
*/
function alo_em_get_all_languages($fallback_by_users = false)
{
global $wp_version, $alo_em_all_languages;
if (empty($alo_em_all_languages)) {
// Choice by custom filters
$langs_by_filter = apply_filters('alo_easymail_multilang_get_all_languages', false, $fallback_by_users);
// Hook
if (!empty($langs_by_filter) && is_array($langs_by_filter)) {
$alo_em_all_languages = $langs_by_filter;
} elseif (alo_em_multilang_enabled_plugin() == "qTrans" && function_exists('qtrans_getSortedLanguages')) {
$alo_em_all_languages = qtrans_getSortedLanguages();
} elseif (alo_em_multilang_enabled_plugin() == "WPML" && function_exists('icl_get_languages')) {
$languages = icl_get_languages('skip_missing=0&orderby=code');
if (is_array($languages)) {
$alo_em_all_languages = array_keys($languages);
}
} elseif (get_option('alo_em_langs_list') != "") {
$languages = explode(",", get_option('alo_em_langs_list'));
// If languages, add locale lang (if not yet) and return
if (!empty($languages[0])) {
$default = alo_em_short_langcode(get_locale());
if (!in_array($default, $languages)) {
$languages[] = $default;
}
$alo_em_all_languages = $languages;
}
} elseif ($fallback_by_users) {
$alo_em_all_languages = alo_em_get_all_languages_by_users();
} else {
$alo_em_all_languages = array(alo_em_short_langcode(get_locale()));
}
}
return $alo_em_all_languages;
}
示例13: cs_language_defaults
function cs_language_defaults()
{
$multilang = array();
if (cs_is_wpml_activated() || cs_is_qtranslate_activated() || cs_is_polylang_activated()) {
if (cs_is_wpml_activated()) {
global $sitepress;
$multilang['default'] = $sitepress->get_default_language();
$multilang['current'] = $sitepress->get_current_language();
$multilang['languages'] = $sitepress->get_active_languages();
} else {
if (cs_is_polylang_activated()) {
global $polylang;
$current = pll_current_language();
$default = pll_default_language();
$current = empty($current) ? $default : $current;
$poly_langs = $polylang->model->get_languages_list();
$languages = array();
foreach ($poly_langs as $p_lang) {
$languages[$p_lang->slug] = $p_lang->slug;
}
$multilang['default'] = $default;
$multilang['current'] = $current;
$multilang['languages'] = $languages;
} else {
if (cs_is_qtranslate_activated()) {
global $q_config;
$multilang['default'] = $q_config['default_language'];
$multilang['current'] = $q_config['language'];
$multilang['languages'] = array_flip(qtrans_getSortedLanguages());
}
}
}
}
$multilang = apply_filters('cs_language_defaults', $multilang);
return !empty($multilang) ? $multilang : false;
}
示例14: render_field
function render_field($field)
{
// enqueue
acf_enqueue_uploader();
// vars
$id = uniqid('acf-editor-');
//$id = $field['id'] . '-' . uniqid();
$mode = 'html';
$show_tabs = true;
// get height
$height = acf_get_user_setting('wysiwyg_height', 300);
$height = max($height, 300);
// minimum height is 300
// detect mode
// case: visual tab only
if ($field['tabs'] == 'visual') {
$mode = 'tmce';
$show_tabs = false;
} elseif ($field['tabs'] == 'text') {
$show_tabs = false;
} elseif (wp_default_editor() == 'tinymce') {
$mode = 'tmce';
}
// mode
$switch_class = $mode . '-active';
// filter value for editor
remove_all_filters('acf_the_editor_content');
if ($mode == 'tmce') {
add_filter('acf_the_editor_content', 'wp_richedit_pre');
} else {
add_filter('acf_the_editor_content', 'wp_htmledit_pre');
}
global $q_config, $wp_version;
$languages = qtrans_getSortedLanguages(true);
$values = qtrans_split($field['value'], $quicktags = true);
$currentLanguage = $this->plugin->get_active_language();
echo '<div class="multi-language-field multi-language-field-wysiwyg">';
foreach ($languages as $language) {
$class = $language === $currentLanguage ? 'wp-switch-editor current-language' : 'wp-switch-editor';
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
}
$uid = uniqid('acf-editor-');
foreach ($languages as $language) {
$value = apply_filters('acf_the_editor_content', $values[$language]);
$id = $uid . "-{$language}";
$name = $field['name'] . "[{$language}]";
$class = $switch_class;
if ($language === $currentLanguage) {
$class .= ' current-language';
}
?>
<div id="wp-<?php
echo $id;
?>
-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php
echo $class;
?>
" data-toolbar="<?php
echo $field['toolbar'];
?>
" data-upload="<?php
echo $field['media_upload'];
?>
" data-language="<?php
echo $language;
?>
">
<div id="wp-<?php
echo $id;
?>
-editor-tools" class="wp-editor-tools hide-if-no-js">
<?php
if ($field['media_upload']) {
?>
<div id="wp-<?php
echo $id;
?>
-media-buttons" class="wp-media-buttons">
<?php
do_action('media_buttons');
?>
</div>
<?php
}
?>
<?php
if (user_can_richedit() && $show_tabs) {
?>
<div class="wp-editor-tabs">
<button id="<?php
echo $id;
?>
-tmce" class="wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);" type="button"><?php
echo __('Visual', 'acf');
?>
</button>
<button id="<?php
echo $id;
?>
-html" class="wp-switch-editor switch-html" onclick="switchEditors.switchto(this);" type="button"><?php
//.........这里部分代码省略.........
示例15: bloginfo
?>
</span></a></h2>
</div>
<div class="description"><?php
bloginfo('description');
?>
</div>
<div id="head-menu">
<ul id="header-nav">
<?php
wp_list_pages('child_of=10&depth=1&title_li=&sort_column=menu_order');
?>
</ul>
<ul id="head-idioma">
<?php
foreach (qtrans_getSortedLanguages() as $language) {
?>
<li class="flag_<?php
echo $language;
?>
<?php
if ($language == $q_config['language']) {
echo ' class="active"';
}
?>
">
<a href="<?php
echo qtrans_convertURL($url, $language);
?>
" ><span><?php
echo $language;