LLMS_Admin_Assets::admin_print_scripts()

Initialize the “llms” object for other scripts to hook into


Return Return

(void)


Top ↑

Source Source

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

	public function admin_print_scripts() {

		$screen = get_current_screen();

		global $post;

		$postdata = array();

		if ( ! empty( $post ) ) {

			$postdata = array(
				'id'        => $post->ID,
				'post_type' => $post->post_type,
			);

		}

		echo '
			<script type="text/javascript">
				window.llms = window.llms || {};
				window.llms.ajax_nonce = "' . wp_create_nonce( LLMS_AJAX::NONCE ) . '";
				window.llms.admin_url = "' . admin_url() . '";
				window.llms.post = ' . json_encode( $postdata ) . ';
				window.llms.analytics = ' . json_encode( $this->get_analytics_options() ) . ';
			</script>
		';

		echo '<script type="text/javascript">window.LLMS = window.LLMS || {};</script>';
		echo '<script type="text/javascript">window.LLMS.l10n = window.LLMS.l10n || {}; window.LLMS.l10n.strings = ' . LLMS_L10n::get_js_strings( true ) . ';</script>';

		$forms = LLMS_Forms::instance()->get_post_type();

		if ( $forms === $screen->id ) {
			echo "<script>window.llms.formLocations = JSON.parse( '" . wp_slash( wp_json_encode( LLMS_Forms::instance()->get_locations() ) ) . "' );</script>";
		}

		if ( ! empty( $screen->is_block_editor ) || 'customize' === $screen->base ) {
			echo "<script>window.llms.userInfoFields = JSON.parse( '" . wp_slash( wp_json_encode( llms_get_user_information_fields_for_editor() ) ) . "' );</script>";
		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.9.0 Use wp_slash() after wp_json_encode() to prevent issues encountered when strings contain single quotes.
5.0.0 Output Form location information as a window variable for block editor utilization.
4.5.1 Add an analytics localization object.
4.4.0 Add ajax_nonce.
3.7.5 Unknown.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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