| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly |
| 4 |
if( !defined( 'ABSPATH' ) ) exit; |
| 5 |
|
| 6 |
$args = array(); $items_count = 0; |
| 7 |
if(!empty($_GET['wpfpaged'])) $paged = intval($_GET['wpfpaged']); |
| 8 |
if(!empty($_GET['wpff'])) $args['forumid'] = intval($_GET['wpff']); |
| 9 |
|
| 10 |
$type = WPF()->post->options['recent_posts_type']; |
| 11 |
if(!is_user_logged_in() || !WPF()->perm->usergroup_can('aum')){ $args['private'] = 0; $args['status'] = 0; } |
| 12 |
|
| 13 |
if( $type == 'topics' ){ |
| 14 |
$end_date = time() - (14 * 24 * 60 * 60); |
| 15 |
$args['where'] = "`modified` > '" . date( 'Y-m-d H:i:s', $end_date ) . "'"; |
| 16 |
$args['orderby'] = (!empty($_GET['wpfob'])) ? sanitize_text_field($_GET['wpfob']) : 'modified'; |
| 17 |
$args['order'] = 'DESC'; |
| 18 |
$args['offset'] = ($paged - 1) * WPF()->post->options['topics_per_page']; |
| 19 |
$args['row_count'] = WPF()->post->options['topics_per_page']; |
| 20 |
$topics = WPF()->topic->get_topics($args, $items_count); |
| 21 |
if(empty($topics)){ $end_date = time() - (90 * 24 * 60 * 60); $args['where'] = "`modified` > '" . date( 'Y-m-d H:i:s', $end_date ) . "'"; $topics = WPF()->topic->get_topics($args, $items_count);} |
| 22 |
} |
| 23 |
else{ |
| 24 |
$end_date = time() - (14 * 24 * 60 * 60); |
| 25 |
$args['where'] = "`created` > '" . date( 'Y-m-d H:i:s', $end_date ) . "'"; |
| 26 |
$args['orderby'] = (!empty($_GET['wpfob'])) ? sanitize_text_field($_GET['wpfob']) : 'created'; |
| 27 |
$args['order'] = 'DESC'; |
| 28 |
$args['offset'] = ($paged - 1) * WPF()->post->options['posts_per_page']; |
| 29 |
$args['row_count'] = WPF()->post->options['posts_per_page']; |
| 30 |
$posts = WPF()->post->get_posts($args, $items_count); |
| 31 |
if(empty($posts)){ $end_date = time() - (90 * 24 * 60 * 60); $args['where'] = "`created` > '" . date( 'Y-m-d H:i:s', $end_date ) . "'"; $posts = WPF()->post->get_posts($args, $items_count); } |
| 32 |
} |
| 33 |
?> |
| 34 |
<div class="wpforo-recent-wrap"> |
| 35 |
<div class="wpf-head-bar"> |
| 36 |
<h1 id="wpforo-title" style="padding-bottom:0px; margin-bottom:0px;"> |
| 37 |
<?php wpforo_phrase('Recent Posts') ?> |
| 38 |
<?php if( wpforo_feature('rss-feed') ): ?> |
| 39 |
<div class="wpforo-feed"> |
| 40 |
<span class="wpf-feed-forums"> |
| 41 |
<a href="<?php WPF()->feed->rss2_url( true, 'forum' ); ?>" title="<?php wpforo_phrase('Forums RSS Feed') ?>" target="_blank"> |
| 42 |
<span><?php wpforo_phrase('Forums') ?></span> <i class="fas fa-rss wpfsx"></i> |
| 43 |
</a> |
| 44 |
</span><sep> | </sep> |
| 45 |
<span class="wpf-feed-topics"> |
| 46 |
<a href="<?php WPF()->feed->rss2_url( true, 'topic' ); ?>" title="<?php wpforo_phrase('Topics RSS Feed') ?>" target="_blank"> |
| 47 |
<span><?php wpforo_phrase('Topics') ?></span> <i class="fas fa-rss wpfsx"></i> |
| 48 |
</a> |
| 49 |
</span> |
| 50 |
</div> |
| 51 |
<?php endif; ?> |
| 52 |
</h1> |
| 53 |
<div class="wpf-snavi"> |
| 54 |
<?php WPF()->tpl->pagenavi($paged, $items_count, FALSE); ?> |
| 55 |
</div> |
| 56 |
</div> |
| 57 |
<?php if( $type == 'topics' ): ?> |
| 58 |
<div class="wpforo-recent-content wpfr-topics"> |
| 59 |
<?php if( !empty($topics) ): ?> |
| 60 |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
| 61 |
<tr class="wpf-htr"> |
| 62 |
<td class="wpf-shead-avatar"> </td> |
| 63 |
<td class="wpf-shead-title"><?php wpforo_phrase('Topic Title') ?></td> |
| 64 |
<td class="wpf-shead-forum"><?php wpforo_phrase('Forum') ?></td> |
| 65 |
</tr> |
| 66 |
<?php foreach($topics as $topic) : extract($topic, EXTR_OVERWRITE); ?> |
| 67 |
<?php |
| 68 |
$member = wpforo_member($topic); |
| 69 |
$forum = wpforo_forum($topic['forumid']); |
| 70 |
if(isset($topic['last_post']) && $topic['last_post'] != 0){ |
| 71 |
$last_post = wpforo_post($topic['last_post']); |
| 72 |
$last_poster = wpforo_member($last_post); |
| 73 |
} |
| 74 |
if(isset($topic['first_postid']) && $topic['first_postid'] != 0){ |
| 75 |
$first_post = wpforo_post($topic['first_postid']); |
| 76 |
$intro_posts = WPF()->post->options['layout_extended_intro_posts_count']; if( $intro_posts < 1 ){ $intro_posts = NULL; } else { $intro_posts = ($intro_posts > 1) ? ($intro_posts - 1) : $intro_posts = 0; } |
| 77 |
$first_poster = wpforo_member($first_post); |
| 78 |
$posts = WPF()->post->get_posts( array('topicid' => $topic['topicid'], 'orderby' => '`is_first_post` ASC, `created` DESC, `postid` DESC', 'row_count' => $intro_posts) ); |
| 79 |
} |
| 80 |
$topic_url = wpforo_topic($topic['topicid'], 'url'); |
| 81 |
$post_toglle = WPF()->post->options['layout_extended_intro_posts_toggle']; |
| 82 |
$classes = WPF()->tpl->icon('topic', $topic, false); |
| 83 |
$class = explode( ' ', $classes); $class = ( isset($class[0]) ) ? 'wpf-' . str_replace('fa-', '', $class[0]) : ''; |
| 84 |
?> |
| 85 |
<tr class="wpf-ttr"> |
| 86 |
<td class="wpf-spost-avatar"> |
| 87 |
<?php if( WPF()->perm->usergroup_can('va') && wpforo_feature('avatars') ): ?> |
| 88 |
<?php echo WPF()->member->avatar($member, 'alt="'.esc_attr($member['display_name']).'"', 30) ?> |
| 89 |
<?php endif; ?> |
| 90 |
</td> |
| 91 |
<td class="wpf-spost-title"> |
| 92 |
<a href="<?php echo esc_url(WPF()->topic->get_topic_url($topicid)) ?>" class="wpf-spost-title-link <?php wpforo_unread_topic($topic['topicid']); ?>" title="<?php wpforo_phrase('View entire topic') ?>"><?php echo esc_html($title) ?> <i class="fas fa-chevron-right" style="font-size:11px;"></i></a> |
| 93 |
<p style="font-size:12px"><?php wpforo_member_link($member, 'by'); ?> <?php wpforo_date($topic['created']); ?> | <span style="text-transform: lowercase;"><?php wpforo_phrase('Last post') ?>:</span> <?php wpforo_date($last_post['created']); ?></p> |
| 94 |
</td> |
| 95 |
<td class="wpf-spost-forum"><a href="<?php echo $forum['url'] ?>"><?php echo esc_html($forum['title']); ?></a></td> |
| 96 |
</tr> |
| 97 |
<tr class="wpf-ptr"> |
| 98 |
<td class="wpf-spost-icon"> </td> |
| 99 |
<td colspan="2" class="wpf-stext"> |
| 100 |
<ul> |
| 101 |
<?php if(!empty($posts) && is_array($posts)) : ?> |
| 102 |
<?php foreach($posts as $post) : ?> |
| 103 |
<?php $poster = wpforo_member($post); ?> |
| 104 |
<li> |
| 105 |
<i class="fas fa-reply fa-rotate-180 wpfsx wpfcl-0"></i> <a href="<?php echo esc_url( wpforo_post($post['postid'], 'url') ); ?>" title="<?php wpforo_phrase('REPLY:') ?> <?php echo esc_html( wpforo_text($post['body'], 100, false)) ?>"><?php echo (( $post_body = esc_html(wpforo_text($post['body'], WPF()->post->options['layout_extended_intro_posts_length'], FALSE)) ) ? $post_body : esc_html($post['title'])) ?></a> |
| 106 |
<div class="wpf-spost-topic-recent-posts"><?php wpforo_date($post['created']); ?> <?php wpforo_member_link($poster, 'by %s', 5); ?> </div> |
| 107 |
<br class="wpf-clear"> |
| 108 |
</li> |
| 109 |
<?php endforeach ?> |
| 110 |
<?php if(intval($topic['posts']) > ($intro_posts+1)): ?> |
| 111 |
<li style="text-align:right;"><a href="<?php echo esc_url($topic_url) ?>"><?php wpforo_phrase('view all posts', true, 'lower'); ?> <i class="fas fa-angle-right" aria-hidden="true"></i></a></li> |
| 112 |
<?php endif ?> |
| 113 |
<?php endif ?> |
| 114 |
</ul> |
| 115 |
</td> |
| 116 |
</tr> |
| 117 |
<?php endforeach ?> |
| 118 |
</table> |
| 119 |
<?php else: ?> |
| 120 |
<p class="wpf-p-error"><?php wpforo_phrase('No topics were found here') ?> </p> |
| 121 |
<?php endif; ?> |
| 122 |
</div> |
| 123 |
<div class="wpf-snavi"> |
| 124 |
<?php WPF()->tpl->pagenavi($paged, $items_count, FALSE); ?> |
| 125 |
</div> |
| 126 |
<?php else: ?> |
| 127 |
<div class="wpforo-recent-content wpfr-posts"> |
| 128 |
<?php if( !empty($posts) ): ?> |
| 129 |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
| 130 |
<tr class="wpf-htr"> |
| 131 |
<td class="wpf-shead-avatar"> </td> |
| 132 |
<td class="wpf-shead-title"><?php wpforo_phrase('Post Title') ?></td> |
| 133 |
<td class="wpf-shead-forum"><?php wpforo_phrase('Forum') ?></td> |
| 134 |
</tr> |
| 135 |
<?php foreach($posts as $post) : extract($post, EXTR_OVERWRITE); ?> |
| 136 |
<?php |
| 137 |
$member = wpforo_member($post); |
| 138 |
$forum = wpforo_forum($post['forumid']); |
| 139 |
?> |
| 140 |
<tr class="wpf-ttr"> |
| 141 |
<td class="wpf-spost-avatar"> |
| 142 |
<?php if( WPF()->perm->usergroup_can('va') && wpforo_feature('avatars') ): ?> |
| 143 |
<?php echo WPF()->member->avatar($member, 'alt="'.esc_attr($member['display_name']).'"', 40) ?> |
| 144 |
<?php endif; ?> |
| 145 |
</td> |
| 146 |
<td class="wpf-spost-title"> |
| 147 |
<a href="<?php echo esc_url(WPF()->post->get_post_url($postid)) ?>" class="wpf-spost-title-link <?php wpforo_unread_topic($post['topicid']); ?>" title="<?php wpforo_phrase('View entire post') ?>"><?php echo esc_html($title) ?> <i class="fas fa-chevron-right" style="font-size:11px;"></i></a> |
| 148 |
<p style="font-size:12px"><?php wpforo_member_link($member, 'by'); ?>, <?php wpforo_date($post['created']); ?></p> |
| 149 |
</td> |
| 150 |
<td class="wpf-spost-forum"><a href="<?php echo $forum['url'] ?>"><?php echo esc_html($forum['title']); ?></a></td> |
| 151 |
</tr> |
| 152 |
<tr class="wpf-ptr"> |
| 153 |
<td class="wpf-spost-icon"> </td> |
| 154 |
<td colspan="2" class="wpf-stext"> |
| 155 |
<?php |
| 156 |
$body = wpforo_content_filter( $body ); |
| 157 |
$body = preg_replace('#\[attach\][^\[\]]*\[\/attach\]#is', '', strip_tags($body)); |
| 158 |
wpforo_text($body, 200); |
| 159 |
?> |
| 160 |
</td> |
| 161 |
</tr> |
| 162 |
<?php endforeach ?> |
| 163 |
</table> |
| 164 |
<?php else: ?> |
| 165 |
<p class="wpf-p-error"><?php wpforo_phrase('No posts were found here') ?> </p> |
| 166 |
<?php endif; ?> |
| 167 |
</div> |
| 168 |
<div class="wpf-snavi"> |
| 169 |
<?php WPF()->tpl->pagenavi($paged, $items_count, FALSE); ?> |
| 170 |
</div> |
| 171 |
<?php endif; ?> |
| 172 |
|
| 173 |
|
| 174 |
</div> |
| 175 |
<p> </p> |
| 176 |
<p> </p> |
| 177 |
<p> </p> |
| 178 |
|