• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP pll_default_language函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: syncProductsMeta

 /**
  * Sync porduct meta
  *
  * @return false if the current post type is not "porduct"
  */
 public function syncProductsMeta()
 {
     $currentScreen = get_current_screen();
     if ($currentScreen->post_type !== 'product') {
         return false;
     }
     // sync product meta with polylang
     add_filter('pll_copy_post_metas', array(__CLASS__, 'getProductMetaToCopy'));
     $ID = false;
     $disable = false;
     /*
      * Disable editing product meta for translation
      *
      * if the "post" is defined in $_GET then we should check if the current
      * porduct has a translation and it is the same as the default translation
      * lang defined in polylang then porduct meta editing must by enabled
      *
      * if the "new_lang" is defined or if the current page is the "edit"
      * page then porduct meta editing must by disabled
      */
     if (isset($_GET['post'])) {
         $ID = absint($_GET['post']);
         $disable = $ID && pll_get_post_language($ID) != pll_default_language();
     } elseif (isset($_GET['new_lang']) || $currentScreen->base == 'edit') {
         $disable = isset($_GET['new_lang']) && esc_attr($_GET['new_lang']) != pll_default_language() ? true : false;
         $ID = isset($_GET['from_post']) ? absint($_GET['from_post']) : false;
     }
     // disable fields edit for translation
     if ($disable) {
         add_action('admin_print_scripts', array($this, 'addFieldsLocker'), 100);
     }
     /* sync selected prodcut type */
     $this->syncSelectedProdcutType($ID);
 }
开发者ID:qRoC,项目名称:woo-poly-integration,代码行数:39,代码来源:Meta.php


示例2: taxonomy_rewrite_rules_filter

 /**
  * Translate the rewrite rules.
  */
 public function taxonomy_rewrite_rules_filter($rewrite_rules)
 {
     global $polylang, $wp_rewrite;
     $translated_rules = array();
     // For each lang.
     foreach ($this->translated_slugs as $lang => $translated_slug) {
         // If "Hide URL language information for default language" option is
         // set to true the rules has to be different for the default language.
         if ($polylang->options['hide_default'] && $lang == pll_default_language()) {
             // For each rule.
             foreach ($rewrite_rules as $rule_key => $rule_value) {
                 // Only translate the rewrite slug.
                 $translated_rules[str_replace(trim($this->taxonomy_object->rewrite['slug'], '/'), $translated_slug, $rule_key)] = $rule_value;
             }
         } else {
             // For each rule.
             foreach ($rewrite_rules as $rule_key => $rule_value) {
                 $taxonomy_rewrite_slug = $this->taxonomy_object->rewrite['slug'];
                 // Replace the rewrite tags in slugs.
                 foreach ($wp_rewrite->rewritecode as $position => $code) {
                     $taxonomy_rewrite_slug = str_replace($code, $wp_rewrite->rewritereplace[$position], $taxonomy_rewrite_slug);
                     $translated_slug = str_replace($code, $wp_rewrite->rewritereplace[$position], $translated_slug);
                 }
                 // Shift the matches up cause "lang" will be the first.
                 $translated_rules['(' . $lang . ')/' . str_replace(trim($taxonomy_rewrite_slug, '/'), $translated_slug, $rule_key)] = str_replace(array('[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]'), array('[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]'), $rule_value);
             }
         }
     }
     return $translated_rules;
 }
开发者ID:jqueryalmeida,项目名称:wp-polylang-translate-rewrite-slugs,代码行数:33,代码来源:taxonomy.php


示例3: get_languages

 /**
  * Get available languages.
  */
 private function get_languages()
 {
     if ($this->plugin === 'Polylang') {
         global $polylang;
         // set default language
         $this->default_lang = pll_default_language();
         // set languages
         $registered_languages = $polylang->model->get_languages_list();
         if (!empty($registered_languages)) {
             foreach ($registered_languages as $language) {
                 $this->languages[] = $language->slug;
             }
         }
     } elseif ($this->plugin === 'WPML') {
         global $sitepress;
         // set default language
         $this->default_lang = $sitepress->get_default_language();
         // set languages
         $registered_languages = icl_get_languages();
         if (!empty($registered_languages)) {
             foreach ($registered_languages as $language) {
                 $this->languages[] = $language['language_code'];
             }
         }
     }
     // remove default language
     if (($key = array_search($this->default_lang, $this->languages)) !== false) {
         unset($this->languages[$key]);
     }
 }
开发者ID:patlegris,项目名称:On-Off,代码行数:33,代码来源:translate-rewrite-slugs.php


