[wp-trac] [WordPress Trac] #23658: wp_deregister_script('jquery') and wp_enqueue('jquery-ui-dialog') dependancy Issue (using child theme)

WordPress Trac noreply at wordpress.org
Fri Mar 1 19:03:53 UTC 2013


#23658: wp_deregister_script('jquery') and wp_enqueue('jquery-ui-dialog')
dependancy Issue (using child theme)
-----------------------------+--------------------------------
 Reporter:  eliddon          |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  External Libraries
  Version:  3.5.1            |   Severity:  normal
 Keywords:  needs-patch      |
-----------------------------+--------------------------------
 I've created a child theme using Twenty Eleven as the parent theme.  The
 only Customization to the parent theme is as follows:
 {{{
 function load_jquery_from_google() {

         $protocol = ( isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] ==
 'on') ) ? 'https' : 'http';
         $url = $protocol .
 '://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
         wp_deregister_script('jquery');

         if (get_transient('google_jquery') == true) {
                 wp_register_script('jquery', $url, array(), '1.9.1',
 true);
         }
         else {
                 $resp = wp_remote_head($url);
                 if (!is_wp_error($resp) && 200 ==
 $resp['response']['code']) {
                         set_transient('google_jquery', true, 60 * 5);
                         wp_register_script('jquery', $url, array(),
 '1.9.1', true);
                 }
                 else {
                         set_transient('google_jquery', false, 60 * 5);
                         $url = get_template_directory_uri() .
 '/js/jquery-1.9.0.min.js';

                         wp_register_script('jquery', $url, array(),
 '1.9.0', true);
                 }
         }


 }

 add_action('wp_enqueue_scripts','load_jquery_from_google');

 }}}

 Basically just re-registering jquery to load from the Google CDN.  Now in
 my Child theme, I want to load 'jquery-ui-dialog', so I do so as follows:


 {{{
 function public_load_front_end_user_scripts() {
   wp_enqueue_script('jquery-ui-dialog', false, array('jquery','jquery-ui-
 core'), true );
 }

 add_action( 'wp_print_scripts', 'public_load_front_end_user_scripts');
 }}}

 This loads all dependencies, but for some reason it loads jquery after,
 instead of before (even though it still queues up jquery to be loaded).

 I've tried the following with no difference in results:

 1) Use a lower priority value in
 add_action('wp_enqueue_scripts','load_jquery_from_google'); - the results
 moved the jquery script above the navigation.js twenty eleven theme script
 but not above the jquery-ui-dialog script.

 2) I tried explicitly calling wp_enqueue_script('jquery') before
 wp_enqueue_script('jquery-ui-dialog') - did not change results

 3)Tried setting $deps and leaving them blank on the wp_enqueue_script
 ('jquery-ui-dialog') call - did not change results

 4) Tried moving both sets of code to child theme to rule out any issues
 with order of functions loading - no change

 5) Tried running the add_action of load_jquery_from_google in 'init'

 6) Only thing that works, is if I set jquery to load from the HEAD.

 7) I've tried using wp_deregister('jquery-ui-core') and then register it
 again with the proper dependancies, while this works, if it tried to load
 any other jquery-ui-* scripts, I have to manually deregister those and re-
 register in order for it to entirely work.

 I'm assuming if when I run a wp_deregister_script it removes the jquery
 dependency on the jquery-ui-dialog script.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23658>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list