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
← All changes | includes/core/template-functions.php +25 -29 trunk2.6.17 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 /**
4 - * bbPress Template Functions.
4 + * bbPress Template Functions
5 5 *
6 6 * This file contains functions necessary to mirror the WordPress core template
7 7 * loading process. Many of those functions are not filterable, and even then
8 8 * would not be robust enough to predict where bbPress templates might exist.
@@ -14,15 +14,14 @@
14 14 // Exit if accessed directly
15 15 defined( 'ABSPATH' ) || exit;
16 16
17 17 /**
18 - * Adds bbPress theme support to any active WordPress theme.
18 + * Adds bbPress theme support to any active WordPress theme
19 19 *
20 20 * @since 2.0.0 bbPress (r3032)
21 21 *
22 22 * @param string $slug
23 - * @param string $name Optional. Default null.
24 - * @return string The template filename if one is located.
23 + * @param string $name Optional. Default null
25 24 */
26 25 function bbp_get_template_part( $slug, $name = null ) {
27 26
28 27 // Execute code for this part
@@ -164,9 +163,9 @@
164 163 return bbp_locate_template( $files, false, false );
165 164 }
166 165
167 166 /**
168 - * Convert an enqueueable file path to a URL.
167 + * Convert an enqueueable file path to a URL
169 168 *
170 169 * @since 2.6.0
171 170 * @param string $file
172 171 *
@@ -306,11 +305,11 @@
306 305 * Deregisters a previously registered template stack location.
307 306 *
308 307 * @since 2.3.0 bbPress (r4652)
309 308 *
310 - * @param string $location_callback Callback function that returns the.
309 + * @param string $location_callback Callback function that returns the
311 310 * @param int $priority
312 - * @return bool Whether stack was removed.
311 + * @return bool Whether stack was removed
313 312 */
314 313 function bbp_deregister_template_stack( $location_callback = '', $priority = 10 ) {
315 314
316 315 // Bail if no location, or function/method is not callable
@@ -328,11 +327,11 @@
328 327 *
329 328 * @since 2.2.0 bbPress (r4323)
330 329 * @since 2.6.0 bbPress (r5944) Added support for `WP_Hook`
331 330 *
332 - * @global array $wp_filter Stores all of the filters.
331 + * @global array $wp_filter Stores all of the filters
333 332 * @global array $merged_filters Merges the filter hooks using this function.
334 - * @global array $wp_current_filter stores the list of current filters with the current one last.
333 + * @global array $wp_current_filter stores the list of current filters with the current one last
335 334 *
336 335 * @return array The filtered value after all hooked functions are applied to it.
337 336 */
338 337 function bbp_get_template_stack() {
@@ -389,37 +388,34 @@
389 388 return (array) apply_filters( 'bbp_get_template_stack', $stack );
390 389 }
391 390
392 391 /**
393 - * Get a template part in an output buffer, and return it.
392 + * Get a template part in an output buffer, and return it
394 393 *
395 394 * @since 2.4.0 bbPress (r5043)
396 395 *
397 396 * @param string $slug
398 397 * @param string $name
399 - * @param string $display
400 398 * @return string
401 399 */
402 -function bbp_buffer_template_part( $slug, $name = null, $display = true ) {
400 +function bbp_buffer_template_part( $slug, $name = null, $echo = true ) {
403 401 ob_start();
404 402
405 - // Load the template part
406 403 bbp_get_template_part( $slug, $name );
407 404
408 405 // Get the output buffer contents
409 - $retval = ob_get_clean();
406 + $output = ob_get_clean();
410 407
411 - // Maybe display the output buffer contents
412 - if ( true === $display ) {
413 - echo $retval;
408 + // Echo or return the output buffer contents
409 + if ( true === $echo ) {
410 + echo $output;
411 + } else {
412 + return $output;
414 413 }
415 -
416 - // Return the buffer contents
417 - return $retval;
418 414 }
419 415
420 416 /**
421 - * Retrieve path to a template.
417 + * Retrieve path to a template
422 418 *
423 419 * Used to quickly retrieve the path of a template without including the file
424 420 * extension. It will also check the parent theme and theme-compat theme with
425 421 * the use of {@link bbp_locate_template()}. Allows for more generic template
@@ -427,9 +423,9 @@
427 423 *
428 424 * @since 2.1.0 bbPress (r3629)
429 425 *
430 426 * @param string $type Filename without extension.
431 - * @param array $templates An optional list of template candidates.
427 + * @param array $templates An optional list of template candidates
432 428 * @return string Full path to file.
433 429 */
434 430 function bbp_get_query_template( $type, $templates = array() ) {
435 431 $type = preg_replace( '|[^a-z0-9-]+|', '', $type );
@@ -455,14 +451,14 @@
455 451 return apply_filters( "bbp_{$type}_template", $template, $templates );
456 452 }
457 453
458 454 /**
459 - * Get the possible subdirectories to check for templates in.
455 + * Get the possible subdirectories to check for templates in
460 456 *
461 457 * @since 2.1.0 bbPress (r3738)
462 458 *
463 - * @param array $templates Templates we are looking for.
464 - * @return array Possible subdirectories to look in.
459 + * @param array $templates Templates we are looking for
460 + * @return array Possible subdirectories to look in
465 461 */
466 462 function bbp_get_template_locations( $templates = array() ) {
467 463 $locations = array(
468 464 'bbpress',
@@ -474,9 +470,9 @@
474 470 return apply_filters( 'bbp_get_template_locations', $locations, $templates );
475 471 }
476 472
477 473 /**
478 - * Add template locations to template files being searched for.
474 + * Add template locations to template files being searched for
479 475 *
480 476 * @since 2.1.0 bbPress (r3738)
481 477 *
482 478 * @param array $stacks
@@ -499,9 +495,9 @@
499 495 return (array) apply_filters( 'bbp_add_template_stack_locations', array_unique( $retval ), $stacks );
500 496 }
501 497
502 498 /**
503 - * Add checks for bbPress conditions to parse_query action.
499 + * Add checks for bbPress conditions to parse_query action
504 500 *
505 501 * If it's a user page, WP_Query::bbp_is_single_user is set to true.
506 502 *
507 503 * If it's a user edit page, WP_Query::bbp_is_single_user_edit is set to true
@@ -517,10 +513,10 @@
517 513 * If it's a forum edit, WP_Query::bbp_is_forum_edit is set to true
518 514 * If it's a topic edit, WP_Query::bbp_is_topic_edit is set to true
519 515 * If it's a reply edit, WP_Query::bbp_is_reply_edit is set to true.
520 516 *
521 - * If it's a view page, WP_Query::bbp_is_view is set to true.
522 - * If it's a search page, WP_Query::bbp_is_search is set to true.
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
523 519 *
524 520 * @since 2.0.0 bbPress (r2688)
525 521 *
526 522 * @param WP_Query $posts_query