PUM_Site_Assets::localize_scripts()

Localize scripts if enqueued.


Description Description


Source Source

File: classes/Site/Assets.php

	public static function localize_scripts() {
		$site_home_path = parse_url( home_url() );
		$site_home_path = isset( $site_home_path['path'] ) ? $site_home_path['path'] : '/';

		wp_localize_script( 'popup-maker-site', 'pum_vars', apply_filters( 'pum_vars', array(
			'version'                => Popup_Maker::$VER,
			'pm_dir_url'             => Popup_Maker::$URL,
			'ajaxurl'                => admin_url( 'admin-ajax.php' ),
			'restapi'                => function_exists( 'rest_url' ) ? esc_url_raw( rest_url( 'pum/v1' ) ) : false,
			'rest_nonce'             => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : null,
			'default_theme'          => (string) pum_get_default_theme_id(),
			'debug_mode'             => Popup_Maker::debug_mode(),
			'disable_tracking'       => popmake_get_option( 'disable_popup_open_tracking' ),
			'home_url'               => trailingslashit( $site_home_path ),
			'message_position'       => 'top',
			'core_sub_forms_enabled' => ! PUM_Newsletters::$disabled,
			'popups'                 => array(),
		) ) );

		if ( Popup_Maker::debug_mode() || isset( $_GET['pum_debug'] ) ) {
			wp_localize_script( 'popup-maker-site', 'pum_debug_vars', apply_filters( 'pum_debug_vars', array(
				'debug_mode_enabled'    => __( 'Popup Maker', 'popup-maker' ) . ': ' . __( 'Debug Mode Enabled', 'popup-maker' ),
				'debug_started_at'      => __( 'Debug started at:', 'popup-maker' ),
				'debug_more_info'       => sprintf( __( 'For more information on how to use this information visit %s', 'popup-maker' ), 'https://docs.wppopupmaker.com/?utm_medium=js-debug-info&utm_campaign=contextual-help&utm_source=browser-console&utm_content=more-info' ),
				'global_info'           => __( 'Global Information', 'popup-maker' ),
				'localized_vars'        => __( 'Localized variables', 'popup-maker' ),
				'popups_initializing'   => __( 'Popups Initializing', 'popup-maker' ),
				'popups_initialized'    => __( 'Popups Initialized', 'popup-maker' ),
				'single_popup_label'    => __( 'Popup: #', 'popup-maker' ),
				'theme_id'              => __( 'Theme ID: ', 'popup-maker' ),
				'label_method_call'     => __( 'Method Call:', 'popup-maker' ),
				'label_method_args'     => __( 'Method Arguments:', 'popup-maker' ),
				'label_popup_settings'  => __( 'Settings', 'popup-maker' ),
				'label_triggers'        => __( 'Triggers', 'popup-maker' ),
				'label_cookies'         => __( 'Cookies', 'popup-maker' ),
				'label_delay'           => __( 'Delay:', 'popup-maker' ),
				'label_conditions'      => __( 'Conditions', 'popup-maker' ),
				'label_cookie'          => __( 'Cookie:', 'popup-maker' ),
				'label_settings'        => __( 'Settings:', 'popup-maker' ),
				'label_selector'        => __( 'Selector:', 'popup-maker' ),
				'label_mobile_disabled' => __( 'Mobile Disabled:', 'popup-maker' ),
				'label_tablet_disabled' => __( 'Tablet Disabled:', 'popup-maker' ),
				'label_event'           => __( 'Event: %s', 'popup-maker' ),
				'triggers'              => PUM_Triggers::instance()->dropdown_list(),
				'cookies'               => PUM_Cookies::instance()->dropdown_list(),
			) ) );
		}

		/* Here for backward compatibility. */
		wp_localize_script( 'popup-maker-site', 'pum_sub_vars', array(
			'ajaxurl'          => admin_url( 'admin-ajax.php' ),
			'message_position' => 'top',
		) );
	}


Top ↑

User Contributed Notes User Contributed Notes

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