示例4: set_language

 /**
  * Action: Set Language
  *
  * @param string  $lang_slug
  * @param object  $current_lang  Current language
  */
 public function set_language($lang_slug, $current_lang)
 {
     $this->default_lang = pll_default_language();
     $this->current_lang = pll_current_language();
     acf_update_setting('default_language', $this->default_lang);
     acf_update_setting('current_language', $this->current_lang);
 }
开发者ID:locomotivemtl,项目名称:wordpress-boilerplate,代码行数:13,代码来源:acf.php


示例5: create_nav_menu_locations

 public function create_nav_menu_locations()
 {
     static $once;
     global $_wp_registered_nav_menus;
     if (isset($_wp_registered_nav_menus) && !$once) {
         foreach ($_wp_registered_nav_menus as $loc => $name) {
             foreach ($this->model->get_languages_list() as $lang) {
                 $arr[$loc . (pll_default_language() == $lang->slug ? '' : '___' . $lang->slug)] = $name . ' ' . $lang->name;
             }
         }
         $_wp_registered_nav_menus = $arr;
         $once = true;
     }
 }
开发者ID:WordPressArt,项目名称:conisia,代码行数:14,代码来源:nav-menu.php


示例6: languages

 /**
  * Prints the languages currently available
  *
  * ## EXAMPLES
  *
  *     wp polylang languages
  *
  * @synopsis
  * @alias langs
  */
 function languages($args, $assocArgs)
 {
     $languages = pll_get_languages_list();
     if (!count($languages)) {
         WP_CLI::success("Less than two languages are currently configurated.");
         return;
     }
     $default = pll_default_language();
     foreach ($languages as $language) {
         $line = "{$language->slug} — {$language->name}";
         if ($language->slug == $default) {
             $line .= ' [DEFAULT]';
         }
         WP_CLI::line($line);
     }
 }
开发者ID:dereckson,项目名称:wp-cli-polylang,代码行数:26,代码来源:Polylang_Command.php


示例7: syncProductsMeta

 /**
  * Sync product meta.
  *
  * @return false if the current post type is not "product"
  */
 public function syncProductsMeta()
 {
     // sync product meta with polylang
     add_filter('pll_copy_post_metas', array(__CLASS__, 'getProductMetaToCopy'));
     // Shipping Class translation is not supported after WooCommerce 2.6 but it is
     // still implemented by WooCommerce as a taxonomy. Therefore Polylang will not
     // copy the Shipping Class meta. We need to take care of it.
     if (Utilities::woocommerceVersionCheck('2.6')) {
         add_action('wp_insert_post', array($this, 'syncShippingClass'), 10, 3);
     }
     $currentScreen = get_current_screen();
     if ($currentScreen->post_type !== 'product') {
         return false;
     }
     $ID = false;
     $disable = false;
     /*
      * Disable editing product meta for translation
      *
      * if the "post" is defined in $_GET then we should check if the current
      * product has a translation and it is the same as the default translation
      * lang defined in polylang then product meta editing must by enabled
      *
      * if the "new_lang" is defined or if the current page is the "edit"
      * page then product meta editing must by disabled
      */
     if (isset($_GET['post'])) {
         $ID = absint($_GET['post']);
         $disable = $ID && pll_get_post_language($ID) != pll_default_language();
     } elseif (isset($_GET['new_lang']) || $currentScreen->base == 'edit') {
         $disable = isset($_GET['new_lang']) && esc_attr($_GET['new_lang']) != pll_default_language() ? true : false;
         $ID = isset($_GET['from_post']) ? absint($_GET['from_post']) : false;
         // Add the '_translation_porduct_type' meta, for the case where
         // the product was created before plugin acivation.
         $this->addProductTypeMeta($ID);
     }
     // disable fields edit for translation
     if ($disable) {
         add_action('admin_print_scripts', array($this, 'addFieldsLocker'), 100);
     }
     /* sync selected product type */
     $this->syncSelectedproductType($ID);
 }
开发者ID:hyyan,项目名称:woo-poly-integration,代码行数:48,代码来源:Meta.php


