[wp-trac] [WordPress Trac] #8884: Bug In wp_enqueue_script() In Footer

WordPress Trac wp-trac at lists.automattic.com
Mon Jan 19 08:31:02 GMT 2009


#8884: Bug In wp_enqueue_script() In Footer
--------------------------+-------------------------------------------------
 Reporter:  GamerZ        |       Owner:  azaozz
     Type:  defect (bug)  |      Status:  new   
 Priority:  high          |   Milestone:  2.8   
Component:  JavaScript    |     Version:  2.8   
 Severity:  normal        |    Keywords:        
--------------------------+-------------------------------------------------
 I saw Andrew Ozz committing the patch to allow plugin authors to plugin
 their JS into the footer using wp_enqueue_script(). The script works in
 WP-Admin but when in the client side view, it works a little weird.
 {{{
 #!php
 add_action('admin_print_scripts-wp-polls/polls-manager.php',
 'poll_javascripts_admin');
 function poll_javascripts_admin() {
         wp_enqueue_script('wp-polls-admin', plugins_url('wp-polls/polls-
 admin-js.js'), array('jquery'), '2.50', true);
 }
 }}}
 The above code works perfect, with the last argument of
 wp_enqueue_script() set to true means print in the footer.

 Now lets move onto the client side.
 {{{
 #!php
 add_action('wp_print_scripts', 'poll_javascripts');
 function poll_javascripts() {
         wp_enqueue_script('wp-polls', plugins_url('wp-polls/polls-js.js'),
 array('jquery'), '2.50', true);
 }
 }}}
 The above code is similar to that of the WP-Admin side with the last
 argument of wp_enqueue_script() set to true means print in the footer.

 There is 2 problem with the code above.

 1. It will print in the footer of WP-Admin as well even though the hook is
 for "wp_print_scripts" and not "admin_print_scripts".

 2. In the client side, instead of printing it in the footer, it prints in
 the header.

 I am using the default theme and hence there is a <?php wp_footer(); ?> in
 footer.php

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


More information about the wp-trac mailing list