See https://codex.wordpress.org/Plugin_API/Action_Reference
💡 Always hook the latest possible action.
- Not when plugin's main file or the themes's
functions.php
file is being loaded! - Plugins at
plugins_loaded
- Theme's
functions.php
file is loaded just beforeafter_setup_theme
- Generally at
init
add_action('plugins_loaded', 'myprefix_add_hooks', 10, 0);
register_activation_hook()
register_post_type()
- Core request type (entry points and routes),
see template hierarchy and
Toolkit4WP\Is::request()
- Plugin and themes request types (e.g. AMP pages, XML sitemap)
💡 Anonymous visitors include ones with JS disabled, robots, attackers and pull CDN.
See https://codex.wordpress.org/Conditional_Tags
- Post type
is_singular($cpt)
- Page template
- Archives
- Current admin page, see https://codex.wordpress.org/Plugin_API/Action_Reference/load-(page)
- Logged in users with core roles
- Custom roles
💡 is_admin()
includes wp_doing_ajax()
!
- Based on
WP_DEBUG
- Based on environment name from
WP_ENV
GET and POST variables.
💡 Best to avoid direct request variable access.
register
GET, POSTlogin
GET, POSTlogout
GETlostpassword
(wasretrievepassword
) GET, POSTrp
GET,resetpass
POSTconfirm_admin_email
GET every six months after an admin has logged inpostpass
POST password protected postsconfirmaction
GET multisite account activationWP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED
GET, POST?