Last active
November 1, 2015 09:05
-
-
Save mayeenulislam/9106f0d0efc5de7454e9 to your computer and use it in GitHub Desktop.
Show WordPress database queries at the footer only to the admin if WP_DEBUG is enabled
This file contains hidden or 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 | |
/** | |
* db QUERIES | |
* Prerequisite: define('SAVEQUERIES', true) | |
*/ | |
function nano_enqueue_db_queries() { | |
global $wpdb; | |
echo '<h2>Database Last Query</h2>'; | |
echo $wpdb->last_query; | |
echo '<hr>'; | |
echo '<h2>Database Queries</h2>'; | |
var_dump( $wpdb->queries ); | |
} | |
if ( WP_DEBUG && current_user_can( 'administrator' ) ) | |
add_action( 'wp_footer', 'nano_enqueue_db_queries' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment