PluginProbe
bbPress / 2.6.19
bbPress v2.6.19
2.6.19 2.6.18 2.6.17 trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 All 74 releases
bbpress / includes / common / shortcodes.php

shortcodes.php in bbPress 2.6.19, at includes/common/shortcodes.php

888 lines 22.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress Shortcodes
5 *
6 * @package bbPress
7 * @subpackage Shortcodes
8 */
9
10 // Exit if accessed directly
11 defined( 'ABSPATH' ) || exit;
12
13 if ( ! class_exists( 'BBP_Shortcodes' ) ) :
14 /**
15 * bbPress Shortcode Class
16 *
17 * @since 2.0.0 bbPress (r3032)
18 */
19 class BBP_Shortcodes {
20
21 /** Vars ******************************************************************/
22
23 /**
24 * @var array Shortcode => function
25 */
26 public $codes = array();
27
28 /** Functions *************************************************************/
29
30 /**
31 * Add the register_shortcodes action to bbp_init
32 *
33 * @since 2.0.0 bbPress (r3143)
34 *
35 */
36 public function __construct() {
37 $this->setup_globals();
38 $this->add_shortcodes();
39 }
40
41 /**
42 * Shortcode globals
43 *
44 * @since 2.0.0 bbPress (r3344)
45 *
46 * @access private
47 */
48 private function setup_globals() {
49
50 // phpcs:disable PEAR.Functions.FunctionCallSignature.CloseBracketLine
51
52 // Setup the shortcodes
53 $this->codes = apply_filters(
54 'bbp_shortcodes',
55 array(
56
57 /** Forums ********************************************************/
58
59 'bbp-forum-index' => array( $this, 'display_forum_index' ), // Forum Index
60 'bbp-forum-form' => array( $this, 'display_forum_form' ), // Topic form
61 'bbp-single-forum' => array( $this, 'display_forum' ), // Specific forum - pass an 'id' attribute
62
63 /** Topics ********************************************************/
64
65 'bbp-topic-index' => array( $this, 'display_topic_index' ), // Topic index
66 'bbp-topic-form' => array( $this, 'display_topic_form' ), // Topic form
67 'bbp-single-topic' => array( $this, 'display_topic' ), // Specific topic - pass an 'id' attribute
68
69 /** Topic Tags ****************************************************/
70
71 'bbp-topic-tags' => array( $this, 'display_topic_tags' ), // All topic tags in a cloud
72 'bbp-single-tag' => array( $this, 'display_topics_of_tag' ), // Topics of Tag
73
74 /** Replies *******************************************************/
75
76 'bbp-reply-form' => array( $this, 'display_reply_form' ), // Reply form
77 'bbp-single-reply' => array( $this, 'display_reply' ), // Specific reply - pass an 'id' attribute
78
79 /** Views *********************************************************/
80
81 'bbp-single-view' => array( $this, 'display_view' ), // Single view
82
83 /** Search ********************************************************/
84
85 'bbp-search-form' => array( $this, 'display_search_form' ), // Search form
86 'bbp-search' => array( $this, 'display_search' ), // Search
87
88 /** Account *******************************************************/
89
90 'bbp-login' => array( $this, 'display_login' ), // Login
91 'bbp-register' => array( $this, 'display_register' ), // Register
92 'bbp-lost-pass' => array( $this, 'display_lost_pass' ), // Lost Password
93
94 /** Others *******************************************************/
95
96 'bbp-stats' => array( $this, 'display_stats' ), // Stats
97 )
98 );
99
100 // phpcs:enable
101 }
102
103 /**
104 * Register the bbPress shortcodes
105 *
106 * @since 2.0.0 bbPress (r3344)
107 */
108 private function add_shortcodes() {
109 foreach ( (array) $this->codes as $code => $function ) {
110 add_shortcode( $code, $function );
111 }
112 }
113
114 /**
115 * Unset some globals in the $bbp object that hold query related info
116 *
117 * @since 2.0.0 bbPress (r3344)
118 */
119 private function unset_globals() {
120 $bbp = bbpress();
121
122 // Unset global queries
123 $bbp->forum_query = new WP_Query();
124 $bbp->topic_query = new WP_Query();
125 $bbp->reply_query = new WP_Query();
126 $bbp->search_query = new WP_Query();
127
128 // Unset global ID's
129 $bbp->current_view_id = 0;
130 $bbp->current_forum_id = 0;
131 $bbp->current_topic_id = 0;
132 $bbp->current_reply_id = 0;
133 $bbp->current_topic_tag_id = 0;
134
135 // Reset the post data
136 wp_reset_postdata();
137 }
138
139 /** Output Buffers ********************************************************/
140
141 /**
142 * Start an output buffer.
143 *
144 * This is used to put the contents of the shortcode into a variable rather
145 * than outputting the HTML at run-time. This allows shortcodes to appear
146 * in the correct location in the_content() instead of when it's created.
147 *
148 * @since 2.0.0 bbPress (r3344)
149 *
150 * @param string $query_name
151 */
152 private function start( $query_name = '' ) {
153
154 // Set query name
155 bbp_set_query_name( $query_name );
156
157 // Start output buffer
158 ob_start();
159 }
160
161 /**
162 * Return the contents of the output buffer and flush its contents.
163 *
164 * @since 2.0.0 bbPress (r3344)
165 *
166 * @return string Contents of output buffer.
167 */
168 private function end() {
169
170 // Unset globals
171 $this->unset_globals();
172
173 // Get the query name, for filter
174 $query_name = bbp_get_query_name();
175
176 // Reset the query name
177 bbp_reset_query_name();
178
179 // Return and flush the output buffer
180 $output = ob_get_clean();
181
182 /**
183 * Filters the contents of the output buffer before returning.
184 *
185 * @since 2.6.0 bbPress (r6438)
186 *
187 * @param string $output The contents of the output buffer.
188 * @param string $query_name The query name used for this output.
189 */
190 return apply_filters( 'bbp_display_shortcode', $output, $query_name );
191 }
192
193 /** Forum shortcodes ******************************************************/
194
195 /**
196 * Display an index of all visible root level forums in an output buffer
197 * and return to ensure that post/page contents are displayed first.
198 *
199 * @since 2.0.0 bbPress (r3032)
200 *
201 * @return string
202 */
203 public function display_forum_index() {
204
205 // Unset globals
206 $this->unset_globals();
207
208 // Start output buffer
209 $this->start( 'bbp_forum_archive' );
210
211 bbp_get_template_part( 'content', 'archive-forum' );
212
213 // Return contents of output buffer
214 return $this->end();
215 }
216
217 /**
218 * Display the contents of a specific forum ID in an output buffer
219 * and return to ensure that post/page contents are displayed first.
220 *
221 * @since 2.0.0 bbPress (r3032)
222 *
223 * @param array $attr
224 * @param string $content
225 * @return string
226 */
227 public function display_forum( $attr, $content = '' ) {
228
229 // Sanity check required info
230 if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) {
231 return $content;
232 }
233
234 // Set passed attribute to $forum_id for clarity
235 $forum_id = bbpress()->current_forum_id = $attr['id'];
236
237 // Bail if ID passed is not a forum
238 if ( ! bbp_is_forum( $forum_id ) ) {
239 return $content;
240 }
241
242 // Start output buffer
243 $this->start( 'bbp_single_forum' );
244
245 // Check forum caps
246 if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) {
247 bbp_get_template_part( 'content', 'single-forum' );
248
249 // Forum is private and user does not have caps
250 } elseif ( bbp_is_forum_private( $forum_id, false ) ) {
251 bbp_get_template_part( 'feedback', 'no-access' );
252 }
253
254 // Return contents of output buffer
255 return $this->end();
256 }
257
258 /**
259 * Display the forum form in an output buffer and return to ensure
260 * post/page contents are displayed first.
261 *
262 * @since 2.1.0 bbPress (r3566)
263 */
264 public function display_forum_form() {
265
266 // Start output buffer
267 $this->start( 'bbp_forum_form' );
268
269 // Output templates
270 bbp_get_template_part( 'form', 'forum' );
271
272 // Return contents of output buffer
273 return $this->end();
274 }
275
276 /** Topic shortcodes ******************************************************/
277
278 /**
279 * Display an index of all visible root level topics in an output buffer
280 * and return to ensure that post/page contents are displayed first.
281 *
282 * @since 2.0.0 bbPress (r3032)
283 *
284 * @return string
285 */
286 public function display_topic_index() {
287
288 // Unset globals
289 $this->unset_globals();
290
291 // Filter the query
292 if ( ! bbp_is_topic_archive() ) {
293 add_filter( 'bbp_before_has_topics_parse_args', array( $this, 'display_topic_index_query' ) );
294 }
295
296 // Start output buffer
297 $this->start( 'bbp_topic_archive' );
298
299 // Output template
300 bbp_get_template_part( 'content', 'archive-topic' );
301
302 // Return contents of output buffer
303 return $this->end();
304 }
305
306 /**
307 * Display the contents of a specific topic ID in an output buffer
308 * and return to ensure that post/page contents are displayed first.
309 *
310 * @since 2.0.0 bbPress (r3032)
311 *
312 * @param array $attr
313 * @param string $content
314 * @return string
315 */
316 public function display_topic( $attr, $content = '' ) {
317
318 // Sanity check required info
319 if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) {
320 return $content;
321 }
322
323 // Unset globals
324 $this->unset_globals();
325
326 // Set passed attribute to $forum_id for clarity
327 $topic_id = bbpress()->current_topic_id = $attr['id'];
328 $forum_id = bbp_get_topic_forum_id( $topic_id );
329
330 // Bail if ID passed is not a topic
331 if ( ! bbp_is_topic( $topic_id ) ) {
332 return $content;
333 }
334
335 // Do not render a non-public topic for users who cannot read it.
336 if ( ! bbp_is_topic_public( $topic_id ) && ! current_user_can( 'read_topic', $topic_id ) ) {
337 return $content;
338 }
339
340 // Reset the queries if not in theme compat
341 if ( ! bbp_is_theme_compat_active() ) {
342
343 $bbp = bbpress();
344
345 // Reset necessary forum_query attributes for topics loop to function
346 $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type();
347 $bbp->forum_query->in_the_loop = true;
348 $bbp->forum_query->post = get_post( $forum_id );
349
350 // Reset necessary topic_query attributes for topics loop to function
351 $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type();
352 $bbp->topic_query->in_the_loop = true;
353 $bbp->topic_query->post = get_post( $topic_id );
354 }
355
356 // Start output buffer
357 $this->start( 'bbp_single_topic' );
358
359 // Check forum caps
360 if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) {
361 bbp_get_template_part( 'content', 'single-topic' );
362
363 // Forum is private and user does not have caps
364 } elseif ( bbp_is_forum_private( $forum_id, false ) ) {
365 bbp_get_template_part( 'feedback', 'no-access' );
366 }
367
368 // Return contents of output buffer
369 return $this->end();
370 }
371
372 /**
373 * Display the topic form in an output buffer and return to ensure
374 * post/page contents are displayed first.
375 *
376 * Supports 'forum_id' attribute to display the topic form for a particular
377 * forum. This currently has styling issues from not being wrapped in
378 * <div id="bbpress-forums" class="bbpress-wrapper"></div> which will need to be sorted out later.
379 *
380 * @since 2.0.0 bbPress (r3042)
381 *
382 * @param array $attr
383 * @param string $content
384 * @return string
385 */
386 public function display_topic_form( $attr = array(), $content = '' ) {
387
388 // Sanity check supplied info
389 if ( ! empty( $content ) || ( ! empty( $attr['forum_id'] ) && ( ! is_numeric( $attr['forum_id'] ) || ! bbp_is_forum( $attr['forum_id'] ) ) ) ) {
390 return $content;
391 }
392
393 // Unset globals
394 $this->unset_globals();
395
396 // If forum id is set, use the 'bbp_single_forum' query name
397 if ( ! empty( $attr['forum_id'] ) ) {
398
399 // Set the global current_forum_id for future requests
400 bbpress()->current_forum_id = $forum_id = bbp_get_forum_id( $attr['forum_id'] );
401
402 // Start output buffer
403 $this->start( 'bbp_single_forum' );
404
405 // No forum id was passed
406 } else {
407
408 // Set the $forum_id variable to satisfy checks below
409 $forum_id = 0;
410
411 // Start output buffer
412 $this->start( 'bbp_topic_form' );
413 }
414
415 // If the forum id is set, check forum caps else display normal topic form
416 if ( empty( $forum_id ) || bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) {
417 bbp_get_template_part( 'form', 'topic' );
418
419 // Forum is private and user does not have caps
420 } elseif ( bbp_is_forum_private( $forum_id, false ) ) {
421 bbp_get_template_part( 'feedback', 'no-access' );
422 }
423
424 // Return contents of output buffer
425 return $this->end();
426 }
427
428 /** Replies ***************************************************************/
429
430 /**
431 * Display the contents of a specific reply ID in an output buffer
432 * and return to ensure that post/page contents are displayed first.
433 *
434 * @since 2.1.0 bbPress (r3634)
435 *
436 * @param array $attr
437 * @param string $content
438 * @return string
439 */
440 public function display_reply( $attr, $content = '' ) {
441
442 // Sanity check required info
443 if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) {
444 return $content;
445 }
446
447 // Unset globals
448 $this->unset_globals();
449
450 // Set passed attribute to $reply_id for clarity
451 $reply_id = bbpress()->current_reply_id = $attr['id'];
452 $forum_id = bbp_get_reply_forum_id( $reply_id );
453
454 // Bail if ID passed is not a reply
455 if ( ! bbp_is_reply( $reply_id ) ) {
456 return $content;
457 }
458
459 // Do not render a non-public reply or its parent topic to unauthorized users.
460 $topic_id = bbp_get_reply_topic_id( $reply_id );
461 if ( ( ! bbp_is_reply_public( $reply_id ) && ! current_user_can( 'read_reply', $reply_id ) ) || ( ! bbp_is_topic_public( $topic_id ) && ! current_user_can( 'read_topic', $topic_id ) ) ) {
462 return $content;
463 }
464
465 // Reset the queries if not in theme compat
466 if ( ! bbp_is_theme_compat_active() ) {
467
468 $bbp = bbpress();
469
470 // Reset necessary forum_query attributes for reply loop to function
471 $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type();
472 $bbp->forum_query->in_the_loop = true;
473 $bbp->forum_query->post = get_post( $forum_id );
474
475 // Reset necessary reply_query attributes for reply loop to function
476 $bbp->reply_query->query_vars['post_type'] = bbp_get_reply_post_type();
477 $bbp->reply_query->in_the_loop = true;
478 $bbp->reply_query->post = get_post( $reply_id );
479 }
480
481 // Start output buffer
482 $this->start( 'bbp_single_reply' );
483
484 // Check forum caps
485 if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) {
486 bbp_get_template_part( 'content', 'single-reply' );
487
488 // Forum is private and user does not have caps
489 } elseif ( bbp_is_forum_private( $forum_id, false ) ) {
490 bbp_get_template_part( 'feedback', 'no-access' );
491 }
492
493 // Return contents of output buffer
494 return $this->end();
495 }
496
497 /**
498 * Display the reply form in an output buffer and return to ensure
499 * post/page contents are displayed first.
500 *
501 * @since 2.0.0 bbPress (r3042)
502 */
503 public function display_reply_form() {
504
505 // Start output buffer
506 $this->start( 'bbp_reply_form' );
507
508 // Output templates
509 bbp_get_template_part( 'form', 'reply' );
510
511 // Return contents of output buffer
512 return $this->end();
513 }
514
515 /** Topic Tags ************************************************************/
516
517 /**
518 * Display a tag cloud of all topic tags in an output buffer and return to
519 * ensure that post/page contents are displayed first.
520 *
521 * @since 2.0.0 bbPress (r3132)
522 *
523 * @return string
524 */
525 public function display_topic_tags() {
526
527 // Unset globals
528 $this->unset_globals();
529
530 // Start output buffer
531 $this->start( 'bbp_topic_tags' );
532
533 // Output the topic tags
534 wp_tag_cloud(
535 array(
536 'smallest' => 9,
537 'largest' => 38,
538 'number' => 80,
539 'taxonomy' => bbp_get_topic_tag_tax_id()
540 )
541 );
542
543 // Return contents of output buffer
544 return $this->end();
545 }
546
547 /**
548 * Display the contents of a specific topic tag in an output buffer
549 * and return to ensure that post/page contents are displayed first.
550 *
551 * @since 2.0.0 bbPress (r3132)
552 *
553 * @param array $attr
554 * @param string $content
555 * @return string
556 */
557 public function display_topics_of_tag( $attr, $content = '' ) {
558
559 // Sanity check required info
560 if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) {
561 return $content;
562 }
563
564 // Unset globals
565 $this->unset_globals();
566
567 // Filter the query
568 if ( ! bbp_is_topic_tag() ) {
569 add_filter( 'bbp_before_has_topics_parse_args', array( $this, 'display_topics_of_tag_query' ) );
570 }
571
572 // Start output buffer
573 $this->start( 'bbp_topic_tag' );
574
575 // Set passed attribute to $ag_id for clarity
576 bbpress()->current_topic_tag_id = $tag_id = $attr['id'];
577
578 // Output template
579 bbp_get_template_part( 'content', 'archive-topic' );
580
581 // Return contents of output buffer
582 return $this->end();
583 }
584
585 /**
586 * Display the contents of a specific topic tag in an output buffer
587 * and return to ensure that post/page contents are displayed first.
588 *
589 * @since 2.0.0 bbPress (r3348)
590 *
591 * @return string
592 */
593 public function display_topic_tag_form() {
594
595 // Unset globals
596 $this->unset_globals();
597
598 // Start output buffer
599 $this->start( 'bbp_topic_tag_edit' );
600
601 // Output template
602 bbp_get_template_part( 'content', 'topic-tag-edit' );
603
604 // Return contents of output buffer
605 return $this->end();
606 }
607
608 /** Views *****************************************************************/
609
610 /**
611 * Display the contents of a specific view in an output buffer and return to
612 * ensure that post/page contents are displayed first.
613 *
614 * @since 2.0.0 bbPress (r3167)
615 *
616 * @param array $attr
617 * @param string $content
618 * @return string
619 */
620 public function display_view( $attr, $content = '' ) {
621
622 // Sanity check required info
623 if ( empty( $attr['id'] ) ) {
624 return $content;
625 }
626
627 // Set passed attribute to $view_id for clarity
628 $view_id = $attr['id'];
629
630 // Start output buffer
631 $this->start( 'bbp_single_view' );
632
633 // Unset globals
634 $this->unset_globals();
635
636 // Set the current view ID
637 bbpress()->current_view_id = $view_id;
638
639 // Load the view
640 bbp_view_query( $view_id );
641
642 // Output template
643 bbp_get_template_part( 'content', 'single-view' );
644
645 // Return contents of output buffer
646 return $this->end();
647 }
648
649 /** Search ****************************************************************/
650
651 /**
652 * Display the search form in an output buffer and return to ensure
653 * post/page contents are displayed first.
654 *
655 * @since 2.3.0 bbPress (r4586)
656 */
657 public function display_search_form() {
658
659 // Bail if search is disabled
660 if ( ! bbp_allow_search() ) {
661 return;
662 }
663
664 // Start output buffer
665 $this->start( 'bbp_search_form' );
666
667 // Output templates
668 bbp_get_template_part( 'form', 'search' );
669
670 // Return contents of output buffer
671 return $this->end();
672 }
673
674 /**
675 * Display the contents of search results in an output buffer and return to
676 * ensure that post/page contents are displayed first.
677 *
678 * @since 2.3.0 bbPress (r4579)
679 *
680 * @param array $attr
681 * @param string $content
682 */
683 public function display_search( $attr, $content = '' ) {
684
685 // Sanity check required info
686 if ( ! empty( $content ) ) {
687 return $content;
688 }
689
690 // Bail if search is disabled
691 if ( ! bbp_allow_search() ) {
692 return;
693 }
694
695 // Trim search attribute if it's set
696 if ( isset( $attr['search'] ) ) {
697 $attr['search'] = trim( $attr['search'] );
698 }
699
700 // Set passed attribute to $search_terms for clarity
701 $search_terms = empty( $attr['search'] )
702 ? bbp_get_search_terms()
703 : $attr['search'];
704
705 // Get the rewrite ID (one time, to avoid repeated calls)
706 $rewrite_id = bbp_get_search_rewrite_id();
707
708 // Unset globals
709 $this->unset_globals();
710
711 // Set terms for query
712 set_query_var( $rewrite_id, $search_terms );
713
714 // Start output buffer
715 $this->start( $rewrite_id );
716
717 // Output template
718 bbp_get_template_part( 'content', 'search' );
719
720 // Return contents of output buffer
721 return $this->end();
722 }
723
724 /** Account ***************************************************************/
725
726 /**
727 * Display a login form
728 *
729 * @since 2.0.0 bbPress (r3302)
730 *
731 * @return string
732 */
733 public function display_login() {
734
735 // Unset globals
736 $this->unset_globals();
737
738 // Start output buffer
739 $this->start( 'bbp_login' );
740
741 // Output templates
742 if ( ! is_user_logged_in() ) {
743 bbp_get_template_part( 'form', 'user-login' );
744 } else {
745 bbp_get_template_part( 'feedback', 'logged-in' );
746 }
747
748 // Return contents of output buffer
749 return $this->end();
750 }
751
752 /**
753 * Display a register form
754 *
755 * @since 2.0.0 bbPress (r3302)
756 *
757 * @return string
758 */
759 public function display_register() {
760
761 // Unset globals
762 $this->unset_globals();
763
764 // Start output buffer
765 $this->start( 'bbp_register' );
766
767 // Output templates
768 if ( ! is_user_logged_in() ) {
769 bbp_get_template_part( 'form', 'user-register' );
770 } else {
771 bbp_get_template_part( 'feedback', 'logged-in' );
772 }
773
774 // Return contents of output buffer
775 return $this->end();
776 }
777
778 /**
779 * Display a lost password form
780 *
781 * @since 2.0.0 bbPress (r3302)
782 *
783 * @return string
784 */
785 public function display_lost_pass() {
786
787 // Unset globals
788 $this->unset_globals();
789
790 // Start output buffer
791 $this->start( 'bbp_lost_pass' );
792
793 // Output templates
794 if ( ! is_user_logged_in() ) {
795 bbp_get_template_part( 'form', 'user-lost-pass' );
796 } else {
797 bbp_get_template_part( 'feedback', 'logged-in' );
798 }
799
800 // Return contents of output buffer
801 return $this->end();
802 }
803
804 /** Other *****************************************************************/
805
806 /**
807 * Display forum statistics
808 *
809 * @since 2.3.0 bbPress (r4510)
810 *
811 * @return string
812 */
813 public function display_stats() {
814
815 // Unset globals
816 $this->unset_globals();
817
818 // Start output buffer
819 $this->start();
820
821 // Output statistics
822 bbp_get_template_part( 'content', 'statistics' );
823
824 // Return contents of output buffer
825 return $this->end();
826 }
827
828 /**
829 * Display a breadcrumb
830 *
831 * @since 2.0.0 bbPress (r3302)
832 *
833 * @return string
834 */
835 public function display_breadcrumb() {
836
837 // Unset globals
838 $this->unset_globals();
839
840 // Start output buffer
841 $this->start();
842
843 // Output breadcrumb
844 bbp_breadcrumb();
845
846 // Return contents of output buffer
847 return $this->end();
848 }
849
850 /** Query Filters *********************************************************/
851
852 /**
853 * Filter the query for the topic index
854 *
855 * @since 2.1.0 bbPress (r3637)
856 *
857 * @param array $args
858 * @return array
859 */
860 public function display_topic_index_query( $args = array() ) {
861 $args['author'] = 0;
862 $args['show_stickies'] = true;
863 $args['order'] = 'DESC';
864 return $args;
865 }
866
867 /**
868 * Filter the query for topic tags
869 *
870 * @since 2.1.0 bbPress (r3637)
871 *
872 * @param array $args
873 * @return array
874 */
875 public function display_topics_of_tag_query( $args = array() ) {
876 $args['tax_query'] = array(
877 array(
878 'taxonomy' => bbp_get_topic_tag_tax_id(),
879 'field' => 'id',
880 'terms' => bbpress()->current_topic_tag_id
881 )
882 );
883
884 return $args;
885 }
886 }
887 endif;
888