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


PHP pll_the_languages函数代码示例

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


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

示例1: language

 public static function language()
 {
     if (!function_exists('pll_the_languages')) {
         return;
     }
     return pll_the_languages(array('raw' => true));
 }
开发者ID:guimachiavelli,项目名称:vac,代码行数:7,代码来源:navigation.php

示例2: widget

 /**
  * Displays the widget
  *
  * @since 0.1
  *
  * @param array $args     Display arguments including before_title, after_title, before_widget, and after_widget.
  * @param array $instance The settings for the particular instance of the widget
  */
 function widget($args, $instance)
 {
     // Sets a unique id for dropdown
     $instance['dropdown'] = empty($instance['dropdown']) ? 0 : $args['widget_id'];
     if ($list = pll_the_languages(array_merge($instance, array('echo' => 0)))) {
         $title = empty($instance['title']) ? '' : $instance['title'];
         /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
         $title = apply_filters('widget_title', $title, $instance, $this->id_base);
         echo $args['before_widget'];
         if ($title) {
             echo $args['before_title'] . $title . $args['after_title'];
         }
         echo $instance['dropdown'] ? $list : "<ul>\n" . $list . "</ul>\n";
         echo $args['after_widget'];
     }
 }
开发者ID:spielhoelle,项目名称:amnesty,代码行数:24,代码来源:widget-languages.php

示例3: wp_get_nav_menu_items

 public function wp_get_nav_menu_items($items)
 {
     if (doing_action('customize_register')) {
         // needed since WP 4.3, doing_action available since WP 3.9
         return $items;
     }
     // the customizer menus does not sort the items and we need them to be sorted before splitting the language switcher
     usort($items, array($this, 'usort_menu_items'));
     $new_items = array();
     $offset = 0;
     foreach ($items as $key => $item) {
         if ($options = get_post_meta($item->ID, '_pll_menu_item', true)) {
             $i = 0;
             foreach (pll_the_languages(array_merge(array('raw' => 1), $options)) as $lang) {
                 $lang_item = clone $item;
                 $lang_item->ID = $lang_item->ID . '-' . $lang['slug'];
                 // a unique ID
                 $lang_item->title = $options['show_flags'] && $options['show_names'] ? $lang['flag'] . '&nbsp;' . esc_html($lang['name']) : ($options['show_flags'] ? $lang['flag'] : esc_html($lang['name']));
                 $lang_item->url = $lang['url'];
                 $lang_item->lang = $lang['slug'];
                 // save this for use in nav_menu_link_attributes
                 $lang_item->classes = $lang['classes'];
                 $lang_item->menu_order += $offset + $i++;
                 $new_items[] = $lang_item;
             }
             $offset += $i - 1;
         } else {
             $item->menu_order += $offset;
             $new_items[] = $item;
         }
     }
     return $new_items;
 }
开发者ID:WordPressArt,项目名称:conisia,代码行数:33,代码来源:frontend-nav-menu.php

示例4: wp_get_nav_menu_items

 public function wp_get_nav_menu_items($items)
 {
     $new_items = array();
     $offset = 0;
     foreach ($items as $key => $item) {
         if ($options = get_post_meta($item->ID, '_pll_menu_item', true)) {
             $i = 0;
             foreach (pll_the_languages(array_merge(array('raw' => 1), $options)) as $lang) {
                 $lang_item = clone $item;
                 $lang_item->ID = $lang_item->ID . '-' . $lang['slug'];
                 // a unique ID
                 $lang_item->title = $options['show_flags'] && $options['show_names'] ? $lang['flag'] . '&nbsp;' . esc_html($lang['name']) : ($options['show_flags'] ? $lang['flag'] : esc_html($lang['name']));
                 $lang_item->url = $lang['url'];
                 $lang_item->lang = $lang['slug'];
                 // save this for use in nav_menu_link_attributes
                 $lang_item->classes = $lang['classes'];
                 $lang_item->menu_order += $offset + $i++;
                 $new_items[] = $lang_item;
             }
             $offset += $i - 1;
         } else {
             $item->menu_order += $offset;
             $new_items[] = $item;
         }
     }
     return $new_items;
 }
开发者ID:santikrass,项目名称:apache,代码行数:27,代码来源:frontend-nav-menu.php

