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


PHP qtranxf_convertURL函数代码示例

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


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

示例1: qtrans_in_nav_el

 function qtrans_in_nav_el($item_output, $item, $depth, $args)
 {
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     /*
         Example link: http://google.com|en|http://google.com.ua|ua|
     */
     if (preg_match_all('~(.*?)\\|(\\w{2,})\\|~', $item->url, $matches)) {
         $ext_url = '';
         foreach ($matches[1] as $i => $match) {
             $ext_url .= "[:{$matches[2][$i]}]{$match}";
         }
         $item->url = esc_attr(__($ext_url));
     }
     // Determine integration with qTranslate Plugin
     if (function_exists('qtranxf_convertURL')) {
         $attributes .= !empty($item->url) ? ' href="' . qtranxf_convertURL(esc_attr($item->url)) . '"' : '';
     } else {
         $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     }
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= '</a>';
     $item_output .= $args->after;
     return $item_output;
 }
开发者ID:Tusko,项目名称:WP-Anatomy,代码行数:28,代码来源:qtranslate.php

示例2: convertURL

 public function convertURL($url, $lang = '')
 {
     if (function_exists('qtranxf_convertURL')) {
         return qtranxf_convertURL($url, $lang);
     } else {
         return qtrans_convertURL($url, $lang);
     }
 }
开发者ID:HuyNguyen11,项目名称:testsite,代码行数:8,代码来源:qtranslate-support-for-woocommerce.php

示例3: qtrans_in_nav_el

 function qtrans_in_nav_el($item_output, $item, $depth, $args)
 {
     $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
     $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
     $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
     // Determine integration with qTranslate Plugin
     if (function_exists('qtranxf_convertURL')) {
         $attributes .= !empty($item->url) ? ' href="' . qtranxf_convertURL(esc_attr($item->url)) . '"' : '';
     } else {
         $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
     }
     $item_output = $args->before;
     $item_output .= '<a' . $attributes . '>';
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
     $item_output .= '</a>';
     $item_output .= $args->after;
     return $item_output;
 }
开发者ID:iceanothers,项目名称:wp-skillet,代码行数:18,代码来源:init.php

示例4: wpa_qtrans_site_url

function wpa_qtrans_site_url($url)
{
    // you probably don't want this in admin side
    if (is_admin()) {
        return $url;
    }
    return function_exists('qtranxf_convertURL') ? qtranxf_convertURL($url) : $url;
}
开发者ID:Rostyk27,项目名称:themewp,代码行数:8,代码来源:themer.php

示例5: qtranxf_conf


//.........这里部分代码省略.........
            ?>
</th>
				<td><p class="qtranxs_explanation"><?php 
            echo __('Every multilingual field is expected to have a meaningful content in the "Default Language". Usually, it is the language of your site before it became multilingual.', 'qtranslate');
            echo ' ';
            echo __('Order of languages defines in which order they are listed, when languages need to be listed, otherwise it is not important.', 'qtranslate');
            ?>
</p>
					<fieldset id="qtranxs-languages-menu">
					<legend class="hidden"><?php 
            _e('Default Language', 'qtranslate');
            ?>
</legend>
					<table id="qtranxs-enabled-languages">
				<?php 
            $flag_location = qtranxf_flag_location();
            foreach (qtranxf_getSortedLanguages() as $key => $language) {
                echo '<tr>';
                echo '<td><label title="' . $q_config['language_name'][$language] . '"><input type="radio" name="default_language" value="' . $language . '"';
                checked($language, $q_config['default_language']);
                echo ' />';
                echo ' <a href="' . add_query_arg('moveup', $language, $clean_uri) . '"><img src="' . $pluginurl . 'arrowup.png" alt="up" /></a>';
                echo ' <a href="' . add_query_arg('movedown', $language, $clean_uri) . '"><img src="' . $pluginurl . 'arrowdown.png" alt="down" /></a>';
                echo ' <img src="' . $flag_location . $q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" /> ';
                echo ' ' . $q_config['language_name'][$language];
                echo '</label></td>';
                echo '<td>[:' . $language . ']</td><td><a href="' . $clean_uri . '&edit=' . $language . '">' . __('Edit', 'qtranslate') . '</a></td><td><a href="' . $clean_uri . '&disable=' . $language . '">' . __('Disable', 'qtranslate') . '</a></td>';
                echo '</tr>' . PHP_EOL;
            }
            ?>
					</table>
					<p class="qtranxs_notes"><?php 
            $url = get_bloginfo('url');
            $url = qtranxf_convertURL($url, $q_config['default_language'], true);
            printf(__('Choose the default language of your blog. This is the language which will be shown on %s. You can also change the order the languages by clicking on the arrows above.', 'qtranslate'), $url);
            ?>
