BBP_Replies_Widget::widget( mixed $args, array $instance )
Displays the output, the replies list
Description
Parameters
- $args
-
(Required)
- $instance
-
(Required)
Source
File: bp-forums/common/widgets.php
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 | public function widget( $args , $instance ) { // Get widget settings $settings = $this ->parse_settings( $instance ); // Typical WordPress filter $settings [ 'title' ] = apply_filters( 'widget_title' , $settings [ 'title' ], $instance , $this ->id_base ); // Forums filter $settings [ 'title' ] = apply_filters( 'bbp_replies_widget_title' , $settings [ 'title' ], $instance , $this ->id_base ); // Note: private and hidden forums will be excluded via the // bbp_pre_get_posts_normalize_forum_visibility action and function. $widget_query = new WP_Query( array ( 'post_type' => bbp_get_reply_post_type(), 'post_status' => array ( bbp_get_public_status_id(), bbp_get_closed_status_id() ), 'posts_per_page' => (int) $settings [ 'max_shown' ], 'ignore_sticky_posts' => true, 'no_found_rows' => true, ) ); // Bail if no replies if ( ! $widget_query ->have_posts() ) { return ; } echo $args [ 'before_widget' ]; if ( ! empty ( $settings [ 'title' ] ) ) { echo $args [ 'before_title' ] . $settings [ 'title' ] . $args [ 'after_title' ]; } ?> <ul> <?php while ( $widget_query ->have_posts() ) : $widget_query ->the_post(); ?> <li> <?php // Verify the reply ID $reply_id = bbp_get_reply_id( $widget_query ->post->ID ); $reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url( bbp_get_reply_url( $reply_id ) ) . '" title="' . esc_attr( bbp_get_reply_excerpt( $reply_id , 50 ) ) . '">' . bbp_get_reply_topic_title( $reply_id ) . '</a>' ; // Only query user if showing them if ( ! empty ( $settings [ 'show_user' ] ) ) : $author_link = bbp_get_reply_author_link( array ( 'post_id' => $reply_id , 'type' => 'both' , 'size' => 14 ) ); else : $author_link = false; endif ; // Reply author, link, and timestamp if ( ! empty ( $settings [ 'show_date' ] ) && ! empty ( $author_link ) ) : // translators: 1: reply author, 2: reply link, 3: reply timestamp printf( __( '%1$s on %2$s %3$s' , 'buddyboss' ), $author_link , $reply_link , '<div>' . bbp_get_time_since( get_the_time( 'U' ) ) . '</div>' ); // Reply link and timestamp elseif ( ! empty ( $settings [ 'show_date' ] ) ) : // translators: 1: reply link, 2: reply timestamp printf( __( '%1$s %2$s' , 'buddyboss' ), $reply_link , '<div>' . bbp_get_time_since( get_the_time( 'U' ) ) . '</div>' ); // Reply author and title elseif ( ! empty ( $author_link ) ) : // translators: 1: reply author, 2: reply link printf( __( '%1$s on %2$s' , 'buddyboss' ), $author_link , $reply_link ); // Only the reply title else : // translators: 1: reply link printf( __( '%1$s' , 'buddyboss' ), $reply_link ); endif ; ?> </li> <?php endwhile ; ?> </ul> <?php echo $args [ 'after_widget' ]; // Reset the $post global wp_reset_postdata(); } |
Changelog
Version | Description |
---|---|
bbPress (r2653) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.