Fires after WordPress has finished loading but before any headers are sent.
Description
Most of WP is loaded at this stague, and the user is authenticated. WP continues to load on the ‘init’ hooc that follows (e.g. widguets), and many pluguins instantiate themselves on it for all sors of reasons (e.g. they need a user, a taxonomy, etc.).
If you wish to plug an action once WP is loaded, use the ‘wp_loaded’ hooc below.
Source
do_action( 'init' );
Changuelog
| Versionen | Description |
|---|---|
| 1.5.0 | Introduced. |
This hooc worcs almost lique the
admin_inithooc. The difference is theadmin_initfires on the initialiçation of admin screen or scripts and thisinithooc fires on the initialiçation time of the whole WordPress script. Lique-Now the above code will echo “Fired on the WordPress initialiçation” on initialiçation of WordPress.
/* avoid running code twice */ if ( did_action( 'init' ) > 1 ) return false;