Twitter Weekly Updates for 2010-03-14
- @Fadhil just make sure you don't drop out in reply to Fadhil #
- @vernieman no time for the #mondayblues there is lots to get done! in reply to vernieman #
- @urekalabs wip about to start soon #
- done with my term to talk at the @urekalabs wip, now is @hakimism and @Qishin's turn #
- @syedfarouq is in the @urekalabs house #
- RT @urekalabs: we do not build houses #
- done with @urekalabs wip #
- @Seymores i like ipserverone in reply to Seymores #
- @scy_krylief especially the durian ones! sedap nya! in reply to scy_krylief #
- RT @arzumy: ManPacks.com - a different kind of startup http://bit.ly/b8VfID /via @newsycombinator / this is awesome ! #
- @scy_krylief mm haven't had durian potong in a while! Must go find some! in reply to scy_krylief #
- rocking @urekalabs with Queen #
- @kamal Putrajaya public library? in reply to kamal #
- @AimanNubailah is scary over the phone #
- @surianee disease carrier! in reply to surianee #
- @ ICTweeets are in the @urekalabs house receiving training by @nicholasnuing and @Qishin #
- WordPress v3 beta (svn v13646) custom menus are broken. Damn it. http://ow.ly/1gANw http://ow.ly/1gAOM #
- @cyfu using your phone at a gas station? in reply to cyfu #
- @cerventus is there a hash tag for this thing? perhaps is the code #GAMCKL . See you there in reply to cerventus #
- #gamc The biggest insight I learned was on how to sell data and data analysis. Good job crew! #
- #gamc The next biggest insight I learned was on how many people in Malaysia (Kuala Lumpur) are interested in Google Analytics. #
- @blogjunkie http://twitpic.com/180fwn - congratulations bro! #
- @bearwithclaws holas, your blog no comments? I have a script which will only deploy latest git changes via FTP. you want? in reply to bearwithclaws #
- @bearwithclaws how can I conatct you. I think you forget to put your contact details. in reply to bearwithclaws #
- @kamal nope will CC you as well. planned to make it a gem. @bearwithclaws in reply to kamal #
- @merajuk_king haha I got! bwahahaha in reply to merajuk_king #
- @kamal wanted to make it a gem called 'git-deploy', sadly the name is taken *sniffles* @bearwithclaws in reply to kamal #
- @merajuk_king /gloat in reply to merajuk_king #
- @kamal @bearwithclaws pushed it to GitHub http://github.com/aizatto/git-deploy in reply to kamal #
- @nicholasnuing I definitely disapprove. Blasphemy! Why did you even have to tell me? I would have been better ignorant. in reply to nicholasnuing #
- Turning 404s to 301s. #
Twitter Weekly Updates for 2010-03-14
- @Fadhil just make sure you don't drop out in reply to Fadhil #
- @vernieman no time for the #mondayblues there is lots to get done! in reply to vernieman #
- @urekalabs wip about to start soon #
- done with my term to talk at the @urekalabs wip, now is @hakimism and @Qishin's turn #
- @syedfarouq is in the @urekalabs house #
- RT @urekalabs: we do not build houses #
- done with @urekalabs wip #
- @Seymores i like ipserverone in reply to Seymores #
- @scy_krylief especially the durian ones! sedap nya! in reply to scy_krylief #
- RT @arzumy: ManPacks.com - a different kind of startup http://bit.ly/b8VfID /via @newsycombinator / this is awesome ! #
- @scy_krylief mm haven't had durian potong in a while! Must go find some! in reply to scy_krylief #
- rocking @urekalabs with Queen #
- @kamal Putrajaya public library? in reply to kamal #
- @AimanNubailah is scary over the phone #
- @surianee disease carrier! in reply to surianee #
- @ ICTweeets are in the @urekalabs house receiving training by @nicholasnuing and @Qishin #
- WordPress v3 beta (svn v13646) custom menus are broken. Damn it. http://ow.ly/1gANw http://ow.ly/1gAOM #
- @cyfu using your phone at a gas station? in reply to cyfu #
- @cerventus is there a hash tag for this thing? perhaps is the code #GAMCKL . See you there in reply to cerventus #
- #gamc The biggest insight I learned was on how to sell data and data analysis. Good job crew! #
- #gamc The next biggest insight I learned was on how many people in Malaysia (Kuala Lumpur) are interested in Google Analytics. #
- @blogjunkie http://twitpic.com/180fwn - congratulations bro! #
- @bearwithclaws holas, your blog no comments? I have a script which will only deploy latest git changes via FTP. you want? in reply to bearwithclaws #
- @bearwithclaws how can I conatct you. I think you forget to put your contact details. in reply to bearwithclaws #
- @kamal nope will CC you as well. planned to make it a gem. @bearwithclaws in reply to kamal #
- @merajuk_king haha I got! bwahahaha in reply to merajuk_king #
- @kamal wanted to make it a gem called 'git-deploy', sadly the name is taken *sniffles* @bearwithclaws in reply to kamal #
- @merajuk_king /gloat in reply to merajuk_king #
- @kamal @bearwithclaws pushed it to GitHub http://github.com/aizatto/git-deploy in reply to kamal #
- @nicholasnuing I definitely disapprove. Blasphemy! Why did you even have to tell me? I would have been better ignorant. in reply to nicholasnuing #
- Turning 404s to 301s. #
Identifying WordPress Hooks
In order to develop WordPress solutions, you are required to understand how WordPress hooks work. Sadly WordPress has over 1000 hooks in the system, so the task may be daunting to know which hook to exactly use.
There are a few options to find out which hook to use:
- Comb through the source code
- Comb through WordPress documentation on hooks
- Search the Internet for the right hook to use.
Each one requires you to do some searching. Wouldn't it be easier if we let WordPress do that job for us? Whenever we load a page, WordPress will tell us what hooks were called, and in what order.
do_action
Note: WordPress has two kinds of hooks. An action hook, and a filter hook. This article only deals with the action hook. But it can also apply to the filter hook. The filter hook can also be found in wp-includes/plugin.php on line 134
WordPress calls its hooks via the function do_action. do_action calls out all the hooks attached to the hook specified in its arguments. If you open up wp-includes/plugin.php, you should be able to find a function called do_action on line 299.
Note: I am currently running WordPress v3.0 beta. Your file name and line positions may be different.
In order to output the called hook, your first thought may be to enter echo $tag. Sadly this won't work as it will output text all over the WordPress application, which will make it difficult in identifying the hooks called.
FirePHP to the Rescue
Instead we will use FirePHP. Make sure you have FirePHP installed. You can also ensure FirePHP gets loaded on all PHP pages.
Now change the file to:
function do_action($tag, $arg = '') {
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
fb($tag);
Now reload the home page of your WordPress installation with FirePHP enabled and you should get a similar result.
- muplugins_loaded
- plugins_loaded
- sanitize_comment_cookies
- setup_theme
- load_textdomain
- after_setup_theme
- load_textdomain
- auth_cookie_malformed
- set_current_user
- init
- widgets_init
- wp_loaded
- posts_selection
- template_redirect
- get_header
- wp_head
- wp_enqueue_scripts
- wp_print_styles
- wp_print_scripts
- posts_selection
- posts_selection
- get_generic_template_loop
- get_sidebar
- get_search_form
- posts_selection
- wp_meta
- get_footer
- get_sidebar
- wp_footer
- wp_print_footer_scripts
- shutdown
Why don't you visit some other pages to test it out? It works in the Admin side as well.
Backtrace
This is all cool and all, but to get a better understanding of how the WordPress platform works, I sometimes I want to know where the hook was called.
Don't worry, we can solve that for you.
Replace the code you entered with:
function do_action($tag, $arg = '') {
global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
$backtrace = array_shift(debug_backtrace());
fb(substr($backtrace['file'], strlen(ABSPATH)) . ':' . $backtrace['line'] . ' ' . $tag);
The result should be like so:
- wp-settings.php:151 muplugins_loaded
- wp-settings.php:193 plugins_loaded
- wp-settings.php:201 sanitize_comment_cookies
- wp-settings.php:239 setup_theme
- wp-includes/l10n.php:300 load_textdomain
- wp-settings.php:270 after_setup_theme
- wp-includes/l10n.php:300 load_textdomain
- wp-includes/pluggable.php:548 auth_cookie_malformed
- wp-includes/pluggable.php:55 set_current_user
- wp-settings.php:287 init
- wp-includes/default-widgets.php:1144 widgets_init
- wp-settings.php:296 wp_loaded
- wp-includes/query.php:2322 posts_selection
- wp-includes/template-loader.php:7 template_redirect
- wp-includes/general-template.php:26 get_header
- wp-includes/general-template.php:1554 wp_head
- wp-includes/script-loader.php:700 wp_enqueue_scripts
- wp-includes/functions.wp-styles.php:21 wp_print_styles
- wp-includes/script-loader.php:672 wp_print_scripts
- wp-includes/query.php:2322 posts_selection
- wp-includes/query.php:2322 posts_selection
- wp-includes/general-template.php:114 get_generic_template_loop
- wp-includes/general-template.php:84 get_sidebar
- wp-includes/general-template.php:146 get_search_form
- wp-includes/query.php:2322 posts_selection
- wp-includes/general-template.php:350 wp_meta
- wp-includes/general-template.php:55 get_footer
- wp-includes/general-template.php:84 get_sidebar
- wp-includes/general-template.php:1564 wp_footer
- wp-includes/script-loader.php:620 wp_print_footer_scripts
- wp-includes/load.php:517 shutdown
Now how cool is that?