</p>
					</fieldset>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row"><?php 
            _e('URL Modification Mode', 'qtranslate');
            ?>
</th>
				<td>
					<?php 
            if ($permalink_is_query) {
                ?>
					<p><?php 
                printf(__('Use one of the pretty %spermalinks%s, if the desirable mode is disabled.', 'qtranslate'), '<a href="' . admin_url('options-permalink.php') . '">', '</a>');
                ?>
</p>
					<?php 
            }
            ?>
					<fieldset><legend class="hidden"><?php 
            _e('URL Modification Mode', 'qtranslate');
            ?>
</legend>
						<label title="Query Mode"><input type="radio" name="url_mode" value="<?php 
            echo QTX_URL_QUERY;
            ?>
" <?php 
            checked($url_mode, QTX_URL_QUERY);
            ?>
开发者ID:Krishan19,项目名称:qtranslate-x,代码行数:67,代码来源:qtx_configuration.php

示例6: qtrans_convertURL

 function qtrans_convertURL($url = '', $lang = '', $forceadmin = false, $showDefaultLanguage = false)
 {
     return qtranxf_convertURL($url, $lang, $forceadmin, $showDefaultLanguage);
 }
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:4,代码来源:qtranslate_compatibility.php

示例7: qtranxf_convertBlogInfoURL

/**
 * @since 3.2.8 moved here from _hooks.php
 */
function qtranxf_convertBlogInfoURL($url, $what)
{
    switch ($what) {
        case 'stylesheet_url':
        case 'template_url':
        case 'template_directory':
        case 'stylesheet_directory':
            return $url;
        default:
            return qtranxf_convertURL($url);
    }
}
开发者ID:ycms,项目名称:framework,代码行数:15,代码来源:qtranslate_frontend.php

示例8: qtranxf_customize_allowed_urls

function qtranxf_customize_allowed_urls($urls)
{
    global $q_config;
    $home = home_url('/', is_ssl() ? 'https' : 'http');
    $urls[] = $home;
    foreach ($q_config['enabled_languages'] as $lang) {
        $url = qtranxf_convertURL($home, $lang, true, true);
        $urls[] = $url;
    }
    if ($q_config['hide_default_language']) {
        $urls[] = qtranxf_convertURL($home, $q_config['default_language'], true, false);
    }
    return $urls;
}
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:14,代码来源:qtx_admin.php

示例9: qtranxf_use_block

