WP_Scripts::add_inline_script
Adds extra code to a registered script.
Метод класса: WP_Scripts{}
Хуков нет.
Возвращает
true|false. True on success, false on failure.
Использование
global $wp_scripts; $wp_scripts->add_inline_script( $handle, $data, $position );
- $handle(строка) (обязательный)
- Name of the script to add the inline script to. Must be lowercase.
- $data(строка) (обязательный)
- String containing the JavaScript to be added.
- $position(строка)
- Whether to add the inline script before the handle or after.
По умолчанию: 'after'
Список изменений
| С версии 4.5.0 | Введена. |
Код WP_Scripts::add_inline_script() WP Scripts::add inline script WP 6.9
public function add_inline_script( $handle, $data, $position = 'after' ) {
if ( ! $data ) {
return false;
}
if ( 'after' !== $position ) {
$position = 'before';
}
$script = (array) $this->get_data( $handle, $position );
$script[] = $data;
return $this->add_data( $handle, $position, $script );
}