WP_Scripts::print_extra_script() public WP 3.3.0
Prints extra scripts of a registered script.
{} Это метод класса: WP_Scripts{}
Хуков нет.
Возвращает
true|false/Строку/null
. Void if no data exists, extra scripts if $echo is true, true otherwise.
Использование
global $wp_scripts; $wp_scripts->print_extra_script( $handle, $echo );
- $handle(строка) (обязательный)
- The script's registered handle.
- $echo(true|false)
- Whether to echo the extra script instead of just returning it.
По умолчанию: true
Список изменений
С версии 3.3.0 | Введена. |
Код WP_Scripts::print_extra_script() WP Scripts::print extra script WP 5.7.1
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;
}