Reputation: 7328
I'm developing a plugin for WordPress. For the settings page of the plugin, is it safe to assume that jQuery will be provided. This, indeed, seems to be the case for 4.0.1 but I want to know if there's any data on what version of jQuery different versions of WordPress include, etc.
Thanks.
Upvotes: 1
Views: 134
Reputation: 6828
It is safe to assume jQuery will be available on a normal plugin settings page. To be 100% sure your script can rely on jQuery, you can specify array( 'jquery' )
for the $deps
param of wp_enqueue_script()
, e.g.:
wp_enqueue_script(
'myscript',
plugins_url( '/js/myscript.js' , __FILE__ ),
array( 'jquery' )
);
There's no need to enqueue jQuery separately if you specify it as a dependency, WP will enqueue the required script(s) automatically.
An unofficial list of jQuery versions included in WP can be found here.
Upvotes: 0
Reputation: 1517
You can use this to enqueue jQuery on an admin page
function your_plugin_init() {
wp_enqueue_script( 'jquery');
}
add_action('admin_init', 'your_plugin_init');
Please be aware that the bundled version will load jQuery in no conflict mode.
This list the jQuery versions included in each WordPress version http://plugins.twinpictures.de/wordpress-jquery-versions/
Upvotes: 2