WP_Scripts::get_inline_script_tag
Gets tags for inline scripts registered for a specific handle.
Method of the class: WP_Scripts{}
No Hooks.
Returns
String. Inline script, which may be empty string.
Usage
global $wp_scripts; $wp_scripts->get_inline_script_tag( $handle, $position );
- $handle(string) (required)
- Name of the script to get associated inline script tag for. Must be lowercase.
- $position(string)
- Whether to get tag for inline scripts in the before or after position.
Default:'after'
Changelog
| Since 6.3.0 | Introduced. |
WP_Scripts::get_inline_script_tag() WP Scripts::get inline script tag code WP 6.9.1
public function get_inline_script_tag( $handle, $position = 'after' ) {
$js = $this->get_inline_script_data( $handle, $position );
if ( empty( $js ) ) {
return '';
}
$id = "{$handle}-js-{$position}";
return wp_get_inline_script_tag( $js, compact( 'id' ) );
}