Action hook 'wp_print_scripts'

in WP Core File wp-includes/script-loader.php at line 2251

View Source

wp_print_scripts

Action Hook
Description
Prints the script queue in the HTML head on the front end. Postpones the scripts that were queued for the footer. wp_print_footer_scripts() is called in the footer to print these scripts.

Hook Information

File Location wp-includes/script-loader.php View on GitHub
Hook Type Action
Line Number 2251

Hook Parameters

This hook doesn't accept any parameters.

Usage Examples

Basic Usage
<?php
// Hook into wp_print_scripts
add_action('wp_print_scripts', 'my_custom_function');

function my_custom_function() {
    // Your custom code here
}

Source Code Context

wp-includes/script-loader.php:2251 - How this hook is used in WordPress core
<?php
2246  function wp_print_head_scripts() {
2247  	global $wp_scripts;
2248  
2249  	if ( ! did_action( 'wp_print_scripts' ) ) {
2250  		/** This action is documented in wp-includes/functions.wp-scripts.php */
2251  		do_action( 'wp_print_scripts' );
2252  	}
2253  
2254  	if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
2255  		return array(); // No need to run if nothing is queued.
2256  	}

PHP Documentation

<?php
/**
 * Prints the script queue in the HTML head on the front end.
 *
 * Postpones the scripts that were queued for the footer.
 * wp_print_footer_scripts() is called in the footer to print these scripts.
 *
 * @since 2.8.0
 *
 * @global WP_Scripts $wp_scripts
 *
 * @return string[] Handles of the scripts that were printed.
 */
Quick Info
  • Hook Type: Action
  • Parameters: 0
  • File: wp-includes/script-loader.php
Related Hooks

Related hooks will be displayed here in future updates.