WP_Scripts::get_inline_script_tag()publicWP 6.3.0

Gets tags for inline scripts registered for a specific handle.

Method of the class: WP_Scripts{}

No Hooks.

Return

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() code WP 6.6

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' ) );
}