WP_Scripts::print_extra_script │ public │ WP 3.3.0

Prints extra scripts of a registered script.

Метод класса: WP_Scripts{}

Хуков нет.

Возвращает

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

Использование

global $wp_scripts;
$wp_scripts->print_extra_script( $handle, $display );
$handle(строка) (обязательный)
The script's registered handle.
$display(true|false)
Whether to print the extra script instead of just returning it.
По умолчанию: true

Список изменений

С версии 3.3.0 Введена.

Код WP_Scripts::print_extra_script() WP 7.1.2

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

	/*
	 * Do not print a sourceURL comment if concatenation is enabled.
	 *
	 * Extra scripts may be concatenated into a single script.
	 * The line-based sourceURL comments may break concatenated scripts
	 * and do not make sense when multiple scripts are joined together.
	 */
	if ( ! $this->do_concat ) {
		$output .= sprintf(
			"\n//# sourceURL=%s",
			rawurlencode( "{$handle}-js-extra" )
		);
	}

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

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

	return true;
}