-
-
Save bewho/674dba3ebd7c7a7d5475b7e018316bef to your computer and use it in GitHub Desktop.
Block slow performance queries from wordpress core
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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