• Resolved maccast

    (@maccast)


    I’m getting this warning when WP_DEBUG is on:

    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.

    The error is in reference to line 601 of the rssimport.php file.

    Basically the stuff in this block

    if ( is_admin() && FB_RSSI_QUICKTAG ) {
    	if ( version_compare( $GLOBALS['wp_version'], '3.3alpha', '>=' ) ) {
    		$post_page_pages = array('post-new.php', 'post.php', 'page-new.php', 'page.php');
    		if ( in_array( $pagenow, $post_page_pages ) ) {
    			wp_enqueue_script(
    				'rssimport_insert_button',
    				plugin_dir_url( __FILE__) . '/js/quicktag.js',
    				array( 'quicktags' )
    			);
    			add_action( 'admin_print_scripts', 'rssimport_insert_button' );
    		}
    	} else {
    		add_action( 'admin_footer', 'RSSImport_insert_button' );
    	}
    }

    https://www.ads-software.com/plugins/rss-import/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Frank Bueltge

    (@bueltge)

    I will fix this. On my tasks was also the switch to the new possibilities to add quicktags, but not enough time. The source of the plugin is very old, but it works and have no problems. Your hints are welcome.

    Thread Starter maccast

    (@maccast)

    I think for this one they are just saying you need to change the the hook you are using to admin_enqueue_scripts. So I assume you would change:

    add_action( 'admin_print_scripts', 'rssimport_insert_button' );
    to:
    add_action( 'admin_enqueue_scripts', 'rssimport_insert_button' );.

    You may need to also change the call as well:

    add_action( 'admin_footer', 'RSSImport_insert_button' );
    to:
    add_action( 'admin_enqueue_scripts', 'RSSImport_insert_button' );

    It looks like you only want the script running in the admin, right? If you make the hook change you can probably remove the is_admin() clause in your IF statement (if ( is_admin() && FB_RSSI_QUICKTAG ))

    Or were you just looking for suggestions on how to the new possibilities to add quicktags? ??

    Plugin Author Frank Bueltge

    (@bueltge)

    No, the hook is not enough.
    I will control, that the script was only load on the post and page post type. I have change to the hook: admin_print_footer_scripts The best way to print the scripts inside the footer in backend. And also I have the global $pagenow for check the right pages in the backend.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_enqueue_script was called incorrectly’ is closed to new replies.