Changeset 11007
- Timestamp:
- 08/10/2016 11:40:14 AM (9 years ago)
- Location:
- trunk/src/bp-core
- Files:
-
- 2 edited
-
bp-core-catchuri.php (modified) (1 diff)
-
bp-core-filters.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-catchuri.php
r10982 r11007 1016 1016 } 1017 1017 add_action( 'wp_head', '_bp_maybe_remove_rel_canonical', 8 ); 1018 1019 /** 1020 * Stop WordPress performing a DB query for its main loop. 1021 * 1022 * As of WordPress 4.6, it is possible to bypass the main WP_Query entirely. 1023 * This saves us one unnecessary database query! :) 1024 * 1025 * @since 2.7.0 1026 * 1027 * @param null $retval Current return value for filter. 1028 * @param WP_Query $query Current WordPress query object. 1029 * @return null|array 1030 */ 1031 function bp_core_filter_wp_query( $retval, $query ) { 1032 if ( ! $query->is_main_query() ) { 1033 return $retval; 1034 } 1035 1036 /* 1037 * If not on a BP single page, bail. 1038 * It's too early to use bp_is_single_item() here. 1039 */ 1040 if ( ! bp_is_group() || ! bp_is_user() || ! bp_is_single_activity() ) { 1041 return $retval; 1042 } 1043 1044 $query->found_posts = 0; 1045 $query->max_num_pages = 0; 1046 1047 // Return something other than a null value to bypass WP_Query. 1048 return array(); 1049 } -
trunk/src/bp-core/bp-core-filters.php
r10941 r11007 75 75 // Turn comments off for BuddyPress pages. 76 76 add_filter( 'comments_open', 'bp_comments_open', 10, 2 ); 77 78 // Prevent DB query for WP's main loop. 79 add_filter( 'posts_pre_query', 'bp_core_filter_wp_query', 10, 2 ); 77 80 78 81 /**
Note: See TracChangeset
for help on using the changeset viewer.