_print_scripts()
Prints scripts (internal use only)
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
null. Nothing (null).
Usage
_print_scripts();
Notes
- Global. WP_Scripts.
$wp_scripts - Global. true|false.
$compress_scripts
Changelog
| Since 2.8.0 | Introduced. |
_print_scripts() print scripts code WP 6.9.1
function _print_scripts() {
global $wp_scripts, $compress_scripts;
$zip = $compress_scripts ? 1 : 0;
if ( $zip && defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ) {
$zip = 'gzip';
}
$concat = trim( $wp_scripts->concat, ', ' );
$type_attr = current_theme_supports( 'html5', 'script' ) ? '' : " type='text/javascript'";
if ( $concat ) {
if ( ! empty( $wp_scripts->print_code ) ) {
echo "\n<script{$type_attr}>\n";
echo "/* <![CDATA[ */\n"; // Not needed in HTML 5.
echo $wp_scripts->print_code;
echo sprintf( "\n//# sourceURL=%s\n", rawurlencode( 'js-inline-concat-' . $concat ) );
echo "/* ]]> */\n";
echo "</script>\n";
}
$concat = str_split( $concat, 128 );
$concatenated = '';
foreach ( $concat as $key => $chunk ) {
$concatenated .= "&load%5Bchunk_{$key}%5D={$chunk}";
}
$src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version;
echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n";
}
if ( ! empty( $wp_scripts->print_html ) ) {
echo $wp_scripts->print_html;
}
}