When is wp_loaded initiated only with admin or only when user enters the site or both?
When is wp_loaded
initiated?
Im trying to add function that downloads a big file for the plugin DB, and I need it to be executed whenever user/admin/unknown user get in the frontend, after the site is fully loaded, so that it would not be any delay with the site speed, and user experience.
I use this script:
// add update check when admin login
if (is_admin()) {
function wp_plugin_update() {
include( plugin_dir_path( __FILE__ ) . 'wp-plugin-update.php');
}
add_action( 'admin_init', 'wp_shabbat_update' );
}
// add update check when user enter the site after footer loaded
if (!(is_admin() )) {
function wp_plugin_update() {
include( plugin_dir_path( __FILE__ ) . 'wp-plugin-update.php');
}
add_action( 'wp_loaded', 'wp_plugin_update' );
}
Can I only use this and it will work with admin and when user enter the site? :
function wp_plugin_update() {
include( plugin_dir_path( __FILE__ ) . 'wp-plugin-update.php');
}
add_action( 'wp_loaded', 'wp_plugin_update' );
Topic wp-load.php plugin-development Wordpress
Category Web