PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.1
Forumax – AI Powered Advanced Community Forum Plugin v2.5.1
2.5.1 2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 All 31 releases
bbp-core / templates / loop-topics.php

loop-topics.php in Forumax – AI Powered Advanced Community Forum Plugin 2.5.1, at templates/loop-topics.php

156 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Topics Loop
4 *
5 * @package bbPress
6 * @subpackage Theme
7 */
8
9 // Exit if accessed directly
10 defined( 'ABSPATH' ) || exit;
11
12 do_action( 'bbp_template_before_topics_loop' );
13
14 bbp_get_template_part('loop-topics-head');
15 ?>
16
17 <div class="load-forum">
18 <?php
19
20 $paged = get_query_var('paged') ? get_query_var('paged') : 1;
21 $is_queried_obj = is_singular('forum') ? get_queried_object_id() : false;
22 $user_id = is_singular('forum') ? false : bbp_get_displayed_user_field('ID');
23 $topic_status = isset($_GET['tab']) && $_GET['tab'] === 'closed' ? 'closed' : 'publish';
24
25 $args = [
26 'post_type' => 'topic',
27 'post_parent' => $is_queried_obj,
28 'post_status' => $topic_status,
29 'posts_per_page' => get_option('_bbp_topics_per_page', 10),
30 'order' => 'DESC',
31 'orderby' => 'ID',
32 'paged' => $paged,
33 'author' => $user_id
34 ];
35
36 // If is topic tag page
37 if ( is_tax('topic-tag') ) {
38 $args['tax_query'] = [
39 [
40 'taxonomy' => 'topic-tag',
41 'field' => 'slug',
42 'terms' => get_queried_object()->slug,
43 ]
44 ];
45 }
46
47 // User profile pages render the bbPress topics loop below, so skip this query there.
48 $is_user_page = forumax_is_user_profile_page();
49 $query = $is_user_page ? null : new WP_Query( $args );
50
51 if ( ! $is_user_page && $query->have_posts() ) :
52 echo '<div class="community-posts-wrapper bb-radius">';
53 while ( $query->have_posts() ) : $query->the_post();
54 global $post;
55 $parent_post_id = get_queried_object_id();
56 $favorite = get_post_meta( get_the_ID(), '_bbp_favorite', true );
57 $favorite_count = !empty( $favorite ) ? $favorite[0] : '0';
58 ?>
59 <div class="community-post style-two">
60 <div class="post-content">
61 <div class="author-avatar">
62 <?php
63 echo bbp_get_topic_author_link(
64 array(
65 'post_id' => get_the_ID(),
66 'type' => 'avatar',
67 'size' => 40
68 )
69 );
70 ?>
71 </div>
72 <div class="entry-content">
73 <?php
74 the_title( sprintf( '<a href="%s" rel="bookmark"> <h3 class="post-title">', get_permalink() ), '</h3></a>' );
75 do_action( 'bbpc-resolved-topics' );
76 ?>
77
78 <?php do_action( 'bbp_theme_after_topic_title' ); ?>
79
80 <ul class="meta community-post-meta">
81 <li>
82 <?php echo get_the_post_thumbnail(bbp_get_topic_forum_id(), array(40, 40)); ?>
83 <a href="<?php echo get_permalink( bbp_get_topic_forum_id() ); ?>" class="title">
84 <?php echo get_the_title( bbp_get_topic_forum_id() ); ?>
85 </a>
86 </li>
87 <li>
88 <i class="icon_clock_alt"></i> <?php bbp_topic_post_date(get_the_ID(), true); ?>
89 </li>
90 </ul>
91 </div>
92 </div>
93 <div class="post-meta-wrapper">
94 <ul class="post-meta-info">
95 <li><a href="<?php echo esc_url( get_permalink() ); ?>">
96 <i class="icon_chat_alt"></i> <?php forumax_topic_reply_count(); ?> </a>
97 </li>
98 <li><a href="<?php echo esc_url( get_permalink() ); ?>">
99 <i class="icon_star"></i> <?php echo esc_html( $favorite_count ); ?> </a>
100 </li>
101 </ul>
102 </div>
103 </div>
104 <?php
105 endwhile;
106 wp_reset_postdata();
107 echo '</div>';
108
109 ?>
110 <div class="pagination-wrapper">
111 <div class="view-post-of">
112 <p><?php bbp_forum_pagination_count(); ?></p>
113 </div>
114 <?php if ( $query->max_num_pages > 1 ) : ?>
115 <div class="bbp-pagination">
116 <?php
117 $big = 999999999;
118 $current_url = add_query_arg( 'paged', '', get_pagenum_link() );
119 $current_url = remove_query_arg( 'tab', $current_url );
120
121 echo paginate_links( array(
122 'base' => str_replace( $big, '%#%', esc_url( add_query_arg( 'paged', $big, $current_url ) ) ),
123 'format' => '?paged=%#%',
124 'current' => max( 1, get_query_var('paged') ),
125 'total' => $query->max_num_pages,
126 'prev_text' => '<i class="arrow_carrot-left"></i>',
127 'next_text' => '<i class="arrow_carrot-right"></i>',
128 'add_args' => array('tab' => $topic_status === 'publish' ? '' : 'closed')
129 ));
130 ?>
131 </div>
132 <?php endif; ?>
133 </div>
134 <?php
135
136 elseif ( $is_user_page ):
137 ?>
138 <div id="bbp-topic-<?php bbp_topic_id(); ?>" class="community-posts-wrapper bb-radius">
139 <?php
140 while ( bbp_topics() ) : bbp_the_topic();
141 bbp_get_template_part( 'loop', 'single-topic' );
142 endwhile;
143 ?>
144 </div>
145 <?php
146 else:
147 ?> <div class="community-posts-wrapper bb-radius"> <?php
148 echo '<h5 class="error frmx-p-4 frmx-mb-0">' . esc_html__( 'Oops! No Posts Found', 'forumax' ) . '</h5>';
149 echo '</div>';
150 endif;
151
152 echo '</div>';
153
154
155
156