forked from Fitoussi/geo-my-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeo-my-wp.php
executable file
·666 lines (528 loc) · 24 KB
/
geo-my-wp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
<?php
/*
Plugin Name: GEO my WP
Plugin URI: http://www.geomywp.com
Description: Add location to any post types, pages or members (using Buddypress) and create an advance proximity search forms.
Version: 2.5
Author: Eyal Fitoussi
Author URI: http://www.geomywp.com
License: GPLv2
Text Domain: GMW
Domain Path: /languages/
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) )
exit;
/**
* GEO my WP class.
*/
class GEO_my_WP {
/**
* @var GEO my WP
*
* @since 2.4
*/
private static $instance;
/**
* GEO my WP settings from database
*
* @access private
*/
private $settings;
/**
* GEO my WP forms from database
*
* @access private
*/
private $forms;
/**
* Main Instance
*
* Insures that only one instance of GEO_my_WP exists in memory at any one
* time.
*
* @since 2.4
* @static
* @staticvar array $instance
* @return GEO_my_WP
*/
public static function instance() {
if ( !isset( self::$instance ) && !( self::$instance instanceof GEO_my_WP ) ) {
self::$instance = new GEO_my_WP;
self::$instance->constants();
self::$instance->includes();
self::$instance->actions();
self::$instance->load_textdomain();
}
return self::$instance;
}
/**
* A dummy constructor to prevent GEO my WP from being loaded more than once.
*
* @since 2.4
*/
private function __construct() {
$this->settings = get_option( 'gmw_options' );
$this->forms = get_option( 'gmw_forms' );
}
/**
* Setup plugin constants
*
* @access private
* @since 2.4
* @return void
*/
private function constants() {
// Define constants
if ( !defined( 'GMW_REMOTE_SITE_URL' ) )
define( 'GMW_REMOTE_SITE_URL', 'https://geomywp.com' );
define( 'GMW_VERSION', '2.5' );
define( 'GMW_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
define( 'GMW_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
define( 'GMW_IMAGES', GMW_URL . '/assets/images' );
define( 'GMW_AJAX' , get_bloginfo( 'wpurl' ) . '/wp-admin/admin-ajax.php' );
define( 'GMW_FILE', __FILE__ );
define( 'GMW_BASENAME', plugin_basename( GMW_FILE ) );
}
/**
* Include files
*
* @since 2.4
*
*/
public function includes() {
include_once( 'includes/geo-my-wp-deprecated-functions.php' );
//include admin files
if ( is_admin() && !defined( 'DOING_AJAX' ) ) {
include( GMW_PATH . '/includes/admin/geo-my-wp-admin.php' );
include( GMW_PATH . '/includes/admin/geo-my-wp-updater.php' );
include( GMW_PATH . '/includes/admin/geo-my-wp-license-handler.php' );
}
//include files in front-end
if ( !is_admin() || defined( 'DOING_AJAX' ) ) {
include( 'includes/geo-my-wp-gmw-class.php' );
include( 'includes/geo-my-wp-template-functions.php' );
include( 'includes/geo-my-wp-shortcodes.php' );
}
///load posts locator add-on
if ( GEO_my_WP::gmw_check_addon( 'posts' ) ) {
include_once GMW_PATH . '/plugins/posts/connect.php';
}
//include widgets
include_once GMW_PATH . '/includes/geo-my-wp-widgets.php';
}
/**
* Actions
*
* @since 2.4
*/
public function actions() {
//initiate add-ons hook
add_filter( 'gmw_admin_addons_page', array( $this, 'addons_init' ), 10 );
//include scripts in the front end
add_action( 'wp_enqueue_scripts', array( $this, 'frontend_register_scripts' ), 10 );
add_filter( 'clean_url', array( $this, 'clean_google_url' ), 99, 3 );
//main gmw shortcode
add_shortcode( 'gmw', array( $this, 'gmw' ) );
//map styles
add_action( 'wp_footer', array( $this, 'maps_options' ), 5 );
//google places autocomplete
add_action( 'wp_footer', array( $this, 'google_places_address_autocomplete' ), 10 );
//init widgets
add_action( 'widgets_init', create_function( '', 'return register_widget( "GMW_Current_Location_Widget" );' ) );
add_action( 'widgets_init', create_function( '', 'return register_widget( "GMW_Search_Form_Widget" );' ) );
//load friends locator add-on
if ( GEO_my_WP::gmw_check_addon( 'friends' ) && class_exists( 'BuddyPress' ) ) {
add_action( 'bp_loaded', array( $this, 'members_locator_addon_init' ), 20 );
}
//include sweetdate theme functions when needed
$active_theme = wp_get_theme();
if ( $active_theme->get('Name') == 'Sweetdate' || $active_theme->get('Template') == 'Sweetdate' || $active_theme->get('Template') == 'sweetdate' ) {
add_action( 'bp_init', array( $this, 'sweetdate_init' ), 20 );
}
//add_action('wp_ajax_list_update_order', array( $this, 'order_list' ) );
}
//not ready yet. just a test...
/* function order_list(){
die(json_encode($_POST));
global $wp_logo_slider_images;
$list = $wp_logo_slider_images;
$new_order = $_POST['list_item'];
$new_list = array();
foreach( $new_order as $v ){
if ( isset( $list[$v] ) ){
$new_list[$v] = $list[$v];
}
}
die($new_list);
//update_option('wp_logo_slider_images',$new_list);
} */
/**
* Include addon function.
*
* @access public
* @return $addons
*/
public function addons_init( $addons ) {
$addons['posts'] = array(
'name' => 'posts',
'title' => __( 'Post Types Locator', 'GMW' ),
'version' => GMW_VERSION,
'item' => 'Post Types Locator',
'file' => GMW_PATH . '/plugins/posts/connect.php',
'folder' => 'posts',
'author' => 'Eyal Fitoussi',
'desc' => __( 'Add geo-location to Posts and pages. Create an advance proximity search forms to search for locations based on post types, categories, distance and more.', 'GMW' ),
'license' => false,
'image' => false,
'require' => array(),
);
$addons['friends'] = array(
'name' => 'friends',
'title' => __( 'Members Locator', 'GMW' ),
'version' => GMW_VERSION,
'item' => 'Members Locator',
'file' => GMW_PATH . '/plugins/friends/includes/gmw-fl-component.php',
'folder' => 'friends',
'author' => 'Eyal Fitoussi',
'desc' => __( 'Let the BuddyPress members of your site to add location to thier profile. Create an advance proximity search forms to search for members based on location, Xprofile Fields and more.', 'GMW' ),
'image' => false,
'license' => false,
'require' => array(
'Buddypress Plugin' => array( 'plugin_file' => 'buddypress/bp-loader.php', 'link' => 'http://buddypress.org' )
)
);
return $addons;
}
/**
* GMW function
* Check if addon is active
*
* @param unknown_type $addon
*/
public static function gmw_check_addon( $addon ) {
$addons = get_option( 'gmw_addons' );
if ( ( isset( $addons[$addon] ) && $addons[$addon] == 'active' ) && ( !isset( $_POST['gmw_premium_license'] ) ) ) {
return true;
} else {
return false;
}
}
/**
* Localization
*
* @access public
* @return void
*/
public function load_textdomain() {
load_plugin_textdomain( 'GMW', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* frontend_scripts function.
*
* @access public
* @return void
*/
public function frontend_register_scripts() {
$protocol = is_ssl() ? 'https' : 'http';
$googleApi = ( isset( $this->settings['general_settings']['google_api'] ) ) ? '&key=' . $this->settings['general_settings']['google_api'] : '';
$region = ( isset( $this->settings['general_settings']['country_code'] ) ) ? '®ion=' .$this->settings['general_settings']['country_code'] : '';
$language = ( isset( $this->settings['general_settings']['language_code'] ) ) ? '&language=' .$this->settings['general_settings']['language_code'] : '';
//register google maps api
if ( !wp_script_is( 'google-maps', 'registered' ) ) {
wp_register_script( 'google-maps', $protocol.'://maps.googleapis.com/maps/api/js?libraries=places'.$googleApi.$region.$language.'&sensor=false', array( 'jquery' ), false );
}
//enqueue google maps api
if ( !wp_script_is( 'google-maps', 'enqueued' ) ) {
wp_enqueue_script( 'google-maps' );
}
wp_enqueue_style( 'dashicons' );
wp_register_style( 'gmw-style', GMW_URL.'/assets/css/style.css' );
wp_enqueue_style( 'gmw-style' );
//enqueue gmw style and script
wp_register_script( 'gmw-js', GMW_URL.'/assets/js/gmw.min.js', array( 'jquery' ), GMW_VERSION, true );
wp_enqueue_script( 'gmw-js' );
wp_localize_script( 'gmw-js', 'gmwSettings', $this->settings );
wp_register_script( 'gmw-map', GMW_URL.'/assets/js/map.min.js', array( 'jquery' ), GMW_VERSION, true );
wp_register_script( 'gmw-google-autocomplete', GMW_URL.'/assets/js/googleAddressAutocomplete.js', array( 'jquery' ), GMW_VERSION, true );
//wp_register_script( 'chosen', GMW_URL . '/assets/js/chosen.jquery.min.js', array( 'jquery' ), GMW_VERSION, true );
//wp_register_style( 'chosen', GMW_URL . '/assets/css/chosen.min.css' );
//only register some JavsScript libraries
if ( !wp_script_is( 'gmw-infobox', 'registered' ) ) {
wp_register_script( 'gmw-infobox', GMW_URL . '/assets/js/infobox.min.js', array( 'jquery' ), GMW_VERSION, true );
$infobox_close_btn = $protocol.'://www.google.com/intl/en_us/mapfiles/close.gif';
wp_localize_script( 'gmw-infobox', 'closeButton', $infobox_close_btn );
}
if ( !wp_script_is( 'gmw-marker-clusterer', 'registered' ) ) {
wp_register_script( 'gmw-marker-clusterer', GMW_URL . '/assets/js/marker-clusterer.min.js', array( 'jquery' ), GMW_VERSION, true );
}
$cluster_image = $protocol.'://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m';
wp_localize_script( 'gmw-marker-clusterer', 'clusterImage', $cluster_image );
if ( !wp_script_is( 'gmw-marker-spiderfier', 'registered' ) ) {
wp_register_script( 'gmw-marker-spiderfier', GMW_URL . '/assets/js/marker-spiderfier.min.js', array( 'jquery' ), GMW_VERSION, true );
}
}
/**
* Load members locator add-on component
*
*/
function members_locator_addon_init() {
global $bp;
include_once GMW_PATH . '/plugins/friends/includes/gmw-fl-component.php';
$bp->gmw_location = new GMW_Location_Component;
}
/**
* GEO my WP main shortcode
* @param $params
*/
public function gmw( $params ) {
$_GET = apply_filters( 'gmw_modify_get_args', $_GET );
$elements = array( 'search_form', 'map', 'search_results', 'form' );
if ( empty( $params ) )
return;
//get the element type
$element = key( $params );
//make sure the element is lagit
if ( !in_array( $element, $elements ) || empty( $params[$element] ) )
return;
//get the form ID
$formId = $params[$element];
if ( $formId != 'results' ) {
if ( !is_numeric( $formId ) || empty( $this->forms[$formId] ) )
return;
$this->form = $this->forms[$formId];
$this->form['element_triggered'] = $element;
} elseif ( $formId == 'results' && !empty( $_GET['action'] ) && $_GET['action'] == "gmw_post" ) {
$this->form = $this->forms[$_GET['gmw_form']];
$this->form['element_triggered'] = 'results_page';
} else{
return;
}
//if results page is set
if ( !empty( $this->form['search_results']['results_page'] ) ) {
$this->form['search_results']['results_page'] = get_permalink( $this->form['search_results']['results_page'] );
//if this is a widget and results page is not set in the shorcode settings we will get the results page from the main settings
} elseif ( isset( $params['widget'] ) ) {
$this->form['search_results']['results_page'] = get_permalink( $this->settings['general_settings']['results_page'] );
} else {
$this->form['search_results']['results_page'] = false;
}
$this->form['params'] = $params;
$this->form['submitted'] = ( !empty( $_GET['action'] ) && $_GET['action'] == "gmw_post" ) ? true : false;
$this->form['page_load_results_trigger'] = ( !$this->form['submitted'] && !empty( $this->form['page_load_results']['all_locations'] ) ) ? true : false;
$this->form['auto_results_trigger'] = ( !$this->form['submitted'] && ( !empty( $this->form['search_results']['auto_search']['on'] ) || !empty( $this->form['search_results']['auto_all_results'] ) ) ) ? true : false;
$this->form['in_widget'] = ( !empty( $params['widget'] ) ) ? true : false;
$this->form['ul_address'] = ( !empty( $_COOKIE['gmw_address'] ) ) ? urldecode( $_COOKIE['gmw_address'] ) : false;
$this->form['ul_lat'] = ( !empty( $_COOKIE['gmw_lat'] ) ) ? urldecode( $_COOKIE['gmw_lat'] ) : false;
$this->form['ul_lng'] = ( !empty( $_COOKIE['gmw_lng'] ) ) ? urldecode( $_COOKIE['gmw_lng'] ) : false;
$this->form['ul_icon'] = ( !empty( $this->form['results_map']['your_location_icon'] ) ) ? $this->form['results_map']['your_location_icon'] : 'https://maps.google.com/mapfiles/ms/icons/blue-dot.png';
$this->form['region'] = ( !empty( $this->settings['general_settings']['country_code'] ) ) ? $this->settings['general_settings']['country_code'] : 'US';
$this->form['language'] = ( !empty( $this->settings['general_settings']['language_code'] ) ) ? $this->settings['general_settings']['language_code'] : 'EN';
$this->form['get_per_page'] = false;
$this->form['units_array'] = false;
$this->form['your_lat'] = false;
$this->form['your_lng'] = false;
$this->form['radius'] = false;
$this->form['org_address'] = false;
$this->form['paged'] = 0;
$this->form['per_page'] = -1;
$this->form['is_mobile'] = ( wp_is_mobile() ) ? true : false;
$this->form['gif_loader'] = GMW_URL.'/assets/images/gmw-loader.gif';
$this->form['map_loader'] = GMW_URL.'/assets/images/map-loader.gif';
$this->form['results'] = array();
//Get current page number
$paged = ( is_front_page() ) ? 'page' : 'paged';
$this->form['paged'] = ( get_query_var( $paged ) ) ? get_query_var( $paged ) : 1;
$this->form['labels'] = gmw_form_set_labels( $this->form );
//modify form values
$this->form = apply_filters( 'gmw_'.$this->form['prefix'].'_default_form_values' , $this->form );
ob_start();
do_action( 'gmw_'.$this->form['prefix'].'_shortcode_start', $this->form, $this->settings );
//display search form anywere on the page using the search_form shortcode
if ( !apply_filters( 'gmw_'.$this->form['ID'].'_search_form_disabled', false ) && ( $this->form['element_triggered'] == 'search_form' || $this->form['element_triggered'] == 'form' ) && !empty( $this->form['search_form']['form_template'] ) && $this->form['search_form']['form_template'] != 'no_form' ) {
do_action( 'gmw_' . $this->form['prefix'] . '_before_search_form', $this->form );
//display search form
gmw_search_form( $this->form );
do_action( 'gmw_' . $this->form['prefix'] . '_after_search_form', $this->form );
}
//display map using shortcode
if ( $this->form['element_triggered'] == 'map' ) {
if ( $this->form['submitted'] && $this->form['search_results']['display_map'] != "shortcode" )
return;
if ( $this->form['page_load_results_trigger'] && $this->form['page_load_results']['display_map'] != "shortcode" )
return;
if ( $this->form['auto_results_trigger'] && $this->form['search_results']['display_map'] != "shortcode" )
return;
do_action( 'gmw_' . $this->form['prefix'] . '_before_map', $this->form );
//display map
echo gmw_get_results_map( $this->form );
do_action( 'gmw_' . $this->form['prefix'] . '_after_map', $this->form );
}
//display results anywere on the page using the map shortcode
if ( !$this->form['in_widget'] && in_array( $this->form['element_triggered'], array( 'form', 'search_results', 'results_page' ) ) ) {
do_action( 'gmw_'.$this->form['prefix'].'_results_shortcode', $this->form );
do_action( 'gmw_results_shortcode', $this->form );
}
do_action( 'gmw_'.$this->form['prefix'].'_shortcode_end', $this->form );
$output_string = ob_get_contents();
ob_end_clean();
return $output_string;
}
/**
* make sure google maps API loads properly
* fix provided by user dfa327 http://wordpress.org/support/topic/google-maps-server-rejected-your-request-proposed-fix
* Thank you
*/
public function clean_google_url( $url, $original_url, $_context ) {
if ( strstr( $url, "googleapis.com" ) !== false ) {
$url = str_replace( "&", "&", $url ); // or $url = $original_url
}
return $url;
}
/**
* Sweetdate theme files
*
* @since 2.4
*
*/
public function sweetdate_init() {
//admin settings
if ( is_admin() && !defined( 'DOING_AJAX' ) ) {
include_once GMW_PATH . '/third-party/sweetdate/geo-my-wp-sd-admin.php';
}
//include members query only on members page
if ( bp_current_component() == 'members' ) {
include_once GMW_PATH . '/third-party/sweetdate/geo-my-wp-sd-class.php';
}
}
/**
* GMW function - Geocode address
* @since 1.0
* @author Eyal Fitoussi
* @author This function inspired by a script written by Pippin Williamson - Thank you
*/
public static function geocoder( $address, $force_refresh = false ) {
$address_hash = md5( $address );
$coordinates = get_transient( 'gmw_geocoded_'.$address_hash );
if ( $force_refresh || $coordinates === false ) {
$args = array( 'address' => urlencode( $address ), 'sensor' => 'false' );
$url = add_query_arg( $args, 'http://maps.googleapis.com/maps/api/geocode/json' );
$response = wp_remote_get( $url );
if( is_wp_error( $response ) )
return;
$data = wp_remote_retrieve_body( $response );
if( is_wp_error( $data ) )
return;
if ( $response['response']['code'] == 200 ) {
$data = json_decode( $data );
if ( $data->status === 'OK' ) {
$location['street'] = false;
$location['apt'] = false;
$location['city'] = false;
$location['state_short'] = false;
$location['state_long'] = false;
$location['zipcode'] = false;
$location['country_short'] = false;
$location['country_long'] = false;
$coordinates = $data->results[0]->geometry->location;
$location['lat'] = $coordinates->lat;
$location['lng'] = $coordinates->lng;
$location['formatted_address'] = (string) $data->results[0]->formatted_address;
$address_componenets = $data->results[0]->address_components;
foreach ($address_componenets as $ac) {
if ($ac->types[0] == 'street_number') {
$street_number = esc_attr($ac->long_name);
}
if ($ac->types[0] == 'route') {
$street_f = esc_attr( $ac->long_name );
if ( isset( $street_number ) && !empty( $street_number ) ) {
$location['street'] = $street_number . ' ' . $street_f;
} else {
$location['street'] = $street_f;
}
}
if ( $ac->types[0] == 'subpremise' ) {
$location['apt'] = esc_attr($ac->long_name);
}
if ( $ac->types[0] == 'locality' ) {
$location['city'] = esc_attr( $ac->long_name );
}
if ($ac->types[0] == 'administrative_area_level_1') {
$location['state_short'] = esc_attr($ac->short_name);
$location['state_long'] = esc_attr($ac->long_name);
}
if ($ac->types[0] == 'postal_code') {
$location['zipcode'] = esc_attr($ac->long_name);
}
if ($ac->types[0] == 'country') {
$location['country_short'] = esc_attr($ac->short_name);
$location['country_long'] = esc_attr($ac->long_name);
}
}
do_action( 'gmw_geocoded_location', $location );
// cache coordinates for 3 months
set_transient( 'gmw_geocoded_'.$address_hash, $location, 3600*24*30*3 );
} elseif ( $data->status === 'ZERO_RESULTS' ) {
return array( 'error' => __( 'The address entered could not be geocoded.', 'GMW' ) );
} elseif ( $data->status === 'INVALID_REQUEST' ) {
return array( 'error' => __( 'Invalid request. Did you enter an address?', 'GMW' ) );
} elseif ( $data->status === 'OVER_QUERY_LIMIT' ) {
return array( 'error' => __( 'Something went wrong while retrieving your location.', 'GMW' ) . '<span style="display:none">OVER_QUERY_LIMIT</span>' );
} else {
return array( 'error' => __( 'Something went wrong while retrieving your location.', 'GMW' ) );
}
} else {
return array( 'error' => __( 'Unable to contact Google API service.', 'GMW' ) );
}
} else {
// return cached results
$location = $coordinates;
}
return $location;
}
public function maps_options( $id=false) {
//initiate map styles object
echo '<script>gmwMapOptions = {}; gmwMapObjects = {};</script>';
do_action( 'gmw_map_options' );
}
/**
* Gmw Google Places Address Autocomplete
*
* Will trigger Google Address autocomplete on input field
* use the filter to add the field ID of the field where you'd like to have autocomplete
*
* @since 2.5
* @author Eyal Fitoussi
*
*/
public static function google_places_address_autocomplete( $ac_fields=false ) {
if ( !$ac_fields ) {
//add field ID here
$ac_fields = apply_filters( 'gmw_google_places_address_autocomplete_fields', array() );
if ( empty( $ac_fields ) )
return;
wp_localize_script( 'gmw-google-autocomplete', 'gacFields', $ac_fields );
}
if ( !wp_script_is( 'gmw-google-autocomplete', 'enqueued') ) {
wp_enqueue_script( 'gmw-google-autocomplete' );
}
?>
<script>
jQuery(document).ready(function($) {
gmwGoogleAddressAutocomplete( JSON.parse('<?php echo json_encode( $ac_fields ); ?>') );
});
</script>
<?php
}
}
/**
* GMW Instance
*
* @since 1.1.1
* @return GEO my WP Instance
*/
function GMW() {
return GEO_my_WP::instance();
}
// Init GMW
GMW();