• Resolved stevemullen

    (@stevemullen)


    I am investigating plugins on my site that are not loading scripts and styles correctly. instagram-feed-pro is active on this site.

    My problem is that WP is generating a warning because code (plugins, themes…) are not loading scripts and styles correctly, but the warning is not indicating the offending code:
    [12-Apr-2019 12:57:45 UTC] PHP Notice: wp_register_script was called <strong>incorrectly</strong>. Scripts and styles should not be registered or enqueued until the <code>wp_enqueue_scripts</code>, <code>admin_enqueue_scripts</code>, or <code>login_enqueue_scripts</code> hooks. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.3.0.) in /home/redacted/public_html/wp-includes/functions.php on line 4667

    This plugin appears to call wp_enqueue_script directly in a handful of files. This is not supported and generates PHP warnings. These are the instances I found:

    instagram-feed-pro/sbi-init.php
    ln 21 – wp_enqueue_script is called directly.
    ln 25 – wp_enqueue_style is called directly.

    Thank you

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Craig at Smash Balloon

    (@craig-at-smash-balloon)

    Hey stevemullen,

    Sorry for any confusion! Our plugin works by registering our scripts using the wp_enqueue_script hook as suggested. The plugin only ends up enqueuing the script on pages where the feed is used. That’s what you’re seeing on lines 21 and 25.

    I think this is an accepted way of doing this. I don’t get the same errors and we haven’t had anyone else report this issue. In fact, it looks like the error you pasted refers to wp_register_script specifically.

    Can you try deactivating other plugins to see if it fixes the issue? Does deactivating Instagram Feed fix this?

    – Craig

    Thread Starter stevemullen

    (@stevemullen)

    Ok – thank you

    Plugin Contributor Craig at Smash Balloon

    (@craig-at-smash-balloon)

    No problem! Let me know if you need anything else.

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

The topic ‘PHP Notice: wp_enqueue_script called correctly?’ is closed to new replies.