Created
June 14, 2011 17:14
-
-
Save sivel/1025377 to your computer and use it in GitHub Desktop.
Output or log queries generated by WordPress
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 | |
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) | |
add_action( 'wp_footer', 'the_queries' ); | |
function the_queries() { | |
global $wpdb; | |
if ( defined( 'LOGQUERIES' ) && LOGQUERIES ) { | |
foreach ( $wpdb->queries as $query ) | |
error_log( trim( $query[0] ) . "\n", 3, WP_CONTENT_DIR . '/debug.log' ); | |
} else { | |
echo '<pre>'; | |
print_r( $wpdb->queries ); | |
echo '</pre>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment