wppaste
WordPress

WP_Scripts::add_inline_script( string $handle, string $data, string $position = 'after' ): bool

Since
4.5.0
Source
wp-includes/class-wp-scripts.php:464
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.
$positionstringoptional
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

	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 );	}

History

Introduced in 4.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 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.