wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_get_inline_script_tag › WordPress Function
Since5.7.0
Deprecatedn/a
› wp_get_inline_script_tag ( $javascript, $attributes = array() )
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: |
Wraps inline JavaScript in `<script>` tag.
It is possible to inject attributes in the<script>
tag via the {@see 'wp_script_attributes'} filter.
Automatically injects type attribute if needed.Related Functions: wp_print_inline_script_tag, wp_get_script_tag, wp_add_inline_script, wp_print_script_tag, wp_tinymce_inline_scripts
Source
function wp_get_inline_script_tag( $javascript, $attributes = array() ) { if ( ! isset( $attributes['type'] ) && ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) { $attributes['type'] = 'text/javascript'; } /** * Filters attributes to be added to a script tag. * * @since 5.7.0 * * @param array $attributes Key-value pairs representing `<script>` tag attributes. * Only the attribute name is added to the `<script>` tag for * entries with a boolean value, and that are true. * @param string $javascript Inline JavaScript code. */ $attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $javascript ); $javascript = "\n" . trim( $javascript, "\n\r " ) . "\n"; return sprintf( "<script%s>%s</script>\n", wp_sanitize_script_attributes( $attributes ), $javascript ); }