• Aaron D. Campbell

    (@aaroncampbell)


    When you enqueue simple-pull-quote.js you should set ‘quicktags’ as a dependency since it needs the ‘edButtons’ variable that is created there. Adding one more parameter with to the call takes care of it:

    function simplePullQuotes() {
    	wp_enqueue_script(
    		'simple-pull-quotes',
    		plugin_dir_url(__FILE__) . 'simple-pull-quote.js',
    		array('quicktags')
    	);
    }

    Without that, the button on the HTML editor doesn’t work if the pull-quote JS is loaded before quicktags. Also, on many pages it causes a JS error which makes the flyout nav not work properly.

    Another suggestion would be to write a function to determine if that JS should be loaded (only needed if there’s an editor to add buttons to). After the Deadline adds a button like you, and it uses a function like this to determine if it should:

    /* Helper used to check if javascript should be added to page. Helps avoid bloat in admin */
    function AtD_should_load_on_page() {
    	global $pagenow, $current_screen;
    
    	$pages = array( 'post.php', 'post-new.php', 'page.php', 'page-new.php', 'admin.php', 'profile.php' );
    
    	if ( in_array( $pagenow, $pages ) ) {
    		if ( isset( $current_screen->post_type ) && $current_screen->post_type ) {
    			return post_type_supports( $current_screen->post_type, 'editor' );
    		}
    		return true;
    	}
    
    	return apply_filters( 'atd_load_scripts', false );
    }

    https://www.ads-software.com/extend/plugins/simple-pull-quote/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘wp_enqueue_script missing dependency’ is closed to new replies.