示例5: wp_get_nav_menu_items

 public function wp_get_nav_menu_items($items)
 {
     $new_items = array();
     $offset = 0;
     foreach ($items as $key => $item) {
         if ($options = get_post_meta($item->ID, '_pll_menu_item', true)) {
             extract($options);
             $i = 0;
             foreach (pll_the_languages(array_merge(array('raw' => 1), $options)) as $language) {
                 extract($language);
                 $lang_item = clone $item;
                 $lang_item->ID = $lang_item->ID . '-' . $slug;
                 // a unique ID
                 $lang_item->title = $show_flags && $show_names ? $flag . '&nbsp;' . esc_html($name) : ($show_flags ? $flag : esc_html($name));
                 $lang_item->url = $url;
                 $lang_item->lang = $slug;
                 // save this for use in nav_menu_link_attributes
                 $lang_item->classes = $classes;
                 $lang_item->menu_order += $offset + $i++;
                 $new_items[] = $lang_item;
             }
             $offset += $i - 1;
         } else {
             $item->menu_order += $offset;
             $new_items[] = $item;
         }
     }
     return $new_items;
 }
开发者ID:kivivuori,项目名称:jotain,代码行数:29,代码来源:frontend-nav-menu.php

示例6: switcher_shortcode

 /**
  * Registers the Polylang Language Switcher function as a shortcode
  *
  * @since 1.6.0
  */
 public function switcher_shortcode($atts, $content = null)
 {
     // Make sure pll_the_languages() is defined
     if (function_exists('pll_the_languages')) {
         // Extract attributes
         extract(shortcode_atts(array('dropdown' => false, 'show_flags' => true, 'show_names' => false, 'classes' => '', 'hide_if_empty' => true, 'force_home' => false, 'hide_if_no_translation' => false, 'hide_current' => false, 'post_id' => null, 'raw' => false), $atts));
         // Args
         $dropdown = 'true' == $dropdown ? true : false;
         $show_flags = 'true' == $show_flags ? true : false;
         $show_names = 'true' == $show_names ? true : false;
         // Dropdown args
         if ($dropdown) {
             $show_flags = $show_names = false;
         }
         // Classes
         $classes = 'polylang-switcher-shortcode clr';
         if ($show_names && !$dropdown) {
             $classes .= ' flags-and-names';
         }
         // Display Switcher
         if (!$dropdown) {
             echo '<ul class="' . $classes . '">';
         }
         // Display the switcher
         pll_the_languages(array('dropdown' => $dropdown, 'show_flags' => $show_flags, 'show_names' => $show_names, 'hide_if_empty' => $hide_if_empty, 'force_home' => $force_home, 'hide_if_no_translation' => $hide_if_no_translation, 'hide_current' => $hide_current, 'post_id' => $post_id, 'raw' => $raw));
         if (!$dropdown) {
             echo '</ul>';
         }
     }
 }
开发者ID:iq007,项目名称:MadScape,代码行数:35,代码来源:polylang.php

示例7: widget

 function widget($args, $instance)
 {
     global $polylang;
     if (!(isset($polylang) && $polylang->model->get_languages_list() && ($list = pll_the_languages(array_merge($instance, array('echo' => 0)))))) {
         return;
     }
     extract($args);
     extract($instance);
     echo "{$before_widget}\n";
     if ($title = apply_filters('widget_title', $title, $instance, $this->id_base)) {
         echo $before_title . $title . $after_title;
     }
     echo $dropdown ? $list : "<ul>\n" . $list . "</ul>\n";
     echo "{$after_widget}\n";
     // javascript to switch the language when using a dropdown list
     if ($dropdown) {
         foreach ($polylang->model->get_languages_list() as $language) {
             $url = $force_home || ($url = $polylang->links->get_translation_url($language)) == null ? $polylang->links->get_home_url($language) : $url;
             $urls[] = '"' . esc_js($language->slug) . '":"' . esc_url($url) . '"';
         }
         $urls = implode(',', $urls);
         $js = "\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t//<![CDATA[\n\t\t\t\t\tvar urls = {{$urls}};\n\t\t\t\t\tvar d = document.getElementById('lang_choice');\n\t\t\t\t\td.onchange = function() {\n\t\t\t\t\t\tfor (var i in urls) {\n\t\t\t\t\t\t\tif (this.value == i)\n\t\t\t\t\t\t\t\tlocation.href = urls[i];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t//]]>\n\t\t\t\t</script>";
         echo $js;
     }
 }
