Skip to:
Content

BuddyPress.org

Ticket #5021: 5021.02.patch

File 5021.02.patch, 1.8 KB (added by r-a-y, 6 years ago)
  • bp-core/bp-core-template-loader.php

    function bp_get_template_stack() { 
    202202function bp_buffer_template_part( $slug, $name = null, $echo = true ) {
    203203        ob_start();
    204204
    205         // Remove 'bp_replace_the_content' filter to prevent infinite loops
    206         remove_filter( 'the_content', 'bp_replace_the_content' );
    207 
    208205        bp_get_template_part( $slug, $name );
    209206
    210         // Remove 'bp_replace_the_content' filter to prevent infinite loops
    211         add_filter( 'the_content', 'bp_replace_the_content' );
    212 
    213207        // Get the output buffer contents
    214208        $output = ob_get_contents();
    215209
  • bp-core/bp-core-theme-compatibility.php

    function bp_template_include_theme_compat( $template = '' ) { 
    521521         */
    522522        if ( bp_is_theme_compat_active() ) {
    523523
    524                 // Remove all filters from the_content
    525                 bp_remove_all_filters( 'the_content' );
    526 
    527                 // Add a filter on the_content late, which we will later remove
    528                 if ( ! has_filter( 'the_content', 'bp_replace_the_content' ) ) {
     524                // Remove all filters from 'the_content' after the_post() is called
     525                // This is the latest we can run this before we do our object buffering
     526                add_action( 'loop_start', create_function( '', "
     527                        bp_remove_all_filters( 'the_content' );
    529528                        add_filter( 'the_content', 'bp_replace_the_content' );
    530                 }
     529                " ), 9999 );
     530
     531                // Restore the filters after the post loop is finished
     532                add_action( 'loop_end', create_function( '', "
     533                        bp_restore_all_filters( 'the_content' );
     534                " ), 0 );
    531535
    532536                // Add BuddyPress's head action to wp_head
    533537                if ( ! has_action( 'wp_head', 'bp_head' ) ) {