After the solution to this question was to get a function to launch BEFORE the init
action is fired by taking the sequence out of its function, it got me thinking, is there any earlier in the WP load sequence that I can hook a function into?
Leave a Reply
You must be logged in to post a comment.
muplugins_loaded
is the earliest hook.The next best hook to trigger is
plugins_loaded
.RESOURCES
For anyone interested in finding this out on your own, there is an awesome plugin named Query Monitor.
Install and activate the plugin (on staging or dev install obviously) and just select what you want from the drop down.
As mentioned in a comment on the accepted answer, the hook muplugins_loaded is not conditional. If you read the source code you will find that it is always fired – at least in recent versions of WordPress. According to the documentation it is also the first available hook. However, unless you are actually writing a must-use or network activated plugin it doesn’t make much sense to use it since it will fire before your plugin or theme is loaded.
If you are writing a plugin, then the plugins_loaded is the first general action hook to use.
If you are adding code to your theme’s functions.php, then you could use after_setup_theme.