W3cubDocs

/WordPress

WP_Scripts::get_inline_script_data( string $handle, string $position = ‘after’ ): string

Gets data for inline scripts registered for a specific handle.

Parameters

$handlestringrequired
Name of the script to get data for.
Must be lowercase.
$positionstringoptional
Whether to add the inline script before the handle or after. Default 'after'.

Default:'after'

Return

string Inline script, which may be empty string.

Source

public function get_inline_script_data( $handle, $position = 'after' ) {
	$data = $this->get_data( $handle, $position );
	if ( empty( $data ) || ! is_array( $data ) ) {
		return '';
	}

	return trim( implode( "\n", $data ), "\n" );
}

Changelog

Version Description
6.3.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_scripts/get_inline_script_data