Here we solve the Wordpress 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 init hooks.
So I thought I would start my geek-dom with a quick problem that I had this morning after I upgraded my Wordpress blog with my custom plug-in. I got this silly message at the top of the screen:
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 init hooks.
I believe this is a version 3.3 thing. This has to do with a simple call in your addActionsAndFilters() functions of your plug-in. The fix is rather simple (luckily).
Find the following action call:
wp_enqueue_style(’reviewpress’, plugins_url(’/css/reviewpress.css’, __FILE__));
(Yours will different but the call to your custom css file should be the same using the wp_enqueue_style).
All we need to do is call it like a standard add_action:
function wpse49339_enqueue_styles() {
wp_enqueue_style(’reviewpress’, plugins_url(’/css/reviewpress.css’, __FILE__));
}
add_action( ‘wp_enqueue_scripts’, ‘wpse49339_enqueue_styles’ );
The add_action will now call the wp_enqueue_scripts function AFTER the init and wp_enqueue_scripts!
That is it! All should be happy once again!
cheers…matt
|
Don't Buy Another Money Making Product Until You Watch These FREE Videos! |
My name is Matthew Bredel and as of March, 2007, I am a full-time, work-at-home internet marketer.
For close to 10 years, I worked for a defense company which was an OK job, but I was so uninspired in life and frankly, I needed some more money. That is when I first discovered internet marketing! Now I admit that I didn't start making thousands in my first couple of months (in fact, I lost my shirt!), but I finally saw the "internet light"...