bbp_get_template_stack()

Call the functions added to the ‘bbp_template_stack’ filter hook, and return an array of the template locations.


Description Description


Return Return

(array) The filtered value after all hooked functions are applied to it.


Top ↑

Source Source

File: includes/core/template-functions.php

function bbp_get_template_stack() {
	global $wp_filter, $merged_filters, $wp_current_filter;

	// Setup some default variables
	$tag  = 'bbp_template_stack';
	$args = $stack = array();

	// Add 'bbp_template_stack' to the current filter array
	$wp_current_filter[] = $tag;

	// Bail if no stack setup
	if ( empty( $wp_filter[ $tag ] ) ) {
		return array();
	}

	// Check if WP_Hook class exists, see #WP17817
	if ( class_exists( 'WP_Hook' ) ) {
		$filter = $wp_filter[ $tag ]->callbacks;
	} else {
		$filter = &$wp_filter[ $tag ];

		// Sort
		if ( ! isset( $merged_filters[ $tag ] ) ) {
			ksort( $filter );
			$merged_filters[ $tag ] = true;
		}
	}

	// Ensure we're always at the beginning of the filter array
	reset( $filter );

	// Loop through 'bbp_template_stack' filters, and call callback functions
	do {
		foreach ( (array) current( $filter ) as $the_ ) {
			if ( ! is_null( $the_['function'] ) ) {
				$args[1] = $stack;
				$stack[] = call_user_func_array( $the_['function'], array_slice( $args, 1, (int) $the_['accepted_args'] ) );
			}
		}
	} while ( next( $filter ) !== false );

	// Remove 'bbp_template_stack' from the current filter array
	array_pop( $wp_current_filter );

	// Remove empties and duplicates
	$stack = array_unique( array_filter( $stack ) );

	// Filter & return
	return (array) apply_filters( 'bbp_get_template_stack', $stack ) ;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 bbPress (r5944) Added support for WP_Hook
2.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.