W3cubDocs

/WordPress

WP_Scripts::print_extra_script( string $handle, bool $display = true ): bool|string|void

Prints extra scripts of a registered script.

Parameters

$handlestringrequired
The script’s registered handle.
$displaybooloptional
Whether to print the extra script instead of just returning it.

Default:true

Return

bool|string|void Void if no data exists, extra scripts if $display is true, true otherwise.

Source

public function print_extra_script( $handle, $display = true ) {
	$output = $this->get_data( $handle, 'data' );
	if ( ! $output ) {
		return;
	}

	if ( ! $display ) {
		return $output;
	}

	wp_print_inline_script_tag( $output, array( 'id' => "{$handle}-js-extra" ) );

	return true;
}

Changelog

Version Description
3.3.0 Introduced.

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