Adds extra code to a registered script.
Parameters
$handle
stringrequired- Name of the script to add the inline script to.
Must be lowercase. $data
stringrequired- String containing the JavaScript to be added.
$position
stringoptional- Whether to add the inline script before the handle or after. Default
'after'
.Default:
'after'
Source
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 );
}
Changelog
Version | Description |
---|---|
4.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.