[wp-hackers] Wordpress Code flow

Jeremy Clarke jer at simianuprising.com
Sun Nov 21 16:58:32 UTC 2010


On Thu, Nov 18, 2010 at 9:43 AM, Haluk Karamete <halukkaramete at gmail.com>wrote:

>
> In order to understand wp from the ground up, I thoght I should get a full
> grasp of from url to all the way to wp_footer() what really happens... Ant
> pointers in this regard is highly appreciated.
>
>
Aside from the Query Overview article which will probably help you a good
way to get a sense of the flow is through the various action hooks. If you
look at the order in which they occur then you get a sense of what WP is
doing, and if you're curious about a specific part it's usually easy to find
the action hook in the source and see what's happening around it (though
often the relevant functions don't have good descriptions so you have to
parse all the PHP logic before you really understand it).

You can read the action order on the codex
http://codex.wordpress.org/Plugin_API/Action_Reference

You can also use a plugin like 'Suspect' which gives a list of all actions
in the the order they fired:
http://wordpress.org/extend/plugins/suspect/(suspect is also a good
way to see what queries wp is performing, and a
contender for best WP-Tuner (RIP) replacement).

You can also use the following code in a plugin or functions.php to echo out
the name of each action as it fires, so you can see how the flow of actions
relates to whatever it is that you're working on:

/**
 * Debug system to echo out every hook name as it fires
 */
function gv_debug_print_every_hook() {
    echo "<br />";
    echo current_filter();
}
add_action('all', 'gv_debug_print_every_hook');


-- 
Jeremy Clarke | http://jeremyclarke.org
Code and Design | http://globalvoicesonline.org


More information about the wp-hackers mailing list