[100] | 1 | <?php
|
---|
| 2 | function recent_posts_list_block($options)
|
---|
| 3 | {
|
---|
| 4 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
[120] | 5 | $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_recent_posts_list_block.html' : trim( $options[1] );
|
---|
| 6 | $disp_count = empty( $options[2] ) ? '10' : $options[2] ;
|
---|
| 7 | $disp_red = empty( $options[3] ) ? '1' : $options[3] ;
|
---|
| 8 | $disp_green = empty( $options[4] ) ? '7' : $options[4] ;
|
---|
[142] | 9 | $date_format = empty( $options[5] ) ? '' : $options[5] ;
|
---|
| 10 | $time_format = empty( $options[6] ) ? '' : $options[6] ;
|
---|
| 11 | $tag_select = $options[7] ;
|
---|
[435] | 12 | $cat_select = empty( $options[8] ) ? '0' : $options[8] ;
|
---|
| 13 |
|
---|
| 14 | $selected = explode(',' , $cat_select);
|
---|
[142] | 15 |
|
---|
[100] | 16 | $mydirpath = get_xpress_dir_path();
|
---|
| 17 |
|
---|
[142] | 18 | if (empty($date_format)) $date_format = get_settings('date_format');
|
---|
| 19 | if (empty($time_format)) $time_format = get_settings('time_format');
|
---|
[100] | 20 | if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&";
|
---|
[435] | 21 | if (array_search(0,$selected)===0) $cat_select = 0;
|
---|
[157] | 22 |
|
---|
[272] | 23 | $selected_author_id = xpress_selected_author_id('echo=0');
|
---|
[157] | 24 | if (!empty($selected_author_id)){
|
---|
| 25 | $author_where ="author=$selected_author_id&";
|
---|
| 26 | } else {
|
---|
| 27 | $author_where = '';
|
---|
| 28 | }
|
---|
[100] | 29 |
|
---|
| 30 | global $wpdb,$wp_query;
|
---|
| 31 | $block = array();
|
---|
| 32 | $item_no = 0;
|
---|
| 33 | if (!is_null($wpdb)){
|
---|
| 34 | $wp_query->in_the_loop = true; //for use the_tags() in multi lopp
|
---|
[435] | 35 | if ($cat_select) {
|
---|
| 36 | $r = new WP_Query($author_where . $tag_where . "cat=$cat_select&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
|
---|
| 37 | } else {
|
---|
[157] | 38 | $r = new WP_Query($author_where . $tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
|
---|
[100] | 39 | }
|
---|
| 40 | while($r->have_posts()){
|
---|
| 41 | $r->the_post();
|
---|
| 42 | ob_start();
|
---|
| 43 | the_ID();
|
---|
| 44 | $post_id = ob_get_contents();
|
---|
| 45 | ob_end_clean();
|
---|
| 46 |
|
---|
| 47 | ob_start();
|
---|
| 48 | the_title();
|
---|
| 49 | $title = ob_get_contents();
|
---|
| 50 | ob_end_clean();
|
---|
| 51 |
|
---|
| 52 | ob_start();
|
---|
| 53 | the_permalink();
|
---|
| 54 | $permalink = ob_get_contents();
|
---|
| 55 | ob_end_clean();
|
---|
| 56 |
|
---|
| 57 | ob_start();
|
---|
| 58 | the_author_posts_link();
|
---|
| 59 | $author = ob_get_contents();
|
---|
| 60 | ob_end_clean();
|
---|
| 61 |
|
---|
| 62 | ob_start();
|
---|
| 63 | the_category(' • ');
|
---|
| 64 | $category = ob_get_contents();
|
---|
| 65 | ob_end_clean();
|
---|
| 66 |
|
---|
[262] | 67 | if (function_exists('the_tags')){
|
---|
| 68 | ob_start();
|
---|
| 69 | the_tags(__('Tags:', 'xpress') . ' ',' • ','');
|
---|
| 70 | $tags = ob_get_contents();
|
---|
| 71 | ob_end_clean();
|
---|
| 72 | } else {
|
---|
| 73 | $tags = '';
|
---|
| 74 | }
|
---|
[100] | 75 |
|
---|
| 76 | ob_start();
|
---|
[142] | 77 | the_modified_date($date_format);
|
---|
[100] | 78 | $post_modified_date = ob_get_contents();
|
---|
| 79 | ob_end_clean();
|
---|
[262] | 80 |
|
---|
[100] | 81 | ob_start();
|
---|
[142] | 82 | the_modified_date($time_format);
|
---|
[100] | 83 | $post_modified_time = ob_get_contents();
|
---|
| 84 | ob_end_clean();
|
---|
| 85 |
|
---|
| 86 | ob_start();
|
---|
[142] | 87 | the_time($date_format);
|
---|
[100] | 88 | $post_date = ob_get_contents();
|
---|
| 89 | ob_end_clean();
|
---|
| 90 |
|
---|
| 91 | ob_start();
|
---|
[142] | 92 | the_time($time_format);
|
---|
[100] | 93 | $post_time = ob_get_contents();
|
---|
| 94 | ob_end_clean();
|
---|
| 95 |
|
---|
| 96 |
|
---|
| 97 | ob_start();
|
---|
| 98 | comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
|
---|
| 99 | $comments_popup_link = ob_get_contents();
|
---|
| 100 | ob_end_clean();
|
---|
| 101 |
|
---|
| 102 | $red_sec = $disp_red *60*60*24;
|
---|
| 103 | $green_sec = $disp_green *60*60*24;
|
---|
| 104 | ob_start();
|
---|
| 105 | the_time('U');
|
---|
| 106 | $check_time = ob_get_contents();
|
---|
| 107 | ob_end_clean();
|
---|
| 108 | $elapse = time() - $check_time;
|
---|
| 109 | $new_mark = '';
|
---|
| 110 | if ($elapse < $red_sec ) {
|
---|
[121] | 111 | $new_mark = '<em style="color: red; font-size: small;">New! </em>';
|
---|
[100] | 112 |
|
---|
| 113 | } else if ($elapse < $green_sec) {
|
---|
[121] | 114 | $new_mark = '<em style="color: green; font-size: small;">New! </em>';
|
---|
[100] | 115 | }
|
---|
| 116 |
|
---|
| 117 | $post_title = '<a href="' . $permalink . '">' . $title . '</a>';
|
---|
| 118 | $post_date_time = $post_date . ' ' . $post_time ;
|
---|
| 119 | $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ;
|
---|
| 120 | $trackback_url = trackback_url(false);
|
---|
[272] | 121 | $post_viwes = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');
|
---|
| 122 |
|
---|
[100] | 123 | // if (empty($tags)) $tags = __('Not Tag');
|
---|
| 124 |
|
---|
| 125 | $row_data = array(
|
---|
| 126 | 'post_id' => $post_id ,
|
---|
| 127 | 'new_mark' => $new_mark ,
|
---|
| 128 | 'post_title' => $post_title ,
|
---|
| 129 | 'post_date' => $post_date ,
|
---|
| 130 | 'post_time' => $post_time ,
|
---|
| 131 | 'post_date_time' => $post_date_time ,
|
---|
| 132 | 'post_modified_date' => $post_modified_date ,
|
---|
| 133 | 'post_modified_time' => $post_modified_time ,
|
---|
| 134 | 'post_modified_date_time' => $post_modified_date_time ,
|
---|
| 135 | 'post_author' => $author ,
|
---|
| 136 | 'post_category' => $category ,
|
---|
| 137 | 'post_tags' => $tags,
|
---|
| 138 | 'post_views' => $post_viwes,
|
---|
| 139 | 'comment_link' => $comments_popup_link ,
|
---|
| 140 | 'trackback_url' => $trackback_url
|
---|
| 141 | );
|
---|
| 142 |
|
---|
| 143 | $block['contents']['item'.$item_no] = $row_data;
|
---|
| 144 | $item_no++;
|
---|
| 145 | }
|
---|
| 146 | $block['data_count'] = $item_no; //xml unserialise error
|
---|
| 147 | }
|
---|
| 148 | return $block ;
|
---|
| 149 | }
|
---|
| 150 | ?> |
---|