PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / trunk
Forumax – AI Powered Advanced Community Forum Plugin vtrunk
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 2.0.0 2.1.0 All 29 releases
bbp-core / templates / loop-topics.php

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

154 lines 5.5 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 $query = new WP_Query( $args );
48
49 if ( $query->have_posts() && !in_array('bbp-user-page', get_body_class()) ) :
50 echo '<div class="community-posts-wrapper bb-radius">';
51 while ( $query->have_posts() ) : $query->the_post();
52 global $post;
53 $parent_post_id = get_queried_object_id();
54 $favorite = get_post_meta( get_the_ID(), '_bbp_favorite', true );
55 $favorite_count = !empty( $favorite ) ? $favorite[0] : '0';
56 ?>
57 <div class="community-post style-two">
58 <div class="post-content">
59 <div class="author-avatar">
60 <?php
61 echo bbp_get_topic_author_link(
62 array(
63 'post_id' => get_the_ID(),
64 'type' => 'avatar',
65 'size' => 40
66 )
67 );
68 ?>
69 </div>
70 <div class="entry-content">
71 <?php
72 the_title( sprintf( '<a href="%s" rel="bookmark"> <h3 class="post-title">', get_permalink() ), '</h3></a>' );
73 do_action( 'bbpc-resolved-topics' );
74 ?>
75
76 <?php do_action( 'bbp_theme_after_topic_title' ); ?>
77
78 <ul class="meta community-post-meta">
79 <li>
80 <?php echo get_the_post_thumbnail(bbp_get_topic_forum_id(), array(40, 40)); ?>
81 <a href="<?php echo get_permalink( bbp_get_topic_forum_id() ); ?>" class="title">
82 <?php echo get_the_title( bbp_get_topic_forum_id() ); ?>
83 </a>
84 </li>
85 <li>
86 <i class="icon_clock_alt"></i> <?php bbp_topic_post_date(get_the_ID(), true); ?>
87 </li>
88 </ul>
89 </div>
90 </div>
91 <div class="post-meta-wrapper">
92 <ul class="post-meta-info">
93 <li><a href="<?php echo esc_url( get_permalink() ); ?>">
94 <i class="icon_chat_alt"></i> <?php forumax_topic_reply_count(); ?> </a>
95 </li>
96 <li><a href="<?php echo esc_url( get_permalink() ); ?>">
97 <i class="icon_star"></i> <?php echo esc_html( $favorite_count ); ?> </a>
98 </li>
99 </ul>
100 </div>
101 </div>
102 <?php
103 endwhile;
104 wp_reset_postdata();
105 echo '</div>';
106
107 ?>
108 <div class="pagination-wrapper">
109 <div class="view-post-of">
110 <p><?php bbp_forum_pagination_count(); ?></p>
111 </div>
112 <?php if ( $query->max_num_pages > 1 ) : ?>
113 <div class="bbp-pagination">
114 <?php
115 $big = 999999999;
116 $current_url = add_query_arg( 'paged', '', get_pagenum_link() );
117 $current_url = remove_query_arg( 'tab', $current_url );
118
119 echo paginate_links( array(
120 'base' => str_replace( $big, '%#%', esc_url( add_query_arg( 'paged', $big, $current_url ) ) ),
121 'format' => '?paged=%#%',
122 'current' => max( 1, get_query_var('paged') ),
123 'total' => $query->max_num_pages,
124 'prev_text' => '<i class="arrow_carrot-left"></i>',
125 'next_text' => '<i class="arrow_carrot-right"></i>',
126 'add_args' => array('tab' => $topic_status === 'publish' ? '' : 'closed')
127 ));
128 ?>
129 </div>
130 <?php endif; ?>
131 </div>
132 <?php
133
134 elseif ( in_array('bbp-user-page', get_body_class()) ):
135 ?>
136 <div id="bbp-topic-<?php bbp_topic_id(); ?>" class="community-posts-wrapper bb-radius">
137 <?php
138 while ( bbp_topics() ) : bbp_the_topic();
139 bbp_get_template_part( 'loop', 'single-topic' );
140 endwhile;
141 ?>
142 </div>
143 <?php
144 else:
145 ?> <div class="community-posts-wrapper bb-radius"> <?php
146 echo '<h5 class="error frmx-p-4 frmx-mb-0">' . esc_html__( 'Oops! No Posts Found', 'forumax' ) . '</h5>';
147 echo '</div>';
148 endif;
149
150 echo '</div>';
151
152
153
154