WP_Scripts::print_inline_script()
Prints inline scripts registered for a specific handle.
Метод класса: WP_Scripts{}
Хуков нет.
Возвращает
Строку|false
. Script on success, false otherwise.
Использование
global $wp_scripts; $wp_scripts->print_inline_script( $handle, $position, $display );
- $handle(строка) (обязательный)
- Name of the script to add the inline script to. Must be lowercase.
- $position(строка)
- Whether to add the inline script before the handle or after.
По умолчанию: 'after' - $display(true|false)
- Whether to print the script instead of just returning it.
По умолчанию: true
Список изменений
С версии 4.5.0 | Введена. |
Код WP_Scripts::print_inline_script() WP Scripts::print inline script WP 6.2.2
public function print_inline_script( $handle, $position = 'after', $display = true ) { $output = $this->get_data( $handle, $position ); if ( empty( $output ) ) { return false; } $output = trim( implode( "\n", $output ), "\n" ); if ( $display ) { printf( "<script%s id='%s-js-%s'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), esc_attr( $position ), $output ); } return $output; }