WP_Scripts::print_inline_script()publicWP 4.5.0

Устарела с версии 6.3.0. Больше не поддерживается и может быть удалена. Используйте methods get_inline_script_tag() or get_inline_script_data().

Prints inline scripts registered for a specific handle.

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

Хуков нет.

Возвращает

Строку|false. Script data on success, false otherwise.

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

global $wp_scripts;
$wp_scripts->print_inline_script( $handle, $position, $display );
$handle(строка) (обязательный)
Name of the script to print inline scripts for. Must be lowercase.
$position(строка)
Whether to add the inline script before the handle or after.
По умолчанию: 'after'
$display(true|false)
Whether to print the script tag instead of just returning the script data.
По умолчанию: true

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

С версии 4.5.0 Введена.
Устарела с 6.3.0 Use methods get_inline_script_tag() or get_inline_script_data() instead.

Код WP_Scripts::print_inline_script() WP 6.5.2

public function print_inline_script( $handle, $position = 'after', $display = true ) {
	_deprecated_function( __METHOD__, '6.3.0', 'WP_Scripts::get_inline_script_data() or WP_Scripts::get_inline_script_tag()' );

	$output = $this->get_inline_script_data( $handle, $position );
	if ( empty( $output ) ) {
		return false;
	}

	if ( $display ) {
		echo $this->get_inline_script_tag( $handle, $position );
	}
	return $output;
}