XPressME Integration Kit

Trac


Ignore:
Timestamp:
Mar 31, 2009, 7:00:25 PM (15 years ago)
Author:
toemon
Message:

抜粋のロジックを、wp-multibyte-patchと同等の処理を行うようにする。 #82
XOOPS,WordPressの表示切替(ユーザ選択)機能 #11
bump Ver0.20

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/plugins/xpressme/include/custom_functions.php

    r144 r145  
    3131function xpress_is_theme_sidebar_disp(){ 
    3232        global $xpress_config; 
     33        if (is_wordpress_style()) return true; 
    3334        return $xpress_config->is_theme_sidebar_disp; 
    3435}        
     
    276277} 
    277278 
    278 function xpress_the_content($more_link_text = '',$excerpt_size = 0,$show = true) 
    279 { 
    280         $content = get_the_content();    
    281         if($excerpt_size > 0) { 
    282  
    283                 $content = apply_filters('the_excerpt_rss', $content); 
    284                 $content = strip_tags($content); 
    285  
    286                 if (mb_strlen($content) > $excerpt_size){  
    287                         $content = mb_substr($content, 0, $excerpt_size);  
    288                         $content .= '... '; 
    289                         if (!empty($more_link_text)) $content .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>'; 
     279function get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text = '') { 
     280        global $post,$xpress_config; 
     281         
     282        $blog_encoding = get_option('blog_charset'); 
     283        $text = get_the_content(''); 
     284        $text = strip_shortcodes( $text ); 
     285        $text = apply_filters('the_content', $text); 
     286        $text = str_replace(']]>', ']]&gt;', $text); 
     287        $text = strip_tags($text); 
     288        $is_almost_ascii = ($xpress_config->ascii_judged_rate < round(@(mb_strlen($text, $blog_encoding) / strlen($text)) * 100)) ? true : false; 
     289        if($is_almost_ascii) { 
     290                $words = explode(' ', $text, $excerpt_length_word + 1); 
     291 
     292                if(count($words) > $excerpt_length_word) { 
     293                        array_pop($words); 
     294                        array_push($words, ' ... '); 
     295                        $text = implode(' ', $words); 
     296                        if (!empty($more_link_text)) $text .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>'; 
     297 
    290298                } 
    291299        } 
     300        elseif(mb_strlen($text, $blog_encoding) > $excerpt_length_character) { 
     301                $text = mb_substr($text, 0, $xpress_config->excerpt_length_character, $blog_encoding) . ' ... '; 
     302                if (!empty($more_link_text)) $text .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>'; 
     303        } 
     304 
     305        return $text; 
     306} 
     307 
     308function xpress_the_content($more_link_text = null, $stripteaser = 0, $more_file = '',$show = true) 
     309{ 
     310        global $post,$xpress_config; 
     311         
     312         
     313        if ($xpress_config->is_content_excerpt){ 
     314                $excerpt_length_word = $xpress_config->excerpt_length_word; 
     315                $excerpt_length_character = $xpress_config->excerpt_length_character; 
     316                $more_link_text = $xpress_config->more_link_text; 
     317                $content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text); 
     318        } else { 
     319                $content = get_the_content($more_link_text,$stripteaser,$more_file); 
     320                $content = apply_filters('the_content', $content); 
     321                $content = str_replace(']]>', ']]&gt;', $content); 
     322        }        
    292323        if(empty($show)) return $content; 
    293324        echo $content; 
Note: See TracChangeset for help on using the changeset viewer.