Changeset 5042
- Timestamp:
- 07/18/2013 08:41:02 AM (13 years ago)
- File:
-
- 1 edited
-
trunk/includes/core/theme-compat.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/core/theme-compat.php
r4995 r5042 648 648 $template = bbp_get_theme_compat_templates(); 649 649 650 add_filter( 'the_content', 'bbp_replace_the_content' ); 650 // Hook onto the start and end of the loop, and prepare to replace the 651 // main section of the_content() output. 652 add_action( 'loop_start', 'bbp_theme_compat_main_loop_start', 9999 ); 653 add_action( 'loop_end', 'bbp_theme_compat_main_loop_end', -9999 ); 651 654 } 652 655 … … 708 711 $page = bbp_get_page_by_path( bbp_get_root_slug() ); 709 712 if ( !empty( $page ) ) { 713 714 // Restore previously unset filters 715 bbp_restore_all_filters( 'the_content' ); 716 717 // Remove 'bbp_replace_the_content' filter to prevent infinite loops 718 remove_filter( 'the_content', 'bbp_replace_the_content' ); 719 720 // Start output buffer 721 ob_start(); 722 723 // Grab the content of this page 710 724 $new_content = apply_filters( 'the_content', $page->post_content ); 725 726 // Clean up the buffer 727 ob_end_clean(); 728 729 // Add 'bbp_replace_the_content' filter back (@see $this::start()) 730 add_filter( 'the_content', 'bbp_replace_the_content' ); 711 731 712 732 // Use the topics archive … … 735 755 $page = bbp_get_page_by_path( bbp_get_topic_archive_slug() ); 736 756 if ( !empty( $page ) ) { 757 758 // Restore previously unset filters 759 bbp_restore_all_filters( 'the_content' ); 760 761 // Remove 'bbp_replace_the_content' filter to prevent infinite loops 762 remove_filter( 'the_content', 'bbp_replace_the_content' ); 763 764 // Start output buffer 765 ob_start(); 766 767 // Grab the content of this page 737 768 $new_content = apply_filters( 'the_content', $page->post_content ); 769 770 // Clean up the buffer 771 ob_end_clean(); 772 773 // Add 'bbp_replace_the_content' filter back (@see $this::start()) 774 add_filter( 'the_content', 'bbp_replace_the_content' ); 738 775 739 776 // No page so show the archive … … 832 869 // Return possibly hi-jacked content 833 870 return $content; 871 } 872 873 874 /** 875 * Helper function to conditionally toggle the_content filters in the main 876 * query loop. Aids with theme compatibility. 877 * 878 * @since bbPress (r4972) 879 * @internal Used only by theme compatibilty 880 * @see bp_template_include_theme_compat() 881 * @see bp_theme_compat_main_loop_end() 882 */ 883 function bbp_theme_compat_main_loop_start() { 884 885 // Bail if not the main loop where theme compat is happening 886 if ( ! bbp_do_theme_compat() ) 887 return; 888 889 // Remove all of the filters from the_content 890 bbp_remove_all_filters( 'the_content' ); 891 892 // Make sure we replace the content 893 add_filter( 'the_content', 'bbp_replace_the_content' ); 894 } 895 896 /** 897 * Helper function to conditionally toggle the_content filters in the main 898 * query loop. Aids with theme compatibility. 899 * 900 * @since bbPress (r4972) 901 * @internal Used only by theme compatibilty 902 * @see bbp_template_include_theme_compat() 903 * @see bbp_theme_compat_main_loop_start() 904 */ 905 function bbp_theme_compat_main_loop_end() { 906 907 // Bail if not the main loop where theme compat is happening 908 if ( ! bbp_do_theme_compat() ) 909 return; 910 911 // Put all the filters back 912 bbp_restore_all_filters( 'the_content' ); 834 913 } 835 914
Note: See TracChangeset
for help on using the changeset viewer.