Question

I'm developing a plugin and for that I need jQuery and jQuery datepicker. I's taught that WordPress already enqueued some scripts, and I found 'jquery' and 'jquery-ui-datepicker' there.

Where the datepicker is said to be dependent to jQuery. In that codex page it's also mentioned that, we can call a dependent script like the following:

function my_scripts_method() {
    wp_enqueue_script( 'custom-script', plugins_url( '/js/custom_script.js' , __FILE__ ), array( 'jquery' ) );
}    
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );

I got the point is right for any custom script. But what about the default scripts?
What to put on the source ($src) then?

wp_enqueue_script( 'jquery-ui-datepicker', $src, array( 'jquery' ) );

I can't put a null string ('') or a variable, anything, theoretically, and practically.

Was it helpful?

Solution

You don't have to provide source or dependencies, they're already registered by the script loader with those values, you just need to enqueue the proper handle.

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