LLMS_Frontend_Assets::enqueue_inline_script( string $id, string $script, string $where = 'footer', float $priority = 10 )

Enqueue an inline script


Description Description


Parameters Parameters

$id

(string) (Required) unique id for the script, used to prevent duplicates

$script

(string) (Required) JS to enqueue, do not add <script> tags!

$where

(string) (Optional) where to enqueue, in the header or footer

Default value: 'footer'

$priority

(float) (Optional) enqueue priority

Default value: 10


Top ↑

Return Return

(boolean)


Top ↑

Source Source

File: includes/class.llms.frontend.assets.php

	public static function enqueue_inline_script( $id, $script, $where = 'footer', $priority = 10 ) {

		// dupcheck
		if ( self::is_inline_script_enqueued( $id ) ) {
			return false;
		}

		// retrieve the current array of scripts
		$scripts = self::get_inline_scripts( $where );

		$priority = (string) $priority;

		// if something already exist at the priority, increment until we can save it
		while ( isset( $scripts[ $priority ] ) ) {

			$priority = (float) $priority;
			$priority = $priority + 0.01;
			$priority = (string) $priority;

		}

		// add the script to the array
		$scripts[ $priority ] = $script;

		// add it to the array of enqueued scripts
		self::$enqueued_inline_scripts[] = $id;

		ksort( $scripts );

		// save updated array
		self::$inline_scripts[ $where ] = $scripts;

		return true;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.4.1 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: