Skip to:
Content

BuddyPress.org

Ticket #5021: 5021.3.patch

File 5021.3.patch, 2.1 KB (added by johnjamesjacoby, 6 years ago)

Remove is_main_query() calls

  • bp-core/bp-core-template-loader.php

     
    396396        );
    397397        return bp_get_query_template( 'buddypress', $templates );
    398398}
     399
     400/**
     401 * Helper function to conditionally toggle the_content filters in the main
     402 * query loop. Aids with theme compatibility.
     403 *
     404 * @since BuddyPress (1.8)
     405 * @internal Used only by theme compatibilty
     406 * @see bp_template_include_theme_compat()
     407 * @see bp_theme_compat_main_loop_end()
     408 */
     409function bp_theme_compat_main_loop_start() {
     410
     411        // Bail if not the main query
     412        if ( ! in_the_loop() )
     413                return;
     414
     415        // Remove all of the filters from the_content
     416        bp_remove_all_filters( 'the_content' );
     417
     418        // Make sure we replace the content
     419        add_filter( 'the_content', 'bp_replace_the_content' );
     420}
     421
     422/**
     423 * Helper function to conditionally toggle the_content filters in the main
     424 * query loop. Aids with theme compatibility.
     425 *
     426 * @since BuddyPress (1.8)
     427 * @internal Used only by theme compatibilty
     428 * @see bp_template_include_theme_compat()
     429 * @see bp_theme_compat_main_loop_start()
     430 */
     431function bp_theme_compat_main_loop_end() {
     432
     433        // Bail if not the main query
     434        if ( ! in_the_loop() )
     435                return;
     436
     437        // Put all the filters back
     438        bp_restore_all_filters( 'the_content' );
     439}
  • bp-core/bp-core-theme-compatibility.php

     
    521521         */
    522522        if ( bp_is_theme_compat_active() ) {
    523523
    524                 // Remove all filters from the_content
    525                 bp_remove_all_filters( 'the_content' );
     524                // Remove all 'the_content' filters at the beginning of the post loop
     525                add_action( 'loop_start', 'bp_theme_compat_main_loop_start',  9999 );
    526526
    527                 // Add a filter on the_content late, which we will later remove
    528                 if ( ! has_filter( 'the_content', 'bp_replace_the_content' ) ) {
    529                         add_filter( 'the_content', 'bp_replace_the_content' );
    530                 }
     527                // Restore all 'the_content' filters after the post loop is finished
     528                add_action( 'loop_end',   'bp_theme_compat_main_loop_end',   -9999 );
    531529
    532530                // Add BuddyPress's head action to wp_head
    533531                if ( ! has_action( 'wp_head', 'bp_head' ) ) {