wp_enqueue_script was called incorrectly Issue when active plugins of WordPress Admin Bar Improved

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.

error code: 523