示例8: shim_untranslated

 public function shim_untranslated($query_args, $args)
 {
     $def_lang = pll_default_language();
     $cur_lang = pll_current_language();
     $mixed = $cur_lang != $def_lang;
     if (apply_filters('listify_polylang_only_selected', false)) {
         return $query_args;
     }
     if (isset($query_args['tax_query']) && $mixed) {
         $taxes = $query_args['tax_query'];
         foreach ($taxes as $key => $tax) {
             $terms = $tax['terms'];
             $trans = array();
             if (is_array($terms)) {
                 foreach ($terms as $term) {
                     // annoying since we have slugs but get an id but need back to slugs
                     $obj = get_term_by('slug', $term, $tax['taxonomy']);
                     $trans = pll_get_term($obj->term_id, $def_lang);
                     $trans = get_term_by('id', $trans, $tax['taxonomy']);
                     $query_args['tax_query'][$key]['terms'] = array_merge($terms, array($trans->slug));
                 }
             }
         }
     }
     $terms = get_terms('post_translations');
     $exclude = array();
     foreach ($terms as $translation) {
         $trans = unserialize($translation->description);
         if ($mixed) {
             $exclude[] = $trans[$def_lang];
         }
     }
     if ($mixed) {
         if (isset($query_args['post__in'])) {
             $query_args['post__in'] = array_diff($query_args['post__in'], $exclude);
             unset($query_args['post__not_in']);
         } else {
             $query_args['post__not_in'] = $exclude;
         }
     }
     return $query_args;
 }
开发者ID:durichitayat,项目名称:befolio-wp,代码行数:42,代码来源:class-polylang.php


示例9: optionsframework_option_name

 function optionsframework_option_name()
 {
     $themename = get_option('stylesheet');
     $themename = preg_replace("/\\W/", "_", strtolower($themename));
     if (is_child_theme()) {
         $themename = str_replace("_child", "", $themename);
     }
     $themename_lan = $themename;
     if (defined('ICL_LANGUAGE_CODE') && ICL_LANGUAGE_CODE != 'en') {
         $themename_lan = $themename . '_' . ICL_LANGUAGE_CODE;
     }
     if (function_exists('pll_current_language')) {
         $default_lan = pll_default_language('slug');
         $current_lan = pll_current_language('slug');
         if ($current_lan != '') {
             $themename_lan = $themename . '_' . $current_lan;
         }
     }
     return $themename_lan;
 }
开发者ID:JasonAJames,项目名称:jasonajamescom,代码行数:20,代码来源:admin-options.php


示例10: syncProductsMeta

 /**
  * Sync porduct meta
  *
  * @return false if the current post type is not "product"
  */
 public function syncProductsMeta()
 {
     // sync product meta with polylang
     add_filter('pll_copy_post_metas', array(__CLASS__, 'getProductMetaToCopy'));
     $currentScreen = get_current_screen();
     if ($currentScreen->post_type !== 'product') {
         return false;
     }
     $ID = false;
     $disable = false;
     /*
      * Disable editing product meta for product translations
      *
      * In case of a "Add or update product" ($GET['post'] is set), and the
      * product language is different from the default, it is a product translation
      * and editing the product metadata should be disabled.
      *
      * In case of a "Add product translation" ($GET['new_lang'] is set), or the
      * 'edit' page, editing product metadata should be disabled.
      */
     if (isset($_GET['post'])) {
         // Add or update product
         $ID = absint($_GET['post']);
         $disable = $ID && pll_get_post_language($ID) != pll_default_language();
     } elseif (isset($_GET['new_lang']) || $currentScreen->base == 'edit') {
         // Add product translation
         $ID = isset($_GET['from_post']) ? absint($_GET['from_post']) : false;
         $disable = isset($_GET['new_lang']) && esc_attr($_GET['new_lang']) != pll_default_language() ? true : false;
         // Add the '_translation_porduct_type' meta,for the case the product
         // was created before plugin acivation.
         $this->add_product_type_meta($ID);
     }
     // disable fields edit for product translations
     if ($disable) {
         add_action('admin_print_scripts', array($this, 'addFieldsLocker'), 100);
     }
     // sync the product type selection in the product data settings box
     $this->sync_product_type_selection($ID);
 }
开发者ID:decarvalhoaa,项目名称:woopoly,代码行数:44,代码来源:Meta.php


示例11: real_site_url

 function real_site_url($path = '')
 {
     $site_url = get_site_url();
     // check for multi-language-framework plugin
     if (is_plugin_active('multi-language-framework/multi-language-framework.php')) {
         global $mlf_config;
         $current_language = substr(strtolower(get_bloginfo('language')), 0, 2);
         if ($mlf_config['default_language'] != $current_language) {
             $site_url .= '/' . $current_language;
         }
     } elseif (is_plugin_active('polylang/polylang.php')) {
         $defLang = pll_default_language();
         $curLang = pll_current_language();
         if ($defLang != $curLang) {
             $site_url .= '/' . $curLang;
         }
     }
     if ($path != '') {
         $site_url .= '/' . $path;
     }
     $site_url .= '/';
     return $site_url;
 }
