Enqueue WordPress jQuery after it’s been deregistered by a plugin

I’m looking after a WordPress install that makes use of a plugin that deregisters jQuery and replaces it with it’s own ancient version. I’m aware of why loading your own jQuery is irresponsible and would like to use the version of jQuery bundled with WordPress. I’m currently deregistering the plugin’s version of jQuery and enqueuing the WordPress version. However my approach makes some assumptions about the location and version of jQuery. Is there a better way to do this and ensure things don’t break when WordPress is updated?

wp_deregister_script( 'jquery' );
wp_enqueue_script( 'jquery', '/wp-includes/js/jquery/jquery.js', array(), '1.10.2', false ); 

Related posts

Leave a Reply

1 comment

  1. I think you can just use:

    wp_enqueue_script( 'jquery' );
    

    And WordPress will know to use the included one.

    Edit:

    You can use:

    wp_enqueue_script( 'jquery-core' );
    

    Assuming that hasn’t also been deregistered by another script. I guess this could run the risk of allowing a plugin to register ‘jquery’ and for 2 versions of jquery to be loaded, though. Keep an eye out!