Skip to content

Instantly share code, notes, and snippets.

@mayeenulislam
Last active November 1, 2015 09:05
Show Gist options
  • Save mayeenulislam/9106f0d0efc5de7454e9 to your computer and use it in GitHub Desktop.
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
<?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