开发者ID:bireme,项目名称:lildbi-web-wp-plugin,代码行数:23,代码来源:template-functions.php


示例12: pll_default_language

<?php

/**
 * Template Name: Related Resources
 */
global $post;
$lang = '';
if (is_plugin_active('polylang/polylang.php')) {
    $defLang = pll_default_language();
    $curLang = pll_current_language();
    if ($defLang != $curLang) {
        $lang = $curLang;
    }
}
// get all the child categories of "Related resources" category
$category = get_category_by_slug($post->post_name);
$args = array('type' => 'post', 'child_of' => $category->term_id, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => FALSE, 'hierarchical' => 1, 'taxonomy' => 'category');
$child_categories = get_categories($args);
get_header();
?>

    <?php 
$breadcrumb = '<div class="breadcrumb"><a href="' . esc_url(home_url("/" . $lang . "/")) . '" class="home">Home</a> > ' . $category->name . '</div>';
echo $breadcrumb;
?>
    <div id="primary" class="site-content">
        <div id="content" role="main" <?php 
post_class('related-resources');
?>
>
开发者ID:aspto,项目名称:wordpress-themes,代码行数:30,代码来源:related-resources.php


示例13: set_language

 /**
  * Action: Set Language
  *
  * @param string  $lang_slug
  * @param object  $current_lang  Current language
  */
 public function set_language($lang_slug, $current_lang)
 {
     $this->default_lang = pll_default_language();
     $this->current_lang = pll_current_language();
 }
开发者ID:locomotivemtl,项目名称:wordpress-boilerplate,代码行数:11,代码来源:gf.php


示例14: grunion_contact_form_field_html_filter

 /**
  * Jetpack
  * Adapted from the same function in jetpack-3.0.2/3rd-party/wpml.php
  * Keeps using 'icl_translate' as the function registers the string
  *
  * @since 1.5.4
  */
 public function grunion_contact_form_field_html_filter($r, $field_label, $id)
 {
     if (function_exists('icl_translate')) {
         if (pll_current_language() !== pll_default_language()) {
             $label_translation = icl_translate('jetpack ', $field_label . '_label', $field_label);
             $r = str_replace($field_label, $label_translation, $r);
         }
     }
     return $r;
 }
开发者ID:spielhoelle,项目名称:amnesty,代码行数:17,代码来源:plugins-compat.php


示例15: dropdown_pages

 /**
  * Get all available pages with default admin language.
  */
 private function dropdown_pages($args = array())
 {
     $defaults = array('echo' => 0, 'post_type' => 'page', 'show_option_none' => __('None', 'events-maker'), 'option_none_value' => 0, 'suppress_filters' => false);
     $args = wp_parse_args($args, $defaults);
     if (class_exists('SitePress') && array_key_exists('sitepress', $GLOBALS)) {
         global $sitepress;
         $current_lang = $sitepress->get_current_language();
         $default_lang = $sitepress->get_default_language();
         // @TODO this only works if $_GET lang parameter is 'all' or equal to $default_lang
         // unfortunatelly WPML does not support any method to override that
         $sitepress->switch_lang($default_lang, true);
     } elseif (class_exists('Polylang') && function_exists('pll_default_language')) {
         $args['lang'] = pll_default_language('slug');
     }
     $pages = wp_dropdown_pages($args);
     if (class_exists('SitePress') && array_key_exists('sitepress', $GLOBALS)) {
         $sitepress->switch_lang($current_lang);
     }
     return $pages;
 }
开发者ID:patlegris,项目名称:On-Off,代码行数:23,代码来源:class-settings.php


