Skip to content

Instantly share code, notes, and snippets.

@bewho
Forked from selul/core_query_bans.php
Created May 14, 2017 02:21
Show Gist options
  • Save bewho/674dba3ebd7c7a7d5475b7e018316bef to your computer and use it in GitHub Desktop.
Save bewho/674dba3ebd7c7a7d5475b7e018316bef 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