Created
March 18, 2015 02:28
-
-
Save avioli/498a7108eec2e40fec2e to your computer and use it in GitHub Desktop.
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 | |
/** | |
* DEBUGGING | |
* | |
* Rewrite rules | |
*/ | |
function dev4press_debug_rewrite_rules() { | |
global $wp_rewrite; | |
echo '<div>'; | |
if (!empty($wp_rewrite->rules)) { | |
echo '<h1>Active Rewrite Rules</h1>'; | |
echo '<table><thead><tr style="text-align:left">'; | |
echo '<th>Rule</th><th>Rewrite</th>'; | |
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 dev4press_debug_page_request() { | |
global $wp, $template; | |
if (!defined("D4P_EOL")) { | |
define("D4P_EOL", "\n"); | |
} | |
echo '<!-- Request: '; | |
echo empty($wp->request) ? "None" : esc_html($wp->request); | |
echo ' -->'.D4P_EOL; | |
echo '<!-- Matched Rewrite Rule: '; | |
echo empty($wp->matched_rule) ? "None" : esc_html($wp->matched_rule); | |
echo ' -->'.D4P_EOL; | |
echo '<!-- Matched Rewrite Query: '; | |
echo empty($wp->matched_query) ? "None" : esc_html($wp->matched_query); | |
echo ' -->'.D4P_EOL; | |
echo '<!-- Loaded Template: '; | |
echo basename($template); | |
echo ' -->'.D4P_EOL; | |
} | |
add_action('wp', function() { | |
dev4press_debug_page_request(); | |
dev4press_debug_rewrite_rules(); | |
die(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment