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


PHP SitePress::get_element_language_details方法代码示例

本文整理汇总了PHP中SitePress::get_element_language_details方法的典型用法代码示例。如果您正苦于以下问题:PHP SitePress::get_element_language_details方法的具体用法?PHP SitePress::get_element_language_details怎么用?PHP SitePress::get_element_language_details使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SitePress的用法示例。


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

示例1: strpos

 function post_type_link_filter($post_link, $post, $leavename, $sample)
 {
     if (!$this->sitepress->is_translated_post_type($post->post_type) || !($ld = $this->sitepress->get_element_language_details($post->ID, 'post_' . $post->post_type))) {
         return $post_link;
     }
     if (isset($this->post_link_cache[$post->ID][$leavename . '#' . $sample])) {
         $post_link = $this->post_link_cache[$post->ID][$leavename . '#' . $sample];
     } else {
         $st_settings = $this->sitepress->get_setting('st');
         $strings_language = !empty($st_settings['strings_language']) ? $st_settings['strings_language'] : 'en';
         // fix permalink when object is not in the current language
         if ($ld->language_code != $strings_language) {
             $slug_settings = $this->sitepress->get_setting('posts_slug_translation');
             $slug_settings = !empty($slug_settings['types'][$post->post_type]) ? $slug_settings['types'][$post->post_type] : null;
             if ((bool) $slug_settings === true) {
                 $slug_this = $this->get_slug_by_type($post->post_type);
                 $slug_real = $this->get_translated_slug($slug_this, $ld->language_code);
                 if (empty($slug_real)) {
                     return $post_link;
                 }
                 global $wp_rewrite;
                 if (isset($wp_rewrite->extra_permastructs[$post->post_type])) {
                     $struct_original = $wp_rewrite->extra_permastructs[$post->post_type]['struct'];
                     $lslash = false !== strpos($struct_original, '/' . $slug_this) ? '/' : '';
                     $wp_rewrite->extra_permastructs[$post->post_type]['struct'] = preg_replace('@' . $lslash . $slug_this . '/@', $lslash . $slug_real . '/', $struct_original);
                     remove_filter('post_type_link', array($this, 'post_type_link_filter'), 1);
                     // high priority
                     $post_link = get_post_permalink($post->ID, $leavename, $sample);
                     add_filter('post_type_link', array($this, 'post_type_link_filter'), 1, 4);
                     // high priority
                     $wp_rewrite->extra_permastructs[$post->post_type]['struct'] = $struct_original;
                 } else {
                     $post_link = str_replace($slug_this . '=', $slug_real . '=', $post_link);
                 }
             }
             $this->post_link_cache[$post->ID][$leavename . '#' . $sample] = $post_link;
         }
     }
     return $post_link;
 }
开发者ID:fdelarosa191,项目名称:iftheme-docs,代码行数:40,代码来源:slug-translation.php

示例2: isset

 function post_type_link_filter($post_link, $post, $leavename, $sample)
 {
     if ($this->ignore_post_type_link) {
         return $post_link;
     }
     if (!$this->sitepress->is_translated_post_type($post->post_type) || !($ld = $this->sitepress->get_element_language_details($post->ID, 'post_' . $post->post_type))) {
         return $post_link;
     }
     if (isset($this->post_link_cache[$post->ID][$leavename . '#' . $sample])) {
         $post_link = $this->post_link_cache[$post->ID][$leavename . '#' . $sample];
     } else {
         $slug_settings = $this->sitepress->get_setting('posts_slug_translation');
         $slug_settings = !empty($slug_settings['types'][$post->post_type]) ? $slug_settings['types'][$post->post_type] : null;
         if ((bool) $slug_settings === true) {
             $post_type_obj = get_post_type_object($post->post_type);
             $slug_this = isset($post_type_obj->rewrite['slug']) ? trim($post_type_obj->rewrite['slug'], '/') : false;
             $slug_real = $this->get_translated_slug($slug_this, $post->post_type, $ld->language_code);
             if (empty($slug_real) || empty($slug_this) || $slug_this == $slug_real) {
                 return $post_link;
             }
             global $wp_rewrite;
             if (isset($wp_rewrite->extra_permastructs[$post->post_type])) {
                 $struct_original = $wp_rewrite->extra_permastructs[$post->post_type]['struct'];
                 $lslash = false !== strpos($struct_original, '/' . $slug_this) ? '/' : '';
                 $wp_rewrite->extra_permastructs[$post->post_type]['struct'] = preg_replace('@' . $lslash . $slug_this . '/@', $lslash . $slug_real . '/', $struct_original);
                 $this->ignore_post_type_link = true;
                 $post_link = get_post_permalink($post->ID, $leavename, $sample);
                 $this->ignore_post_type_link = false;
                 $wp_rewrite->extra_permastructs[$post->post_type]['struct'] = $struct_original;
             } else {
                 $post_link = str_replace($slug_this . '=', $slug_real . '=', $post_link);
             }
         }
         $this->post_link_cache[$post->ID][$leavename . '#' . $sample] = $post_link;
     }
     return $post_link;
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:37,代码来源:slug-translation.php


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