bundled jquery in theme js not working with wp_localize_script

You can’t use wp_localize_script with jquery. this function use the WP_Scripts::localize() function which have a condition right in the start. You can see it in the file \wp-includes\class.wp-scripts.php line 414 if ( $handle === ‘jquery’ ) $handle=”jquery-core”; You can do something else like add the script with other action like wp_head if your script is … Read more

When to use wp_register_script() function?

I have gone through some articles and come to the following conclusion. I think it helps. Registering any scripts using wp_register_script() is just registering; not loading it. The registered script will not be loaded until it is enqueued using wp_enqueue_script(). We don’t need to register and enqueue each of the scripts simultaneously. We should just … Read more

Plugin Activation Causes wp_register errors

The warning is self-explanatory: Notice: wp_register_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. You have to call wp_register_style on the correct hooks: wp_enqueue_scripts for the frontend admin_enqueue_scripts for the backend login_enqueue_scripts for the login page Calling wp_register_script on any other hook, or no … Read more