WP_Scripts::print_extra_script

Advertisement

Summery Summery

Prints extra scripts of a registered script.

Syntax Syntax

WP_Scripts::print_extra_script( string $handle, bool $echo = true )

Parameters Parameters

$handle

(string) (Required) The script's registered handle.

$echo

(bool) (Optional) Whether to echo the extra script instead of just returning it.

Default value: true

Return Return

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

Source Source

File: wp-includes/class.wp-scripts.php

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

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

		printf( "<script%s id='%s-js-extra'>\n", $this->type_attr, esc_attr( $handle ) );

		// CDATA is not needed for HTML 5.
		if ( $this->type_attr ) {
			echo "/* <![CDATA[ */\n";
		}

		echo "$output\n";

		if ( $this->type_attr ) {
			echo "/* ]]> */\n";
		}

		echo "</script>\n";

		return true;
	}

Advertisement

Changelog Changelog

Changelog
Version Description
3.3.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.