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)
-
init
handles the initialization of WordPress – just before the headers are sent. -
send_headers
sends the headers and lets us add extra HTTP headers. -
after_switch_theme
is fired off right after the user switches themes. -
manage_posts_custom_column
gives us the possibility to add custom columns to the "All Posts" page in the admin panel. -
admin_head
allows us to inject code to the<head>
of the pages in the admin panel. -
wp_footer
makes it possible for us to run code through thewp_footer()
function. -
wp_enqueue_scripts
is the action to enqueue scripts and styles correctly to the front-end. -
admin_notices
lets us display admin notices in the back-end. -
widgets_init
initializes the widgets of WordPress and allows us to modify it. -
delete_user
is called right after a user is deleted from the database.
Part Three: Fifty Actions of WordPress – 50 Examples (11 to 20)
-
wp_default_styles
controls the process of loading of the default WordPress styles. -
get_footer
makes it possible for us to tamper with theget_footer()
function. -
admin_init
is fired off each time an admin page is loaded, giving us the opportunity to get creative with it! -
wp_authenticate
runs to authenticate a user when they log in. -
login_form
handles the login form, giving us the chance to customize it. -
admin_menu
lets 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_update
is called right after a profile is updated in the database.
Part Four: Fifty Actions of WordPress – 50 Examples (21 to 30)
-
pre_get_posts
is fired off before theget_posts()
function, allowing us to play with the query. -
transition_post_status
is the action that controls the transition of post statuses, like "draft to publish", "future to private" and such. -
admin_enqueue_scripts
is used to enqueue scripts and styles correctly in the admin panel. -
save_post
executes 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_end
is fired off at the end of the "At a Glance" (formerly "Right Now") section. -
wp_meta
is the action that allows us to tamper with the default "Meta" widget. -
wp_dashboard_setup
initializes the Dashboard, the homepage of the admin panel, and makes it possible for us to monkey with it. -
set_current_user
is part of the pluggablewp_set_current_user
function which changes the current user by ID or name. -
plugins_loaded
runs right after all the activated plugin files are loaded.
Part Five: Fifty Actions of WordPress – 50 Examples (31 to 40)
-
wp_default_scripts
handles the execution of default WordPress scripts and lets us tamper with the process. -
wp_head
makes it possible for us to run code in thewp_head()
function. -
after_setup_theme
is called each time a file of the activated theme is loaded. -
manage_media_custom_column
gives 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_redirect
is called when a "page template" is loaded. -
do_feed
handles the feeds of your WordPress installation. -
admin_bar_menu
allows us to manipulate the Toolbar. -
wp_list_categories
makes it possible for us to control the behavior of the default "Categories" widget. -
pre_get_search_form
runs 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_ping
is called before a ping is processed. -
get_header
makes it possible for us to run code in theget_header()
function. -
login_head
executes in the<head>
of the login page and lets us control it. -
admin_footer
is fired before the</body>
tag in admin pages. -
login_enqueue_scripts
is used to enqueue scripts and styles correctly in the login page. -
manage_users_custom_column
gives us the chance to add custom columns to the Users table in the "All Users" page. -
activated_plugin
is fired off each time a plugin is activated. -
admin_color_scheme_picker
controls the behaviour of the "color schemes" picker in the user profile editing pages. -
wp_logout
runs 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