Add the ability to print data *after* a script, whether it is concatenated or not:

* Add a third argument to `WP_Scripts->print_extra_script()`, `$key`, which will be passed to `->get_data()` (no longer passes hardcoded `'data'`)
* When `$key` is set to `'data-after'`, the inline script will be printed after the `<script>` tag. If the scripts are being concatenated, all scripts' `'data-after'` data will be printed after the concatenated `<script>` has been rendered.

Props hakre, wonderboymusic.
Fixes #25277.


git-svn-id: https://develop.svn.wordpress.org/trunk@31032 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-01-03 05:07:15 +00:00
parent d699ce8b13
commit c21e4f95ce
2 changed files with 24 additions and 4 deletions

View File

@@ -857,8 +857,21 @@ function _print_scripts() {
echo "<script type='text/javascript' src='" . esc_attr($src) . "'></script>\n";
}
if ( !empty($wp_scripts->print_html) )
if ( ! empty( $wp_scripts->print_html ) ) {
echo $wp_scripts->print_html;
}
if ( ! empty( $wp_scripts->print_after_html ) ) {
if ( $wp_scripts->do_concat ) {
echo "<script type='text/javascript'>\n";
echo "/* <![CDATA[ */\n"; // not needed in HTML 5
echo trim( $wp_scripts->print_after_html ) . "\n";
echo "/* ]]> */\n";
echo "</script>\n";
} else {
echo $wp_scripts->print_after_html;
}
}
}
/**