Mihael
Member
Posted 4 months ago #
Please, someone put me out of my misery and let me know what is a most probable reason for this problem:
As far as I checked (at least 10 times) all my scripts are registered and enqueued as they should be...
Notice: wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in my_path/wp-includes/functions.php on line 3587
Thank you!
James Edmonston
Member
Posted 4 months ago #
Post the source of the file that is causing the errors - will allow us to debug and find the problem.
Thanks.
Mihael
Member
Posted 4 months ago #
That would be rather difficult since the error does not say... I have a functions.php including a bunch of other custom scripts - as I exclude those, error remains... so they are not the problem :(
James Edmonston
Member
Posted 4 months ago #
Is it a custom theme or a fresh install of WordPress?
Mihael
Member
Posted 4 months ago #
It is my custom "work" and wordpress 3.3.1.
I was thinking this might be some kind of more obvious error maybe... but it probably isn't... I am most certain that it is my mistake, since almost always is :)
James Edmonston
Member
Posted 4 months ago #
Well if you post the code where you enqueued scripts etc, that'll help.
Mihael
Member
Posted 4 months ago #
That would be to many code to post since I can't even find the origin of the error - we are talking about 40 files... I will have to take some more time and find the error... As I see now, the only thing that could be a problem is that some script is not registered when it should be... I will just have to revisit all my code.
James, thank you for your effort... I am sorry that we couldn't get anywhere with this one :/
Ryann Micua
Member
Posted 3 months ago #
Hi Michael, i believe it has soemthing to do with the way you are supposed to register/enqueue your scripts.. basically the php notice is saying that you are using wp_register_script incorrectly. read this for more info. http://codex.wordpress.org/Function_Reference/wp_register_script
you have to hook the register function into either wp_enqueue_scripts, admin_enqueue_scripts, or init.
so, to use wp_register_script() properly do it like this:
add_action('wp_enqueue_script','register_my_scripts');
function register_my_scripts(){
wp_register_script('xxx');
}
georgeliebau
Member
Posted 1 week ago #
Where in the theme directory's functions.php file does that code go?
Thanks!
does not matter really... just put it "here" and "there".. test it.
Ryann Micua
Member
Posted 1 week ago #
basically, just go through all the places where you used wp_register_script() function and hook it to either "wp_enqueue_scripts", "init" or "admin_enqueue_scripts"