Reference › WP_Scripts WP_Scripts::add_inline_script ( string $handle , string $data , string $position = 'after' ): bool
Since 4.5.0
Source wp-includes/class-wp-scripts.php:519Parameters Return Uses Source History Adds extra code to a registered script.
Parameters
$handlestring Name of the script to add the inline script to. Must be lowercase.
$datastring String containing the JavaScript to be added.
$positionstring optional Whether to add the inline script before the handle or after. Default 'after'.Default: 'after' Return
bool True on success, false on failure. Uses · 2 WP_Scripts::get_data() WP_Scripts::add_data() This overrides the add_data method from WP_Dependencies, to support normalizing of $args. Source View on Trac ↗ View on GitHub ↗
519 public function add_inline_script ( $handle , $data , $position = 'after' ) { 520 if ( ! $data ) { 521 return false ; 522 } 523 524 if ( 'after' !== $position ) { 525 $position = 'before' ; 526 } 527 528 $script = ( array ) $this -> get_data ( $handle , $position ) ; 529 $script [ ] = $data ; 530 531 return $this -> add_data ( $handle , $position , $script ) ; 532 } History Introduced in 4.5.0 . Unchanged from 6.7.7 through 7.1.0.
6.7.7 6.8.8 6.9.7 7.0.4 7.1.0 Signature, return type and hooks compared across 5 parsed releases.
About this page Parsed data Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/class-wp-scripts.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. Corrections Something wrong on this page? Report it and it gets fixed in the next regeneration.