LLMS_Admin_Assets::admin_print_scripts()
Initialize the “llms” object for other scripts to hook into
Return Return
(void)
Source Source
File: includes/admin/class.llms.admin.assets.php
/**
* Initialize the "llms" object for other scripts to hook into
*
* @since 1.0.0
* @since 3.7.5 Unknown.
* @since 4.4.0 Add `ajax_nonce`.
* @since 4.5.1 Add an analytics localization object.
* @since 5.0.0 Output Form location information as a window variable for block editor utilization.
* @since 5.9.0 Use `wp_slash()` after `wp_json_encode()` to prevent issues encountered when strings contain single quotes.
* @since 7.1.1 Add `home_url`.
*
* @return void
*/
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.home_url = "' . esc_url( home_url() ) . '";
window.llms.post = ' . wp_json_encode( $postdata ) . ';
window.llms.analytics = ' . wp_json_encode( $this->get_analytics_options() ) . ';
</script>
';
Expand full source code Collapse full source code View on GitHub
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. |