XPressME Integration Kit

Trac


Ignore:
Timestamp:
Jun 9, 2009, 5:37:04 PM (15 years ago)
Author:
toemon
Message:

#130 カスタムテンプレートタグでwp_parse_argsを利用
get_xpress_excerpt_contents()
xpress_the_content()
を除き修正

File:
1 edited

Legend:

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

    r262 r272  
    11<?php 
    2 function xpress_the_title($show = true) 
    3 { 
     2function xpress_the_title($args = '') 
     3{ 
     4        $defaults = array( 
     5                'echo' => 1 
     6        ); 
     7        $r = wp_parse_args( $args, $defaults ); 
     8 
     9        extract( $r ); 
     10 
    411        $output = '<div class ="xpress-post-header">' . "\n"; 
    512         
     
    3441        $output .= '</div>' . "\n"; 
    3542         
    36         if (empty($show)) 
    37                 return $output; 
    38         else 
    39                 echo $output; 
     43        if ($echo) 
     44                echo $output; 
     45        else 
     46                return $output; 
    4047 
    4148} 
     
    5360} 
    5461 
    55 function xpress_selected_author($show=true ) { 
     62function xpress_selected_author($args ='' ) { 
     63        $defaults = array( 
     64                'echo' => 1 
     65        ); 
     66        $r = wp_parse_args( $args, $defaults ); 
     67 
     68        extract( $r ); 
     69 
    5670        $output = ''; 
    5771        $author_cookie = get_xpress_dir_name() . "_select_author" ; 
     
    6175                $output = $user_info->display_name; 
    6276        } 
    63         if (empty($show)) 
    64                 return $output; 
    65         else 
    66                 echo $output; 
     77        if ($echo) 
     78                echo $output; 
     79        else 
     80                return $output; 
    6781                 
    6882} 
    69 function xpress_selected_author_id($show=true ) { 
     83function xpress_selected_author_id($args ='' ) { 
     84        $defaults = array( 
     85                'echo' => 1 
     86        ); 
     87        $r = wp_parse_args( $args, $defaults ); 
     88 
     89        extract( $r ); 
    7090        $output = ''; 
    7191        $author_cookie = get_xpress_dir_name() . "_select_author" ; 
     
    7595                $output = ''; 
    7696        } 
    77         if (empty($show)) 
    78                 return $output; 
    79         else 
    80                 echo $output; 
    81                  
    82 } 
    83  
    84 function xpress_now_user_level($show=true ) { 
     97        if ($echo) 
     98                echo $output; 
     99        else 
     100                return $output;          
     101} 
     102 
     103function xpress_now_user_level($args ='' ) { 
    85104        global $current_user; 
     105        $defaults = array( 
     106                'echo' => 1 
     107        ); 
     108        $r = wp_parse_args( $args, $defaults ); 
     109 
     110        extract( $r ); 
     111         
    86112        $output = @$current_user->user_level; 
    87         if (empty($show)) 
    88                 return $output; 
    89         else 
    90                 echo $output;            
    91 } 
    92  
    93  
    94 function xpress_list_pings($trackback, $args, $depth) { 
    95        $GLOBALS['comment'] = $trackback; 
    96         echo '<li id="comment-<?php comment_ID(); ?>">'; 
    97         comment_author_link(); 
    98 } 
    99          
    100 function xpress_credit($show = true) 
     113        if ($echo) 
     114                echo $output; 
     115        else 
     116                return $output; 
     117} 
     118 
     119 
     120         
     121function xpress_credit($args ='') 
    101122{ 
    102123        global $wp_version , $xoops_config; 
     
    105126        } 
    106127         
     128        $defaults = array( 
     129                'echo' => 1 
     130        ); 
     131        $r = wp_parse_args( $args, $defaults ); 
     132 
     133        extract( $r ); 
     134         
    107135        $xpress_version = $xoops_config->module_version; 
    108136        $xpress_codename = $xoops_config->module_codename; 
    109         $ret = '<a href="http://ja.xpressme.info"'. " target='_blank'" . '>XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>'; 
     137        $output = '<a href="http://ja.xpressme.info"'. " target='_blank'" . '>XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>'; 
    110138        if ($xoops_config->is_wpmu) { 
    111                 $ret .= '(included <a href="http://mu.wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress MU ' . $wpmu_version . '</a>)'; 
     139                $output .= '(included <a href="http://mu.wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress MU ' . $wpmu_version . '</a>)'; 
    112140        } else { 
    113141                if (strstr($wp_version,'ME')){ 
    114                         $ret .= '(included <a href="http://wpme.sourceforge.jp/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)'; 
     142                        $output .= '(included <a href="http://wpme.sourceforge.jp/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)'; 
    115143                } else { 
    116                         $ret .= '(included <a href="http://wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)'; 
     144                        $output .= '(included <a href="http://wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)'; 
    117145                } 
    118146        } 
    119         if (empty($show)) 
    120                 return $ret; 
    121         else 
    122                 echo $ret; 
    123 } 
    124  
    125 function xpress_convert_time($show = true) 
    126 { 
    127         $ret =  timer_stop(0) .'sec. '; 
    128         if (empty($show)) 
    129                 return $ret; 
    130         else 
    131                 echo $ret; 
     147        if ($echo) 
     148                echo $output; 
     149        else 
     150                return $output; 
     151} 
     152 
     153function xpress_convert_time($args ='') 
     154{ 
     155        $defaults = array( 
     156                'echo' => 1, 
     157                'format' => '(%.3f sec.)'                
     158        ); 
     159        $r = wp_parse_args( $args, $defaults ); 
     160 
     161        extract( $r ); 
     162         
     163        $output =  sprintf($format,timer_stop(0)); 
     164        if ($echo) 
     165                echo $output; 
     166        else 
     167                return $output; 
    132168} 
    133169 
     
    138174}        
    139175 
    140 function xpress_left_arrow_post_link($show = true) 
     176function xpress_left_arrow_post_link($args ='') 
    141177{ 
    142178        global $xpress_config; 
     179        $defaults = array( 
     180                'echo' => 1 
     181        ); 
     182        $r = wp_parse_args( $args, $defaults ); 
     183 
     184        extract( $r ); 
     185         
    143186        $ret = ''; 
    144187                 
     
    191234                $on_mouse_show = $body_matches[1]; 
    192235        } 
    193         $ret = str_replace('">','" title="'.$on_mouse_show . '">' , $ret); 
    194  
    195         if (empty($show)) 
    196                 return $ret; 
    197         else 
    198                 echo $ret; 
    199 } 
    200  
    201 function xpress_right_arrow_post_link($show = true) 
     236        $output = str_replace('">','" title="'.$on_mouse_show . '">' , $ret); 
     237 
     238        if ($echo) 
     239                echo $output; 
     240        else 
     241                return $output; 
     242} 
     243 
     244function xpress_right_arrow_post_link($args ='') 
    202245{ 
    203246        global $xpress_config; 
     247        $defaults = array( 
     248                'echo' => 1 
     249        ); 
     250        $r = wp_parse_args( $args, $defaults ); 
     251 
     252        extract( $r ); 
     253 
    204254        $ret = '';               
    205255         
     
    252302                $on_mouse_show = $body_matches[1]; 
    253303        } 
    254         $ret = str_replace('">','" title="'.$on_mouse_show . '">' , $ret); 
    255  
    256         if (empty($show)) 
    257                 return $ret; 
    258         else 
    259                 echo $ret;       
     304        $output = str_replace('">','" title="'.$on_mouse_show . '">' , $ret); 
     305 
     306        if ($echo) 
     307                echo $output; 
     308        else 
     309                return $output; 
    260310} 
    261311// page link 
    262 function xpress_left_arrow_posts_link($show = true) 
     312function xpress_left_arrow_posts_link($args ='') 
    263313{ 
    264314        global $xpress_config; 
    265         $ret = ''; 
     315        $defaults = array( 
     316                'echo' => 1 
     317        ); 
     318        $r = wp_parse_args( $args, $defaults ); 
     319 
     320        extract( $r ); 
     321 
     322        $output = ''; 
    266323                 
    267324        if($xpress_config->is_left_page_navi_old){ 
     
    269326                ob_start(); 
    270327                next_posts_link("&laquo; $link_title"); 
    271                 $ret = ob_get_contents(); 
     328                $output = ob_get_contents(); 
    272329                ob_end_clean(); 
    273330        } else { 
     
    275332                ob_start(); 
    276333                previous_posts_link("&laquo; $link_title"); 
    277                 $ret = ob_get_contents(); 
    278                 ob_end_clean(); 
    279         } 
    280  
    281         if (empty($show)) 
    282                 return $ret; 
    283         else 
    284                 echo $ret; 
    285 } 
    286  
    287 function xpress_right_arrow_posts_link($show = true) 
     334                $output = ob_get_contents(); 
     335                ob_end_clean(); 
     336        } 
     337 
     338        if ($echo) 
     339                echo $output; 
     340        else 
     341                return $output; 
     342} 
     343 
     344function xpress_right_arrow_posts_link($args ='') 
    288345{ 
    289346        global $xpress_config; 
    290         $ret = '';               
     347        $defaults = array( 
     348                'echo' => 1 
     349        ); 
     350        $r = wp_parse_args( $args, $defaults ); 
     351 
     352        extract( $r ); 
     353 
     354        $output = '';            
    291355         
    292356        if($xpress_config->is_left_page_navi_old){ 
     
    294358                ob_start(); 
    295359                previous_posts_link("$link_title &raquo;"); 
    296                 $ret = ob_get_contents(); 
     360                $output = ob_get_contents(); 
    297361                ob_end_clean(); 
    298362        } else { 
     
    300364                ob_start(); 
    301365                next_posts_link("$link_title &raquo;"); 
    302                 $ret = ob_get_contents(); 
    303                 ob_end_clean(); 
    304         } 
    305  
    306         if (empty($show)) 
    307                 return $ret; 
    308         else 
    309                 echo $ret;       
     366                $output = ob_get_contents(); 
     367                ob_end_clean(); 
     368        } 
     369 
     370        if ($echo) 
     371                echo $output; 
     372        else 
     373                return $output; 
    310374} 
    311375 
     
    336400// Set and retrieves post views given a post ID or post object.  
    337401// Retrieves post views given a post ID or post object.  
    338 function xpress_post_views_count($post_id=0,$format= '',$show = true) { 
     402function xpress_post_views_count($args ='') { 
    339403        global $xoops_db,$wpdb; 
    340404 
    341405        static $post_cache_views; 
     406 
     407        $defaults = array( 
     408                'post_id' => 0, 
     409                'format'=> __('views :%d','xpressme'), 
     410                'echo' => 1 
     411        ); 
     412        $r = wp_parse_args( $args, $defaults ); 
     413 
     414        extract( $r ); 
    342415 
    343416        if ( empty($post_id) ) { 
     
    361434        if (empty($format)) $format = __('views :%d','xpressme'); 
    362435         
    363         $ret = sprintf($format,$v_count); 
    364  
    365         if ($show) echo $ret; else return $ret; 
     436        $output = sprintf($format,$v_count); 
     437 
     438        if ($echo) 
     439                echo $output; 
     440        else 
     441                return $output; 
    366442} 
    367443 
     
    466542} 
    467543 
    468 function xpress_post_new_link($link_title = 'Post New',$display = true) 
     544function xpress_post_new_link($args ='') 
    469545{ 
    470546        global $xoops_config; 
     547         
     548        $defaults = array( 
     549                'link_title'=> 'Post New', 
     550                'echo' => 1 
     551        ); 
     552        $r = wp_parse_args( $args, $defaults ); 
     553 
     554        extract( $r ); 
     555 
    471556         
    472557        if ($xoops_config->wp_db_version  > 5000){ 
     
    475560                $output = '<a href="'. get_xpress_url() . '/wp-admin/post.php' . '">' . $link_title . '</a>'; 
    476561        }        
    477         if ($display)  
    478                 echo $output; 
    479         else 
    480                 return $output; 
    481 } 
    482  
    483 function xpress_conditional_title($display = true) 
    484 { 
    485         $selected_author = xpress_selected_author(false); 
     562        if ($echo) 
     563                echo $output; 
     564        else 
     565                return $output; 
     566} 
     567 
     568function xpress_conditional_title($args ='') 
     569{ 
     570        $defaults = array( 
     571                'echo' => 1 
     572        ); 
     573        $r = wp_parse_args( $args, $defaults ); 
     574 
     575        extract( $r ); 
     576         
     577        $selected_author = xpress_selected_author('echo=0'); 
    486578         
    487579        $output = __('Main', 'xpressme'); 
     
    507599         
    508600        if (!empty($selected_author)){ 
    509                 $selected_id = xpress_selected_author_id(false); 
     601                $selected_id = xpress_selected_author_id('echo=0'); 
    510602//              $output = get_avatar($selected_id,$size = '32') . sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output; 
    511603                if (empty($output)) 
     
    514606                        $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output; 
    515607        }        
    516         if ($display)  
    517                 echo $output; 
    518         else 
    519                 return $output; 
    520 } 
    521  
    522 function xpress_pings_list($show = true){ 
     608        if ($echo) 
     609                echo $output; 
     610        else 
     611                return $output; 
     612} 
     613 
     614function xpress_pings_list($args =''){ 
     615        $defaults = array( 
     616                'echo' => 1 
     617        ); 
     618        $r = wp_parse_args( $args, $defaults ); 
     619 
     620        extract( $r ); 
    523621         
    524622        $trackbacks = xpress_get_pings(); 
     
    539637        } 
    540638         
    541         if ($show) echo $output; else return $output; 
    542 } 
    543  
    544 function xpress_pings_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { 
     639        if ($echo) 
     640                echo $output; 
     641        else 
     642                return $output; 
     643} 
     644 
     645function xpress_pings_number( $args ='' ) { 
     646        $defaults = array( 
     647                'zero' => __('No Trackback/Pingback', 'xpressme'), 
     648                'one' => __('One Trackback/Pingback', 'xpressme'), 
     649                'more' => __('% TrackBack/Pingback', 'xpressme'), 
     650                'deprecated' => '', 
     651                'echo' => 1 
     652        ); 
     653        $r = wp_parse_args( $args, $defaults ); 
     654 
     655        extract( $r ); 
     656 
    545657        $pings = xpress_get_pings(); 
    546658        if (empty($pings)){ 
     
    550662        } 
    551663        if ( $number > 1 ) 
    552                 $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% TrackBack/Pingback', 'xpressme') : $more); 
     664                $output = str_replace('%', number_format_i18n($number), $more); 
    553665        elseif ( $number == 0 ) 
    554                 $output = ( false === $zero ) ? __('No Trackback/Pingback', 'xpressme') : $zero; 
     666                $output = $zero; 
    555667        else // must be one 
    556                 $output = ( false === $one ) ? __('One Trackback/Pingback', 'xpressme') : $one; 
    557  
    558         echo $output; 
     668                $output = $one; 
     669 
     670        if ($echo) 
     671                echo $output; 
     672        else 
     673                return $output; 
    559674} 
    560675 
     
    608723} 
    609724 
    610 function xpress_get_calendar($sun_color = '#DB0000' ,$sat_color = '#004D99' ,$initial = true) { 
     725function xpress_get_calendar($args = '') { 
    611726        global $wpdb, $m, $monthnum, $year, $wp_locale, $posts , $xoops_config; 
    612727 
     728        $defaults = array( 
     729                sun_color => '#DB0000', 
     730                sat_color => '#004D99', 
     731                initial => true 
     732        ); 
     733        $r = wp_parse_args( $args, $defaults ); 
     734 
     735        extract( $r ); 
    613736        if ($xoops_config->is_wp20){ 
    614737                ob_start(); 
Note: See TracChangeset for help on using the changeset viewer.