diff --git src/bp-core/bp-core-filters.php src/bp-core/bp-core-filters.php
index 447dbace0..1d9c1aae0 100644
|
|
|
add_filter( 'bp_get_template_stack', 'bp_add_template_stack_locations' ); |
| 78 | 78 | // Turn comments off for BuddyPress pages. |
| 79 | 79 | add_filter( 'comments_open', 'bp_comments_open', 10, 2 ); |
| 80 | 80 | |
| | 81 | // Force comments count to be 0 or comments list to be an empty array. |
| | 82 | add_filter( 'comments_pre_query', 'bp_comments_pre_query', 10, 2 ); |
| | 83 | |
| 81 | 84 | // Prevent DB query for WP's main loop. |
| 82 | 85 | add_filter( 'posts_pre_query', 'bp_core_filter_wp_query', 10, 2 ); |
| 83 | 86 | |
diff --git src/bp-core/bp-core-theme-compatibility.php src/bp-core/bp-core-theme-compatibility.php
index 06fa44853..17bcf8dc7 100644
|
|
|
function bp_comments_open( $open, $post_id = 0 ) { |
| 935 | 935 | return apply_filters( 'bp_force_comment_status', $retval, $open, $post_id ); |
| 936 | 936 | } |
| 937 | 937 | |
| | 938 | /** |
| | 939 | * Avoid potential extra comment query on BuddyPress pages. |
| | 940 | * |
| | 941 | * @since 10.5.0 |
| | 942 | * |
| | 943 | * @param array|int|null $comment_data The comments list, the comment count or null. |
| | 944 | * @param WP_Comment_Query $wp_comment_query The WP_Comment_Query instance. |
| | 945 | * @return array|int|null Null to leave WordPress deal with the comment query, an empty array or 0 to shortcircuit it. |
| | 946 | */ |
| | 947 | function bp_comments_pre_query( $comment_data, $wp_comment_query ) { |
| | 948 | $is_post_null = isset( $wp_comment_query->query_vars['post_id'] ) && 0 === (int) $wp_comment_query->query_vars['post_id']; |
| | 949 | |
| | 950 | if ( ! is_buddypress() || ! $is_post_null ) { |
| | 951 | return $comment_data; |
| | 952 | } |
| | 953 | |
| | 954 | if ( isset( $wp_comment_query->query_vars['count'] ) && $wp_comment_query->query_vars['count'] ) { |
| | 955 | $comment_data = 0; |
| | 956 | } else { |
| | 957 | $comment_data = array(); |
| | 958 | } |
| | 959 | |
| | 960 | return $comment_data; |
| | 961 | } |
| | 962 | |
| 938 | 963 | /** |
| 939 | 964 | * Do not allow {@link comments_template()} to render during theme compatibility. |
| 940 | 965 | * |