Changeset 13332
- Timestamp:
- 09/30/2022 08:04:47 PM (3 years ago)
- Location:
- trunk/src/bp-core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-filters.php
r13322 r13332 78 78 // Turn comments off for BuddyPress pages. 79 79 add_filter( 'comments_open', 'bp_comments_open', 10, 2 ); 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 ); 80 83 81 84 // Prevent DB query for WP's main loop. -
trunk/src/bp-core/bp-core-theme-compatibility.php
r13108 r13332 937 937 938 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 963 /** 939 964 * Do not allow {@link comments_template()} to render during theme compatibility. 940 965 *
Note: See TracChangeset
for help on using the changeset viewer.