Changeset 7793
- Timestamp:
- 02/05/2014 07:17:40 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.9/bp-core/bp-core-theme-compatibility.php
r7662 r7793 820 820 return apply_filters( 'bp_force_comment_status', $retval, $open, $post_id ); 821 821 } 822 823 /** 824 * Do not allow {@link comments_template()} to render during theme compatibility. 825 * 826 * When theme compatibility sets the 'is_page' flag to true via 827 * {@link bp_theme_compat_reset_post()}, themes that use comments_template() 828 * in their page template will run. 829 * 830 * To prevent comments_template() from rendering, we set the 'is_page' and 831 * 'is_single' flags to false since that function looks at these conditionals 832 * before querying the database for comments and loading the comments template. 833 * 834 * This is done during the output buffer as late as possible to prevent any 835 * wonkiness. 836 * 837 * @since BuddyPress (1.9.2) 838 * 839 * @param string $retval The current post content. 840 */ 841 function bp_theme_compat_toggle_is_page( $retval = '' ) { 842 global $wp_query; 843 844 $wp_query->is_single = false; 845 $wp_query->is_page = false; 846 847 // Set a switch so we know that we've toggled these WP_Query properties 848 buddypress()->theme_compat->is_page_toggled = true; 849 850 return $retval; 851 } 852 add_filter( 'bp_replace_the_content', 'bp_theme_compat_toggle_is_page', 9999 ); 853 854 /** 855 * Restores the 'is_single' and 'is_page' flags if toggled by BuddyPress. 856 * 857 * @since BuddyPress (1.9.2) 858 * 859 * @see bp_theme_compat_toggle_is_page() 860 * @param object $query The WP_Query object. 861 */ 862 function bp_theme_compat_loop_end( $query ) { 863 864 // Get BuddyPress 865 $bp = buddypress(); 866 867 // Bail if page is not toggled 868 if ( ! isset( $bp->theme_compat->is_page_toggled ) ) { 869 return; 870 } 871 872 // Revert our toggled WP_Query properties 873 $query->is_single = true; 874 $query->is_page = true; 875 876 // Unset our switch 877 unset( $bp->theme_compat->is_page_toggled ); 878 } 879 add_action( 'loop_end', 'bp_theme_compat_loop_end' );
Note: See TracChangeset
for help on using the changeset viewer.