6

Is there a simple way (plugin / function) that uses Tidy or some other lib to pretty-print Wordpress's HTML output?

It's unreadable as it is and it's almost impossible to write a theme with proper indentation with all the includes / hooks going on all over the place.

Performance is not an issue as this only needs to be active for development purposes.

6
  • Well, firebug does provide you with indentation in it's html tab.
    – mhitza
    Commented Aug 20, 2010 at 16:18
  • This is better suited to wordpress.stackexchange.com
    – Bobby Jack
    Commented Aug 20, 2010 at 16:47
  • Note that firebug's HTML view is dynamic - i.e. it will update according to any DOM manipulation. Depending on your requirements, and whether your page has any scripts present, this may be an issue.
    – Bobby Jack
    Commented Aug 20, 2010 at 16:48
  • If you need it static I suppose he could just copy n' paste the source from 'view source' over to an IDE and have that format the code for him.
    – Yi Jiang
    Commented Aug 21, 2010 at 5:14
  • I sometimes use this technique but that involves copy-pasting the code, creating a new document to paste it into, etc.
    – Andrei
    Commented Aug 23, 2010 at 23:13

2 Answers 2

0

I suggest:

  1. Get Firebug
  2. Use PHP heredocs
  3. Include whitespace in your output using \n (newline), \t (tab), etc.
1
  • I do have Firebug. Problem is not with stuff from variables but more of the way things from core Wordpress get included (eg. get_header(), get_footer()).
    – Andrei
    Commented Aug 23, 2010 at 23:10
0

Give Kint PHP Debugger a try.

Works great for doing var_dumps with a nice UI.

Example:

$items = array('pine', 'apple', array('numbers' => [1,2,3,4]));
d($items);

Not the answer you're looking for? Browse other questions tagged or ask your own question.