LLMS_Frontend_Assets::enqueue_inline_scripts()

Enqueue inline scripts.


Return Return

(void)


Top ↑

Source Source

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

	 *
	 * @since 4.4.0
	 * @since 7.0.0 Include checkout page script data for AJAX-powered gateways.
	 *
	 * @return void
	 */
	protected static function enqueue_inline_scripts() {

		// Ensure the main llms object exists.
		llms()->assets->enqueue_inline( 'llms-obj', 'window.llms = window.llms || {};', 'footer', 5 );

		// Define inline scripts.
		$scripts = array(
			'llms-ajaxurl'           => 'window.llms.ajaxurl = "' . admin_url( 'admin-ajax.php', is_ssl() ? 'https' : 'http' ) . '";',
			'llms-ajax-nonce'        => 'window.llms.ajax_nonce = "' . wp_create_nonce( LLMS_AJAX::NONCE ) . '";',
			'llms-tracking-settings' => "window.llms.tracking = '" . wp_json_encode( llms()->events()->get_client_settings() ) . "';",
			'llms-LLMS-obj'          => 'window.LLMS = window.LLMS || {};',
			'llms-l10n'              => 'window.LLMS.l10n = window.LLMS.l10n || {}; window.LLMS.l10n.strings = ' . LLMS_L10n::get_js_strings( true ) . ';',
		);

		$checkout_urls = self::get_checkout_urls();
		if ( ! empty( $checkout_urls ) ) {
			$scripts['llms-checkout-urls'] = "window.llms.checkoutUrls = JSON.parse( '" . wp_json_encode( $checkout_urls ) . "' );";
		}



Top ↑

Changelog Changelog

Changelog
Version Description
7.0.0 Include checkout page script data for AJAX-powered gateways.
4.4.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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