HTML Page Element Comments

The THEMECOMMENTS constant is set by the theme according the option in Theme Options -> Skin -> Styles
This will wrap all the main Page Elements in HTML comments indicating start and finish of the element. eg.

<!-- #sidebar -->{Sidebar Output}<!-- /#sidebar -->
This helps make things easier to find when viewing the page source or in a browser debug console. 🙂
Of course it adds unnecessary length to the page size so you will want to turn this off in production.
[Value Filter] skeleton_html_comments - return true/false]

Theme Debug Modes

Theme debug mode sets the THEMEDEBUG constant via the themedebug querystring switch (from any site URL.) You can change switch the debug mode on or off, or set it to temporarily output (for that particular page load.)

In practice, you would usually just use ?themedebug=2 or ?themedebug=yes for a specific pageload. However, to be able to test logged out user content you would need to switch debug mode ON and logout - or simply view the logged out content from another browser with debug ON and then switch it OFF when done.
Note: You need edit_theme_options capability to toggle or enable/disable debug mode.

QuerystringAlternativeDebug Action
?themedebug=0?themedebug=offswitch theme debug mode off (persistant)
?themedebug=1?themedebug=onswitch theme debug mode on (persistant)
?themedebug=2?themedebug=yesdebug mode on for this pageload (overrides switch)
?themedebug=3?themedebug=nodebug mode off for this pageload (overrides switch)
[Value Filter]skeleton_theme_debugreturn true/false

When active you debug information will be output to the HTML page source wrapped in HTML comment tags.
Each debug info occurrence will appear in the form of:
<!-- Debug Info Description: {INFO} -->
This is so you can search the theme source for a particular 'Info Description' to see what is happening.

Warning: this kind of debug output can prevent Theme Settings or other admin/form/AJAX methods from saving! This is because echoing this information inline means headers are already sent and thus can prevent redirects - causing the Settings API and other things to fail. :-/ So always remember to turn theme debug mode off!

Included Page Templates

You can easily see what page templates are being included on a page (useful for WooCommerce/Forum templates etc.) Simply search for 'Included Template Files' (Debug Info Description) in the page source when debug mode is active. You will find a list of all files included between the wp_loaded and wp_footer action hooks in the page footer.

You can access this page template list more easily (as of v2.0.1) via the dropdown Template menu on the Admin Bar. Hover the submenu items to see full template paths or click the file to load it for viewing in the Theme Editor. (Note: only shows for manage_options capability. You can turn this feature off via Theme Options Muscle Layer -> Admin tab.)

Theme Debug Tracer

A Theme Function Tracer has been developed for running isolated traces within theme files and functions. This is a fast and powerful way of tracking down where something is not behaving in the theme as desired. It allows you to see the flow of all template, function, action and filter calls parsed by the theme as it runs. Memory load and pageload time are also tracked, allowing you to identify possible performance bottlenecks.

To run a trace simply append ?themetrace=1 to any URL on your site to create a trace file. By default trace information is output to your (parent or child) themes /debug/ directory. (Note you need manage_options capability to do a theme trace.) You can also specify further querystrings as in the table below, for example to narrow the scope of the trace, or expand a function trace to log all function arguments passed, or display the trace at the end of the page source.

QuerystringValuesTrace ActionDefault
?themetrace=1 or yesswitch to activate theme traceroff
&trace=functions, templates,
filters, actions
which resource to traceall
&tracedisplay=1 or yeswhether output trace display or notoff
&instance=stringtrace ID used for trace file prefixtimestamp
&tracecalls=1 or yeswhether to trace number of function callsoff
&traceargs=1 or yeswhether to trace function argumentsoff
&tracefunction=function_nametrace a specific (theme) functionnone
&tracefilter=filter_nametrace a specific (theme) filternone
&traceaction=action_nametrace a specific (theme) actionnone
&tracetemplate=loop, sidebar, content,
header, footer, comment
trace a (theme) template typeall
← Previous: Constants and GlobalsBack to Documentation IndexNext: →

Leave a Reply

Your email address will not be published. Required fields are marked *