_wp_scripts_maybe_doing_it_wrong

Helper function to output a _doing_it_wrong message when applicable.

Description

_wp_scripts_maybe_doing_it_wrong( (string) $function ); 

Parameters (1)

0. $function (string)
Function name.

Usage

  1. if ( !function_exists( '_wp_scripts_maybe_doing_it_wrong' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.wp-scripts.php'; 
  3.  
  4. // Function name. 
  5. $function = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _wp_scripts_maybe_doing_it_wrong($function); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.wp-scripts.php  
  1. function _wp_scripts_maybe_doing_it_wrong( $function ) { 
  2. if ( did_action( 'init' ) || did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' ) || did_action( 'login_enqueue_scripts' ) ) { 
  3. return; 
  4.  
  5. _doing_it_wrong( $function, sprintf( 
  6. /** translators: 1: wp_enqueue_scripts, 2: admin_enqueue_scripts, 3: login_enqueue_scripts */ 
  7. __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),  
  8. '<code>wp_enqueue_scripts</code>',  
  9. '<code>admin_enqueue_scripts</code>',  
  10. '<code>login_enqueue_scripts</code>' 
  11. ), '3.3.0' );