Changeset 7128
- Timestamp:
- 05/29/2013 02:29:43 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-theme-compatibility.php
r6867 r7128 519 519 * should be coded without superfluous mark-up and logic (prev/next 520 520 * navigation, comments, date/time, etc...) 521 * 522 * Hook into 'bp_get_buddypress_template' to override the array of 523 * possible templates, or 'bp_buddypress_template' to override the result. 521 524 */ 522 525 if ( bp_is_theme_compat_active() ) { 523 526 524 // Remove all filters from the_content525 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' ) ) {529 add_filter( 'the_content', 'bp_replace_the_content' );530 }527 // Hook to the beginning of the main post loop to remove all filters 528 // from the_content as late as possible. 529 add_action( 'loop_start', 'bp_theme_compat_main_loop_start', 9999 ); 530 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 ); 531 534 532 535 // Add BuddyPress's head action to wp_head … … 573 576 // Return possibly hi-jacked content 574 577 return $content; 578 } 579 580 /** 581 * Helper function to conditionally toggle the_content filters in the main 582 * query loop. Aids with theme compatibility. 583 * 584 * @since BuddyPress (1.8) 585 * @internal Used only by theme compatibilty 586 * @see bp_template_include_theme_compat() 587 * @see bp_theme_compat_main_loop_end() 588 */ 589 function bp_theme_compat_main_loop_start() { 590 591 // Bail if not the main query 592 if ( ! in_the_loop() ) 593 return; 594 595 // Remove all of the filters from the_content 596 bp_remove_all_filters( 'the_content' ); 597 598 // Make sure we replace the content 599 add_filter( 'the_content', 'bp_replace_the_content' ); 600 } 601 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' ); 575 619 } 576 620
Note: See TracChangeset
for help on using the changeset viewer.