Question

I have read all the previous posts about this but can't seem to get my head around what is wrong with my code. This is in a plugin that I have written. I thought I had it sorted but looks like I haven't is it the order in which I am calling these?

function gedshow_ajaxurl() {
    echo '<script type="text/javascript">
        var ajaxurl = "' . admin_url('admin-ajax.php') . '";
        </script>';
}
add_action('wp_head', 'gedshow_ajaxurl');

wp_enqueue_script('jquery');
add_action('admin_menu', 'gedshow_setup_menu');

function mw_enqueue_color_picker( $hook_suffix ) {
    // first check that $hook_suffix is appropriate for your admin page
    wp_enqueue_style( 'wp-color-picker' );
    wp_enqueue_script( 'my-script-handle', plugins_url('my-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
}

add_action( 'admin_enqueue_scripts', 'mw_enqueue_color_picker' );

function gedshow_enqueue_styles(){
    $file_url = plugins_url('gedshow.css',__FILE__);
    wp_enqueue_style('sp_stylesheet',$file_url);
}
add_action( 'wp_enqueue_scripts','gedshow_enqueue_styles');
Was it helpful?

Solution

Removing wp_enqueue_script('jquery'); will fix your problem.

Put jquery into deps parameter of wp_enqueue_script function.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top