PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
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 2.2 2.2.1 All 72 releases
bbpress / includes / core / template-functions.php

template-functions.php in bbPress 2.6.17, at includes/core/template-functions.php

742 lines 22.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress Template Functions
5 *
6 * This file contains functions necessary to mirror the WordPress core template
7 * loading process. Many of those functions are not filterable, and even then
8 * would not be robust enough to predict where bbPress templates might exist.
9 *
10 * @package bbPress
11 * @subpackage TemplateFunctions
12 */
13
14 // Exit if accessed directly
15 defined( 'ABSPATH' ) || exit;
16
17 /**
18 * Adds bbPress theme support to any active WordPress theme
19 *
20 * @since 2.0.0 bbPress (r3032)
21 *
22 * @param string $slug
23 * @param string $name Optional. Default null
24 */
25 function bbp_get_template_part( $slug, $name = null ) {
26
27 // Execute code for this part
28 do_action( 'get_template_part_' . $slug, $slug, $name );
29
30 // Setup possible parts
31 $templates = array();
32 if ( isset( $name ) ) {
33 $templates[] = $slug . '-' . $name . '.php';
34 }
35 $templates[] = $slug . '.php';
36
37 // Allow template parst to be filtered
38 $templates = apply_filters( 'bbp_get_template_part', $templates, $slug, $name );
39
40 // Return the part that is found
41 return bbp_locate_template( $templates, true, false );
42 }
43
44 /**
45 * Retrieve the name of the highest priority template file that exists.
46 *
47 * Searches in the child theme before parent theme so that themes which
48 * inherit from a parent theme can just overload one file. If the template is
49 * not found in either of those, it looks in the theme-compat folder last.
50 *
51 * @since 2.1.0 bbPress (r3618)
52 *
53 * @param string|array $template_names Template file(s) to search for, in order.
54 * @param bool $load If true the template file will be loaded if it is found.
55 * @param bool $require_once Whether to require_once or require. Default true.
56 * Has no effect if $load is false.
57 * @return string The template filename if one is located.
58 */
59 function bbp_locate_template( $template_names, $load = false, $require_once = true ) {
60
61 // No file found yet
62 $located = false;
63 $template_locations = bbp_get_template_stack();
64
65 // Try to find a template file
66 foreach ( (array) $template_names as $template_name ) {
67
68 // Continue if template is empty
69 if ( empty( $template_name ) ) {
70 continue;
71 }
72
73 // Trim off any slashes from the template name
74 $template_name = ltrim( $template_name, '/' );
75
76 // Loop through template stack
77 foreach ( (array) $template_locations as $template_location ) {
78
79 // Continue if $template_location is empty
80 if ( empty( $template_location ) ) {
81 continue;
82 }
83
84 // Check child theme first
85 if ( file_exists( trailingslashit( $template_location ) . $template_name ) ) {
86 $located = trailingslashit( $template_location ) . $template_name;
87 break 2;
88 }
89 }
90 }
91
92 /**
93 * This action exists only to follow the standard bbPress coding convention,
94 * and should not be used to short-circuit any part of the template locator.
95 *
96 * If you want to override a specific template part, please either filter
97 * 'bbp_get_template_part' or add a new location to the template stack.
98 */
99 do_action( 'bbp_locate_template', $located, $template_name, $template_names, $template_locations, $load, $require_once );
100
101 // Maybe load the template if one was located
102 if ( ( defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ) && ( true === $load ) && ! empty( $located ) ) {
103 load_template( $located, $require_once );
104 }
105
106 return $located;
107 }
108
109 /**
110 * Locate an enqueueable file on the server. Used before being enqueued.
111 *
112 * If SCRIPT_DEBUG is set and the file includes a .min suffix, this function
113 * will automatically attempt to locate a non-minified version of that file.
114 *
115 * If SCRIPT_DEBUG is not set and the file exclude a .min suffix, this function
116 * will automatically attempt to locate a minified version of that file.
117 *
118 * See: https://bbpress.trac.wordpress.org/ticket/3218
119 *
120 * @since 2.6.0
121 *
122 * @param string $file
123 *
124 * @return boolean
125 */
126 function bbp_locate_enqueueable( $file = '' ) {
127
128 // Bail if no file to locate
129 if ( empty( $file ) ) {
130 return false;
131 }
132
133 // Add file to files array
134 $files = array( $file );
135
136 // Get the file variant (minified or not, but opposite of $file)
137 $file_is_min = ( false !== strpos( $file, '.min' ) );
138 $file_variant = ( false === $file_is_min )
139 ? str_replace( array( '.css', '.js' ), array( '.min.css', '.min.js' ), $file )
140 : str_replace( '.min', '', $file );
141
142 // Are we debugging?
143 $script_debug = bbp_doing_script_debug();
144
145 // Debugging, so prefer unminified files
146 if ( true === $script_debug ) {
147 if ( true === $file_is_min ) {
148 array_unshift( $files, $file_variant );
149 } else {
150 array_push( $files, $file_variant );
151 }
152
153 // Not debugging, so prefer minified files
154 } elseif ( false === $script_debug ) {
155 if ( true === $file_is_min ) {
156 array_push( $files, $file_variant );
157 } else {
158 array_unshift( $files, $file_variant );
159 }
160 }
161
162 // Return first found file location in the stack
163 return bbp_locate_template( $files, false, false );
164 }
165
166 /**
167 * Convert an enqueueable file path to a URL
168 *
169 * @since 2.6.0
170 * @param string $file
171 *
172 * @return string
173 */
174 function bbp_urlize_enqueueable( $file = '' ) {
175
176 // Get DIR and URL
177 $content_dir = constant( 'WP_CONTENT_DIR' );
178 $content_url = content_url();
179
180 // IIS (Windows) here
181 // Replace back slashes with forward slash
182 if ( false !== strpos( $file, '\\' ) ) {
183 $file = str_replace( '\\', '/', $file );
184 $content_dir = str_replace( '\\', '/', $content_dir );
185 }
186
187 // Return path to file relative to site URL
188 return str_replace( $content_dir, $content_url, $file );
189 }
190
191 /**
192 * Enqueue a script from the highest priority location in the template stack.
193 *
194 * Registers the style if file provided (does NOT overwrite) and enqueues.
195 *
196 * @since 2.5.0 bbPress (r5180)
197 *
198 * @param string $handle Name of the stylesheet.
199 * @param string|bool $file Relative path to stylesheet. Example: '/css/mystyle.css'.
200 * @param array $deps An array of registered style handles this stylesheet depends on. Default empty array.
201 * @param string|bool $ver String specifying the stylesheet version number, if it has one. This parameter is used
202 * to ensure that the correct version is sent to the client regardless of caching, and so
203 * should be included if a version number is available and makes sense for the stylesheet.
204 * @param string $media Optional. The media for which this stylesheet has been defined.
205 * Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print',
206 * 'screen', 'tty', or 'tv'.
207 *
208 * @return mixed The style filename if one is located. False if not.
209 */
210 function bbp_enqueue_style( $handle = '', $file = '', $deps = array(), $ver = false, $media = 'all' ) {
211
212 // Attempt to locate an enqueueable
213 $located = bbp_locate_enqueueable( $file );
214
215 // Enqueue if located
216 if ( ! empty( $located ) ) {
217
218 // Make sure there is always a version
219 if ( empty( $ver ) ) {
220 $ver = bbp_get_asset_version();
221 }
222
223 // Make path to file relative to site URL
224 $located = bbp_urlize_enqueueable( $located );
225
226 // Register the style
227 wp_register_style( $handle, $located, $deps, $ver, $media );
228
229 // Enqueue the style
230 wp_enqueue_style( $handle );
231 }
232
233 return $located;
234 }
235
236 /**
237 * Enqueue a script from the highest priority location in the template stack.
238 *
239 * Registers the style if file provided (does NOT overwrite) and enqueues.
240 *
241 * @since 2.5.0 bbPress (r5180)
242 *
243 * @param string $handle Name of the script.
244 * @param string|bool $file Relative path to the script. Example: '/js/myscript.js'.
245 * @param array $deps An array of registered handles this script depends on. Default empty array.
246 * @param string|bool $ver Optional. String specifying the script version number, if it has one. This parameter
247 * is used to ensure that the correct version is sent to the client regardless of caching,
248 * and so should be included if a version number is available and makes sense for the script.
249 * @param bool $in_footer Optional. Whether to enqueue the script before </head> or before </body>.
250 * Default 'false'. Accepts 'false' or 'true'.
251 *
252 * @return mixed The script filename if one is located. False if not.
253 */
254 function bbp_enqueue_script( $handle = '', $file = '', $deps = array(), $ver = false, $in_footer = false ) {
255
256 // Attempt to locate an enqueueable
257 $located = bbp_locate_enqueueable( $file );
258
259 // Enqueue if located
260 if ( ! empty( $located ) ) {
261
262 // Make sure there is always a version
263 if ( empty( $ver ) ) {
264 $ver = bbp_get_asset_version();
265 }
266
267 // Make path to file relative to site URL
268 $located = bbp_urlize_enqueueable( $located );
269
270 // Register the style
271 wp_register_script( $handle, $located, $deps, $ver, $in_footer );
272
273 // Enqueue the style
274 wp_enqueue_script( $handle );
275 }
276
277 return $located;
278 }
279
280 /**
281 * This is really cool. This function registers a new template stack location,
282 * using WordPress's built in filters API.
283 *
284 * This allows for templates to live in places beyond just the parent/child
285 * relationship, to allow for custom template locations. Used in conjunction
286 * with bbp_locate_template(), this allows for easy template overrides.
287 *
288 * @since 2.2.0 bbPress (r4323)
289 *
290 * @param string $location_callback Callback function that returns the
291 * @param int $priority
292 */
293 function bbp_register_template_stack( $location_callback = '', $priority = 10 ) {
294
295 // Bail if no location, or function/method is not callable
296 if ( empty( $location_callback ) || ! is_callable( $location_callback ) ) {
297 return false;
298 }
299
300 // Add location callback to template stack
301 return add_filter( 'bbp_template_stack', $location_callback, (int) $priority );
302 }
303
304 /**
305 * Deregisters a previously registered template stack location.
306 *
307 * @since 2.3.0 bbPress (r4652)
308 *
309 * @param string $location_callback Callback function that returns the
310 * @param int $priority
311 * @return bool Whether stack was removed
312 */
313 function bbp_deregister_template_stack( $location_callback = '', $priority = 10 ) {
314
315 // Bail if no location, or function/method is not callable
316 if ( empty( $location_callback ) || ! is_callable( $location_callback ) ) {
317 return false;
318 }
319
320 // Remove location callback to template stack
321 return remove_filter( 'bbp_template_stack', $location_callback, (int) $priority );
322 }
323
324 /**
325 * Call the functions added to the 'bbp_template_stack' filter hook, and return
326 * an array of the template locations.
327 *
328 * @since 2.2.0 bbPress (r4323)
329 * @since 2.6.0 bbPress (r5944) Added support for `WP_Hook`
330 *
331 * @global array $wp_filter Stores all of the filters
332 * @global array $merged_filters Merges the filter hooks using this function.
333 * @global array $wp_current_filter stores the list of current filters with the current one last
334 *
335 * @return array The filtered value after all hooked functions are applied to it.
336 */
337 function bbp_get_template_stack() {
338 global $wp_filter, $merged_filters, $wp_current_filter;
339
340 // Setup some default variables
341 $tag = 'bbp_template_stack';
342 $args = $stack = array();
343
344 // Add 'bbp_template_stack' to the current filter array
345 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
346 $wp_current_filter[] = $tag;
347
348 // Bail if no stack setup
349 if ( empty( $wp_filter[ $tag ] ) ) {
350 return array();
351 }
352
353 // Check if WP_Hook class exists, see #WP17817
354 if ( class_exists( 'WP_Hook' ) ) {
355 $filter = $wp_filter[ $tag ]->callbacks;
356 } else {
357 $filter = &$wp_filter[ $tag ];
358
359 // Sort
360 if ( ! isset( $merged_filters[ $tag ] ) ) {
361 ksort( $filter );
362
363 // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
364 $merged_filters[ $tag ] = true;
365 }
366 }
367
368 // Ensure we're always at the beginning of the filter array
369 reset( $filter );
370
371 // Loop through 'bbp_template_stack' filters, and call callback functions
372 do {
373 foreach ( (array) current( $filter ) as $the_ ) {
374 if ( ! is_null( $the_['function'] ) ) {
375 $args[1] = $stack;
376 $stack[] = call_user_func_array( $the_['function'], array_slice( $args, 1, (int) $the_['accepted_args'] ) );
377 }
378 }
379 } while ( next( $filter ) !== false );
380
381 // Remove 'bbp_template_stack' from the current filter array
382 array_pop( $wp_current_filter );
383
384 // Remove empties and duplicates
385 $stack = array_unique( array_filter( $stack ) );
386
387 // Filter & return
388 return (array) apply_filters( 'bbp_get_template_stack', $stack );
389 }
390
391 /**
392 * Get a template part in an output buffer, and return it
393 *
394 * @since 2.4.0 bbPress (r5043)
395 *
396 * @param string $slug
397 * @param string $name
398 * @return string
399 */
400 function bbp_buffer_template_part( $slug, $name = null, $echo = true ) {
401 ob_start();
402
403 bbp_get_template_part( $slug, $name );
404
405 // Get the output buffer contents
406 $output = ob_get_clean();
407
408 // Echo or return the output buffer contents
409 if ( true === $echo ) {
410 echo $output;
411 } else {
412 return $output;
413 }
414 }
415
416 /**
417 * Retrieve path to a template
418 *
419 * Used to quickly retrieve the path of a template without including the file
420 * extension. It will also check the parent theme and theme-compat theme with
421 * the use of {@link bbp_locate_template()}. Allows for more generic template
422 * locations without the use of the other get_*_template() functions.
423 *
424 * @since 2.1.0 bbPress (r3629)
425 *
426 * @param string $type Filename without extension.
427 * @param array $templates An optional list of template candidates
428 * @return string Full path to file.
429 */
430 function bbp_get_query_template( $type, $templates = array() ) {
431 $type = preg_replace( '|[^a-z0-9-]+|', '', $type );
432
433 // Fallback template
434 if ( empty( $templates ) ) {
435 $templates = array( "{$type}.php" );
436 }
437
438 // Filter possible templates
439 $templates = apply_filters( "bbp_get_{$type}_template", $templates );
440
441 // Stash the possible templates for this query, for later use
442 bbp_set_theme_compat_templates( $templates );
443
444 // Try to locate a template in the stack
445 $template = bbp_locate_template( $templates );
446
447 // Stash the located template for this query, for later use
448 bbp_set_theme_compat_template( $template );
449
450 // Filter & return
451 return apply_filters( "bbp_{$type}_template", $template, $templates );
452 }
453
454 /**
455 * Get the possible subdirectories to check for templates in
456 *
457 * @since 2.1.0 bbPress (r3738)
458 *
459 * @param array $templates Templates we are looking for
460 * @return array Possible subdirectories to look in
461 */
462 function bbp_get_template_locations( $templates = array() ) {
463 $locations = array(
464 'bbpress',
465 'forums',
466 ''
467 );
468
469 // Filter & return
470 return apply_filters( 'bbp_get_template_locations', $locations, $templates );
471 }
472
473 /**
474 * Add template locations to template files being searched for
475 *
476 * @since 2.1.0 bbPress (r3738)
477 *
478 * @param array $stacks
479 * @return array()
480 */
481 function bbp_add_template_stack_locations( $stacks = array() ) {
482 $retval = array();
483
484 // Get alternate locations
485 $locations = bbp_get_template_locations();
486
487 // Loop through locations and stacks and combine
488 foreach ( (array) $stacks as $stack ) {
489 foreach ( (array) $locations as $custom_location ) {
490 $retval[] = untrailingslashit( trailingslashit( $stack ) . $custom_location );
491 }
492 }
493
494 // Filter & return
495 return (array) apply_filters( 'bbp_add_template_stack_locations', array_unique( $retval ), $stacks );
496 }
497
498 /**
499 * Add checks for bbPress conditions to parse_query action
500 *
501 * If it's a user page, WP_Query::bbp_is_single_user is set to true.
502 *
503 * If it's a user edit page, WP_Query::bbp_is_single_user_edit is set to true
504 * and the the 'wp-admin/includes/user.php' file is included.
505 *
506 * In addition, on user/user edit pages, WP_Query::home is set to false & query
507 * vars 'bbp_user_id' with the displayed user id is added.
508 *
509 * In 2.6.0, the 'author_name' variable is no longer set when viewing a single
510 * user, because of is_author() weirdness. If this removal causes problems, it
511 * may come back in a future release.
512 *
513 * If it's a forum edit, WP_Query::bbp_is_forum_edit is set to true
514 * If it's a topic edit, WP_Query::bbp_is_topic_edit is set to true
515 * If it's a reply edit, WP_Query::bbp_is_reply_edit is set to true.
516 *
517 * If it's a view page, WP_Query::bbp_is_view is set to true
518 * If it's a search page, WP_Query::bbp_is_search is set to true
519 *
520 * @since 2.0.0 bbPress (r2688)
521 *
522 * @param WP_Query $posts_query
523 */
524 function bbp_parse_query( $posts_query ) {
525
526 // Bail if $posts_query is not the main loop
527 if ( ! $posts_query->is_main_query() ) {
528 return;
529 }
530
531 // Bail if filters are suppressed on this query
532 if ( true === $posts_query->get( 'suppress_filters' ) ) {
533 return;
534 }
535
536 // Bail if in admin
537 if ( is_admin() ) {
538 return;
539 }
540
541 // Get query variables (default to null if not set)
542 $bbp_view = $posts_query->get( bbp_get_view_rewrite_id(), null );
543 $bbp_user = $posts_query->get( bbp_get_user_rewrite_id(), null );
544 $is_edit = $posts_query->get( bbp_get_edit_rewrite_id(), null );
545 $is_search = $posts_query->get( bbp_get_search_rewrite_id(), null );
546
547 // It is a user page - We'll also check if it is user edit
548 if ( ! is_null( $bbp_user ) ) {
549
550 /** Find User *********************************************************/
551
552 // Setup the default user variable
553 $the_user = false;
554
555 // If using pretty permalinks, always use slug
556 if ( get_option( 'permalink_structure' ) ) {
557 $the_user = get_user_by( 'slug', $bbp_user );
558
559 // If not using pretty permalinks, always use numeric ID
560 } elseif ( is_numeric( $bbp_user ) ) {
561 $the_user = get_user_by( 'id', $bbp_user );
562 }
563
564 // 404 and bail if user does not have a profile
565 if ( empty( $the_user->ID ) || ! bbp_user_has_profile( $the_user->ID ) ) {
566 $posts_query->bbp_is_404 = true;
567 return;
568 }
569
570 /** User Exists *******************************************************/
571
572 $is_favs = $posts_query->get( bbp_get_user_favorites_rewrite_id() );
573 $is_subs = $posts_query->get( bbp_get_user_subscriptions_rewrite_id() );
574 $is_topics = $posts_query->get( bbp_get_user_topics_rewrite_id() );
575 $is_replies = $posts_query->get( bbp_get_user_replies_rewrite_id() );
576 $is_engagements = $posts_query->get( bbp_get_user_engagements_rewrite_id() );
577
578 // View or edit?
579 if ( ! is_null( $is_edit ) ) {
580
581 // We are editing a profile
582 $posts_query->bbp_is_single_user_edit = true;
583
584 // Load the core WordPress contact methods
585 if ( ! function_exists( '_wp_get_user_contactmethods' ) ) {
586 require_once ABSPATH . 'wp-includes/registration.php';
587 }
588
589 // Load the edit_user functions
590 if ( ! function_exists( 'edit_user' ) ) {
591 require_once ABSPATH . 'wp-admin/includes/user.php';
592 }
593
594 // Load the grant/revoke super admin functions
595 if ( is_multisite() && ! function_exists( 'revoke_super_admin' ) ) {
596 require_once ABSPATH . 'wp-admin/includes/ms.php';
597 }
598
599 // Editing a user
600 $posts_query->bbp_is_edit = true;
601
602 // User favorites
603 } elseif ( ! empty( $is_favs ) ) {
604 $posts_query->bbp_is_single_user_favs = true;
605
606 // User subscriptions
607 } elseif ( ! empty( $is_subs ) ) {
608 $posts_query->bbp_is_single_user_subs = true;
609
610 // User topics
611 } elseif ( ! empty( $is_topics ) ) {
612 $posts_query->bbp_is_single_user_topics = true;
613
614 // User topics
615 } elseif ( ! empty( $is_replies ) ) {
616 $posts_query->bbp_is_single_user_replies = true;
617
618 // User engagements
619 } elseif ( ! empty( $is_engagements ) ) {
620 $posts_query->bbp_is_single_user_engagements = true;
621
622 // User profile
623 } else {
624 $posts_query->bbp_is_single_user_profile = true;
625 }
626
627 // Make sure 404 is not set
628 $posts_query->is_404 = false;
629
630 // Correct is_home variable
631 $posts_query->is_home = false;
632
633 // Looking at a single user
634 $posts_query->bbp_is_single_user = true;
635
636 // User found so don't 404 yet
637 $posts_query->bbp_is_404 = false;
638
639 // User is looking at their own profile
640 if ( bbp_get_current_user_id() === $the_user->ID ) {
641 $posts_query->bbp_is_single_user_home = true;
642 }
643
644 // Set bbp_user_id for future reference
645 $posts_query->set( 'bbp_user_id', $the_user->ID );
646
647 // Set the displayed user global to this user
648 bbpress()->displayed_user = $the_user;
649
650 // View Page
651 } elseif ( ! is_null( $bbp_view ) ) {
652
653 // Check if the view exists by checking if there are query args are set
654 $view_args = bbp_get_view_query_args( $bbp_view );
655
656 // Bail if view args are empty
657 if ( empty( $view_args ) ) {
658 $posts_query->bbp_is_404 = true;
659 return;
660 }
661
662 // Correct is_home variable
663 $posts_query->is_home = false;
664
665 // We are in a custom topic view
666 $posts_query->bbp_is_view = true;
667
668 // No 404 because views are all (currently) public
669 $posts_query->bbp_is_404 = false;
670
671 // Search Page
672 } elseif ( ! is_null( $is_search ) ) {
673
674 // Check if there are search query args set
675 $search_terms = bbp_get_search_terms();
676 if ( ! empty( $search_terms ) ) {
677 $posts_query->bbp_search_terms = $search_terms;
678 }
679
680 // Correct is_home variable
681 $posts_query->is_home = false;
682
683 // We are in a search query
684 $posts_query->bbp_is_search = true;
685
686 // No 404 because search is always public
687 $posts_query->bbp_is_404 = false;
688
689 // Forum/Topic/Reply Edit Page
690 } elseif ( ! is_null( $is_edit ) ) {
691
692 // Get the post type from the main query loop
693 $post_type = $posts_query->get( 'post_type' );
694
695 // Check which post_type we are editing, if any
696 if ( ! empty( $post_type ) ) {
697 switch ( $post_type ) {
698
699 // We are editing a forum
700 case bbp_get_forum_post_type() :
701 $posts_query->bbp_is_forum_edit = true;
702 $posts_query->bbp_is_edit = true;
703 $posts_query->bbp_is_404 = false;
704 break;
705
706 // We are editing a topic
707 case bbp_get_topic_post_type() :
708 $posts_query->bbp_is_topic_edit = true;
709 $posts_query->bbp_is_edit = true;
710 $posts_query->bbp_is_404 = false;
711 break;
712
713 // We are editing a reply
714 case bbp_get_reply_post_type() :
715 $posts_query->bbp_is_reply_edit = true;
716 $posts_query->bbp_is_edit = true;
717 $posts_query->bbp_is_404 = false;
718 break;
719 }
720
721 // We are editing a topic tag
722 } elseif ( bbp_is_topic_tag() ) {
723 $posts_query->bbp_is_topic_tag_edit = true;
724 $posts_query->bbp_is_edit = true;
725 $posts_query->bbp_is_404 = false;
726 }
727
728 // We save post revisions on our own
729 remove_action( 'pre_post_update', 'wp_save_post_revision' );
730
731 // Topic tag page
732 } elseif ( bbp_is_topic_tag() ) {
733 $posts_query->set( 'bbp_topic_tag', get_query_var( 'term' ) );
734 $posts_query->set( 'post_type', bbp_get_topic_post_type() );
735 $posts_query->set( 'posts_per_page', bbp_get_topics_per_page() );
736
737 // Do topics on forums root
738 } elseif ( is_post_type_archive( bbp_get_post_types( array( 'has_archive' => true ) ) ) && ( 'topics' === bbp_show_on_root() ) ) {
739 $posts_query->bbp_show_topics_on_root = true;
740 }
741 }
742