[537] | 1 | <?php
|
---|
| 2 | // Block Version: 1.0
|
---|
| 3 | function global_recent_posts_list_block($options)
|
---|
| 4 | {
|
---|
| 5 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
[792] | 6 | $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_global_recent_posts_list_block.html' : trim( $options[1] );
|
---|
[537] | 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] ;
|
---|
[792] | 12 | $shown_for_each_blog = empty( $options[7] ) ? false : true ;
|
---|
| 13 | $exclusion_blog = empty( $options[8] ) ? '0' : $options[8] ;
|
---|
| 14 |
|
---|
[537] | 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 |
|
---|
[792] | 25 | $data_array = xpress_grobal_recent_posts($disp_count,$exclusion_blog,$shown_for_each_blog);
|
---|
[537] | 26 | $item_no = 0;
|
---|
[545] | 27 | $red_sec = $disp_red *60*60*24;
|
---|
| 28 | $green_sec = $disp_green *60*60*24;
|
---|
[537] | 29 | foreach($data_array as $data){
|
---|
[545] | 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 |
|
---|
[537] | 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
|
---|
[792] | 46 | $block['shown_for_each_blog'] = $shown_for_each_blog;
|
---|
[537] | 47 | } else {
|
---|
| 48 | $block['err_message'] = __('This blog is not set to the multi blog.', 'xpress');
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | return $block ;
|
---|
| 52 | }
|
---|
| 53 | ?> |
---|