Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. /* Produces a dump on the state of WordPress when a not found error occurs */
  2. /* useful when debugging permalink issues, rewrite rule trouble, place inside functions.php and add debug to your query string */
  3.  
  4. if (isset($_GET["debug"])) {
  5. ini_set('error_reporting', -1);
  6. ini_set('display_errors', 'On');
  7. echo '<pre>';
  8.  
  9. add_action('parse_request', function(&$wp)
  10. {
  11.  
  12. global $wp_rewrite;
  13.  
  14. echo '<h2>rewrite rules</h2>';
  15. echo var_export($wp_rewrite->wp_rewrite_rules(), true);
  16.  
  17. echo '<h2>permalink structure</h2>';
  18. echo var_export($wp_rewrite->permalink_structure, true);
  19.  
  20. echo '<h2>page permastruct</h2>';
  21. echo var_export($wp_rewrite->get_page_permastruct(), true);
  22.  
  23. echo '<h2>matched rule and query</h2>';
  24. echo var_export($wp->matched_rule, true);
  25.  
  26. echo '<h2>matched query</h2>';
  27. echo var_export($wp->matched_query, true);
  28.  
  29. echo '<h2>request</h2>';
  30. echo var_export($wp->request, true);
  31.  
  32. global $wp_the_query;
  33. echo '<h2>the query</h2>';
  34. echo var_export($wp_the_query, true);
  35.  
  36.  
  37. });
  38.  
  39.  
  40. add_action('template_redirect', function()
  41. {
  42. global $wp_filter;
  43. echo '<h2>template redirect filters</h2>';
  44. echo var_export($wp_filter[current_filter()], true);
  45.  
  46. }, 99999);
  47. function debug_404_template_redirect()
  48. {
  49.  
  50. }
  51. add_filter('template_include', function($template)
  52. {
  53. echo '<h2>template file selected</h2>';
  54. echo var_export($template, true);
  55.  
  56. echo '</pre>';
  57. exit();
  58. });
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement