XPressME Integration Kit

Trac


Ignore:
Timestamp:
Oct 28, 2009, 11:00:33 AM (15 years ago)
Author:
toemon
Message:

最新の記事内容ブロックに、日付による抽出オプション追加 Fixes #240

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/recent_posts_content_block_theme.php

    r274 r425  
    66        $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ; 
    77        $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_recent_posts_content_block.html' : trim( $options[1] ); 
    8         $disp_count =  ($options[2])?intval($options[2]):10; 
    9         $excerpt = empty( $options[3] ) ? false : true ; 
    10         $excerpt_size =  ($options[4])?intval($options[4]):100; 
    11         $date_format = empty( $options[5] ) ? '' : $options[5] ; 
    12         $time_format = empty( $options[6] ) ? '' : $options[6] ; 
    13         $tag_select = $options[7] ; 
    14     $selected = array_slice($options,8); // get allowed cats 
     8        $day_select = ($options[2])?intval($options[2]):0; 
     9        $day_size = ($options[3])?intval($options[3]):0; 
     10        $disp_count =  ($options[4])?intval($options[4]):10; 
     11        $excerpt = empty( $options[5] ) ? false : true ; 
     12        $excerpt_size =  ($options[6])?intval($options[6]):100; 
     13        $date_format = empty( $options[7] ) ? '' : $options[7] ; 
     14        $time_format = empty( $options[8] ) ? '' : $options[8] ; 
     15        $tag_select = $options[9] ; 
     16    $selected = array_slice($options,10); // get allowed cats 
    1517 
    1618        $mydirpath = get_xpress_dir_path(); 
     
    2628                $author_where = ''; 
    2729        } 
     30         
     31        $date_today = mktime (0, 0, 0, date("m"), date("d"), date("Y")); 
     32        $between_days = $day_size * 60 * 60 * 24; 
     33         
    2834        global $wpdb,$wp_query; 
    2935        $block = array(); 
     
    3339                if (array_search(0,$selected)===0) { 
    3440                        $r = new WP_Query($author_where . $tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish"); 
    35  
    3641                } else { 
    3742                        $cat_id = implode(',',$selected); 
    38                         $r = new WP_Query($author_where . $tag_where . "cat=$cat_id&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish"); 
     43                        $r = new WP_Query($author_where . $tag_where ."cat=$cat_id&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish"); 
    3944                } 
    4045                while($r->have_posts()){                         
    4146                        $r->the_post(); 
     47                        if ($day_select == 1){ 
     48                                $post_date = mktime (0, 0, 0, get_the_time("m"), get_the_time("d"), get_the_time("Y")); 
     49                                $base_date = $date_today - $between_days; 
     50                                if ($post_date < $base_date) continue; 
     51                        } 
     52                        if ($day_select == 2){ 
     53                                $post_date = mktime (0, 0, 0, get_the_time("m"), get_the_time("d"), get_the_time("Y")); 
     54                                if (empty($lastes_date)) $lastes_date = $post_date; 
     55                                $base_date = $lastes_date - $between_days; 
     56                                if ($post_date < $base_date) continue; 
     57                        } 
     58                         
    4259                        ob_start(); 
    4360                                the_ID(); 
Note: See TracChangeset for help on using the changeset viewer.