Developers tool: WordPress Hooks & Filters Flow
-
I ran across this little gem while looking for a php class for ‘modified pre-order tree trasversal’. Try saying that three times real quick. No idea how I arrived at ‘WordPress Hooks & Filters Flow’ but I’m glad I did.
bp is entirely event driven in nature. Everything responds to or creates events that wp calls actions and filters. This script analyzes a live wp install and dumps all the actions/filters like so:
wp
* Priority 1 :
1. bp_core_set_uri_globals()
2. bp_core_setup_globals()
3. bp_activity_setup_globals()
4. bp_blogs_setup_globals()
5. friends_setup_globals()
6. groups_setup_globals()
7. messages_setup_globals()
8. bp_wire_setup_globals()
9. xprofile_setup_globals()
* Priority 2 :
1. bp_core_add_settings_nav()
2. bp_core_setup_nav()
3. bp_activity_setup_nav()
4. bp_blogs_setup_nav()
5. friends_setup_nav()
6. groups_setup_nav()
7. messages_setup_nav()
8. bp_wire_setup_nav()
9. xprofile_setup_nav()
10. bp_show_home_blog()
11. bp_show_register_page()
12. bp_show_activation_page()
* Priority 3 :
1. bp_core_setup_session()
2. bp_activity_action_sitewide_feed()
3. bp_activity_action_personal_feed()
4. bp_activity_action_friends_feed()
5. bp_forums_setup()
6. groups_action_join_group()
7. messages_action_view_message()
8. messages_action_delete_message()
9. messages_action_bulk_delete()
10. xprofile_action_delete_avatar()
11. xprofile_action_new_wire_post()
12. xprofile_action_delete_wire_post()
* Priority 4 :
1. groups_screen_group_admin_edit_details()
2. groups_screen_group_admin_settings()
3. groups_screen_group_admin_avatar()
4. groups_screen_group_admin_manage_members()
5. groups_screen_group_admin_requests()
6. groups_screen_group_admin_delete_group()
* Priority 5 :
1. bp_core_directory_members_setup()
2. bp_core_search_site()
3. bp_blogs_directory_blogs_setup()
4. groups_directory_groups_setup()
* Priority 6 :
1. bp_core_get_random_member()
2. bp_blogs_redirect_to_random_blog()
3. groups_redirect_to_random_group()
* Priority 10 :
1. bp_core_catch_no_access()
2. bp_core_add_js()
3. xprofile_add_js()
What you see above is bp’s wake up event ‘wp’, the bp functions that hook it and the sequence they are called. Way cool! In my particular install there are:
Number of hooks 293
Number of registered filters / actions : 673
I get to see all of them live and in person. You can too. From Ozh’s description of this utility:
WordPress Hooks & Filters Flow
4 blablas On: 2006/05/16 Viewed: 6774 times
Basically, a plugin for WordPress creates a PHP function (a filter or an action) which is called when a particular event (a hook) occurs, for example when a post is printed or when a comment is posted (for more info about hooks, filters and action, check the Codex)
When developping a new plugin, you sometimes encounter unexpected behaviors from your code, which can originate from a filter conflict : another PHP function with a higher priority was triggered before your own function, and processed the same bits you’re trying to pass through your function.
That’s why when developping plugins, it’s important to be well aware of what I call the Filter Flow : for each hook, which functions are called in which order ?
So, I wrote this script : WordPress Hooks & Filters Flow
I thought other developers might be interested.
http://planetozh.com/blog/my-projects/wordpress-hooks-filter-flow/
- The topic ‘Developers tool: WordPress Hooks & Filters Flow’ is closed to new replies.