0

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.

1
  • Just use wp_enqueue_script( 'jquery-ui-datepicker' ); if it's a core supplied script. You don't need to tell it anything else.
    – Otto
    Aug 25, 2014 at 3:52

1 Answer 1

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.