Skip to:
Content

BuddyPress.org

Ticket #5021: 5021.06.patch

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

    function bp_buffer_template_part( $slug, $name = null, $echo = true ) { 
    207207
    208208        bp_get_template_part( $slug, $name );
    209209
    210         // Remove 'bp_replace_the_content' filter to prevent infinite loops
    211         add_filter( 'the_content', 'bp_replace_the_content' );
    212 
    213210        // Get the output buffer contents
    214211        $output = ob_get_contents();
    215212
    216213        // Flush the output buffer
    217214        ob_end_clean();
    218215
     216        // Put all the filters back
     217        bp_restore_all_filters( 'the_content' );
     218
    219219        // Echo or return the output buffer contents
    220220        if ( true === $echo ) {
    221221                echo $output;
  • bp-core/bp-core-theme-compatibility.php

    function bp_template_include_theme_compat( $template = '' ) { 
    528528                // from the_content as late as possible.
    529529                add_action( 'loop_start', 'bp_theme_compat_main_loop_start',  9999 );
    530530
    531                 // Hook to the end of the main post loop to restore all filters to
    532                 // the_content as early as possible.
    533                 add_action( 'loop_end',   'bp_theme_compat_main_loop_end',   -9999 );
    534 
    535531                // Add BuddyPress's head action to wp_head
    536532                if ( ! has_action( 'wp_head', 'bp_head' ) ) {
    537533                        add_action( 'wp_head', 'bp_head' );
    function bp_replace_the_content( $content = '' ) { 
    588584 */
    589585function bp_theme_compat_main_loop_start() {
    590586
     587        global $wp_query;
     588
     589        // Bail if there is more than one post in this loop, our page injection means
     590        // there is only one post in the loop
     591        if ( $wp_query->post_count > 1 )
     592                return;
     593
     594        // Prevent recursion
     595        remove_action( 'loop_start', 'bp_theme_compat_main_loop_start', 9999 );
     596
    591597        // Bail if not the main query
    592598        if ( ! in_the_loop() )
    593599                return;
    function bp_theme_compat_main_loop_start() { 
    599605        add_filter( 'the_content', 'bp_replace_the_content' );
    600606}
    601607
    602 /**
    603  * Helper function to conditionally toggle the_content filters in the main
    604  * query loop. Aids with theme compatibility.
    605  *
    606  * @since BuddyPress (1.8)
    607  * @internal Used only by theme compatibilty
    608  * @see bp_template_include_theme_compat()
    609  * @see bp_theme_compat_main_loop_start()
    610  */
    611 function bp_theme_compat_main_loop_end() {
    612 
    613         // Bail if not the main query
    614         if ( ! in_the_loop() )
    615                 return;
    616 
    617         // Put all the filters back
    618         bp_restore_all_filters( 'the_content' );
    619 }
    620 
    621608/** Filters *******************************************************************/
    622609
    623610/**