Created
November 8, 2016 10:21
-
-
Save selul/1b6a155a71e38f8ceb740f001bca5cfb 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