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