示例16: elseif

        } elseif (ICL_LANGUAGE_CODE != 'en' && ICL_LANGUAGE_CODE != 'all' && function_exists('pll_default_language')) {
            if (in_array(ICL_LANGUAGE_CODE, $pll_languages)) {
                $lang = '_' . ICL_LANGUAGE_CODE;
                if (!get_option($theme_name . '_options' . $lang)) {
                    update_option($theme_name . '_options' . $lang, get_option($theme_name . '_options'));
                }
            }
        } elseif (ICL_LANGUAGE_CODE == 'all') {
            if (defined('ICL_SITEPRESS_VERSION')) {
                $lang = '_' . $sitepress->get_default_language();
                if ($sitepress->get_default_language() == 'en') {
                    $lang = '';
                }
            } elseif (function_exists('pll_default_language')) {
                $lang = '_' . pll_default_language('slug');
                if (pll_default_language('slug') == 'en') {
                    $lang = '';
                }
            }
        } else {
            $lang = '';
        }
    } else {
        $lang = '';
    }
}
// End Avada Edit
define('OPTIONS', $theme_name . '_options' . $lang);
define('BACKUPS', $theme_name . '_backups' . $lang);
/**
 * Required action filters
开发者ID:universal-youth,项目名称:www.universal-youth.com,代码行数:31,代码来源:index.php


示例17: nav_menu_locations

 public function nav_menu_locations($menus)
 {
     if (is_array($menus)) {
         foreach ($menus as $loc => $menu) {
             foreach ($this->model->get_languages_list() as $lang) {
                 if (pll_default_language() != $lang->slug && !empty($this->options['nav_menus'][$this->theme][$loc][$lang->slug])) {
                     $menus[$loc . '___' . $lang->slug] = $this->options['nav_menus'][$this->theme][$loc][$lang->slug];
                 }
             }
         }
     }
     return $menus;
 }
开发者ID:MaryMaffka,项目名称:dpm,代码行数:13,代码来源:admin-nav-menu.php


示例18: get_default_language_code

 /**
  * Get default language code
  *
  * @return string Default language code
  */
 function get_default_language_code()
 {
     return pll_default_language('slug');
 }
开发者ID:silvestrelosada,项目名称:wpsolr-search-engine,代码行数:9,代码来源:plugin-polylang.php


示例19: getDefaultLanguage

 /**
  * Get the default language
  *
  * @return string
  */
 public function getDefaultLanguage()
 {
     return pll_default_language();
 }
开发者ID:nextbuzz,项目名称:buzz-seo,代码行数:9,代码来源:Polylang.php


示例20: term_link_filter

 /**
  * Fix "get_term_link" for this taxonomy.
  */
 public function term_link_filter($termlink, $term, $taxonomy)
 {
     // Check if the post type is handle.
     if (isset($this->taxonomies[$taxonomy])) {
         global $wp_rewrite, $polylang;
         if (!is_object($term)) {
             if (is_int($term)) {
                 $term = get_term($term, $taxonomy);
             } else {
                 $term = get_term_by('slug', $term, $taxonomy);
             }
         }
         if (!is_object($term)) {
             $term = new WP_Error('invalid_term', __('Empty Term'));
         }
         if (is_wp_error($term)) {
             return $term;
         }
         // Get the term language.
         $term_language = PLL()->model->term->get_language($term->term_id);
         if ($term_language) {
             $lang = $term_language->slug;
         } else {
             $lang = pll_default_language();
         }
         // Check if the language is handle.
         if (isset($this->taxonomies[$taxonomy]->translated_slugs[$lang])) {
             $taxonomy = $term->taxonomy;
             $termlink = $this->taxonomies[$taxonomy]->translated_struct[$lang];
             $slug = $term->slug;
             $t = get_taxonomy($taxonomy);
             if (empty($termlink)) {
                 if ('category' == $taxonomy) {
                     $termlink = '?cat=' . $term->term_id;
                 } elseif ($t->query_var) {
                     $termlink = "?{$t->query_var}={$slug}";
                 } else {
                     $termlink = "?taxonomy={$taxonomy}&term={$slug}";
                 }
                 $termlink = home_url($termlink);
             } else {
                 if ($t->rewrite['hierarchical']) {
                     $hierarchical_slugs = array();
                     $ancestors = get_ancestors($term->term_id, $taxonomy);
                     foreach ((array) $ancestors as $ancestor) {
                         $ancestor_term = get_term($ancestor, $taxonomy);
                         $hierarchical_slugs[] = $ancestor_term->slug;
                     }
                     $hierarchical_slugs = array_reverse($hierarchical_slugs);
                     $hierarchical_slugs[] = $slug;
                     $termlink = str_replace("%{$taxonomy}%", implode('/', $hierarchical_slugs), $termlink);
                 } else {
                     $termlink = str_replace("%{$taxonomy}%", $slug, $termlink);
                 }
                 $termlink = home_url(user_trailingslashit($termlink, 'category'));
             }
             // Back Compat filters.
             if ('post_tag' == $taxonomy) {
                 $termlink = apply_filters('tag_link', $termlink, $term->term_id);
             } elseif ('category' == $taxonomy) {
                 $termlink = apply_filters('category_link', $termlink, $term->term_id);
             }
         }
     }
     return $termlink;
 }
开发者ID:jussikinnula,项目名称:wp-polylang-translate-rewrite-slugs,代码行数:69,代码来源:polylang-translate-rewrite-slugs.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP pll_e函数代码示例发布时间:2022-05-15
下一篇:
PHP pll_current_language函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap