Skip to:
Content

BuddyPress.org

Ticket #5021: 5021.4.patch

File 5021.4.patch, 1.4 KB (added by r-a-y, 12 years ago)

Add further conditions before removing all filters

  • bp-core/bp-core-theme-compatibility.php

    function bp_theme_compat_main_loop_start() { 
    592592        if ( ! in_the_loop() )
    593593                return;
    594594
     595        // Bail if we've already run BP's injection
     596        if ( ! empty( buddypress()->theme_compat->runonce ) )
     597                return;
     598
     599        global $wp_query;
     600
     601        // Bail if there is more than one post in this loop, our page injection means
     602        // there is only one post in the loop
     603        if ( $wp_query->post_count > 1 )
     604                return;
     605
    595606        // Remove all of the filters from the_content
    596607        bp_remove_all_filters( 'the_content' );
    597608
    598609        // Make sure we replace the content
    599610        add_filter( 'the_content', 'bp_replace_the_content' );
     611
     612        // Note that we've run our injection
     613        buddypress()->theme_compat->runonce = 1;
    600614}
    601615
    602616/**
    function bp_theme_compat_main_loop_start() { 
    610624 */
    611625function bp_theme_compat_main_loop_end() {
    612626
    613         // Bail if not the main query
    614         if ( ! in_the_loop() )
     627        // Bail if we haven't run BP's content injection yet
     628        if ( empty( buddypress()->theme_compat->runonce ) )
    615629                return;
    616630
    617631        // Put all the filters back
    618632        bp_restore_all_filters( 'the_content' );
     633
     634        // Remove our marker
     635        unset( buddypress()->theme_compat->runonce );
    619636}
    620637
    621638/** Filters *******************************************************************/