Skip to content

Instantly share code, notes, and snippets.

@palermomarco
Created August 5, 2014 10:44
Show Gist options
  • Save palermomarco/1c3a90e7174b27112fb1 to your computer and use it in GitHub Desktop.
Save palermomarco/1c3a90e7174b27112fb1 to your computer and use it in GitHub Desktop.
I use this functions to help me debugging wordpress
/* debug functions */
error_reporting(E_ALL);
ini_set("display_errors", 1);
function debug_wp_rewrite_rules() {
global $wp_rewrite;
echo '<div>';
if (!empty($wp_rewrite->rules)) {
echo '<h5>Rewrite Rules</h5>';
echo '<table><thead><tr>';
echo '<td>Rule</td><td>Rewrite</td>';
echo '</tr></thead><tbody>';
foreach ($wp_rewrite->rules as $name => $value) {
echo '<tr><td>'.$name.'</td><td>'.$value.'</td></tr>';
}
echo '</tbody></table>';
} else {
echo 'No rules defined.';
}
echo '</div>';
}
function debug_wp_page_request() {
global $wp, $template;
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