XPressME Integration Kit

Trac

source: branches/Ver2.4/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/global_recent_posts_list_block_theme.php @ 792

Last change on this file since 792 was 792, checked in by toemon, 13 years ago

マルチサイト用、最近の投稿(全ブログ)ブロックのオプションに「対象ブログの除外」、「ブログ毎に抽出」を追加、ブロックオプションのデフォルトテンプレートの誤りを修正

File size: 1.9 KB
Line 
1<?php
2// Block Version: 1.0
3function global_recent_posts_list_block($options)
4{
5        $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
6        $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_global_recent_posts_list_block.html' : trim( $options[1] );
7        $disp_count = empty( $options[2] ) ? '10' : $options[2] ;
8        $disp_red = empty( $options[3] ) ? '1' : $options[3] ;
9        $disp_green = empty( $options[4] ) ? '7' : $options[4] ;
10        $date_format = empty( $options[5] ) ? '' : $options[5] ;
11        $time_format = empty( $options[6] ) ? '' : $options[6] ;
12        $shown_for_each_blog = empty( $options[7] ) ? false : true ;           
13        $exclusion_blog = empty( $options[8] ) ? '0' : $options[8] ;
14       
15        $mydirpath = get_xpress_dir_path();
16       
17        if (xpress_is_multiblog() && function_exists('get_blog_list')){
18                if (empty($date_format)) $date_format = get_settings('date_format');
19                if (empty($time_format)) $time_format = get_settings('time_format');
20                if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&";
21               
22                global $wpdb,$wp_query;
23                $block = array();
24               
25                $data_array = xpress_grobal_recent_posts($disp_count,$exclusion_blog,$shown_for_each_blog);
26                $item_no = 0;
27                $red_sec = $disp_red *60*60*24;
28                $green_sec = $disp_green *60*60*24;
29                foreach($data_array as $data){
30                        $elapse = time() - $data->post_unix_time;
31                        $new_mark = '';
32                        if ($elapse < $red_sec ) {
33                                $new_mark = '<em style="color: red; font-size: small;">New! </em>';
34
35                        } else if ($elapse < $green_sec) {
36                                $new_mark = '<em style="color: green; font-size: small;">New! </em>';
37                        }
38                        $data->new_mark = $new_mark;
39
40                        $row_data = get_object_vars($data);
41                               
42                        $block['contents']['item'.$item_no] = $row_data;
43                        $item_no++;
44                }
45                $block['data_count'] = $item_no;  //xml unserialise error
46                $block['shown_for_each_blog'] = $shown_for_each_blog;
47        } else {
48                $block['err_message'] = __('This blog is not set to the multi blog.', 'xpress');
49        }
50               
51        return $block ;
52}
53?>
Note: See TracBrowser for help on using the repository browser.