PluginProbe
Maps Plugin using Google Maps for WordPress – WP Google Map / trunk
Maps Plugin using Google Maps for WordPress – WP Google Map vtrunk
1.9.7 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 All 96 releases
gmap-embed / includes / traits / AssetHandler.php

AssetHandler.php in Maps Plugin using Google Maps for WordPress – WP Google Map trunk, at includes/traits/AssetHandler.php

421 lines 23.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WGMSRM\Traits;
4
5 if (!defined('ABSPATH')) {
6 exit;
7 }
8
9 /**
10 * Trait AssetHandler: enqueue, dequeue assets
11 */
12 trait AssetHandler
13 {
14
15
16 /**
17 * @return array
18 */
19 public function getLocalizedScripts()
20 {
21 // Setup wizard validation data
22 $wpgmap_setup_validation_data = array(
23 'apikey' => __('Please enter a valid API key', 'gmap-embed'),
24 'language' => __('Please select a language', 'gmap-embed'),
25 'regionalarea' => __('Please select a regional area', 'gmap-embed'),
26 'licencekey' => __('Invalid license key', 'gmap-embed'),
27 'success' => __('Successfully installed.', 'gmap-embed'),
28 'failed_to_finish' => __('Something went wrong, please reload and try again', 'gmap-embed'),
29 );
30
31 // Setup wizard get api key modal content
32 $wpgmap_setup_api_key_modal_data = array(
33 'faq_title' => __('Help Manual', 'gmap-embed'),
34 'faq_item_title' => __(' Click here to see Help Manual on how to get API key', 'gmap-embed'),
35 'faq_item_url' => esc_url('https://wpgooglemap.com/documentation/wp-google-map-quick-installation?utm_source=gmap-embed&utm_medium=wordpress-plugin&utm_campaign=documentation&utm_content=setup-wizard-faq-link'),
36 'video_title' => __('Video Tutorial', 'gmap-embed'),
37 'video_url' => esc_url('//www.youtube.com/embed/1G2VksP-uX0'),
38 'api_key_title' => __('Get API Key', 'gmap-embed'),
39 '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'),
40 );
41
42 // what we collect modal content
43 $wgm_wwc_msg = array(
44 'title' => __('What we collect?', 'gmap-embed'),
45 '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'),
46 );
47 $wgm_admin_locales = array(
48 'dt' => array(
49 'no_map_created' => __('No map created yet, please click on Add New to create your map.', 'gmap-embed'),
50 'no_marker_created' => __('No marker created yet.', 'gmap-embed'),
51 ),
52 'sweet_alert' => array(
53 'oops' => __('Opps...', 'gmap-embed'),
54 // translators: %s: Premium version URL.
55 'notice_unlimited_maps' => sprintf(__('You need to upgrade to the <a target="_blank" href="%s">Premium</a> Version to create <b>Unlimited Maps</b>.', 'gmap-embed'), esc_url('https://wpgooglemap.com/pricing?utm_source=gmap-embed&utm_medium=wordpress-plugin&utm_campaign=upgrade-to-pro&utm_content=limit-maps-lock')),
56 // translators: %s: Premium version URL.
57 'notice_unlimited_marker' => sprintf(__('You need to upgrade to the <a target="_blank" href="%s">Premium</a> Version to create <b>Unlimited Markers</b>.', 'gmap-embed'), esc_url('https://wpgooglemap.com/pricing?utm_source=gmap-embed&utm_medium=wordpress-plugin&utm_campaign=upgrade-to-pro&utm_content=limit-markers-lock')),
58 // translators: %s: Premium version URL.
59 'notice_to_use_feature' => sprintf(__('You need to upgrade to the <a target="_blank" href="%s">Premium</a> Version to use <b>this feature</b>.', 'gmap-embed'), esc_url('https://wpgooglemap.com/pricing?utm_source=gmap-embed&utm_medium=wordpress-plugin&utm_campaign=upgrade-to-pro&utm_content=generic-feature-lock')),
60 ),
61 );
62
63 $wgm_localized = array(
64 // Common data
65 'api_key' => $this->config->get_api_key(),
66 'is_premium_user' => $this->config->is_premium(),
67 'get_p_v_url' => esc_url('https://wpgooglemap.com/pricing?utm_source=gmap-embed&utm_medium=wordpress-plugin&utm_campaign=upgrade-to-pro&utm_content=premium-feature-lock-js'),
68 'site_url' => site_url(),
69 'setup_wizard' => array(
70 'setup_validation_msg' => $wpgmap_setup_validation_data,
71 'setup_api_key_modal' => $wpgmap_setup_api_key_modal_data,
72 'wgm_wwc_msg' => $wgm_wwc_msg,
73 ),
74 'plugin_url' => WGM_PLUGIN_URL,
75 'locales' => $wgm_admin_locales,
76 'wgm_ajax_nonce' => wp_create_nonce('wgm_ajax_req'),
77 'wgm_map_create_nonce' => wp_create_nonce('wgm_create_map'),
78 'wgm_marker_nonce' => wp_create_nonce('wgm_create_marker'),
79 'wgm_preview_nonce' => wp_create_nonce('wgm_preview_map'),
80 'wgm_sw_nonce' => wp_create_nonce('wgm_setup_wizard'),
81 'nonces' => [
82 'wpgmapembed_save_map_data' => wp_create_nonce('wpgmapembed_save_map_data'),
83 'wpgmapembed_load_map_data' => wp_create_nonce('wpgmapembed_load_map_data'),
84 'wpgmapembed_popup_load_map_data' => wp_create_nonce('wpgmapembed_popup_load_map_data'),
85 'wpgmapembed_get_wpgmap_data' => wp_create_nonce('wpgmapembed_get_wpgmap_data'),
86 'wpgmapembed_remove_wpgmap' => wp_create_nonce('wpgmapembed_remove_wpgmap'),
87 'wpgmapembed_save_setup_wizard' => wp_create_nonce('wpgmapembed_save_setup_wizard'),
88 'wgm_get_all_maps' => wp_create_nonce('wgm_get_all_maps'),
89 'wpgmapembed_save_map_markers' => wp_create_nonce('wpgmapembed_save_map_markers'),
90 'wpgmapembed_update_map_markers' => wp_create_nonce('wpgmapembed_update_map_markers'),
91 'wpgmapembed_get_marker_icons' => wp_create_nonce('wpgmapembed_get_marker_icons'),
92 'wpgmapembed_save_marker_icon' => wp_create_nonce('wpgmapembed_save_marker_icon'),
93 'wpgmapembed_get_markers_by_map_id' => wp_create_nonce('wpgmapembed_get_markers_by_map_id'),
94 'wpgmapembed_p_get_markers_by_map_id' => wp_create_nonce('wpgmapembed_p_get_markers_by_map_id'),
95 'wgm_get_markers_by_map_id' => wp_create_nonce('wgm_get_markers_by_map_id'),
96 'wpgmapembed_delete_marker' => wp_create_nonce('wpgmapembed_delete_marker'),
97 'wpgmapembed_clone_map' => wp_create_nonce('wpgmapembed_clone_map'),
98 'wpgmapembed_clone_marker' => wp_create_nonce('wpgmapembed_clone_marker'),
99 'wpgmapembed_get_marker_data_by_marker_id' => wp_create_nonce('wpgmapembed_get_marker_data_by_marker_id'),
100 'wgm_save_category' => wp_create_nonce('wgm_save_category'),
101 'wgm_update_category' => wp_create_nonce('wgm_update_category'),
102 'wgm_delete_category' => wp_create_nonce('wgm_delete_category'),
103 'wgm_get_categories' => wp_create_nonce('wgm_get_categories'),
104 'wgm_get_category_data' => wp_create_nonce('wgm_get_category_data'),
105 ],
106 // Import related localized strings
107 'import_messages' => array(
108 'no_file_title' => __('No file', 'gmap-embed'),
109 'no_file_text' => __('Please choose a file to import.', 'gmap-embed'),
110 'file_type_mismatch_title' => __('File type mismatch', 'gmap-embed'),
111 'file_type_mismatch_text' => __('The selected file does not appear to match the chosen format. Please select the correct file or change the file type.', 'gmap-embed'),
112 'large_file_title' => __('Large file', 'gmap-embed'),
113 'large_file_text' => __('The selected file is {file} which exceeds the server upload limit of {limit}. The upload will likely fail. Do you still want to continue?', 'gmap-embed'),
114 'destructive_title' => __('Destructive action', 'gmap-embed'),
115 'destructive_text' => __('You chose Replace and Create new map. This will delete existing maps and markers. This action cannot be undone. Do you want to continue?', 'gmap-embed'),
116 'preview_error_title' => __('Preview error', 'gmap-embed'),
117 'preview_error_text' => __('Preview failed', 'gmap-embed'),
118 // Server-side import error messages (used when redirecting back to the Import tab)
119 'server_error_invalid_mapping' => __('Invalid CSV column mapping. Please review the mapping and try again.', 'gmap-embed'),
120 'server_error_create_map_failed' => __('Failed to create target map for marker import. Check site permissions and try again.', 'gmap-embed'),
121 'server_error_empty_csv' => __('The uploaded CSV appears to be empty or malformed.', 'gmap-embed'),
122 'server_error_unknown_csv_type' => __('Unknown CSV import data type selected.', 'gmap-embed'),
123 'server_error_create_map_permission' => __('Insufficient permissions to create maps. You need the proper capability to import into a new map.', 'gmap-embed'),
124 // Confirm / cancel labels
125 'confirm_button' => __('Continue', 'gmap-embed'),
126 'cancel_button' => __('Cancel', 'gmap-embed'),
127 // Dry run messages
128 'dryrun_title' => __('Dry Run Result', 'gmap-embed'),
129 'dryrun_success' => __('Dry run completed successfully. {count} items would be imported.', 'gmap-embed'),
130 'dryrun_json_success' => __('Dry run completed successfully. {maps} maps, {markers} markers and {categories} categories would be imported.', 'gmap-embed'),
131 'ajax_error' => __('An error occurred while processing the request. Please try again.', 'gmap-embed'),
132 ),
133 );
134
135 if (isset($_GET['tag']) && sanitize_text_field(wp_unslash($_GET['tag'])) == 'edit') {
136 if (isset($_GET['wgm_map_create_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['wgm_map_create_nonce'])), 'wgm_create_map')) {
137 // Nonce verified for map edit action
138 $map_id = isset($_GET['id']) ? intval(sanitize_text_field(wp_unslash($_GET['id']))) : 0;
139 $wgm_admin_center_str = sanitize_text_field(get_post_meta($map_id, 'wpgmap_center_lat_lng', true));
140 if (empty($wgm_admin_center_str)) {
141 $wgm_admin_center_str = sanitize_text_field(get_post_meta($map_id, 'wpgmap_latlng', true));
142 }
143 $wgm_admin_current_lat_lng = explode(',', $wgm_admin_center_str);
144 $current_map_marker_lat = (isset($wgm_admin_current_lat_lng[0]) && is_numeric($wgm_admin_current_lat_lng[0])) ? floatval($wgm_admin_current_lat_lng[0]) : 40.73359922990751;
145 $current_map_marker_lng = (isset($wgm_admin_current_lat_lng[1]) && is_numeric($wgm_admin_current_lat_lng[1])) ? floatval($wgm_admin_current_lat_lng[1]) : -74.02791395625002;
146 $wgm_map_zoom = get_post_meta($map_id, 'wpgmap_map_zoom', true);
147 $wgm_map_type = get_post_meta($map_id, 'wpgmap_map_type', true);
148
149 $wgm_admin_gmap_data = $this->get_wpgmapembed_data(intval($map_id));
150 $wgm_admin_single_map = json_decode($wgm_admin_gmap_data);
151
152 $wgm_localized['edit_data'] = [
153 'center_lat' => $current_map_marker_lat,
154 'center_lng' => $current_map_marker_lng,
155 'map_id' => intval($map_id),
156 'map_zoom' => $wgm_map_zoom ? intval($wgm_map_zoom) : 10,
157 'map_type' => $wgm_map_type ? esc_html($wgm_map_type) : 'ROADMAP',
158 'theme_json' => ($wgm_admin_single_map && isset($wgm_admin_single_map->wgm_theme_json)) ? wp_kses_data($wgm_admin_single_map->wgm_theme_json) : '',
159 ];
160
161 // Fetch categories for localization
162 global $wpdb;
163 $wgm_admin_categories = wp_cache_get('wgm_categories_all', 'gmap-embed');
164 if (false === $wgm_admin_categories) {
165 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
166 $wgm_admin_categories = $wpdb->get_results("SELECT id, name, parent_id FROM {$wpdb->prefix}wgm_categories ORDER BY parent_id ASC, name ASC");
167 wp_cache_set('wgm_categories_all', $wgm_admin_categories, 'gmap-embed', 12 * HOUR_IN_SECONDS);
168 }
169 $wgm_localized['edit_data']['categories'] = $wgm_admin_categories;
170
171 $wgm_localized['wgm_object'] = $wgm_localized['edit_data'];
172 } else {
173 // Nonce missing or invalid for map edit action
174 $wgm_redirect_url = esc_url_raw(
175 add_query_arg(
176 array('page' => 'wpgmapembed'),
177 admin_url('admin.php')
178 )
179 );
180 wp_safe_redirect($wgm_redirect_url);
181 exit;
182 }
183 }
184
185 // Settings page data
186 $wgm_page = isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : '';
187 if ($wgm_page === 'wpgmapembed-settings') {
188 $wgm_localized['settings_data'] = [
189 'max_upload' => wp_max_upload_size(),
190 ];
191 $wgm_localized['strings'] = [
192 'csv_preview' => __('CSV Preview', 'gmap-embed'),
193 'json_preview' => __('JSON Preview', 'gmap-embed'),
194 'column_mapping' => __('Column Mapping', 'gmap-embed'),
195 'column_mapping_desc' => __('Map each CSV column to plugin fields before importing.', 'gmap-embed'),
196 'json_preview_label' => __('JSON Preview', 'gmap-embed'),
197 ];
198 $wgm_localized['sample_files'] = [
199 'json' => [
200 'url' => esc_url(WGM_PLUGIN_URL . 'admin/assets/sample/example_markers_categories.json'),
201 'label' => __('Download sample JSON', 'gmap-embed'),
202 ],
203 'csv_markers' => [
204 'url' => esc_url(WGM_PLUGIN_URL . 'admin/assets/sample/example_markers.csv'),
205 'label' => __('Download sample CSV (Markers)', 'gmap-embed'),
206 ],
207 'csv_categories' => [
208 'url' => esc_url(WGM_PLUGIN_URL . 'admin/assets/sample/example_categories.csv'),
209 'label' => __('Download sample CSV (Categories)', 'gmap-embed'),
210 ],
211 ];
212 }
213
214 return $wgm_localized;
215 }
216
217 public function getPluginStatus()
218 {
219 // API status variable ->debugging purpose
220 return wp_json_encode(
221 array(
222 'p_v' => WGM_PLUGIN_VERSION,
223 'p_d_v' => WGM_PLUGIN_DEV_VERSION,
224 'l_api' => $this->config->get('_wgm_load_map_api_condition', 'always'),
225 'p_api' => $this->config->get('_wgm_prevent_other_plugin_theme_api_load', 'N'),
226 'i_p' => $this->config->is_premium(),
227 'd_f_s_c' => $this->config->get('_wgm_disable_full_screen_control', 'N'),
228 'd_s_v' => $this->config->get('_wgm_disable_street_view', 'N'),
229 'd_z_c' => $this->config->get('_wgm_disable_zoom_control', 'N'),
230 'd_p_c' => $this->config->get('_wgm_disable_pan_control', 'N'),
231 'd_m_t_c' => $this->config->get('_wgm_disable_map_type_control', 'N'),
232 'd_m_w_z' => $this->config->get('_wgm_disable_mouse_wheel_zoom', 'N'),
233 'd_m_d' => $this->config->get('_wgm_disable_mouse_dragging', 'N'),
234 'd_m_d_c_z' => $this->config->get('_wgm_disable_mouse_double_click_zooming', 'N'),
235 'e_d_f_a_c' => $this->config->get('_wgm_enable_direction_form_auto_complete', 'N'),
236 'lng' => $this->config->get('srm_gmap_lng', 'en'),
237 'reg' => $this->config->get('srm_gmap_region', 'US'),
238 'd_u' => $this->config->get('_wgm_distance_unit', 'km'),
239 'm_r' => $this->config->get('_wgm_minimum_role_for_map_edit', 'administrator'),
240 'php_v' => PHP_VERSION,
241 'wp_v' => get_bloginfo('version'),
242 )
243 );
244 }
245
246 /**
247 * Register common scripts
248 */
249 private function registerCommonScripts()
250 {
251 $srm_gmap_lng = $this->config->get('srm_gmap_lng', 'en');
252 $srm_gmap_region = $this->config->get('srm_gmap_region', 'US');
253 //phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion,WordPress.WP.EnqueuedResourceParameters.NotInFooter
254 wp_register_script(
255 'wp-gmap-api',
256 esc_url_raw('https://maps.google.com/maps/api/js?key=' . rawurlencode($this->wpgmap_api_key) . '&libraries=places&language=' . rawurlencode($srm_gmap_lng) . '&region=' . rawurlencode($srm_gmap_region) . '&callback=wgm_gmap_api_loaded'),
257 ['jquery']
258 );
259
260 // Datatables
261 wp_register_style('wgm-datatable-css', WGM_PLUGIN_URL . 'admin/assets/third-party/datatables/css/jquery.dataTables.min.css', array(), '1.13.7');
262 wp_register_script('wgm-datatable-js', WGM_PLUGIN_URL . 'admin/assets/third-party/datatables/js/jquery.dataTables.min.js', array('jquery'), '1.13.7', true);
263
264 // Swiper
265 wp_register_style('wgm-swiper-css', WGM_PLUGIN_URL . 'admin/assets/third-party/swiper/css/swiper-bundle.min.css', array(), '11.0.5');
266 wp_register_script('wgm-swiper-js', WGM_PLUGIN_URL . 'admin/assets/third-party/swiper/js/swiper-bundle.min.js', array(), '11.0.5', true);
267 }
268
269 /**
270 * Add async attribute to Google Maps API script
271 */
272 public function wgm_add_async_attribute($tag, $handle, $src) {
273 if ($handle === 'wp-gmap-api') {
274 return str_replace(' src', ' async defer src', $tag);
275 }
276 return $tag;
277 }
278
279 /**
280 * Print Google Maps API Callback Script
281 */
282 public function wgm_head_callback_script() {
283 ?>
284 <script type="text/javascript">
285 window.wgm_map_queue = window.wgm_map_queue || [];
286 window.wgm_gmap_api_loaded = function() {
287 window.wgm_map_queue.forEach(function(f) { f(); });
288 window.wgm_map_queue = [];
289 };
290 </script>
291 <?php
292 }
293
294 /**
295 * Register frontend scripts
296 */
297 public function register_frontend_scripts()
298 {
299 wp_register_script(
300 'wp-gmap-embed-front-js',
301 WGM_PLUGIN_URL . 'public/assets/js/wgm-frontend.js',
302 array('jquery', 'wp-gmap-api'),
303 filemtime(WGM_PLUGIN_PATH . 'public/assets/js/wgm-frontend.js'),
304 true
305 );
306 }
307
308 public function wgm_enqueue_front_assets() {
309 wp_enqueue_style('wgm-design-system-css', WGM_PLUGIN_URL . 'admin/assets/css/wgm-design-system.css', array(), filemtime(WGM_PLUGIN_PATH . 'admin/assets/css/wgm-design-system.css'));
310 wp_enqueue_style('wp-gmap-front-custom-style-css', WGM_PLUGIN_URL . 'public/assets/css/front_custom_style.css', array('wgm-design-system-css'), filemtime(WGM_PLUGIN_PATH . 'public/assets/css/front_custom_style.css'));
311 $custom_css_styles = esc_textarea(get_option('wpgmap_s_custom_css'));
312 if (strlen($custom_css_styles) !== 0) {
313 wp_add_inline_style('wp-gmap-front-custom-style-css', "$custom_css_styles");
314 }
315 }
316
317 /**
318 * To enqueue CSS & JS for frontend
319 */
320 public function gmap_front_enqueue_scripts()
321 {
322 // Register common scripts (includes: google maps api)
323 $this->registerCommonScripts();
324
325 // Based on user defined condition, enqueue Google Map API script
326 if (in_array($this->config->get('_wgm_load_map_api_condition', 'always'), array('where-required', 'always', 'only-front-end'))) {
327 wp_enqueue_script('wp-gmap-api');
328 }
329
330 // Custom JS script and Plugin status including
331 $wgm_settings_status = $this->getPluginStatus();
332 $custom_js_scripts = get_option('wpgmap_s_custom_js');
333 $custom_js_scripts .= "\nvar wgm_status = $wgm_settings_status;";
334 $custom_js_ca_data_enclosed = "/* <![CDATA[ */\n" . $custom_js_scripts . "\n/* ]]> */";
335 wp_add_inline_script('wp-gmap-api', $custom_js_ca_data_enclosed);
336
337 // Centralized Frontend Logic
338 wp_enqueue_script('wp-gmap-embed-front-js');
339
340 // Select2 for frontend filters
341 wp_enqueue_style('wgm-select2-css', WGM_PLUGIN_URL . 'admin/assets/third-party/select2/css/select2.min.css', array(), '4.1.0-rc.0');
342 wp_enqueue_script('wgm-select2-js', WGM_PLUGIN_URL . 'admin/assets/third-party/select2/js/select2.min.js', array('jquery'), '4.1.0-rc.0', true);
343
344 $this->wgm_enqueue_front_assets();
345 }
346
347 /**
348 * To enqueue scripts for admin-panel
349 */
350 function enqueue_admin_gmap_scripts()
351 {
352 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
353 $page = isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : '';
354 // Nonce verification should be added if this triggers sensitive actions.
355 global $pagenow;
356 if ($pagenow === 'post.php' || $pagenow === 'post-new.php' || ($page == 'wpgmapembed' || $page === 'wpgmapembed-settings' || $page === 'wpgmapembed-new' || $page === 'wgm_setup_wizard' || $page === 'wpgmapembed-support' || $page === 'wpgmapembed-categories')) {
357
358 // Registering common scripts (Included: Google API)
359 $this->registerCommonScripts();
360
361 // Including Google Map API for only New Map and Edit Map page
362 if (in_array(esc_html(get_option('_wgm_load_map_api_condition', 'always')), array('where-required', 'always', 'only-backend-end')) && ($page === 'wpgmapembed' or $page === 'wpgmapembed-new')) {
363 wp_enqueue_script('wp-gmap-api');
364 }
365
366 /** Common assets */
367 wp_enqueue_script('wp-gmap-common-js', WGM_PLUGIN_URL . 'admin/assets/js/common.js', array(), filemtime(WGM_PLUGIN_PATH . 'admin/assets/js/common.js'), false);
368 $wgm_localized = $this->getLocalizedScripts();
369 wp_localize_script('wp-gmap-common-js', 'wgm_l', $wgm_localized);
370 /** Common admin styles */
371 wp_enqueue_style('wgm-design-system-css', WGM_PLUGIN_URL . 'admin/assets/css/wgm-design-system.css', array(), filemtime(WGM_PLUGIN_PATH . 'admin/assets/css/wgm-design-system.css'));
372 wp_enqueue_style('wp-gmap-style-css', WGM_PLUGIN_URL . 'admin/assets/css/wp-gmap-style.css', array('wgm-design-system-css'), filemtime(WGM_PLUGIN_PATH . 'admin/assets/css/wp-gmap-style.css'));
373 // Font awesome
374 wp_enqueue_style('wp-gmap-fontawasome-css', WGM_PLUGIN_URL . 'admin/assets/third-party/font-awesome/5/css/font-awesome.css', array(), filemtime(WGM_PLUGIN_PATH . 'admin/assets/third-party/font-awesome/5/css/font-awesome.css'));
375 // Sweet alert related
376 wp_enqueue_style('wp-gmap-sweetalert2-css', WGM_PLUGIN_URL . 'admin/assets/third-party/sweetalert2/css/sweetalert2.min.css', array(), filemtime(WGM_PLUGIN_PATH . 'admin/assets/third-party/sweetalert2/css/sweetalert2.min.css'));
377 wp_enqueue_script('wp-gmap-sweetalert2-js', WGM_PLUGIN_URL . 'admin/assets/third-party/sweetalert2/js/sweetalert2.min.js', array(), filemtime(WGM_PLUGIN_PATH . 'admin/assets/third-party/sweetalert2/js/sweetalert2.min.js'), true);
378 // Media upload
379 wp_enqueue_script('media-upload');
380 wp_enqueue_script('thickbox');
381 wp_enqueue_script('wpgmap-media-upload');
382 wp_enqueue_media();
383 wp_enqueue_style('thickbox');
384
385 /** Edit and Add Map page */
386 if ($pagenow === 'post.php' || $pagenow === 'post-new.php' || ($page === 'wpgmapembed' or $page === 'wpgmapembed-new')) {
387 wp_enqueue_script('wgm-map-curd-js', WGM_PLUGIN_URL . 'admin/assets/js/wgm_map_crud.js', array('wp-gmap-common-js', 'wgm-datatable-js'), filemtime(WGM_PLUGIN_PATH . 'admin/assets/js/wgm_map_crud.js'), true);
388 wp_enqueue_script('wp-gmap-markers-js', WGM_PLUGIN_URL . 'admin/assets/js/wgm_marker_crud.js', array('wp-gmap-common-js'), filemtime(WGM_PLUGIN_PATH . 'admin/assets/js/wgm_marker_crud.js'), true);
389 wp_enqueue_script('wgm-geo-based-map-edit-js', WGM_PLUGIN_URL . 'admin/assets/js/geo_based_map_edit.js', array('wp-gmap-common-js', 'wgm-select2-js'), filemtime(WGM_PLUGIN_PATH . 'admin/assets/js/geo_based_map_edit.js'), true);
390 wp_enqueue_script('wgm-icon-selector-js', WGM_PLUGIN_URL . 'admin/assets/js/wgm-icon-selector.js', array('jquery'), filemtime(WGM_PLUGIN_PATH . 'admin/assets/js/wgm-icon-selector.js'), true);
391 // Select2
392 wp_enqueue_style('wgm-select2-css', WGM_PLUGIN_URL . 'admin/assets/third-party/select2/css/select2.min.css', array(), '4.1.0-rc.0');
393 wp_enqueue_script('wgm-select2-js', WGM_PLUGIN_URL . 'admin/assets/third-party/select2/js/select2.min.js', array('jquery'), '4.1.0-rc.0', true);
394 // Datatables
395 wp_enqueue_style('wgm-datatable-css');
396 wp_enqueue_script('wgm-datatable-js');
397 }
398
399 /** Setup Wizard */
400 if ($page === 'wgm_setup_wizard') {
401 wp_enqueue_style('wp-gmap-setup-wizard-css', WGM_PLUGIN_URL . 'admin/assets/css/setup_wizard.css', array(), filemtime(WGM_PLUGIN_PATH . '/admin/assets/css/setup_wizard.css'));
402 wp_enqueue_script('wp-gmap-setup-wizard-js', WGM_PLUGIN_URL . 'admin/assets/js/setup_wizard.js', array(), filemtime(WGM_PLUGIN_PATH . 'admin/assets/js/setup_wizard.js'), true);
403 }
404
405 /** Page-specific admin overrides */
406
407 if ($page === 'wpgmapembed-settings') {
408 wp_enqueue_script('wgm-admin-settings-js', WGM_PLUGIN_URL . 'admin/assets/js/wgm-admin-settings.js', array('wp-gmap-common-js'), filemtime(WGM_PLUGIN_PATH . 'admin/assets/js/wgm-admin-settings.js'), true);
409 }
410 if ($page === 'wpgmapembed' || $page === 'wpgmapembed-new') {
411 wp_enqueue_script('wgm-admin-edit-js', WGM_PLUGIN_URL . 'admin/assets/js/wgm-admin-edit.js', array('wp-gmap-common-js'), filemtime(WGM_PLUGIN_PATH . 'admin/assets/js/wgm-admin-edit.js'), true);
412 }
413 if ($page === 'wpgmapembed-categories') {
414 wp_enqueue_script('wgm-categories-js', WGM_PLUGIN_URL . 'admin/assets/js/categories.js', array('wp-gmap-common-js', 'wgm-datatable-js', 'wp-gmap-sweetalert2-js'), filemtime(WGM_PLUGIN_PATH . 'admin/assets/js/categories.js'), true);
415 wp_enqueue_style('wgm-datatable-css');
416 wp_enqueue_script('wgm-datatable-js');
417 }
418 }
419 }
420 }
421