PluginProbe
WP Maps – Google Maps,OpenStreetMap,Mapbox,Store Locator,Listing,Directory & Filters / version4.4.8
WP Maps – Google Maps,OpenStreetMap,Mapbox,Store Locator,Listing,Directory & Filters vversion4.4.8
4.9.9 4.9.8 4.9.7 4.9.6 4.9.5 4.8.7 4.8.8 4.8.9 4.9.0 4.9.1 4.9.2 4.9.3 version4.4.8 trunk 3.0.8 3.1.1 4.0.6 4.2.2 4.4.5 4.4.6 4.4.7 4.4.9 4.5.0 4.5.1 4.5.2 All 54 releases
wp-google-map-plugin / wp-google-map-plugin.php

wp-google-map-plugin.php in WP Maps – Google Maps,OpenStreetMap,Mapbox,Store Locator,Listing,Directory & Filters version4.4.8, at wp-google-map-plugin.php

999 lines 34.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: WP Maps
4 Plugin URI: https://www.flippercode.com
5 Description: A fully customizable WordPress Plugin for Google Maps. Create unlimited Google Maps Shortcodes, assign unlimited locations with custom infowindow messages and add to pages, posts and widgets.
6 Author: flippercode
7 Author URI: https://www.flippercode.com
8 Version: 4.4.8
9 Text Domain: wp-google-map-plugin
10 Domain Path: /lang
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 die( 'You are not allowed to call this page directly.' );
15 }
16
17 if ( ! class_exists( 'FC_Google_Maps_Lite' ) ) {
18
19 /**
20 * Main plugin class
21 * @author Flipper Code <hello@flippercode.com>
22 * @package Maps
23 */
24 class FC_Google_Maps_Lite
25 {
26 /**
27 * List of Modules.
28 * @var array
29 */
30 private $modules = array();
31 /**
32 * Intialize variables, files and call actions.
33 * @var array
34 */
35 public function __construct() {
36
37 $this->wpgmp_define_constants();
38 $this->wpgmp_load_files();
39
40 register_activation_hook( __FILE__, array( $this, 'wpgmp_plugin_activation' ) );
41 register_deactivation_hook( __FILE__, array( $this, 'wpgmp_plugin_deactivation' ) );
42 if( is_multisite() ){
43
44 add_action( 'wpmu_new_blog', array( $this, 'wpgmp_on_blog_new_generate'), 10, 6 );
45 add_filter( 'wpmu_drop_tables', array( $this, 'wpgmp_on_blog_delete') );
46
47 }
48 add_action( 'plugins_loaded', array( $this, 'wpgmp_load_plugin_languages' ) );
49 add_action( 'init', array( $this, 'wpgmp_init' ) );
50 add_action( 'widgets_init', array( $this, 'wpgmp_google_map_widget' ) );
51
52 }
53
54 /**
55 * Call WordPress hooks.
56 */
57 function wpgmp_init() {
58
59 add_action( 'media_upload_ell_insert_gmap_tab', array( $this, 'wpgmp_google_map_media_upload_tab' ) );
60 add_action( 'wp_enqueue_scripts', array( $this, 'wpgmp_frontend_scripts' ) );
61 add_shortcode( 'put_wpgm', array( $this, 'wpgmp_show_location_in_map' ) );
62 add_shortcode( 'display_map', array( $this, 'wpgmp_display_map' ) );
63 add_filter( 'fc-dummy-placeholders', array( $this, 'wpgmp_apply_placeholders') );
64
65 if(is_admin()){
66 add_action( 'admin_head', array( $this, 'wpgmp_customizer_font_family' ) );
67 add_action( 'admin_menu', array( $this, 'wpgmp_create_menu' ) );
68 add_filter( 'media_upload_tabs', array( $this, 'wpgmp_google_map_tabs_filter' ) );
69 add_action( 'admin_enqueue_scripts', array( $this, 'wpgmp_overview_page_styles') );
70 add_filter( 'plugin_action_links_'. plugin_basename(__FILE__), array($this, 'wpgmp_go_pro_link'), 10, 1 );
71 add_filter( 'fc_after_plugin_header', array( $this, 'wpgmp_show_buynow_notice') );
72 add_action( 'admin_head', array( $this, 'wpgmp_custom_css_admin_head' ) );
73 add_action( 'wp_ajax_wpgmp_hide_buy_notice', array( $this, 'wpgmp_hide_buy_notice' ) );
74 add_action( 'wp_ajax_nopriv_wpgmp_hide_buy_notice', array( $this, 'wpgmp_hide_buy_notice' ) );
75 add_action( 'admin_footer', array( $this, 'wpgmp_add_modals') );
76 add_action('admin_notices', array($this, 'wpgmp_show_sample_admin_notice__info'));
77 add_action('wp_ajax_wpgmp_hide_sample_notice', array($this, 'wpgmp_hide_sample_notice'));
78 add_action('wp_ajax_nopriv_wpgmp_hide_sample_notice', array($this, 'wpgmp_hide_sample_notice'));
79 add_action('admin_menu', array($this,'add_custom_link_into_plugin_menu') );
80 }
81
82 }
83
84 /**
85 * Register WP Google Map Widget
86 */
87 function wpgmp_google_map_widget() { register_widget( 'WPGMP_Google_Map_Widget_Class' ); }
88
89 function wpgmp_customizer_font_family() {
90
91 if ( isset( $_GET['doaction'] ) and 'edit' == $_GET['doaction'] and isset( $_GET['map_id'] ) ) {
92
93 $modelFactory = new WPGMP_Model();
94 $map_obj = $modelFactory->create_object( 'map' );
95 $styles_and_scripts = $map_obj->get_map_customizer_style();
96 $font_families = $styles_and_scripts['font_families'];
97 $fc_skin_styles = $styles_and_scripts['fc_skin_styles'];
98 if ( ! empty( $fc_skin_styles ) ) {
99 echo '<style>' . $fc_skin_styles . '</style>';
100 }
101 if ( ! empty( $font_families ) ) {
102 $font_families = array_unique($font_families);
103 ?>
104 <script type="text/javascript">
105 var google_customizer_fonts = <?php echo json_encode($font_families,JSON_FORCE_OBJECT);?>;
106 </script>
107 <?php }
108
109 }
110
111 }
112
113
114 function wpgmp_go_pro_link($actions) {
115
116 $actions['settings'] = '<a href="' . admin_url( 'admin.php?page=wpgmp_manage_settings' ) . '">'.esc_html__( 'Settings', 'wp-google-map-plugin' ).'</a>';
117 $actions['go_pro'] = '<a style="color:#2ea100;" target = "_blank" href="https://www.wpmapspro.com/?utm_source=wordpress&utm_medium=liteversion&utm_campaign=freemium&utm_id=freemium">'.esc_html__( 'Pro Version', 'wp-google-map-plugin' ).'</a>';
118
119
120 return $actions;
121 }
122
123 function wpgmp_custom_css_admin_head() {
124
125 $modelFactory = new WPGMP_Model();
126 $location_obj = $modelFactory->create_object( 'location' );
127 $locations = $location_obj->fetch();
128 if(is_array($locations) && count($locations) > 0) { ?>
129 <style>.wp-list-table .locations{ margin-top: 40px; } </style> <?php
130 }
131 }
132
133 /**
134 * Eneque scripts at frontend.
135 */
136 function wpgmp_frontend_scripts() {
137
138 global $post;
139
140 $wpgmp_settings = get_option( 'wpgmp_settings', true );
141
142 // Hook accept cookies
143 if ( isset($wpgmp_settings['wpgmp_gdpr']) && $wpgmp_settings['wpgmp_gdpr'] == true ) {
144
145 $wpgmp_accept_cookies = apply_filters( 'wpgmp_accept_cookies', false );
146
147 if ( $wpgmp_accept_cookies == false ) {
148
149 return;
150 }
151 }
152
153 $auto_fix = '';
154
155 if( isset($wpgmp_settings['wpgmp_auto_fix']) && !empty($wpgmp_settings['wpgmp_auto_fix'])) {
156
157 $auto_fix = $wpgmp_settings['wpgmp_auto_fix'];
158
159 if ( $auto_fix == 'true' ) {
160 wp_enqueue_script( 'jquery' );
161 }
162 }
163
164 // Check if the current page content has the shortcode [put_wpgm id=X]
165 if ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'put_wpgm' ) && preg_match( '/\[put_wpgm id=\d+\]/', $post->post_content ) ) {
166 wp_enqueue_style('wpgmp-frontend_css',WPGMP_CSS.'frontend.css');
167 wp_enqueue_script( 'jquery' );
168 }
169
170 $language = get_option( 'wpgmp_language' );
171
172 if ( $language == '' )
173 $language = 'en';
174
175
176 if ( get_option( 'wpgmp_api_key' ) != '' ) {
177 $google_map_api = 'https://maps.google.com/maps/api/js?key='.get_option( 'wpgmp_api_key' ).'&callback=wpgmpInitMap&libraries=geometry,places&language='.$language;
178 } else {
179 $google_map_api = 'https://maps.google.com/maps/api/js?&callback=initwpmaps&libraries=geometry,places&language='.$language;
180 }
181
182
183 $where = get_option( 'wpgmp_scripts_place' );
184
185 if ( $where == 'header' ) {
186 $where = false;
187 } else {
188 $where = true;
189 }
190
191 $wpgmp_local = array();
192 $wpgmp_local['all_location'] = esc_html__( 'All', 'wp-google-map-plugin' );
193 $wpgmp_local['show_locations'] = esc_html__( 'Show Locations', 'wp-google-map-plugin' );
194 $wpgmp_local['sort_by'] = esc_html__( 'Sort by', 'wp-google-map-plugin' );
195 $wpgmp_local['wpgmp_not_working'] = esc_html__( 'Not working...', 'wp-google-map-plugin' );
196 $wpgmp_local['select_category'] = esc_html__( 'Select Category', 'wp-google-map-plugin' );
197 $wpgmp_local['place_icon_url'] = WPGMP_ICONS;
198 $wpgmp_local['wpgmp_assets'] = WPGMP_JS;
199
200 $scripts = array();
201
202 $scripts[] = array(
203 'handle' => 'wpgmp-google-map-main',
204 'src' => WPGMP_JS.'maps.js',
205 'deps' => array(),
206 );
207
208 $scripts[] = array(
209 'handle' => 'wpgmp-google-api',
210 'src' => $google_map_api,
211 'deps' => array('wpgmp-google-map-main'),
212 );
213
214 if ( $scripts ) {
215 foreach ( $scripts as $script ) {
216 if ( $auto_fix == 'true' ) {
217 wp_enqueue_script( $script['handle'], $script['src'], $script['deps'], WPGMP_VERSION, $where );
218 } else {
219 wp_register_script( $script['handle'], $script['src'], $script['deps'], WPGMP_VERSION, $where );
220 }
221 }
222 }
223
224 wp_localize_script( 'wpgmp-google-map-main', 'wpgmp_local',$wpgmp_local );
225
226 }
227 /**
228 * Display map at the frontend using put_wpgmp shortcode.
229 * @param array $atts Map Options.
230 * @param string $content Content.
231 */
232 function wpgmp_show_location_in_map($atts, $content = null) {
233
234 try {
235 $factoryObject = new WPGMP_Controller();
236 $viewObject = $factoryObject->create_object( 'shortcode' );
237 $output = $viewObject->display( 'put-wpgmp',$atts );
238 return $output;
239
240 } catch (Exception $e) {
241 echo WPGMP_Template::show_message( array( 'error' => $e->getMessage() ) );
242
243 }
244
245 }
246 /**
247 * Display map at the frontend using display_map shortcode.
248 * @param array $atts Map Options.
249 */
250 function wpgmp_display_map($atts) {
251
252 try {
253 $factoryObject = new WPGMP_Controller();
254 $viewObject = $factoryObject->create_object( 'shortcode' );
255 $output = $viewObject->display( 'display-map',$atts );
256 return $output;
257
258 } catch (Exception $e) {
259 echo WPGMP_Template::show_message( array( 'error' => $e->getMessage() ) );
260
261 }
262
263 }
264 /**
265 * Process slug and display view in the backend.
266 */
267 function wpgmp_processor() {
268
269 $return = '';
270 if ( isset( $_GET['page'] ) ) {
271 $page = sanitize_key( wp_unslash( $_GET['page'] ) );
272 } else {
273 $page = 'wpgmp_view_overview';
274 }
275
276 $pageData = explode( '_', $page );
277 $obj_type = $pageData[2];
278 $obj_operation = $pageData[1];
279
280 if ( count( $pageData ) < 3 ) {
281 die( 'Cheating!' );
282 }
283
284 try {
285 if ( count( $pageData ) > 3 ) {
286 $obj_type = $pageData[2].'_'.$pageData[3];
287 }
288
289 $factoryObject = new WPGMP_Controller();
290 $viewObject = $factoryObject->create_object( $obj_type );
291 $viewObject->display( $obj_operation );
292
293 } catch (Exception $e) {
294 echo WPGMP_Template::show_message( array( 'error' => $e->getMessage() ) );
295
296 }
297
298 }
299 /**
300 * Create backend navigation.
301 */
302 function wpgmp_create_menu() {
303
304 global $navigations;
305
306 $pagehook1 = add_menu_page(
307 esc_html__( 'WP MAPS', 'wp-google-map-plugin' ),
308 esc_html__( 'WP MAPS', 'wp-google-map-plugin' ),
309 'wpgmp_admin_overview',
310 WPGMP_SLUG,
311 array( $this,'wpgmp_processor' ),
312 esc_url( WPGMP_IMAGES.'flippercode.png' )
313 );
314
315 if ( current_user_can( 'manage_options' ) ) {
316 $role = get_role( 'administrator' );
317 $role->add_cap( 'wpgmp_admin_overview' );
318 }
319
320 $this->wpgmp_load_modules_menu();
321
322 add_action( 'load-'.$pagehook1, array( $this, 'wpgmp_backend_scripts' ) );
323
324 }
325 /**
326 * Read models and create backend navigation.
327 */
328 function wpgmp_load_modules_menu() {
329
330 $modules = $this->modules;
331 $pagehooks = array();
332 if ( is_array( $modules ) ) {
333 foreach ( $modules as $module ) {
334
335 $object = new $module;
336
337 if ( method_exists( $object,'navigation' ) ) {
338
339 if ( ! is_array( $object->navigation() ) )
340 continue;
341
342 foreach ( $object->navigation() as $nav => $title ) {
343
344 if ( current_user_can( 'manage_options' ) && is_admin() ) {
345 $role = get_role( 'administrator' );
346 $role->add_cap( $nav );
347
348 }
349
350 $pagehooks[] = add_submenu_page(
351 WPGMP_SLUG,
352 $title,
353 $title,
354 $nav,
355 $nav,
356 array( $this,'wpgmp_processor' )
357 );
358 }
359 }
360 }
361 }
362
363 if ( is_array( $pagehooks ) ) {
364
365 foreach ( $pagehooks as $key => $pagehook ) {
366 add_action( 'load-'.$pagehooks[ $key ], array( $this, 'wpgmp_backend_scripts' ) );
367 }
368 }
369
370 }
371
372 function add_custom_link_into_plugin_menu() {
373
374 global $submenu;
375 $permalink = 'https://www.wpmapspro.com/?utm_source=wordpress&utm_medium=liteversion&utm_campaign=freemium&utm_id=freemium';
376 $submenu['wpgmp_view_overview'][] = array( '<span class="fc-fire-sale"><img draggable="false" role="img" class="emoji" alt="🔥" src="https://s.w.org/images/core/emoji/14.0.0/svg/1f525.svg"></span>'.esc_html__(' Go Pro', 'wpgmp-google-map'), "manage_options", $permalink );
377 }
378
379 /**
380 * Eneque scripts in the backend.
381 */
382 function wpgmp_backend_scripts() {
383
384 if ( get_option( 'wpgmp_api_key' ) != '' ) {
385 $google_map_api = 'https://maps.google.com/maps/api/js?key='.get_option( 'wpgmp_api_key' ).'&callback=initwpmaps&libraries=geometry,places,drawing&language=en';
386 } else {
387 $google_map_api = 'https://maps.google.com/maps/api/js?&callback=initwpmaps&libraries=geometry,places,drawing&language=en';
388 }
389
390 wp_enqueue_style( 'thickbox' );
391 wp_enqueue_style( 'wp-color-picker' );
392 $wp_scripts = array( 'jQuery','thickbox', 'wp-color-picker');
393
394 if ( $wp_scripts ) {
395 foreach ( $wp_scripts as $wp_script ) {
396 wp_enqueue_script( $wp_script );
397 }
398 }
399
400 $scripts = array();
401
402 $scripts[] = array(
403 'handle' => 'wpgmp-backend-google-maps',
404 'src' => WPGMP_JS.'backend.js',
405 'deps' => array(),
406 );
407
408 $scripts[] = array(
409 'handle' => 'wpgmp-map',
410 'src' => WPGMP_JS.'maps.js',
411 'deps' => array(),
412 );
413
414 $scripts[] = array(
415 'handle' => 'wpgmp-backend-google-api',
416 'src' => $google_map_api,
417 'deps' => array('wpgmp-map'),
418 );
419
420 $scripts[] = array(
421 'handle' => 'bootstrap-modal',
422 'src' => WPGMP_JS . 'bootstrap-modal.js',
423 'deps' => array(),
424 );
425
426 $scripts[] = array(
427 'handle' => 'flippercode-datatable',
428 'src' => WPGMP_JS . 'vendor/datatables/datatables.js',
429 'deps' => array(),
430 );
431
432 $scripts[] = array(
433 'handle' => 'flippercode-webfont',
434 'src' => WPGMP_JS . 'vendor/webfont/webfont.js',
435 'deps' => array(),
436 );
437
438 $scripts[] = array(
439 'handle' => 'flippercode-select2',
440 'src' => WPGMP_JS . 'vendor/select2/select2.js',
441 'deps' => array(),
442 );
443
444 $scripts[] = array(
445 'handle' => 'flippercode-slick',
446 'src' => WPGMP_JS . 'vendor/slick/slick.js',
447 'deps' => array(),
448 );
449
450 $scripts[] = array(
451 'handle' => 'wpgmp-infobox',
452 'src' => WPGMP_JS . 'vendor/infobox/infobox.js',
453 'deps' => array(),
454 );
455
456 $scripts[] = array(
457 'handle' => 'wpgmp-accordion',
458 'src' => WPGMP_JS . 'vendor/accordion/accordion.js',
459 'deps' => array(),
460 );
461
462 $scripts[] = array(
463 'handle' => 'flippercode-ui',
464 'src' => WPGMP_JS.'flippercode-ui.js',
465 'deps' => array(),
466 );
467
468 if ( $scripts ) {
469 foreach ( $scripts as $script ) {
470 wp_enqueue_script( $script['handle'], $script['src'], $script['deps'],false );
471 }
472 }
473
474 $wpgmp_local = array();
475 $wpgmp_local['language'] = 'en';
476 $wpgmp_local['urlforajax'] = admin_url( 'admin-ajax.php' );
477 $wpgmp_local['hide'] = esc_html__( 'Hide','wp-google-map-plugin' );
478 $wpgmp_local['nonce'] = wp_create_nonce( 'fc-call-nonce' );
479 $wpgmp_local['ajaxnonce'] = wp_create_nonce('fc_communication');
480 $wpgmp_local['text_editable'] = array( '.fc-text', '.fc-post-link', '.place_title', '.fc-item-content', '.wpgmp_locations_content' );
481 $wpgmp_local['bg_editable'] = array( '.fc-bg', '.fc-item-box', '.fc-pagination', '.wpgmp_locations' );
482 $wpgmp_local['margin_editable'] = array( '.fc-margin', '.fc-item-title', '.wpgmp_locations_head', '.fc-item-content', '.fc-item-meta' );
483 $wpgmp_local['full_editable'] = array( '.fc-css', '.fc-item-title', '.wpgmp_locations_head', '.fc-readmore-link', '.fc-item-meta', 'a.page-numbers', '.current', '.wpgmp_location_meta' );
484 $wpgmp_local['confirm_location_delete'] = esc_html__( 'Do you really want to delete this location?', 'wp-google-map-plugin' );
485 $wpgmp_local['confirm_map_delete'] = esc_html__( 'Do you really want to delete this map?', 'wp-google-map-plugin' );
486 $wpgmp_local['confirm_category_delete'] = esc_html__( 'Do you really want to delete this category?', 'wp-google-map-plugin' );
487 $wpgmp_local['confirm_route_delete'] = esc_html__( 'Do you really want to delete this route?', 'wp-google-map-plugin' );
488 $wpgmp_local['confirm_record_delete'] = esc_html__( 'Do you really want to delete this record?', 'wp-google-map-plugin' );
489 $wpgmp_local['no_record_for_bulk_delete'] = esc_html__( 'Please select some records first to apply bulk action on them.','wp-google-map-plugin' );
490 $wpgmp_local['confirm_bulk_delete'] = esc_html__( 'Are you sure you want to delete the selected records ?','wp-google-map-plugin' );
491 $wpgmp_local['confirm_overwrite_db'] = esc_html__( 'Overwrite existing google maps database?','wp-google-map-plugin' );
492 $wpgmp_local['referrer_copied'] = esc_html__( 'Referrer Was Copied','wp-google-map-plugin' );
493 $wpgmp_local['do_referrer_copy'] = esc_html__( 'Copy HTTP Referrer To Clipboard','wp-google-map-plugin' );
494
495
496 wp_localize_script( 'wpgmp-map', 'wpgmp_local', $wpgmp_local );
497 wp_localize_script( 'flippercode-ui', 'settings_obj', $wpgmp_local );
498
499 $wpgmp_js_lang = array();
500 $wpgmp_js_lang['confirm'] = esc_html__( 'Are you sure to delete item?','wp-google-map-plugin' );
501 wp_localize_script( 'wpgmp-backend-google-maps', 'wpgmp_js_lang', $wpgmp_js_lang );
502 $admin_styles = array(
503 'font_awesome_minimised' => WPGMP_CSS. 'font-awesome.min.css',
504 'wpgmp-map-bootstrap' => WPGMP_CSS.'flippercode-ui.css',
505 'wpgmp-backend-google-map' => WPGMP_CSS.'backend.css',
506 'wpgmp-backend-bootstrap-modal' => WPGMP_CSS . 'bootstrap-modal.css'
507
508 );
509
510 if ( $admin_styles ) {
511 foreach ( $admin_styles as $admin_style_key => $admin_style_value ) {
512 wp_enqueue_style( $admin_style_key, $admin_style_value );
513 }
514 }
515 }
516
517 public static function wpgmp_apply_placeholders( $content ){
518
519 $data['marker_id'] = 1;
520 $data['marker_title'] = 'New York, NY, United States';
521 $data['marker_address'] = 'New York, NY, United States';
522 $data['marker_message'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.';
523 $data['marker_category'] = 'Real Estate';
524 $data['marker_icon'] = WPGMP_IMAGES . 'default_marker.png';
525 $data['marker_latitude'] = '40.7127837';
526 $data['marker_longitude'] = '-74.00594130000002';
527 $data['marker_city'] = 'New York';
528 $data['marker_state'] = 'NY';
529 $data['marker_country'] = 'United States';
530 $data['marker_zoom'] = '5';
531 $data['marker_postal_code'] = '10002';
532 $data['extra_field_slug'] = 'color';
533 $data['marker_featured_image_src'] = WPGMP_IMAGES . 'sample.jpg';
534 $data['marker_image'] = '<img class="fc-item-featured_image fc-item-large" src="' . WPGMP_IMAGES . 'sample.jpg' . '" />';
535 $data['marker_featured_image'] = '<img class="fc-item-featured_image fc-item-large" src="' . WPGMP_IMAGES . 'sample.jpg' . '" />';
536 $data['post_title'] = 'Lorem ipsum dolor sit amet, consectetur';
537 $data['post_link'] = '#';
538 $data['post_excerpt'] = 'Lorem ipsum dolor sit amet, consectetur';
539 $data['post_content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.';
540 $data['post_categories'] = 'city tour';
541 $data['post_tags'] = 'WordPress, plugins, google maps';
542 $data['post_featured_image'] = '<img class="fc-item-featured_image fc-item-large" src="' . WPGMP_IMAGES . 'sample.jpg' . '" />';
543 $data['post_author'] = 'FlipperCode';
544 $data['post_comments'] = '<i class="fci fci-comment"></i> 10';
545 $data['view_count'] = '<i class="fci fci-heart"></i> 1';
546
547 foreach ( $data as $key => $value ) {
548 if ( strstr( $key, 'marker_featured_image_src' ) === false && strstr( $key, 'marker_icon' ) === false && strstr( $key, 'post_link' ) === false && strstr( $key, 'marker_zoom' ) === false && strstr( $key, 'marker_id' ) === false && strstr( $key, 'post_title' ) === false) {
549 $content = str_replace( "{{$key}}", $value . '<span class="fc-hidden-placeholder">{' . $key . '}</span>', $content );
550 } else {
551 $content = str_replace( "{{$key}}", $value, $content );
552 }
553 }
554
555 return $content;
556
557 }
558
559 /**
560 * Eneque scripts at backend overview page only.
561 */
562 function wpgmp_overview_page_styles( $hook ) {
563
564 if ( 'toplevel_page_wpgmp_view_overview' != $hook )
565 return;
566 wp_enqueue_style( 'custom-mailchimp-style', plugin_dir_url( __FILE__ ) . 'assets/css/mailchimp.css"');
567 }
568
569 /**
570 * Load plugin language file.
571 */
572 function wpgmp_load_plugin_languages() {
573
574 $this->modules = apply_filters( 'wpgmp_extensions',$this->modules);
575 load_plugin_textdomain( 'wp-google-map-plugin', false, WPGMP_FOLDER.'/lang' );
576 }
577 /**
578 * Call hook on plugin activation for both multi-site and single-site.
579 */
580 function wpgmp_plugin_activation( $network_wide ) {
581
582 if ( is_multisite() && $network_wide ) {
583 global $wpdb;
584 $currentblog = $wpdb->blogid;
585 $activated = array();
586 $sql = "SELECT blog_id FROM {$wpdb->blogs}";
587 $blog_ids = $wpdb->get_col( $wpdb->prepare( $sql, null ) );
588
589 foreach ( $blog_ids as $blog_id ) {
590 switch_to_blog( $blog_id );
591 $this->wpgmp_activation();
592 $activated[] = $blog_id;
593 }
594 switch_to_blog( $currentblog );
595
596 } else {
597 $this->wpgmp_activation();
598 }
599 }
600 /**
601 * Call hook on plugin deactivation for both multi-site and single-site.
602 */
603 function wpgmp_plugin_deactivation() {
604
605 if ( is_multisite() && $network_wide ) {
606 global $wpdb;
607 $currentblog = $wpdb->blogid;
608 $activated = array();
609 $sql = "SELECT blog_id FROM {$wpdb->blogs}";
610 $blog_ids = $wpdb->get_col( $wpdb->prepare( $sql, null ) );
611
612 foreach ( $blog_ids as $blog_id ) {
613 switch_to_blog( $blog_id );
614 $this->wpgmp_deactivation();
615 $activated[] = $blog_id;
616 }
617
618 switch_to_blog( $currentblog );
619
620 } else {
621 $this->wpgmp_deactivation();
622 }
623 }
624
625 /**
626 * Perform tasks on new blog create and table install.
627 */
628
629 function wpgmp_on_blog_new_generate( $blog_id, $user_id, $domain, $path, $site_id, $meta ){
630
631 if ( is_plugin_active_for_network( plugin_basename(__FILE__) ) ) {
632 switch_to_blog( $blog_id );
633 $this->wpgmp_activation();
634 restore_current_blog();
635 }
636
637 }
638
639 /**
640 * Perform tasks on when blog deleted and remove plugin tables.
641 */
642
643 function wpgmp_on_blog_delete( $tables ){
644
645 global $wpdb;
646 $tables[] = str_replace( $wpdb->base_prefix, $wpdb->prefix, TBL_LOCATION );
647 $tables[] = str_replace( $wpdb->base_prefix, $wpdb->prefix, TBL_GROUPMAP );
648 $tables[] = str_replace( $wpdb->base_prefix, $wpdb->prefix, TBL_MAP );
649 $tables[] = str_replace( $wpdb->base_prefix, $wpdb->prefix, TBL_ROUTES );
650 $tables[] = str_replace( $wpdb->base_prefix, $wpdb->prefix, TBL_BACKUPS );
651 return $tables;
652
653 }
654 /**
655 * Create choose icon tab in media manager.
656 * @param array $tabs Current Tabs.
657 * @return array New Tabs.
658 */
659 function wpgmp_google_map_tabs_filter($tabs) {
660
661 $newtab = array( 'ell_insert_gmap_tab' => esc_html__( 'Choose Icons', 'wp-google-map-plugin' ) );
662 return array_merge( $tabs, $newtab );
663 }
664 /**
665 * Intialize wp_iframe for icons tab
666 * @return [type] [description]
667 */
668 function wpgmp_google_map_media_upload_tab() {
669
670 wp_enqueue_style( 'marker-listing-styling', WPGMP_CSS.'marker-category-style.css' );
671 wp_enqueue_script( 'marker-listing-script', WPGMP_JS.'marker-category-script.js');
672 return wp_iframe( array( $this, 'media_wpgmp_google_map_icon' ), array() );
673 }
674
675 /**
676 * Read images/icons folder.
677 */
678 function media_wpgmp_google_map_icon() {
679
680 wp_enqueue_style( 'media' );
681 media_upload_header();
682 $form_action_url = site_url( "wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=ell_insert_gmap_tab", 'admin' );
683 ?>
684
685 <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr( $form_action_url ); ?>" class="media-upload-form marker-choose-form" id="library-form">
686 <h3 class="media-title"><?php esc_html_e( 'Choose icon', 'wp-google-map-plugin' ) ?></h3>
687 <input name="wpgmp_search_icon" id="wpgmp_search_icon" type='text' value="" placeholder="<?php esc_html_e( 'Search icons','wp-google-map-plugin' ); ?>" />
688 <div class="select_icons_container">
689 <ul id="select_icons">
690 <?php
691 $dir = WPGMP_ICONS_DIR;
692 $file_display = array( 'jpg', 'jpeg', 'png', 'gif' );
693
694 if ( file_exists( $dir ) == false ) {
695 echo 'Directory \'', $dir, '\' not found!';
696
697 } else {
698 $dir_contents = scandir( $dir );
699 foreach ( $dir_contents as $file ) {
700 $image_data = explode( '.', $file );
701 $file_type = strtolower( end( $image_data ) );
702 if ( '.' !== $file && '..' !== $file && true == in_array( $file_type, $file_display ) ) {
703 ?>
704 <li class="read_icons">
705 <img alt="<?php echo esc_attr($image_data[0]); ?>" title="<?php echo esc_attr($image_data[0]); ?>" src="<?php echo esc_url(WPGMP_ICONS.$file); ?>"/>
706 </li>
707 <?php
708 }
709 }
710 }
711 if(isset($_GET['target']))
712 $target = sanitize_key($_GET['target']);
713 ?>
714 </ul>
715 <button type="button" class="button set_marker_cat_button" data-message="<?php esc_html_e( 'Please choose marker icon for the category.','wp-google-map-plugin' ); ?>" data-target="<?php echo esc_attr($target); ?>" value="1" onclick="add_icon_to_images();" name="send[<?php echo esc_attr($picid) ?>]"><?php esc_html_e( 'Insert into Post', 'wp-google-map-plugin' ) ?>
716 </button>
717 </div>
718 </form>
719 <?php
720 }
721
722 function wpgmp_hide_buy_notice(){
723
724 $nonce = $_REQUEST['ajaxnonce'];
725 if ( !isset($_REQUEST['ajaxnonce']) ||
726 ! wp_verify_nonce( $nonce, 'fc_communication' ) ||
727 !current_user_can('manage_options') ) {
728
729 $result = array('status' => '0');
730
731 } else {
732 $data = unserialize(get_option('wpgmp_ignore_buy_pro'));
733 $data['wpgmp_hide_buy_notice'] = 'true';
734 update_option('wpgmp_ignore_buy_pro', serialize($data));
735 $result = array('status' => '1');
736 }
737
738 echo json_encode($result);
739 exit;
740 }
741
742 function wpgmp_show_buynow_notice($pluginheader){
743
744 if( isset($_GET['page']) && !empty($_GET['page']) && strpos( sanitize_key( $_GET['page'] ), 'wpgmp' ) !== false ){
745
746 $ignore = unserialize(get_option('wpgmp_ignore_buy_pro'));
747
748 if(isset($ignore['wpgmp_hide_buy_notice']) && !empty($ignore['wpgmp_hide_buy_notice'])){}
749 else {
750
751 $premium_plugin = '<a target="_blank" href="https://www.wpmapspro.com/?utm_source=wordpress&utm_medium=liteversion&utm_campaign=freemium&utm_id=freemium">'.esc_html__('Pro','wp-google-map-plugin').'</a>';
752
753 $pluginheader .= '<div class="flippercode-ui">
754 <div class="fc-main"><div class="buy_premium notice notice-success is-dismissible">'.sprintf( esc_html__('Upgrade hassle-free to %s version & unlock listing, routes, directions, filtration, drawing & many more features.','wp-google-map-plugin' ), $premium_plugin).' <a class="buy_now_link" href="https://www.wpmapspro.com/?utm_source=wordpress&utm_medium=liteversion&utm_campaign=freemium&utm_id=freemium" target="_blank">'.esc_html__('Upgrade Now','wp-google-map-plugin').'</a> or <a onclick="return false;" class="fc_ignore_notice hide_buy_notice" href="#">'.esc_html('Don\'t show again','wp-google-map-plugin').'</a></div></div></div>';
755 }
756 }
757
758 return $pluginheader;
759
760 }
761
762 function wpgmp_hide_sample_notice()
763 {
764
765 $nonce = $_REQUEST['ajaxnonce'];
766 if (
767 !isset($_REQUEST['ajaxnonce']) ||
768 !wp_verify_nonce($nonce, 'fc_communication') ||
769 !current_user_can('manage_options')
770 ) {
771
772 $result = array('status' => '0');
773 } else {
774 $data = unserialize(get_option('wpgmp_ignore_buy_pro'));
775 $data['wpgmp_hide_sample_notice'] = 'true';
776 update_option('wpgmp_ignore_buy_pro', serialize($data));
777 $result = array('status' => '1');
778 }
779
780 echo json_encode($result);
781 exit;
782 }
783
784 function admin_notice_html(){
785 ?>
786 <div class="flippercode-ui">
787 <div class="fc-main">
788 <div class="notice notice-info is-dismissible sample_notice fcdoc-body" >
789 <div class="notice_b">
790 <img src="<?php echo WPGMP_IMAGES; ?>/google-maps-128x128.png" alt="" width="86px" height="86px">
791 <div class="notice_b_inner">
792 <h3><?php esc_html_e('WP Maps','wp-google-map-plugin'); ?></h3>
793 <p><?php esc_html_e('Hello, we at ','wp-google-map-plugin'); ?><strong>flippercode.com</strong> <?php esc_html_e('would like to thank you for using our plugin. We would really appreciate if you could take a moment to drop a quick review that will inspire us to keep going.','wp-google-map-plugin'); ?></p>
794
795 <div class="notice_btn_b">
796 <a href="https://wordpress.org/plugins/wp-google-map-plugin/#reviews" class="button button-primary" target="_blank"><?php esc_html_e('Review now','wp-google-map-plugin'); ?></a>
797 <button class="button hide_sample_notice"><?php esc_html_e('Never show again','wp-google-map-plugin'); ?></button>
798 </div>
799 </div>
800 </div>
801 </div>
802 </div>
803 </div>
804 <?php
805 }
806 function wpgmp_show_sample_admin_notice__info(){
807
808 if (isset($_GET['page']) && !empty($_GET['page']) && strpos(sanitize_key($_GET['page']), 'wpgmp') !== false) {
809
810 $ignore = unserialize(get_option('wpgmp_ignore_buy_pro'));
811
812 if(isset($ignore['wpgmp_hide_sample_notice']) && !empty($ignore['wpgmp_hide_sample_notice']) && $ignore['wpgmp_hide_sample_notice'] == 'true')
813 return;
814
815 if(isset($ignore['wpgmp_show_sample_notice_time']) && !empty($ignore['wpgmp_show_sample_notice_time'])){
816
817 if( date('Y-m-d') >= $ignore['wpgmp_show_sample_notice_time'] ){
818 $this->admin_notice_html();
819 }
820 }
821
822 }
823 }
824
825 /**
826 * Perform tasks on plugin deactivation.
827 */
828 function wpgmp_deactivation() {}
829
830 /**
831 * Perform tasks on plugin deactivation.
832 */
833 function wpgmp_activation() {
834
835 global $wpdb;
836
837 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
838
839 $modules = $this->modules;
840 $pagehooks = array();
841 if ( is_array( $modules ) ) {
842 foreach ( $modules as $module ) {
843 $object = new $module;
844 if ( method_exists( $object,'install' ) ) {
845 $tables[] = $object->install();
846 }
847 }
848 }
849
850 if ( is_array( $tables ) ) {
851 foreach ( $tables as $i => $sql ) {
852 dbDelta( $sql );
853 }
854 }
855
856 $data = unserialize(get_option('wpgmp_ignore_buy_pro'));
857 if( !isset($data['wpgmp_show_sample_notice_time']) || empty($data['wpgmp_show_sample_notice_time'])){
858 $data['wpgmp_show_sample_notice_time'] = date('Y-m-d', strtotime('+3days'));
859 update_option('wpgmp_ignore_buy_pro', serialize($data));
860 }
861
862 }
863
864 function wpgmp_add_modals() {
865
866 $screen = get_current_screen();
867 if(isset($screen) && !empty($screen) ){
868
869 if( $screen->id == 'wp-maps_page_wpgmp_manage_location' ||
870 $screen->id == 'wp-maps_page_wpgmp_manage_group_map'||
871 $screen->id == 'wp-maps_page_wpgmp_manage_map' ){
872 include_once( WPGMP_DIR.'inc/modals/delete.php' );
873 include_once( WPGMP_DIR.'inc/modals/delete-bulk.php' );
874 echo $modal_html_delete;
875 echo $modal_html_bulk_delete;
876 }
877 }
878
879 }
880 /**
881 * Define all constants.
882 */
883 private function wpgmp_define_constants() {
884
885 global $wpdb;
886
887 if ( ! defined( 'WPGMP_SLUG' ) )
888 define( 'WPGMP_SLUG', 'wpgmp_view_overview' );
889
890 if ( ! defined( 'WPGMP_VERSION' ) )
891 define( 'WPGMP_VERSION', '4.4.8' );
892
893 if ( ! defined( 'WPGMP_FOLDER' ) )
894 define( 'WPGMP_FOLDER', basename( dirname( __FILE__ ) ) );
895
896 if ( ! defined( 'WPGMP_DIR' ) )
897 define( 'WPGMP_DIR', plugin_dir_path( __FILE__ ) );
898
899 if ( ! defined( 'WPGMP_ICONS_DIR' ) )
900 define( 'WPGMP_ICONS_DIR', WPGMP_DIR.'/assets/images/icons/' );
901
902 if ( ! defined( 'WPGMP_CORE_CLASSES' ) )
903 define( 'WPGMP_CORE_CLASSES', WPGMP_DIR.'core/' );
904
905 if ( ! defined( 'WPGMP_PLUGIN_CLASSES' ) )
906 define( 'WPGMP_PLUGIN_CLASSES', WPGMP_DIR . 'classes/' );
907
908 if ( ! defined( 'WPGMP_TEMPLATES' ) )
909 define( 'WPGMP_TEMPLATES', WPGMP_DIR . 'templates/' );
910
911 if ( ! defined( 'WPGMP_MODEL' ) )
912 define( 'WPGMP_MODEL', WPGMP_DIR . 'modules/' );
913
914 if ( ! defined( 'WPGMP_CONTROLLER' ) )
915 define( 'WPGMP_CONTROLLER', WPGMP_CORE_CLASSES );
916
917 if ( ! defined( 'WPGMP_CORE_CONTROLLER_CLASS' ) )
918 define( 'WPGMP_CORE_CONTROLLER_CLASS', WPGMP_CORE_CLASSES.'class.controller.php' );
919
920 if ( ! defined( 'WPGMP_MODEL' ) )
921 define( 'WPGMP_MODEL', WPGMP_DIR.'modules/' );
922
923 if ( ! defined( 'WPGMP_URL' ) )
924 define( 'WPGMP_URL', plugin_dir_url( WPGMP_FOLDER ).WPGMP_FOLDER.'/' );
925
926 if ( ! defined( 'WPGMP_CSS' ) )
927 define( 'WPGMP_CSS', WPGMP_URL.'assets/css/' );
928
929 if ( ! defined( 'WPGMP_TEMPLATES_URL' ) )
930 define( 'WPGMP_TEMPLATES_URL', WPGMP_URL.'templates/' );
931
932 if ( ! defined( 'WPGMP_JS' ) )
933 define( 'WPGMP_JS', WPGMP_URL.'assets/js/' );
934
935 if ( ! defined( 'WPGMP_IMAGES' ) )
936 define( 'WPGMP_IMAGES', WPGMP_URL.'assets/images/' );
937
938 if ( ! defined( 'WPGMP_ICONS' ) )
939 define( 'WPGMP_ICONS', WPGMP_URL.'assets/images/icons/' );
940
941 if ( ! defined( 'TBL_LOCATION' ) )
942 define( 'TBL_LOCATION', $wpdb->prefix.'map_locations' );
943
944 if ( ! defined( 'TBL_GROUPMAP' ) )
945 define( 'TBL_GROUPMAP', $wpdb->prefix.'group_map' );
946
947 if ( ! defined( 'TBL_MAP' ) )
948 define( 'TBL_MAP', $wpdb->prefix.'create_map' );
949
950 if ( ! defined( 'TBL_ROUTES' ) )
951 define( 'TBL_ROUTES', $wpdb->prefix.'map_routes' );
952
953 if ( ! defined( 'WPGMP_PRO_IMAGES' ) )
954 define( 'WPGMP_PRO_IMAGES', WPGMP_URL.'assets/images/pro/' );
955
956 if ( ! defined( 'WPGMP_PREMIUM_LINK' ) )
957 define( 'WPGMP_PREMIUM_LINK', '<a href="javascript:void(0);" class="get_pro">'.esc_html__('PRO', 'wp-google-map-plugin').'</a>' );
958
959 }
960 /**
961 * Load all required core classes.
962 */
963 private function wpgmp_load_files() {
964
965
966 $coreInitialisationFile = plugin_dir_path( __FILE__ ).'core/class.initiate-core.php';
967 if ( file_exists( $coreInitialisationFile ) ) {
968 require_once( $coreInitialisationFile );
969 }
970
971 //Load Plugin Files
972 $plugin_files_to_include = array('wpgmp-check-cookies.php','wpgmp-template.php','wpgmp-controller.php',
973 'wpgmp-model.php','class.map-widget.php');
974 foreach ( $plugin_files_to_include as $file ) {
975
976 if(file_exists(WPGMP_PLUGIN_CLASSES . $file))
977 require_once( WPGMP_PLUGIN_CLASSES . $file );
978 }
979 // Load all modules.
980 $core_modules = array( 'overview','group_map','location','map','settings','route','drawing', 'permissions', 'tools','extentions' );
981 if ( is_array( $core_modules ) ) {
982 foreach ( $core_modules as $module ) {
983
984 $file = WPGMP_MODEL.$module.'/model.'.$module.'.php';
985
986 if ( file_exists( $file ) ) {
987 include_once( $file );
988 $class_name = 'WPGMP_Model_'.ucwords( $module );
989 array_push( $this->modules, $class_name );
990 }
991 }
992 }
993
994 }
995 }
996 }
997
998 new FC_Google_Maps_Lite();
999