Skip to content

Instantly share code, notes, and snippets.

@selul
Created November 8, 2016 10:21
Show Gist options
  • Save selul/1b6a155a71e38f8ceb740f001bca5cfb to your computer and use it in GitHub Desktop.
Save selul/1b6a155a71e38f8ceb740f001bca5cfb to your computer and use it in GitHub Desktop.
Block slow performance queries from wordpress core
add_filter( 'query', 'sel_filter_slow_query', 999 );
function sel_filter_slow_query( $query ) {
//set an array of functions which run the slow queries:
$banned_functions = array ( 'count_users','bbp_get_statistics', 'bpbbpst_support_statistics' );
foreach($banned_functions as $banned_function){
if ( in_array( $banned_function , wp_list_pluck( debug_backtrace(), 'function' ) ) ) {
return "SELECT 1 ";
}
}
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment