wpgmap_api_key . '&libraries=places&language=' . $srm_gmap_lng . '®ion=' . $srm_gmap_region, array('jquery')); $custom_js_scripts = get_option('wpgmap_s_custom_js'); if (strlen($custom_js_scripts) != 0) { wp_add_inline_script('srm_gmap_api', "$custom_js_scripts"); } wp_enqueue_style('wp-gmap-embed-front-css', plugins_url('../../assets/css/front_custom_style.css', __FILE__), array(), filemtime(__DIR__ . '/../../assets/css/front_custom_style.css')); $custom_css_styles = get_option('wpgmap_s_custom_css'); if (strlen($custom_css_styles) != 0) { wp_add_inline_style('wp-gmap-embed-front-css', "$custom_css_styles"); } } /** * To enqueue scripts for admin-panel */ function enqueue_admin_gmap_scripts() { global $pagenow; if ($pagenow == 'post.php' || $pagenow == 'post-new.php' || (isset($_GET['page']) and ($_GET['page'] == 'wpgmapembed' or $_GET['page'] == 'wgm_setup_wizard'))) { $srm_gmap_lng = get_option('srm_gmap_lng', 'en'); $srm_gmap_region = get_option('srm_gmap_region', 'US'); wp_enqueue_script('wp-gmap-api', 'https://maps.google.com/maps/api/js?key=' . $this->wpgmap_api_key . '&libraries=places&language=' . $srm_gmap_lng . '®ion=' . $srm_gmap_region, array('jquery'), '20200506', true); wp_enqueue_script('wp-gmap-custom-js', plugins_url('../../assets/js/custom.js', __FILE__), array('wp-gmap-api'), filemtime(__DIR__ . '/../../assets/js/custom.js'), false); wp_enqueue_style('wp-gmap-embed-css', plugins_url('../../assets/css/wp-gmap-style.css', __FILE__), array(), filemtime(__DIR__ . '/../../assets/css/wp-gmap-style.css')); //Setup Wizard related assets wp_enqueue_style('wp-gmap-setup-wizard-css', plugins_url('../../assets/admin/css/setup_wizard.css', __FILE__), array(), filemtime(__DIR__ . '/../../assets/admin/css/setup_wizard.css')); wp_enqueue_style('wp-gmap-fontawasome-css', plugins_url('../../assets/admin/third-party/font-awesome/css/font-awesome.css', __FILE__), array(), filemtime(__DIR__ . '/../../assets/admin/third-party/font-awesome/css/font-awesome.css')); wp_enqueue_style('wp-gmap-sweetalert2-css', plugins_url('../../assets/admin/third-party/sweetalert2/css/sweetalert2.min.css', __FILE__), array(), filemtime(__DIR__ . '/../../assets/admin/third-party/sweetalert2/css/sweetalert2.min.css')); wp_enqueue_script('wp-gmap-sweetalert2-js', plugins_url('../../assets/admin/third-party/sweetalert2/js/sweetalert2.min.js', __FILE__), array(), filemtime(__DIR__ . '/../../assets/admin/third-party/sweetalert2/js/sweetalert2.min.js'), true); wp_enqueue_script('wp-gmap-setup-wizard-js', plugins_url('../../assets/admin/js/setup_wizard.js', __FILE__), array(), filemtime(__DIR__ . '/../../assets/admin/js/setup_wizard.js'), true); // Setup wizard validation data $wpgmap_setup_validation_data = array( 'apikey' => __('Please enter a valid API key', 'gmap-embed'), 'language' => __('Please select a language', 'gmap-embed'), 'regionalarea' => __('Please select a regional area', 'gmap-embed'), 'licencekey' => __('Invalid license key', 'gmap-embed'), 'success' => __('Successfully installed.', 'gmap-embed'), 'failed_to_finish' => __('Something went wrong, please reload and try again', 'gmap-embed') ); // Setup wizard get api key modal content $wpgmap_setup_api_key_modal_data = array( 'faq_title' => __('Documentation', 'gmap-embed'), 'faq_item_title' => __(' Click here to see documentation on how to get API key', 'gmap-embed'), 'faq_item_url' => esc_url('https://srmilon.info/2021/05/08/wp-google-map-installation-wizard?utm_source=wp_admin&utm_medium=setup_wizard&utm_campaign=setup_wizard_faq'), 'video_title' => __('Video Tutorial', 'gmap-embed'), 'video_url' => esc_url('//www.youtube.com/embed/m-jAsxG0zuk'), 'api_key_title' => __('Get API Key', 'gmap-embed'), 'api_key_url' => esc_url('//console.developers.google.com/flows/enableapi?apiid=maps_backend,places_backend,geolocation,geocoding_backend,directions_backend&keyType=CLIENT_SIDE&reusekey=true'), ); //what we collect modal content $wgm_wwc_msg = array( 'title' => __('What we collect?', 'gmap-embed'), 'desc' => __('We collect non-sensitive diagnostic data and plugin usage information. Your site URL, WordPress & PHP version, plugins & themes and email address to send you the discount coupon. This data lets us make sure this plugin always stays compatible with the most popular plugins and themes. No spam, we promise.', 'gmap-embed') ); $wgm_setup_wizard_localized = array( 'setup_validation_msg' => $wpgmap_setup_validation_data, 'site_url' => site_url(), 'setup_api_key_modal' => $wpgmap_setup_api_key_modal_data, 'wgm_wwc_msg' => $wgm_wwc_msg ); wp_localize_script('wp-gmap-setup-wizard-js', 'wgm_setup_wizard', $wgm_setup_wizard_localized); // For media upload wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_enqueue_script('wpgmap-media-upload'); wp_enqueue_style('thickbox'); if (isset($_GET['tag']) and $_GET['tag'] == 'edit') { // enqueue scripts for localization wp_register_script('wp-gmap-lz-script', plugins_url('../../assets/js/localized_script.js', __FILE__), array('wp-gmap-custom-js'), filemtime(__DIR__ . '/../../assets/js/localized_script.js'), true); // Localize the script with new data $current_map_marker_lat_lng = explode(',', get_post_meta($_GET['id'], 'wpgmap_latlng', true)); $current_map_marker_lat = isset($current_map_marker_lat_lng[0]) ? $current_map_marker_lat_lng[0] : 40.73359922990751; $current_map_marker_lng = isset($current_map_marker_lat_lng[1]) ? $current_map_marker_lat_lng[1] : -74.02791395625002; $translation_array = array( 'current_map_marker_lat' => $current_map_marker_lat, 'current_map_marker_lng' => $current_map_marker_lng ); wp_localize_script('wp-gmap-lz-script', 'gmap_object', $translation_array); // Enqueued script with localized data. wp_enqueue_script('wp-gmap-lz-script'); } } } }