I don’t know how but now I am getting this error :
Notice: wp_enqueue_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. Please see Debugging in WordPress for
more information. (This message was added in version 3.3.) in
wp-includes/functions.php on line 3049Notice: wp_enqueue_script 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. Please see
Debugging in WordPress for more information. (This message was added
in version 3.3.) in wp-includes/functions.php on line 3049Warning: Cannot modify header information – headers already sent by
(output started at wp-includes/functions.php:3049) in wp-login.php on
line 415Warning: Cannot modify header information – headers already sent by
(output started at wp-includes/functions.php:3049) in wp-login.php on
line 427
This is what I get when I try to log in… On other sites, I have only two first errors. I try to fix it but I can’t. Any suggestions?
Disable all plugins and switch to the default theme. It should be gone now.
Then enable each addon step by step, until the problem comes back. You know the source now, letâs say a plugin.
The plugin calls probably
wp_enqueue_script
too early. Find all occurrences of that function, then make sure they are bound to specific actions:wp_register_script()
should be called for the actionwp_loaded
wp_enqueue_script
on one of the actionswp_enqueue_scripts
,admin_enqueue_scripts
,customize_controls_enqueue_scripts
orlogin_enqueue_scripts
(see this thread for the latter).Based on Gregory Schultz’s solution:
Wrap all your scripts and styles in a function and hook that function to your target
enqueue
action.ð
wp_enqueue_scripts
â front-endadmin_enqueue_scripts
â admin pagelogin_enqueue_scripts
â login pageRather than disable all your plugins one by one, or modify your codebase to debug, you can use the Query Monitor plugin to narrow down the source of this error.
When you see this error reported in the console:
The last column (
Component
) will tell you the plugin that is triggering the error. From there do a search inside of that plugin (or theme) to find and patch the issue.The reason why this is happening is because these functions are being called straight from the functions.php file, without using a function. Find out which lines in functions.php aren’t inside a function like this, and add them.
Example for datepicker:
-Instead of this in functions.php:
-We add this
Hope it works
It means there are 3 “endpoints” for
wp_enqueue_script()
which are wp_enqueue_scripts for the frontend, login_enqueue_scripts for the login screen, admin_enqueue_scripts for the admin dashboard. Check this link.You get this error because
wp_enqueue_script()
was called unproperly.Wrap it in a hook called wp_enqueue_scripts.
Example:
What resolved this issue for me was downloading WordPress classic editor and classic widgets plugin