Title: [Plugin: JQuery Mega Menu Widget] Patch fix for &quot;Notice: wp_enqueue_script was called incorrect
Last modified: August 20, 2016

---

# [Plugin: JQuery Mega Menu Widget] Patch fix for "Notice: wp_enqueue_script was called incorrect

 *  Resolved [benmoreassynt](https://wordpress.org/support/users/benmoreassynt/)
 * (@benmoreassynt)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-jquery-mega-menu-widget-patch-fix-for-notice-wp_enqueue_script-was-called-incorrectly/)
 * If, as I do, you have PHP set to show all errors during development, you get 
   the following error for Mega Menu plugin.
 * Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not
   be registered or enqueued until the wp_enqueue_scripts.
 * It’s an easy fix, and one you might want to add to the code.
 * Change the plugin intialization from:
 *     ```
       // Initialize the plugin.
       $dcjqmegamenu = new dc_jqmegamenu();
       ```
   
 * to
 *     ```
       $dcjqmegamenu = new dc_jqmegamenu;
       add_action('init', array($dcjqmegamenu, 'dc_jqmegamenu2'));
       ```
   
 * Rename the first function in `dc_jqmegamenu` to `dc_jqmegamenu2` (because you
   want to stop the class auto-initializing, and wait for it to be initialized at
   the right time by the WordPress init hook.
 * In reality, the way the current code calls it does not do any harm, apart from
   spitting out kind of annoying error warnings on every page, but perhaps still
   worth fixing?
 * Here’s the content of a patch file I created:
 *     ```
       *** dcwp_jquery_mega_menu.orig.php	2012-08-11 14:22:06.272810507 -0400
       --- dcwp_jquery_mega_menu.php	2012-08-11 14:18:28.772809667 -0400
       ***************
       *** 13,19 ****
   
         class dc_jqmegamenu {
   
       ! 	function dc_jqmegamenu(){
         		global $registered_skins;
   
         		if(!is_admin()){
       --- 13,19 ----
   
         class dc_jqmegamenu {
   
       ! 	function dc_jqmegamenu2(){
         		global $registered_skins;
   
         		if(!is_admin()){
       ***************
       *** 49,55 ****
         include_once('dcwp_jquery_mega_menu_widget.php');
   
         // Initialize the plugin.
       ! $dcjqmegamenu = new dc_jqmegamenu();
   
         // Register the widget
         add_action('widgets_init', create_function('', 'return register_widget("dc_jqmegamenu_widget");'));
       --- 49,57 ----
         include_once('dcwp_jquery_mega_menu_widget.php');
   
         // Initialize the plugin.
       !
       ! 	$dcjqmegamenu = new dc_jqmegamenu;
       ! 	add_action('init', array($dcjqmegamenu, 'dc_jqmegamenu2'));
   
         // Register the widget
         add_action('widgets_init', create_function('', 'return register_widget("dc_jqmegamenu_widget");'));
       ```
   
 * [http://wordpress.org/extend/plugins/jquery-mega-menu/](http://wordpress.org/extend/plugins/jquery-mega-menu/)

The topic ‘[Plugin: JQuery Mega Menu Widget] Patch fix for "Notice: wp_enqueue_script
was called incorrect’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/jquery-mega-menu_e7e7e7.svg)
 * [JQuery Mega Menu Widget](https://wordpress.org/plugins/jquery-mega-menu/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jquery-mega-menu/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jquery-mega-menu/)
 * [Active Topics](https://wordpress.org/support/plugin/jquery-mega-menu/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jquery-mega-menu/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jquery-mega-menu/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [benmoreassynt](https://wordpress.org/support/users/benmoreassynt/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-jquery-mega-menu-widget-patch-fix-for-notice-wp_enqueue_script-was-called-incorrectly/)
 * Status: resolved