Getting Wordpress notice on installing enewsletter plugin.

The e-newsletter plugin is showing
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 init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.)
on its pages.
Also on saving the newsletters the page goes blank.

  • aecnu

    Greetings jamesburfield,

    Welcome to WPMU Dev!

    Could you please describe where you are seeing this error?

    I run this plugin myself on my personal production sites for quite some time now and have never seen anything like it.

    Just went in and did another test just to see if anything has changed so I am not sticking foot in mouth ... lol ... and using just the save to check the scenario you gave. Worked flawlessly.

    In my opinion it is time to go into full blown trouble shooting mode because it appears there may be some conflict here and one way to find out conclusively.

    Standard plugin trouble shooting protocol - first to switch to the Twenty Eleven theme just long enough to check for the problem - if the problem still exists next involves deactivating all plugins except the plugin in question and then see if the issue still exists.

    If it does not, then you want to activate plugins one at a time testing in between to see if the issue returns. Even when you find one plugin, it may be in your interest to deactivate the problem plugin and continue testing the rest of the plugins to insure no others are also conflicting. You will know the conflict when the issue returns and which plugin(s) you activated that cause the issue.

    Please advise if there are any plugin conflicts and if so what the plugins are that are conflicting.

    Cheers, Joe

  • jamesburfield

    hi aecnu,

    Actually it was showing error because the wp_enqueue_script was not called on any hooks, I am using wordpress 3.3.2

    I think here is the reason for the error

    //including JS scripts for Newsletter pages
            if ( isset( $_REQUEST['page'] ) && 1 == $this->is_enewsletter_page( $_REQUEST['page'] ) ) {
                wp_enqueue_script( 'jquery' );
    
                //including JS scripts
                wp_enqueue_script( 'jquery-ui-tabs' );
                wp_enqueue_script( 'jquery-ui-core' );
    
                //including JS scripts for tooltips
                wp_register_script( 'jquery_tooltips', $this->plugin_url . 'email-newsletter-files/js/jquery.tools.min.js' );
                wp_enqueue_script( 'jquery_tooltips' );
    
                //including JS scripts for progressbar
                wp_register_script( 'jquery_ui_widget', $this->plugin_url . 'email-newsletter-files/js/ui.widget.js' );
                wp_enqueue_script( 'jquery_ui_widget' );
    
                //including JS scripts for progressbar
                wp_register_script( 'jquery_progressbar', $this->plugin_url . 'email-newsletter-files/js/jquery.ui.progressbar.js' );
                wp_enqueue_script( 'jquery_progressbar' );
            }

    I solved it by following:

    //including JS scripts for Newsletter pages
            if ( isset( $_REQUEST['page'] ) && 1 == $this->is_enewsletter_page( $_REQUEST['page'] ) ) {
                function enewsletter_enqueue(){
                wp_enqueue_script( 'jquery' );
    
                //including JS scripts
                wp_enqueue_script( 'jquery-ui-tabs' );
                wp_enqueue_script( 'jquery-ui-core' );
    
                //including JS scripts for tooltips
                wp_register_script( 'jquery_tooltips', $this->plugin_url . 'email-newsletter-files/js/jquery.tools.min.js' );
                wp_enqueue_script( 'jquery_tooltips' );
    
                //including JS scripts for progressbar
                wp_register_script( 'jquery_ui_widget', $this->plugin_url . 'email-newsletter-files/js/ui.widget.js' );
                wp_enqueue_script( 'jquery_ui_widget' );
    
                //including JS scripts for progressbar
                wp_register_script( 'jquery_progressbar', $this->plugin_url . 'email-newsletter-files/js/jquery.ui.progressbar.js' );
                wp_enqueue_script( 'jquery_progressbar' );}
                add_action('wp_enqueue_scripts', 'enewsletter_enqueue');
            }

    Is that correct?
    Please let me know if there is better solution for this.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.