function qtranxf_use_block($lang, $blocks, $show_available = false, $show_empty = false)
{
    global $q_config;
    $content = qtranxf_split_blocks($blocks);
    // if content is available show the content in the requested language
    if (!empty($content[$lang])) {
        return $content[$lang];
    } elseif ($show_empty) {
        return '';
    }
    // content is not available in requested language (bad!!) what now?
    // find available and alternative languages
    if (empty($content[$q_config['default_language']])) {
        $alt_lang = null;
        $alt_content = null;
        $alt_lang_is_default = false;
    } else {
        $alt_lang = $q_config['default_language'];
        $alt_content = $content[$alt_lang];
        $alt_lang_is_default = true;
    }
    $available_languages = array();
    foreach ($content as $language => $lang_text) {
        if (empty($lang_text)) {
            continue;
        }
        if (!qtranxf_isEnabled($language)) {
            continue;
        }
        $available_languages[] = $language;
        if (empty($alt_lang)) {
            $alt_lang = $language;
            $alt_content = $lang_text;
        }
    }
    if (!$alt_lang) {
        return '';
    }
    if (!$show_available) {
        if ($q_config['show_displayed_language_prefix']) {
            return '(' . $q_config['language_name'][$alt_lang] . ') ' . $alt_content;
        } else {
            return $alt_content;
        }
        /*
        	// check if content is available in default language, if not return first language found. (prevent empty result)
        	$language = $q_config['default_language'];
        	if(!isset($available_languages[$language])){
        		
        	}
        	if($lang!=$q_config['default_language']){
        		$language = $q_config['default_language'];
        		$lang_text = $content[$language];
        		//$lang_text = trim($lang_text);
        		if(!empty($lang_text)){
        			if ($q_config['show_displayed_language_prefix'])
        				return '('.$q_config['language_name'][$language].') '.$lang_text;
        			else
        				return $lang_text;
        		}
        	}
        	foreach($content as $language => $lang_text) {
        		$lang_text = trim($lang_text);
        		if(empty($lang_text)) continue;
        		if ($q_config['show_displayed_language_prefix'])
        			return '('.$q_config['language_name'][$language].') '.$lang_text;
        		else
        			return $lang_text;
        	}
        */
    }
    // display selection for available languages
    //$available_languages = array_unique($available_languages);
    $language_list = '';
    if (preg_match('/%LANG:([^:]*):([^%]*)%/', $q_config['not_available'][$lang], $match)) {
        $normal_separator = $match[1];
        $end_separator = $match[2];
        // build available languages string backward
        $i = 0;
        foreach ($available_languages as $language) {
            if ($i == 1) {
                $language_list = $end_separator . $language_list;
            }
            if ($i > 1) {
                $language_list = $normal_separator . $language_list;
            }
            $language_list = '<a href="' . qtranxf_convertURL('', $language, false, true) . '">' . $q_config['language_name'][$language] . '</a>' . $language_list;
            ++$i;
        }
    }
    //qtranxf_dbg_echo('$language_list=',$language_list,true);
    //if(isset($post)){
    //	//qtranxf_dbg_echo('$post='.$post);
    //}
    if (!empty($q_config['show_alternative_content']) && $q_config['show_alternative_content']) {
        // show content in  alternative language
        if (sizeof($available_languages) > 1) {
            if ($alt_lang_is_default) {
                //$fmt = __('For the sake of viewer convenience, the content is shown below in this site default language %s.', 'qtranslate');
                $msg = __('For the sake of viewer convenience, the content is shown below in this site default language.', 'qtranslate');
//.........这里部分代码省略.........
开发者ID:ycms,项目名称:framework,代码行数:101,代码来源:qtranslate_core.php

示例10: qwpseo_xmlsitemaps_config

/**
 * adds single-language sitemap links to the Yoast configuration page for XML Sitemaps.
*/
function qwpseo_xmlsitemaps_config()
{
    global $q_config;
    $options = get_option('wpseo_xml');
    //qtranxf_dbg_log('qwpseo_xmlsitemaps_config: $options: ',$options);
    if (empty($options['enablexmlsitemap'])) {
        return;
    }
    printf(__('%sNotes from %s' . PHP_EOL), '<h3>', 'qTranslate&#8209;X</h3>');
    echo '<p>' . PHP_EOL;
    echo __('In addition to main XML Sitemap, you may also view sitemaps for each individual language:') . PHP_EOL;
    echo '<ul>' . PHP_EOL;
    $sitemap_index_url = qtranxf_convertURL(get_option('home') . '/sitemap_index.xml', $q_config['default_language'], true);
    $url = home_url('i18n-index-sitemap.xml');
    $rb = '';
    foreach ($q_config['enabled_languages'] as $lang) {
        $href = qtranxf_convertURL($url, $lang, true, true);
        $u = $q_config['default_language'] == $lang ? qtranxf_convertURL($url, $lang, true, false) : $href;
        echo '<li>' . $q_config['language_name'][$lang] . ' (' . $lang . ', ' . $q_config['locale'][$lang] . '): <a href="' . $href . '" target="_blank">' . $u . '</a></li>' . PHP_EOL;
        $rb .= 'Sitemap: ' . $u . PHP_EOL;
    }
    echo '</ul><br />' . PHP_EOL;
    printf(__('It is advisable to append the site\'s "%s" with the list of index sitemaps separated by language'), '/robots.txt');
    $nmaps = count($q_config['enabled_languages']) + 1;
    echo '<br /><textarea class="widefat" rows="' . $nmaps . '" name="robots-sitemaps" readonly="readonly">' . $rb . '</textarea>' . PHP_EOL;
    //echo '<pre>'.$rb.'</pre>'.PHP_EOL;
    echo '<br />or with this single entry of flat multilingual index sitemap<br /><textarea class="widefat" rows="2" name="robots-sitemap" readonly="readonly">Sitemap: ' . $sitemap_index_url . '</textarea>' . PHP_EOL;
    echo '<br />Do not combine two sets together, since they both equally cover all languages in all pages as defined by Yoast configuration.';
    echo '</p>' . PHP_EOL;
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:33,代码来源:qwpseo-admin.php

示例11: get_permalink

    $current_url = get_permalink();
}
// Obtaining from Qtranslate
if (function_exists('qtrans_getSortedLanguages')) {
    $current_lang = qtrans_getLanguage();
    $languages = qtrans_getSortedLanguages();
    foreach ($languages as $lang) {
        $display_languages[$lang] = array('name' => $lang, 'url' => qtrans_convertURL($current_url, $lang, 0, 1));
    }
}
// Obtaining from Qtranslate W
if (function_exists('qtranxf_getSortedLanguages')) {
    $current_lang = qtranxf_getLanguage();
    $languages = qtranxf_getSortedLanguages();
    foreach ($languages as $lang) {
        $display_languages[$lang] = array('name' => $lang, 'url' => qtranxf_convertURL($current_url, $lang, 0, 1));
    }
}
// Obtaining from Polylang
if (function_exists('pll_current_language')) {
    global $polylang;
    $current_lang = pll_current_language();
    $poly_langs = pll_the_languages(array('raw' => 1, 'echo' => 0));
    foreach ($poly_langs as $lang) {
        $display_languages[$lang['slug']] = array('name' => $lang['slug'], 'url' => $lang['url']);
    }
}
if (!empty($display_languages)) {
    echo '<div class="languages">';
    foreach ($display_languages as $lang) {
        echo '<a hreflang="' . $lang['name'] . '" ' . ($lang['name'] == $current_lang ? 'class="current"' : '') . ' href="' . $lang['url'] . '"><span>' . $lang['name'] . '</span></a>';
开发者ID:xfifix,项目名称:WPUTheme,代码行数:31,代码来源:languages.php

示例12: qwpseo_sitemap_index

function qwpseo_sitemap_index($sm)
{
    global $q_config, $wpseo_sitemaps;
    if (isset($q_config['sitemap-type'])) {
        return;
    }
    //qtranxf_dbg_log('qwpseo_sitemap_index: $wpseo_sitemaps: ', $wpseo_sitemaps);
    ob_start();
    $wpseo_sitemaps->output();
    $content = ob_get_contents();
    ob_end_clean();
    //qtranxf_dbg_log('qwpseo_sitemap_index: $content: ', $content);
    $p = 0;
    $sitemaps = array();
    while (($p = strpos($content, '<sitemap>', $p)) !== false) {
        if (($e = strpos($content, '</sitemap>', $p)) !== false) {
            $len = $e - $p + strlen('</sitemap>');
            $s = substr($content, $p, $len);
            //qtranxf_dbg_log('qwpseo_sitemap_index: $s: ', $s);
            $p += $len;
            $sitemaps[] = $s;
        } else {
            $p += strlen('<sitemap>');
        }
    }
    $sm = '';
    foreach ($q_config['enabled_languages'] as $lang) {
        //if($lang == $q_config['default_language']) continue;
        if ($lang == $q_config['language']) {
            continue;
        }
        //$sm .= preg_replace('!<loc>(.*)/([^/]+)</loc>!','<loc>$1/'.$lang.'-$2</loc>',$s);
        foreach ($sitemaps as $s) {
            if (preg_match('!<loc>([^<]+)</loc>!', $s, $matches)) {
                $loc = $matches[1];
                $sm .= preg_replace('!<loc>([^<]+)</loc>!', '<loc>' . qtranxf_convertURL($loc, $lang) . '</loc>', $s);
            }
        }
    }
    //qtranxf_dbg_log('qwpseo_sitemap_index: $sm: ', $sm);
    return $sm;
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:42,代码来源:qwpseo-front.php

示例13: language_converturl

 function language_converturl($url = null, $language = null)
 {
     global $slideshow_languageplugin;
     if (!empty($url) && !empty($language)) {
         switch ($slideshow_languageplugin) {
             case 'qtranslate':
                 $url = qtrans_convertURL($url, $language);
                 break;
             case 'qtranslate-x':
                 $url = qtranxf_convertURL($url, $language);
                 break;
             case 'wpml':
                 if (function_exists('icl_get_languages')) {
                     $languages = icl_get_languages();
                     $language = $this->language_current();
                     if (!empty($languages[$language]['url'])) {
                         //$url = $languages[$language]['url'];
                     }
                 }
                 break;
         }
     }
     return $url;
 }
开发者ID:andywgarcia,项目名称:campuslifeohs,代码行数:24,代码来源:slideshow-gallery-plugin.php

示例14: qtranxf_use_block

function qtranxf_use_block($lang, $blocks, $show_available = false, $show_empty = false)
{
    global $q_config;
    //qtranxf_dbg_log('qtranxf_use_language('.$lang.') $text: ', $text);
    //qtranxf_dbg_log('qtranxf_use_language: $blocks: ', $blocks);
    $available_langs = array();
    $content = qtranxf_split_blocks($blocks, $available_langs);
    //qtranxf_dbg_log('qtranxf_use_block: $content: ',$content);
    //qtranxf_dbg_log('qtranxf_use_block: $available_langs: ',$available_langs);
    // if content is available show the content in the requested language
    if (!empty($available_langs[$lang])) {
        return $content[$lang];
    } elseif ($show_empty) {
        return '';
    }
    // content is not available in requested language (bad!!) what now?
    //remove available languages that are not enabled
    foreach ($available_langs as $language => $b) {
        if (qtranxf_isEnabled($language)) {
            continue;
        }
        unset($available_langs[$language]);
    }
    // set alternative language
    if (empty($available_langs[$q_config['default_language']])) {
        $alt_lang = null;
        $alt_content = null;
        $alt_lang_is_default = false;
        foreach ($available_langs as $language => $b) {
            $alt_lang = $language;
            $alt_content = $content[$language];
            break;
        }
    } else {
        $alt_lang = $q_config['default_language'];
        $alt_content = $content[$alt_lang];
        $alt_lang_is_default = true;
    }
    if (!$alt_lang) {
        return '';
    }
    if (!$show_available) {
        if ($q_config['show_displayed_language_prefix']) {
            return '(' . $q_config['language_name'][$alt_lang] . ') ' . $alt_content;
        } else {
            return $alt_content;
        }
    }
    //qtranxf_dbg_log('$alt_content=',$alt_content);
    // display selection for available languages
    $language_list = '';
    if (preg_match('/%LANG:([^:]*):([^%]*)%/', $q_config['not_available'][$lang], $match)) {
        $normal_separator = $match[1];
        $end_separator = $match[2];
        if (!is_textdomain_loaded('language-names')) {
            //is not loaded by default, since this place should not be hit frequently
            $locale = $q_config['locale'][$q_config['language']];
            load_textdomain('language-names', QTRANSLATE_DIR . '/lang/language-names/language-' . $locale . '.mo');
        }
        $translations = get_translations_for_domain('language-names');
        // build available languages string backward
        $i = 0;
        foreach ($available_langs as $language => $b) {
            if ($i == 1) {
                $language_list = $end_separator . $language_list;
            } elseif ($i > 1) {
                $language_list = $normal_separator . $language_list;
            }
            $locale = $q_config['locale'][$language];
            while (!isset($translations->entries[$locale])) {
                if ($locale[2] == '_') {
                    $locale = substr($locale, 0, 2);
                    if (isset($translations->entries[$locale])) {
                        break;
                    }
                }
                $locale = null;
                break;
            }
            if ($locale) {
                $language_name = $translations->entries[$locale]->translations[0];
                $language_name = mb_convert_case($language_name, MB_CASE_TITLE);
            } else {
                $language_name = $q_config['language_name'][$language];
            }
            $language_list = '&ldquo;<a href="' . qtranxf_convertURL('', $language, false, true) . '" class="qtranxs-available-language-link qtranxs-available-language-link-' . $language . '">' . $language_name . '</a>&rdquo;' . $language_list;
            ++$i;
        }
    }
    //qtranxf_dbg_log('$language_list=',$language_list);
    $msg = '';
    if (!empty($q_config['show_alternative_content']) && $q_config['show_alternative_content']) {
        // show content in  alternative language
        if (sizeof($available_langs) > 1) {
            if ($alt_lang_is_default) {
                //$fmt = __('For the sake of viewer convenience, the content is shown below in this site default language %s.', 'qtranslate');
                $msg = __('For the sake of viewer convenience, the content is shown below in this site default language.', 'qtranslate');
            } else {
                //$fmt = __('For the sake of viewer convenience, the content is shown below in an available alternative language %s.', 'qtranslate');
                $msg = __('For the sake of viewer convenience, the content is shown below in one of the available alternative languages.', 'qtranslate');
//.........这里部分代码省略.........
开发者ID:antigenius,项目名称:qtranslate-x,代码行数:101,代码来源:qtranslate_core.php

示例15: qtranxf_generateLanguageSelectCode

/**
 * Language Select Code for non-Widget users
 * @args is a hash array of options, which accepts the following keys:
 *   ‘type’ – one of the values: ‘text’, ‘image’, ‘both’, ‘dropdown’ and ‘custom’, which match the choices on widget admin page.
 *   ‘format’ – needs to be provided if ‘type’ is ‘custom’. Read help text to this option on widget admin page.
 *   ‘id’ – id of widget, which is used as a distinctive string to create CSS entities.
 * @since 3.4.5 type of argument is changed, compatibility with old way is preserved.
*/
function qtranxf_generateLanguageSelectCode($args = array(), $id = '')
{
    global $q_config;
    if (is_string($args)) {
        $type = $args;
    } elseif (is_bool($args) && $args) {
        $type = 'image';
    } elseif (is_array($args)) {
        if (!empty($args['type'])) {
            $type = $args['type'];
        }
        if (empty($id) && !empty($args['id'])) {
            $id = $args['id'];
        }
    }
    if (empty($type)) {
        $type = 'text';
    } else {
        switch ($type) {
            case 'text':
            case 'image':
            case 'both':
            case 'short':
            case 'css_only':
            case 'custom':
            case 'dropdown':
                break;
            default:
                $type = 'text';
        }
    }
    if (empty($id)) {
        $id = 'qtranslate';
    }
    $id .= '-chooser';
    if (is_404()) {
        $url = get_option('home');
    } else {
        $url = '';
    }
    $flag_location = qtranxf_flag_location();
    echo PHP_EOL . '<ul class="language-chooser language-chooser-' . $type . ' qtranxs_language_chooser" id="' . $id . '">' . PHP_EOL;
    switch ($type) {
        case 'image':
        case 'text':
        case 'css_only':
        case 'dropdown':
            foreach (qtranxf_getSortedLanguages() as $language) {
                $alt = $q_config['language_name'][$language] . ' (' . $language . ')';
                $classes = array('lang-' . $language);
                if ($language == $q_config['language']) {
                    $classes[] = 'active';
                }
                echo '<li class="' . implode(' ', $classes) . '"><a href="' . qtranxf_convertURL($url, $language, false, true) . '"';
                // set hreflang
                echo ' hreflang="' . $language . '"';
                echo ' title="' . $alt . '"';
                if ($type == 'image') {
                    echo ' class="qtranxs_image qtranxs_image_' . $language . '"';
                } elseif ($type == 'text') {
                    echo ' class="qtranxs_text qtranxs_text_' . $language . '"';
                } elseif ($type == 'css_only') {
                    // to be removed
                    echo ' class="qtranxs_css qtranxs_css_' . $language . '"';
                }
                echo '>';
                if ($type == 'image') {
                    echo '<img src="' . $flag_location . $q_config['flag'][$language] . '" alt="' . $alt . '" />';
                }
                echo '<span';
                if ($type == 'image' || $type == 'css_only') {
                    echo ' style="display:none"';
                }
                echo '>' . $q_config['language_name'][$language] . '</span>';
                echo '</a></li>' . PHP_EOL;
            }
            //echo '</ul><div class="qtranxs_widget_end"></div>'.PHP_EOL;
            if ($type == 'dropdown') {
                echo '<script type="text/javascript">' . PHP_EOL . '// <![CDATA[' . PHP_EOL;
                echo "var lc = document.getElementById('" . $id . "');" . PHP_EOL;
                echo "var s = document.createElement('select');" . PHP_EOL;
                echo "s.id = 'qtranxs_select_" . $id . "';" . PHP_EOL;
                echo "lc.parentNode.insertBefore(s,lc);" . PHP_EOL;
                // create dropdown fields for each language
                foreach (qtranxf_getSortedLanguages() as $language) {
                    echo qtranxf_insertDropDownElement($language, qtranxf_convertURL($url, $language, false, true), $id);
                }
                // hide html language chooser text
                echo "s.onchange = function() { document.location.href = this.value;}" . PHP_EOL;
                echo "lc.style.display='none';" . PHP_EOL;
                echo '// ]]>' . PHP_EOL . '</script>' . PHP_EOL;
            }
//.........这里部分代码省略.........
开发者ID:razik440,项目名称:qtranslate-x,代码行数:101,代码来源:qtranslate_widget.php


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