Title: wp_enqueue_script was called incorrectly
Last modified: August 21, 2016

---

# wp_enqueue_script was called incorrectly

 *  Resolved [maccast](https://wordpress.org/support/users/maccast/)
 * (@maccast)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-3/)
 * I’m getting this warning when WP_DEBUG is on:
 * wp_enqueue_script was called **incorrectly**. Scripts and styles should not be
   registered or enqueued until the `wp_enqueue_scripts`, `admin_enqueue_scripts`,
   or `init` hooks. Please see [Debugging in WordPress](http://codex.wordpress.org/Debugging_in_WordPress)
   for more information.
 * The error is in reference to line 601 of the `rssimport.php` file.
 * Basically the stuff in this block
 *     ```
       if ( is_admin() && FB_RSSI_QUICKTAG ) {
       	if ( version_compare( $GLOBALS['wp_version'], '3.3alpha', '>=' ) ) {
       		$post_page_pages = array('post-new.php', 'post.php', 'page-new.php', 'page.php');
       		if ( in_array( $pagenow, $post_page_pages ) ) {
       			wp_enqueue_script(
       				'rssimport_insert_button',
       				plugin_dir_url( __FILE__) . '/js/quicktag.js',
       				array( 'quicktags' )
       			);
       			add_action( 'admin_print_scripts', 'rssimport_insert_button' );
       		}
       	} else {
       		add_action( 'admin_footer', 'RSSImport_insert_button' );
       	}
       }
       ```
   
 * [http://wordpress.org/plugins/rss-import/](http://wordpress.org/plugins/rss-import/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Frank Bueltge](https://wordpress.org/support/users/bueltge/)
 * (@bueltge)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-3/#post-4054330)
 * I will fix this. On my tasks was also the switch to the new possibilities to 
   add quicktags, but not enough time. The source of the plugin is very old, but
   it works and have no problems. Your hints are welcome.
 *  Thread Starter [maccast](https://wordpress.org/support/users/maccast/)
 * (@maccast)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-3/#post-4054334)
 * I think for this one they are just saying you need to change the the hook you
   are using to `admin_enqueue_scripts`. So I assume you would change:
 * `add_action( 'admin_print_scripts', 'rssimport_insert_button' );`
    to: `add_action('
   admin_enqueue_scripts', 'rssimport_insert_button' );`.
 * You may need to also change the call as well:
 *  `add_action( 'admin_footer', 'RSSImport_insert_button' );`
    to: `add_action('
   admin_enqueue_scripts', 'RSSImport_insert_button' );`
 * It looks like you only want the script running in the admin, right? If you make
   the hook change you can probably remove the `is_admin()` clause in your IF statement(`
   if ( is_admin() && FB_RSSI_QUICKTAG )`)
 * Or were you just looking for suggestions on how to the new possibilities to add
   quicktags? 😉
 *  Plugin Author [Frank Bueltge](https://wordpress.org/support/users/bueltge/)
 * (@bueltge)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-3/#post-4054356)
 * No, the hook is not enough.
    I will control, that the script was only load on
   the post and page post type. I have change to the hook: `admin_print_footer_scripts`
   The best way to print the scripts inside the footer in backend. And also I have
   the global $pagenow for check the right pages in the backend.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘wp_enqueue_script was called incorrectly’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/rss-import.svg)
 * [RSSImport](https://wordpress.org/plugins/rss-import/)
 * [Support Threads](https://wordpress.org/support/plugin/rss-import/)
 * [Active Topics](https://wordpress.org/support/plugin/rss-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/rss-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/rss-import/reviews/)

## Tags

 * [wp_enqueue_script](https://wordpress.org/support/topic-tag/wp_enqueue_script/)

 * 3 replies
 * 2 participants
 * Last reply from: [Frank Bueltge](https://wordpress.org/support/users/bueltge/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-3/#post-4054356)
 * Status: resolved