0

i know that this error is just a notice:

notice: 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 /home/linksfrkses/public_html/wp-includes/functions.php on line 3547

But, on many project i want to work with the debug on.
once i even solved this - but, i cant remember how...

i searched and checked and keep getting posts saying
"use wp_enqueue_scripts" but i am... So, what is wrong with this code:

    function enqueue_stuff(){

    wp_enqueue_style('bootstrapcss', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', array(), '3.3', 'all');
    wp_enqueue_style('fontawesome', 'http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css', array(), false);
    wp_enqueue_style('maincss', BASE_URL . '/css/main.css');

    wp_enqueue_script('jquery');
    wp_enqueue_script('bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js', array('jquery'), 3.3, true);
    wp_enqueue_script('chainedjs', BASE_URL.'/js/jquery.chained.mini.js', array('jquery'), false, true);
    wp_enqueue_script('miscscripts', BASE_URL.'/js/misc-scripts.js', array('jquery'), false, true);

}
add_action('wp_enqueue_scripts', 'enqueue_stuff');
  • That notice is thrown when wp_enqueue_script() is used inside an early hook e.g. when used directly in functions.php without be wrapped in a hook. But in your code above it is used properly, on 'wp_enqueue_scripts' hook, so problem must be elsewhere. – gmazzap Jan 13 '15 at 0:47
  • do you mean a plugin? (based on that question) any way to trace the source? the error / notice message is pretty general. – Sagive SEO Jan 13 '15 at 0:58
  • 1
    search your wp-content directory for instances of wp_enqueue_script, it's elsewhere in your theme, or a plugin. – Milo Jan 13 '15 at 2:53
  • thats a good way to go about it. thanks a lot for helping mate. – Sagive SEO Jan 13 '15 at 14:18
0

ok... after @milo comments i went ahead and searched for wp_enqueue_scripts in my plugin folders and found 2 plugins doing it wrong.

Fixed them (until the next update) and everything works... So, i have no controll - these are good plugins and yet. wrote the plugins authors and hope for the best.

thats all - case solved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.