• Hi

    Thank you for creating this plugin; it looks like it will be a great way for sites to hook their AWIN site codes in easily ??

    I’ve just activated this plugin on a new site (current stable version of WordPress 5.6); and receive the following Notice level error from PHP:

    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 login_enqueue_scripts hooks. This notice was triggered by the convert-a-link handle. Please see Debugging in WordPress for more information. (This message was added in version 3.3.0.) in /wordpress/wp-includes/functions.php on line 5229

    …while the script still appears in the source code, and I can see the AWIN variable being generated; it’s clagging up the debugging logs.

    The issue appears to be a result of calling wp_enqueue_scripts procedurally, outside of a hooked function in plugins/convert-a-link/convert-a-link.php line 29; and could be resolved by changing:

    
    $publisherId = get_option('cal_publisherId');
    wp_enqueue_script('convert-a-link', 'https://www.dwin2.com/pub.'. $publisherId .'.min.js', array(), false, true);
    

    to

    
    function convert_a_link_scripts() {
        $publisherId = get_option('cal_publisherId');
        wp_enqueue_script('convert-a-link', 'https://www.dwin2.com/pub.'. $publisherId .'.min.js', array(), false, true);
    }
    add_action('wp_enqueue_scripts','convert_a_link_scripts');
    

    Thanks in advance ??

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