开发者ID:kivivuori,项目名称:jotain,代码行数:25,代码来源:widget-languages.php

示例8: add_to_context

function add_to_context($context)
{
    /* So here you are adding data to Timber's context object, i.e...
       $data['foo'] = 'I am some other typical value set in your functions.php file, unrelated to the menu';
       */
    /* add a Timber menu and send it along to the context. */
    $context['principal'] = new TimberMenu('principal');
    $context['secondaire'] = new TimberMenu('secondaire');
    if (function_exists('pll_the_languages')) {
        $context['language_switcher'] = pll_the_languages($args = ['dropdown' => 1, 'show_names' => 1, 'show_flags' => 0, 'hide_if_empty' => 0, 'hide_if_no_translation' => 0, 'hide_current' => 1, 'echo' => 0]);
    }
    return $context;
}
开发者ID:BibCnrs,项目名称:BibCnrs,代码行数:13,代码来源:functions.php

示例9: getTranslatedTerms

 /**
  * Get an array with all available translations for a given term
  *
  * @param int $termID
  * @return array Indexed array with as key the language code, and as value the post id
  */
 public function getTranslatedTerms($termID)
 {
     $languages = pll_the_languages(array('raw' => 1));
     $result = array();
     foreach ($languages as $lang) {
         $lang = $lang['slug'];
         $transTermID = pll_get_term($termID, $lang);
         if (is_int($transTermID) && $transTermID !== $termID) {
             $result[$lang] = $transTermID;
         }
     }
     return $result;
 }
开发者ID:nextbuzz,项目名称:buzz-seo,代码行数:19,代码来源:Polylang.php

示例10: widget

 function widget($args, $instance)
 {
     // sets a unique id for dropdown
     $instance['dropdown'] = empty($instance['dropdown']) ? 0 : $args['widget_id'];
     if ($list = pll_the_languages(array_merge($instance, array('echo' => 0)))) {
         $title = empty($instance['title']) ? '' : $instance['title'];
         $title = apply_filters('widget_title', $title, $instance, $this->id_base);
         echo $args['before_widget'];
         if ($title) {
             echo $args['before_title'] . $title . $args['after_title'];
         }
         echo $instance['dropdown'] ? $list : "<ul>\n" . $list . "</ul>\n";
         echo $args['after_widget'];
     }
 }
开发者ID:iq007,项目名称:MadScape,代码行数:15,代码来源:widget-languages.php

