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


PHP pll_default_language函数代码示例

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


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


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