WP_Scripts::get_inline_script_data()
Gets data for inline scripts registered for a specific handle.
Method of the class: WP_Scripts{}
No Hooks.
Return
String
. Inline script, which may be empty string.
Usage
global $wp_scripts; $wp_scripts->get_inline_script_data( $handle, $position );
- $handle(string) (required)
- Name of the script to get data for. Must be lowercase.
- $position(string)
- Whether to add the inline script before the handle or after.
Default: 'after'
Changelog
Since 6.3.0 | Introduced. |
WP_Scripts::get_inline_script_data() WP Scripts::get inline script data code WP 6.7.2
public function get_inline_script_data( $handle, $position = 'after' ) { $data = $this->get_data( $handle, $position ); if ( empty( $data ) || ! is_array( $data ) ) { return ''; } return trim( implode( "\n", $data ), "\n" ); }