Link to home
Start Free TrialLog in
Avatar of Robert Saylor
Robert SaylorFlag for United States of America

asked on

Notice: wp_enqueue_style was called incorrectly

Stylesheet in WordPress plugin:

$plugin_dir = "test";
wp_enqueue_style('style', plugins_url("/" . $plugin_dir . "/css/style.css"), array(), null, null);

Open in new window


When this is ran I get a notice warning:

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.0.) in /home/username/public_html/wp/wp-includes/functions.php on line 4147

I have spent several hours on google trying different combos but it keeps falling back to this warning.

Note: I am looking for a solution in the plugin folder only. I do not want to mess with the theme. I have another same issue with a script and solving this will also solve another problem I have.
ASKER CERTIFIED SOLUTION
Avatar of Robert Saylor
Robert Saylor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robert Saylor

ASKER

self solve