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


PHP SucomUtil::decode_utf8方法代码示例

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


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

示例1: get_caption

 public function get_caption($type = 'title', $textlen = 200, $use_post = true, $use_cache = true, $add_hashtags = true, $encode = true, $md_idx = true, $src_id = '')
 {
     if ($this->p->debug->enabled) {
         $this->p->debug->args(array('type' => $type, 'textlen' => $textlen, 'use_post' => $use_post, 'use_cache' => $use_cache, 'add_hashtags' => $add_hashtags, 'encode' => $encode, 'md_idx' => $md_idx, 'src_id' => $src_id));
     }
     $caption = false;
     $separator = html_entity_decode($this->p->options['og_title_sep'], ENT_QUOTES, get_bloginfo('charset'));
     if ($md_idx === true) {
         switch ($type) {
             case 'title':
                 $md_idx = 'og_title';
                 break;
             case 'excerpt':
                 $md_idx = 'og_desc';
                 break;
             case 'both':
                 $md_idx = 'og_caption';
                 break;
         }
     }
     if (is_singular() || $use_post !== false) {
         if (($obj = $this->p->util->get_post_object($use_post)) === false) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('exiting early: invalid object type');
             }
             return $caption;
         }
         $post_id = empty($obj->ID) || empty($obj->post_type) ? 0 : $obj->ID;
     }
     // skip if no metadata index / key name
     if (!empty($md_idx)) {
         if (is_singular() || $use_post !== false) {
             if (!empty($post_id)) {
                 $caption = $this->p->util->get_mod_options('post', $post_id, $md_idx);
             }
             if (!empty($caption) && !empty($add_hashtags) && !preg_match('/( #[a-z0-9\\-]+)+$/U', $caption)) {
                 $hashtags = $this->get_hashtags($post_id, $add_hashtags);
                 if (!empty($hashtags)) {
                     $caption = $this->p->util->limit_text_length($caption, $textlen - strlen($hashtags) - 1, '...', false) . ' ' . $hashtags;
                 }
             }
         } elseif (SucomUtil::is_term_page()) {
             $term = $this->p->util->get_term_object();
             if (!empty($term->term_id)) {
                 $caption = $this->p->util->get_mod_options('taxonomy', $term->term_id, $md_idx);
             }
         } elseif (SucomUtil::is_author_page()) {
             $author = $this->p->util->get_author_object();
             if (!empty($author->ID)) {
                 $caption = $this->p->util->get_mod_options('user', $author->ID, $md_idx);
             }
         }
     }
     if (empty($caption)) {
         if (!empty($md_idx)) {
             $md_prefix = preg_replace('/_(title|desc|caption)$/', '', $md_idx);
             $md_title = $md_prefix . '_title';
             $md_desc = $md_prefix . '_desc';
         } else {
             $md_title = $md_desc = $md_idx;
         }
         // request all values un-encoded, then encode once we have the complete caption text
         switch ($type) {
             case 'title':
                 $caption = $this->get_title($textlen, '...', $use_post, $use_cache, $add_hashtags, false, $md_title, $src_id);
                 break;
             case 'excerpt':
                 $caption = $this->get_description($textlen, '...', $use_post, $use_cache, $add_hashtags, false, $md_desc, $src_id);
                 break;
             case 'both':
                 $prefix = $this->get_title(0, '', $use_post, $use_cache, false, false, $md_title, $src_id) . ' ' . $separator . ' ';
                 $caption = $prefix . $this->get_description($textlen - strlen($prefix), '...', $use_post, $use_cache, $add_hashtags, false, $md_desc, $src_id);
                 break;
         }
     }
     if ($encode === true) {
         $caption = wp_encode_emoji(htmlentities($caption, ENT_QUOTES, get_bloginfo('charset'), false));
     } else {
         // just in case
         $charset = get_bloginfo('charset');
         $caption = html_entity_decode(SucomUtil::decode_utf8($caption), ENT_QUOTES, $charset);
     }
     return apply_filters($this->p->cf['lca'] . '_caption', $caption, $use_post, $add_hashtags, $md_idx, $src_id);
 }
开发者ID:leotaillard,项目名称:btws2016,代码行数:84,代码来源:webpage.php

示例2: get_caption

 public function get_caption($type = 'title', $length = 200, $use_post = true, $use_cache = true, $add_hashtags = true, $encode = true, $custom_idx = 'og_title', $source_id = '')
 {
     if ($this->p->debug->enabled) {
         $this->p->debug->args(array('type' => $type, 'length' => $length, 'use_post' => $use_post, 'use_cache' => $use_cache, 'add_hashtags' => $add_hashtags, 'encode' => $encode, 'custom_idx' => $custom_idx, 'source_id' => $source_id));
     }
     $caption = false;
     $separator = html_entity_decode($this->p->options['og_title_sep'], ENT_QUOTES, get_bloginfo('charset'));
     if (is_singular() || $use_post !== false) {
         if (($obj = $this->p->util->get_post_object($use_post)) === false) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('exiting early: invalid object type');
             }
             return $caption;
         }
         $post_id = empty($obj->ID) || empty($obj->post_type) ? 0 : $obj->ID;
         if (!empty($post_id)) {
             $caption = $this->p->util->get_mod_options('post', $post_id, $custom_idx);
         }
     } elseif (SucomUtil::is_term_page()) {
         $term = $this->p->util->get_term_object();
         if (!empty($term->term_id)) {
             $caption = $this->p->util->get_mod_options('taxonomy', $term->term_id, $custom_idx);
         }
     } elseif (SucomUtil::is_author_page()) {
         $author = $this->p->util->get_author_object();
         if (!empty($author->ID)) {
             $caption = $this->p->util->get_mod_options('user', $author->ID, $custom_idx);
         }
     }
     if (empty($caption)) {
         $custom_prefix = preg_replace('/_(title|desc|caption)$/', '', $custom_idx);
         // request all values un-encoded, then encode once we have the complete caption text
         switch (strtolower($type)) {
             case 'title':
                 $caption = $this->get_title($length, '...', $use_post, $use_cache, $add_hashtags, false, $custom_prefix . '_title', $source_id);
                 break;
             case 'excerpt':
                 $caption = $this->get_description($length, '...', $use_post, $use_cache, $add_hashtags, false, $custom_prefix . '_desc', $source_id);
                 break;
             case 'both':
                 $prefix = $this->get_title(0, '', $use_post, $use_cache, false, false, $custom_prefix . '_title', $source_id) . ' ' . $separator . ' ';
                 $caption = $prefix . $this->get_description($length - strlen($prefix), '...', $use_post, $use_cache, $add_hashtags, false, $custom_prefix . '_desc', $source_id);
                 break;
         }
     }
     if ($encode === true) {
         $caption = htmlentities($caption, ENT_QUOTES, get_bloginfo('charset'), false);
     } else {
         // just in case
         $charset = get_bloginfo('charset');
         $caption = html_entity_decode(SucomUtil::decode_utf8($caption), ENT_QUOTES, $charset);
     }
     return apply_filters($this->p->cf['lca'] . '_caption', $caption, $use_post, $add_hashtags, $custom_idx, $source_id);
 }
开发者ID:jamesvillarrubia,项目名称:uniken-web,代码行数:54,代码来源:webpage.php


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