Created
March 7, 2018 21:56
-
-
Save fadingdust/cb72c25b6ac0c66a98f8dd4a4e9c400e to your computer and use it in GitHub Desktop.
Add an HTTP header on Wordpress REST API responses showing the number of MySQL Queries performed
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
<?php | |
// Add the Number of queries to the header, because I'm a nerd. | |
add_filter( 'rest_pre_serve_request', function( $value ) { | |
header( 'X-Query-Count: '.intval( get_num_queries() ) ); | |
return $value; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment