0

I am getting the error with the following message when i active my plugins "WordPress Admin Bar Improved":

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.0.) in C:\xampp\htdocs\flexisim\wp-includes\functions.php on line 4094

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 C:\xampp\htdocs\flexisim\wp-includes\functions.php on line 4094

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 C:\xampp\htdocs\flexisim\wp-includes\functions.php on line 4094

Following is the related code i found from my plugins which include wp_enqueue_scripts:

public function admin_scripts()
{
    wp_enqueue_script('wpabi_admin_js', plugins_url('wpabi-admin.js', __FILE__), array('jquery'), '1.0');

}

public function admin_styles()
{
    wp_enqueue_style('wpabi_admin_css', plugins_url('wpabi-admin.css', __FILE__), '', '2.0', 'all');
}

What i can do to resolve this kind of error?

Looking for the help,

Thank you very much.

2

To use wp_enqueue_script() correctly, you need to launch your function with the action wp_enqueue_scripts.

In your __construct() or init function

  add_action('wp_enqueue_scripts', array($this, 'admin_script'));

You can enqueue both, scripts and styles, in this function.

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.