Welcome to the series finale of "Fifty Actions of WordPress!" Over the last few weeks, we've been looking at WordPress actions - what they are, how to use them, and 50 of those that exist along with examples of how to put them to work for us.
In this last part, we're going to review what we learned and summarize all the 50 actions with a couple of words for each one.
Let's begin!
Part One: An Introduction to WordPress Actions
We started with a simple introduction to the world of actions in WordPress. Since the whole system is actually pretty easy, it wasn't hard to introduce it at all. We learned the following seven essential functions:
-
add_action()which allows us to hook our functions to existing action hooks, -
remove_action()which removes a function from an existing action hook, -
remove_all_actions()which removes all functions from an action hook, -
do_action()which lets us create new action hooks, -
do_action_ref_array()which lets us create new action hooks using an array for arguments, -
did_action()which counts the number of times an action is fired, - and
has_action()which checks if anything's hooked to an action.
50 Great Examples for 50 Great Actions
Over the course of the following five articles, we were introduced to 10 actions in the core with examples for every single one of them.
Let's remember what each one was good for:
Part Two: Fifty Actions of WordPress – 50 Examples (1 to 10)
-
inithandles the initialization of WordPress – just before the headers are sent. -
send_headerssends the headers and lets us add extra HTTP headers. -
after_switch_themeis fired off right after the user switches themes. -
manage_posts_custom_columngives us the possibility to add custom columns to the "All Posts" page in the admin panel. -
admin_headallows us to inject code to the<head>of the pages in the admin panel. -
wp_footermakes it possible for us to run code through thewp_footer()function. -
wp_enqueue_scriptsis the action to enqueue scripts and styles correctly to the front-end. -
admin_noticeslets us display admin notices in the back-end. -
widgets_initinitializes the widgets of WordPress and allows us to modify it. -
delete_useris called right after a user is deleted from the database.
Part Three: Fifty Actions of WordPress – 50 Examples (11 to 20)
-
wp_default_stylescontrols the process of loading of the default WordPress styles. -
get_footermakes it possible for us to tamper with theget_footer()function. -
admin_initis fired off each time an admin page is loaded, giving us the opportunity to get creative with it! -
wp_authenticateruns to authenticate a user when they log in. -
login_formhandles the login form, giving us the chance to customize it. -
admin_menulets us add/remove menu items (or sub-menu items) to the main administration menu. -
wp, the action with the shortest name, runs after a query is parsed but before any template is executed. -
admin_head-(page_name)allows us to control the<head>of the admin page which is specified in the name of the action (page_name). -
wp_before_admin_bar_render, as its name suggests, runs before the Toolbar (formerly Admin Bar) is rendered. -
profile_updateis called right after a profile is updated in the database.
Part Four: Fifty Actions of WordPress – 50 Examples (21 to 30)
-
pre_get_postsis fired off before theget_posts()function, allowing us to play with the query. -
transition_post_statusis the action that controls the transition of post statuses, like "draft to publish", "future to private" and such. -
admin_enqueue_scriptsis used to enqueue scripts and styles correctly in the admin panel. -
save_postexecutes right after a post is saved to the database. -
add_meta_boxes_(post_type)lets us add meta boxes to a custom post type's post edit screen. -
activity_box_endis fired off at the end of the "At a Glance" (formerly "Right Now") section. -
wp_metais the action that allows us to tamper with the default "Meta" widget. -
wp_dashboard_setupinitializes the Dashboard, the homepage of the admin panel, and makes it possible for us to monkey with it. -
set_current_useris part of the pluggablewp_set_current_userfunction which changes the current user by ID or name. -
plugins_loadedruns right after all the activated plugin files are loaded.
Part Five: Fifty Actions of WordPress – 50 Examples (31 to 40)
-
wp_default_scriptshandles the execution of default WordPress scripts and lets us tamper with the process. -
wp_headmakes it possible for us to run code in thewp_head()function. -
after_setup_themeis called each time a file of the activated theme is loaded. -
manage_media_custom_columngives us the opportunity to add extra columns to the file list in the Media Library. -
comment_(old_status)_to_(new_status), which has two variables in its name, executes after a comment's status is changed in the database. -
template_redirectis called when a "page template" is loaded. -
do_feedhandles the feeds of your WordPress installation. -
admin_bar_menuallows us to manipulate the Toolbar. -
wp_list_categoriesmakes it possible for us to control the behavior of the default "Categories" widget. -
pre_get_search_formruns just before the search form in your theme is loaded.
Part Six: Fifty Actions of WordPress – 50 Examples (41 to 50)
-
admin_head-(plugin_page)runs in the<head>of the plugin pages you specify. -
pre_pingis called before a ping is processed. -
get_headermakes it possible for us to run code in theget_header()function. -
login_headexecutes in the<head>of the login page and lets us control it. -
admin_footeris fired before the</body>tag in admin pages. -
login_enqueue_scriptsis used to enqueue scripts and styles correctly in the login page. -
manage_users_custom_columngives us the chance to add custom columns to the Users table in the "All Users" page. -
activated_pluginis fired off each time a plugin is activated. -
admin_color_scheme_pickercontrols the behaviour of the "color schemes" picker in the user profile editing pages. -
wp_logoutruns when a user logs out.
Part Seven: The End
You guessed it, you're reading part seven right now! Joking aside, here we are at the end of the series. I really, really hope you enjoyed this series as much as I did while writing the whole thing.
Contributions of all types are appreciated, by the way. You can:
- Share your thoughts on this series by commenting below,
- Suggest new filters and example ideas for an "addendum" part or two,
- Offer ways to improve my writing if you caught a mistake, incoherency or ambiguity in my posts,
- And share these tutorials anywhere for everyone to see and learn about WordPress filters!
Thank you for taking time to read the series - hopefully it serves as a point of education and of reference moving forward!
Comments