WP_Scripts::add_inline_script() – Method | Developer.WordPress.org

Adds extra code to a registered script.

Parameters

$handlestringrequired

Name of the script to add the inline script to.
Must be lowercase.

$datastringrequired

String containing the JavaScript to be added.

$positionstringoptional

Whether to add the inline script before the handle or after. Default 'after'.

Return

bool True on success, false on failure.

Source

public function add_inline_script( $handle, $data, $position = 'after' ) {
	if ( ! $data ) {
		return false;
	}

	if ( 'after' !== $position ) {
		$position = 'before';
	}

	$script   = (array) $this->get_data( $handle, $position );
	$script[] = $data;

	return $this->add_data( $handle, $position, $script );
}

View all references View on Trac View on GitHub

Changelog

VersionDescription
4.5.0Introduced.