Languages: English • script is 日本語 (Add your language)
Determine if a script has been registered, enqueued, printed, or is waiting to be printed. Very useful when registering/enqueing scripts in plugins to avoid conflicts with other plugin scripts.
<?php wp_script_is( $handle, $list = 'enqueued' ); ?>
$handle = 'fluidVids.js'; $list = 'enqueued'; if (wp_script_is( $handle, $list )) { return; } else { wp_register_script( 'fluidVids.js', plugin_dir_url(__FILE__).'js/fluidvids.min.js'); wp_enqueue_script( 'fluidVids.js' ); }
This would check if the script named 'fluidVids.js' is enqueued. If it is enqueued, it does nothing. If it is not enqueued, the files are then registered and enqueued.
wp_script_is() is located in wp-includes/functions.wp-scripts.php
.
Enqueue Styles
Enqueue Scripts
Front-End Hooks
Admin Hooks
Login Hooks