Skip to:
Content

bbPress.org

Ticket #2871: 2871.diff

File 2871.diff, 1.5 KB (added by netweb, 9 years ago)
  • src/includes/core/template-functions.php

     
    314314        // Add 'bbp_template_stack' to the current filter array
    315315        $wp_current_filter[] = $tag;
    316316
    317         // Bail if no stack setup
    318         if ( empty( $wp_filter[ $tag ] ) ) {
    319                 return array();
    320         }
     317        if ( class_exists( 'WP_Hook' ) ) {
     318                $filter = $wp_filter[ $tag ]->callbacks;
     319        } else {
     320                $filter = &$wp_filter[ $tag ];
    321321
    322         // Sort
    323         if ( ! isset( $merged_filters[ $tag ] ) ) {
    324                 ksort( $wp_filter[ $tag ] );
    325                 $merged_filters[ $tag ] = true;
     322                // Sort
     323                if ( ! isset( $merged_filters[ $tag ] ) ) {
     324                        ksort( $filter );
     325                        $merged_filters[ $tag ] = true;
     326                }
    326327        }
    327328
    328329        // Ensure we're always at the beginning of the filter array
    329         reset( $wp_filter[ $tag ] );
     330        reset( $filter );
    330331
    331332        // Loop through 'bbp_template_stack' filters, and call callback functions
    332333        do {
    333                 foreach ( (array) current( $wp_filter[ $tag ] ) as $the_ ) {
     334                foreach ( (array) current( $filter ) as $the_ ) {
    334335                        if ( ! is_null( $the_['function'] ) ) {
    335336                                $args[1] = $stack;
    336337                                $stack[] = call_user_func_array( $the_['function'], array_slice( $args, 1, (int) $the_['accepted_args'] ) );
    337338                        }
    338339                }
    339         } while ( next( $wp_filter[ $tag ] ) !== false );
     340        } while ( next( $filter ) !== false );
    340341
    341342        // Remove 'bbp_template_stack' from the current filter array
    342343        array_pop( $wp_current_filter );