WordPress.org

Make WordPress Core

Ticket #9346: print-scripts-footer.diff

File print-scripts-footer.diff, 867 bytes (added by amattie, 9 years ago)

Alternative solution for consideration purposes

  • wp-includes/functions.wp-scripts.php

     
    101101        if ( $src ) {
    102102                $_handle = explode('?', $handle);
    103103                $wp_scripts->add( $_handle[0], $src, $deps, $ver );
    104                 if ( $in_footer )
     104                if ( $in_footer ) {
    105105                        $wp_scripts->add_data( $_handle[0], 'group', 1 );
     106                       
     107                        // when the scripts are actually printed via WP_Scripts->do_item, the handles are added to
     108                        // in_footer[] if the have a group set. if wp_print_scripts has already beed called, do_item
     109                        // won't called on these items and so they won't be displayed in the footer
     110                        if (did_action('wp_print_scripts'))
     111                                $wp_scripts->in_footer[] = $_handle[0];
     112                }
    106113        }
    107114        $wp_scripts->enqueue( $handle );
    108115}