示例11: widget

 function widget($args, $instance)
 {
     global $polylang;
     // sets a unique id for dropdown
     $instance['dropdown'] = empty($instance['dropdown']) ? 0 : $args['widget_id'];
     if (!(isset($polylang) && $polylang->model->get_languages_list() && ($list = pll_the_languages(array_merge($instance, array('echo' => 0)))))) {
         return;
     }
     echo $args['before_widget'];
     if ($title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     echo $instance['dropdown'] ? $list : "<ul>\n" . $list . "</ul>\n";
     echo $args['after_widget'];
 }
开发者ID:WordPressArt,项目名称:conisia,代码行数:15,代码来源:widget-languages.php

示例12: topWidget

function topWidget()
{
    ?>

    <div class="top-widget">
    <?php 
    if (!function_exists('dynamic_sidebar') || !dynamic_sidebar()) {
        ?>
        <div class="ito-search-laguage">
            <div class="ito-search">
                <?php 
        if (!dynamic_sidebar('search')) {
            ?>
             
                    <form id="searchform" method="get" action="<?php 
            bloginfo('home');
            ?>
">
                        <input type="text" name="s" id="s" value="" size="13" />
                    </form>
                <?php 
        }
        ?>
            </div>
            <div class="ito-language">
                <?php 
        pll_the_languages();
        ?>
            </div>
        </div>
        <?php 
    }
    ?>
    </div>
    <?php 
}
开发者ID:ramonvloon,项目名称:Ingrid,代码行数:36,代码来源:top-widget.php

示例13: add_to_context

 function add_to_context($context)
 {
     $context['site'] = $this;
     $context['menu_primary'] = new TimberMenu("menu_primary");
     $context['menu_secondary'] = new TimberMenu("menu_secondary");
     $context['menu_custom'] = new TimberMenu("menu_custom");
     if (function_exists('get_fields')) {
         $context['options'] = get_fields('options');
     }
     if (function_exists('pll_the_languages')) {
         $context['language_switcher'] = pll_the_languages($args = ['show_names' => 0, 'show_flags' => 1, 'hide_if_empty' => 0, 'hide_if_no_translation' => 0, 'hide_current' => 0, 'echo' => 0]);
     }
     if (function_exists('get_field')) {
         $context['global_businessinfo_firmenbezeichnung'] = get_field('firmenbezeichnung', 'options');
         $context['global_businessinfo_strasse_hausnummer'] = get_field('strasse_hausnummer', 'options');
         $context['global_businessinfo_postleitzahl'] = get_field('postleitzahl', 'options');
         $context['global_businessinfo_ort'] = get_field('ort', 'options');
         $context['global_businessinfo_bundesland'] = get_field('bundesland', 'options');
         $context['global_businessinfo_telefon'] = get_field('telefon', 'options');
         $context['global_businessinfo_telefon_link'] = get_field('telefon-link', 'options');
         $context['global_businessinfo_telefax'] = get_field('telefax', 'options');
         $context['global_businessinfo_telefax_link'] = get_field('telefax-link', 'options');
         $context['global_businessinfo_email'] = get_field('e-mail', 'options');
     }
     $context['analyticsProfile'] = 'UA-49457421-XX';
     return $context;
 }
开发者ID:baze,项目名称:wp-starter-theme,代码行数:27,代码来源:functions.php

示例14: body_class

<body <?php 
body_class();
?>
>

<?php 
if (of_get_option('innerpageslider', true) != 'hide' || is_home() || is_front_page()) {
    ?>
	<div class="slider-main">
            <div class="top-bar">
                <?php 
    _e('<h1>Britway Resources</h1><p>Integrate Resources, Create Value, Satisfy Customer.</p>', 'skt-white');
    ?>
                <ul class="languages"><?php 
    pll_the_languages(array('show_flags' => 1, 'show_names' => 1));
    ?>
</ul>
            </div><!-- top-bar -->
            
            
    <div id="slider" class="nivoSlider">
       <?php 
    $default_images = array(1 => array('slide_image' => get_template_directory_uri() . "/images/slides/slider1.jpg"), 2 => array('slide_image' => get_template_directory_uri() . "/images/slides/slider2.jpg"), 3 => array('slide_image' => get_template_directory_uri() . "/images/slides/slider3.jpg"), 4 => array('slide_image' => get_template_directory_uri() . "/images/slides/slider1.jpg"), 5 => array('slide_image' => get_template_directory_uri() . "/images/slides/slider2.jpg"));
    for ($i = 1; $i < 6; $i++) {
        if (of_get_option('slide' . $i, true) != '') {
            ?>
                	<img src="<?php 
            echo of_get_option('slide' . $i, $default_images[$i]['slide_image']);
            ?>
"  />
开发者ID:britwayresources,项目名称:website,代码行数:30,代码来源:header.php

示例15: pll_current_language

        if (GPConfig::getInstance()->get_cfg('gp_language_switcher_name')) {
            if ($flag) {
                echo '&nbsp;';
            }
            echo '<span class="gp-ls-name">' . pll_current_language('name') . '</span>';
        } elseif (GPConfig::getInstance()->get_cfg('gp_language_switcher_slug')) {
            if ($flag) {
                echo '&nbsp;';
            }
            echo '<span class="gp-ls-name">' . pll_current_language('slug') . '</span>';
        }
        ?>
                    <!-- <span class="caret"></span> -->
                </button>
                
                <?php 
        $args = array('echo' => false, 'dropdown' => false, 'show_flags' => true, 'show_names' => true, 'hide_if_empty' => false, 'raw' => false);
        $list = pll_the_languages(array_merge($args));
        ?>
                
                <ul class="dropdown-menu" aria-labelledby="gp-header-language-switcher">
                    <?php 
        echo $list;
        ?>
                </ul>
            </div>
        </div>
        
    <?php 
    }
}
开发者ID:sjozsef,项目名称:geckopress,代码行数:31,代码来源:header-language-switcher.php


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