how can I get wordpress to tell me which function rendered a specific piece of output
I've found the List Hooked Functio开发者_如何转开发ns method to display all the elements that are contributing to the final render, but I want to see which of those functions is ultimately responsible for rendering a specific piece of output. Ideally, it would work similarly to Magento's Template Hints so the responsible code is listed right next to the resultant output.
I guess I could write a function that hooks into each event and attempts to find the last function in the chain of hooks for that particular component...
Any thoughts appreciated.
Thanks, Jonathan
You may want to try "WordPress Hook Sniffer" at http://wordpress.org/extend/plugins/wordpress-hook-sniffer/ or the method mentioned at "Identifying WordPress Hooks" http://blog.aizatto.com/2010/03/14/identifying-wordpress-hooks/.
I think this will be very hard to do. Wordpress output comes from all over the place, many little functions that call echo
on their own without notifying anything (activating no hook). If everything went through a template, you could modify the code that calls the template so it prints the name of the template first, as your Magento example seems to do. But this is not the Wordpress way, so your best attempt may be to replace all calls to echo
with echo __FILE__ . ': ' . __FUNCTION__ .
or something weird like that.
精彩评论