Automattic\WooCommerce\Blocks\Assets

Api::add_inline_scriptpublicWC 1.0

Adds an inline script, once.

Method of the class: Api{}

No Hooks.

Returns

null. Nothing (null).

Usage

$Api = new Api();
$Api->add_inline_script( $handle, $script );
$handle(string) (required)
Script handle.
$script(string) (required)
Script contents.

Api::add_inline_script() code WC 9.9.5

public function add_inline_script( $handle, $script ) {
	if ( ! empty( $this->inline_scripts[ $handle ] ) && in_array( $script, $this->inline_scripts[ $handle ], true ) ) {
		return;
	}

	wp_add_inline_script( $handle, $script );

	if ( isset( $this->inline_scripts[ $handle ] ) ) {
		$this->inline_scripts[ $handle ][] = $script;
	} else {
		$this->inline_scripts[ $handle ] = array( $script );
	}
}