wp_add_inline_script


wp_add_inline_script ( $handle, $data, $position = 'after' )

Parameters:
  • (string) handle Name of the script to add the inline script to.
  • (string) data String containing the JavaScript to be added.
  • (string) position Optional. Whether to add the inline script before the handle or after. Default 'after'.
See:
  • WP_Scripts::add_inline_script()
Returns:
  • (bool) True on success, false on failure.
Defined at:

Description

Adds extra code to a registered script.Code will only be added if the script is already in the queue. Accepts a string `$data` containing the code. If two or more code blocks are added to the same script `$handle`, they will be printed in the order they were added, i.e. the latter added code can redeclare the previous.

Related Functions

wp_add_inline_style, wp_get_inline_script_tag, wp_tinymce_inline_scripts, wp_localize_script, wp_print_inline_script_tag

Top Google Results

User discussions

wpseek mobile