• Hi, I have WordPress 5.2.3 con il tema Impreza Child and when I try to register a member it shows this message: “Il sito sta avendo problemi tecnici. Controlla la casella di posta dell’amministratore del sito per istruzioni.”
    In the mail box there aren’t any messages about that.
    I have enabled debug mode from wp-config.php and when I load the home page it shows the same message three times: “Notice: wp_register_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 /var/www/vhosts/…/…/wp-includes/functions.php on line ….”

    Any suggestions?
    Many thanks for the support

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must create a new function hooked to (usually) ‘wp_enqueue_scripts’ so that it fires at the correct time during the WP page load. Otherwise it will fire before WP is ready and will not work (simplified explanation).

    Here is an example of a custom function (“jquery_manage_scripts()”) hooked to the ‘wp_enqueue_scripts’ WP action hook, which gets rid of the native WP jQuery and loads a newer version from a public (Google) library.

    function jquery_manage_scripts() {
    
        wp_deregister_script( 'jquery' );
        wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js", false, '3.4.1', true);
        wp_enqueue_script( 'jquery' );
    }
    add_action( 'wp_enqueue_scripts', 'jquery_manage_scripts', 99 );

    This code would be added to your (child) theme functions.php file, after you adjust it to suit your needs, more like:

    function impreza_manage_scripts() {
        wp_register_script( 'my-script', 'https://url-to-my-script' );
        wp_enqueue_script( 'my-script' );
    }
    add_action( 'wp_enqueue_scripts', 'impreza_manage_scripts', 99 );

    Hopefully this gives you ideas. Learn More about wp_register_script here.

    Thread Starter albcol

    (@albcol)

    Thanks a lot for your response.
    This is my functions.php code. Where is the error?

    [ 7,169 lines of code deleted ]

    Thanks

    • This reply was modified 6 years, 6 months ago by Jan Dembowski.
    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @albcol Please do not post large code or responses like that here, it doesn’t work after ~10 lines or so.

    If you need share that data please use https://pastebin.com/ instead and post the link to that paste.

    Thread Starter albcol

    (@albcol)

    Thanks a lot for your response.
    I have to do this hook for every call to “wp_register_script” and wp_enqueue_script in all files of my site or only in functions.php?
    Thanks

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

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