Skip to content

Instantly share code, notes, and snippets.

@nigelheap
Created March 20, 2017 22:36
Show Gist options
  • Save nigelheap/bc2f2e365cb665c3ebf167d80471c815 to your computer and use it in GitHub Desktop.
Save nigelheap/bc2f2e365cb665c3ebf167d80471c815 to your computer and use it in GitHub Desktop.
Wordpress: Prints debug info for the current request
<?php
/**
* Prints debug info for the current request.
* Works well interest just after the opening <head> tag in your header template
*/
function nigelheap_debug_request() {
global $wp, $template;
echo "\r\n";
echo '<!– Request: ';
echo empty($wp->request) ? 'None' : esc_html($wp->request);
echo ' –>'."\r\n";
echo '<!– Matched Rewrite Rule: ';
echo empty($wp->matched_rule) ? 'None' : esc_html($wp->matched_rule);
echo ' –>'."\r\n";
echo '<!– Matched Rewrite Query: ';
echo empty($wp->matched_query) ? 'None' : esc_html($wp->matched_query);
echo ' –>'."\r\n";
echo '<!– Loaded Template: ';
echo basename($template);
echo ' –>'."\r\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment