Test Failed
Push — master ( dc11f8...b6268a )
by Stiofan
54s
created
geodirectory_shortcodes.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -427,7 +427,7 @@
 block discarded – undo
427 427
         }
428 428
 
429 429
         return $output;
430
-    }else{
430
+    } else{
431 431
         ob_start();
432 432
         add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array
433 433
         add_action('the_post', 'create_list_jsondata'); // Add marker in json array
Please login to merge, or discard this patch.
Indentation   +909 added lines, -909 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 // If this file is called directly, abort.
9 9
 if (!defined('WPINC')) {
10
-    die;
10
+	die;
11 11
 }
12 12
 require_once('geodirectory-functions/shortcode_functions.php');
13 13
 
@@ -32,43 +32,43 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function geodir_sc_add_listing($atts)
34 34
 {
35
-    ob_start();
36
-    $defaults = array(
37
-        'pid' => '',
38
-        'listing_type' => 'gd_place',
39
-        'login_msg' => __('You must login to post.', 'geodirectory'),
40
-        'show_login' => false,
41
-    );
42
-    $params = shortcode_atts($defaults, $atts);
43
-
44
-    foreach ($params as $key => $value) {
45
-        $_REQUEST[$key] = $value;
46
-    }
47
-
48
-    $user_id = get_current_user_id();
49
-    if (!$user_id) {
50
-        echo $params['login_msg'];
51
-        if ($params['show_login']) {
52
-            echo "<br />";
53
-            $defaults = array(
54
-                'before_widget' => '',
55
-                'after_widget' => '',
56
-                'before_title' => '',
57
-                'after_title' => '',
58
-            );
59
-
60
-            geodir_loginwidget_output($defaults, $defaults);
61
-        }
62
-
63
-
64
-    } else {
65
-       // Add listing page will be used if shortcode is detected in page content, no need to call it here
66
-    }
67
-    $output = ob_get_contents();
68
-
69
-    ob_end_clean();
70
-
71
-    return $output;
35
+	ob_start();
36
+	$defaults = array(
37
+		'pid' => '',
38
+		'listing_type' => 'gd_place',
39
+		'login_msg' => __('You must login to post.', 'geodirectory'),
40
+		'show_login' => false,
41
+	);
42
+	$params = shortcode_atts($defaults, $atts);
43
+
44
+	foreach ($params as $key => $value) {
45
+		$_REQUEST[$key] = $value;
46
+	}
47
+
48
+	$user_id = get_current_user_id();
49
+	if (!$user_id) {
50
+		echo $params['login_msg'];
51
+		if ($params['show_login']) {
52
+			echo "<br />";
53
+			$defaults = array(
54
+				'before_widget' => '',
55
+				'after_widget' => '',
56
+				'before_title' => '',
57
+				'after_title' => '',
58
+			);
59
+
60
+			geodir_loginwidget_output($defaults, $defaults);
61
+		}
62
+
63
+
64
+	} else {
65
+	   // Add listing page will be used if shortcode is detected in page content, no need to call it here
66
+	}
67
+	$output = ob_get_contents();
68
+
69
+	ob_end_clean();
70
+
71
+	return $output;
72 72
 }
73 73
 
74 74
 /**
@@ -96,136 +96,136 @@  discard block
 block discarded – undo
96 96
  */
97 97
 function geodir_sc_home_map($atts)
98 98
 {
99
-    ob_start();
100
-    $defaults = array(
101
-        'width' => '960',
102
-        'height' => '425',
103
-        'maptype' => 'ROADMAP',
104
-        'zoom' => '13',
105
-        'autozoom' => '',
106
-        'child_collapse' => '0',
107
-        'scrollwheel' => '0',
99
+	ob_start();
100
+	$defaults = array(
101
+		'width' => '960',
102
+		'height' => '425',
103
+		'maptype' => 'ROADMAP',
104
+		'zoom' => '13',
105
+		'autozoom' => '',
106
+		'child_collapse' => '0',
107
+		'scrollwheel' => '0',
108 108
 		'marker_cluster' => false,
109
-        'latitude' => '',
110
-        'longitude' => ''
111
-    );
112
-
113
-    $params = shortcode_atts($defaults, $atts);
114
-
115
-    $params = gdsc_validate_map_args($params);
116
-
117
-    $map_args = array(
118
-        'map_canvas_name' => 'gd_home_map',
119
-        'latitude' => $params['latitude'],
120
-        'longitude' => $params['longitude'],
121
-
122
-        /**
123
-         * Filter the widget width of the map on home/listings page.
124
-         *
125
-         * @since 1.0.0
126
-         * @param mixed(string|int|float) $params['width'] The map width.
127
-         */
128
-        'width' => apply_filters('widget_width', $params['width']),
129
-        /**
130
-         * Filter the widget height of the map on home/listings page.
131
-         *
132
-         * @since 1.0.0
133
-         * @param mixed(string|int|float) $params['height'] The map height.
134
-         */
135
-        'height' => apply_filters('widget_heigh', $params['height']),
136
-        /**
137
-         * Filter the widget maptype of the map on home/listings page.
138
-         *
139
-         * @since 1.0.0
109
+		'latitude' => '',
110
+		'longitude' => ''
111
+	);
112
+
113
+	$params = shortcode_atts($defaults, $atts);
114
+
115
+	$params = gdsc_validate_map_args($params);
116
+
117
+	$map_args = array(
118
+		'map_canvas_name' => 'gd_home_map',
119
+		'latitude' => $params['latitude'],
120
+		'longitude' => $params['longitude'],
121
+
122
+		/**
123
+		 * Filter the widget width of the map on home/listings page.
124
+		 *
125
+		 * @since 1.0.0
126
+		 * @param mixed(string|int|float) $params['width'] The map width.
127
+		 */
128
+		'width' => apply_filters('widget_width', $params['width']),
129
+		/**
130
+		 * Filter the widget height of the map on home/listings page.
131
+		 *
132
+		 * @since 1.0.0
133
+		 * @param mixed(string|int|float) $params['height'] The map height.
134
+		 */
135
+		'height' => apply_filters('widget_heigh', $params['height']),
136
+		/**
137
+		 * Filter the widget maptype of the map on home/listings page.
138
+		 *
139
+		 * @since 1.0.0
140 140
 		 * @since 1.5.2 Added TERRAIN map type.
141
-         * @param string $params['maptype'] The map type. Can be ROADMAP | SATELLITE | HYBRID | TERRAIN.
142
-         */
143
-        'maptype' => apply_filters('widget_maptype', $params['maptype']),
144
-        /**
145
-         * Filter the widget scrollwheel value of the map on home/listings page.
146
-         *
147
-         * Should the scrollwheel zoom the map or not.
148
-         *
149
-         * @since 1.0.0
150
-         * @param bool $params['scrollwheel'] True to allow scroll wheel to scroll map or false if not.
151
-         */
152
-        'scrollwheel' => apply_filters('widget_scrollwheel', $params['scrollwheel']),
153
-        /**
154
-         * Filter the widget zoom level of the map on home/listings page.
155
-         *
156
-         * @since 1.0.0
157
-         * @param int $params['zoom'] The zoom level of the map. Between 1-19.
158
-         */
159
-        'zoom' => apply_filters('widget_zoom', $params['zoom']),
160
-        /**
161
-         * Filter the widget auto zoom value of the map on home/listings page.
162
-         *
163
-         * If the map should autozoom to fit the markers shown.
164
-         *
165
-         * @since 1.0.0
166
-         * @param bool $params['autozoom'] True if the map should autozoom, false if not.
167
-         */
168
-        'autozoom' => apply_filters('widget_autozoom', $params['autozoom']),
169
-        /**
170
-         * Filter the widget child_collapse value of the map on home/listings page.
171
-         *
172
-         * If the map should auto collapse the child categories if the category bar is present.
173
-         *
174
-         * @since 1.0.0
175
-         * @param bool $params['child_collapse'] True if the map should collapse the categories, false if not.
176
-         */
177
-        'child_collapse' => apply_filters('widget_child_collapse', $params['child_collapse']),
178
-        'enable_cat_filters' => true,
179
-        'enable_text_search' => true,
180
-        'enable_post_type_filters' => true,
181
-        /**
182
-         * Filter the widget enable_location_filters value of the map on home/listings page.
183
-         *
184
-         * This is used when the location addon is used.
185
-         *
186
-         * @since 1.0.0
187
-         * @param bool $val True if location filters should be used, false if not.
188
-         */
189
-        'enable_location_filters' => apply_filters('geodir_home_map_enable_location_filters', false),
190
-        'enable_jason_on_load' => false,
191
-        'enable_marker_cluster' => false,
192
-        'enable_map_resize_button' => true,
193
-        'map_class_name' => 'geodir-map-home-page',
194
-        'is_geodir_home_map_widget' => true,
195
-    );
141
+		 * @param string $params['maptype'] The map type. Can be ROADMAP | SATELLITE | HYBRID | TERRAIN.
142
+		 */
143
+		'maptype' => apply_filters('widget_maptype', $params['maptype']),
144
+		/**
145
+		 * Filter the widget scrollwheel value of the map on home/listings page.
146
+		 *
147
+		 * Should the scrollwheel zoom the map or not.
148
+		 *
149
+		 * @since 1.0.0
150
+		 * @param bool $params['scrollwheel'] True to allow scroll wheel to scroll map or false if not.
151
+		 */
152
+		'scrollwheel' => apply_filters('widget_scrollwheel', $params['scrollwheel']),
153
+		/**
154
+		 * Filter the widget zoom level of the map on home/listings page.
155
+		 *
156
+		 * @since 1.0.0
157
+		 * @param int $params['zoom'] The zoom level of the map. Between 1-19.
158
+		 */
159
+		'zoom' => apply_filters('widget_zoom', $params['zoom']),
160
+		/**
161
+		 * Filter the widget auto zoom value of the map on home/listings page.
162
+		 *
163
+		 * If the map should autozoom to fit the markers shown.
164
+		 *
165
+		 * @since 1.0.0
166
+		 * @param bool $params['autozoom'] True if the map should autozoom, false if not.
167
+		 */
168
+		'autozoom' => apply_filters('widget_autozoom', $params['autozoom']),
169
+		/**
170
+		 * Filter the widget child_collapse value of the map on home/listings page.
171
+		 *
172
+		 * If the map should auto collapse the child categories if the category bar is present.
173
+		 *
174
+		 * @since 1.0.0
175
+		 * @param bool $params['child_collapse'] True if the map should collapse the categories, false if not.
176
+		 */
177
+		'child_collapse' => apply_filters('widget_child_collapse', $params['child_collapse']),
178
+		'enable_cat_filters' => true,
179
+		'enable_text_search' => true,
180
+		'enable_post_type_filters' => true,
181
+		/**
182
+		 * Filter the widget enable_location_filters value of the map on home/listings page.
183
+		 *
184
+		 * This is used when the location addon is used.
185
+		 *
186
+		 * @since 1.0.0
187
+		 * @param bool $val True if location filters should be used, false if not.
188
+		 */
189
+		'enable_location_filters' => apply_filters('geodir_home_map_enable_location_filters', false),
190
+		'enable_jason_on_load' => false,
191
+		'enable_marker_cluster' => false,
192
+		'enable_map_resize_button' => true,
193
+		'map_class_name' => 'geodir-map-home-page',
194
+		'is_geodir_home_map_widget' => true,
195
+	);
196 196
 
197 197
 	// Add marker cluster
198 198
 	if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) {
199
-        $map_args['enable_marker_cluster'] = true;
200
-        if(get_option('geodir_marker_cluster_type')) {
201
-            if ($map_args['autozoom']) {
202
-                $map_args['enable_marker_cluster_no_reposition'] = false;
203
-            } else {
204
-                $map_args['enable_marker_cluster_no_reposition'] = true;
205
-            }
199
+		$map_args['enable_marker_cluster'] = true;
200
+		if(get_option('geodir_marker_cluster_type')) {
201
+			if ($map_args['autozoom']) {
202
+				$map_args['enable_marker_cluster_no_reposition'] = false;
203
+			} else {
204
+				$map_args['enable_marker_cluster_no_reposition'] = true;
205
+			}
206 206
 
207
-            $map_args['enable_marker_cluster_server'] = true ;
207
+			$map_args['enable_marker_cluster_server'] = true ;
208 208
 
209
-        }
209
+		}
210 210
 	} else {
211 211
 		$map_args['enable_marker_cluster'] = false;
212 212
 	}
213 213
 
214
-    // if lat and long set in shortcode, hack it so the map is not repositioned
215
-    if(!empty($params['latitude']) && !empty($params['longitude']) ){
216
-        $map_args['enable_marker_cluster_no_reposition'] = true;
217
-    }
214
+	// if lat and long set in shortcode, hack it so the map is not repositioned
215
+	if(!empty($params['latitude']) && !empty($params['longitude']) ){
216
+		$map_args['enable_marker_cluster_no_reposition'] = true;
217
+	}
218 218
 
219 219
 
220
-    geodir_draw_map($map_args);
220
+	geodir_draw_map($map_args);
221 221
 
222
-    add_action('wp_footer', 'geodir_home_map_add_script', 100);
222
+	add_action('wp_footer', 'geodir_home_map_add_script', 100);
223 223
 
224
-    $output = ob_get_contents();
224
+	$output = ob_get_contents();
225 225
 
226
-    ob_end_clean();
226
+	ob_end_clean();
227 227
 
228
-    return $output;
228
+	return $output;
229 229
 }
230 230
 add_shortcode('gd_homepage_map', 'geodir_sc_home_map');
231 231
 
@@ -264,218 +264,218 @@  discard block
 block discarded – undo
264 264
  */
265 265
 function geodir_sc_listing_map($atts) {
266 266
 
267
-    // if some params are set then we need a new query, if not then we can use the main query
268
-    if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) {
269
-
270
-        global $add_post_in_marker_array, $gd_sc_map_params;
271
-        $backup_globals                             = array();
272
-        $backup_globals['add_post_in_marker_array'] = $add_post_in_marker_array;
273
-        $backup_globals['gd_sc_map_params']         = $gd_sc_map_params;
274
-
275
-        $defaults = array(
276
-            'width'          => '294',
277
-            'height'         => '370',
278
-            'zoom'           => '13',
279
-            'autozoom'       => '',
280
-            'sticky'         => '',
281
-            'showall'        => '0',
282
-            'scrollwheel'    => '0',
283
-            'maptype'        => 'ROADMAP',
284
-            'child_collapse' => 0,
285
-            'marker_cluster' => false,
286
-            'post_type'      => 'gd_place',
287
-            'category'       => '0',
288
-            'event_type'     => 'all'
289
-        );
290
-
291
-        $params = shortcode_atts( $defaults, $atts );
292
-
293
-        if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) {
294
-            $params['post_type'] = 'gd_place';
295
-        }
296
-
297
-        // Validate the selected category/ies - Grab the current list based on post_type
298
-        $category_taxonomy = geodir_get_taxonomies( $params['post_type'] );
299
-        $categories        = get_terms( $category_taxonomy, array(
300
-            'orderby' => 'count',
301
-            'order'   => 'DESC',
302
-            'fields'  => 'ids'
303
-        ) );
304
-
305
-        // Make sure we have an array
306
-        if ( ! ( is_array( $params['category'] ) ) ) {
307
-            $params['category'] = explode( ',', $params['category'] );
308
-        }
309
-
310
-        // Array_intersect returns only the items in $params['category'] that are also in our category list
311
-        // Otherwise it becomes empty and later on that will mean "All"
312
-        $params['category'] = array_intersect( $params['category'], $categories );
313
-
314
-        if ( $params['post_type'] == 'gd_event' ) {
315
-            $params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] );
316
-        }
317
-
318
-        $params = gdsc_validate_map_args( $params );
319
-
320
-        $gd_sc_map_params = $params;
321
-
322
-        $query_args = array(
323
-            'posts_per_page' => 1000000, //@todo kiran why was this added? 
324
-            'is_geodir_loop' => true,
325
-            'gd_location'    => false,
326
-            'post_type'      => $params['post_type'],
327
-        );
328
-
329
-        if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) {
330
-            $category_taxonomy = geodir_get_taxonomies( $params['post_type'] );
331
-
332
-            ######### WPML #########
333
-            if ( geodir_wpml_is_taxonomy_translated( $category_taxonomy[0] ) ) {
334
-                $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] );
335
-            }
336
-            ######### WPML #########
337
-
338
-            $tax_query = array(
339
-                'taxonomy' => $category_taxonomy[0],
340
-                'field'    => 'id',
341
-                'terms'    => $params['category']
342
-            );
343
-
344
-            $query_args['tax_query'] = array( $tax_query );
345
-        }
346
-
347
-        $add_post_in_marker_array = true;
348
-
349
-        if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) {
350
-            global $geodir_event_widget_listview;
351
-            $geodir_event_widget_listview = true;
352
-
353
-            $query_args['geodir_event_type'] = $params['event_type'];
354
-
355
-            $listings = geodir_event_get_widget_events( $query_args );
356
-
357
-            $geodir_event_widget_listview = false;
358
-        } else {
359
-            $listings = geodir_get_widget_listings( $query_args );
360
-        }
361
-
362
-        if ( ! empty( $listings ) ) {
363
-            foreach ( $listings as $listing ) {
364
-                create_marker_jason_of_posts( $listing );
365
-            }
366
-        }
367
-
368
-        ob_start();
369
-        add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array
370
-
371
-        add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array
372
-
373
-        add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers
374
-
375
-        $default_location = geodir_get_default_location();
376
-
377
-        $map_args = array(
378
-            'map_canvas_name'          => 'gd_listing_map',
379
-            'width'                    => $params['width'],
380
-            'height'                   => $params['height'],
381
-            'zoom'                     => $params['zoom'],
382
-            'autozoom'                 => $params['autozoom'],
383
-            'sticky'                   => $params['sticky'],
384
-            'showall'                  => $params['showall'],
385
-            'scrollwheel'              => $params['scrollwheel'],
386
-            'maptype'                  => $params['maptype'],
387
-            'child_collapse'           => 0,
388
-            'enable_cat_filters'       => false,
389
-            'enable_text_search'       => false,
390
-            'enable_post_type_filters' => false,
391
-            'enable_location_filters'  => false,
392
-            'enable_jason_on_load'     => true,
393
-            'ajax_url'                 => geodir_get_ajax_url(),
394
-            'latitude'                 => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '',
395
-            'longitude'                => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '',
396
-            'streetViewControl'        => true,
397
-            'showPreview'              => '0',
398
-            'maxZoom'                  => 21,
399
-            'bubble_size'              => 'small',
400
-        );
401
-
402
-        if ( is_single() ) {
403
-            global $post;
404
-            if ( isset( $post->post_latitude ) ) {
405
-                $map_args['latitude']  = $post->post_latitude;
406
-                $map_args['longitude'] = $post->post_longitude;
407
-            }
408
-
409
-            $map_args['map_class_name'] = 'geodir-map-listing-page-single';
410
-        } else {
411
-            $map_args['map_class_name'] = 'geodir-map-listing-page';
412
-        }
413
-
414
-        // Add marker cluster
415
-        if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) {
416
-            $map_args['enable_marker_cluster'] = true;
417
-        } else {
418
-            $map_args['enable_marker_cluster'] = false;
419
-        }
420
-
421
-        geodir_draw_map( $map_args );
422
-
423
-        $output = ob_get_contents();
424
-
425
-        ob_end_clean();
426
-
427
-        foreach ( $backup_globals as $global => $value ) {
428
-            ${$global} = $value;
429
-        }
430
-
431
-        return $output;
432
-    }else{
433
-        ob_start();
434
-        add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array
435
-        add_action('the_post', 'create_list_jsondata'); // Add marker in json array
436
-        add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers
437
-        $defaults = array(
438
-            'width' => '294',
439
-            'height' => '370',
440
-            'zoom' => '13',
441
-            'autozoom' => '',
442
-            'sticky' => '',
443
-            'showall' => '0',
444
-            'scrollwheel' => '0',
445
-            'maptype' => 'ROADMAP',
446
-            'child_collapse' => 0,
447
-            'marker_cluster' => false
448
-        );
449
-        $params = shortcode_atts($defaults, $atts);
450
-        $params = gdsc_validate_map_args($params);
451
-        $map_args = array(
452
-            'map_canvas_name' => 'gd_listing_map',
453
-            'width' => $params['width'],
454
-            'height' => $params['height'],
455
-            'zoom' => $params['zoom'],
456
-            'autozoom' => $params['autozoom'],
457
-            'sticky' => $params['sticky'],
458
-            'showall' => $params['showall'],
459
-            'scrollwheel' => $params['scrollwheel'],
460
-            'child_collapse' => 0,
461
-            'enable_cat_filters' => false,
462
-            'enable_text_search' => false,
463
-            'enable_post_type_filters' => false,
464
-            'enable_location_filters' => false,
465
-            'enable_jason_on_load' => true,
466
-        );
467
-        if (is_single()) {
468
-            global $post;
469
-            $map_default_lat = $address_latitude = $post->post_latitude;
470
-            $map_default_lng = $address_longitude = $post->post_longitude;
471
-            $mapview = $post->post_mapview;
472
-            $map_args['zoom'] = $post->post_mapzoom;
473
-            $map_args['map_class_name'] = 'geodir-map-listing-page-single';
474
-        } else {
475
-            $default_location = geodir_get_default_location();
476
-            $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
477
-            $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
478
-            $map_args['map_class_name'] = 'geodir-map-listing-page';
267
+	// if some params are set then we need a new query, if not then we can use the main query
268
+	if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) {
269
+
270
+		global $add_post_in_marker_array, $gd_sc_map_params;
271
+		$backup_globals                             = array();
272
+		$backup_globals['add_post_in_marker_array'] = $add_post_in_marker_array;
273
+		$backup_globals['gd_sc_map_params']         = $gd_sc_map_params;
274
+
275
+		$defaults = array(
276
+			'width'          => '294',
277
+			'height'         => '370',
278
+			'zoom'           => '13',
279
+			'autozoom'       => '',
280
+			'sticky'         => '',
281
+			'showall'        => '0',
282
+			'scrollwheel'    => '0',
283
+			'maptype'        => 'ROADMAP',
284
+			'child_collapse' => 0,
285
+			'marker_cluster' => false,
286
+			'post_type'      => 'gd_place',
287
+			'category'       => '0',
288
+			'event_type'     => 'all'
289
+		);
290
+
291
+		$params = shortcode_atts( $defaults, $atts );
292
+
293
+		if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) {
294
+			$params['post_type'] = 'gd_place';
295
+		}
296
+
297
+		// Validate the selected category/ies - Grab the current list based on post_type
298
+		$category_taxonomy = geodir_get_taxonomies( $params['post_type'] );
299
+		$categories        = get_terms( $category_taxonomy, array(
300
+			'orderby' => 'count',
301
+			'order'   => 'DESC',
302
+			'fields'  => 'ids'
303
+		) );
304
+
305
+		// Make sure we have an array
306
+		if ( ! ( is_array( $params['category'] ) ) ) {
307
+			$params['category'] = explode( ',', $params['category'] );
308
+		}
309
+
310
+		// Array_intersect returns only the items in $params['category'] that are also in our category list
311
+		// Otherwise it becomes empty and later on that will mean "All"
312
+		$params['category'] = array_intersect( $params['category'], $categories );
313
+
314
+		if ( $params['post_type'] == 'gd_event' ) {
315
+			$params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] );
316
+		}
317
+
318
+		$params = gdsc_validate_map_args( $params );
319
+
320
+		$gd_sc_map_params = $params;
321
+
322
+		$query_args = array(
323
+			'posts_per_page' => 1000000, //@todo kiran why was this added? 
324
+			'is_geodir_loop' => true,
325
+			'gd_location'    => false,
326
+			'post_type'      => $params['post_type'],
327
+		);
328
+
329
+		if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) {
330
+			$category_taxonomy = geodir_get_taxonomies( $params['post_type'] );
331
+
332
+			######### WPML #########
333
+			if ( geodir_wpml_is_taxonomy_translated( $category_taxonomy[0] ) ) {
334
+				$category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] );
335
+			}
336
+			######### WPML #########
337
+
338
+			$tax_query = array(
339
+				'taxonomy' => $category_taxonomy[0],
340
+				'field'    => 'id',
341
+				'terms'    => $params['category']
342
+			);
343
+
344
+			$query_args['tax_query'] = array( $tax_query );
345
+		}
346
+
347
+		$add_post_in_marker_array = true;
348
+
349
+		if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) {
350
+			global $geodir_event_widget_listview;
351
+			$geodir_event_widget_listview = true;
352
+
353
+			$query_args['geodir_event_type'] = $params['event_type'];
354
+
355
+			$listings = geodir_event_get_widget_events( $query_args );
356
+
357
+			$geodir_event_widget_listview = false;
358
+		} else {
359
+			$listings = geodir_get_widget_listings( $query_args );
360
+		}
361
+
362
+		if ( ! empty( $listings ) ) {
363
+			foreach ( $listings as $listing ) {
364
+				create_marker_jason_of_posts( $listing );
365
+			}
366
+		}
367
+
368
+		ob_start();
369
+		add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array
370
+
371
+		add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array
372
+
373
+		add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers
374
+
375
+		$default_location = geodir_get_default_location();
376
+
377
+		$map_args = array(
378
+			'map_canvas_name'          => 'gd_listing_map',
379
+			'width'                    => $params['width'],
380
+			'height'                   => $params['height'],
381
+			'zoom'                     => $params['zoom'],
382
+			'autozoom'                 => $params['autozoom'],
383
+			'sticky'                   => $params['sticky'],
384
+			'showall'                  => $params['showall'],
385
+			'scrollwheel'              => $params['scrollwheel'],
386
+			'maptype'                  => $params['maptype'],
387
+			'child_collapse'           => 0,
388
+			'enable_cat_filters'       => false,
389
+			'enable_text_search'       => false,
390
+			'enable_post_type_filters' => false,
391
+			'enable_location_filters'  => false,
392
+			'enable_jason_on_load'     => true,
393
+			'ajax_url'                 => geodir_get_ajax_url(),
394
+			'latitude'                 => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '',
395
+			'longitude'                => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '',
396
+			'streetViewControl'        => true,
397
+			'showPreview'              => '0',
398
+			'maxZoom'                  => 21,
399
+			'bubble_size'              => 'small',
400
+		);
401
+
402
+		if ( is_single() ) {
403
+			global $post;
404
+			if ( isset( $post->post_latitude ) ) {
405
+				$map_args['latitude']  = $post->post_latitude;
406
+				$map_args['longitude'] = $post->post_longitude;
407
+			}
408
+
409
+			$map_args['map_class_name'] = 'geodir-map-listing-page-single';
410
+		} else {
411
+			$map_args['map_class_name'] = 'geodir-map-listing-page';
412
+		}
413
+
414
+		// Add marker cluster
415
+		if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) {
416
+			$map_args['enable_marker_cluster'] = true;
417
+		} else {
418
+			$map_args['enable_marker_cluster'] = false;
419
+		}
420
+
421
+		geodir_draw_map( $map_args );
422
+
423
+		$output = ob_get_contents();
424
+
425
+		ob_end_clean();
426
+
427
+		foreach ( $backup_globals as $global => $value ) {
428
+			${$global} = $value;
429
+		}
430
+
431
+		return $output;
432
+	}else{
433
+		ob_start();
434
+		add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array
435
+		add_action('the_post', 'create_list_jsondata'); // Add marker in json array
436
+		add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers
437
+		$defaults = array(
438
+			'width' => '294',
439
+			'height' => '370',
440
+			'zoom' => '13',
441
+			'autozoom' => '',
442
+			'sticky' => '',
443
+			'showall' => '0',
444
+			'scrollwheel' => '0',
445
+			'maptype' => 'ROADMAP',
446
+			'child_collapse' => 0,
447
+			'marker_cluster' => false
448
+		);
449
+		$params = shortcode_atts($defaults, $atts);
450
+		$params = gdsc_validate_map_args($params);
451
+		$map_args = array(
452
+			'map_canvas_name' => 'gd_listing_map',
453
+			'width' => $params['width'],
454
+			'height' => $params['height'],
455
+			'zoom' => $params['zoom'],
456
+			'autozoom' => $params['autozoom'],
457
+			'sticky' => $params['sticky'],
458
+			'showall' => $params['showall'],
459
+			'scrollwheel' => $params['scrollwheel'],
460
+			'child_collapse' => 0,
461
+			'enable_cat_filters' => false,
462
+			'enable_text_search' => false,
463
+			'enable_post_type_filters' => false,
464
+			'enable_location_filters' => false,
465
+			'enable_jason_on_load' => true,
466
+		);
467
+		if (is_single()) {
468
+			global $post;
469
+			$map_default_lat = $address_latitude = $post->post_latitude;
470
+			$map_default_lng = $address_longitude = $post->post_longitude;
471
+			$mapview = $post->post_mapview;
472
+			$map_args['zoom'] = $post->post_mapzoom;
473
+			$map_args['map_class_name'] = 'geodir-map-listing-page-single';
474
+		} else {
475
+			$default_location = geodir_get_default_location();
476
+			$map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
477
+			$map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
478
+			$map_args['map_class_name'] = 'geodir-map-listing-page';
479 479
 			if ( geodir_is_page( 'search' ) ) {
480 480
 				$map_default_lat = '';
481 481
 				$map_default_lng = '';
@@ -491,31 +491,31 @@  discard block
 block discarded – undo
491 491
 					}
492 492
 				}
493 493
 			}
494
-        }
495
-        if (empty($mapview)) {
496
-            $mapview = 'ROADMAP';
497
-        }
498
-        // Set default map options
499
-        $map_args['ajax_url'] = geodir_get_ajax_url();
500
-        $map_args['latitude'] = $map_default_lat;
501
-        $map_args['longitude'] = $map_default_lng;
502
-        $map_args['streetViewControl'] = true;
503
-        $map_args['maptype'] = $mapview;
504
-        $map_args['showPreview'] = '0';
505
-        $map_args['maxZoom'] = 21;
506
-        $map_args['bubble_size'] = 'small';
507
-
508
-        // Add marker cluster
509
-        if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) {
510
-            $map_args['enable_marker_cluster'] = true;
511
-        } else {
512
-            $map_args['enable_marker_cluster'] = false;
513
-        }
514
-        geodir_draw_map($map_args);
515
-        $output = ob_get_contents();
516
-        ob_end_clean();
517
-        return $output;
518
-    }
494
+		}
495
+		if (empty($mapview)) {
496
+			$mapview = 'ROADMAP';
497
+		}
498
+		// Set default map options
499
+		$map_args['ajax_url'] = geodir_get_ajax_url();
500
+		$map_args['latitude'] = $map_default_lat;
501
+		$map_args['longitude'] = $map_default_lng;
502
+		$map_args['streetViewControl'] = true;
503
+		$map_args['maptype'] = $mapview;
504
+		$map_args['showPreview'] = '0';
505
+		$map_args['maxZoom'] = 21;
506
+		$map_args['bubble_size'] = 'small';
507
+
508
+		// Add marker cluster
509
+		if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) {
510
+			$map_args['enable_marker_cluster'] = true;
511
+		} else {
512
+			$map_args['enable_marker_cluster'] = false;
513
+		}
514
+		geodir_draw_map($map_args);
515
+		$output = ob_get_contents();
516
+		ob_end_clean();
517
+		return $output;
518
+	}
519 519
 }
520 520
 
521 521
 add_shortcode('gd_listing_slider', 'geodir_sc_listing_slider');
@@ -548,120 +548,120 @@  discard block
 block discarded – undo
548 548
  */
549 549
 function geodir_sc_listing_slider($atts)
550 550
 {
551
-    ob_start();
552
-    $defaults = array(
553
-        'post_type' => 'gd_place',
554
-        'category' => '0',
555
-        'post_number' => '5',
556
-        'slideshow' => '0',
557
-        'animation_loop' => 0,
558
-        'direction_nav' => 0,
559
-        'slideshow_speed' => 5000,
560
-        'animation_speed' => 600,
561
-        'animation' => 'slide',
562
-        'order_by' => 'latest',
563
-        'show_title' => '',
564
-        'show_featured_only' => '',
565
-        'title' => '',
566
-    );
567
-
568
-    $params = shortcode_atts($defaults, $atts);
569
-
570
-
571
-    /*
551
+	ob_start();
552
+	$defaults = array(
553
+		'post_type' => 'gd_place',
554
+		'category' => '0',
555
+		'post_number' => '5',
556
+		'slideshow' => '0',
557
+		'animation_loop' => 0,
558
+		'direction_nav' => 0,
559
+		'slideshow_speed' => 5000,
560
+		'animation_speed' => 600,
561
+		'animation' => 'slide',
562
+		'order_by' => 'latest',
563
+		'show_title' => '',
564
+		'show_featured_only' => '',
565
+		'title' => '',
566
+	);
567
+
568
+	$params = shortcode_atts($defaults, $atts);
569
+
570
+
571
+	/*
572 572
      *
573 573
      * Now we begin the validation of the attributes.
574 574
      */
575
-    // Check we have a valid post_type
576
-    if (!(gdsc_is_post_type_valid($params['post_type']))) {
577
-        $params['post_type'] = 'gd_place';
578
-    }
579
-
580
-    // Check we have a valid sort_order
581
-    $params['order_by'] = gdsc_validate_sort_choice($params['order_by']);
582
-
583
-    // Match the chosen animation to our options
584
-    $animation_list = array('slide', 'fade');
585
-    if (!(in_array($params['animation'], $animation_list))) {
586
-        $params['animation'] = 'slide';
587
-    }
588
-
589
-    // Post_number needs to be a positive integer
590
-    $params['post_number'] = absint($params['post_number']);
591
-    if (0 == $params['post_number']) {
592
-        $params['post_number'] = 1;
593
-    }
594
-
595
-    // Manage the entered categories
596
-    if (0 != $params['category'] || '' != $params['category']) {
597
-        $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']);
598
-    }
599
-    // Convert show_title to a bool
600
-    $params['show_title'] = intval(gdsc_to_bool_val($params['show_title']));
601
-
602
-    // Convert show_featured_only to a bool
603
-    $params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only']));
604
-
605
-    /*
575
+	// Check we have a valid post_type
576
+	if (!(gdsc_is_post_type_valid($params['post_type']))) {
577
+		$params['post_type'] = 'gd_place';
578
+	}
579
+
580
+	// Check we have a valid sort_order
581
+	$params['order_by'] = gdsc_validate_sort_choice($params['order_by']);
582
+
583
+	// Match the chosen animation to our options
584
+	$animation_list = array('slide', 'fade');
585
+	if (!(in_array($params['animation'], $animation_list))) {
586
+		$params['animation'] = 'slide';
587
+	}
588
+
589
+	// Post_number needs to be a positive integer
590
+	$params['post_number'] = absint($params['post_number']);
591
+	if (0 == $params['post_number']) {
592
+		$params['post_number'] = 1;
593
+	}
594
+
595
+	// Manage the entered categories
596
+	if (0 != $params['category'] || '' != $params['category']) {
597
+		$params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']);
598
+	}
599
+	// Convert show_title to a bool
600
+	$params['show_title'] = intval(gdsc_to_bool_val($params['show_title']));
601
+
602
+	// Convert show_featured_only to a bool
603
+	$params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only']));
604
+
605
+	/*
606 606
      * Hopefully all attributes are now valid, and safe to pass forward
607 607
      */
608 608
 
609
-    // redeclare vars after validation
610
-
611
-    if (isset($params['direction_nav'])) {
612
-        $params['directionNav'] = $params['direction_nav'];
613
-    }
614
-    if (isset($params['animation_loop'])) {
615
-        $params['animationLoop'] = $params['animation_loop'];
616
-    }
617
-    if (isset($params['slideshow_speed'])) {
618
-        $params['slideshowSpeed'] = $params['slideshow_speed'];
619
-    }
620
-    if (isset($params['animation_speed'])) {
621
-        $params['animationSpeed'] = $params['animation_speed'];
622
-    }
623
-    if (isset($params['order_by'])) {
624
-        $params['list_sort'] = $params['order_by'];
625
-    }
626
-
627
-    $query_args = array(
628
-        'post_number' => $params['post_number'],
629
-        'is_geodir_loop' => true,
630
-        'post_type' => $params['post_type'],
631
-        'order_by' => $params['order_by']
632
-    );
633
-
634
-    if (1 == $params['show_featured_only']) {
635
-        $query_args['show_featured_only'] = 1;
636
-    }
637
-
638
-    if (0 != $params['category'] && '' != $params['category']) {
639
-        $category_taxonomy = geodir_get_taxonomies($params['post_type']);
640
-        $tax_query = array(
641
-            'taxonomy' => $category_taxonomy[0],
642
-            'field' => 'id',
643
-            'terms' => $params['category'],
644
-        );
645
-
646
-        $query_args['tax_query'] = array($tax_query);
647
-    }
648
-
649
-    $defaults = array(
650
-        'before_widget' => '',
651
-        'after_widget' => '',
652
-        'before_title' => '',
653
-        'after_title' => '',
654
-    );
655
-
656
-    $query_args = array_merge($query_args, $params);
657
-
658
-    geodir_listing_slider_widget_output($defaults, $query_args);
659
-
660
-    $output = ob_get_contents();
661
-
662
-    ob_end_clean();
663
-
664
-    return $output;
609
+	// redeclare vars after validation
610
+
611
+	if (isset($params['direction_nav'])) {
612
+		$params['directionNav'] = $params['direction_nav'];
613
+	}
614
+	if (isset($params['animation_loop'])) {
615
+		$params['animationLoop'] = $params['animation_loop'];
616
+	}
617
+	if (isset($params['slideshow_speed'])) {
618
+		$params['slideshowSpeed'] = $params['slideshow_speed'];
619
+	}
620
+	if (isset($params['animation_speed'])) {
621
+		$params['animationSpeed'] = $params['animation_speed'];
622
+	}
623
+	if (isset($params['order_by'])) {
624
+		$params['list_sort'] = $params['order_by'];
625
+	}
626
+
627
+	$query_args = array(
628
+		'post_number' => $params['post_number'],
629
+		'is_geodir_loop' => true,
630
+		'post_type' => $params['post_type'],
631
+		'order_by' => $params['order_by']
632
+	);
633
+
634
+	if (1 == $params['show_featured_only']) {
635
+		$query_args['show_featured_only'] = 1;
636
+	}
637
+
638
+	if (0 != $params['category'] && '' != $params['category']) {
639
+		$category_taxonomy = geodir_get_taxonomies($params['post_type']);
640
+		$tax_query = array(
641
+			'taxonomy' => $category_taxonomy[0],
642
+			'field' => 'id',
643
+			'terms' => $params['category'],
644
+		);
645
+
646
+		$query_args['tax_query'] = array($tax_query);
647
+	}
648
+
649
+	$defaults = array(
650
+		'before_widget' => '',
651
+		'after_widget' => '',
652
+		'before_title' => '',
653
+		'after_title' => '',
654
+	);
655
+
656
+	$query_args = array_merge($query_args, $params);
657
+
658
+	geodir_listing_slider_widget_output($defaults, $query_args);
659
+
660
+	$output = ob_get_contents();
661
+
662
+	ob_end_clean();
663
+
664
+	return $output;
665 665
 }
666 666
 
667 667
 add_shortcode('gd_login_box', 'geodir_sc_login_box');
@@ -685,22 +685,22 @@  discard block
 block discarded – undo
685 685
  */
686 686
 function geodir_sc_login_box($atts)
687 687
 {
688
-    ob_start();
688
+	ob_start();
689 689
 
690
-    $defaults = array(
691
-        'before_widget' => '',
692
-        'after_widget' => '',
693
-        'before_title' => '',
694
-        'after_title' => '',
695
-    );
690
+	$defaults = array(
691
+		'before_widget' => '',
692
+		'after_widget' => '',
693
+		'before_title' => '',
694
+		'after_title' => '',
695
+	);
696 696
 
697
-    geodir_loginwidget_output($defaults, $defaults);
697
+	geodir_loginwidget_output($defaults, $defaults);
698 698
 
699
-    $output = ob_get_contents();
699
+	$output = ob_get_contents();
700 700
 
701
-    ob_end_clean();
701
+	ob_end_clean();
702 702
 
703
-    return $output;
703
+	return $output;
704 704
 }
705 705
 
706 706
 add_shortcode('gd_popular_post_category', 'geodir_sc_popular_post_category');
@@ -731,31 +731,31 @@  discard block
 block discarded – undo
731 731
  */
732 732
 function geodir_sc_popular_post_category($atts)
733 733
 {
734
-    ob_start();
735
-    global $geodir_post_category_str;
736
-    $defaults = array(
737
-        'category_limit' => 15,
738
-        'category_restrict' => false,
739
-        'before_widget' => '',
740
-        'after_widget' => '',
741
-        'before_title' => '',
742
-        'after_title' => '',
743
-        'title' => '',
744
-        'default_post_type' => '',
745
-        'parent_only' => false,
746
-    );
747
-
748
-    $params = shortcode_atts($defaults, $atts, 'popular_post_category');
749
-    $params['category_limit'] = absint($params['category_limit']);
750
-    $params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : '';
751
-    $params['parent_only'] = gdsc_to_bool_val($params['parent_only']);
752
-    geodir_popular_post_category_output($params, $params);
753
-
754
-    $output = ob_get_contents();
755
-
756
-    ob_end_clean();
757
-
758
-    return $output;
734
+	ob_start();
735
+	global $geodir_post_category_str;
736
+	$defaults = array(
737
+		'category_limit' => 15,
738
+		'category_restrict' => false,
739
+		'before_widget' => '',
740
+		'after_widget' => '',
741
+		'before_title' => '',
742
+		'after_title' => '',
743
+		'title' => '',
744
+		'default_post_type' => '',
745
+		'parent_only' => false,
746
+	);
747
+
748
+	$params = shortcode_atts($defaults, $atts, 'popular_post_category');
749
+	$params['category_limit'] = absint($params['category_limit']);
750
+	$params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : '';
751
+	$params['parent_only'] = gdsc_to_bool_val($params['parent_only']);
752
+	geodir_popular_post_category_output($params, $params);
753
+
754
+	$output = ob_get_contents();
755
+
756
+	ob_end_clean();
757
+
758
+	return $output;
759 759
 }
760 760
 
761 761
 add_shortcode('gd_popular_post_view', 'geodir_sc_popular_post_view');
@@ -798,98 +798,98 @@  discard block
 block discarded – undo
798 798
  */
799 799
 function geodir_sc_popular_post_view($atts)
800 800
 {
801
-    ob_start();
802
-    $defaults = array(
803
-        'post_type' => 'gd_place',
804
-        'category' => '0',
805
-        'post_number' => '5',
806
-        'layout' => 'gridview_onehalf',
807
-        'add_location_filter' => '0',
808
-        'list_sort' => 'latest',
809
-        'use_viewing_post_type' => '1',
810
-        'character_count' => '20',
811
-        'listing_width' => '',
812
-        'show_featured_only' => '0',
813
-        'show_special_only' => '0',
814
-        'with_pics_only' => '0',
815
-        'with_videos_only' => '0',
816
-        'hide_if_empty' => '0',
817
-        'before_widget' => '',
818
-        'after_widget' => '',
819
-        'before_title' => '<h3 class="widget-title">',
820
-        'after_title' => '</h3>',
821
-        'title' => '',
822
-        'category_title' => '',
823
-    );
824
-
825
-    $params = shortcode_atts($defaults, $atts);
826
-
827
-    /**
828
-     * Validate our incoming params
829
-     */
801
+	ob_start();
802
+	$defaults = array(
803
+		'post_type' => 'gd_place',
804
+		'category' => '0',
805
+		'post_number' => '5',
806
+		'layout' => 'gridview_onehalf',
807
+		'add_location_filter' => '0',
808
+		'list_sort' => 'latest',
809
+		'use_viewing_post_type' => '1',
810
+		'character_count' => '20',
811
+		'listing_width' => '',
812
+		'show_featured_only' => '0',
813
+		'show_special_only' => '0',
814
+		'with_pics_only' => '0',
815
+		'with_videos_only' => '0',
816
+		'hide_if_empty' => '0',
817
+		'before_widget' => '',
818
+		'after_widget' => '',
819
+		'before_title' => '<h3 class="widget-title">',
820
+		'after_title' => '</h3>',
821
+		'title' => '',
822
+		'category_title' => '',
823
+	);
830 824
 
831
-    // Validate the selected post type, default to gd_place on fail
832
-    if (!(gdsc_is_post_type_valid($params['post_type']))) {
833
-        $params['post_type'] = 'gd_place';
834
-    }
835
-
836
-    // Validate the selected category/ies - Grab the current list based on post_type
837
-    $category_taxonomy = geodir_get_taxonomies($params['post_type']);
838
-    $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids'));
839
-
840
-    // Make sure we have an array
841
-    if (!(is_array($params['category']))) {
842
-        $params['category'] = explode(',', $params['category']);
843
-    }
844
-
845
-    // Array_intersect returns only the items in $params['category'] that are also in our category list
846
-    // Otherwise it becomes empty and later on that will mean "All"
847
-    $params['category'] = array_intersect($params['category'], $categories);
848
-
849
-    // Post_number needs to be a positive integer
850
-    $params['post_number'] = absint($params['post_number']);
851
-    if (0 == $params['post_number']) {
852
-        $params['post_number'] = 1;
853
-    }
854
-
855
-    // Validate our layout choice
856
-    // Outside of the norm, I added some more simple terms to match the existing
857
-    // So now I just run the switch to set it properly.
858
-    $params['layout'] = gdsc_validate_layout_choice($params['layout']);
859
-
860
-    // Validate our sorting choice
861
-    $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']);
862
-
863
-    // Validate character_count
864
-    if ($params['character_count'] !== '') {
865
-        $params['character_count'] = absint($params['character_count']);
866
-    }
867
-
868
-    // Validate Listing width, used in the template widget-listing-listview.php
869
-    // The context is in width=$listing_width% - So we need a positive number between 0 & 100
870
-    $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']);
871
-
872
-    // Validate the checkboxes used on the widget
873
-    $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']);
874
-    $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']);
875
-    $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']);
876
-    $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']);
877
-    $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']);
878
-    $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']);
879
-    $params['hide_if_empty'] = gdsc_to_bool_val($params['hide_if_empty']);
880
-
881
-    /**
882
-     * End of validation
883
-     */
825
+	$params = shortcode_atts($defaults, $atts);
826
+
827
+	/**
828
+	 * Validate our incoming params
829
+	 */
830
+
831
+	// Validate the selected post type, default to gd_place on fail
832
+	if (!(gdsc_is_post_type_valid($params['post_type']))) {
833
+		$params['post_type'] = 'gd_place';
834
+	}
835
+
836
+	// Validate the selected category/ies - Grab the current list based on post_type
837
+	$category_taxonomy = geodir_get_taxonomies($params['post_type']);
838
+	$categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids'));
839
+
840
+	// Make sure we have an array
841
+	if (!(is_array($params['category']))) {
842
+		$params['category'] = explode(',', $params['category']);
843
+	}
844
+
845
+	// Array_intersect returns only the items in $params['category'] that are also in our category list
846
+	// Otherwise it becomes empty and later on that will mean "All"
847
+	$params['category'] = array_intersect($params['category'], $categories);
884 848
 
885
-    geodir_popular_postview_output($params, $params);
849
+	// Post_number needs to be a positive integer
850
+	$params['post_number'] = absint($params['post_number']);
851
+	if (0 == $params['post_number']) {
852
+		$params['post_number'] = 1;
853
+	}
854
+
855
+	// Validate our layout choice
856
+	// Outside of the norm, I added some more simple terms to match the existing
857
+	// So now I just run the switch to set it properly.
858
+	$params['layout'] = gdsc_validate_layout_choice($params['layout']);
859
+
860
+	// Validate our sorting choice
861
+	$params['list_sort'] = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']);
862
+
863
+	// Validate character_count
864
+	if ($params['character_count'] !== '') {
865
+		$params['character_count'] = absint($params['character_count']);
866
+	}
867
+
868
+	// Validate Listing width, used in the template widget-listing-listview.php
869
+	// The context is in width=$listing_width% - So we need a positive number between 0 & 100
870
+	$params['listing_width'] = gdsc_validate_listing_width($params['listing_width']);
886 871
 
872
+	// Validate the checkboxes used on the widget
873
+	$params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']);
874
+	$params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']);
875
+	$params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']);
876
+	$params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']);
877
+	$params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']);
878
+	$params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']);
879
+	$params['hide_if_empty'] = gdsc_to_bool_val($params['hide_if_empty']);
887 880
 
888
-    $output = ob_get_contents();
881
+	/**
882
+	 * End of validation
883
+	 */
889 884
 
890
-    ob_end_clean();
885
+	geodir_popular_postview_output($params, $params);
891 886
 
892
-    return $output;
887
+
888
+	$output = ob_get_contents();
889
+
890
+	ob_end_clean();
891
+
892
+	return $output;
893 893
 }
894 894
 
895 895
 add_shortcode('gd_recent_reviews', 'geodir_sc_recent_reviews');
@@ -911,37 +911,37 @@  discard block
 block discarded – undo
911 911
  * @return string Recent reviews HTML.
912 912
  */
913 913
 function geodir_sc_recent_reviews($atts) {
914
-    ob_start();
915
-    $defaults = array(
914
+	ob_start();
915
+	$defaults = array(
916 916
 		'title' => '',
917 917
 		'count' => 5,
918
-    );
918
+	);
919 919
 
920
-    $params = shortcode_atts($defaults, $atts);
920
+	$params = shortcode_atts($defaults, $atts);
921 921
 
922
-    $count = absint($params['count']);
923
-    if (0 == $count) {
924
-        $count = 1;
925
-    }
922
+	$count = absint($params['count']);
923
+	if (0 == $count) {
924
+		$count = 1;
925
+	}
926 926
 	
927 927
 	$title = !empty($params['title']) ? __($params['title'], 'geodirectory') : '';
928 928
 
929
-    $comments_li = geodir_get_recent_reviews(30, $count, 100, false);
929
+	$comments_li = geodir_get_recent_reviews(30, $count, 100, false);
930 930
 
931
-    if ($comments_li) {
932
-        if ($title != '') { ?>
931
+	if ($comments_li) {
932
+		if ($title != '') { ?>
933 933
 		<h3 class="geodir-sc-recent-reviews-title widget-title"><?php echo $title; ?></h3>
934 934
 		<?php } ?>
935 935
         <div class="geodir_sc_recent_reviews_section">
936 936
             <ul class="geodir_sc_recent_reviews"><?php echo $comments_li; ?></ul>
937 937
         </div>
938 938
     <?php
939
-    }
940
-    $output = ob_get_contents();
939
+	}
940
+	$output = ob_get_contents();
941 941
 
942
-    ob_end_clean();
942
+	ob_end_clean();
943 943
 
944
-    return $output;
944
+	return $output;
945 945
 }
946 946
 
947 947
 add_shortcode('gd_related_listings', 'geodir_sc_related_listings');
@@ -971,63 +971,63 @@  discard block
 block discarded – undo
971 971
  */
972 972
 function geodir_sc_related_listings($atts)
973 973
 {
974
-    ob_start();
975
-    $defaults = array(
976
-        'post_number' => 5,
977
-        'relate_to' => 'category',
978
-        'layout' => 'gridview_onehalf',
979
-        'add_location_filter' => 0,
980
-        'listing_width' => '',
981
-        'list_sort' => 'latest',
982
-        'character_count' => 20,
983
-        'is_widget' => 1,
984
-        'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>',
985
-    );
986
-    // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet.
987
-
988
-    $params = shortcode_atts($defaults, $atts);
989
-
990
-    /**
991
-     * Begin validating parameters
992
-     */
974
+	ob_start();
975
+	$defaults = array(
976
+		'post_number' => 5,
977
+		'relate_to' => 'category',
978
+		'layout' => 'gridview_onehalf',
979
+		'add_location_filter' => 0,
980
+		'listing_width' => '',
981
+		'list_sort' => 'latest',
982
+		'character_count' => 20,
983
+		'is_widget' => 1,
984
+		'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>',
985
+	);
986
+	// The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet.
987
+
988
+	$params = shortcode_atts($defaults, $atts);
989
+
990
+	/**
991
+	 * Begin validating parameters
992
+	 */
993 993
 
994
-    // Validate that post_number is a number and is 1 or higher
995
-    $params['post_number'] = absint($params['post_number']);
996
-    if (0 === $params['post_number']) {
997
-        $params['post_number'] = 1;
998
-    }
994
+	// Validate that post_number is a number and is 1 or higher
995
+	$params['post_number'] = absint($params['post_number']);
996
+	if (0 === $params['post_number']) {
997
+		$params['post_number'] = 1;
998
+	}
999 999
 
1000
-    // Validate relate_to - only category or tags
1001
-    $params['relate_to'] = geodir_strtolower($params['relate_to']);
1002
-    if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) {
1003
-        $params['relate_to'] = 'category';
1004
-    }
1000
+	// Validate relate_to - only category or tags
1001
+	$params['relate_to'] = geodir_strtolower($params['relate_to']);
1002
+	if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) {
1003
+		$params['relate_to'] = 'category';
1004
+	}
1005 1005
 
1006
-    // Validate layout selection
1007
-    $params['layout'] = gdsc_validate_layout_choice($params['layout']);
1006
+	// Validate layout selection
1007
+	$params['layout'] = gdsc_validate_layout_choice($params['layout']);
1008 1008
 
1009
-    // Validate sorting option
1010
-    $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']);
1009
+	// Validate sorting option
1010
+	$params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']);
1011 1011
 
1012
-    // Validate add_location_filter
1013
-    $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']);
1012
+	// Validate add_location_filter
1013
+	$params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']);
1014 1014
 
1015
-    // Validate listing_width
1016
-    $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']);
1015
+	// Validate listing_width
1016
+	$params['listing_width'] = gdsc_validate_listing_width($params['listing_width']);
1017 1017
 
1018
-    // Validate character_count
1019
-    if ($params['character_count'] !== '') {
1020
-        $params['character_count'] = absint($params['character_count']);
1021
-    }
1018
+	// Validate character_count
1019
+	if ($params['character_count'] !== '') {
1020
+		$params['character_count'] = absint($params['character_count']);
1021
+	}
1022 1022
 
1023
-    if ($related_display = geodir_related_posts_display($params)) {
1024
-        echo $related_display;
1025
-    }
1026
-    $output = ob_get_contents();
1023
+	if ($related_display = geodir_related_posts_display($params)) {
1024
+		echo $related_display;
1025
+	}
1026
+	$output = ob_get_contents();
1027 1027
 
1028
-    ob_end_clean();
1028
+	ob_end_clean();
1029 1029
 
1030
-    return $output;
1030
+	return $output;
1031 1031
 }
1032 1032
 
1033 1033
 /**
@@ -1051,13 +1051,13 @@  discard block
 block discarded – undo
1051 1051
  * @return string Advanced search widget HTML.
1052 1052
  */
1053 1053
 function geodir_sc_advanced_search($atts) {
1054
-    $defaults = array(
1054
+	$defaults = array(
1055 1055
 		'title' => '',
1056 1056
 		'before_widget' => '<section id="geodir_advanced_search-1" class="widget geodir-widget geodir_advance_search_widget">',
1057
-        'after_widget' => '</section>',
1058
-        'before_title' => '<h3 class="widget-title">',
1059
-        'after_title' => '</h3>',
1060
-        'show_adv_search' => 'default',
1057
+		'after_widget' => '</section>',
1058
+		'before_title' => '<h3 class="widget-title">',
1059
+		'after_title' => '</h3>',
1060
+		'show_adv_search' => 'default',
1061 1061
 		'post_type' => ''
1062 1062
 	);
1063 1063
 	
@@ -1081,9 +1081,9 @@  discard block
 block discarded – undo
1081 1081
 	the_widget('geodir_advance_search_widget', $params, $params );
1082 1082
 	
1083 1083
 	$output = ob_get_contents();
1084
-    ob_end_clean();
1084
+	ob_end_clean();
1085 1085
 
1086
-    return $output;
1086
+	return $output;
1087 1087
 }
1088 1088
 add_shortcode('gd_advanced_search', 'geodir_sc_advanced_search');
1089 1089
 
@@ -1129,48 +1129,48 @@  discard block
 block discarded – undo
1129 1129
 		'add_location_filter' => '1',
1130 1130
 		'tab_layout' => 'bestof-tabs-on-top',
1131 1131
 		'before_widget' => '<section id="bestof_widget-1" class="widget geodir-widget geodir_bestof_widget geodir_sc_bestof_widget">',
1132
-        'after_widget' => '</section>',
1133
-        'before_title' => '<h3 class="widget-title">',
1134
-        'after_title' => '</h3>',
1132
+		'after_widget' => '</section>',
1133
+		'before_title' => '<h3 class="widget-title">',
1134
+		'after_title' => '</h3>',
1135 1135
 	);
1136 1136
 	$params = shortcode_atts($defaults, $atts);
1137 1137
 
1138
-    /**
1139
-     * Validate our incoming params
1140
-     */
1138
+	/**
1139
+	 * Validate our incoming params
1140
+	 */
1141 1141
 
1142
-    // Validate the selected post type, default to gd_place on fail
1143
-    if (!(gdsc_is_post_type_valid($params['post_type']))) {
1144
-        $params['post_type'] = 'gd_place';
1145
-    }
1142
+	// Validate the selected post type, default to gd_place on fail
1143
+	if (!(gdsc_is_post_type_valid($params['post_type']))) {
1144
+		$params['post_type'] = 'gd_place';
1145
+	}
1146 1146
 	
1147 1147
 	// Post limit needs to be a positive integer
1148
-    $params['post_limit'] = absint($params['post_limit']);
1149
-    if (0 == $params['post_limit']) {
1150
-        $params['post_limit'] = 5;
1151
-    }
1148
+	$params['post_limit'] = absint($params['post_limit']);
1149
+	if (0 == $params['post_limit']) {
1150
+		$params['post_limit'] = 5;
1151
+	}
1152 1152
 	
1153 1153
 	// Category limit needs to be a positive integer
1154
-    $params['categ_limit'] = absint($params['categ_limit']);
1155
-    if (0 == $params['categ_limit']) {
1156
-        $params['categ_limit'] = 3;
1157
-    }
1154
+	$params['categ_limit'] = absint($params['categ_limit']);
1155
+	if (0 == $params['categ_limit']) {
1156
+		$params['categ_limit'] = 3;
1157
+	}
1158 1158
 	
1159 1159
 	// Tab layout validation
1160
-    $params['tab_layout'] = $params['tab_layout'];
1161
-    if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) {
1162
-        $params['tab_layout'] = 'bestof-tabs-on-top';
1163
-    }
1160
+	$params['tab_layout'] = $params['tab_layout'];
1161
+	if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) {
1162
+		$params['tab_layout'] = 'bestof-tabs-on-top';
1163
+	}
1164 1164
 	
1165 1165
 	// Validate character_count
1166
-    $params['character_count'] = $params['character_count'];
1166
+	$params['character_count'] = $params['character_count'];
1167 1167
 
1168 1168
 	ob_start();
1169 1169
 	the_widget('geodir_bestof_widget', $params, $params);
1170
-    $output = ob_get_contents();
1171
-    ob_end_clean();
1170
+	$output = ob_get_contents();
1171
+	ob_end_clean();
1172 1172
 
1173
-    return $output;
1173
+	return $output;
1174 1174
 }
1175 1175
 add_shortcode('gd_bestof_widget', 'geodir_sc_bestof_widget');
1176 1176
 
@@ -1223,162 +1223,162 @@  discard block
 block discarded – undo
1223 1223
  * @return string HTML content to display geodirectory listings.
1224 1224
  */
1225 1225
 function geodir_sc_gd_listings($atts, $content = '') {
1226
-    global $post;
1227
-    $defaults = array(
1228
-        'title'                 => '',
1229
-        'post_type'             => 'gd_place',
1230
-        'category'              => 0,
1231
-        'list_sort'             => 'latest',
1232
-        'event_type'            => '',
1233
-        'post_number'           => 10,
1234
-        'post_author'           => '',
1235
-        'layout'                => 'gridview_onehalf',
1236
-        'listing_width'         => '',
1237
-        'character_count'       => 20,
1238
-        'add_location_filter'   => 1,
1239
-        'show_featured_only'    => '',
1240
-        'show_special_only'     => '',
1241
-        'with_pics_only'        => '',
1242
-        'with_videos_only'      => '',
1243
-        'with_pagination'       => '1',
1244
-        'top_pagination'        => '0',
1245
-        'bottom_pagination'     => '1',
1246
-        'without_no_results'    => 0,
1247
-        'tags'                  => '',
1248
-        'show_favorites_only'   => '',
1249
-        'favorites_by_user'     => '',
1250
-    );
1251
-    $params = shortcode_atts($defaults, $atts);
1252
-
1253
-    $params['title']        = wp_strip_all_tags($params['title']);
1254
-    $params['post_type']    = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place';
1255
-
1256
-    // Validate the selected category/ies - Grab the current list based on post_type
1257
-    $category_taxonomy      = geodir_get_taxonomies($params['post_type']);
1258
-    $categories             = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids', 'hide_empty' => 0));
1259
-
1260
-    // Make sure we have an array
1261
-    if (!(is_array($params['category']))) {
1262
-        $params['category'] = explode(',', $params['category']);
1263
-    }
1264
-
1265
-    // Array_intersect returns only the items in $params['category'] that are also in our category list
1266
-    // Otherwise it becomes empty and later on that will mean "All"
1267
-    $params['category']     = array_intersect($params['category'], $categories);
1268
-
1269
-    // Post_number needs to be a positive integer
1270
-    $params['post_number']  = absint($params['post_number']);
1271
-    $params['post_number']  = $params['post_number'] > 0 ? $params['post_number'] : 10;
1226
+	global $post;
1227
+	$defaults = array(
1228
+		'title'                 => '',
1229
+		'post_type'             => 'gd_place',
1230
+		'category'              => 0,
1231
+		'list_sort'             => 'latest',
1232
+		'event_type'            => '',
1233
+		'post_number'           => 10,
1234
+		'post_author'           => '',
1235
+		'layout'                => 'gridview_onehalf',
1236
+		'listing_width'         => '',
1237
+		'character_count'       => 20,
1238
+		'add_location_filter'   => 1,
1239
+		'show_featured_only'    => '',
1240
+		'show_special_only'     => '',
1241
+		'with_pics_only'        => '',
1242
+		'with_videos_only'      => '',
1243
+		'with_pagination'       => '1',
1244
+		'top_pagination'        => '0',
1245
+		'bottom_pagination'     => '1',
1246
+		'without_no_results'    => 0,
1247
+		'tags'                  => '',
1248
+		'show_favorites_only'   => '',
1249
+		'favorites_by_user'     => '',
1250
+	);
1251
+	$params = shortcode_atts($defaults, $atts);
1252
+
1253
+	$params['title']        = wp_strip_all_tags($params['title']);
1254
+	$params['post_type']    = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place';
1255
+
1256
+	// Validate the selected category/ies - Grab the current list based on post_type
1257
+	$category_taxonomy      = geodir_get_taxonomies($params['post_type']);
1258
+	$categories             = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids', 'hide_empty' => 0));
1259
+
1260
+	// Make sure we have an array
1261
+	if (!(is_array($params['category']))) {
1262
+		$params['category'] = explode(',', $params['category']);
1263
+	}
1264
+
1265
+	// Array_intersect returns only the items in $params['category'] that are also in our category list
1266
+	// Otherwise it becomes empty and later on that will mean "All"
1267
+	$params['category']     = array_intersect($params['category'], $categories);
1268
+
1269
+	// Post_number needs to be a positive integer
1270
+	$params['post_number']  = absint($params['post_number']);
1271
+	$params['post_number']  = $params['post_number'] > 0 ? $params['post_number'] : 10;
1272 1272
     
1273
-    // Post_number needs to be a positive integer
1274
-    if (!empty($params['post_author'])) {
1275
-        // 'current' left for backwards compatibility
1276
-        if ( $params['post_author'] == 'current' || $params['post_author'] == 'current_author') {
1277
-            if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) {
1278
-                $params['post_author'] = $post->post_author;
1279
-            } else {
1280
-                $params['post_author'] = -1; // Don't show any listings.
1281
-            }
1282
-        } else if ($params['post_author'] == 'current_user' ) {
1283
-            if ($current_user_id = get_current_user_id()) {
1284
-                $params['post_author'] = $current_user_id;
1285
-            } else {
1286
-                $params['post_author'] = -1; // If not logged in then don't show any listings.
1287
-            }
1288
-        } else if (absint($params['post_author']) > 0) {
1289
-            $params['post_author'] = absint($params['post_author']);
1290
-        } else {
1291
-            $params['post_author'] = -1; // Don't show any listings.
1292
-        }
1293
-    } else {
1294
-        unset($params['post_author']);
1295
-    }
1296
-
1297
-    // Validate character_count
1298
-    //todo: is this necessary?
1299
-    $params['character_count']  = $params['character_count'];
1300
-
1301
-    // Validate our layout choice
1302
-    // Outside of the norm, I added some more simple terms to match the existing
1303
-    // So now I just run the switch to set it properly.
1304
-    $params['layout']           = gdsc_validate_layout_choice($params['layout']);
1305
-
1306
-    // Validate our sorting choice
1307
-    $params['list_sort']        = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']);
1308
-
1309
-    // Validate Listing width, used in the template widget-listing-listview.php
1310
-    // The context is in width=$listing_width% - So we need a positive number between 0 & 100
1311
-    $params['listing_width']    = gdsc_validate_listing_width($params['listing_width']);
1312
-
1313
-    // Validate the checkboxes used on the widget
1314
-    $params['add_location_filter']  = gdsc_to_bool_val($params['add_location_filter']);
1315
-    $params['show_featured_only']   = gdsc_to_bool_val($params['show_featured_only']);
1316
-    $params['show_special_only']    = gdsc_to_bool_val($params['show_special_only']);
1317
-    $params['with_pics_only']       = gdsc_to_bool_val($params['with_pics_only']);
1318
-    $params['with_videos_only']     = gdsc_to_bool_val($params['with_videos_only']);
1319
-    $params['with_pagination']      = gdsc_to_bool_val($params['with_pagination']);
1320
-    $params['top_pagination']       = gdsc_to_bool_val($params['top_pagination']);
1321
-    $params['bottom_pagination']    = gdsc_to_bool_val($params['bottom_pagination']);
1273
+	// Post_number needs to be a positive integer
1274
+	if (!empty($params['post_author'])) {
1275
+		// 'current' left for backwards compatibility
1276
+		if ( $params['post_author'] == 'current' || $params['post_author'] == 'current_author') {
1277
+			if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) {
1278
+				$params['post_author'] = $post->post_author;
1279
+			} else {
1280
+				$params['post_author'] = -1; // Don't show any listings.
1281
+			}
1282
+		} else if ($params['post_author'] == 'current_user' ) {
1283
+			if ($current_user_id = get_current_user_id()) {
1284
+				$params['post_author'] = $current_user_id;
1285
+			} else {
1286
+				$params['post_author'] = -1; // If not logged in then don't show any listings.
1287
+			}
1288
+		} else if (absint($params['post_author']) > 0) {
1289
+			$params['post_author'] = absint($params['post_author']);
1290
+		} else {
1291
+			$params['post_author'] = -1; // Don't show any listings.
1292
+		}
1293
+	} else {
1294
+		unset($params['post_author']);
1295
+	}
1296
+
1297
+	// Validate character_count
1298
+	//todo: is this necessary?
1299
+	$params['character_count']  = $params['character_count'];
1300
+
1301
+	// Validate our layout choice
1302
+	// Outside of the norm, I added some more simple terms to match the existing
1303
+	// So now I just run the switch to set it properly.
1304
+	$params['layout']           = gdsc_validate_layout_choice($params['layout']);
1305
+
1306
+	// Validate our sorting choice
1307
+	$params['list_sort']        = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']);
1308
+
1309
+	// Validate Listing width, used in the template widget-listing-listview.php
1310
+	// The context is in width=$listing_width% - So we need a positive number between 0 & 100
1311
+	$params['listing_width']    = gdsc_validate_listing_width($params['listing_width']);
1312
+
1313
+	// Validate the checkboxes used on the widget
1314
+	$params['add_location_filter']  = gdsc_to_bool_val($params['add_location_filter']);
1315
+	$params['show_featured_only']   = gdsc_to_bool_val($params['show_featured_only']);
1316
+	$params['show_special_only']    = gdsc_to_bool_val($params['show_special_only']);
1317
+	$params['with_pics_only']       = gdsc_to_bool_val($params['with_pics_only']);
1318
+	$params['with_videos_only']     = gdsc_to_bool_val($params['with_videos_only']);
1319
+	$params['with_pagination']      = gdsc_to_bool_val($params['with_pagination']);
1320
+	$params['top_pagination']       = gdsc_to_bool_val($params['top_pagination']);
1321
+	$params['bottom_pagination']    = gdsc_to_bool_val($params['bottom_pagination']);
1322 1322
     
1323
-    // User favorites
1324
-    $params['show_favorites_only']  = gdsc_to_bool_val($params['show_favorites_only']);
1325
-    if (!empty($params['show_favorites_only'])) {
1326
-        if ( $params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') {
1327
-            if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) {
1328
-                $params['favorites_by_user'] = $post->post_author;
1329
-            } else {
1330
-                $params['favorites_by_user'] = 0;
1331
-            }
1332
-        } else if ($params['favorites_by_user'] == 'current_user' || empty($params['favorites_by_user'])) {
1333
-            if ($current_user_id = get_current_user_id()) {
1334
-                $params['favorites_by_user'] = $current_user_id;
1335
-            } else {
1336
-                $params['favorites_by_user'] = 0;
1337
-            }
1338
-        } else if (absint($params['favorites_by_user']) > 0) {
1339
-            $params['favorites_by_user'] = absint($params['favorites_by_user']);
1340
-        } else {
1341
-            $params['favorites_by_user'] = 0;
1342
-        }
1343
-    }
1344
-
1345
-    // Clean tags
1346
-    if (!empty($params['tags'])) {
1347
-        if (!is_array($params['tags'])) {
1348
-            $comma = _x(',', 'tag delimiter');
1349
-            if ( ',' !== $comma ) {
1350
-                $params['tags'] = str_replace($comma, ',', $params['tags']);
1351
-            }
1352
-            $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,"));
1353
-            $params['tags'] = array_map('trim', $params['tags']);
1354
-        }
1355
-    } else {
1356
-        $params['tags'] = array();
1357
-    }
1358
-
1359
-    /**
1360
-     * End of validation
1361
-     */
1362
-    if (isset($atts['geodir_ajax'])) {
1363
-        $params['geodir_ajax'] = $atts['geodir_ajax'];
1364
-        unset($atts['geodir_ajax']);
1365
-    }
1366
-    if (isset($atts['pageno'])) {
1367
-        $params['pageno'] = $atts['pageno'];
1368
-        unset($atts['pageno']);
1369
-    }
1370
-
1371
-    if ( !empty($atts['shortcode_content']) ) {
1372
-        $content = $atts['shortcode_content'];
1373
-    }
1374
-    $params['shortcode_content'] = trim($content);
1375
-    $atts['shortcode_content'] = trim($content);
1323
+	// User favorites
1324
+	$params['show_favorites_only']  = gdsc_to_bool_val($params['show_favorites_only']);
1325
+	if (!empty($params['show_favorites_only'])) {
1326
+		if ( $params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') {
1327
+			if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) {
1328
+				$params['favorites_by_user'] = $post->post_author;
1329
+			} else {
1330
+				$params['favorites_by_user'] = 0;
1331
+			}
1332
+		} else if ($params['favorites_by_user'] == 'current_user' || empty($params['favorites_by_user'])) {
1333
+			if ($current_user_id = get_current_user_id()) {
1334
+				$params['favorites_by_user'] = $current_user_id;
1335
+			} else {
1336
+				$params['favorites_by_user'] = 0;
1337
+			}
1338
+		} else if (absint($params['favorites_by_user']) > 0) {
1339
+			$params['favorites_by_user'] = absint($params['favorites_by_user']);
1340
+		} else {
1341
+			$params['favorites_by_user'] = 0;
1342
+		}
1343
+	}
1344
+
1345
+	// Clean tags
1346
+	if (!empty($params['tags'])) {
1347
+		if (!is_array($params['tags'])) {
1348
+			$comma = _x(',', 'tag delimiter');
1349
+			if ( ',' !== $comma ) {
1350
+				$params['tags'] = str_replace($comma, ',', $params['tags']);
1351
+			}
1352
+			$params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,"));
1353
+			$params['tags'] = array_map('trim', $params['tags']);
1354
+		}
1355
+	} else {
1356
+		$params['tags'] = array();
1357
+	}
1358
+
1359
+	/**
1360
+	 * End of validation
1361
+	 */
1362
+	if (isset($atts['geodir_ajax'])) {
1363
+		$params['geodir_ajax'] = $atts['geodir_ajax'];
1364
+		unset($atts['geodir_ajax']);
1365
+	}
1366
+	if (isset($atts['pageno'])) {
1367
+		$params['pageno'] = $atts['pageno'];
1368
+		unset($atts['pageno']);
1369
+	}
1370
+
1371
+	if ( !empty($atts['shortcode_content']) ) {
1372
+		$content = $atts['shortcode_content'];
1373
+	}
1374
+	$params['shortcode_content'] = trim($content);
1375
+	$atts['shortcode_content'] = trim($content);
1376 1376
     
1377
-    $params['shortcode_atts']       = $atts;
1377
+	$params['shortcode_atts']       = $atts;
1378 1378
 
1379
-    $output = geodir_sc_gd_listings_output($params);
1379
+	$output = geodir_sc_gd_listings_output($params);
1380 1380
 
1381
-    return $output;
1381
+	return $output;
1382 1382
 }
1383 1383
 add_shortcode('gd_listings', 'geodir_sc_gd_listings');
1384 1384
 
@@ -1418,56 +1418,56 @@  discard block
 block discarded – undo
1418 1418
  * @return string HTML content to display CPT categories.
1419 1419
  */
1420 1420
 function geodir_sc_cpt_categories_widget($atts, $content = '') {
1421
-    $defaults = array(
1422
-        'title' => '',
1423
-        'post_type' => '', // NULL for all
1424
-        'hide_empty' => '',
1425
-        'show_count' => '',
1426
-        'hide_icon' => '',
1427
-        'cpt_left' => '',
1428
-        'sort_by' => 'count',
1429
-        'max_count' => 'all',
1430
-        'max_level' => '1',
1431
-        'no_cpt_filter' => '',
1432
-        'no_cat_filter' => '',
1433
-        'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">',
1434
-        'after_widget' => '</section>',
1435
-        'before_title' => '<h3 class="widget-title">',
1436
-        'after_title' => '</h3>',
1437
-    );
1438
-    $params = shortcode_atts($defaults, $atts);
1439
-
1440
-    /**
1441
-     * Validate our incoming params
1442
-     */
1443
-    // Make sure we have an array
1444
-    $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array();
1445
-     
1446
-    // Validate the checkboxes used on the widget
1447
-    $params['hide_empty'] 	= gdsc_to_bool_val($params['hide_empty']);
1448
-    $params['show_count'] 	= gdsc_to_bool_val($params['show_count']);
1449
-    $params['hide_icon'] 	= gdsc_to_bool_val($params['hide_icon']);
1450
-    $params['cpt_left'] 	= gdsc_to_bool_val($params['cpt_left']);
1421
+	$defaults = array(
1422
+		'title' => '',
1423
+		'post_type' => '', // NULL for all
1424
+		'hide_empty' => '',
1425
+		'show_count' => '',
1426
+		'hide_icon' => '',
1427
+		'cpt_left' => '',
1428
+		'sort_by' => 'count',
1429
+		'max_count' => 'all',
1430
+		'max_level' => '1',
1431
+		'no_cpt_filter' => '',
1432
+		'no_cat_filter' => '',
1433
+		'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">',
1434
+		'after_widget' => '</section>',
1435
+		'before_title' => '<h3 class="widget-title">',
1436
+		'after_title' => '</h3>',
1437
+	);
1438
+	$params = shortcode_atts($defaults, $atts);
1451 1439
 
1452
-    if ($params['max_count'] != 'all') {
1453
-        $params['max_count'] = absint($params['max_count']);
1454
-    }
1440
+	/**
1441
+	 * Validate our incoming params
1442
+	 */
1443
+	// Make sure we have an array
1444
+	$params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array();
1445
+     
1446
+	// Validate the checkboxes used on the widget
1447
+	$params['hide_empty'] 	= gdsc_to_bool_val($params['hide_empty']);
1448
+	$params['show_count'] 	= gdsc_to_bool_val($params['show_count']);
1449
+	$params['hide_icon'] 	= gdsc_to_bool_val($params['hide_icon']);
1450
+	$params['cpt_left'] 	= gdsc_to_bool_val($params['cpt_left']);
1451
+
1452
+	if ($params['max_count'] != 'all') {
1453
+		$params['max_count'] = absint($params['max_count']);
1454
+	}
1455 1455
 
1456
-    if ($params['max_level'] != 'all') {
1457
-        $params['max_level'] = absint($params['max_level']);
1458
-    }
1456
+	if ($params['max_level'] != 'all') {
1457
+		$params['max_level'] = absint($params['max_level']);
1458
+	}
1459 1459
 
1460
-    $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']);
1461
-    $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']);
1460
+	$params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']);
1461
+	$params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']);
1462 1462
 
1463
-    $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count';
1463
+	$params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count';
1464 1464
 
1465
-    ob_start();
1466
-    the_widget('geodir_cpt_categories_widget', $params, $params);
1467
-    $output = ob_get_contents();
1468
-    ob_end_clean();
1465
+	ob_start();
1466
+	the_widget('geodir_cpt_categories_widget', $params, $params);
1467
+	$output = ob_get_contents();
1468
+	ob_end_clean();
1469 1469
 
1470
-    return $output;
1470
+	return $output;
1471 1471
 }
1472 1472
 add_shortcode('gd_cpt_categories', 'geodir_sc_cpt_categories_widget');
1473 1473
 
@@ -1482,6 +1482,6 @@  discard block
 block discarded – undo
1482 1482
  * @return string HTML code.
1483 1483
  */
1484 1484
 function geodir_sc_responsive_videos($atts, $content) {
1485
-    return '<div class="geodir-video-wrapper">'.$content.'</div>';
1485
+	return '<div class="geodir-video-wrapper">'.$content.'</div>';
1486 1486
 }
1487 1487
 add_shortcode('gd_video', 'geodir_sc_responsive_videos');
1488 1488
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 	// Add marker cluster
198 198
 	if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) {
199 199
         $map_args['enable_marker_cluster'] = true;
200
-        if(get_option('geodir_marker_cluster_type')) {
200
+        if (get_option('geodir_marker_cluster_type')) {
201 201
             if ($map_args['autozoom']) {
202 202
                 $map_args['enable_marker_cluster_no_reposition'] = false;
203 203
             } else {
204 204
                 $map_args['enable_marker_cluster_no_reposition'] = true;
205 205
             }
206 206
 
207
-            $map_args['enable_marker_cluster_server'] = true ;
207
+            $map_args['enable_marker_cluster_server'] = true;
208 208
 
209 209
         }
210 210
 	} else {
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	}
213 213
 
214 214
     // if lat and long set in shortcode, hack it so the map is not repositioned
215
-    if(!empty($params['latitude']) && !empty($params['longitude']) ){
215
+    if (!empty($params['latitude']) && !empty($params['longitude'])) {
216 216
         $map_args['enable_marker_cluster_no_reposition'] = true;
217 217
     }
218 218
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 function geodir_sc_listing_map($atts) {
266 266
 
267 267
     // if some params are set then we need a new query, if not then we can use the main query
268
-    if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) {
268
+    if (isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type'])) {
269 269
 
270 270
         global $add_post_in_marker_array, $gd_sc_map_params;
271 271
         $backup_globals                             = array();
@@ -288,34 +288,34 @@  discard block
 block discarded – undo
288 288
             'event_type'     => 'all'
289 289
         );
290 290
 
291
-        $params = shortcode_atts( $defaults, $atts );
291
+        $params = shortcode_atts($defaults, $atts);
292 292
 
293
-        if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) {
293
+        if (!(gdsc_is_post_type_valid($params['post_type']))) {
294 294
             $params['post_type'] = 'gd_place';
295 295
         }
296 296
 
297 297
         // Validate the selected category/ies - Grab the current list based on post_type
298
-        $category_taxonomy = geodir_get_taxonomies( $params['post_type'] );
299
-        $categories        = get_terms( $category_taxonomy, array(
298
+        $category_taxonomy = geodir_get_taxonomies($params['post_type']);
299
+        $categories        = get_terms($category_taxonomy, array(
300 300
             'orderby' => 'count',
301 301
             'order'   => 'DESC',
302 302
             'fields'  => 'ids'
303
-        ) );
303
+        ));
304 304
 
305 305
         // Make sure we have an array
306
-        if ( ! ( is_array( $params['category'] ) ) ) {
307
-            $params['category'] = explode( ',', $params['category'] );
306
+        if (!(is_array($params['category']))) {
307
+            $params['category'] = explode(',', $params['category']);
308 308
         }
309 309
 
310 310
         // Array_intersect returns only the items in $params['category'] that are also in our category list
311 311
         // Otherwise it becomes empty and later on that will mean "All"
312
-        $params['category'] = array_intersect( $params['category'], $categories );
312
+        $params['category'] = array_intersect($params['category'], $categories);
313 313
 
314
-        if ( $params['post_type'] == 'gd_event' ) {
315
-            $params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] );
314
+        if ($params['post_type'] == 'gd_event') {
315
+            $params['event_type'] = gdsc_validate_list_filter_choice($params['event_type']);
316 316
         }
317 317
 
318
-        $params = gdsc_validate_map_args( $params );
318
+        $params = gdsc_validate_map_args($params);
319 319
 
320 320
         $gd_sc_map_params = $params;
321 321
 
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
             'post_type'      => $params['post_type'],
327 327
         );
328 328
 
329
-        if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) {
330
-            $category_taxonomy = geodir_get_taxonomies( $params['post_type'] );
329
+        if (!empty($params['category']) && isset($params['category'][0]) && (int) $params['category'][0] != 0) {
330
+            $category_taxonomy = geodir_get_taxonomies($params['post_type']);
331 331
 
332 332
             ######### WPML #########
333
-            if ( geodir_wpml_is_taxonomy_translated( $category_taxonomy[0] ) ) {
334
-                $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] );
333
+            if (geodir_wpml_is_taxonomy_translated($category_taxonomy[0])) {
334
+                $category = gd_lang_object_ids($params['category'], $category_taxonomy[0]);
335 335
             }
336 336
             ######### WPML #########
337 337
 
@@ -341,36 +341,36 @@  discard block
 block discarded – undo
341 341
                 'terms'    => $params['category']
342 342
             );
343 343
 
344
-            $query_args['tax_query'] = array( $tax_query );
344
+            $query_args['tax_query'] = array($tax_query);
345 345
         }
346 346
 
347 347
         $add_post_in_marker_array = true;
348 348
 
349
-        if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) {
349
+        if ($params['post_type'] == 'gd_event' && function_exists('geodir_event_get_widget_events')) {
350 350
             global $geodir_event_widget_listview;
351 351
             $geodir_event_widget_listview = true;
352 352
 
353 353
             $query_args['geodir_event_type'] = $params['event_type'];
354 354
 
355
-            $listings = geodir_event_get_widget_events( $query_args );
355
+            $listings = geodir_event_get_widget_events($query_args);
356 356
 
357 357
             $geodir_event_widget_listview = false;
358 358
         } else {
359
-            $listings = geodir_get_widget_listings( $query_args );
359
+            $listings = geodir_get_widget_listings($query_args);
360 360
         }
361 361
 
362
-        if ( ! empty( $listings ) ) {
363
-            foreach ( $listings as $listing ) {
364
-                create_marker_jason_of_posts( $listing );
362
+        if (!empty($listings)) {
363
+            foreach ($listings as $listing) {
364
+                create_marker_jason_of_posts($listing);
365 365
             }
366 366
         }
367 367
 
368 368
         ob_start();
369
-        add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array
369
+        add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array
370 370
 
371
-        add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array
371
+        add_action('the_post', 'create_list_jsondata'); // Add marker in json array
372 372
 
373
-        add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers
373
+        add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers
374 374
 
375 375
         $default_location = geodir_get_default_location();
376 376
 
@@ -391,17 +391,17 @@  discard block
 block discarded – undo
391 391
             'enable_location_filters'  => false,
392 392
             'enable_jason_on_load'     => true,
393 393
             'ajax_url'                 => geodir_get_ajax_url(),
394
-            'latitude'                 => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '',
395
-            'longitude'                => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '',
394
+            'latitude'                 => isset($default_location->city_latitude) ? $default_location->city_latitude : '',
395
+            'longitude'                => isset($default_location->city_longitude) ? $default_location->city_longitude : '',
396 396
             'streetViewControl'        => true,
397 397
             'showPreview'              => '0',
398 398
             'maxZoom'                  => 21,
399 399
             'bubble_size'              => 'small',
400 400
         );
401 401
 
402
-        if ( is_single() ) {
402
+        if (is_single()) {
403 403
             global $post;
404
-            if ( isset( $post->post_latitude ) ) {
404
+            if (isset($post->post_latitude)) {
405 405
                 $map_args['latitude']  = $post->post_latitude;
406 406
                 $map_args['longitude'] = $post->post_longitude;
407 407
             }
@@ -412,24 +412,24 @@  discard block
 block discarded – undo
412 412
         }
413 413
 
414 414
         // Add marker cluster
415
-        if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) {
415
+        if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) {
416 416
             $map_args['enable_marker_cluster'] = true;
417 417
         } else {
418 418
             $map_args['enable_marker_cluster'] = false;
419 419
         }
420 420
 
421
-        geodir_draw_map( $map_args );
421
+        geodir_draw_map($map_args);
422 422
 
423 423
         $output = ob_get_contents();
424 424
 
425 425
         ob_end_clean();
426 426
 
427
-        foreach ( $backup_globals as $global => $value ) {
427
+        foreach ($backup_globals as $global => $value) {
428 428
             ${$global} = $value;
429 429
         }
430 430
 
431 431
         return $output;
432
-    }else{
432
+    } else {
433 433
         ob_start();
434 434
         add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array
435 435
         add_action('the_post', 'create_list_jsondata'); // Add marker in json array
@@ -476,16 +476,16 @@  discard block
 block discarded – undo
476 476
             $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
477 477
             $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
478 478
             $map_args['map_class_name'] = 'geodir-map-listing-page';
479
-			if ( geodir_is_page( 'search' ) ) {
479
+			if (geodir_is_page('search')) {
480 480
 				$map_default_lat = '';
481 481
 				$map_default_lng = '';
482
-				if ( isset( $_REQUEST['sgeo_lat'] ) && isset( $_REQUEST['sgeo_lon'] ) ) {
483
-					$map_default_lat = (float)sanitize_text_field( $_REQUEST['sgeo_lat'] );
484
-					$map_default_lng = (float)sanitize_text_field( $_REQUEST['sgeo_lon'] );
482
+				if (isset($_REQUEST['sgeo_lat']) && isset($_REQUEST['sgeo_lon'])) {
483
+					$map_default_lat = (float) sanitize_text_field($_REQUEST['sgeo_lat']);
484
+					$map_default_lng = (float) sanitize_text_field($_REQUEST['sgeo_lon']);
485 485
 				}
486
-				if ( empty( $map_default_lat ) && empty( $map_default_lng ) && ! empty( $_REQUEST['set_location_type'] ) && ! empty( $_REQUEST['set_location_val'] ) && function_exists( 'geodir_get_location_by_id' ) ) {
487
-					$location = geodir_get_location_by_id( '', (int)$_REQUEST['set_location_val'] );
488
-					if ( ! empty( $location ) ) {
486
+				if (empty($map_default_lat) && empty($map_default_lng) && !empty($_REQUEST['set_location_type']) && !empty($_REQUEST['set_location_val']) && function_exists('geodir_get_location_by_id')) {
487
+					$location = geodir_get_location_by_id('', (int) $_REQUEST['set_location_val']);
488
+					if (!empty($location)) {
489 489
 						$map_default_lat = $location->city_latitude;
490 490
 						$map_default_lng = $location->city_longitude;
491 491
 					}
@@ -1065,20 +1065,20 @@  discard block
 block discarded – undo
1065 1065
 	
1066 1066
 	$show_adv_search = isset($params['show_adv_search']) && in_array($params['show_adv_search'], array('default', 'always', 'searched')) ? $params['show_adv_search'] : '';
1067 1067
 	
1068
-	if ($show_adv_search != '' ) {
1069
-		$show_adv_class = 'geodir-advance-search-' . $show_adv_search . ' ';
1068
+	if ($show_adv_search != '') {
1069
+		$show_adv_class = 'geodir-advance-search-'.$show_adv_search.' ';
1070 1070
 		if ($show_adv_search == 'searched' && geodir_is_page('search')) {
1071 1071
 			$show_adv_search = 'search';
1072 1072
 		}
1073
-		$show_adv_attrs = 'data-show-adv="' . $show_adv_search . '"';
1073
+		$show_adv_attrs = 'data-show-adv="'.$show_adv_search.'"';
1074 1074
 		
1075
-		$params['before_widget'] = str_replace('class="', $show_adv_attrs . ' class="' . $show_adv_class, $params['before_widget']);
1075
+		$params['before_widget'] = str_replace('class="', $show_adv_attrs.' class="'.$show_adv_class, $params['before_widget']);
1076 1076
 	}
1077 1077
 	
1078 1078
 	ob_start();
1079 1079
 	
1080 1080
 	//geodir_get_template_part('listing', 'filter-form');
1081
-	the_widget('geodir_advance_search_widget', $params, $params );
1081
+	the_widget('geodir_advance_search_widget', $params, $params);
1082 1082
 	
1083 1083
 	$output = ob_get_contents();
1084 1084
     ob_end_clean();
@@ -1273,13 +1273,13 @@  discard block
 block discarded – undo
1273 1273
     // Post_number needs to be a positive integer
1274 1274
     if (!empty($params['post_author'])) {
1275 1275
         // 'current' left for backwards compatibility
1276
-        if ( $params['post_author'] == 'current' || $params['post_author'] == 'current_author') {
1276
+        if ($params['post_author'] == 'current' || $params['post_author'] == 'current_author') {
1277 1277
             if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) {
1278 1278
                 $params['post_author'] = $post->post_author;
1279 1279
             } else {
1280 1280
                 $params['post_author'] = -1; // Don't show any listings.
1281 1281
             }
1282
-        } else if ($params['post_author'] == 'current_user' ) {
1282
+        } else if ($params['post_author'] == 'current_user') {
1283 1283
             if ($current_user_id = get_current_user_id()) {
1284 1284
                 $params['post_author'] = $current_user_id;
1285 1285
             } else {
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 
1297 1297
     // Validate character_count
1298 1298
     //todo: is this necessary?
1299
-    $params['character_count']  = $params['character_count'];
1299
+    $params['character_count'] = $params['character_count'];
1300 1300
 
1301 1301
     // Validate our layout choice
1302 1302
     // Outside of the norm, I added some more simple terms to match the existing
@@ -1308,7 +1308,7 @@  discard block
 block discarded – undo
1308 1308
 
1309 1309
     // Validate Listing width, used in the template widget-listing-listview.php
1310 1310
     // The context is in width=$listing_width% - So we need a positive number between 0 & 100
1311
-    $params['listing_width']    = gdsc_validate_listing_width($params['listing_width']);
1311
+    $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']);
1312 1312
 
1313 1313
     // Validate the checkboxes used on the widget
1314 1314
     $params['add_location_filter']  = gdsc_to_bool_val($params['add_location_filter']);
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
     // User favorites
1324 1324
     $params['show_favorites_only']  = gdsc_to_bool_val($params['show_favorites_only']);
1325 1325
     if (!empty($params['show_favorites_only'])) {
1326
-        if ( $params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') {
1326
+        if ($params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') {
1327 1327
             if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) {
1328 1328
                 $params['favorites_by_user'] = $post->post_author;
1329 1329
             } else {
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
     if (!empty($params['tags'])) {
1347 1347
         if (!is_array($params['tags'])) {
1348 1348
             $comma = _x(',', 'tag delimiter');
1349
-            if ( ',' !== $comma ) {
1349
+            if (',' !== $comma) {
1350 1350
                 $params['tags'] = str_replace($comma, ',', $params['tags']);
1351 1351
             }
1352 1352
             $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,"));
@@ -1368,13 +1368,13 @@  discard block
 block discarded – undo
1368 1368
         unset($atts['pageno']);
1369 1369
     }
1370 1370
 
1371
-    if ( !empty($atts['shortcode_content']) ) {
1371
+    if (!empty($atts['shortcode_content'])) {
1372 1372
         $content = $atts['shortcode_content'];
1373 1373
     }
1374 1374
     $params['shortcode_content'] = trim($content);
1375 1375
     $atts['shortcode_content'] = trim($content);
1376 1376
     
1377
-    $params['shortcode_atts']       = $atts;
1377
+    $params['shortcode_atts'] = $atts;
1378 1378
 
1379 1379
     $output = geodir_sc_gd_listings_output($params);
1380 1380
 
@@ -1446,8 +1446,8 @@  discard block
 block discarded – undo
1446 1446
     // Validate the checkboxes used on the widget
1447 1447
     $params['hide_empty'] 	= gdsc_to_bool_val($params['hide_empty']);
1448 1448
     $params['show_count'] 	= gdsc_to_bool_val($params['show_count']);
1449
-    $params['hide_icon'] 	= gdsc_to_bool_val($params['hide_icon']);
1450
-    $params['cpt_left'] 	= gdsc_to_bool_val($params['cpt_left']);
1449
+    $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']);
1450
+    $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']);
1451 1451
 
1452 1452
     if ($params['max_count'] != 'all') {
1453 1453
         $params['max_count'] = absint($params['max_count']);
Please login to merge, or discard this patch.
geodirectory-admin/option-pages/notifications_settings_array.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         'id' => 'geodir_post_submited_success_email_subject_admin',
130 130
         'type' => 'text',
131 131
         'css' => 'min-width:300px;',
132
-        'std' => __('Post Submitted Successfully','geodirectory') // Default value for the page title - changed in settings
132
+        'std' => __('Post Submitted Successfully', 'geodirectory') // Default value for the page title - changed in settings
133 133
     ),
134 134
      array(
135 135
         'name' => '',
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         'id' => 'geodir_post_submited_success_email_content_admin',
138 138
         'css' => 'width:500px; height: 150px;',
139 139
         'type' => 'textarea',
140
-        'std' => __('<p>Dear Admin,</p><p>A new  listing has been published [#listing_link#]. This email is just for your information.</p><br><p>[#site_name#]</p>','geodirectory')
140
+        'std' => __('<p>Dear Admin,</p><p>A new  listing has been published [#listing_link#]. This email is just for your information.</p><br><p>[#site_name#]</p>', 'geodirectory')
141 141
     ),
142 142
     array(
143 143
         'name' => __('Notify Admin when listing edited by Author', 'geodirectory'),
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         'id' => 'geodir_post_submited_success_email_subject',
189 189
         'type' => 'text',
190 190
         'css' => 'min-width:300px;',
191
-        'std' => __('Post Submitted Successfully','geodirectory') // Default value for the page title - changed in settings
191
+        'std' => __('Post Submitted Successfully', 'geodirectory') // Default value for the page title - changed in settings
192 192
     ),
193 193
     array(
194 194
         'name' => '',
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         'id' => 'geodir_post_submited_success_email_content',
197 197
         'css' => 'width:500px; height: 150px;',
198 198
         'type' => 'textarea',
199
-        'std' => __('<p>Dear [#client_name#],</p><p>You submitted the below listing information. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>','geodirectory')
199
+        'std' => __('<p>Dear [#client_name#],</p><p>You submitted the below listing information. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>', 'geodirectory')
200 200
     ),
201 201
 
202 202
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         'id' => 'geodir_forgot_password_content',
215 215
         'css' => 'width:500px; height: 150px;',
216 216
         'type' => 'textarea',
217
-        'std' => __("<p>Dear [#client_name#],<p><p>You requested a new password for [#site_name_url#]</p><p>[#login_details#]</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>",'geodirectory')
217
+        'std' => __("<p>Dear [#client_name#],<p><p>You requested a new password for [#site_name_url#]</p><p>[#login_details#]</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>", 'geodirectory')
218 218
     ),
219 219
 
220 220
     array(
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         'id' => 'geodir_registration_success_email_content',
232 232
         'css' => 'width:500px; height: 150px;',
233 233
         'type' => 'textarea',
234
-        'std' => __("<p>Dear [#client_name#],</p><p>You can log in  with the following information:</p><p>[#login_details#]</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>",'geodirectory')
234
+        'std' => __("<p>Dear [#client_name#],</p><p>You can log in  with the following information:</p><p>[#login_details#]</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>", 'geodirectory')
235 235
     ),
236 236
     array(
237 237
         'name' => __('Listing published email', 'geodirectory'),
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         'id' => 'geodir_email_friend_content',
271 271
         'css' => 'width:500px; height: 150px;',
272 272
         'type' => 'textarea',
273
-        'std' => __("<p>Dear [#to_name#],<p><p>Your friend has sent you a message from <b>[#site_name#]</b> </p><p>===============================</p><p><b>Subject : [#subject#]</b></p><p>[#comments#] [#listing_link#]</p><p>===============================</p><p>Thank you,<br /><br />[#site_name#].</p>",'geodirectory')
273
+        'std' => __("<p>Dear [#to_name#],<p><p>Your friend has sent you a message from <b>[#site_name#]</b> </p><p>===============================</p><p><b>Subject : [#subject#]</b></p><p>[#comments#] [#listing_link#]</p><p>===============================</p><p>Thank you,<br /><br />[#site_name#].</p>", 'geodirectory')
274 274
     ),
275 275
 
276 276
     array(
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         'id' => 'geodir_email_enquiry_content',
288 288
         'css' => 'width:500px; height: 150px;',
289 289
         'type' => 'textarea',
290
-        'std' => __("<p>Dear [#to_name#],<p><p>An enquiry has been sent from <b>[#listing_link#]</b></p><p>===============================</p><p>[#comments#]</p><p>===============================</p><p>Thank you,<br /><br />[#site_name_url#].</p>",'geodirectory')
290
+        'std' => __("<p>Dear [#to_name#],<p><p>An enquiry has been sent from <b>[#listing_link#]</b></p><p>===============================</p><p>[#comments#]</p><p>===============================</p><p>Thank you,<br /><br />[#site_name_url#].</p>", 'geodirectory')
291 291
     ),
292 292
 
293 293
     array('type' => 'sectionend', 'id' => 'other_emails'),
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
         'id' => 'geodir_post_added_success_msg_content',
304 304
         'css' => 'width:500px; height: 150px;',
305 305
         'type' => 'textarea',
306
-        'std' => __('<p>Thank you, your information has been successfully received.</p><p><a href="[#submited_information_link#]" >View your submitted information &raquo;</a></p><p>Thank you for visiting us at [#site_name#].</p>','geodirectory')
306
+        'std' => __('<p>Thank you, your information has been successfully received.</p><p><a href="[#submited_information_link#]" >View your submitted information &raquo;</a></p><p>Thank you for visiting us at [#site_name#].</p>', 'geodirectory')
307 307
     ),
308 308
 
309 309
 
Please login to merge, or discard this patch.
Indentation   +309 added lines, -309 removed lines patch added patch discarded remove patch
@@ -17,314 +17,314 @@
 block discarded – undo
17 17
 $geodir_settings['notifications_settings'] = apply_filters('geodir_notifications_settings', array(
18 18
 
19 19
 
20
-    array('name' => __('Options', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'notification_options'),
21
-
22
-
23
-    array('name' => __('Notification Options', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'notification_options'),
24
-
25
-    array(
26
-        'name' => __('List of usable shortcodes', 'geodirectory'),
27
-        'desc' => __('[#client_name#],[#listing_link#],[#posted_date#],[#number_of_days#],[#number_of_grace_days#],[#login_url#],[#username#],[#user_email#],[#site_name_url#],[#renew_link#],[#post_id#],[#site_name#],[#from_email#](in most cases this will be the admin email, except for popup forms)', 'geodirectory'),
28
-        'id' => 'geodir_list_of_usable_shordcodes',
29
-        'type' => 'html_content',
30
-        'css' => 'min-width:300px;',
31
-        'std' => 'All Places' // Default value for the page title - changed in settings
32
-    ),
33
-
34
-    array(
35
-        'name' => __('Use advanced editor? (slow loading)', 'geodirectory'),
36
-        'desc' => __('Yes', 'geodirectory'),
37
-        'id' => 'geodir_tiny_editor',
38
-        'std' => 'yes',
39
-        'type' => 'radio',
40
-        'value' => '1',
41
-        'radiogroup' => 'start'
42
-    ),
43
-    array(
44
-        'name' => __('Use advanced editor?(slow loading)', 'geodirectory'),
45
-        'desc' => __('No', 'geodirectory'),
46
-        'id' => 'geodir_tiny_editor',
47
-        'std' => 'yes',
48
-        'type' => 'radio',
49
-        'value' => '0',
50
-        'radiogroup' => 'end'
51
-    ),
52
-
53
-
54
-    array('type' => 'sectionend', 'id' => 'notification_options'),
55
-
56
-
57
-    array('name' => __('Site Bcc Options', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'site_bcc_options'),
58
-
59
-    array('name' => __('Site Bcc Options', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'site_bcc_options'),
60
-
61
-    array(
62
-        'name' => __('New user registration', 'geodirectory'),
63
-        'desc' => __('Yes', 'geodirectory'),
64
-        'id' => 'geodir_bcc_new_user',
65
-        'std' => 'yes',
66
-        'type' => 'radio',
67
-        'value' => '1',
68
-        'radiogroup' => 'start'
69
-    ),
70
-    array(
71
-        'name' => __('New user registration', 'geodirectory'),
72
-        'desc' => __('No', 'geodirectory'),
73
-        'id' => 'geodir_bcc_new_user',
74
-        'std' => 'yes',
75
-        'type' => 'radio',
76
-        'value' => '0',
77
-        'radiogroup' => 'end'
78
-    ),
79
-
80
-    array(
81
-        'name' => __('Send to friend', 'geodirectory'),
82
-        'desc' => __('Yes', 'geodirectory'),
83
-        'id' => 'geodir_bcc_friend',
84
-        'std' => 'yes',
85
-        'type' => 'radio',
86
-        'value' => '1',
87
-        'radiogroup' => 'start'
88
-    ),
89
-    array(
90
-        'name' => __('Send to friend', 'geodirectory'),
91
-        'desc' => __('No', 'geodirectory'),
92
-        'id' => 'geodir_bcc_friend',
93
-        'std' => 'yes',
94
-        'type' => 'radio',
95
-        'value' => '0',
96
-        'radiogroup' => 'end'
97
-    ),
98
-
99
-    array(
100
-        'name' => __('Send enquiry', 'geodirectory'),
101
-        'desc' => __('Yes', 'geodirectory'),
102
-        'id' => 'geodir_bcc_enquiry',
103
-        'std' => 'yes',
104
-        'type' => 'radio',
105
-        'value' => '1',
106
-        'radiogroup' => 'start'
107
-    ),
108
-    array(
109
-        'name' => __('Send enquiry', 'geodirectory'),
110
-        'desc' => __('No', 'geodirectory'),
111
-        'id' => 'geodir_bcc_enquiry',
112
-        'std' => 'yes',
113
-        'type' => 'radio',
114
-        'value' => '0',
115
-        'radiogroup' => 'end'
116
-    ),
117
-
118
-
119
-    array('type' => 'sectionend', 'id' => 'site_bcc_options'),
120
-
121
-
122
-    array('name' => __('Admin Emails', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'admin_emails'),
123
-
124
-    array('name' => __('Admin Emails', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'admin_emails'),
125
-
126
-    array(
127
-        'name' => __('Notify to admin on post submit', 'geodirectory'),
128
-        'desc' => __('Yes', 'geodirectory'),
129
-        'id' => 'geodir_notify_post_submit',
130
-        'std' => '1',
131
-        'type' => 'radio',
132
-        'value' => '1',
133
-        'radiogroup' => 'start'
134
-    ),
135
-    array(
136
-        'name' => __('Notify to admin on post submit', 'geodirectory'),
137
-        'desc' => __('No', 'geodirectory'),
138
-        'id' => 'geodir_notify_post_submit',
139
-        'std' => '1',
140
-        'type' => 'radio',
141
-        'value' => '0',
142
-        'radiogroup' => 'end'
143
-    ),
144
-    array(
145
-        'name' => __('Post submit success to admin email', 'geodirectory'),
146
-        'desc' => '',
147
-        'id' => 'geodir_post_submited_success_email_subject_admin',
148
-        'type' => 'text',
149
-        'css' => 'min-width:300px;',
150
-        'std' => __('Post Submitted Successfully','geodirectory') // Default value for the page title - changed in settings
151
-    ),
152
-     array(
153
-        'name' => '',
154
-        'desc' => '',
155
-        'id' => 'geodir_post_submited_success_email_content_admin',
156
-        'css' => 'width:500px; height: 150px;',
157
-        'type' => 'textarea',
158
-        'std' => __('<p>Dear Admin,</p><p>A new  listing has been published [#listing_link#]. This email is just for your information.</p><br><p>[#site_name#]</p>','geodirectory')
159
-    ),
160
-    array(
161
-        'name' => __('Notify Admin when listing edited by Author', 'geodirectory'),
162
-        'desc' => __('Yes', 'geodirectory'),
163
-        'id' => 'geodir_notify_post_edited',
164
-        'std' => '0',
165
-        'type' => 'radio',
166
-        'value' => '1',
167
-        'radiogroup' => 'start'
168
-    ),
169
-    array(
170
-        'name' => __('Notify Admin when listing edited by Author', 'geodirectory'),
171
-        'desc' => __('No', 'geodirectory'),
172
-        'id' => 'geodir_notify_post_edited',
173
-        'std' => '0',
174
-        'type' => 'radio',
175
-        'value' => '0',
176
-        'radiogroup' => 'end'
177
-    ),
178
-    array(
179
-        'name' => __('Listing edited by Author', 'geodirectory'),
180
-        'desc' => '',
181
-        'id' => 'geodir_post_edited_email_subject_admin',
182
-        'type' => 'text',
183
-        'css' => 'min-width:300px;',
184
-        'std' => __('[[#site_name#]] Listing edited by Author', 'geodirectory')
185
-    ),
186
-    array(
187
-        'name' => '',
188
-        'desc' => '',
189
-        'id' => 'geodir_post_edited_email_content_admin',
190
-        'css' => 'width:500px; height: 150px;',
191
-        'type' => 'textarea',
192
-        'std' => __('<p>Dear Admin,</p><p>A listing [#listing_link#] has been edited by it\'s author [#post_author_name#].</p><br><p><b>Listing Details:</b></p><p>Listing ID: [#post_id#]</p><p>Listing URL: [#listing_link#]</p><p>Date: [#current_date#]</p><br><p>This email is just for your information.</p><p>[#site_name#]</p>', 'geodirectory')
193
-    ),
194
-
195
-
196
-    array('type' => 'sectionend', 'id' => 'admin_emails'),
197
-
198
-
199
-    array('name' => __('Client Emails', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'client_emails'),
200
-
201
-    array('name' => __('Client Emails', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'client_emails'),
202
-
203
-    array(
204
-        'name' => __('Post submit success to client email', 'geodirectory'),
205
-        'desc' => '',
206
-        'id' => 'geodir_post_submited_success_email_subject',
207
-        'type' => 'text',
208
-        'css' => 'min-width:300px;',
209
-        'std' => __('Post Submitted Successfully','geodirectory') // Default value for the page title - changed in settings
210
-    ),
211
-    array(
212
-        'name' => '',
213
-        'desc' => '',
214
-        'id' => 'geodir_post_submited_success_email_content',
215
-        'css' => 'width:500px; height: 150px;',
216
-        'type' => 'textarea',
217
-        'std' => __('<p>Dear [#client_name#],</p><p>You submitted the below listing information. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>','geodirectory')
218
-    ),
219
-
220
-
221
-    array(
222
-        'name' => __('User forgot password email', 'geodirectory'),
223
-        'desc' => '',
224
-        'id' => 'geodir_forgot_password_subject',
225
-        'type' => 'text',
226
-        'css' => 'min-width:300px;',
227
-        'std' => __('[#site_name#] - Your new password', 'geodirectory') // Default value for the page title - changed in settings
228
-    ),
229
-    array(
230
-        'name' => '',
231
-        'desc' => '',
232
-        'id' => 'geodir_forgot_password_content',
233
-        'css' => 'width:500px; height: 150px;',
234
-        'type' => 'textarea',
235
-        'std' => __("<p>Dear [#client_name#],<p><p>You requested a new password for [#site_name_url#]</p><p>[#login_details#]</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>",'geodirectory')
236
-    ),
237
-
238
-    array(
239
-        'name' => __('Registration success email', 'geodirectory'),
240
-        'desc' => '',
241
-        'id' => 'geodir_registration_success_email_subject',
242
-        'type' => 'text',
243
-        'css' => 'min-width:300px;',
244
-        'std' => __('Your Log In Details', 'geodirectory') // Default value for the page title - changed in settings
245
-    ),
246
-    array(
247
-        'name' => '',
248
-        'desc' => '',
249
-        'id' => 'geodir_registration_success_email_content',
250
-        'css' => 'width:500px; height: 150px;',
251
-        'type' => 'textarea',
252
-        'std' => __("<p>Dear [#client_name#],</p><p>You can log in  with the following information:</p><p>[#login_details#]</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>",'geodirectory')
253
-    ),
254
-    array(
255
-        'name' => __('Listing published email', 'geodirectory'),
256
-        'desc' => '',
257
-        'id' => 'geodir_post_published_email_subject',
258
-        'type' => 'text',
259
-        'css' => 'min-width:300px;',
260
-        'std' => __('Listing Published Successfully', 'geodirectory') // Default value for the page title - changed in settings
261
-    ),
262
-    array(
263
-        'name' => '',
264
-        'desc' => '',
265
-        'id' => 'geodir_post_published_email_content',
266
-        'css' => 'width:500px; height: 150px;',
267
-        'type' => 'textarea',
268
-        'std' => __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory')
269
-    ),
270
-
271
-    array('type' => 'sectionend', 'id' => 'client_emails'),
272
-
273
-    array('name' => __('Other Emails', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'other_emails'),
274
-
275
-    array('name' => __('Other Emails', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'other_emails'),
276
-
277
-    array(
278
-        'name' => __('Send to friend', 'geodirectory'),
279
-        'desc' => '',
280
-        'id' => 'geodir_email_friend_subject',
281
-        'type' => 'text',
282
-        'css' => 'min-width:300px;',
283
-        'std' => __('[#from_name#] thought you might be interested in..', 'geodirectory')
284
-    ),
285
-    array(
286
-        'name' => '',
287
-        'desc' => '',
288
-        'id' => 'geodir_email_friend_content',
289
-        'css' => 'width:500px; height: 150px;',
290
-        'type' => 'textarea',
291
-        'std' => __("<p>Dear [#to_name#],<p><p>Your friend has sent you a message from <b>[#site_name#]</b> </p><p>===============================</p><p><b>Subject : [#subject#]</b></p><p>[#comments#] [#listing_link#]</p><p>===============================</p><p>Thank you,<br /><br />[#site_name#].</p>",'geodirectory')
292
-    ),
293
-
294
-    array(
295
-        'name' => __('Email enquiry', 'geodirectory'),
296
-        'desc' => '',
297
-        'id' => 'geodir_email_enquiry_subject',
298
-        'type' => 'text',
299
-        'css' => 'min-width:300px;',
300
-        'std' => __('Website Enquiry', 'geodirectory')
301
-    ),
302
-    array(
303
-        'name' => '',
304
-        'desc' => '',
305
-        'id' => 'geodir_email_enquiry_content',
306
-        'css' => 'width:500px; height: 150px;',
307
-        'type' => 'textarea',
308
-        'std' => __("<p>Dear [#to_name#],<p><p>An enquiry has been sent from <b>[#listing_link#]</b></p><p>===============================</p><p>[#comments#]</p><p>===============================</p><p>Thank you,<br /><br />[#site_name_url#].</p>",'geodirectory')
309
-    ),
310
-
311
-    array('type' => 'sectionend', 'id' => 'other_emails'),
312
-
313
-
314
-    array('name' => __('Messages', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'messages'),
315
-
316
-    array('name' => __('Messages', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'messages'),
317
-
318
-    array(
319
-        'name' => __('Post submitted success', 'geodirectory'),
320
-        'desc' => '',
321
-        'id' => 'geodir_post_added_success_msg_content',
322
-        'css' => 'width:500px; height: 150px;',
323
-        'type' => 'textarea',
324
-        'std' => __('<p>Thank you, your information has been successfully received.</p><p><a href="[#submited_information_link#]" >View your submitted information &raquo;</a></p><p>Thank you for visiting us at [#site_name#].</p>','geodirectory')
325
-    ),
326
-
327
-
328
-    array('type' => 'sectionend', 'id' => 'messages'),
20
+	array('name' => __('Options', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'notification_options'),
21
+
22
+
23
+	array('name' => __('Notification Options', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'notification_options'),
24
+
25
+	array(
26
+		'name' => __('List of usable shortcodes', 'geodirectory'),
27
+		'desc' => __('[#client_name#],[#listing_link#],[#posted_date#],[#number_of_days#],[#number_of_grace_days#],[#login_url#],[#username#],[#user_email#],[#site_name_url#],[#renew_link#],[#post_id#],[#site_name#],[#from_email#](in most cases this will be the admin email, except for popup forms)', 'geodirectory'),
28
+		'id' => 'geodir_list_of_usable_shordcodes',
29
+		'type' => 'html_content',
30
+		'css' => 'min-width:300px;',
31
+		'std' => 'All Places' // Default value for the page title - changed in settings
32
+	),
33
+
34
+	array(
35
+		'name' => __('Use advanced editor? (slow loading)', 'geodirectory'),
36
+		'desc' => __('Yes', 'geodirectory'),
37
+		'id' => 'geodir_tiny_editor',
38
+		'std' => 'yes',
39
+		'type' => 'radio',
40
+		'value' => '1',
41
+		'radiogroup' => 'start'
42
+	),
43
+	array(
44
+		'name' => __('Use advanced editor?(slow loading)', 'geodirectory'),
45
+		'desc' => __('No', 'geodirectory'),
46
+		'id' => 'geodir_tiny_editor',
47
+		'std' => 'yes',
48
+		'type' => 'radio',
49
+		'value' => '0',
50
+		'radiogroup' => 'end'
51
+	),
52
+
53
+
54
+	array('type' => 'sectionend', 'id' => 'notification_options'),
55
+
56
+
57
+	array('name' => __('Site Bcc Options', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'site_bcc_options'),
58
+
59
+	array('name' => __('Site Bcc Options', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'site_bcc_options'),
60
+
61
+	array(
62
+		'name' => __('New user registration', 'geodirectory'),
63
+		'desc' => __('Yes', 'geodirectory'),
64
+		'id' => 'geodir_bcc_new_user',
65
+		'std' => 'yes',
66
+		'type' => 'radio',
67
+		'value' => '1',
68
+		'radiogroup' => 'start'
69
+	),
70
+	array(
71
+		'name' => __('New user registration', 'geodirectory'),
72
+		'desc' => __('No', 'geodirectory'),
73
+		'id' => 'geodir_bcc_new_user',
74
+		'std' => 'yes',
75
+		'type' => 'radio',
76
+		'value' => '0',
77
+		'radiogroup' => 'end'
78
+	),
79
+
80
+	array(
81
+		'name' => __('Send to friend', 'geodirectory'),
82
+		'desc' => __('Yes', 'geodirectory'),
83
+		'id' => 'geodir_bcc_friend',
84
+		'std' => 'yes',
85
+		'type' => 'radio',
86
+		'value' => '1',
87
+		'radiogroup' => 'start'
88
+	),
89
+	array(
90
+		'name' => __('Send to friend', 'geodirectory'),
91
+		'desc' => __('No', 'geodirectory'),
92
+		'id' => 'geodir_bcc_friend',
93
+		'std' => 'yes',
94
+		'type' => 'radio',
95
+		'value' => '0',
96
+		'radiogroup' => 'end'
97
+	),
98
+
99
+	array(
100
+		'name' => __('Send enquiry', 'geodirectory'),
101
+		'desc' => __('Yes', 'geodirectory'),
102
+		'id' => 'geodir_bcc_enquiry',
103
+		'std' => 'yes',
104
+		'type' => 'radio',
105
+		'value' => '1',
106
+		'radiogroup' => 'start'
107
+	),
108
+	array(
109
+		'name' => __('Send enquiry', 'geodirectory'),
110
+		'desc' => __('No', 'geodirectory'),
111
+		'id' => 'geodir_bcc_enquiry',
112
+		'std' => 'yes',
113
+		'type' => 'radio',
114
+		'value' => '0',
115
+		'radiogroup' => 'end'
116
+	),
117
+
118
+
119
+	array('type' => 'sectionend', 'id' => 'site_bcc_options'),
120
+
121
+
122
+	array('name' => __('Admin Emails', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'admin_emails'),
123
+
124
+	array('name' => __('Admin Emails', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'admin_emails'),
125
+
126
+	array(
127
+		'name' => __('Notify to admin on post submit', 'geodirectory'),
128
+		'desc' => __('Yes', 'geodirectory'),
129
+		'id' => 'geodir_notify_post_submit',
130
+		'std' => '1',
131
+		'type' => 'radio',
132
+		'value' => '1',
133
+		'radiogroup' => 'start'
134
+	),
135
+	array(
136
+		'name' => __('Notify to admin on post submit', 'geodirectory'),
137
+		'desc' => __('No', 'geodirectory'),
138
+		'id' => 'geodir_notify_post_submit',
139
+		'std' => '1',
140
+		'type' => 'radio',
141
+		'value' => '0',
142
+		'radiogroup' => 'end'
143
+	),
144
+	array(
145
+		'name' => __('Post submit success to admin email', 'geodirectory'),
146
+		'desc' => '',
147
+		'id' => 'geodir_post_submited_success_email_subject_admin',
148
+		'type' => 'text',
149
+		'css' => 'min-width:300px;',
150
+		'std' => __('Post Submitted Successfully','geodirectory') // Default value for the page title - changed in settings
151
+	),
152
+	 array(
153
+		'name' => '',
154
+		'desc' => '',
155
+		'id' => 'geodir_post_submited_success_email_content_admin',
156
+		'css' => 'width:500px; height: 150px;',
157
+		'type' => 'textarea',
158
+		'std' => __('<p>Dear Admin,</p><p>A new  listing has been published [#listing_link#]. This email is just for your information.</p><br><p>[#site_name#]</p>','geodirectory')
159
+	),
160
+	array(
161
+		'name' => __('Notify Admin when listing edited by Author', 'geodirectory'),
162
+		'desc' => __('Yes', 'geodirectory'),
163
+		'id' => 'geodir_notify_post_edited',
164
+		'std' => '0',
165
+		'type' => 'radio',
166
+		'value' => '1',
167
+		'radiogroup' => 'start'
168
+	),
169
+	array(
170
+		'name' => __('Notify Admin when listing edited by Author', 'geodirectory'),
171
+		'desc' => __('No', 'geodirectory'),
172
+		'id' => 'geodir_notify_post_edited',
173
+		'std' => '0',
174
+		'type' => 'radio',
175
+		'value' => '0',
176
+		'radiogroup' => 'end'
177
+	),
178
+	array(
179
+		'name' => __('Listing edited by Author', 'geodirectory'),
180
+		'desc' => '',
181
+		'id' => 'geodir_post_edited_email_subject_admin',
182
+		'type' => 'text',
183
+		'css' => 'min-width:300px;',
184
+		'std' => __('[[#site_name#]] Listing edited by Author', 'geodirectory')
185
+	),
186
+	array(
187
+		'name' => '',
188
+		'desc' => '',
189
+		'id' => 'geodir_post_edited_email_content_admin',
190
+		'css' => 'width:500px; height: 150px;',
191
+		'type' => 'textarea',
192
+		'std' => __('<p>Dear Admin,</p><p>A listing [#listing_link#] has been edited by it\'s author [#post_author_name#].</p><br><p><b>Listing Details:</b></p><p>Listing ID: [#post_id#]</p><p>Listing URL: [#listing_link#]</p><p>Date: [#current_date#]</p><br><p>This email is just for your information.</p><p>[#site_name#]</p>', 'geodirectory')
193
+	),
194
+
195
+
196
+	array('type' => 'sectionend', 'id' => 'admin_emails'),
197
+
198
+
199
+	array('name' => __('Client Emails', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'client_emails'),
200
+
201
+	array('name' => __('Client Emails', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'client_emails'),
202
+
203
+	array(
204
+		'name' => __('Post submit success to client email', 'geodirectory'),
205
+		'desc' => '',
206
+		'id' => 'geodir_post_submited_success_email_subject',
207
+		'type' => 'text',
208
+		'css' => 'min-width:300px;',
209
+		'std' => __('Post Submitted Successfully','geodirectory') // Default value for the page title - changed in settings
210
+	),
211
+	array(
212
+		'name' => '',
213
+		'desc' => '',
214
+		'id' => 'geodir_post_submited_success_email_content',
215
+		'css' => 'width:500px; height: 150px;',
216
+		'type' => 'textarea',
217
+		'std' => __('<p>Dear [#client_name#],</p><p>You submitted the below listing information. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>','geodirectory')
218
+	),
219
+
220
+
221
+	array(
222
+		'name' => __('User forgot password email', 'geodirectory'),
223
+		'desc' => '',
224
+		'id' => 'geodir_forgot_password_subject',
225
+		'type' => 'text',
226
+		'css' => 'min-width:300px;',
227
+		'std' => __('[#site_name#] - Your new password', 'geodirectory') // Default value for the page title - changed in settings
228
+	),
229
+	array(
230
+		'name' => '',
231
+		'desc' => '',
232
+		'id' => 'geodir_forgot_password_content',
233
+		'css' => 'width:500px; height: 150px;',
234
+		'type' => 'textarea',
235
+		'std' => __("<p>Dear [#client_name#],<p><p>You requested a new password for [#site_name_url#]</p><p>[#login_details#]</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>",'geodirectory')
236
+	),
237
+
238
+	array(
239
+		'name' => __('Registration success email', 'geodirectory'),
240
+		'desc' => '',
241
+		'id' => 'geodir_registration_success_email_subject',
242
+		'type' => 'text',
243
+		'css' => 'min-width:300px;',
244
+		'std' => __('Your Log In Details', 'geodirectory') // Default value for the page title - changed in settings
245
+	),
246
+	array(
247
+		'name' => '',
248
+		'desc' => '',
249
+		'id' => 'geodir_registration_success_email_content',
250
+		'css' => 'width:500px; height: 150px;',
251
+		'type' => 'textarea',
252
+		'std' => __("<p>Dear [#client_name#],</p><p>You can log in  with the following information:</p><p>[#login_details#]</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>",'geodirectory')
253
+	),
254
+	array(
255
+		'name' => __('Listing published email', 'geodirectory'),
256
+		'desc' => '',
257
+		'id' => 'geodir_post_published_email_subject',
258
+		'type' => 'text',
259
+		'css' => 'min-width:300px;',
260
+		'std' => __('Listing Published Successfully', 'geodirectory') // Default value for the page title - changed in settings
261
+	),
262
+	array(
263
+		'name' => '',
264
+		'desc' => '',
265
+		'id' => 'geodir_post_published_email_content',
266
+		'css' => 'width:500px; height: 150px;',
267
+		'type' => 'textarea',
268
+		'std' => __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory')
269
+	),
270
+
271
+	array('type' => 'sectionend', 'id' => 'client_emails'),
272
+
273
+	array('name' => __('Other Emails', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'other_emails'),
274
+
275
+	array('name' => __('Other Emails', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'other_emails'),
276
+
277
+	array(
278
+		'name' => __('Send to friend', 'geodirectory'),
279
+		'desc' => '',
280
+		'id' => 'geodir_email_friend_subject',
281
+		'type' => 'text',
282
+		'css' => 'min-width:300px;',
283
+		'std' => __('[#from_name#] thought you might be interested in..', 'geodirectory')
284
+	),
285
+	array(
286
+		'name' => '',
287
+		'desc' => '',
288
+		'id' => 'geodir_email_friend_content',
289
+		'css' => 'width:500px; height: 150px;',
290
+		'type' => 'textarea',
291
+		'std' => __("<p>Dear [#to_name#],<p><p>Your friend has sent you a message from <b>[#site_name#]</b> </p><p>===============================</p><p><b>Subject : [#subject#]</b></p><p>[#comments#] [#listing_link#]</p><p>===============================</p><p>Thank you,<br /><br />[#site_name#].</p>",'geodirectory')
292
+	),
293
+
294
+	array(
295
+		'name' => __('Email enquiry', 'geodirectory'),
296
+		'desc' => '',
297
+		'id' => 'geodir_email_enquiry_subject',
298
+		'type' => 'text',
299
+		'css' => 'min-width:300px;',
300
+		'std' => __('Website Enquiry', 'geodirectory')
301
+	),
302
+	array(
303
+		'name' => '',
304
+		'desc' => '',
305
+		'id' => 'geodir_email_enquiry_content',
306
+		'css' => 'width:500px; height: 150px;',
307
+		'type' => 'textarea',
308
+		'std' => __("<p>Dear [#to_name#],<p><p>An enquiry has been sent from <b>[#listing_link#]</b></p><p>===============================</p><p>[#comments#]</p><p>===============================</p><p>Thank you,<br /><br />[#site_name_url#].</p>",'geodirectory')
309
+	),
310
+
311
+	array('type' => 'sectionend', 'id' => 'other_emails'),
312
+
313
+
314
+	array('name' => __('Messages', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'messages'),
315
+
316
+	array('name' => __('Messages', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'messages'),
317
+
318
+	array(
319
+		'name' => __('Post submitted success', 'geodirectory'),
320
+		'desc' => '',
321
+		'id' => 'geodir_post_added_success_msg_content',
322
+		'css' => 'width:500px; height: 150px;',
323
+		'type' => 'textarea',
324
+		'std' => __('<p>Thank you, your information has been successfully received.</p><p><a href="[#submited_information_link#]" >View your submitted information &raquo;</a></p><p>Thank you for visiting us at [#site_name#].</p>','geodirectory')
325
+	),
326
+
327
+
328
+	array('type' => 'sectionend', 'id' => 'messages'),
329 329
 
330 330
 )); // End Manage NOtifications settings
Please login to merge, or discard this patch.
geodirectory-admin/option-pages/general_settings_array.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@
 block discarded – undo
98 98
     ),
99 99
     array('type' => 'sectionend', 'id' => 'general_options'),
100 100
 
101
-));/* General Options End*/
101
+)); /* General Options End*/
102 102
 
103 103
 /**
104 104
  * Filter GD Google Analytic Settings array.
Please login to merge, or discard this patch.
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -16,92 +16,92 @@  discard block
 block discarded – undo
16 16
  */
17 17
 $general_options = apply_filters('geodir_general_options', array(
18 18
 
19
-    array('name' => __('General', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'general_options'),
20
-
21
-    array('name' => __('General Options', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'general_options'),
22
-
23
-    array(
24
-        'name' => __('Sender name', 'geodirectory'),
25
-        'desc' => __('(Name that will be shown as email sender when users receive emails from this site)', 'geodirectory'),
26
-        'id' => 'site_email_name',
27
-        'type' => 'text',
28
-        'css' => 'min-width:300px;',
29
-        'std' => get_bloginfo('name') // Default value for the page title - changed in settings
30
-    ),
31
-
32
-    array(
33
-        'name' => __('Email address', 'geodirectory'),
34
-        'desc' => __('(Emails to users will be sent via this mail ID)', 'geodirectory'),
35
-        'id' => 'site_email',
36
-        'type' => 'text',
37
-        'css' => 'min-width:300px;',
38
-        'std' => get_bloginfo('admin_email') // Default value for the page title - changed in settings
39
-    ),
40
-    array(
41
-        'name' => __('Allow user to see wp-admin area', 'geodirectory'),
42
-        'desc' => __('Yes', 'geodirectory'),
43
-        'id' => 'geodir_allow_wpadmin',
44
-        'std' => '1',
45
-        'type' => 'radio',
46
-        'value' => '1',
47
-        'radiogroup' => 'start'
48
-    ),
49
-    array(
50
-        'name' => __('Allow user to see wp-admin area', 'geodirectory'),
51
-        'desc' => __('No', 'geodirectory'),
52
-        'id' => 'geodir_allow_wpadmin',
53
-        'std' => '0',
54
-        'type' => 'radio',
55
-        'value' => '0',
56
-        'radiogroup' => 'end'
57
-    ),
58
-
59
-    array(
60
-        'name' => __('Allow user to choose own password', 'geodirectory'),
61
-        'desc' => __('Yes', 'geodirectory'),
62
-        'id' => 'geodir_allow_cpass',
63
-        'std' => '1',
64
-        'type' => 'radio',
65
-        'value' => '1',
66
-        'radiogroup' => 'start'
67
-    ),
68
-    array(
69
-        'name' => __('Allow user to choose own password', 'geodirectory'),
70
-        'desc' => __('No', 'geodirectory'),
71
-        'id' => 'geodir_allow_cpass',
72
-        'std' => '0',
73
-        'type' => 'radio',
74
-        'value' => '0',
75
-        'radiogroup' => 'end'
76
-    ),
77
-    array(
78
-        'name' => __('Disable review stars for CPT', 'geodirectory'),
79
-        'desc' => __('Disable review stars for certain CPT without disabling comments on listings.', 'geodirectory'),
80
-        'tip' => '',
81
-        'id' => 'geodir_disable_rating_cpt',
82
-        'css' => 'min-width:300px;',
83
-        'std' => '',
84
-        'type' => 'multiselect',
85
-        'placeholder_text' => __('Select post types', 'geodirectory'),
86
-        'class' => 'chosen_select',
87
-        'options' => array_unique(geodir_post_type_setting_fun())
88
-    ),
89
-    array(
90
-        'name' => __('User deleted posts go to trash', 'geodirectory'),
91
-        'desc' => __('If checked a user deleted post will go to trash, otherwise it will be permanently deleted', 'geodirectory'),
92
-        'id' => 'geodir_disable_perm_delete',
93
-        'type' => 'checkbox',
94
-        'std' => '1'
95
-    ),
96
-    array(
97
-        'name' => __('Max upload file size(in mb)', 'geodirectory'),
98
-        'desc' => __('(Maximum upload file size in MB, 1 MB = 1024 KB. Must be greater then 0(ZERO), for ex: 2. This setting will overwrite the max upload file size limit in image/file upload & import listings for entire GeoDirectory core + GeoDirectory plugins.)', 'geodirectory'),
99
-        'id' => 'geodir_upload_max_filesize',
100
-        'type' => 'text',
101
-        'css' => 'min-width:300px;',
102
-        'std' => '2'
103
-    ),
104
-    array('type' => 'sectionend', 'id' => 'general_options'),
19
+	array('name' => __('General', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'general_options'),
20
+
21
+	array('name' => __('General Options', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'general_options'),
22
+
23
+	array(
24
+		'name' => __('Sender name', 'geodirectory'),
25
+		'desc' => __('(Name that will be shown as email sender when users receive emails from this site)', 'geodirectory'),
26
+		'id' => 'site_email_name',
27
+		'type' => 'text',
28
+		'css' => 'min-width:300px;',
29
+		'std' => get_bloginfo('name') // Default value for the page title - changed in settings
30
+	),
31
+
32
+	array(
33
+		'name' => __('Email address', 'geodirectory'),
34
+		'desc' => __('(Emails to users will be sent via this mail ID)', 'geodirectory'),
35
+		'id' => 'site_email',
36
+		'type' => 'text',
37
+		'css' => 'min-width:300px;',
38
+		'std' => get_bloginfo('admin_email') // Default value for the page title - changed in settings
39
+	),
40
+	array(
41
+		'name' => __('Allow user to see wp-admin area', 'geodirectory'),
42
+		'desc' => __('Yes', 'geodirectory'),
43
+		'id' => 'geodir_allow_wpadmin',
44
+		'std' => '1',
45
+		'type' => 'radio',
46
+		'value' => '1',
47
+		'radiogroup' => 'start'
48
+	),
49
+	array(
50
+		'name' => __('Allow user to see wp-admin area', 'geodirectory'),
51
+		'desc' => __('No', 'geodirectory'),
52
+		'id' => 'geodir_allow_wpadmin',
53
+		'std' => '0',
54
+		'type' => 'radio',
55
+		'value' => '0',
56
+		'radiogroup' => 'end'
57
+	),
58
+
59
+	array(
60
+		'name' => __('Allow user to choose own password', 'geodirectory'),
61
+		'desc' => __('Yes', 'geodirectory'),
62
+		'id' => 'geodir_allow_cpass',
63
+		'std' => '1',
64
+		'type' => 'radio',
65
+		'value' => '1',
66
+		'radiogroup' => 'start'
67
+	),
68
+	array(
69
+		'name' => __('Allow user to choose own password', 'geodirectory'),
70
+		'desc' => __('No', 'geodirectory'),
71
+		'id' => 'geodir_allow_cpass',
72
+		'std' => '0',
73
+		'type' => 'radio',
74
+		'value' => '0',
75
+		'radiogroup' => 'end'
76
+	),
77
+	array(
78
+		'name' => __('Disable review stars for CPT', 'geodirectory'),
79
+		'desc' => __('Disable review stars for certain CPT without disabling comments on listings.', 'geodirectory'),
80
+		'tip' => '',
81
+		'id' => 'geodir_disable_rating_cpt',
82
+		'css' => 'min-width:300px;',
83
+		'std' => '',
84
+		'type' => 'multiselect',
85
+		'placeholder_text' => __('Select post types', 'geodirectory'),
86
+		'class' => 'chosen_select',
87
+		'options' => array_unique(geodir_post_type_setting_fun())
88
+	),
89
+	array(
90
+		'name' => __('User deleted posts go to trash', 'geodirectory'),
91
+		'desc' => __('If checked a user deleted post will go to trash, otherwise it will be permanently deleted', 'geodirectory'),
92
+		'id' => 'geodir_disable_perm_delete',
93
+		'type' => 'checkbox',
94
+		'std' => '1'
95
+	),
96
+	array(
97
+		'name' => __('Max upload file size(in mb)', 'geodirectory'),
98
+		'desc' => __('(Maximum upload file size in MB, 1 MB = 1024 KB. Must be greater then 0(ZERO), for ex: 2. This setting will overwrite the max upload file size limit in image/file upload & import listings for entire GeoDirectory core + GeoDirectory plugins.)', 'geodirectory'),
99
+		'id' => 'geodir_upload_max_filesize',
100
+		'type' => 'text',
101
+		'css' => 'min-width:300px;',
102
+		'std' => '2'
103
+	),
104
+	array('type' => 'sectionend', 'id' => 'general_options'),
105 105
 
106 106
 ));/* General Options End*/
107 107
 
@@ -113,104 +113,104 @@  discard block
 block discarded – undo
113 113
  */
114 114
 $google_analytic_settings = apply_filters('geodir_google_analytic_settings', array(
115 115
 
116
-    array('name' => __('Google Analytics', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'google_analytic_settings'),
117
-
118
-    array('name' => __('Google Analytic Settings', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'google_analytic_settings'),
119
-
120
-
121
-
122
-    array(
123
-        'name' => __('Show business owner google analytics stats?', 'geodirectory'),
124
-        'desc' => __('Yes', 'geodirectory'),
125
-        'id' => 'geodir_ga_stats',
126
-        'std' => '0',
127
-        'type' => 'radio',
128
-        'value' => '1',
129
-        'radiogroup' => 'start'
130
-    ),
131
-    array(
132
-        'name' => __('Show business owner Google Analytics stats?', 'geodirectory'),
133
-        'desc' => __('No', 'geodirectory'),
134
-        'id' => 'geodir_ga_stats',
135
-        'std' => '1',
136
-        'type' => 'radio',
137
-        'value' => '0',
138
-        'radiogroup' => 'end'
139
-    ),
140
-
141
-    array(
142
-        'name' => __('Google analytics access', 'geodirectory'),
143
-        'desc' => '',
144
-        'id' => 'geodir_ga_token',
145
-        'type' => 'google_analytics',
146
-        'css' => 'min-width:300px;',
147
-        'std' => '' // Default value for the page title - changed in settings
148
-    ),
149
-
150
-    array(
151
-        'name' => __('Google analytics Auth Code', 'geodirectory'),
152
-        'desc' => __('You must save this setting before accounts will show.', 'geodirectory'),
153
-        'id' => 'geodir_ga_auth_code',
154
-        'type' => 'text',
155
-        'css' => 'min-width:300px;',
156
-        'std' => '' // Default value for the page title - changed in settings
157
-    ),
158
-
159
-    array(
160
-        'name' => __('Analytics Account', 'geodirectory'),
161
-        'desc' => __('Select the account that you setup for this site.', 'geodirectory'),
162
-        'id' => 'geodir_ga_account_id',
163
-        'css' => 'min-width:300px;',
164
-        'std' => 'gridview_onehalf',
165
-        'type' => 'select',
166
-        'class' => 'chosen_select',
167
-        'options' => geodir_gd_accounts()
168
-    ),
169
-
170
-
171
-    array(
172
-        'name' => __('Add Google analytics tracking code to site?', 'geodirectory'),
173
-        'desc' => __('Yes <small>(this will automatically add the correct tracking code to your site)</small>', 'geodirectory'),
174
-        'id' => 'geodir_ga_add_tracking_code',
175
-        'std' => '0',
176
-        'type' => 'radio',
177
-        'value' => '1',
178
-        'radiogroup' => 'start'
179
-    ),
180
-    array(
181
-        'name' => __('Add Google analytics tracking code to site?', 'geodirectory'),
182
-        'desc' => __('No <small>(if you already have tracking code added you should not add it again)</small>', 'geodirectory'),
183
-        'id' => 'geodir_ga_add_tracking_code',
184
-        'std' => '1',
185
-        'type' => 'radio',
186
-        'value' => '0',
187
-        'radiogroup' => 'end'
188
-    ),
189
-
190
-    array(
191
-        'name' => __('Anonymize user IP?', 'geodirectory'),
192
-        'desc' => __('In most cases this is not required, this is to comply with certain country laws such as Germany.', 'geodirectory'),
193
-        'id' => 'geodir_ga_anonymize_ip',
194
-        'type' => 'checkbox',
195
-        'std' => '0'
196
-    ),
197
-
198
-    array(
199
-        'name' => __('Auto refresh active users?', 'geodirectory'),
200
-        'desc' => __('If ticked it uses the auto refresh time below, if not it never refreshes unless the refresh button is clicked.', 'geodirectory'),
201
-        'id' => 'geodir_ga_auto_refresh',
202
-        'type' => 'checkbox',
203
-        'std' => '0'
204
-    ),
205
-    array(
206
-        'name' => __('Time interval for auto refresh active users', 'geodirectory'),
207
-        'desc' => __('Time interval in seconds to auto refresh active users. The active users will be auto refreshed after this time interval. Leave blank or use 0(zero) to disable auto refresh. Default: 5', 'geodirectory'),
208
-        'id' => 'geodir_ga_refresh_time',
209
-        'type' => 'text',
210
-        'std' => '5'
211
-    ),
212
-
213
-    array('type' => 'sectionend', 'id' => 'google_analytic_settings'),
116
+	array('name' => __('Google Analytics', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'google_analytic_settings'),
117
+
118
+	array('name' => __('Google Analytic Settings', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'google_analytic_settings'),
119
+
120
+
121
+
122
+	array(
123
+		'name' => __('Show business owner google analytics stats?', 'geodirectory'),
124
+		'desc' => __('Yes', 'geodirectory'),
125
+		'id' => 'geodir_ga_stats',
126
+		'std' => '0',
127
+		'type' => 'radio',
128
+		'value' => '1',
129
+		'radiogroup' => 'start'
130
+	),
131
+	array(
132
+		'name' => __('Show business owner Google Analytics stats?', 'geodirectory'),
133
+		'desc' => __('No', 'geodirectory'),
134
+		'id' => 'geodir_ga_stats',
135
+		'std' => '1',
136
+		'type' => 'radio',
137
+		'value' => '0',
138
+		'radiogroup' => 'end'
139
+	),
140
+
141
+	array(
142
+		'name' => __('Google analytics access', 'geodirectory'),
143
+		'desc' => '',
144
+		'id' => 'geodir_ga_token',
145
+		'type' => 'google_analytics',
146
+		'css' => 'min-width:300px;',
147
+		'std' => '' // Default value for the page title - changed in settings
148
+	),
149
+
150
+	array(
151
+		'name' => __('Google analytics Auth Code', 'geodirectory'),
152
+		'desc' => __('You must save this setting before accounts will show.', 'geodirectory'),
153
+		'id' => 'geodir_ga_auth_code',
154
+		'type' => 'text',
155
+		'css' => 'min-width:300px;',
156
+		'std' => '' // Default value for the page title - changed in settings
157
+	),
158
+
159
+	array(
160
+		'name' => __('Analytics Account', 'geodirectory'),
161
+		'desc' => __('Select the account that you setup for this site.', 'geodirectory'),
162
+		'id' => 'geodir_ga_account_id',
163
+		'css' => 'min-width:300px;',
164
+		'std' => 'gridview_onehalf',
165
+		'type' => 'select',
166
+		'class' => 'chosen_select',
167
+		'options' => geodir_gd_accounts()
168
+	),
169
+
170
+
171
+	array(
172
+		'name' => __('Add Google analytics tracking code to site?', 'geodirectory'),
173
+		'desc' => __('Yes <small>(this will automatically add the correct tracking code to your site)</small>', 'geodirectory'),
174
+		'id' => 'geodir_ga_add_tracking_code',
175
+		'std' => '0',
176
+		'type' => 'radio',
177
+		'value' => '1',
178
+		'radiogroup' => 'start'
179
+	),
180
+	array(
181
+		'name' => __('Add Google analytics tracking code to site?', 'geodirectory'),
182
+		'desc' => __('No <small>(if you already have tracking code added you should not add it again)</small>', 'geodirectory'),
183
+		'id' => 'geodir_ga_add_tracking_code',
184
+		'std' => '1',
185
+		'type' => 'radio',
186
+		'value' => '0',
187
+		'radiogroup' => 'end'
188
+	),
189
+
190
+	array(
191
+		'name' => __('Anonymize user IP?', 'geodirectory'),
192
+		'desc' => __('In most cases this is not required, this is to comply with certain country laws such as Germany.', 'geodirectory'),
193
+		'id' => 'geodir_ga_anonymize_ip',
194
+		'type' => 'checkbox',
195
+		'std' => '0'
196
+	),
197
+
198
+	array(
199
+		'name' => __('Auto refresh active users?', 'geodirectory'),
200
+		'desc' => __('If ticked it uses the auto refresh time below, if not it never refreshes unless the refresh button is clicked.', 'geodirectory'),
201
+		'id' => 'geodir_ga_auto_refresh',
202
+		'type' => 'checkbox',
203
+		'std' => '0'
204
+	),
205
+	array(
206
+		'name' => __('Time interval for auto refresh active users', 'geodirectory'),
207
+		'desc' => __('Time interval in seconds to auto refresh active users. The active users will be auto refreshed after this time interval. Leave blank or use 0(zero) to disable auto refresh. Default: 5', 'geodirectory'),
208
+		'id' => 'geodir_ga_refresh_time',
209
+		'type' => 'text',
210
+		'std' => '5'
211
+	),
212
+
213
+	array('type' => 'sectionend', 'id' => 'google_analytic_settings'),
214 214
 
215 215
 )); // google_analytic_settings End
216 216
 
@@ -222,84 +222,84 @@  discard block
 block discarded – undo
222 222
  */
223 223
 $search_settings = apply_filters('geodir_search_settings', array(
224 224
 
225
-    array('name' => __('Search', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'search_settings'),
226
-
227
-    array('name' => __('Search Settings', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'search_settings'),
228
-
229
-    array(
230
-        'name' => __('Limit squared distance area to X miles (helps improve search speed)', 'geodirectory'),
231
-        'desc' => __('Enter whole number only ex. 40 (Tokyo is largest city in the world @40 sq miles) LEAVE BLANK FOR NO DISTANCE LIMIT', 'geodirectory'),
232
-        'id' => 'geodir_search_dist',
233
-        'type' => 'text',
234
-        'css' => 'min-width:300px;',
235
-        'std' => '40' // Default value for the page title - changed in settings
236
-    ),
237
-
238
-    array(
239
-        'name' => __('Show search distances in miles or km', 'geodirectory'),
240
-        'desc' => __('Miles', 'geodirectory'),
241
-        'id' => 'geodir_search_dist_1',
242
-        'std' => 'miles',
243
-        'type' => 'radio',
244
-        'value' => 'miles',
245
-        'radiogroup' => 'start'
246
-    ),
247
-    array(
248
-        'name' => __('Show search distances in miles or km', 'geodirectory'),
249
-        'desc' => __('Kilometers', 'geodirectory'),
250
-        'id' => 'geodir_search_dist_1',
251
-        'std' => 'miles',
252
-        'type' => 'radio',
253
-        'value' => 'km',
254
-        'radiogroup' => 'end'
255
-    ),
256
-
257
-    array(
258
-        'name' => __('If distance is less than 0.01 show distance in meters or feet', 'geodirectory'),
259
-        'desc' => __('Meters', 'geodirectory'),
260
-        'id' => 'geodir_search_dist_2',
261
-        'std' => 'meters',
262
-        'type' => 'radio',
263
-        'value' => 'meters',
264
-        'radiogroup' => 'start'
265
-    ),
266
-
267
-    array(
268
-        'name' => __('If distance is less than 0.01 show distance in meters or feet', 'geodirectory'),
269
-        'desc' => __('Feet', 'geodirectory'),
270
-        'id' => 'geodir_search_dist_2',
271
-        'std' => 'meters',
272
-        'type' => 'radio',
273
-        'value' => 'feet',
274
-        'radiogroup' => 'end'
275
-    ),
276
-
277
-    array(
278
-        'name' => __('Add location specific text to (Near) search for Google', 'geodirectory'),
279
-        'desc' => __('This is usefull if your directory is limted to one location such as: New York or Australia (this setting should be blank if using default country, regions etc with multilocation addon as it will automatically add them)', 'geodirectory'),
280
-        'id' => 'geodir_search_near_addition',
281
-        'type' => 'text',
282
-        'css' => 'min-width:300px;',
283
-        'std' => ''
284
-    ),
285
-    array(
286
-        'name' => __('Individual word search limit', 'geodirectory'),
287
-        'desc' => __('With this option you can limit individual words being searched for, for example searching for `Jo Brown` would return results with words like `Jones`, you can exclude these types of small character words if you wish.', 'geodirectory'),
288
-        'id' => 'geodir_search_word_limit',
289
-        'css' => 'min-width:300px;',
290
-        'std' => 'gridview_onehalf',
291
-        'type' => 'select',
292
-        'class' => 'chosen_select',
293
-        'options' => array_unique(array(
294
-            '0' => __('Disabled', 'geodirectory'),
295
-            '1' => __('1 Character words excluded', 'geodirectory'),
296
-            '2' => __('2 Character words and less excluded', 'geodirectory'),
297
-            '3' => __('3 Character words and less excluded', 'geodirectory'),
298
-        ))
299
-    ),
300
-
301
-
302
-    array('type' => 'sectionend', 'id' => 'search_settings'),
225
+	array('name' => __('Search', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'search_settings'),
226
+
227
+	array('name' => __('Search Settings', 'geodirectory'), 'type' => 'sectionstart', 'id' => 'search_settings'),
228
+
229
+	array(
230
+		'name' => __('Limit squared distance area to X miles (helps improve search speed)', 'geodirectory'),
231
+		'desc' => __('Enter whole number only ex. 40 (Tokyo is largest city in the world @40 sq miles) LEAVE BLANK FOR NO DISTANCE LIMIT', 'geodirectory'),
232
+		'id' => 'geodir_search_dist',
233
+		'type' => 'text',
234
+		'css' => 'min-width:300px;',
235
+		'std' => '40' // Default value for the page title - changed in settings
236
+	),
237
+
238
+	array(
239
+		'name' => __('Show search distances in miles or km', 'geodirectory'),
240
+		'desc' => __('Miles', 'geodirectory'),
241
+		'id' => 'geodir_search_dist_1',
242
+		'std' => 'miles',
243
+		'type' => 'radio',
244
+		'value' => 'miles',
245
+		'radiogroup' => 'start'
246
+	),
247
+	array(
248
+		'name' => __('Show search distances in miles or km', 'geodirectory'),
249
+		'desc' => __('Kilometers', 'geodirectory'),
250
+		'id' => 'geodir_search_dist_1',
251
+		'std' => 'miles',
252
+		'type' => 'radio',
253
+		'value' => 'km',
254
+		'radiogroup' => 'end'
255
+	),
256
+
257
+	array(
258
+		'name' => __('If distance is less than 0.01 show distance in meters or feet', 'geodirectory'),
259
+		'desc' => __('Meters', 'geodirectory'),
260
+		'id' => 'geodir_search_dist_2',
261
+		'std' => 'meters',
262
+		'type' => 'radio',
263
+		'value' => 'meters',
264
+		'radiogroup' => 'start'
265
+	),
266
+
267
+	array(
268
+		'name' => __('If distance is less than 0.01 show distance in meters or feet', 'geodirectory'),
269
+		'desc' => __('Feet', 'geodirectory'),
270
+		'id' => 'geodir_search_dist_2',
271
+		'std' => 'meters',
272
+		'type' => 'radio',
273
+		'value' => 'feet',
274
+		'radiogroup' => 'end'
275
+	),
276
+
277
+	array(
278
+		'name' => __('Add location specific text to (Near) search for Google', 'geodirectory'),
279
+		'desc' => __('This is usefull if your directory is limted to one location such as: New York or Australia (this setting should be blank if using default country, regions etc with multilocation addon as it will automatically add them)', 'geodirectory'),
280
+		'id' => 'geodir_search_near_addition',
281
+		'type' => 'text',
282
+		'css' => 'min-width:300px;',
283
+		'std' => ''
284
+	),
285
+	array(
286
+		'name' => __('Individual word search limit', 'geodirectory'),
287
+		'desc' => __('With this option you can limit individual words being searched for, for example searching for `Jo Brown` would return results with words like `Jones`, you can exclude these types of small character words if you wish.', 'geodirectory'),
288
+		'id' => 'geodir_search_word_limit',
289
+		'css' => 'min-width:300px;',
290
+		'std' => 'gridview_onehalf',
291
+		'type' => 'select',
292
+		'class' => 'chosen_select',
293
+		'options' => array_unique(array(
294
+			'0' => __('Disabled', 'geodirectory'),
295
+			'1' => __('1 Character words excluded', 'geodirectory'),
296
+			'2' => __('2 Character words and less excluded', 'geodirectory'),
297
+			'3' => __('3 Character words and less excluded', 'geodirectory'),
298
+		))
299
+	),
300
+
301
+
302
+	array('type' => 'sectionend', 'id' => 'search_settings'),
303 303
 
304 304
 )); //search_settings End
305 305
 
@@ -311,17 +311,17 @@  discard block
 block discarded – undo
311 311
  */
312 312
 $dummy_data_settings = apply_filters('geodir_dummy_data_settings', array(
313 313
 
314
-    array('name' => __('Dummy Data', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'dummy_data_settings'),
315
-
316
-    array(
317
-        'name' => '',
318
-        'desc' => '',
319
-        'id' => 'geodir_dummy_data_installer',
320
-        'type' => 'dummy_installer',
321
-        'css' => 'min-width:300px;',
322
-        'std' => '40' // Default value for the page title - changed in settings
323
-    ),
324
-    array('type' => 'sectionend', 'id' => 'geodir_dummy_data_settings'),
314
+	array('name' => __('Dummy Data', 'geodirectory'), 'type' => 'title', 'desc' => '', 'id' => 'dummy_data_settings'),
315
+
316
+	array(
317
+		'name' => '',
318
+		'desc' => '',
319
+		'id' => 'geodir_dummy_data_installer',
320
+		'type' => 'dummy_installer',
321
+		'css' => 'min-width:300px;',
322
+		'std' => '40' // Default value for the page title - changed in settings
323
+	),
324
+	array('type' => 'sectionend', 'id' => 'geodir_dummy_data_settings'),
325 325
 
326 326
 )); //dummy_data_settings End
327 327
 
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/Google/Task/Retryable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!class_exists('Google_Client')) {
19
-  require_once dirname(__FILE__) . '/../autoload.php';
19
+  require_once dirname(__FILE__).'/../autoload.php';
20 20
 }
21 21
 
22 22
 /**
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/Google/Auth/Abstract.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!class_exists('Google_Client')) {
19
-  require_once dirname(__FILE__) . '/../autoload.php';
19
+  require_once dirname(__FILE__).'/../autoload.php';
20 20
 }
21 21
 
22 22
 /**
Please login to merge, or discard this patch.
geodirectory-functions/comments_functions.php 3 patches
Braces   +60 added lines, -48 removed lines patch added patch discarded remove patch
@@ -278,8 +278,9 @@  discard block
 block discarded – undo
278 278
 
279 279
     $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : '';
280 280
 
281
-    if (!empty($comment_info))
282
-        $status = $comment_info->comment_approved;
281
+    if (!empty($comment_info)) {
282
+            $status = $comment_info->comment_approved;
283
+    }
283 284
 
284 285
     if ($status == 'approve' || $status == 1) {
285 286
         $status = 1;
@@ -418,12 +419,14 @@  discard block
 block discarded – undo
418 419
         }
419 420
     } else {
420 421
         $rating = 0;
421
-        if (!empty($comment))
422
-            $rating = geodir_get_commentoverall($comment->comment_ID);
422
+        if (!empty($comment)) {
423
+                    $rating = geodir_get_commentoverall($comment->comment_ID);
424
+        }
423 425
         if ($rating != 0 && !is_admin()) {
424 426
             return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
425
-        } else
426
-            return $content;
427
+        } else {
428
+                    return $content;
429
+        }
427 430
     }
428 431
 }
429 432
 
@@ -512,11 +515,12 @@  discard block
 block discarded – undo
512 515
         $post_ratings = get_post_meta($post_id, 'overall_rating');
513 516
     }
514 517
 
515
-    if ($post_ratings)
516
-        return $post_ratings;
517
-    else
518
-        return false;
519
-}
518
+    if ($post_ratings) {
519
+            return $post_ratings;
520
+    } else {
521
+            return false;
522
+    }
523
+    }
520 524
 
521 525
 
522 526
 /**
@@ -541,11 +545,12 @@  discard block
 block discarded – undo
541 545
         )
542 546
     );
543 547
 
544
-    if (!empty($reatings))
545
-        return $reatings;
546
-    else
547
-        return false;
548
-}
548
+    if (!empty($reatings)) {
549
+            return $reatings;
550
+    } else {
551
+            return false;
552
+    }
553
+    }
549 554
 
550 555
 /**
551 556
  * Get review total of a Post.
@@ -569,11 +574,12 @@  discard block
 block discarded – undo
569 574
         )
570 575
     );
571 576
 
572
-    if (!empty($results))
573
-        return $results;
574
-    else
575
-        return false;
576
-}
577
+    if (!empty($results)) {
578
+            return $results;
579
+    } else {
580
+            return false;
581
+    }
582
+    }
577 583
 
578 584
 /**
579 585
  * Get review count by user ID.
@@ -596,11 +602,12 @@  discard block
 block discarded – undo
596 602
         )
597 603
     );
598 604
 
599
-    if (!empty($results))
600
-        return $results;
601
-    else
602
-        return false;
603
-}
605
+    if (!empty($results)) {
606
+            return $results;
607
+    } else {
608
+            return false;
609
+    }
610
+    }
604 611
 
605 612
 /**
606 613
  * Get average overall rating of a Post.
@@ -634,11 +641,12 @@  discard block
 block discarded – undo
634 641
         )
635 642
     );
636 643
 
637
-    if (!empty($results))
638
-        return $results;
639
-    else
640
-        return false;
641
-}
644
+    if (!empty($results)) {
645
+            return $results;
646
+    } else {
647
+            return false;
648
+    }
649
+    }
642 650
 
643 651
 /**
644 652
  * Get review count of a Post.
@@ -662,11 +670,12 @@  discard block
 block discarded – undo
662 670
         )
663 671
     );
664 672
 
665
-    if (!empty($results))
666
-        return $results;
667
-    else
668
-        return false;
669
-}
673
+    if (!empty($results)) {
674
+            return $results;
675
+    } else {
676
+            return false;
677
+    }
678
+    }
670 679
 
671 680
 /**
672 681
  * Get comments count of a Post.
@@ -692,11 +701,12 @@  discard block
 block discarded – undo
692 701
     );
693 702
 
694 703
 
695
-    if (!empty($results))
696
-        return $results;
697
-    else
698
-        return false;
699
-}
704
+    if (!empty($results)) {
705
+            return $results;
706
+    } else {
707
+            return false;
708
+    }
709
+    }
700 710
 
701 711
 /**
702 712
  * Get overall rating of a comment.
@@ -720,11 +730,12 @@  discard block
 block discarded – undo
720 730
         )
721 731
     );
722 732
 
723
-    if ($reatings)
724
-        return $reatings;
725
-    else
726
-        return false;
727
-}
733
+    if ($reatings) {
734
+            return $reatings;
735
+    } else {
736
+            return false;
737
+    }
738
+    }
728 739
 
729 740
 /**
730 741
  * Returns average overall rating of a Post. Depreciated since ver 1.3.6.
@@ -970,8 +981,9 @@  discard block
 block discarded – undo
970 981
     $active_tabs = get_option('geodir_detail_page_tabs_excluded');
971 982
 
972 983
     $is_display = true;
973
-    if (!empty($active_tabs) && in_array('reviews', $active_tabs))
974
-        $is_display = false;
984
+    if (!empty($active_tabs) && in_array('reviews', $active_tabs)) {
985
+            $is_display = false;
986
+    }
975 987
 
976 988
     /**
977 989
      * Filter to change display value.
Please login to merge, or discard this patch.
Indentation   +471 added lines, -471 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
  */
32 32
 function geodir_comment_meta_row_action($a)
33 33
 {
34
-    global $comment;
34
+	global $comment;
35 35
 
36
-    $rating = geodir_get_commentoverall($comment->comment_ID);
37
-    if ($rating != 0) {
38
-        echo geodir_get_rating_stars($rating, $comment->comment_ID);
39
-    }
40
-    return $a;
36
+	$rating = geodir_get_commentoverall($comment->comment_ID);
37
+	if ($rating != 0) {
38
+		echo geodir_get_rating_stars($rating, $comment->comment_ID);
39
+	}
40
+	return $a;
41 41
 }
42 42
 
43 43
 add_action('add_meta_boxes_comment', 'geodir_comment_add_meta_box');
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  */
53 53
 function geodir_comment_add_meta_box($comment)
54 54
 {
55
-    add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high');
55
+	add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high');
56 56
 }
57 57
 
58 58
 /**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
  * @param object $comment The comment object.
67 67
  */
68 68
 function geodir_comment_rating_meta($comment) {
69
-    $post_type = get_post_type($comment->comment_post_ID);
69
+	$post_type = get_post_type($comment->comment_post_ID);
70 70
 	if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
71 71
 		$rating = geodir_get_commentoverall($comment->comment_ID);
72 72
 		
@@ -106,24 +106,24 @@  discard block
 block discarded – undo
106 106
  * @global object $post The post object.
107 107
  */
108 108
 function geodir_comment_rating_fields() {
109
-    global $post;
109
+	global $post;
110 110
 
111
-    $post_types = geodir_get_posttypes();
111
+	$post_types = geodir_get_posttypes();
112 112
 
113
-    if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) {
114
-        $star_texts = array();
115
-        $star_texts[] = __('Terrible', 'geodirectory');
116
-        $star_texts[] = __('Poor', 'geodirectory');
117
-        $star_texts[] = __('Average', 'geodirectory');
118
-        $star_texts[] = __('Very Good', 'geodirectory');
119
-        $star_texts[] = __('Excellent', 'geodirectory');
113
+	if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) {
114
+		$star_texts = array();
115
+		$star_texts[] = __('Terrible', 'geodirectory');
116
+		$star_texts[] = __('Poor', 'geodirectory');
117
+		$star_texts[] = __('Average', 'geodirectory');
118
+		$star_texts[] = __('Very Good', 'geodirectory');
119
+		$star_texts[] = __('Excellent', 'geodirectory');
120 120
         
121
-        $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
122
-        echo $gd_rating_html;
123
-        ?>
121
+		$gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
122
+		echo $gd_rating_html;
123
+		?>
124 124
         <input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="0"/>
125 125
         <?php
126
-    }
126
+	}
127 127
 }
128 128
 
129 129
 add_filter('comment_reply_link', 'geodir_comment_replaylink');
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 function geodir_comment_replaylink($link)
140 140
 {
141 141
 
142
-    if (strpos($link, 'wp-login.php?') !== false) {
143
-        $link = str_replace(wp_login_url(),geodir_login_url(),$link);
144
-    }
145
-    $link = '<div class="gd_comment_replaylink">' . $link . '</div>';
142
+	if (strpos($link, 'wp-login.php?') !== false) {
143
+		$link = str_replace(wp_login_url(),geodir_login_url(),$link);
144
+	}
145
+	$link = '<div class="gd_comment_replaylink">' . $link . '</div>';
146 146
 
147
-    return $link;
147
+	return $link;
148 148
 }
149 149
 
150 150
 add_filter('cancel_comment_reply_link', 'geodir_cancle_replaylink');
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 function geodir_cancle_replaylink($link)
160 160
 {
161 161
 
162
-    $link = '<span class="gd-cancel-replaylink">' . $link . '</span>';
162
+	$link = '<span class="gd-cancel-replaylink">' . $link . '</span>';
163 163
 
164
-    return $link;
164
+	return $link;
165 165
 }
166 166
 
167 167
 add_action('comment_post', 'geodir_save_rating');
@@ -177,32 +177,32 @@  discard block
 block discarded – undo
177 177
  */
178 178
 function geodir_save_rating($comment = 0)
179 179
 {
180
-    global $wpdb, $user_ID, $plugin_prefix;
180
+	global $wpdb, $user_ID, $plugin_prefix;
181 181
 
182
-    $comment_info = get_comment($comment);
182
+	$comment_info = get_comment($comment);
183 183
 
184
-    $post_id = $comment_info->comment_post_ID;
185
-    $status = $comment_info->comment_approved;
186
-    $rating_ip = getenv("REMOTE_ADDR");
184
+	$post_id = $comment_info->comment_post_ID;
185
+	$status = $comment_info->comment_approved;
186
+	$rating_ip = getenv("REMOTE_ADDR");
187 187
 	
188
-    $post = geodir_get_post_info($post_id);
189
-    if (empty($post)) {
190
-        return;
191
-    }
192
-
193
-    if ($post->post_status == 'publish') {
194
-        $post_status = '1';
195
-    } else {
196
-        $post_status = '0';
197
-    }
188
+	$post = geodir_get_post_info($post_id);
189
+	if (empty($post)) {
190
+		return;
191
+	}
192
+
193
+	if ($post->post_status == 'publish') {
194
+		$post_status = '1';
195
+	} else {
196
+		$post_status = '0';
197
+	}
198 198
 	
199
-    if (isset($_REQUEST['geodir_overallrating'])) {
200
-        $overall_rating = $_REQUEST['geodir_overallrating'];
199
+	if (isset($_REQUEST['geodir_overallrating'])) {
200
+		$overall_rating = $_REQUEST['geodir_overallrating'];
201 201
         
202 202
 		if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
203
-            $overall_rating = $overall_rating > 0 ? $overall_rating : '0';
203
+			$overall_rating = $overall_rating > 0 ? $overall_rating : '0';
204 204
 
205
-            $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
205
+			$sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
206 206
 					post_id		= %d,
207 207
 					post_type = %s,
208 208
 					post_title	= %s,
@@ -220,35 +220,35 @@  discard block
 block discarded – undo
220 220
 					post_latitude	= %s,
221 221
 					comment_content	= %s 
222 222
 					",
223
-                array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content)
224
-            );
225
-
226
-            $wpdb->query($sqlqry);
227
-
228
-            /**
229
-             * Called after saving the comment.
230
-             *
231
-             * @since 1.0.0
232
-             * @package GeoDirectory
233
-             * @param array $_REQUEST {
234
-             *    Attributes of the $_REQUEST variable.
235
-             *
236
-             *    @type string $geodir_overallrating Overall rating.
237
-             *    @type string $comment Comment text.
238
-             *    @type string $submit Submit button text.
239
-             *    @type string $comment_post_ID Comment post ID.
240
-             *    @type string $comment_parent Comment Parent ID.
241
-             *    @type string $_wp_unfiltered_html_comment Unfiltered html comment string.
242
-             *
243
-             * }
244
-             */
245
-            do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post');
246
-
247
-            if ($status) {
248
-                geodir_update_postrating($post_id);
249
-            }
250
-        }
251
-    }
223
+				array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content)
224
+			);
225
+
226
+			$wpdb->query($sqlqry);
227
+
228
+			/**
229
+			 * Called after saving the comment.
230
+			 *
231
+			 * @since 1.0.0
232
+			 * @package GeoDirectory
233
+			 * @param array $_REQUEST {
234
+			 *    Attributes of the $_REQUEST variable.
235
+			 *
236
+			 *    @type string $geodir_overallrating Overall rating.
237
+			 *    @type string $comment Comment text.
238
+			 *    @type string $submit Submit button text.
239
+			 *    @type string $comment_post_ID Comment post ID.
240
+			 *    @type string $comment_parent Comment Parent ID.
241
+			 *    @type string $_wp_unfiltered_html_comment Unfiltered html comment string.
242
+			 *
243
+			 * }
244
+			 */
245
+			do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post');
246
+
247
+			if ($status) {
248
+				geodir_update_postrating($post_id);
249
+			}
250
+		}
251
+	}
252 252
 }
253 253
 
254 254
 
@@ -266,51 +266,51 @@  discard block
 block discarded – undo
266 266
  */
267 267
 function geodir_update_rating_status_change($comment_id, $status)
268 268
 {
269
-    if ($status == 'delete') {
270
-        return;
271
-    }
272
-    global $wpdb, $plugin_prefix, $user_ID;
269
+	if ($status == 'delete') {
270
+		return;
271
+	}
272
+	global $wpdb, $plugin_prefix, $user_ID;
273 273
 
274
-    $comment_info = get_comment($comment_id);
274
+	$comment_info = get_comment($comment_id);
275 275
 
276
-    $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : '';
276
+	$post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : '';
277 277
 
278
-    if (!empty($comment_info))
279
-        $status = $comment_info->comment_approved;
278
+	if (!empty($comment_info))
279
+		$status = $comment_info->comment_approved;
280 280
 
281
-    if ($status == 'approve' || $status == 1) {
282
-        $status = 1;
283
-    } else {
284
-        $status = 0;
285
-    }
281
+	if ($status == 'approve' || $status == 1) {
282
+		$status = 1;
283
+	} else {
284
+		$status = 0;
285
+	}
286 286
 
287
-    $comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : '';
288
-    $old_rating = geodir_get_commentoverall($comment_info_ID);
287
+	$comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : '';
288
+	$old_rating = geodir_get_commentoverall($comment_info_ID);
289 289
 
290
-    $post_type = get_post_type($post_id);
290
+	$post_type = get_post_type($post_id);
291 291
 
292
-    $detail_table = $plugin_prefix . $post_type . '_detail';
292
+	$detail_table = $plugin_prefix . $post_type . '_detail';
293 293
 
294
-    if ($comment_id) {
294
+	if ($comment_id) {
295 295
 
296
-        $overall_rating = $old_rating;
296
+		$overall_rating = $old_rating;
297 297
 
298
-        if (isset($old_rating)) {
298
+		if (isset($old_rating)) {
299 299
 
300
-            $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
300
+			$sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
301 301
 						overall_rating = %f,
302 302
 						status		= %s,
303 303
 						comment_content = %s 
304 304
 						WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id));
305 305
 
306
-            $wpdb->query($sqlqry);
306
+			$wpdb->query($sqlqry);
307 307
 
308
-            //update rating
309
-            geodir_update_postrating($post_id, $post_type);
308
+			//update rating
309
+			geodir_update_postrating($post_id, $post_type);
310 310
 
311
-        }
311
+		}
312 312
 
313
-    }
313
+	}
314 314
 
315 315
 }
316 316
 
@@ -329,41 +329,41 @@  discard block
 block discarded – undo
329 329
 function geodir_update_rating($comment_id = 0)
330 330
 {
331 331
 
332
-    global $wpdb, $plugin_prefix, $user_ID;
332
+	global $wpdb, $plugin_prefix, $user_ID;
333 333
 
334
-    $comment_info = get_comment($comment_id);
334
+	$comment_info = get_comment($comment_id);
335 335
 
336
-    $post_id = $comment_info->comment_post_ID;
337
-    $status = $comment_info->comment_approved;
338
-    $old_rating = geodir_get_commentoverall($comment_info->comment_ID);
336
+	$post_id = $comment_info->comment_post_ID;
337
+	$status = $comment_info->comment_approved;
338
+	$old_rating = geodir_get_commentoverall($comment_info->comment_ID);
339 339
 
340
-    $post_type = get_post_type($post_id);
340
+	$post_type = get_post_type($post_id);
341 341
 
342
-    $detail_table = $plugin_prefix . $post_type . '_detail';
342
+	$detail_table = $plugin_prefix . $post_type . '_detail';
343 343
 
344
-    if (isset($_REQUEST['geodir_overallrating'])) {
344
+	if (isset($_REQUEST['geodir_overallrating'])) {
345 345
 
346
-        $overall_rating = $_REQUEST['geodir_overallrating'];
346
+		$overall_rating = $_REQUEST['geodir_overallrating'];
347 347
 
348
-        if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
349
-            $overall_rating = $overall_rating > 0 ? $overall_rating : '0';
348
+		if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
349
+			$overall_rating = $overall_rating > 0 ? $overall_rating : '0';
350 350
 
351
-            if (isset($old_rating)) {
351
+			if (isset($old_rating)) {
352 352
 
353
-                $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
353
+				$sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
354 354
 						overall_rating = %f,
355 355
 						status		= %s,
356 356
 						comment_content	= %s 
357 357
 						WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id));
358 358
 
359
-                $wpdb->query($sqlqry);
359
+				$wpdb->query($sqlqry);
360 360
 
361
-                //update rating
362
-                geodir_update_postrating($post_id, $post_type);
361
+				//update rating
362
+				geodir_update_postrating($post_id, $post_type);
363 363
 
364
-            }
365
-        }
366
-    }
364
+			}
365
+		}
366
+	}
367 367
 
368 368
 
369 369
 }
@@ -379,19 +379,19 @@  discard block
 block discarded – undo
379 379
  */
380 380
 function geodir_comment_delete_comment($comment_id)
381 381
 {
382
-    global $wpdb;
382
+	global $wpdb;
383 383
 
384
-    $review_info = geodir_get_review($comment_id);
385
-    if ($review_info) {
386
-        geodir_update_postrating($review_info->post_id);
387
-    }
384
+	$review_info = geodir_get_review($comment_id);
385
+	if ($review_info) {
386
+		geodir_update_postrating($review_info->post_id);
387
+	}
388 388
 
389
-    $wpdb->query(
390
-        $wpdb->prepare(
391
-            "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d",
392
-            array($comment_id)
393
-        )
394
-    );
389
+	$wpdb->query(
390
+		$wpdb->prepare(
391
+			"DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d",
392
+			array($comment_id)
393
+		)
394
+	);
395 395
 
396 396
 }
397 397
 
@@ -407,21 +407,21 @@  discard block
 block discarded – undo
407 407
  * @return string The comment content.
408 408
  */
409 409
 function geodir_wrap_comment_text($content, $comment = '') {
410
-    if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
411
-        if (!is_admin()) {
412
-            return '<div class="description">' . $content . '</div>';
413
-        } else {
414
-            return $content;
415
-        }
416
-    } else {
417
-        $rating = 0;
418
-        if (!empty($comment))
419
-            $rating = geodir_get_commentoverall($comment->comment_ID);
420
-        if ($rating != 0 && !is_admin()) {
421
-            return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
422
-        } else
423
-            return $content;
424
-    }
410
+	if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
411
+		if (!is_admin()) {
412
+			return '<div class="description">' . $content . '</div>';
413
+		} else {
414
+			return $content;
415
+		}
416
+	} else {
417
+		$rating = 0;
418
+		if (!empty($comment))
419
+			$rating = geodir_get_commentoverall($comment->comment_ID);
420
+		if ($rating != 0 && !is_admin()) {
421
+			return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
422
+		} else
423
+			return $content;
424
+	}
425 425
 }
426 426
 
427 427
 
@@ -438,41 +438,41 @@  discard block
 block discarded – undo
438 438
  */
439 439
 function geodir_update_postrating($post_id = 0, $post_type = '', $delete = false)
440 440
 {
441
-    global $wpdb, $plugin_prefix, $comment;
442
-    if (!$post_type) {
443
-        $post_type = get_post_type($post_id);
444
-    }
445
-    $detail_table = $plugin_prefix . $post_type . '_detail';
446
-    $post_newrating = geodir_get_post_rating($post_id, 1);
447
-    $post_newrating_count = geodir_get_review_count_total($post_id);
441
+	global $wpdb, $plugin_prefix, $comment;
442
+	if (!$post_type) {
443
+		$post_type = get_post_type($post_id);
444
+	}
445
+	$detail_table = $plugin_prefix . $post_type . '_detail';
446
+	$post_newrating = geodir_get_post_rating($post_id, 1);
447
+	$post_newrating_count = geodir_get_review_count_total($post_id);
448 448
 
449 449
 
450
-    //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ;
450
+	//$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ;
451 451
 
452
-    if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
452
+	if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
453 453
 
454
-        $wpdb->query(
455
-            $wpdb->prepare(
456
-                "UPDATE " . $detail_table . " SET
454
+		$wpdb->query(
455
+			$wpdb->prepare(
456
+				"UPDATE " . $detail_table . " SET
457 457
 						overall_rating = %f,
458 458
 						rating_count = %f
459 459
 						where post_id = %d",
460
-                array($post_newrating, $post_newrating_count, $post_id)
461
-            )
462
-        );
463
-
464
-        update_post_meta($post_id, 'overall_rating', $post_newrating);
465
-        update_post_meta($post_id, 'rating_count', $post_newrating_count);
466
-    }
467
-    /**
468
-     * Called after Updating post overall rating and rating count.
469
-     *
470
-     * @since 1.0.0
471
-     * @since 1.4.3 Added `$post_id` param.
472
-     * @package GeoDirectory
473
-     * @param int $post_id The post ID.
474
-     */
475
-    do_action('geodir_update_postrating',$post_id);
460
+				array($post_newrating, $post_newrating_count, $post_id)
461
+			)
462
+		);
463
+
464
+		update_post_meta($post_id, 'overall_rating', $post_newrating);
465
+		update_post_meta($post_id, 'rating_count', $post_newrating_count);
466
+	}
467
+	/**
468
+	 * Called after Updating post overall rating and rating count.
469
+	 *
470
+	 * @since 1.0.0
471
+	 * @since 1.4.3 Added `$post_id` param.
472
+	 * @package GeoDirectory
473
+	 * @param int $post_id The post ID.
474
+	 */
475
+	do_action('geodir_update_postrating',$post_id);
476 476
 
477 477
 }
478 478
 
@@ -490,29 +490,29 @@  discard block
 block discarded – undo
490 490
  */
491 491
 function geodir_get_postoverall($post_id = 0)
492 492
 {
493
-    global $wpdb, $plugin_prefix;
493
+	global $wpdb, $plugin_prefix;
494 494
 
495
-    $post_type = get_post_type($post_id);
496
-    $detail_table = $plugin_prefix . $post_type . '_detail';
495
+	$post_type = get_post_type($post_id);
496
+	$detail_table = $plugin_prefix . $post_type . '_detail';
497 497
 
498
-    if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
498
+	if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
499 499
 
500
-        $post_ratings = $wpdb->get_var(
501
-            $wpdb->prepare(
502
-                "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d",
503
-                array($post_id)
504
-            )
505
-        );
500
+		$post_ratings = $wpdb->get_var(
501
+			$wpdb->prepare(
502
+				"SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d",
503
+				array($post_id)
504
+			)
505
+		);
506 506
 
507 507
 
508
-    } else {
509
-        $post_ratings = get_post_meta($post_id, 'overall_rating');
510
-    }
508
+	} else {
509
+		$post_ratings = get_post_meta($post_id, 'overall_rating');
510
+	}
511 511
 
512
-    if ($post_ratings)
513
-        return $post_ratings;
514
-    else
515
-        return false;
512
+	if ($post_ratings)
513
+		return $post_ratings;
514
+	else
515
+		return false;
516 516
 }
517 517
 
518 518
 
@@ -529,19 +529,19 @@  discard block
 block discarded – undo
529 529
  */
530 530
 function geodir_get_review($comment_id = 0)
531 531
 {
532
-    global $wpdb;
533
-
534
-    $reatings = $wpdb->get_row(
535
-        $wpdb->prepare(
536
-            "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
537
-            array($comment_id)
538
-        )
539
-    );
540
-
541
-    if (!empty($reatings))
542
-        return $reatings;
543
-    else
544
-        return false;
532
+	global $wpdb;
533
+
534
+	$reatings = $wpdb->get_row(
535
+		$wpdb->prepare(
536
+			"SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
537
+			array($comment_id)
538
+		)
539
+	);
540
+
541
+	if (!empty($reatings))
542
+		return $reatings;
543
+	else
544
+		return false;
545 545
 }
546 546
 
547 547
 /**
@@ -557,19 +557,19 @@  discard block
 block discarded – undo
557 557
  */
558 558
 function geodir_get_review_total($post_id = 0)
559 559
 {
560
-    global $wpdb;
561
-
562
-    $results = $wpdb->get_var(
563
-        $wpdb->prepare(
564
-            "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
565
-            array($post_id)
566
-        )
567
-    );
568
-
569
-    if (!empty($results))
570
-        return $results;
571
-    else
572
-        return false;
560
+	global $wpdb;
561
+
562
+	$results = $wpdb->get_var(
563
+		$wpdb->prepare(
564
+			"SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
565
+			array($post_id)
566
+		)
567
+	);
568
+
569
+	if (!empty($results))
570
+		return $results;
571
+	else
572
+		return false;
573 573
 }
574 574
 
575 575
 /**
@@ -585,18 +585,18 @@  discard block
 block discarded – undo
585 585
  */
586 586
 function geodir_get_review_count_by_user_id($user_id = 0)
587 587
 {
588
-    global $wpdb;
589
-    $results = $wpdb->get_var(
590
-        $wpdb->prepare(
591
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0",
592
-            array($user_id)
593
-        )
594
-    );
595
-
596
-    if (!empty($results))
597
-        return $results;
598
-    else
599
-        return false;
588
+	global $wpdb;
589
+	$results = $wpdb->get_var(
590
+		$wpdb->prepare(
591
+			"SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0",
592
+			array($user_id)
593
+		)
594
+	);
595
+
596
+	if (!empty($results))
597
+		return $results;
598
+	else
599
+		return false;
600 600
 }
601 601
 
602 602
 /**
@@ -614,27 +614,27 @@  discard block
 block discarded – undo
614 614
  */
615 615
 function geodir_get_post_rating($post_id = 0, $force_query = 0)
616 616
 {
617
-    global $wpdb, $post;
618
-
619
-    if (isset($post->ID) && $post->ID == $post_id && !$force_query) {
620
-        if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) {
621
-            return $post->overall_rating;
622
-        } else {
623
-            return 0;
624
-        }
625
-    }
626
-
627
-    $results = $wpdb->get_var(
628
-        $wpdb->prepare(
629
-            "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
630
-            array($post_id)
631
-        )
632
-    );
633
-
634
-    if (!empty($results))
635
-        return $results;
636
-    else
637
-        return false;
617
+	global $wpdb, $post;
618
+
619
+	if (isset($post->ID) && $post->ID == $post_id && !$force_query) {
620
+		if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) {
621
+			return $post->overall_rating;
622
+		} else {
623
+			return 0;
624
+		}
625
+	}
626
+
627
+	$results = $wpdb->get_var(
628
+		$wpdb->prepare(
629
+			"SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
630
+			array($post_id)
631
+		)
632
+	);
633
+
634
+	if (!empty($results))
635
+		return $results;
636
+	else
637
+		return false;
638 638
 }
639 639
 
640 640
 /**
@@ -650,19 +650,19 @@  discard block
 block discarded – undo
650 650
  */
651 651
 function geodir_get_review_count_total($post_id = 0)
652 652
 {
653
-    global $wpdb;
654
-
655
-    $results = $wpdb->get_var(
656
-        $wpdb->prepare(
657
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
658
-            array($post_id)
659
-        )
660
-    );
661
-
662
-    if (!empty($results))
663
-        return $results;
664
-    else
665
-        return false;
653
+	global $wpdb;
654
+
655
+	$results = $wpdb->get_var(
656
+		$wpdb->prepare(
657
+			"SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
658
+			array($post_id)
659
+		)
660
+	);
661
+
662
+	if (!empty($results))
663
+		return $results;
664
+	else
665
+		return false;
666 666
 }
667 667
 
668 668
 /**
@@ -679,20 +679,20 @@  discard block
 block discarded – undo
679 679
  */
680 680
 function geodir_get_comments_number($post_id = 0)
681 681
 {
682
-    global $wpdb;
682
+	global $wpdb;
683 683
 
684
-    $results = $wpdb->get_var(
685
-        $wpdb->prepare(
686
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
687
-            array($post_id)
688
-        )
689
-    );
684
+	$results = $wpdb->get_var(
685
+		$wpdb->prepare(
686
+			"SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
687
+			array($post_id)
688
+		)
689
+	);
690 690
 
691 691
 
692
-    if (!empty($results))
693
-        return $results;
694
-    else
695
-        return false;
692
+	if (!empty($results))
693
+		return $results;
694
+	else
695
+		return false;
696 696
 }
697 697
 
698 698
 /**
@@ -708,19 +708,19 @@  discard block
 block discarded – undo
708 708
  */
709 709
 function geodir_get_commentoverall($comment_id = 0)
710 710
 {
711
-    global $wpdb;
712
-
713
-    $reatings = $wpdb->get_var(
714
-        $wpdb->prepare(
715
-            "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
716
-            array($comment_id)
717
-        )
718
-    );
719
-
720
-    if ($reatings)
721
-        return $reatings;
722
-    else
723
-        return false;
711
+	global $wpdb;
712
+
713
+	$reatings = $wpdb->get_var(
714
+		$wpdb->prepare(
715
+			"SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
716
+			array($comment_id)
717
+		)
718
+	);
719
+
720
+	if ($reatings)
721
+		return $reatings;
722
+	else
723
+		return false;
724 724
 }
725 725
 
726 726
 /**
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
  */
735 735
 function geodir_get_commentoverall_number($post_id = 0)
736 736
 {
737
-    return geodir_get_post_rating($post_id);
737
+	return geodir_get_post_rating($post_id);
738 738
 }
739 739
 
740 740
 
@@ -752,102 +752,102 @@  discard block
 block discarded – undo
752 752
  */
753 753
 function geodir_comment_template($comment_template)
754 754
 {
755
-    global $post;
755
+	global $post;
756 756
 
757
-    $post_types = geodir_get_posttypes();
757
+	$post_types = geodir_get_posttypes();
758 758
 
759
-    if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) {
760
-        return;
761
-    }
762
-    if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business
763
-        if (geodir_cpt_has_rating_disabled($post->post_type)) {
764
-            return $comment_template;
765
-        }
759
+	if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) {
760
+		return;
761
+	}
762
+	if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business
763
+		if (geodir_cpt_has_rating_disabled($post->post_type)) {
764
+			return $comment_template;
765
+		}
766 766
         
767
-        $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
768
-        if (!$template) {
769
-            $template = dirname(__FILE__) . '/reviews.php';
770
-        }
771
-        return $template;
772
-    }
767
+		$template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
768
+		if (!$template) {
769
+			$template = dirname(__FILE__) . '/reviews.php';
770
+		}
771
+		return $template;
772
+	}
773 773
 }
774 774
 
775 775
 add_filter("comments_template", "geodir_comment_template");
776 776
 
777 777
 
778 778
 if (!function_exists('geodir_comment')) {
779
-    /**
780
-     * Comment HTML markup.
781
-     *
782
-     * @since 1.0.0
783
-     * @package GeoDirectory
784
-     * @global object $post The current post object.
785
-     * @param object $comment The comment object.
786
-     * @param string|array $args {
787
-     *     Optional. Formatting options.
788
-     *
789
-     *     @type object $walker            Instance of a Walker class to list comments. Default null.
790
-     *     @type int    $max_depth         The maximum comments depth. Default empty.
791
-     *     @type string $style             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
792
-     *     @type string $callback          Callback function to use. Default null.
793
-     *     @type string $end-callback      Callback function to use at the end. Default null.
794
-     *     @type string $type              Type of comments to list.
795
-     *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
796
-     *     @type int    $page              Page ID to list comments for. Default empty.
797
-     *     @type int    $per_page          Number of comments to list per page. Default empty.
798
-     *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
799
-     *     @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
800
-     *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
801
-     *     @type string $format            How to format the comments list.
802
-     *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
803
-     *     @type bool   $short_ping        Whether to output short pings. Default false.
804
-     *     @type bool   $echo              Whether to echo the output or return it. Default true.
805
-     * }
806
-     * @param int $depth Depth of comment.
807
-     */
808
-    function geodir_comment($comment, $args, $depth)
809
-    {
810
-        $GLOBALS['comment'] = $comment;
811
-        switch ($comment->comment_type) :
812
-            case 'pingback' :
813
-            case 'trackback' :
814
-                // Display trackbacks differently than normal comments.
815
-                ?>
779
+	/**
780
+	 * Comment HTML markup.
781
+	 *
782
+	 * @since 1.0.0
783
+	 * @package GeoDirectory
784
+	 * @global object $post The current post object.
785
+	 * @param object $comment The comment object.
786
+	 * @param string|array $args {
787
+	 *     Optional. Formatting options.
788
+	 *
789
+	 *     @type object $walker            Instance of a Walker class to list comments. Default null.
790
+	 *     @type int    $max_depth         The maximum comments depth. Default empty.
791
+	 *     @type string $style             The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
792
+	 *     @type string $callback          Callback function to use. Default null.
793
+	 *     @type string $end-callback      Callback function to use at the end. Default null.
794
+	 *     @type string $type              Type of comments to list.
795
+	 *                                     Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
796
+	 *     @type int    $page              Page ID to list comments for. Default empty.
797
+	 *     @type int    $per_page          Number of comments to list per page. Default empty.
798
+	 *     @type int    $avatar_size       Height and width dimensions of the avatar size. Default 32.
799
+	 *     @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
800
+	 *     @type bool   $reverse_children  Whether to reverse child comments in the list. Default null.
801
+	 *     @type string $format            How to format the comments list.
802
+	 *                                     Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
803
+	 *     @type bool   $short_ping        Whether to output short pings. Default false.
804
+	 *     @type bool   $echo              Whether to echo the output or return it. Default true.
805
+	 * }
806
+	 * @param int $depth Depth of comment.
807
+	 */
808
+	function geodir_comment($comment, $args, $depth)
809
+	{
810
+		$GLOBALS['comment'] = $comment;
811
+		switch ($comment->comment_type) :
812
+			case 'pingback' :
813
+			case 'trackback' :
814
+				// Display trackbacks differently than normal comments.
815
+				?>
816 816
                 <li <?php comment_class('geodir-comment'); ?> id="comment-<?php comment_ID(); ?>">
817 817
                 <p><?php _e('Pingback:', 'geodirectory'); ?> <?php comment_author_link(); ?> <?php edit_comment_link(__('(Edit)', 'geodirectory'), '<span class="edit-link">', '</span>'); ?></p>
818 818
                 <?php
819
-                break;
820
-            default :
821
-                // Proceed with normal comments.
822
-                global $post;
823
-                ?>
819
+				break;
820
+			default :
821
+				// Proceed with normal comments.
822
+				global $post;
823
+				?>
824 824
             <li <?php comment_class('geodir-comment'); ?> id="li-comment-<?php comment_ID(); ?>">
825 825
                 <article id="comment-<?php comment_ID(); ?>" class="comment">
826 826
                     <header class="comment-meta comment-author vcard">
827 827
                         <?php
828
-                        /**
829
-                         * Filter to modify comment avatar size
830
-                         *
831
-                         * You can use this filter to change comment avatar size.
832
-                         *
833
-                         * @since 1.0.0
834
-                         * @package GeoDirectory
835
-                         */
836
-                        $avatar_size = apply_filters('geodir_comment_avatar_size', 44);
837
-                        echo get_avatar($comment, $avatar_size);
838
-                        printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
839
-                            get_comment_author_link(),
840
-                            // If current post author is also comment author, make it known visually.
841
-                            ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
842
-                        );
843
-                        echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>";
844
-                        printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
845
-                            esc_url(get_comment_link($comment->comment_ID)),
846
-                            get_comment_time('c'),
847
-                            /* translators: 1: date, 2: time */
848
-                            sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time())
849
-                        );
850
-                        ?>
828
+						/**
829
+						 * Filter to modify comment avatar size
830
+						 *
831
+						 * You can use this filter to change comment avatar size.
832
+						 *
833
+						 * @since 1.0.0
834
+						 * @package GeoDirectory
835
+						 */
836
+						$avatar_size = apply_filters('geodir_comment_avatar_size', 44);
837
+						echo get_avatar($comment, $avatar_size);
838
+						printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
839
+							get_comment_author_link(),
840
+							// If current post author is also comment author, make it known visually.
841
+							($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
842
+						);
843
+						echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>";
844
+						printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
845
+							esc_url(get_comment_link($comment->comment_ID)),
846
+							get_comment_time('c'),
847
+							/* translators: 1: date, 2: time */
848
+							sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time())
849
+						);
850
+						?>
851 851
                     </header>
852 852
                     <!-- .comment-meta -->
853 853
 
@@ -871,47 +871,47 @@  discard block
 block discarded – undo
871 871
                 </article>
872 872
                 <!-- #comment-## -->
873 873
                 <?php
874
-                break;
875
-        endswitch; // end comment_type check
876
-    }
874
+				break;
875
+		endswitch; // end comment_type check
876
+	}
877 877
 }
878 878
 
879 879
 
880 880
 add_filter('get_comments_number', 'geodir_fix_comment_count', 10, 2);
881 881
 if (!function_exists('geodir_fix_comment_count')) {
882
-    /**
883
-     * Fix comment count by not listing replies as reviews
884
-     *
885
-     * @since 1.0.0
886
-     * @package GeoDirectory
887
-     * @global object $post The current post object.
888
-     * @param int $count The comment count.
889
-     * @param int $post_id The post ID.
890
-     * @todo $post is unreachable since the function return the count before that variable.
891
-     * @return bool|null|string The comment count.
892
-     */
893
-    function geodir_fix_comment_count($count, $post_id)
894
-    {
895
-        if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) {
896
-            global $post;
897
-            $post_types = geodir_get_posttypes();
898
-
899
-            if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
900
-                $review_count = geodir_get_review_count_total($post_id);
901
-                return $review_count;
902
-
903
-                if ($post && isset($post->rating_count)) {
904
-                    return $post->rating_count;
905
-                } else {
906
-                    return geodir_get_comments_number($post_id);
907
-                }
908
-            } else {
909
-                return $count;
910
-            }
911
-        } else {
912
-            return $count;
913
-        }
914
-    }
882
+	/**
883
+	 * Fix comment count by not listing replies as reviews
884
+	 *
885
+	 * @since 1.0.0
886
+	 * @package GeoDirectory
887
+	 * @global object $post The current post object.
888
+	 * @param int $count The comment count.
889
+	 * @param int $post_id The post ID.
890
+	 * @todo $post is unreachable since the function return the count before that variable.
891
+	 * @return bool|null|string The comment count.
892
+	 */
893
+	function geodir_fix_comment_count($count, $post_id)
894
+	{
895
+		if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) {
896
+			global $post;
897
+			$post_types = geodir_get_posttypes();
898
+
899
+			if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
900
+				$review_count = geodir_get_review_count_total($post_id);
901
+				return $review_count;
902
+
903
+				if ($post && isset($post->rating_count)) {
904
+					return $post->rating_count;
905
+				} else {
906
+					return geodir_get_comments_number($post_id);
907
+				}
908
+			} else {
909
+				return $count;
910
+			}
911
+		} else {
912
+			return $count;
913
+		}
914
+	}
915 915
 }
916 916
 
917 917
 /**
@@ -929,14 +929,14 @@  discard block
 block discarded – undo
929 929
  */
930 930
 function geodir_get_rating_stars($rating, $post_id, $small = false)
931 931
 {
932
-    if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
933
-        return NULL;
934
-    }
935
-    $a_rating = $rating / 5 * 100;
936
-
937
-    if ($small) {
938
-        $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>';
939
-    } else {
932
+	if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
933
+		return NULL;
934
+	}
935
+	$a_rating = $rating / 5 * 100;
936
+
937
+	if ($small) {
938
+		$r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>';
939
+	} else {
940 940
 		if (function_exists('geodir_reviewrating_draw_overall_rating')) {
941 941
 			// Show rating stars from review rating manager
942 942
 			$r_html = geodir_reviewrating_draw_overall_rating($rating);
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 			}
954 954
 			$r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>';
955 955
 		}
956
-    }
957
-    return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
956
+	}
957
+	return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
958 958
 }
959 959
 
960 960
 /**
@@ -968,23 +968,23 @@  discard block
 block discarded – undo
968 968
 function geodir_is_reviews_show($pageview = '')
969 969
 {
970 970
 
971
-    $active_tabs = get_option('geodir_detail_page_tabs_excluded');
972
-
973
-    $is_display = true;
974
-    if (!empty($active_tabs) && in_array('reviews', $active_tabs))
975
-        $is_display = false;
976
-
977
-    /**
978
-     * Filter to change display value.
979
-     *
980
-     * You can use this filter to change the is_display value.
981
-     *
982
-     * @since 1.0.0
983
-     * @package GeoDirectory
984
-     * @param bool $is_display Display ratings when set to true.
985
-     * @param string $pageview The view template. Ex: listview, gridview etc.
986
-     */
987
-    return apply_filters('geodir_is_reviews_show', $is_display, $pageview);
971
+	$active_tabs = get_option('geodir_detail_page_tabs_excluded');
972
+
973
+	$is_display = true;
974
+	if (!empty($active_tabs) && in_array('reviews', $active_tabs))
975
+		$is_display = false;
976
+
977
+	/**
978
+	 * Filter to change display value.
979
+	 *
980
+	 * You can use this filter to change the is_display value.
981
+	 *
982
+	 * @since 1.0.0
983
+	 * @package GeoDirectory
984
+	 * @param bool $is_display Display ratings when set to true.
985
+	 * @param string $pageview The view template. Ex: listview, gridview etc.
986
+	 */
987
+	return apply_filters('geodir_is_reviews_show', $is_display, $pageview);
988 988
 }
989 989
 
990 990
 
@@ -992,9 +992,9 @@  discard block
 block discarded – undo
992 992
  * If Disqus plugin is active, do some fixes to show on blogs but no on GD post types
993 993
  */
994 994
 if(function_exists('dsq_can_replace')) {
995
-    remove_filter('comments_template', 'dsq_comments_template');
996
-    add_filter('comments_template', 'dsq_comments_template', 100);
997
-    add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
995
+	remove_filter('comments_template', 'dsq_comments_template');
996
+	add_filter('comments_template', 'dsq_comments_template', 100);
997
+	add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
998 998
 }
999 999
 
1000 1000
 
@@ -1008,14 +1008,14 @@  discard block
 block discarded – undo
1008 1008
  * @return string `1` if active `0` if disabled.
1009 1009
  */
1010 1010
 function geodir_option_disqus_active($disqus_active){
1011
-    global $post;
1012
-    $all_postypes = geodir_get_posttypes();
1011
+	global $post;
1012
+	$all_postypes = geodir_get_posttypes();
1013 1013
 
1014
-    if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
1015
-        $disqus_active = '0';
1016
-    }
1014
+	if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
1015
+		$disqus_active = '0';
1016
+	}
1017 1017
 
1018
-    return $disqus_active;
1018
+	return $disqus_active;
1019 1019
 }
1020 1020
 
1021 1021
 /**
@@ -1029,23 +1029,23 @@  discard block
 block discarded – undo
1029 1029
  * @return array Modified tabs array.
1030 1030
  */
1031 1031
 function geodir_detail_reviews_tab_title($tabs_arr) {
1032
-    $post_type = geodir_get_current_posttype();
1032
+	$post_type = geodir_get_current_posttype();
1033 1033
 
1034
-    if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) {
1035
-        $label_reviews = __('Comments', 'geodirectory');
1034
+	if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) {
1035
+		$label_reviews = __('Comments', 'geodirectory');
1036 1036
         
1037
-        if (defined('GEODIR_CP_VERSION')) {
1038
-            $post_types = geodir_get_posttypes('array');
1037
+		if (defined('GEODIR_CP_VERSION')) {
1038
+			$post_types = geodir_get_posttypes('array');
1039 1039
             
1040
-            if (!empty($post_types[$post_type]['labels']['label_reviews'])) {
1041
-                $label_reviews = stripslashes(__($post_types[$post_type]['labels']['label_reviews'], 'geodirectory'));
1042
-            }
1043
-        }
1040
+			if (!empty($post_types[$post_type]['labels']['label_reviews'])) {
1041
+				$label_reviews = stripslashes(__($post_types[$post_type]['labels']['label_reviews'], 'geodirectory'));
1042
+			}
1043
+		}
1044 1044
         
1045
-        $tabs_arr['reviews']['heading_text'] = $label_reviews;
1046
-    }
1045
+		$tabs_arr['reviews']['heading_text'] = $label_reviews;
1046
+	}
1047 1047
     
1048
-    return $tabs_arr;
1048
+	return $tabs_arr;
1049 1049
 }
1050 1050
 add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_reviews_tab_title', 1000, 1);
1051 1051
 
@@ -1056,13 +1056,13 @@  discard block
 block discarded – undo
1056 1056
  * @since 1.6.21
1057 1057
  */
1058 1058
 function geodir_jetpack_disable_comments(){
1059
-    //only run if jetpack installed
1060
-    if(defined('JETPACK__VERSION')){
1061
-        $post_types = geodir_get_posttypes();
1062
-        foreach($post_types as $post_type){
1063
-            add_filter('jetpack_comment_form_enabled_for_' . $post_type, '__return_false');
1064
-        }
1065
-    }
1059
+	//only run if jetpack installed
1060
+	if(defined('JETPACK__VERSION')){
1061
+		$post_types = geodir_get_posttypes();
1062
+		foreach($post_types as $post_type){
1063
+			add_filter('jetpack_comment_form_enabled_for_' . $post_type, '__return_false');
1064
+		}
1065
+	}
1066 1066
 }
1067 1067
 
1068 1068
 add_action('plugins_loaded','geodir_jetpack_disable_comments');
@@ -1077,13 +1077,13 @@  discard block
 block discarded – undo
1077 1077
  * @return bool True if allowed otherwise False.
1078 1078
  */
1079 1079
 function geodir_check_reviews_open( $open, $post_id ) {
1080
-    if ( $open && $post_id && geodir_is_page( 'detail' ) ) {
1081
-        if ( in_array( get_post_status( $post_id ), array( 'draft', 'pending', 'auto-draft', 'trash' ) ) ) {
1082
-            $open = false;
1083
-        }
1084
-    }
1080
+	if ( $open && $post_id && geodir_is_page( 'detail' ) ) {
1081
+		if ( in_array( get_post_status( $post_id ), array( 'draft', 'pending', 'auto-draft', 'trash' ) ) ) {
1082
+			$open = false;
1083
+		}
1084
+	}
1085 1085
     
1086
-    return $open;
1086
+	return $open;
1087 1087
 }
1088 1088
 add_filter( 'comments_open', 'geodir_check_reviews_open', 10, 2 );
1089 1089
 
@@ -1098,10 +1098,10 @@  discard block
 block discarded – undo
1098 1098
  * @return string Filtered comment content.
1099 1099
  */
1100 1100
 function geodir_remove_img_tags_from_comment( $comment_text, $comment = array(), $args = array() ) {
1101
-    if ( !empty( $comment_text ) && !empty( $comment ) && strpos( $comment_text, '[img' ) !== false && strpos( get_post_type( $comment->comment_post_ID ), 'gd_' ) === 0 ) {
1102
-        $comment_text = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_text );
1103
-        $comment_text = trim( $comment_text );
1104
-    }
1105
-    return $comment_text;
1101
+	if ( !empty( $comment_text ) && !empty( $comment ) && strpos( $comment_text, '[img' ) !== false && strpos( get_post_type( $comment->comment_post_ID ), 'gd_' ) === 0 ) {
1102
+		$comment_text = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_text );
1103
+		$comment_text = trim( $comment_text );
1104
+	}
1105
+	return $comment_text;
1106 1106
 }
1107 1107
 add_filter( 'comment_text', 'geodir_remove_img_tags_from_comment', 10, 3 );
1108 1108
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function geodir_comment_rating_meta($comment) {
69 69
     $post_type = get_post_type($comment->comment_post_ID);
70
-	if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
70
+	if (in_array($post_type, (array) geodir_get_posttypes()) && (int) $comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
71 71
 		$rating = geodir_get_commentoverall($comment->comment_ID);
72 72
 		
73
-		if ((int)get_option('geodir_reviewrating_enable_font_awesome') == 1) {
73
+		if ((int) get_option('geodir_reviewrating_enable_font_awesome') == 1) {
74 74
 			$star_texts = array();
75 75
 			$star_texts[] = __('Terrible', 'geodirectory');
76 76
 			$star_texts[] = __('Poor', 'geodirectory');
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 			echo geodir_font_awesome_rating_form_html('', $star_texts, $rating);
82 82
 		} else {			
83 83
 			if ($rating) {
84
-				echo '<div class="gd_rating" data-average="' . $rating . '" data-id="5">';
84
+				echo '<div class="gd_rating" data-average="'.$rating.'" data-id="5">';
85 85
 
86 86
 			} else {
87 87
 				echo '<div class="gd_rating" data-average="0" data-id="5"></div>';
88 88
 			}
89 89
 		}
90
-		echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="' . $rating . '"  />';
90
+		echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="'.$rating.'"  />';
91 91
 	}
92 92
 }
93 93
 
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 {
141 141
 
142 142
     if (strpos($link, 'wp-login.php?') !== false) {
143
-        $link = str_replace(wp_login_url(),geodir_login_url(),$link);
143
+        $link = str_replace(wp_login_url(), geodir_login_url(), $link);
144 144
     }
145
-    $link = '<div class="gd_comment_replaylink">' . $link . '</div>';
145
+    $link = '<div class="gd_comment_replaylink">'.$link.'</div>';
146 146
 
147 147
     return $link;
148 148
 }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 function geodir_cancle_replaylink($link)
160 160
 {
161 161
 
162
-    $link = '<span class="gd-cancel-replaylink">' . $link . '</span>';
162
+    $link = '<span class="gd-cancel-replaylink">'.$link.'</span>';
163 163
 
164 164
     return $link;
165 165
 }
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
     if (isset($_REQUEST['geodir_overallrating'])) {
200 200
         $overall_rating = $_REQUEST['geodir_overallrating'];
201 201
         
202
-		if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
202
+		if (isset($comment_info->comment_parent) && (int) $comment_info->comment_parent == 0) {
203 203
             $overall_rating = $overall_rating > 0 ? $overall_rating : '0';
204 204
 
205
-            $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
205
+            $sqlqry = $wpdb->prepare("INSERT INTO ".GEODIR_REVIEW_TABLE." SET
206 206
 					post_id		= %d,
207 207
 					post_type = %s,
208 208
 					post_title	= %s,
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
     $post_type = get_post_type($post_id);
291 291
 
292
-    $detail_table = $plugin_prefix . $post_type . '_detail';
292
+    $detail_table = $plugin_prefix.$post_type.'_detail';
293 293
 
294 294
     if ($comment_id) {
295 295
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 
298 298
         if (isset($old_rating)) {
299 299
 
300
-            $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
300
+            $sqlqry = $wpdb->prepare("UPDATE ".GEODIR_REVIEW_TABLE." SET
301 301
 						overall_rating = %f,
302 302
 						status		= %s,
303 303
 						comment_content = %s 
@@ -339,18 +339,18 @@  discard block
 block discarded – undo
339 339
 
340 340
     $post_type = get_post_type($post_id);
341 341
 
342
-    $detail_table = $plugin_prefix . $post_type . '_detail';
342
+    $detail_table = $plugin_prefix.$post_type.'_detail';
343 343
 
344 344
     if (isset($_REQUEST['geodir_overallrating'])) {
345 345
 
346 346
         $overall_rating = $_REQUEST['geodir_overallrating'];
347 347
 
348
-        if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
348
+        if (isset($comment_info->comment_parent) && (int) $comment_info->comment_parent == 0) {
349 349
             $overall_rating = $overall_rating > 0 ? $overall_rating : '0';
350 350
 
351 351
             if (isset($old_rating)) {
352 352
 
353
-                $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
353
+                $sqlqry = $wpdb->prepare("UPDATE ".GEODIR_REVIEW_TABLE." SET
354 354
 						overall_rating = %f,
355 355
 						status		= %s,
356 356
 						comment_content	= %s 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 
389 389
     $wpdb->query(
390 390
         $wpdb->prepare(
391
-            "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d",
391
+            "DELETE FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id=%d",
392 392
             array($comment_id)
393 393
         )
394 394
     );
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
  * @return string The comment content.
408 408
  */
409 409
 function geodir_wrap_comment_text($content, $comment = '') {
410
-    if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
410
+    if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int) $comment->comment_post_ID)) {
411 411
         if (!is_admin()) {
412
-            return '<div class="description">' . $content . '</div>';
412
+            return '<div class="description">'.$content.'</div>';
413 413
         } else {
414 414
             return $content;
415 415
         }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
         if (!empty($comment))
419 419
             $rating = geodir_get_commentoverall($comment->comment_ID);
420 420
         if ($rating != 0 && !is_admin()) {
421
-            return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
421
+            return '<div><div class="gd-rating-text">'.__('Overall Rating', 'geodirectory').': <div class="rating">'.$rating.'</div></div>'.geodir_get_rating_stars($rating, $comment->comment_ID).'</div><div class="description">'.$content.'</div>';
422 422
         } else
423 423
             return $content;
424 424
     }
@@ -442,18 +442,18 @@  discard block
 block discarded – undo
442 442
     if (!$post_type) {
443 443
         $post_type = get_post_type($post_id);
444 444
     }
445
-    $detail_table = $plugin_prefix . $post_type . '_detail';
445
+    $detail_table = $plugin_prefix.$post_type.'_detail';
446 446
     $post_newrating = geodir_get_post_rating($post_id, 1);
447 447
     $post_newrating_count = geodir_get_review_count_total($post_id);
448 448
 
449 449
 
450 450
     //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ;
451 451
 
452
-    if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
452
+    if ($wpdb->get_var("SHOW TABLES LIKE '".$detail_table."'") == $detail_table) {
453 453
 
454 454
         $wpdb->query(
455 455
             $wpdb->prepare(
456
-                "UPDATE " . $detail_table . " SET
456
+                "UPDATE ".$detail_table." SET
457 457
 						overall_rating = %f,
458 458
 						rating_count = %f
459 459
 						where post_id = %d",
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
      * @package GeoDirectory
473 473
      * @param int $post_id The post ID.
474 474
      */
475
-    do_action('geodir_update_postrating',$post_id);
475
+    do_action('geodir_update_postrating', $post_id);
476 476
 
477 477
 }
478 478
 
@@ -493,13 +493,13 @@  discard block
 block discarded – undo
493 493
     global $wpdb, $plugin_prefix;
494 494
 
495 495
     $post_type = get_post_type($post_id);
496
-    $detail_table = $plugin_prefix . $post_type . '_detail';
496
+    $detail_table = $plugin_prefix.$post_type.'_detail';
497 497
 
498
-    if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
498
+    if ($wpdb->get_var("SHOW TABLES LIKE '".$detail_table."'") == $detail_table) {
499 499
 
500 500
         $post_ratings = $wpdb->get_var(
501 501
             $wpdb->prepare(
502
-                "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d",
502
+                "SELECT overall_rating FROM ".$detail_table." WHERE post_id = %d",
503 503
                 array($post_id)
504 504
             )
505 505
         );
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 
534 534
     $reatings = $wpdb->get_row(
535 535
         $wpdb->prepare(
536
-            "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
536
+            "SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id = %d",
537 537
             array($comment_id)
538 538
         )
539 539
     );
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 
562 562
     $results = $wpdb->get_var(
563 563
         $wpdb->prepare(
564
-            "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
564
+            "SELECT SUM(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0",
565 565
             array($post_id)
566 566
         )
567 567
     );
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
     global $wpdb;
589 589
     $results = $wpdb->get_var(
590 590
         $wpdb->prepare(
591
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0",
591
+            "SELECT COUNT(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE user_id = %d AND status=1 AND overall_rating>0",
592 592
             array($user_id)
593 593
         )
594 594
     );
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 
627 627
     $results = $wpdb->get_var(
628 628
         $wpdb->prepare(
629
-            "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
629
+            "SELECT COALESCE(avg(overall_rating),0) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0",
630 630
             array($post_id)
631 631
         )
632 632
     );
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 
655 655
     $results = $wpdb->get_var(
656 656
         $wpdb->prepare(
657
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
657
+            "SELECT COUNT(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0",
658 658
             array($post_id)
659 659
         )
660 660
     );
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 
684 684
     $results = $wpdb->get_var(
685 685
         $wpdb->prepare(
686
-            "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0",
686
+            "SELECT COUNT(overall_rating) FROM ".GEODIR_REVIEW_TABLE." WHERE post_id = %d AND status=1 AND overall_rating>0",
687 687
             array($post_id)
688 688
         )
689 689
     );
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 
713 713
     $reatings = $wpdb->get_var(
714 714
         $wpdb->prepare(
715
-            "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d",
715
+            "SELECT overall_rating FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id = %d",
716 716
             array($comment_id)
717 717
         )
718 718
     );
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
         
767 767
         $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
768 768
         if (!$template) {
769
-            $template = dirname(__FILE__) . '/reviews.php';
769
+            $template = dirname(__FILE__).'/reviews.php';
770 770
         }
771 771
         return $template;
772 772
     }
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
                         printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
839 839
                             get_comment_author_link(),
840 840
                             // If current post author is also comment author, make it known visually.
841
-                            ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
841
+                            ($comment->user_id === $post->post_author) ? '<span>'.__('Post author', 'geodirectory').'</span>' : ''
842 842
                         );
843 843
                         echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>";
844 844
                         printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
             global $post;
897 897
             $post_types = geodir_get_posttypes();
898 898
 
899
-            if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
899
+            if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int) $post_id)) {
900 900
                 $review_count = geodir_get_review_count_total($post_id);
901 901
                 return $review_count;
902 902
 
@@ -929,29 +929,29 @@  discard block
 block discarded – undo
929 929
  */
930 930
 function geodir_get_rating_stars($rating, $post_id, $small = false)
931 931
 {
932
-    if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
932
+    if (!empty($post_id) && geodir_cpt_has_rating_disabled((int) $post_id)) {
933 933
         return NULL;
934 934
     }
935 935
     $a_rating = $rating / 5 * 100;
936 936
 
937 937
     if ($small) {
938
-        $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>';
938
+        $r_html = '<div class="rating"><div class="gd_rating_map" data-average="'.$rating.'" data-id="'.$post_id.'"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: '.$a_rating.'%;"></div><div class="geodir_Star_small"></div></div></div>';
939 939
     } else {
940 940
 		if (function_exists('geodir_reviewrating_draw_overall_rating')) {
941 941
 			// Show rating stars from review rating manager
942 942
 			$r_html = geodir_reviewrating_draw_overall_rating($rating);
943 943
 		} else {
944
-			$rating_img = '<img alt="rating icon" src="' . get_option('geodir_default_rating_star_icon') . '" />';
944
+			$rating_img = '<img alt="rating icon" src="'.get_option('geodir_default_rating_star_icon').'" />';
945 945
 			
946 946
 			/* fix rating star for safari */
947 947
 			$star_width = 23 * 5;
948 948
 			
949 949
 			if ($star_width > 0) {
950
-				$attach_style = 'max-width:' . $star_width . 'px';
950
+				$attach_style = 'max-width:'.$star_width.'px';
951 951
 			} else {
952 952
 				$attach_style = '';
953 953
 			}
954
-			$r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>';
954
+			$r_html = '<div class="geodir-rating" style="'.$attach_style.'"><div class="gd_rating_show" data-average="'.$rating.'" data-id="'.$post_id.'"><div class="geodir_RatingAverage" style="width: '.$a_rating.'%;"></div><div class="geodir_Star">'.$rating_img.$rating_img.$rating_img.$rating_img.$rating_img.'</div></div></div>';
955 955
 		}
956 956
     }
957 957
     return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
@@ -991,10 +991,10 @@  discard block
 block discarded – undo
991 991
 /*
992 992
  * If Disqus plugin is active, do some fixes to show on blogs but no on GD post types
993 993
  */
994
-if(function_exists('dsq_can_replace')) {
994
+if (function_exists('dsq_can_replace')) {
995 995
     remove_filter('comments_template', 'dsq_comments_template');
996 996
     add_filter('comments_template', 'dsq_comments_template', 100);
997
-    add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
997
+    add_filter('pre_option_disqus_active', 'geodir_option_disqus_active', 10, 1);
998 998
 }
999 999
 
1000 1000
 
@@ -1007,11 +1007,11 @@  discard block
 block discarded – undo
1007 1007
  * @param string $disqus_active Hook called before DB call for option so this is empty.
1008 1008
  * @return string `1` if active `0` if disabled.
1009 1009
  */
1010
-function geodir_option_disqus_active($disqus_active){
1010
+function geodir_option_disqus_active($disqus_active) {
1011 1011
     global $post;
1012 1012
     $all_postypes = geodir_get_posttypes();
1013 1013
 
1014
-    if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
1014
+    if (isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
1015 1015
         $disqus_active = '0';
1016 1016
     }
1017 1017
 
@@ -1055,17 +1055,17 @@  discard block
 block discarded – undo
1055 1055
  *
1056 1056
  * @since 1.6.21
1057 1057
  */
1058
-function geodir_jetpack_disable_comments(){
1058
+function geodir_jetpack_disable_comments() {
1059 1059
     //only run if jetpack installed
1060
-    if(defined('JETPACK__VERSION')){
1060
+    if (defined('JETPACK__VERSION')) {
1061 1061
         $post_types = geodir_get_posttypes();
1062
-        foreach($post_types as $post_type){
1063
-            add_filter('jetpack_comment_form_enabled_for_' . $post_type, '__return_false');
1062
+        foreach ($post_types as $post_type) {
1063
+            add_filter('jetpack_comment_form_enabled_for_'.$post_type, '__return_false');
1064 1064
         }
1065 1065
     }
1066 1066
 }
1067 1067
 
1068
-add_action('plugins_loaded','geodir_jetpack_disable_comments');
1068
+add_action('plugins_loaded', 'geodir_jetpack_disable_comments');
1069 1069
 
1070 1070
 /**
1071 1071
  * Check whether the current post is open for reviews.
@@ -1076,16 +1076,16 @@  discard block
 block discarded – undo
1076 1076
  * @param int  $post_id The post ID.
1077 1077
  * @return bool True if allowed otherwise False.
1078 1078
  */
1079
-function geodir_check_reviews_open( $open, $post_id ) {
1080
-    if ( $open && $post_id && geodir_is_page( 'detail' ) ) {
1081
-        if ( in_array( get_post_status( $post_id ), array( 'draft', 'pending', 'auto-draft', 'trash' ) ) ) {
1079
+function geodir_check_reviews_open($open, $post_id) {
1080
+    if ($open && $post_id && geodir_is_page('detail')) {
1081
+        if (in_array(get_post_status($post_id), array('draft', 'pending', 'auto-draft', 'trash'))) {
1082 1082
             $open = false;
1083 1083
         }
1084 1084
     }
1085 1085
     
1086 1086
     return $open;
1087 1087
 }
1088
-add_filter( 'comments_open', 'geodir_check_reviews_open', 10, 2 );
1088
+add_filter('comments_open', 'geodir_check_reviews_open', 10, 2);
1089 1089
 
1090 1090
 /**
1091 1091
  * Filter the [img] tags from comment.
@@ -1097,11 +1097,11 @@  discard block
 block discarded – undo
1097 1097
  * @param array           $args         An array of arguments.
1098 1098
  * @return string Filtered comment content.
1099 1099
  */
1100
-function geodir_remove_img_tags_from_comment( $comment_text, $comment = array(), $args = array() ) {
1101
-    if ( !empty( $comment_text ) && !empty( $comment ) && strpos( $comment_text, '[img' ) !== false && strpos( get_post_type( $comment->comment_post_ID ), 'gd_' ) === 0 ) {
1102
-        $comment_text = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_text );
1103
-        $comment_text = trim( $comment_text );
1100
+function geodir_remove_img_tags_from_comment($comment_text, $comment = array(), $args = array()) {
1101
+    if (!empty($comment_text) && !empty($comment) && strpos($comment_text, '[img') !== false && strpos(get_post_type($comment->comment_post_ID), 'gd_') === 0) {
1102
+        $comment_text = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_text);
1103
+        $comment_text = trim($comment_text);
1104 1104
     }
1105 1105
     return $comment_text;
1106 1106
 }
1107
-add_filter( 'comment_text', 'geodir_remove_img_tags_from_comment', 10, 3 );
1108 1107
\ No newline at end of file
1108
+add_filter('comment_text', 'geodir_remove_img_tags_from_comment', 10, 3);
1109 1109
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory_template_tags.php 3 patches
Braces   +34 added lines, -19 removed lines patch added patch discarded remove patch
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         </script>
253 253
 
254 254
         <?php
255
-    }elseif(get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
255
+    } elseif(get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
256 256
         echo stripslashes(get_option('geodir_ga_tracking_code'));
257 257
     }
258 258
 }
@@ -291,13 +291,14 @@  discard block
 block discarded – undo
291 291
  */
292 292
 function geodir_add_async_forscript($url)
293 293
 {
294
-    if (strpos($url, '#asyncload')===false)
295
-        return $url;
296
-    else if (is_admin())
297
-        return str_replace('#asyncload', '', $url);
298
-    else
299
-        return str_replace('#asyncload', '', $url)."' async='async";
300
-}
294
+    if (strpos($url, '#asyncload')===false) {
295
+            return $url;
296
+    } else if (is_admin()) {
297
+            return str_replace('#asyncload', '', $url);
298
+    } else {
299
+            return str_replace('#asyncload', '', $url)."' async='async";
300
+    }
301
+    }
301 302
 add_filter('clean_url', 'geodir_add_async_forscript', 11, 1);
302 303
 
303 304
 /**
@@ -364,8 +365,10 @@  discard block
 block discarded – undo
364 365
 
365 366
     $half_pages_to_show = round($pages_to_show / 2);
366 367
 
367
-    if (geodir_is_page('home')) // dont apply default  pagination for geodirectory home page.
368
-        return;
368
+    if (geodir_is_page('home')) {
369
+    	// dont apply default  pagination for geodirectory home page.
370
+        return;
371
+    }
369 372
 
370 373
     if (!is_single()) {
371 374
         if (function_exists('geodir_location_geo_home_link')) {
@@ -485,11 +488,21 @@  discard block
 block discarded – undo
485 488
     }
486 489
     $dist_dif = 1000;
487 490
 
488
-    if ($dist <= 5000) $dist_dif = 500;
489
-    if ($dist <= 1000) $dist_dif = 100;
490
-    if ($dist <= 500) $dist_dif = 50;
491
-    if ($dist <= 100) $dist_dif = 10;
492
-    if ($dist <= 50) $dist_dif = 5;
491
+    if ($dist <= 5000) {
492
+    	$dist_dif = 500;
493
+    }
494
+    if ($dist <= 1000) {
495
+    	$dist_dif = 100;
496
+    }
497
+    if ($dist <= 500) {
498
+    	$dist_dif = 50;
499
+    }
500
+    if ($dist <= 100) {
501
+    	$dist_dif = 10;
502
+    }
503
+    if ($dist <= 50) {
504
+    	$dist_dif = 5;
505
+    }
493 506
 
494 507
     ?>
495 508
     <script type="text/javascript">
@@ -550,12 +563,14 @@  discard block
 block discarded – undo
550 563
  */
551 564
 function geodir_add_sharelocation_scripts() {
552 565
     $default_search_for_text = SEARCH_FOR_TEXT;
553
-    if (get_option('geodir_search_field_default_text'))
554
-        $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
566
+    if (get_option('geodir_search_field_default_text')) {
567
+            $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
568
+    }
555 569
 
556 570
     $default_near_text = NEAR_TEXT;
557
-    if (get_option('geodir_near_field_default_text'))
558
-        $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
571
+    if (get_option('geodir_near_field_default_text')) {
572
+            $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
573
+    }
559 574
     
560 575
     $search_location = geodir_get_default_location();
561 576
     
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
     $is_detail_page = false;
40 40
     $geodir_map_name = geodir_map_name();
41 41
 
42
-    if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) {
42
+    if ((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview'))) {
43 43
         $is_detail_page = true;
44 44
     }
45 45
 
46 46
     wp_enqueue_script('jquery');
47 47
 
48
-    wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION);
48
+    wp_register_script('geodirectory-script', geodir_plugin_url().'/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION);
49 49
     wp_enqueue_script('geodirectory-script');
50 50
 
51 51
     $geodir_vars_data = array(
52 52
         'siteurl' => get_option('siteurl'),
53 53
         'geodir_plugin_url' => geodir_plugin_url(),
54
-        'geodir_lazy_load' => get_option('geodir_lazy_load',1),
54
+        'geodir_lazy_load' => get_option('geodir_lazy_load', 1),
55 55
         'geodir_ajax_url' => geodir_get_ajax_url(),
56
-        'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'),
56
+        'geodir_gd_modal' => (int) get_option('geodir_disable_gb_modal'),
57 57
         'is_rtl' => is_rtl() ? 1 : 0 // fix rtl issue
58 58
     );
59 59
 
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
      *
75 75
      * }
76 76
      */
77
-    $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data);
77
+    $geodir_vars_data = apply_filters('geodir_vars_data', $geodir_vars_data);
78 78
 
79 79
     wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data);
80 80
 
81
-    wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true);
82
-    if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');}
81
+    wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION, true);
82
+    if ($is_detail_page) {wp_enqueue_script('geodirectory-jquery-flexslider-js'); }
83 83
 
84
-    wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true);
84
+    wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url().'/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION, true);
85 85
     wp_enqueue_script('geodirectory-lightbox-jquery');
86 86
 
87
-    wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true);
87
+    wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url().'/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION, true);
88 88
     if ($is_detail_page) {
89 89
         wp_enqueue_script('geodirectory-jquery-simplemodal');
90 90
     }
91 91
 
92 92
     if (in_array($geodir_map_name, array('auto', 'google'))) {
93
-        $map_lang = "&language=" . geodir_get_map_default_language();
94
-        $map_key = "&key=" . geodir_get_map_api_key();
93
+        $map_lang = "&language=".geodir_get_map_default_language();
94
+        $map_key = "&key=".geodir_get_map_api_key();
95 95
         /**
96 96
          * Filter the variables that are added to the end of the google maps script call.
97 97
          *
@@ -101,55 +101,55 @@  discard block
 block discarded – undo
101 101
          * @param string $var The string to filter, default is empty string.
102 102
          */
103 103
         $map_extra = apply_filters('geodir_googlemap_script_extra', '');
104
-        wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL);
104
+        wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?'.$map_lang.$map_key.$map_extra, '', NULL);
105 105
         
106 106
         // Overlapping Marker Spiderfier
107
-        wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
107
+        wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url().'/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
108 108
         wp_enqueue_script('geodirectory-g-overlappingmarker-script');
109 109
     }
110 110
     
111 111
     if ($geodir_map_name == 'osm') {
112 112
         // Leaflet OpenStreetMap
113
-        wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
113
+        wp_register_style('geodirectory-leaflet-style', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
114 114
         wp_enqueue_style('geodirectory-leaflet-style');
115 115
             
116
-        wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
116
+        wp_register_script('geodirectory-leaflet-script', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
117 117
         wp_enqueue_script('geodirectory-leaflet-script');
118 118
         
119
-        wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION);
119
+        wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url().'/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION);
120 120
         wp_enqueue_script('geodirectory-leaflet-geo-script');
121 121
         
122 122
         if ($is_detail_page) {
123
-            wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION);
123
+            wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url().'/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION);
124 124
             wp_enqueue_style('geodirectory-leaflet-routing-style');
125 125
                 
126
-            wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION);
126
+            wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url().'/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION);
127 127
             wp_enqueue_script('geodirectory-leaflet-routing-script');
128 128
         }
129 129
         
130 130
         // Overlapping Marker Spiderfier Leaflet
131
-        wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
131
+        wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url().'/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
132 132
         wp_enqueue_script('geodirectory-o-overlappingmarker-script');
133 133
     }
134
-    wp_enqueue_script( 'jquery-ui-autocomplete' );
134
+    wp_enqueue_script('jquery-ui-autocomplete');
135 135
     
136
-    wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
136
+    wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
137 137
     wp_enqueue_script('geodirectory-goMap-script');
138 138
 
139
-    wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION);
139
+    wp_register_script('chosen', geodir_plugin_url().'/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION);
140 140
     wp_enqueue_script('chosen');
141 141
 
142
-    wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION);
142
+    wp_register_script('geodirectory-choose-ajax', geodir_plugin_url().'/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION);
143 143
     wp_enqueue_script('geodirectory-choose-ajax');
144 144
 
145
-    wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true);
145
+    wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true);
146 146
 
147 147
     if (is_page() && geodir_is_page('add-listing')) {
148 148
         // SCRIPT FOR UPLOAD
149 149
         wp_enqueue_script('plupload-all');
150 150
         wp_enqueue_script('jquery-ui-sortable');
151 151
 
152
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true);
152
+        wp_register_script('geodirectory-plupload-script', geodir_plugin_url().'/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
153 153
         wp_enqueue_script('geodirectory-plupload-script');
154 154
         // SCRIPT FOR UPLOAD END
155 155
 
@@ -196,27 +196,27 @@  discard block
 block discarded – undo
196 196
 
197 197
         wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
198 198
 
199
-        wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload');
199
+        wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url().'/geodirectory-assets/js/listing_validation.min.js#asyncload');
200 200
     } // End if for add place page
201 201
 
202
-    wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
202
+    wp_register_script('geodirectory-post-custom-js', geodir_plugin_url().'/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
203 203
     if ($is_detail_page) {
204 204
 		wp_enqueue_script('geodirectory-post-custom-js');
205 205
 	}
206 206
 
207 207
     // font awesome rating script
208 208
 	if (get_option('geodir_reviewrating_enable_font_awesome')) {
209
-		wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true);
209
+		wp_register_script('geodir-barrating-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true);
210 210
 		wp_enqueue_script('geodir-barrating-js');
211 211
 	} else { // default rating script
212
-		wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.min.js', array(), GEODIRECTORY_VERSION, true);
212
+		wp_register_script('geodir-jRating-js', geodir_plugin_url().'/geodirectory-assets/js/jRating.jquery.min.js', array(), GEODIRECTORY_VERSION, true);
213 213
 		wp_enqueue_script('geodir-jRating-js');
214 214
 	}
215 215
 
216
-    wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
216
+    wp_register_script('geodir-on-document-load', geodir_plugin_url().'/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
217 217
     wp_enqueue_script('geodir-on-document-load');
218 218
 
219
-    wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
219
+    wp_register_script('google-geometa', geodir_plugin_url().'/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
220 220
     wp_enqueue_script('google-geometa');
221 221
 }
222 222
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
  */
232 232
 function geodir_header_scripts()
233 233
 {
234
-    echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>';
234
+    echo '<style>'.stripslashes(get_option('geodir_coustem_css')).'</style>';
235 235
     echo stripslashes(get_option('geodir_header_scripts'));
236 236
 }
237 237
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
  */
246 246
 function geodir_google_analytics_tracking_code()
247 247
 {
248
-    if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?>
248
+    if (get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')) {?>
249 249
 
250 250
         <script>
251 251
             (function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
                 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
254 254
             })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
255 255
 
256
-            ga('create', '<?php echo esc_attr(get_option('geodir_ga_account_id'));?>', 'auto');
257
-            <?php if(get_option('geodir_ga_anonymize_ip')){echo "ga('set', 'anonymizeIP', true);";}?>
256
+            ga('create', '<?php echo esc_attr(get_option('geodir_ga_account_id')); ?>', 'auto');
257
+            <?php if (get_option('geodir_ga_anonymize_ip')) {echo "ga('set', 'anonymizeIP', true);"; }?>
258 258
             ga('send', 'pageview');
259 259
 
260 260
         </script>
261 261
 
262 262
         <?php
263
-    }elseif(get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
263
+    }elseif (get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')) {
264 264
         echo stripslashes(get_option('geodir_ga_tracking_code'));
265 265
     }
266 266
 }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      *
284 284
      * Flexbox wont wrap on ios for search form items
285 285
      */
286
-    if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) {
286
+    if (!empty($_SERVER['HTTP_USER_AGENT']) && preg_match('/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'])) {
287 287
         echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>";
288 288
     }
289 289
 }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
  */
300 300
 function geodir_add_async_forscript($url)
301 301
 {
302
-    if (strpos($url, '#asyncload')===false)
302
+    if (strpos($url, '#asyncload') === false)
303 303
         return $url;
304 304
     else if (is_admin())
305 305
         return str_replace('#asyncload', '', $url);
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 function geodir_templates_styles()
318 318
 {
319 319
 
320
-    wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
320
+    wp_register_style('geodir-core-scss', geodir_plugin_url().'/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
321 321
     wp_enqueue_style('geodir-core-scss');
322
-    wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION);
322
+    wp_register_style('geodir-core-scss-footer', geodir_plugin_url().'/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION);
323 323
 
324
-    if(is_rtl()){
325
-    wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
324
+    if (is_rtl()) {
325
+    wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url().'/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
326 326
     wp_enqueue_style('geodirectory-frontend-rtl-style');
327 327
     }
328 328
 
@@ -396,18 +396,18 @@  discard block
 block discarded – undo
396 396
                 $term_id = get_queried_object_id();
397 397
                 $taxonomy = get_query_var('taxonomy');
398 398
 
399
-                if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) {
400
-                    $term = get_term($term_id, $post_type . 'category');
399
+                if ($term_id && $post_type && get_query_var('taxonomy') == $post_type.'category') {
400
+                    $term = get_term($term_id, $post_type.'category');
401 401
                 }
402 402
             }
403 403
             
404
-            if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) {
405
-                $taxonomy_search = $_REQUEST['s' . $post_type . 'category'];
404
+            if (geodir_is_page('search') && !empty($_REQUEST['s'.$post_type.'category'])) {
405
+                $taxonomy_search = $_REQUEST['s'.$post_type.'category'];
406 406
                 
407 407
                 if (!is_array($taxonomy_search)) {
408
-                    $term = get_term((int)$taxonomy_search, $post_type . 'category');
409
-                } else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search
410
-                    $term = get_term((int)$taxonomy_search[0], $post_type . 'category');
408
+                    $term = get_term((int) $taxonomy_search, $post_type.'category');
409
+                } else if (is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search
410
+                    $term = get_term((int) $taxonomy_search[0], $post_type.'category');
411 411
                 }
412 412
             }
413 413
             
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
         if ($max_page > 1 || $always_show) {            
420 420
             // Extra pagination info
421 421
             $geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
422
-            $start_no = ( $paged - 1 ) * $posts_per_page + 1;
422
+            $start_no = ($paged - 1) * $posts_per_page + 1;
423 423
             $end_no = min($paged * $posts_per_page, $numposts);
424 424
 
425 425
             if ($geodir_pagination_more_info != '') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
                 } else {
430 430
                     $pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts);
431 431
                 }
432
-                $pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>';
432
+                $pagination_info = '<div class="gd-pagination-details">'.$pegination_desc.'</div>';
433 433
                 /**
434 434
                  * Adds an extra pagination info above/under pagination.
435 435
                  *
@@ -445,15 +445,15 @@  discard block
 block discarded – undo
445 445
                 $pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type);
446 446
                 
447 447
                 if ($geodir_pagination_more_info == 'before') {
448
-                    $before = $before . $pagination_info;
448
+                    $before = $before.$pagination_info;
449 449
                 } else if ($geodir_pagination_more_info == 'after') {
450
-                    $after = $pagination_info . $after;
450
+                    $after = $pagination_info.$after;
451 451
                 }
452 452
             }
453 453
             
454 454
             echo "$before <div class='Navi gd-navi'>";
455 455
             if ($paged >= ($pages_to_show - 1)) {
456
-                echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link()) . '">&laquo;</a>';
456
+                echo '<a href="'.str_replace('&paged', '&amp;paged', get_pagenum_link()).'">&laquo;</a>';
457 457
             }
458 458
             previous_posts_link($prelabel);
459 459
             for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
@@ -461,13 +461,13 @@  discard block
 block discarded – undo
461 461
                     if ($i == $paged) {
462 462
                         echo "<strong class='on'>$i</strong>";
463 463
                     } else {
464
-                        echo ' <a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($i)) . '">' . $i . '</a> ';
464
+                        echo ' <a href="'.str_replace('&paged', '&amp;paged', get_pagenum_link($i)).'">'.$i.'</a> ';
465 465
                     }
466 466
                 }
467 467
             }
468 468
             next_posts_link($nxtlabel, $max_page);
469 469
             if (($paged + $half_pages_to_show) < ($max_page)) {
470
-                echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($max_page)) . '">&raquo;</a>';
470
+                echo '<a href="'.str_replace('&paged', '&amp;paged', get_pagenum_link($max_page)).'">&raquo;</a>';
471 471
             }
472 472
             echo "</div> $after";
473 473
         }
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
         jQuery(function ($) {
506 506
             $("#distance_slider").slider({
507 507
                 range: true,
508
-                values: [0, <?php echo ($_REQUEST['sdist']!='') ? sanitize_text_field($_REQUEST['sdist']) : "0"; ?>],
508
+                values: [0, <?php echo ($_REQUEST['sdist'] != '') ? sanitize_text_field($_REQUEST['sdist']) : "0"; ?>],
509 509
                 min: 0,
510 510
                 max: <?php echo $dist; ?>,
511 511
                 step: <?php echo $dist_dif; ?>,
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
     $city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : '';
573 573
     ?>
574 574
     <script type="text/javascript">
575
-        var default_location = '<?php echo $city ;?>';
575
+        var default_location = '<?php echo $city; ?>';
576 576
         var latlng;
577 577
         var address;
578 578
         var dist = 0;
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 				var $form = jQuery(this).closest('form');
589 589
 
590 590
 				if (jQuery("#sdist input[type='radio']:checked").length != 0) dist = jQuery("#sdist input[type='radio']:checked").val();
591
-				if (jQuery('.search_text', $form).val() == '' || jQuery('.search_text', $form).val() == '<?php echo $default_search_for_text;?>') jQuery('.search_text', $form).val(s);
591
+				if (jQuery('.search_text', $form).val() == '' || jQuery('.search_text', $form).val() == '<?php echo $default_search_for_text; ?>') jQuery('.search_text', $form).val(s);
592 592
 				
593 593
 				// Disable location based search for disabled location post type.
594 594
 				if (jQuery('.search_by_post', $form).val() != '' && typeof gd_cpt_no_location == 'function') {
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 					}
603 603
 				}
604 604
 				
605
-				if (dist > 0 || (jQuery('select[name="sort_by"]').val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest') || (jQuery(".snear", $form).val() != '' && jQuery(".snear", $form).val() != '<?php echo $default_near_text;?>')) {
605
+				if (dist > 0 || (jQuery('select[name="sort_by"]').val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest') || (jQuery(".snear", $form).val() != '' && jQuery(".snear", $form).val() != '<?php echo $default_near_text; ?>')) {
606 606
 					geodir_setsearch($form);
607 607
 				} else {
608 608
 					jQuery(".snear", $form).val('');
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
         });
621 621
         
622 622
 		function geodir_setsearch($form) {
623
-			if ((dist > 0 || (jQuery('select[name="sort_by"]', $form).val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest')) && (jQuery(".snear", $form).val() == '' || jQuery(".snear", $form).val() == '<?php echo $default_near_text;?>')) jQuery(".snear", $form).val(default_location);
623
+			if ((dist > 0 || (jQuery('select[name="sort_by"]', $form).val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest')) && (jQuery(".snear", $form).val() == '' || jQuery(".snear", $form).val() == '<?php echo $default_near_text; ?>')) jQuery(".snear", $form).val(default_location);
624 624
 			geocodeAddress($form);
625 625
 		}
626 626
 
@@ -639,15 +639,15 @@  discard block
 block discarded – undo
639 639
             // Call the geocode function
640 640
             Sgeocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null;
641 641
 
642
-            if (jQuery('.snear', $form).val() == '' || ( jQuery('.sgeo_lat').val() != '' && jQuery('.sgeo_lon').val() != ''  ) || jQuery('.snear', $form).val().match("^<?php _e('In:','geodirectory');?>")) {
643
-                if (jQuery('.snear', $form).val().match("^<?php _e('In:','geodirectory');?>")) {
642
+            if (jQuery('.snear', $form).val() == '' || ( jQuery('.sgeo_lat').val() != '' && jQuery('.sgeo_lon').val() != ''  ) || jQuery('.snear', $form).val().match("^<?php _e('In:', 'geodirectory'); ?>")) {
643
+                if (jQuery('.snear', $form).val().match("^<?php _e('In:', 'geodirectory'); ?>")) {
644 644
                     jQuery(".snear", $form).val('');
645 645
                 }
646 646
                 jQuery($form).submit();
647 647
             } else {
648 648
                 var address = jQuery(".snear", $form).val();
649 649
 
650
-                if (jQuery('.snear', $form).val() == '<?php echo $default_near_text;?>') {
650
+                if (jQuery('.snear', $form).val() == '<?php echo $default_near_text; ?>') {
651 651
                     initialise2();
652 652
                 } else {
653 653
                     <?php
@@ -660,12 +660,12 @@  discard block
 block discarded – undo
660 660
                     $near_add2 = apply_filters('geodir_search_near_addition', '');
661 661
                     ?>
662 662
                     if (window.gdMaps === 'google') {
663
-                        Sgeocoder.geocode({'address': address<?php echo ($near_add ? '+", ' . $near_add . '"' : '') . $near_add2;?>},
663
+                        Sgeocoder.geocode({'address': address<?php echo ($near_add ? '+", '.$near_add.'"' : '').$near_add2; ?>},
664 664
                             function (results, status) {
665 665
                                 if (status == google.maps.GeocoderStatus.OK) {
666 666
                                     updateSearchPosition(results[0].geometry.location, $form);
667 667
                                 } else {
668
-                                    alert("<?php esc_attr_e('Search was not successful for the following reason :', 'geodirectory');?>" + status);
668
+                                    alert("<?php esc_attr_e('Search was not successful for the following reason :', 'geodirectory'); ?>" + status);
669 669
                                 }
670 670
                             });
671 671
                     } else if (window.gdMaps === 'osm') {
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
                                 if (typeof geo !== 'undefined' && geo.lat && geo.lon) {
675 675
                                     updateSearchPosition(geo, $form);
676 676
                                 } else {
677
-                                    alert("<?php esc_attr_e('Search was not successful for the requested address.', 'geodirectory');?>");
677
+                                    alert("<?php esc_attr_e('Search was not successful for the requested address.', 'geodirectory'); ?>");
678 678
                                 }
679 679
                             });
680 680
                     } else {
@@ -720,19 +720,19 @@  discard block
 block discarded – undo
720 720
             var msg;
721 721
             switch (err.code) {
722 722
                 case err.UNKNOWN_ERROR:
723
-                    msg = "<?php _e('Unable to find your location','geodirectory');?>";
723
+                    msg = "<?php _e('Unable to find your location', 'geodirectory'); ?>";
724 724
                     break;
725 725
                 case err.PERMISSION_DENINED:
726
-                    msg = "<?php _e('Permission denied in finding your location','geodirectory');?>";
726
+                    msg = "<?php _e('Permission denied in finding your location', 'geodirectory'); ?>";
727 727
                     break;
728 728
                 case err.POSITION_UNAVAILABLE:
729
-                    msg = "<?php _e('Your location is currently unknown','geodirectory');?>";
729
+                    msg = "<?php _e('Your location is currently unknown', 'geodirectory'); ?>";
730 730
                     break;
731 731
                 case err.BREAK:
732
-                    msg = "<?php _e('Attempt to find location took too long','geodirectory');?>";
732
+                    msg = "<?php _e('Attempt to find location took too long', 'geodirectory'); ?>";
733 733
                     break;
734 734
                 default:
735
-                    msg = "<?php _e('Location detection not supported in browser','geodirectory');?>";
735
+                    msg = "<?php _e('Location detection not supported in browser', 'geodirectory'); ?>";
736 736
             }
737 737
             jQuery('#info').html(msg);
738 738
         }
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
              * @param object $post The post object.
783 783
              * @param string $link The link to the post.
784 784
              */
785
-            $return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img">&nbsp;</span></a>',$post,$link);
785
+            $return = apply_filters('geodir_featured_badge_on_image', '<a href="'.$link.'"><span class="geodir_featured_img">&nbsp;</span></a>', $post, $link);
786 786
             break;
787 787
         case 'new' :
788 788
             /**
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
              * @param object $post The post object.
793 793
              * @param string $link The link to the post.
794 794
              */
795
-            $return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing">&nbsp;</span></a>',$post,$link);
795
+            $return = apply_filters('geodir_new_badge_on_image', '<a href="'.$link.'"><span class="geodir_new_listing">&nbsp;</span></a>', $post, $link);
796 796
             break;
797 797
 
798 798
     }
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
  * @since 1.6.22
807 807
  */
808 808
 function geodir_fix_script_conflict() {
809
-    if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) {
810
-        wp_dequeue_script( 'flexslider' );
809
+    if (wp_script_is('flexslider', 'enqueued') && wp_script_is('geodirectory-jquery-flexslider-js', 'enqueued')) {
810
+        wp_dequeue_script('flexslider');
811 811
     }
812 812
 }
813
-add_action( 'wp_enqueue_scripts', 'geodir_fix_script_conflict', 100 );
814 813
\ No newline at end of file
814
+add_action('wp_enqueue_scripts', 'geodir_fix_script_conflict', 100);
815 815
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +344 added lines, -344 removed lines patch added patch discarded remove patch
@@ -36,175 +36,175 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function geodir_templates_scripts()
38 38
 {
39
-    $is_detail_page = false;
40
-    $geodir_map_name = geodir_map_name();
39
+	$is_detail_page = false;
40
+	$geodir_map_name = geodir_map_name();
41 41
 
42
-    if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) {
43
-        $is_detail_page = true;
44
-    }
45
-
46
-    wp_enqueue_script('jquery');
47
-
48
-    wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION);
49
-    wp_enqueue_script('geodirectory-script');
50
-
51
-    $geodir_vars_data = array(
52
-        'siteurl' => get_option('siteurl'),
53
-        'geodir_plugin_url' => geodir_plugin_url(),
54
-        'geodir_lazy_load' => get_option('geodir_lazy_load',1),
55
-        'geodir_ajax_url' => geodir_get_ajax_url(),
56
-        'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'),
57
-        'is_rtl' => is_rtl() ? 1 : 0 // fix rtl issue
58
-    );
59
-
60
-    /**
61
-     * Filter the `geodir_var` data array that outputs the  wp_localize_script() translations and variables.
62
-     *
63
-     * This is used by addons to add JS translatable variables.
64
-     *
65
-     * @since 1.4.4
66
-     * @param array $geodir_vars_data {
67
-     *    geodir var data used by addons to add JS translatable variables.
68
-     *
69
-     *    @type string $siteurl Site url.
70
-     *    @type string $geodir_plugin_url Geodirectory core plugin url.
71
-     *    @type string $geodir_ajax_url Geodirectory plugin ajax url.
72
-     *    @type int $geodir_gd_modal Disable GD modal that displays slideshow images in popup?.
73
-     *    @type int $is_rtl Checks if current locale is RTL.
74
-     *
75
-     * }
76
-     */
77
-    $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data);
78
-
79
-    wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data);
80
-
81
-    wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true);
82
-    if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');}
83
-
84
-    wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true);
85
-    wp_enqueue_script('geodirectory-lightbox-jquery');
42
+	if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) {
43
+		$is_detail_page = true;
44
+	}
86 45
 
87
-    wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true);
88
-    if ($is_detail_page) {
89
-        wp_enqueue_script('geodirectory-jquery-simplemodal');
90
-    }
46
+	wp_enqueue_script('jquery');
47
+
48
+	wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION);
49
+	wp_enqueue_script('geodirectory-script');
50
+
51
+	$geodir_vars_data = array(
52
+		'siteurl' => get_option('siteurl'),
53
+		'geodir_plugin_url' => geodir_plugin_url(),
54
+		'geodir_lazy_load' => get_option('geodir_lazy_load',1),
55
+		'geodir_ajax_url' => geodir_get_ajax_url(),
56
+		'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'),
57
+		'is_rtl' => is_rtl() ? 1 : 0 // fix rtl issue
58
+	);
59
+
60
+	/**
61
+	 * Filter the `geodir_var` data array that outputs the  wp_localize_script() translations and variables.
62
+	 *
63
+	 * This is used by addons to add JS translatable variables.
64
+	 *
65
+	 * @since 1.4.4
66
+	 * @param array $geodir_vars_data {
67
+	 *    geodir var data used by addons to add JS translatable variables.
68
+	 *
69
+	 *    @type string $siteurl Site url.
70
+	 *    @type string $geodir_plugin_url Geodirectory core plugin url.
71
+	 *    @type string $geodir_ajax_url Geodirectory plugin ajax url.
72
+	 *    @type int $geodir_gd_modal Disable GD modal that displays slideshow images in popup?.
73
+	 *    @type int $is_rtl Checks if current locale is RTL.
74
+	 *
75
+	 * }
76
+	 */
77
+	$geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data);
78
+
79
+	wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data);
80
+
81
+	wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true);
82
+	if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');}
83
+
84
+	wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true);
85
+	wp_enqueue_script('geodirectory-lightbox-jquery');
86
+
87
+	wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true);
88
+	if ($is_detail_page) {
89
+		wp_enqueue_script('geodirectory-jquery-simplemodal');
90
+	}
91 91
 
92
-    if (in_array($geodir_map_name, array('auto', 'google'))) {
93
-        $map_lang = "&language=" . geodir_get_map_default_language();
94
-        $map_key = "&key=" . geodir_get_map_api_key();
95
-        /**
96
-         * Filter the variables that are added to the end of the google maps script call.
97
-         *
98
-         * This i used to change things like google maps language etc.
99
-         *
100
-         * @since 1.0.0
101
-         * @param string $var The string to filter, default is empty string.
102
-         */
103
-        $map_extra = apply_filters('geodir_googlemap_script_extra', '');
104
-        wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL);
92
+	if (in_array($geodir_map_name, array('auto', 'google'))) {
93
+		$map_lang = "&language=" . geodir_get_map_default_language();
94
+		$map_key = "&key=" . geodir_get_map_api_key();
95
+		/**
96
+		 * Filter the variables that are added to the end of the google maps script call.
97
+		 *
98
+		 * This i used to change things like google maps language etc.
99
+		 *
100
+		 * @since 1.0.0
101
+		 * @param string $var The string to filter, default is empty string.
102
+		 */
103
+		$map_extra = apply_filters('geodir_googlemap_script_extra', '');
104
+		wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL);
105 105
         
106
-        // Overlapping Marker Spiderfier
107
-        wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
108
-        wp_enqueue_script('geodirectory-g-overlappingmarker-script');
109
-    }
106
+		// Overlapping Marker Spiderfier
107
+		wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
108
+		wp_enqueue_script('geodirectory-g-overlappingmarker-script');
109
+	}
110 110
     
111
-    if ($geodir_map_name == 'osm') {
112
-        // Leaflet OpenStreetMap
113
-        wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
114
-        wp_enqueue_style('geodirectory-leaflet-style');
111
+	if ($geodir_map_name == 'osm') {
112
+		// Leaflet OpenStreetMap
113
+		wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
114
+		wp_enqueue_style('geodirectory-leaflet-style');
115 115
             
116
-        wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
117
-        wp_enqueue_script('geodirectory-leaflet-script');
116
+		wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
117
+		wp_enqueue_script('geodirectory-leaflet-script');
118 118
         
119
-        wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION);
120
-        wp_enqueue_script('geodirectory-leaflet-geo-script');
119
+		wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION);
120
+		wp_enqueue_script('geodirectory-leaflet-geo-script');
121 121
         
122
-        if ($is_detail_page) {
123
-            wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION);
124
-            wp_enqueue_style('geodirectory-leaflet-routing-style');
122
+		if ($is_detail_page) {
123
+			wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION);
124
+			wp_enqueue_style('geodirectory-leaflet-routing-style');
125 125
                 
126
-            wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION);
127
-            wp_enqueue_script('geodirectory-leaflet-routing-script');
128
-        }
126
+			wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION);
127
+			wp_enqueue_script('geodirectory-leaflet-routing-script');
128
+		}
129 129
         
130
-        // Overlapping Marker Spiderfier Leaflet
131
-        wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
132
-        wp_enqueue_script('geodirectory-o-overlappingmarker-script');
133
-    }
134
-    wp_enqueue_script( 'jquery-ui-autocomplete' );
130
+		// Overlapping Marker Spiderfier Leaflet
131
+		wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
132
+		wp_enqueue_script('geodirectory-o-overlappingmarker-script');
133
+	}
134
+	wp_enqueue_script( 'jquery-ui-autocomplete' );
135 135
     
136
-    wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
137
-    wp_enqueue_script('geodirectory-goMap-script');
138
-
139
-    wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION);
140
-    wp_enqueue_script('chosen');
141
-
142
-    wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION);
143
-    wp_enqueue_script('geodirectory-choose-ajax');
144
-
145
-    wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true);
146
-
147
-    if (is_page() && geodir_is_page('add-listing')) {
148
-        // SCRIPT FOR UPLOAD
149
-        wp_enqueue_script('plupload-all');
150
-        wp_enqueue_script('jquery-ui-sortable');
151
-
152
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true);
153
-        wp_enqueue_script('geodirectory-plupload-script');
154
-        // SCRIPT FOR UPLOAD END
155
-
156
-        // check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls
157
-        if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
158
-            $ajax_url = admin_url('admin-ajax.php');
159
-        } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
160
-            $ajax_url = admin_url('admin-ajax.php');
161
-        } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
162
-            $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
163
-        } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
164
-            $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
165
-        } else {
166
-            $ajax_url = admin_url('admin-ajax.php');
167
-        }
136
+	wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
137
+	wp_enqueue_script('geodirectory-goMap-script');
138
+
139
+	wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION);
140
+	wp_enqueue_script('chosen');
141
+
142
+	wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION);
143
+	wp_enqueue_script('geodirectory-choose-ajax');
144
+
145
+	wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true);
146
+
147
+	if (is_page() && geodir_is_page('add-listing')) {
148
+		// SCRIPT FOR UPLOAD
149
+		wp_enqueue_script('plupload-all');
150
+		wp_enqueue_script('jquery-ui-sortable');
151
+
152
+		wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true);
153
+		wp_enqueue_script('geodirectory-plupload-script');
154
+		// SCRIPT FOR UPLOAD END
155
+
156
+		// check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls
157
+		if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
158
+			$ajax_url = admin_url('admin-ajax.php');
159
+		} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
160
+			$ajax_url = admin_url('admin-ajax.php');
161
+		} elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
162
+			$ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
163
+		} elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
164
+			$ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
165
+		} else {
166
+			$ajax_url = admin_url('admin-ajax.php');
167
+		}
168 168
 
169
-        // place js config array for plupload
170
-        $plupload_init = array(
171
-            'runtimes' => 'html5,silverlight,browserplus,gears,html4',
172
-            'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
173
-            'container' => 'plupload-upload-ui', // will be adjusted per uploader
174
-            'drop_element' => 'dropbox', // will be adjusted per uploader
175
-            'file_data_name' => 'async-upload', // will be adjusted per uploader
176
-            'multiple_queues' => true,
177
-            'max_file_size' => geodir_max_upload_size(),
178
-            'url' => $ajax_url,
179
-            'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
180
-            'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
181
-            'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
182
-            'multipart' => true,
183
-            'urlstream_upload' => true,
184
-            'multi_selection' => false, // will be added per uploader
185
-            // additional post data to send to our ajax hook
186
-            'multipart_params' => array(
187
-                '_ajax_nonce' => "", // will be added per uploader
188
-                'action' => 'plupload_action', // the ajax action name
189
-                'imgid' => 0 // will be added per uploader
190
-            )
191
-        );
192
-        $base_plupload_config = json_encode($plupload_init);
193
-
194
-        $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
195
-            'upload_img_size' => geodir_max_upload_size());
196
-
197
-        wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
198
-
199
-        wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload');
200
-    } // End if for add place page
201
-
202
-    wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
203
-    if ($is_detail_page) {
169
+		// place js config array for plupload
170
+		$plupload_init = array(
171
+			'runtimes' => 'html5,silverlight,browserplus,gears,html4',
172
+			'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
173
+			'container' => 'plupload-upload-ui', // will be adjusted per uploader
174
+			'drop_element' => 'dropbox', // will be adjusted per uploader
175
+			'file_data_name' => 'async-upload', // will be adjusted per uploader
176
+			'multiple_queues' => true,
177
+			'max_file_size' => geodir_max_upload_size(),
178
+			'url' => $ajax_url,
179
+			'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
180
+			'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
181
+			'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
182
+			'multipart' => true,
183
+			'urlstream_upload' => true,
184
+			'multi_selection' => false, // will be added per uploader
185
+			// additional post data to send to our ajax hook
186
+			'multipart_params' => array(
187
+				'_ajax_nonce' => "", // will be added per uploader
188
+				'action' => 'plupload_action', // the ajax action name
189
+				'imgid' => 0 // will be added per uploader
190
+			)
191
+		);
192
+		$base_plupload_config = json_encode($plupload_init);
193
+
194
+		$gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
195
+			'upload_img_size' => geodir_max_upload_size());
196
+
197
+		wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
198
+
199
+		wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload');
200
+	} // End if for add place page
201
+
202
+	wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
203
+	if ($is_detail_page) {
204 204
 		wp_enqueue_script('geodirectory-post-custom-js');
205 205
 	}
206 206
 
207
-    // font awesome rating script
207
+	// font awesome rating script
208 208
 	if (get_option('geodir_reviewrating_enable_font_awesome')) {
209 209
 		wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true);
210 210
 		wp_enqueue_script('geodir-barrating-js');
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 		wp_enqueue_script('geodir-jRating-js');
214 214
 	}
215 215
 
216
-    wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
217
-    wp_enqueue_script('geodir-on-document-load');
216
+	wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
217
+	wp_enqueue_script('geodir-on-document-load');
218 218
 
219
-    wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
220
-    wp_enqueue_script('google-geometa');
219
+	wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
220
+	wp_enqueue_script('google-geometa');
221 221
 }
222 222
 
223 223
 /**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
  */
232 232
 function geodir_header_scripts()
233 233
 {
234
-    echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>';
235
-    echo stripslashes(get_option('geodir_header_scripts'));
234
+	echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>';
235
+	echo stripslashes(get_option('geodir_header_scripts'));
236 236
 }
237 237
 
238 238
 /**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
  */
246 246
 function geodir_google_analytics_tracking_code()
247 247
 {
248
-    if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?>
248
+	if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?>
249 249
 
250 250
         <script>
251 251
             (function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
         </script>
261 261
 
262 262
         <?php
263
-    }elseif(get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
264
-        echo stripslashes(get_option('geodir_ga_tracking_code'));
265
-    }
263
+	}elseif(get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
264
+		echo stripslashes(get_option('geodir_ga_tracking_code'));
265
+	}
266 266
 }
267 267
 
268 268
 /**
@@ -276,16 +276,16 @@  discard block
 block discarded – undo
276 276
 function geodir_footer_scripts()
277 277
 {
278 278
 
279
-    echo stripslashes(get_option('geodir_footer_scripts'));
279
+	echo stripslashes(get_option('geodir_footer_scripts'));
280 280
 
281
-    /*
281
+	/*
282 282
      * Apple suck and can't/won't fix bugs: https://bugs.webkit.org/show_bug.cgi?id=136041
283 283
      *
284 284
      * Flexbox wont wrap on ios for search form items
285 285
      */
286
-    if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) {
287
-        echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>";
288
-    }
286
+	if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) {
287
+		echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>";
288
+	}
289 289
 }
290 290
 
291 291
 
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
  */
300 300
 function geodir_add_async_forscript($url)
301 301
 {
302
-    if (strpos($url, '#asyncload')===false)
303
-        return $url;
304
-    else if (is_admin())
305
-        return str_replace('#asyncload', '', $url);
306
-    else
307
-        return str_replace('#asyncload', '', $url)."' async='async";
302
+	if (strpos($url, '#asyncload')===false)
303
+		return $url;
304
+	else if (is_admin())
305
+		return str_replace('#asyncload', '', $url);
306
+	else
307
+		return str_replace('#asyncload', '', $url)."' async='async";
308 308
 }
309 309
 add_filter('clean_url', 'geodir_add_async_forscript', 11, 1);
310 310
 
@@ -317,17 +317,17 @@  discard block
 block discarded – undo
317 317
 function geodir_templates_styles()
318 318
 {
319 319
 
320
-    wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
321
-    wp_enqueue_style('geodir-core-scss');
322
-    wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION);
320
+	wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
321
+	wp_enqueue_style('geodir-core-scss');
322
+	wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION);
323 323
 
324
-    if(is_rtl()){
325
-    wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
326
-    wp_enqueue_style('geodirectory-frontend-rtl-style');
327
-    }
324
+	if(is_rtl()){
325
+	wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
326
+	wp_enqueue_style('geodirectory-frontend-rtl-style');
327
+	}
328 328
 
329
-    wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
330
-    wp_enqueue_style('font-awesome');
329
+	wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
330
+	wp_enqueue_style('font-awesome');
331 331
 
332 332
 
333 333
 }
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
  */
342 342
 function geodir_get_sidebar()
343 343
 {
344
-    get_sidebar('geodirectory');
344
+	get_sidebar('geodirectory');
345 345
 }
346 346
 
347 347
 /**
@@ -360,122 +360,122 @@  discard block
 block discarded – undo
360 360
  * @param bool $always_show Do you want to show the pagination always? Default: false.
361 361
  */
362 362
 function geodir_pagination($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
363
-    global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id;
363
+	global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id;
364 364
 
365
-    if (empty($prelabel)) {
366
-        $prelabel = '<strong>&lt;</strong>';
367
-    }
365
+	if (empty($prelabel)) {
366
+		$prelabel = '<strong>&lt;</strong>';
367
+	}
368 368
 
369
-    if (empty($nxtlabel)) {
370
-        $nxtlabel = '<strong>&gt;</strong>';
371
-    }
369
+	if (empty($nxtlabel)) {
370
+		$nxtlabel = '<strong>&gt;</strong>';
371
+	}
372 372
 
373
-    $half_pages_to_show = round($pages_to_show / 2);
373
+	$half_pages_to_show = round($pages_to_show / 2);
374 374
 
375
-    if (geodir_is_page('home')) // dont apply default  pagination for geodirectory home page.
376
-        return;
375
+	if (geodir_is_page('home')) // dont apply default  pagination for geodirectory home page.
376
+		return;
377 377
 
378
-    if (!is_single()) {
379
-        if (function_exists('geodir_location_geo_home_link')) {
380
-            remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
381
-        }
382
-        $numposts = $wp_query->found_posts;
378
+	if (!is_single()) {
379
+		if (function_exists('geodir_location_geo_home_link')) {
380
+			remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
381
+		}
382
+		$numposts = $wp_query->found_posts;
383 383
 
384
-        $max_page = ceil($numposts / $posts_per_page);
384
+		$max_page = ceil($numposts / $posts_per_page);
385 385
 
386
-        if (empty($paged)) {
387
-            $paged = 1;
388
-        }
386
+		if (empty($paged)) {
387
+			$paged = 1;
388
+		}
389 389
         
390
-        $post_type = geodir_get_current_posttype();
391
-        $listing_type_name = get_post_type_plural_label($post_type);
392
-        if (geodir_is_page('listing') || geodir_is_page('search')) {            
393
-            $term = array();
390
+		$post_type = geodir_get_current_posttype();
391
+		$listing_type_name = get_post_type_plural_label($post_type);
392
+		if (geodir_is_page('listing') || geodir_is_page('search')) {            
393
+			$term = array();
394 394
             
395
-            if (is_tax()) {
396
-                $term_id = get_queried_object_id();
397
-                $taxonomy = get_query_var('taxonomy');
395
+			if (is_tax()) {
396
+				$term_id = get_queried_object_id();
397
+				$taxonomy = get_query_var('taxonomy');
398 398
 
399
-                if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) {
400
-                    $term = get_term($term_id, $post_type . 'category');
401
-                }
402
-            }
399
+				if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) {
400
+					$term = get_term($term_id, $post_type . 'category');
401
+				}
402
+			}
403 403
             
404
-            if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) {
405
-                $taxonomy_search = $_REQUEST['s' . $post_type . 'category'];
404
+			if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) {
405
+				$taxonomy_search = $_REQUEST['s' . $post_type . 'category'];
406 406
                 
407
-                if (!is_array($taxonomy_search)) {
408
-                    $term = get_term((int)$taxonomy_search, $post_type . 'category');
409
-                } else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search
410
-                    $term = get_term((int)$taxonomy_search[0], $post_type . 'category');
411
-                }
412
-            }
407
+				if (!is_array($taxonomy_search)) {
408
+					$term = get_term((int)$taxonomy_search, $post_type . 'category');
409
+				} else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search
410
+					$term = get_term((int)$taxonomy_search[0], $post_type . 'category');
411
+				}
412
+			}
413 413
             
414
-            if (!empty($term) && !is_wp_error($term)) {
415
-                $listing_type_name = $term->name;
416
-            }
417
-        }
414
+			if (!empty($term) && !is_wp_error($term)) {
415
+				$listing_type_name = $term->name;
416
+			}
417
+		}
418 418
 
419
-        if ($max_page > 1 || $always_show) {            
420
-            // Extra pagination info
421
-            $geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
422
-            $start_no = ( $paged - 1 ) * $posts_per_page + 1;
423
-            $end_no = min($paged * $posts_per_page, $numposts);
419
+		if ($max_page > 1 || $always_show) {            
420
+			// Extra pagination info
421
+			$geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
422
+			$start_no = ( $paged - 1 ) * $posts_per_page + 1;
423
+			$end_no = min($paged * $posts_per_page, $numposts);
424 424
 
425
-            if ($geodir_pagination_more_info != '') {
426
-                if ($listing_type_name) {
427
-                    $listing_type_name = __($listing_type_name, 'geodirectory');
428
-                    $pegination_desc = wp_sprintf(__('Showing %s %d-%d of %d', 'geodirectory'), $listing_type_name, $start_no, $end_no, $numposts);
429
-                } else {
430
-                    $pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts);
431
-                }
432
-                $pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>';
433
-                /**
434
-                 * Adds an extra pagination info above/under pagination.
435
-                 *
436
-                 * @since 1.5.9
437
-                 *
438
-                 * @param string $pagination_info Extra pagination info content.
439
-                 * @param string $listing_type_name Listing results type.
440
-                 * @param string $start_no First result number.
441
-                 * @param string $end_no Last result number.
442
-                 * @param string $numposts Total number of listings.
443
-                 * @param string $post_type The post type.
444
-                 */
445
-                $pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type);
425
+			if ($geodir_pagination_more_info != '') {
426
+				if ($listing_type_name) {
427
+					$listing_type_name = __($listing_type_name, 'geodirectory');
428
+					$pegination_desc = wp_sprintf(__('Showing %s %d-%d of %d', 'geodirectory'), $listing_type_name, $start_no, $end_no, $numposts);
429
+				} else {
430
+					$pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts);
431
+				}
432
+				$pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>';
433
+				/**
434
+				 * Adds an extra pagination info above/under pagination.
435
+				 *
436
+				 * @since 1.5.9
437
+				 *
438
+				 * @param string $pagination_info Extra pagination info content.
439
+				 * @param string $listing_type_name Listing results type.
440
+				 * @param string $start_no First result number.
441
+				 * @param string $end_no Last result number.
442
+				 * @param string $numposts Total number of listings.
443
+				 * @param string $post_type The post type.
444
+				 */
445
+				$pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type);
446 446
                 
447
-                if ($geodir_pagination_more_info == 'before') {
448
-                    $before = $before . $pagination_info;
449
-                } else if ($geodir_pagination_more_info == 'after') {
450
-                    $after = $pagination_info . $after;
451
-                }
452
-            }
447
+				if ($geodir_pagination_more_info == 'before') {
448
+					$before = $before . $pagination_info;
449
+				} else if ($geodir_pagination_more_info == 'after') {
450
+					$after = $pagination_info . $after;
451
+				}
452
+			}
453 453
             
454
-            echo "$before <div class='Navi gd-navi'>";
455
-            if ($paged >= ($pages_to_show - 1)) {
456
-                echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link()) . '">&laquo;</a>';
457
-            }
458
-            previous_posts_link($prelabel);
459
-            for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
460
-                if ($i >= 1 && $i <= $max_page) {
461
-                    if ($i == $paged) {
462
-                        echo "<strong class='on'>$i</strong>";
463
-                    } else {
464
-                        echo ' <a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($i)) . '">' . $i . '</a> ';
465
-                    }
466
-                }
467
-            }
468
-            next_posts_link($nxtlabel, $max_page);
469
-            if (($paged + $half_pages_to_show) < ($max_page)) {
470
-                echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($max_page)) . '">&raquo;</a>';
471
-            }
472
-            echo "</div> $after";
473
-        }
454
+			echo "$before <div class='Navi gd-navi'>";
455
+			if ($paged >= ($pages_to_show - 1)) {
456
+				echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link()) . '">&laquo;</a>';
457
+			}
458
+			previous_posts_link($prelabel);
459
+			for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
460
+				if ($i >= 1 && $i <= $max_page) {
461
+					if ($i == $paged) {
462
+						echo "<strong class='on'>$i</strong>";
463
+					} else {
464
+						echo ' <a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($i)) . '">' . $i . '</a> ';
465
+					}
466
+				}
467
+			}
468
+			next_posts_link($nxtlabel, $max_page);
469
+			if (($paged + $half_pages_to_show) < ($max_page)) {
470
+				echo '<a href="' . str_replace('&paged', '&amp;paged', get_pagenum_link($max_page)) . '">&raquo;</a>';
471
+			}
472
+			echo "</div> $after";
473
+		}
474 474
         
475
-        if (function_exists('geodir_location_geo_home_link')) {
476
-            add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
477
-        }
478
-    }
475
+		if (function_exists('geodir_location_geo_home_link')) {
476
+			add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
477
+		}
478
+	}
479 479
 }
480 480
 
481 481
 /**
@@ -486,20 +486,20 @@  discard block
 block discarded – undo
486 486
  */
487 487
 function geodir_listingsearch_scripts()
488 488
 {
489
-    if (get_option('gd_search_dist') != '') {
490
-        $dist = get_option('gd_search_dist');
491
-    } else {
492
-        $dist = 500;
493
-    }
494
-    $dist_dif = 1000;
495
-
496
-    if ($dist <= 5000) $dist_dif = 500;
497
-    if ($dist <= 1000) $dist_dif = 100;
498
-    if ($dist <= 500) $dist_dif = 50;
499
-    if ($dist <= 100) $dist_dif = 10;
500
-    if ($dist <= 50) $dist_dif = 5;
501
-
502
-    ?>
489
+	if (get_option('gd_search_dist') != '') {
490
+		$dist = get_option('gd_search_dist');
491
+	} else {
492
+		$dist = 500;
493
+	}
494
+	$dist_dif = 1000;
495
+
496
+	if ($dist <= 5000) $dist_dif = 500;
497
+	if ($dist <= 1000) $dist_dif = 100;
498
+	if ($dist <= 500) $dist_dif = 50;
499
+	if ($dist <= 100) $dist_dif = 10;
500
+	if ($dist <= 50) $dist_dif = 5;
501
+
502
+	?>
503 503
     <script type="text/javascript">
504 504
 
505 505
         jQuery(function ($) {
@@ -557,20 +557,20 @@  discard block
 block discarded – undo
557 557
  * @package GeoDirectory
558 558
  */
559 559
 function geodir_add_sharelocation_scripts() {
560
-    $default_search_for_text = SEARCH_FOR_TEXT;
561
-    if (get_option('geodir_search_field_default_text'))
562
-        $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
560
+	$default_search_for_text = SEARCH_FOR_TEXT;
561
+	if (get_option('geodir_search_field_default_text'))
562
+		$default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
563 563
 
564
-    $default_near_text = NEAR_TEXT;
565
-    if (get_option('geodir_near_field_default_text'))
566
-        $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
564
+	$default_near_text = NEAR_TEXT;
565
+	if (get_option('geodir_near_field_default_text'))
566
+		$default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
567 567
     
568
-    $search_location = geodir_get_default_location();
568
+	$search_location = geodir_get_default_location();
569 569
     
570
-    $default_search_for_text = addslashes(stripslashes($default_search_for_text));
571
-    $default_near_text = addslashes(stripslashes($default_near_text));
572
-    $city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : '';
573
-    ?>
570
+	$default_search_for_text = addslashes(stripslashes($default_search_for_text));
571
+	$default_near_text = addslashes(stripslashes($default_near_text));
572
+	$city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : '';
573
+	?>
574 574
     <script type="text/javascript">
575 575
         var default_location = '<?php echo $city ;?>';
576 576
         var latlng;
@@ -651,14 +651,14 @@  discard block
 block discarded – undo
651 651
                     initialise2();
652 652
                 } else {
653 653
                     <?php
654
-                    $near_add = get_option('geodir_search_near_addition');
655
-                    /**
656
-                     * Adds any extra info to the near search box query when trying to geolocate it via google api.
657
-                     *
658
-                     * @since 1.0.0
659
-                     */
660
-                    $near_add2 = apply_filters('geodir_search_near_addition', '');
661
-                    ?>
654
+					$near_add = get_option('geodir_search_near_addition');
655
+					/**
656
+					 * Adds any extra info to the near search box query when trying to geolocate it via google api.
657
+					 *
658
+					 * @since 1.0.0
659
+					 */
660
+					$near_add2 = apply_filters('geodir_search_near_addition', '');
661
+					?>
662 662
                     if (window.gdMaps === 'google') {
663 663
                         Sgeocoder.geocode({'address': address<?php echo ($near_add ? '+", ' . $near_add . '"' : '') . $near_add2;?>},
664 664
                             function (results, status) {
@@ -772,32 +772,32 @@  discard block
 block discarded – undo
772 772
  */
773 773
 function geodir_show_badges_on_image($which, $post, $link)
774 774
 {
775
-    $return = '';
776
-    switch ($which) {
777
-        case 'featured':
778
-            /**
779
-             * Filter the featured image badge html that appears in the listings pages over the thumbnail.
780
-             *
781
-             * @since 1.0.0
782
-             * @param object $post The post object.
783
-             * @param string $link The link to the post.
784
-             */
785
-            $return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img">&nbsp;</span></a>',$post,$link);
786
-            break;
787
-        case 'new' :
788
-            /**
789
-             * Filter the new image badge html that appears in the listings pages over the thumbnail.
790
-             *
791
-             * @since 1.0.0
792
-             * @param object $post The post object.
793
-             * @param string $link The link to the post.
794
-             */
795
-            $return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing">&nbsp;</span></a>',$post,$link);
796
-            break;
797
-
798
-    }
775
+	$return = '';
776
+	switch ($which) {
777
+		case 'featured':
778
+			/**
779
+			 * Filter the featured image badge html that appears in the listings pages over the thumbnail.
780
+			 *
781
+			 * @since 1.0.0
782
+			 * @param object $post The post object.
783
+			 * @param string $link The link to the post.
784
+			 */
785
+			$return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img">&nbsp;</span></a>',$post,$link);
786
+			break;
787
+		case 'new' :
788
+			/**
789
+			 * Filter the new image badge html that appears in the listings pages over the thumbnail.
790
+			 *
791
+			 * @since 1.0.0
792
+			 * @param object $post The post object.
793
+			 * @param string $link The link to the post.
794
+			 */
795
+			$return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing">&nbsp;</span></a>',$post,$link);
796
+			break;
797
+
798
+	}
799 799
     
800
-    return $return;
800
+	return $return;
801 801
 }
802 802
 
803 803
 /**
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
  * @since 1.6.22
807 807
  */
808 808
 function geodir_fix_script_conflict() {
809
-    if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) {
810
-        wp_dequeue_script( 'flexslider' );
811
-    }
809
+	if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) {
810
+		wp_dequeue_script( 'flexslider' );
811
+	}
812 812
 }
813 813
 add_action( 'wp_enqueue_scripts', 'geodir_fix_script_conflict', 100 );
814 814
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/location_functions.php 4 patches
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  *
37 37
  * @since 1.0.0
38 38
  * @package GeoDirectory
39
- * @return object
39
+ * @return string
40 40
  */
41 41
 function geodir_get_default_location()
42 42
 {
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
  * @package GeoDirectory
277 277
  * @param int $min The minimum number. Default: 0.
278 278
  * @param int $max The maximum number. Default: 1.
279
- * @return float
279
+ * @return integer
280 280
  */
281 281
 function geodir_random_float($min = 0, $max = 1)
282 282
 {
@@ -594,6 +594,9 @@  discard block
 block discarded – undo
594 594
 add_filter('geodir_replace_location_variables', 'geodir_replace_location_variables');
595 595
 
596 596
 
597
+/**
598
+ * @param string $sep
599
+ */
597 600
 function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = ''){
598 601
 
599 602
     global $wp;
Please login to merge, or discard this patch.
Braces   +31 added lines, -22 removed lines patch added patch discarded remove patch
@@ -61,11 +61,12 @@  discard block
 block discarded – undo
61 61
 function geodir_is_default_location_set()
62 62
 {
63 63
     $default_location = geodir_get_default_location();
64
-    if (!empty($default_location))
65
-        return true;
66
-    else
67
-        return false;
68
-}
64
+    if (!empty($default_location)) {
65
+            return true;
66
+    } else {
67
+            return false;
68
+    }
69
+    }
69 70
 
70 71
 /**
71 72
  * Returns location slug using location string.
@@ -259,8 +260,9 @@  discard block
 block discarded – undo
259 260
         }
260 261
         */
261 262
 
262
-        if ($geodir_location->is_default)
263
-            update_option('geodir_default_location', $geodir_location);
263
+        if ($geodir_location->is_default) {
264
+                    update_option('geodir_default_location', $geodir_location);
265
+        }
264 266
 
265 267
         return $geodir_location->location_id;
266 268
 
@@ -308,9 +310,10 @@  discard block
 block discarded – undo
308 310
     $status = $data->status;
309 311
     if ($status == "OK") {
310 312
         return $data->results[0]->address_components;
311
-    } else
312
-        return false;
313
-}
313
+    } else {
314
+            return false;
315
+    }
316
+    }
314 317
 
315 318
 /**
316 319
  * Returns current location terms.
@@ -334,16 +337,19 @@  discard block
 block discarded – undo
334 337
         }
335 338
 
336 339
         $country = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : $gd_session->get('gd_country');
337
-        if ($country != '' && $country)
338
-            $location_array['gd_country'] = urldecode($country);
340
+        if ($country != '' && $country) {
341
+                    $location_array['gd_country'] = urldecode($country);
342
+        }
339 343
 
340 344
         $region = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : $gd_session->get('gd_region');
341
-        if ($region != '' && $region)
342
-            $location_array['gd_region'] = urldecode($region);
345
+        if ($region != '' && $region) {
346
+                    $location_array['gd_region'] = urldecode($region);
347
+        }
343 348
 
344 349
         $city = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : $gd_session->get('gd_city');
345
-        if ($city != '' && $city)
346
-            $location_array['gd_city'] = urldecode($city);
350
+        if ($city != '' && $city) {
351
+                    $location_array['gd_city'] = urldecode($city);
352
+        }
347 353
     } else {
348 354
         if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) {
349 355
             return $location_array;
@@ -355,14 +361,17 @@  discard block
 block discarded – undo
355 361
 
356 362
         $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
357 363
 
358
-        if ($country != '')
359
-            $location_array['gd_country'] = urldecode($country);
364
+        if ($country != '') {
365
+                    $location_array['gd_country'] = urldecode($country);
366
+        }
360 367
 
361
-        if ($region != '')
362
-            $location_array['gd_region'] = urldecode($region);
368
+        if ($region != '') {
369
+                    $location_array['gd_region'] = urldecode($region);
370
+        }
363 371
 
364
-        if ($city != '')
365
-            $location_array['gd_city'] = urldecode($city);
372
+        if ($city != '') {
373
+                    $location_array['gd_city'] = urldecode($city);
374
+        }
366 375
 			
367 376
 		// Fix category link in ajax popular category widget on change post type
368 377
 		if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) {
Please login to merge, or discard this patch.
Indentation   +408 added lines, -408 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function geodir_get_current_city_lat()
11 11
 {
12
-    $location = geodir_get_default_location();
13
-    $lat = isset($location_result->city_latitude) ? $location_result->city_latitude : '39.952484';
12
+	$location = geodir_get_default_location();
13
+	$lat = isset($location_result->city_latitude) ? $location_result->city_latitude : '39.952484';
14 14
 
15
-    return $lat;
15
+	return $lat;
16 16
 }
17 17
 
18 18
 /**
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function geodir_get_current_city_lng()
27 27
 {
28
-    $location = geodir_get_default_location();
29
-    $lng = isset($location_result->city_longitude) ? $location_result->city_longitude : '-75.163786';
30
-    return $lng;
28
+	$location = geodir_get_default_location();
29
+	$lng = isset($location_result->city_longitude) ? $location_result->city_longitude : '-75.163786';
30
+	return $lng;
31 31
 }
32 32
 
33 33
 
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
  */
41 41
 function geodir_get_default_location()
42 42
 {
43
-    /**
44
-     * Filter the default location.
45
-     *
46
-     * @since 1.0.0
47
-     * @package GeoDirectory
48
-     *
49
-     * @param string $location_result The default location object.
50
-     */
51
-    return $location_result = apply_filters('geodir_get_default_location', get_option('geodir_default_location'));
43
+	/**
44
+	 * Filter the default location.
45
+	 *
46
+	 * @since 1.0.0
47
+	 * @package GeoDirectory
48
+	 *
49
+	 * @param string $location_result The default location object.
50
+	 */
51
+	return $location_result = apply_filters('geodir_get_default_location', get_option('geodir_default_location'));
52 52
 }
53 53
 
54 54
 /**
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
  */
61 61
 function geodir_is_default_location_set()
62 62
 {
63
-    $default_location = geodir_get_default_location();
64
-    if (!empty($default_location))
65
-        return true;
66
-    else
67
-        return false;
63
+	$default_location = geodir_get_default_location();
64
+	if (!empty($default_location))
65
+		return true;
66
+	else
67
+		return false;
68 68
 }
69 69
 
70 70
 /**
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 function create_location_slug($location_string)
79 79
 {
80 80
 
81
-    /**
82
-     * Filter the location slug.
83
-     *
84
-     * @since 1.0.0
85
-     * @package GeoDirectory
86
-     *
87
-     * @param string $location_string Sanitized location string.
88
-     */
89
-    return urldecode(apply_filters('geodir_location_slug_check', sanitize_title($location_string)));
81
+	/**
82
+	 * Filter the location slug.
83
+	 *
84
+	 * @since 1.0.0
85
+	 * @package GeoDirectory
86
+	 *
87
+	 * @param string $location_string Sanitized location string.
88
+	 */
89
+	return urldecode(apply_filters('geodir_location_slug_check', sanitize_title($location_string)));
90 90
 
91 91
 }
92 92
 
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function geodir_get_location($id = '')
102 102
 {
103
-    /**
104
-     * Filter the location information.
105
-     *
106
-     * @since 1.0.0
107
-     * @package GeoDirectory
108
-     *
109
-     * @param string $id The location ID.
110
-     */
111
-    return $location_result = apply_filters('geodir_get_location_by_id', get_option('geodir_default_location'), $id);
103
+	/**
104
+	 * Filter the location information.
105
+	 *
106
+	 * @since 1.0.0
107
+	 * @package GeoDirectory
108
+	 *
109
+	 * @param string $id The location ID.
110
+	 */
111
+	return $location_result = apply_filters('geodir_get_location_by_id', get_option('geodir_default_location'), $id);
112 112
 }
113 113
 
114 114
 /**
@@ -122,28 +122,28 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function geodir_get_country_dl($post_country = '', $prefix = '')
124 124
 {
125
-    global $wpdb;
125
+	global $wpdb;
126 126
 
127
-    $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC");
127
+	$rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC");
128 128
     
129
-    $ISO2 = array();
130
-    $countries = array();
129
+	$ISO2 = array();
130
+	$countries = array();
131 131
     
132
-    foreach ($rows as $row) {
133
-        $ISO2[$row->Country] = $row->ISO2;
134
-        $countries[$row->Country] = __($row->Country, 'geodirectory');
135
-    }
132
+	foreach ($rows as $row) {
133
+		$ISO2[$row->Country] = $row->ISO2;
134
+		$countries[$row->Country] = __($row->Country, 'geodirectory');
135
+	}
136 136
     
137
-    asort($countries);
137
+	asort($countries);
138 138
     
139
-    $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>';
140
-    foreach ($countries as $country => $name) {
141
-        $ccode = $ISO2[$country];
139
+	$out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>';
140
+	foreach ($countries as $country => $name) {
141
+		$ccode = $ISO2[$country];
142 142
 
143
-        $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>';
144
-    }
143
+		$out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>';
144
+	}
145 145
 
146
-    echo $out_put;
146
+	echo $out_put;
147 147
 }
148 148
 
149 149
 
@@ -158,40 +158,40 @@  discard block
 block discarded – undo
158 158
 function geodir_location_form_submit()
159 159
 {
160 160
 
161
-    global $wpdb, $plugin_prefix;
162
-    if (isset($_REQUEST['add_location'])) {
161
+	global $wpdb, $plugin_prefix;
162
+	if (isset($_REQUEST['add_location'])) {
163 163
 
164
-        $location_info = array(
165
-            'city' => $_REQUEST['city'],
166
-            'region' => $_REQUEST['region'],
167
-            'country' => $_REQUEST['country'],
168
-            'geo_lat' => $_REQUEST['latitude'],
169
-            'geo_lng' => $_REQUEST['longitude'],
170
-            'is_default' => $_REQUEST['is_default'],
171
-            'update_city' => $_REQUEST['update_city']
172
-        );
164
+		$location_info = array(
165
+			'city' => $_REQUEST['city'],
166
+			'region' => $_REQUEST['region'],
167
+			'country' => $_REQUEST['country'],
168
+			'geo_lat' => $_REQUEST['latitude'],
169
+			'geo_lng' => $_REQUEST['longitude'],
170
+			'is_default' => $_REQUEST['is_default'],
171
+			'update_city' => $_REQUEST['update_city']
172
+		);
173 173
 
174
-        $old_location = geodir_get_default_location();
174
+		$old_location = geodir_get_default_location();
175 175
 
176
-        $locationid = geodir_add_new_location($location_info);
176
+		$locationid = geodir_add_new_location($location_info);
177 177
 
178
-        $default_location = geodir_get_location($locationid);
178
+		$default_location = geodir_get_location($locationid);
179 179
 
180
-        //UPDATE AND DELETE LISTING
181
-        $posttype = geodir_get_posttypes();
182
-        if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') {
180
+		//UPDATE AND DELETE LISTING
181
+		$posttype = geodir_get_posttypes();
182
+		if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') {
183 183
 
184
-            foreach ($posttype as $posttypeobj) {
185
-                $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location
184
+			foreach ($posttype as $posttypeobj) {
185
+				$post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location
186 186
 
187
-                $sql = $wpdb->prepare(
188
-                    "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
189
-                    array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations)
190
-                );
191
-                $wpdb->query($sql);
192
-            }
193
-        }
194
-    }
187
+				$sql = $wpdb->prepare(
188
+					"UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
189
+					array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations)
190
+				);
191
+				$wpdb->query($sql);
192
+			}
193
+		}
194
+	}
195 195
 }
196 196
 
197 197
 /**
@@ -215,37 +215,37 @@  discard block
 block discarded – undo
215 215
  */
216 216
 function geodir_add_new_location($location_info = array())
217 217
 {
218
-    global $wpdb;
219
-
220
-    if (!empty($location_info)) {
221
-        $location_city = ($location_info['city'] != '') ? $location_info['city'] : 'all';
222
-        $location_region = ($location_info['region'] != '') ? $location_info['region'] : 'all';
223
-        $location_country = ($location_info['country'] != '') ? geodir_get_normal_country($location_info['country']) : 'all';
224
-        $location_lat = ($location_info['geo_lat'] != '') ? $location_info['geo_lat'] : '';
225
-        $location_lng = ($location_info['geo_lng'] != '') ? $location_info['geo_lng'] : '';
226
-        $is_default = isset($location_info['is_default']) ? $location_info['is_default'] : '';
227
-        $country_slug = create_location_slug(__($location_country, 'geodirectory'));
228
-        $region_slug = create_location_slug($location_region);
229
-        $city_slug = create_location_slug($location_city);
218
+	global $wpdb;
219
+
220
+	if (!empty($location_info)) {
221
+		$location_city = ($location_info['city'] != '') ? $location_info['city'] : 'all';
222
+		$location_region = ($location_info['region'] != '') ? $location_info['region'] : 'all';
223
+		$location_country = ($location_info['country'] != '') ? geodir_get_normal_country($location_info['country']) : 'all';
224
+		$location_lat = ($location_info['geo_lat'] != '') ? $location_info['geo_lat'] : '';
225
+		$location_lng = ($location_info['geo_lng'] != '') ? $location_info['geo_lng'] : '';
226
+		$is_default = isset($location_info['is_default']) ? $location_info['is_default'] : '';
227
+		$country_slug = create_location_slug(__($location_country, 'geodirectory'));
228
+		$region_slug = create_location_slug($location_region);
229
+		$city_slug = create_location_slug($location_city);
230 230
         
231
-        /**
232
-         * Filter add new location data.
233
-         *
234
-         * @since 1.0.0
235
-         */
236
-        $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0,
237
-            'country' => $location_country,
238
-            'region' => $location_region,
239
-            'city' => $location_city,
240
-            'country_slug' => $country_slug,
241
-            'region_slug' => $region_slug,
242
-            'city_slug' => $city_slug,
243
-            'city_latitude' => $location_lat,
244
-            'city_longitude' => $location_lng,
245
-            'is_default' => $is_default
246
-        ));
247
-
248
-        /* // Not allowed to create country in DB : 2016-12-09
231
+		/**
232
+		 * Filter add new location data.
233
+		 *
234
+		 * @since 1.0.0
235
+		 */
236
+		$geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0,
237
+			'country' => $location_country,
238
+			'region' => $location_region,
239
+			'city' => $location_city,
240
+			'country_slug' => $country_slug,
241
+			'region_slug' => $region_slug,
242
+			'city_slug' => $city_slug,
243
+			'city_latitude' => $location_lat,
244
+			'city_longitude' => $location_lng,
245
+			'is_default' => $is_default
246
+		));
247
+
248
+		/* // Not allowed to create country in DB : 2016-12-09
249 249
         if ($geodir_location->country) {
250 250
 
251 251
             $get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", array($geodir_location->country)));
@@ -259,14 +259,14 @@  discard block
 block discarded – undo
259 259
         }
260 260
         */
261 261
 
262
-        if ($geodir_location->is_default)
263
-            update_option('geodir_default_location', $geodir_location);
262
+		if ($geodir_location->is_default)
263
+			update_option('geodir_default_location', $geodir_location);
264 264
 
265
-        return $geodir_location->location_id;
265
+		return $geodir_location->location_id;
266 266
 
267
-    } else {
268
-        return false;
269
-    }
267
+	} else {
268
+		return false;
269
+	}
270 270
 }
271 271
 
272 272
 /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
  */
281 281
 function geodir_random_float($min = 0, $max = 1)
282 282
 {
283
-    return $min + mt_rand() / mt_getrandmax() * ($max - $min);
283
+	return $min + mt_rand() / mt_getrandmax() * ($max - $min);
284 284
 }
285 285
 
286 286
 /**
@@ -294,23 +294,23 @@  discard block
 block discarded – undo
294 294
  */
295 295
 function geodir_get_address_by_lat_lan($lat, $lng)
296 296
 {
297
-    $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) . "&key=" . geodir_get_map_api_key();
298
-
299
-    $ch = curl_init();
300
-    curl_setopt($ch, CURLOPT_URL, $url);
301
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
302
-    curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
303
-    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
304
-    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
305
-    $response = curl_exec($ch);
306
-    curl_close($ch);
297
+	$url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) . "&key=" . geodir_get_map_api_key();
298
+
299
+	$ch = curl_init();
300
+	curl_setopt($ch, CURLOPT_URL, $url);
301
+	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
302
+	curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
303
+	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
304
+	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
305
+	$response = curl_exec($ch);
306
+	curl_close($ch);
307 307
     
308
-    $data = json_decode($response);
309
-    $status = $data->status;
310
-    if ($status == "OK") {
311
-        return $data->results[0]->address_components;
312
-    } else
313
-        return false;
308
+	$data = json_decode($response);
309
+	$status = $data->status;
310
+	if ($status == "OK") {
311
+		return $data->results[0]->address_components;
312
+	} else
313
+		return false;
314 314
 }
315 315
 
316 316
 /**
@@ -327,71 +327,71 @@  discard block
 block discarded – undo
327 327
  */
328 328
 function geodir_get_current_location_terms($location_array_from = 'session', $gd_post_type = '')
329 329
 {
330
-    global $wp, $gd_session;
331
-    $location_array = array();
332
-    if ($location_array_from == 'session') {
333
-        if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') {
334
-            return $location_array;
335
-        }
330
+	global $wp, $gd_session;
331
+	$location_array = array();
332
+	if ($location_array_from == 'session') {
333
+		if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') {
334
+			return $location_array;
335
+		}
336 336
 
337
-        $country = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : $gd_session->get('gd_country');
338
-        if ($country != '' && $country)
339
-            $location_array['gd_country'] = urldecode($country);
337
+		$country = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : $gd_session->get('gd_country');
338
+		if ($country != '' && $country)
339
+			$location_array['gd_country'] = urldecode($country);
340 340
 
341
-        $region = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : $gd_session->get('gd_region');
342
-        if ($region != '' && $region)
343
-            $location_array['gd_region'] = urldecode($region);
341
+		$region = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : $gd_session->get('gd_region');
342
+		if ($region != '' && $region)
343
+			$location_array['gd_region'] = urldecode($region);
344 344
 
345
-        $city = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : $gd_session->get('gd_city');
346
-        if ($city != '' && $city)
347
-            $location_array['gd_city'] = urldecode($city);
348
-    } else {
349
-        if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) {
350
-            return $location_array;
351
-        }
345
+		$city = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : $gd_session->get('gd_city');
346
+		if ($city != '' && $city)
347
+			$location_array['gd_city'] = urldecode($city);
348
+	} else {
349
+		if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) {
350
+			return $location_array;
351
+		}
352 352
 
353
-        $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
353
+		$country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
354 354
 
355
-        $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
355
+		$region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
356 356
 
357
-        $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
357
+		$city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
358 358
 
359
-        if ($country != '')
360
-            $location_array['gd_country'] = urldecode($country);
359
+		if ($country != '')
360
+			$location_array['gd_country'] = urldecode($country);
361 361
 
362
-        if ($region != '')
363
-            $location_array['gd_region'] = urldecode($region);
362
+		if ($region != '')
363
+			$location_array['gd_region'] = urldecode($region);
364 364
 
365
-        if ($city != '')
366
-            $location_array['gd_city'] = urldecode($city);
365
+		if ($city != '')
366
+			$location_array['gd_city'] = urldecode($city);
367 367
 			
368 368
 		// Fix category link in ajax popular category widget on change post type
369 369
 		if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) {
370 370
 			$location_array = geodir_get_current_location_terms('session');
371 371
 		}
372
-    }
372
+	}
373 373
 
374 374
 
375 375
 	/**
376 376
 	 * Filter the location terms.
377 377
 	 *
378 378
 	 * @since 1.4.6
379
-     * @package GeoDirectory
379
+	 * @package GeoDirectory
380
+	 *
381
+	 * @param array $location_array {
382
+	 *    Attributes of the location_array.
383
+	 *
384
+	 *    @type string $gd_country The country slug.
385
+	 *    @type string $gd_region The region slug.
386
+	 *    @type string $gd_city The city slug.
380 387
 	 *
381
-     * @param array $location_array {
382
-     *    Attributes of the location_array.
383
-     *
384
-     *    @type string $gd_country The country slug.
385
-     *    @type string $gd_region The region slug.
386
-     *    @type string $gd_city The city slug.
387
-     *
388
-     * }
388
+	 * }
389 389
 	 * @param string $location_array_from Source type of location terms. Default session.
390 390
 	 * @param string $gd_post_type WP post type.
391 391
 	 */
392 392
 	$location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type );
393 393
 
394
-    return $location_array;
394
+	return $location_array;
395 395
 
396 396
 }
397 397
 
@@ -404,24 +404,24 @@  discard block
 block discarded – undo
404 404
  * @return bool|string
405 405
  */
406 406
 function geodir_get_location_link($which_location = 'current') {
407
-    $location_link = get_permalink(geodir_location_page_id());
408
-
409
-    if ($which_location == 'base') {
410
-        return $location_link;
411
-    } else {
412
-        $location_terms = geodir_get_current_location_terms();
413
-
414
-        if (!empty($location_terms)) {
415
-            if (get_option('permalink_structure') != '') {
416
-                $location_terms = implode("/", $location_terms);
417
-                $location_terms = rtrim($location_terms, '/');
418
-                $location_link .= $location_terms;
419
-            } else {
420
-                $location_link = geodir_getlink($location_link, $location_terms);
421
-            }
422
-        }
423
-    }
424
-    return $location_link;
407
+	$location_link = get_permalink(geodir_location_page_id());
408
+
409
+	if ($which_location == 'base') {
410
+		return $location_link;
411
+	} else {
412
+		$location_terms = geodir_get_current_location_terms();
413
+
414
+		if (!empty($location_terms)) {
415
+			if (get_option('permalink_structure') != '') {
416
+				$location_terms = implode("/", $location_terms);
417
+				$location_terms = rtrim($location_terms, '/');
418
+				$location_link .= $location_terms;
419
+			} else {
420
+				$location_link = geodir_getlink($location_link, $location_terms);
421
+			}
422
+		}
423
+	}
424
+	return $location_link;
425 425
 }
426 426
 
427 427
 /**
@@ -434,34 +434,34 @@  discard block
 block discarded – undo
434 434
  * @return array|bool Returns address on success.
435 435
  */
436 436
 function geodir_get_osm_address_by_lat_lan($lat, $lng) {
437
-    $url = is_ssl() ? 'https:' : 'http:';
438
-    $url .= '//nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email');
439
-
440
-    $ch = curl_init();
441
-    curl_setopt($ch, CURLOPT_URL, $url);
442
-    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
443
-    curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
444
-    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
445
-    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
446
-    $response = curl_exec($ch);
447
-    curl_close($ch);
448
-    $data = json_decode($response);
437
+	$url = is_ssl() ? 'https:' : 'http:';
438
+	$url .= '//nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email');
439
+
440
+	$ch = curl_init();
441
+	curl_setopt($ch, CURLOPT_URL, $url);
442
+	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
443
+	curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
444
+	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
445
+	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
446
+	$response = curl_exec($ch);
447
+	curl_close($ch);
448
+	$data = json_decode($response);
449 449
     
450
-    if (!empty($data) && !empty($data->address)) {
451
-        $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb');
452
-        $formatted_address = (array)$data->address;
450
+	if (!empty($data) && !empty($data->address)) {
451
+		$address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb');
452
+		$formatted_address = (array)$data->address;
453 453
         
454
-        foreach ( $data->address as $key => $value ) {
455
-            if (!in_array($key, $address_fields)) {
456
-                unset($formatted_address[$key]);
457
-            }
458
-        }
459
-        $data->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : '';
454
+		foreach ( $data->address as $key => $value ) {
455
+			if (!in_array($key, $address_fields)) {
456
+				unset($formatted_address[$key]);
457
+			}
458
+		}
459
+		$data->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : '';
460 460
         
461
-        return $data;
462
-    } else {
463
-        return false;
464
-    }
461
+		return $data;
462
+	} else {
463
+		return false;
464
+	}
465 465
 }
466 466
 
467 467
 /**
@@ -475,51 +475,51 @@  discard block
 block discarded – undo
475 475
  * @return string Returns the country.
476 476
  */
477 477
 function geodir_get_normal_country($country, $default = '1') {
478
-    global $wpdb;
479
-    if ($result = geodir_get_country_by_name($country)) {
480
-        return $result;
481
-    }
478
+	global $wpdb;
479
+	if ($result = geodir_get_country_by_name($country)) {
480
+		return $result;
481
+	}
482 482
     
483
-    if (defined('POST_LOCATION_TABLE')) {
484
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
485
-        if (!empty($rows)) {
486
-            foreach ($rows as $row) {
487
-                $translated = __($row->country, 'geodirectory');
488
-                if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
489
-                    return $result;
490
-                }
491
-            }
492
-        }
483
+	if (defined('POST_LOCATION_TABLE')) {
484
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
485
+		if (!empty($rows)) {
486
+			foreach ($rows as $row) {
487
+				$translated = __($row->country, 'geodirectory');
488
+				if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
489
+					return $result;
490
+				}
491
+			}
492
+		}
493 493
         
494
-        $rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) );
495
-        if (!empty($rows)) {
496
-            foreach ($rows as $row) {
497
-                $translated = __($row->country, 'geodirectory');
498
-                if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
499
-                    return $result;
500
-                }
501
-            }
502
-        }
503
-    }
494
+		$rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) );
495
+		if (!empty($rows)) {
496
+			foreach ($rows as $row) {
497
+				$translated = __($row->country, 'geodirectory');
498
+				if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) {
499
+					return $result;
500
+				}
501
+			}
502
+		}
503
+	}
504 504
     
505
-    if ( $default === '0' ) {
506
-        return NULL;
507
-    }
505
+	if ( $default === '0' ) {
506
+		return NULL;
507
+	}
508 508
     
509
-    $default_location = geodir_get_default_location();
510
-    if (!empty($default_location->country) && $result = geodir_get_country_by_name($default_location->country)) {
511
-        return $result;
512
-    }
509
+	$default_location = geodir_get_default_location();
510
+	if (!empty($default_location->country) && $result = geodir_get_country_by_name($default_location->country)) {
511
+		return $result;
512
+	}
513 513
     
514
-    if (!empty($default_location->country_slug) && $result = geodir_get_country_by_name($default_location->country_slug)) {
515
-        return $result;
516
-    }
514
+	if (!empty($default_location->country_slug) && $result = geodir_get_country_by_name($default_location->country_slug)) {
515
+		return $result;
516
+	}
517 517
     
518
-    if (!empty($default_location->country_ISO2) && $result = geodir_get_country_by_name($default_location->country_ISO2, true)) {
519
-        return $result;
520
-    }
518
+	if (!empty($default_location->country_ISO2) && $result = geodir_get_country_by_name($default_location->country_ISO2, true)) {
519
+		return $result;
520
+	}
521 521
     
522
-    return $country;
522
+	return $country;
523 523
 }
524 524
 
525 525
 /**
@@ -531,16 +531,16 @@  discard block
 block discarded – undo
531 531
  * @return string Country ISO2 code.
532 532
  */
533 533
 function geodir_get_country_iso2($country) {
534
-    global $wpdb;
534
+	global $wpdb;
535 535
     
536
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
537
-        return $result;
538
-    }
539
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
540
-        return $result;
541
-    }
536
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
537
+		return $result;
538
+	}
539
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
540
+		return $result;
541
+	}
542 542
     
543
-    return $country;
543
+	return $country;
544 544
 }
545 545
 
546 546
 /**
@@ -553,16 +553,16 @@  discard block
 block discarded – undo
553 553
  * @return string|null Country ISO2 code.
554 554
  */
555 555
 function geodir_get_country_by_name($country, $iso2 = false) {
556
-    global $wpdb;
556
+	global $wpdb;
557 557
     
558
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
559
-        return $result;
560
-    }
561
-    if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) {
562
-        return $result;
563
-    }
558
+	if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
559
+		return $result;
560
+	}
561
+	if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) {
562
+		return $result;
563
+	}
564 564
     
565
-    return NULL;
565
+	return NULL;
566 566
 }
567 567
 
568 568
 
@@ -582,158 +582,158 @@  discard block
 block discarded – undo
582 582
  */
583 583
 function geodir_replace_location_variables($content, $location_array = array(), $sep = NULL, $gd_page = '') {
584 584
 
585
-    if (empty($content)) {
586
-        return $content;
587
-    }
585
+	if (empty($content)) {
586
+		return $content;
587
+	}
588 588
 
589 589
 
590
-    $location_replace_vars = geodir_location_replace_vars($location_array, $sep, $gd_page);
590
+	$location_replace_vars = geodir_location_replace_vars($location_array, $sep, $gd_page);
591 591
 
592
-    if (!empty($location_replace_vars)) {
593
-        foreach ($location_replace_vars as $search => $replace) {
594
-            if (!empty($search) && strpos($content, $search) !== false) {
595
-                $content = str_replace($search, $replace, $content);
596
-            }
597
-        }
598
-    }
592
+	if (!empty($location_replace_vars)) {
593
+		foreach ($location_replace_vars as $search => $replace) {
594
+			if (!empty($search) && strpos($content, $search) !== false) {
595
+				$content = str_replace($search, $replace, $content);
596
+			}
597
+		}
598
+	}
599 599
 
600
-    return $content;
600
+	return $content;
601 601
 }
602 602
 add_filter('geodir_replace_location_variables', 'geodir_replace_location_variables');
603 603
 
604 604
 
605 605
 function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = ''){
606 606
 
607
-    global $wp;
607
+	global $wp;
608 608
     
609
-    $location_manager = defined('GEODIRLOCATION_VERSION') ? true : false;
610
-
611
-    if (empty($location_array)) {
612
-        $location_array = geodir_get_current_location_terms('query_vars');
613
-    }
614
-
615
-    $location_terms = array();
616
-    $location_terms['gd_neighbourhood'] = !empty($wp->query_vars['gd_neighbourhood']) ? $wp->query_vars['gd_neighbourhood'] : '';
617
-    $location_terms['gd_city'] = !empty($wp->query_vars['gd_city']) ? $wp->query_vars['gd_city'] : '';
618
-    $location_terms['gd_region'] = !empty($wp->query_vars['gd_region']) ? $wp->query_vars['gd_region'] : '';
619
-    $location_terms['gd_country'] = !empty($wp->query_vars['gd_country']) ? $wp->query_vars['gd_country'] : '';
620
-
621
-    $location_names = array();
622
-    foreach ($location_terms as $type => $location) {
623
-        $location_name = $location;
624
-
625
-        if (!empty($location_name)) {
626
-            if ($location_manager) {
627
-                $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
628
-                $location_name = get_actual_location_name($location_type, $location, true);
629
-            } else {
630
-                $location_name = preg_replace( '/-(\d+)$/', '', $location_name);
631
-                $location_name = preg_replace( '/[_-]/', ' ', $location_name );
632
-                $location_name = __(geodir_ucwords($location_name), 'geodirectory');
633
-            }
634
-        }
635
-
636
-        $location_names[$type] = $location_name;
637
-    }
638
-
639
-    $location_single = '';
640
-    foreach ($location_terms as $type => $location) {
641
-        if (!empty($location)) {
642
-            if (!empty($location_names[$type])) {
643
-                $location_single = $location_names[$type];
644
-            } else {
645
-                if ($location_manager) {
646
-                    $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
647
-                    $location_single = get_actual_location_name($location_type, $location, true);
648
-                } else {
649
-                    $location_name = preg_replace( '/-(\d+)$/', '', $location);
650
-                    $location_name = preg_replace( '/[_-]/', ' ', $location_name );
651
-                    $location_single = __(geodir_ucwords($location_name), 'geodirectory');
652
-                }
653
-            }
654
-            break;
655
-        }
656
-    }
657
-
658
-    $full_location = array();
659
-    if (!empty($location_array)) {
660
-        $location_array = array_reverse($location_array);
661
-
662
-        foreach ($location_array as $type => $location) {
663
-            if (!empty($location_names[$type])) {
664
-                $location_name = $location_names[$type];
665
-            } else {
666
-                if ($location_manager) {
667
-                    $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
668
-                    $location_name = get_actual_location_name($location_type, $location, true);
669
-                } else {
670
-                    $location_name = preg_replace( '/-(\d+)$/', '', $location);
671
-                    $location_name = preg_replace( '/[_-]/', ' ', $location_name );
672
-                    $location_name = __(geodir_ucwords($location_name), 'geodirectory');
673
-                }
674
-            }
609
+	$location_manager = defined('GEODIRLOCATION_VERSION') ? true : false;
610
+
611
+	if (empty($location_array)) {
612
+		$location_array = geodir_get_current_location_terms('query_vars');
613
+	}
614
+
615
+	$location_terms = array();
616
+	$location_terms['gd_neighbourhood'] = !empty($wp->query_vars['gd_neighbourhood']) ? $wp->query_vars['gd_neighbourhood'] : '';
617
+	$location_terms['gd_city'] = !empty($wp->query_vars['gd_city']) ? $wp->query_vars['gd_city'] : '';
618
+	$location_terms['gd_region'] = !empty($wp->query_vars['gd_region']) ? $wp->query_vars['gd_region'] : '';
619
+	$location_terms['gd_country'] = !empty($wp->query_vars['gd_country']) ? $wp->query_vars['gd_country'] : '';
620
+
621
+	$location_names = array();
622
+	foreach ($location_terms as $type => $location) {
623
+		$location_name = $location;
624
+
625
+		if (!empty($location_name)) {
626
+			if ($location_manager) {
627
+				$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
628
+				$location_name = get_actual_location_name($location_type, $location, true);
629
+			} else {
630
+				$location_name = preg_replace( '/-(\d+)$/', '', $location_name);
631
+				$location_name = preg_replace( '/[_-]/', ' ', $location_name );
632
+				$location_name = __(geodir_ucwords($location_name), 'geodirectory');
633
+			}
634
+		}
675 635
 
676
-            $full_location[] = $location_name;
677
-        }
636
+		$location_names[$type] = $location_name;
637
+	}
638
+
639
+	$location_single = '';
640
+	foreach ($location_terms as $type => $location) {
641
+		if (!empty($location)) {
642
+			if (!empty($location_names[$type])) {
643
+				$location_single = $location_names[$type];
644
+			} else {
645
+				if ($location_manager) {
646
+					$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
647
+					$location_single = get_actual_location_name($location_type, $location, true);
648
+				} else {
649
+					$location_name = preg_replace( '/-(\d+)$/', '', $location);
650
+					$location_name = preg_replace( '/[_-]/', ' ', $location_name );
651
+					$location_single = __(geodir_ucwords($location_name), 'geodirectory');
652
+				}
653
+			}
654
+			break;
655
+		}
656
+	}
657
+
658
+	$full_location = array();
659
+	if (!empty($location_array)) {
660
+		$location_array = array_reverse($location_array);
661
+
662
+		foreach ($location_array as $type => $location) {
663
+			if (!empty($location_names[$type])) {
664
+				$location_name = $location_names[$type];
665
+			} else {
666
+				if ($location_manager) {
667
+					$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
668
+					$location_name = get_actual_location_name($location_type, $location, true);
669
+				} else {
670
+					$location_name = preg_replace( '/-(\d+)$/', '', $location);
671
+					$location_name = preg_replace( '/[_-]/', ' ', $location_name );
672
+					$location_name = __(geodir_ucwords($location_name), 'geodirectory');
673
+				}
674
+			}
675
+
676
+			$full_location[] = $location_name;
677
+		}
678 678
 
679
-        if (!empty($full_location)) {
680
-            $full_location = array_unique($full_location);
681
-        }
682
-    }
683
-    $full_location = !empty($full_location) ? implode(', ', $full_location): '';
679
+		if (!empty($full_location)) {
680
+			$full_location = array_unique($full_location);
681
+		}
682
+	}
683
+	$full_location = !empty($full_location) ? implode(', ', $full_location): '';
684 684
     
685
-    if ( empty( $full_location ) ) {
686
-        /**
687
-         * Filter the text in meta description in full location is empty.
688
-         *
689
-         * @since 1.6.22
690
-         * 
691
-         * @param string $full_location Default: Empty.
692
-         * @param array  $location_array The array of location variables.
693
-         * @param string $gd_page       The page being filtered.
694
-         * @param string $sep           The separator.
695
-         */
696
-         $full_location = apply_filters( 'geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep );
697
-    }
685
+	if ( empty( $full_location ) ) {
686
+		/**
687
+		 * Filter the text in meta description in full location is empty.
688
+		 *
689
+		 * @since 1.6.22
690
+		 * 
691
+		 * @param string $full_location Default: Empty.
692
+		 * @param array  $location_array The array of location variables.
693
+		 * @param string $gd_page       The page being filtered.
694
+		 * @param string $sep           The separator.
695
+		 */
696
+		 $full_location = apply_filters( 'geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep );
697
+	}
698 698
     
699
-    if ( empty( $location_single ) ) {
700
-        /**
701
-         * Filter the text in meta description in single location is empty.
702
-         *
703
-         * @since 1.6.22
704
-         * 
705
-         * @param string $location_single Default: Empty.
706
-         * @param array $location_array The array of location variables.
707
-         * @param string $gd_page       The page being filtered.
708
-         * @param string $sep           The separator.
709
-         */
710
-         $location_single = apply_filters( 'geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep );
711
-    }
712
-
713
-    $location_replace_vars = array();
714
-    $location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|';
715
-    $location_replace_vars['%%location%%'] = $full_location;
716
-    $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : '';
717
-    $location_replace_vars['%%location_single%%'] = $location_single;
718
-    $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : '';
719
-
720
-    foreach ($location_names as $type => $name) {
721
-        $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
722
-
723
-        $location_replace_vars['%%location_' . $location_type . '%%'] = $name;
724
-        $location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : '';
725
-    }
726
-
727
-    /**
728
-     * Filter the location terms variables to search & replace.
729
-     *
730
-     * @since   1.6.16
731
-     * @package GeoDirectory
732
-     *
733
-     * @param array $location_replace_vars The array of search & replace variables.
734
-     * @param array $location_array The array of location variables.
735
-     * @param string $gd_page       The page being filtered.
736
-     * @param string $sep           The separator.
737
-     */
738
-    return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep );
699
+	if ( empty( $location_single ) ) {
700
+		/**
701
+		 * Filter the text in meta description in single location is empty.
702
+		 *
703
+		 * @since 1.6.22
704
+		 * 
705
+		 * @param string $location_single Default: Empty.
706
+		 * @param array $location_array The array of location variables.
707
+		 * @param string $gd_page       The page being filtered.
708
+		 * @param string $sep           The separator.
709
+		 */
710
+		 $location_single = apply_filters( 'geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep );
711
+	}
712
+
713
+	$location_replace_vars = array();
714
+	$location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|';
715
+	$location_replace_vars['%%location%%'] = $full_location;
716
+	$location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : '';
717
+	$location_replace_vars['%%location_single%%'] = $location_single;
718
+	$location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : '';
719
+
720
+	foreach ($location_names as $type => $name) {
721
+		$location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
722
+
723
+		$location_replace_vars['%%location_' . $location_type . '%%'] = $name;
724
+		$location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : '';
725
+	}
726
+
727
+	/**
728
+	 * Filter the location terms variables to search & replace.
729
+	 *
730
+	 * @since   1.6.16
731
+	 * @package GeoDirectory
732
+	 *
733
+	 * @param array $location_replace_vars The array of search & replace variables.
734
+	 * @param array $location_array The array of location variables.
735
+	 * @param string $gd_page       The page being filtered.
736
+	 * @param string $sep           The separator.
737
+	 */
738
+	return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep );
739 739
 }
740 740
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 {
125 125
     global $wpdb;
126 126
 
127
-    $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC");
127
+    $rows = $wpdb->get_results("SELECT Country,ISO2 FROM ".GEODIR_COUNTRIES_TABLE." ORDER BY Country ASC");
128 128
     
129 129
     $ISO2 = array();
130 130
     $countries = array();
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
     
137 137
     asort($countries);
138 138
     
139
-    $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>';
139
+    $out_put = '<option '.selected('', $post_country, false).' value="">'.__('Select Country', 'geodirectory').'</option>';
140 140
     foreach ($countries as $country => $name) {
141 141
         $ccode = $ISO2[$country];
142 142
 
143
-        $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>';
143
+        $out_put .= '<option '.selected($post_country, $country, false).' value="'.esc_attr($country).'" data-country_code="'.$ccode.'">'.$name.'</option>';
144 144
     }
145 145
 
146 146
     echo $out_put;
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
         if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') {
183 183
 
184 184
             foreach ($posttype as $posttypeobj) {
185
-                $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location
185
+                $post_locations = '['.$default_location->city_slug.'],['.$default_location->region_slug.'],['.$default_location->country_slug.']'; // set all overall post location
186 186
 
187 187
                 $sql = $wpdb->prepare(
188
-                    "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
188
+                    "UPDATE ".$plugin_prefix.$posttypeobj."_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)",
189 189
                     array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations)
190 190
                 );
191 191
                 $wpdb->query($sql);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
          *
234 234
          * @since 1.0.0
235 235
          */
236
-        $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0,
236
+        $geodir_location = (object) apply_filters('geodir_add_new_location', array('location_id' => 0,
237 237
             'country' => $location_country,
238 238
             'region' => $location_region,
239 239
             'city' => $location_city,
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
  */
295 295
 function geodir_get_address_by_lat_lan($lat, $lng)
296 296
 {
297
-    $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng) . "&key=" . geodir_get_map_api_key();
297
+    $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng)."&key=".geodir_get_map_api_key();
298 298
 
299 299
     $ch = curl_init();
300 300
     curl_setopt($ch, CURLOPT_URL, $url);
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	 * @param string $location_array_from Source type of location terms. Default session.
390 390
 	 * @param string $gd_post_type WP post type.
391 391
 	 */
392
-	$location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type );
392
+	$location_array = apply_filters('geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type);
393 393
 
394 394
     return $location_array;
395 395
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
  */
436 436
 function geodir_get_osm_address_by_lat_lan($lat, $lng) {
437 437
     $url = is_ssl() ? 'https:' : 'http:';
438
-    $url .= '//nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email');
438
+    $url .= '//nominatim.openstreetmap.org/reverse?format=json&lat='.trim($lat).'&lon='.trim($lng).'&zoom=16&addressdetails=1&email='.get_option('admin_email');
439 439
 
440 440
     $ch = curl_init();
441 441
     curl_setopt($ch, CURLOPT_URL, $url);
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
     
450 450
     if (!empty($data) && !empty($data->address)) {
451 451
         $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb');
452
-        $formatted_address = (array)$data->address;
452
+        $formatted_address = (array) $data->address;
453 453
         
454
-        foreach ( $data->address as $key => $value ) {
454
+        foreach ($data->address as $key => $value) {
455 455
             if (!in_array($key, $address_fields)) {
456 456
                 unset($formatted_address[$key]);
457 457
             }
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
     }
482 482
     
483 483
     if (defined('POST_LOCATION_TABLE')) {
484
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
484
+        $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM ".POST_LOCATION_TABLE." WHERE country NOT LIKE %s ORDER BY location_id ASC", $country));
485 485
         if (!empty($rows)) {
486 486
             foreach ($rows as $row) {
487 487
                 $translated = __($row->country, 'geodirectory');
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
             }
492 492
         }
493 493
         
494
-        $rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) );
494
+        $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM ".POST_LOCATION_TABLE." WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country));
495 495
         if (!empty($rows)) {
496 496
             foreach ($rows as $row) {
497 497
                 $translated = __($row->country, 'geodirectory');
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
         }
503 503
     }
504 504
     
505
-    if ( $default === '0' ) {
505
+    if ($default === '0') {
506 506
         return NULL;
507 507
     }
508 508
     
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 function geodir_get_country_iso2($country) {
534 534
     global $wpdb;
535 535
     
536
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
536
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country LIKE %s", $country))) {
537 537
         return $result;
538 538
     }
539
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
539
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country LIKE %s", geodir_get_normal_country($country)))) {
540 540
         return $result;
541 541
     }
542 542
     
@@ -555,10 +555,10 @@  discard block
 block discarded – undo
555 555
 function geodir_get_country_by_name($country, $iso2 = false) {
556 556
     global $wpdb;
557 557
     
558
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) {
558
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM ".GEODIR_COUNTRIES_TABLE." WHERE Country LIKE %s", $country))) {
559 559
         return $result;
560 560
     }
561
-    if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) {
561
+    if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM ".GEODIR_COUNTRIES_TABLE." WHERE ISO2 LIKE %s", $country))) {
562 562
         return $result;
563 563
     }
564 564
     
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 add_filter('geodir_replace_location_variables', 'geodir_replace_location_variables');
603 603
 
604 604
 
605
-function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = ''){
605
+function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = '') {
606 606
 
607 607
     global $wp;
608 608
     
@@ -627,8 +627,8 @@  discard block
 block discarded – undo
627 627
                 $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
628 628
                 $location_name = get_actual_location_name($location_type, $location, true);
629 629
             } else {
630
-                $location_name = preg_replace( '/-(\d+)$/', '', $location_name);
631
-                $location_name = preg_replace( '/[_-]/', ' ', $location_name );
630
+                $location_name = preg_replace('/-(\d+)$/', '', $location_name);
631
+                $location_name = preg_replace('/[_-]/', ' ', $location_name);
632 632
                 $location_name = __(geodir_ucwords($location_name), 'geodirectory');
633 633
             }
634 634
         }
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
                     $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
647 647
                     $location_single = get_actual_location_name($location_type, $location, true);
648 648
                 } else {
649
-                    $location_name = preg_replace( '/-(\d+)$/', '', $location);
650
-                    $location_name = preg_replace( '/[_-]/', ' ', $location_name );
649
+                    $location_name = preg_replace('/-(\d+)$/', '', $location);
650
+                    $location_name = preg_replace('/[_-]/', ' ', $location_name);
651 651
                     $location_single = __(geodir_ucwords($location_name), 'geodirectory');
652 652
                 }
653 653
             }
@@ -667,8 +667,8 @@  discard block
 block discarded – undo
667 667
                     $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
668 668
                     $location_name = get_actual_location_name($location_type, $location, true);
669 669
                 } else {
670
-                    $location_name = preg_replace( '/-(\d+)$/', '', $location);
671
-                    $location_name = preg_replace( '/[_-]/', ' ', $location_name );
670
+                    $location_name = preg_replace('/-(\d+)$/', '', $location);
671
+                    $location_name = preg_replace('/[_-]/', ' ', $location_name);
672 672
                     $location_name = __(geodir_ucwords($location_name), 'geodirectory');
673 673
                 }
674 674
             }
@@ -680,9 +680,9 @@  discard block
 block discarded – undo
680 680
             $full_location = array_unique($full_location);
681 681
         }
682 682
     }
683
-    $full_location = !empty($full_location) ? implode(', ', $full_location): '';
683
+    $full_location = !empty($full_location) ? implode(', ', $full_location) : '';
684 684
     
685
-    if ( empty( $full_location ) ) {
685
+    if (empty($full_location)) {
686 686
         /**
687 687
          * Filter the text in meta description in full location is empty.
688 688
          *
@@ -693,10 +693,10 @@  discard block
 block discarded – undo
693 693
          * @param string $gd_page       The page being filtered.
694 694
          * @param string $sep           The separator.
695 695
          */
696
-         $full_location = apply_filters( 'geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep );
696
+         $full_location = apply_filters('geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep);
697 697
     }
698 698
     
699
-    if ( empty( $location_single ) ) {
699
+    if (empty($location_single)) {
700 700
         /**
701 701
          * Filter the text in meta description in single location is empty.
702 702
          *
@@ -707,21 +707,21 @@  discard block
 block discarded – undo
707 707
          * @param string $gd_page       The page being filtered.
708 708
          * @param string $sep           The separator.
709 709
          */
710
-         $location_single = apply_filters( 'geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep );
710
+         $location_single = apply_filters('geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep);
711 711
     }
712 712
 
713 713
     $location_replace_vars = array();
714 714
     $location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|';
715 715
     $location_replace_vars['%%location%%'] = $full_location;
716
-    $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : '';
716
+    $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf(_x('in %s', 'in location', 'geodirectory'), $full_location) : '';
717 717
     $location_replace_vars['%%location_single%%'] = $location_single;
718
-    $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : '';
718
+    $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf(_x('in %s', 'in location', 'geodirectory'), $location_single) : '';
719 719
 
720 720
     foreach ($location_names as $type => $name) {
721 721
         $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type;
722 722
 
723
-        $location_replace_vars['%%location_' . $location_type . '%%'] = $name;
724
-        $location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : '';
723
+        $location_replace_vars['%%location_'.$location_type.'%%'] = $name;
724
+        $location_replace_vars['%%in_location_'.$location_type.'%%'] = !empty($name) ? sprintf(_x('in %s', 'in location', 'geodirectory'), $name) : '';
725 725
     }
726 726
 
727 727
     /**
@@ -735,5 +735,5 @@  discard block
 block discarded – undo
735 735
      * @param string $gd_page       The page being filtered.
736 736
      * @param string $sep           The separator.
737 737
      */
738
-    return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep );
738
+    return apply_filters('geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep);
739 739
 }
740 740
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/helper_functions.php 4 patches
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
     if (geodir_is_wpml()){
148 148
         $home_url = icl_get_home_url();
149
-    }else{
149
+    } else{
150 150
         $home_url = home_url();
151 151
     }
152 152
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         $slug = $post->post_name;
160 160
         //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
161 161
         $login_url = trailingslashit($home_url)."$slug/";
162
-    }else{
162
+    } else{
163 163
         $login_url = trailingslashit($home_url)."?geodir_signup=true";
164 164
     }
165 165
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
     if (geodir_is_wpml()){
204 204
         $home_url = icl_get_home_url();
205
-    }else{
205
+    } else{
206 206
         $home_url = home_url();
207 207
     }
208 208
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         $slug = $post->post_name;
216 216
         //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
217 217
         $info_url = trailingslashit($home_url)."$slug/";
218
-    }else{
218
+    } else{
219 219
         $info_url = trailingslashit($home_url);
220 220
     }
221 221
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1173,7 +1173,7 @@
 block discarded – undo
1173 1173
  *
1174 1174
  * @param string $str The string being decoded.
1175 1175
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1176
- * @return string The width of string.
1176
+ * @return integer The width of string.
1177 1177
  */
1178 1178
 function geodir_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
1179 1179
 	if ( function_exists( 'mb_strwidth' ) ) {
Please login to merge, or discard this patch.
Indentation   +395 added lines, -395 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
  * @return int|null Return the page ID if present or null if not.
15 15
  */
16 16
 function geodir_add_listing_page_id(){
17
-    $gd_page_id = get_option('geodir_add_listing_page');
17
+	$gd_page_id = get_option('geodir_add_listing_page');
18 18
 
19
-    if (geodir_is_wpml()) {
20
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
21
-    }
19
+	if (geodir_is_wpml()) {
20
+		$gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
21
+	}
22 22
 
23
-    return $gd_page_id;
23
+	return $gd_page_id;
24 24
 }
25 25
 
26 26
 /**
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
  * @return int|null Return the page ID if present or null if not.
32 32
  */
33 33
 function geodir_preview_page_id(){
34
-    $gd_page_id = get_option('geodir_preview_page');
34
+	$gd_page_id = get_option('geodir_preview_page');
35 35
 
36
-    if (geodir_is_wpml()) {
37
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
38
-    }
36
+	if (geodir_is_wpml()) {
37
+		$gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
38
+	}
39 39
 
40
-    return $gd_page_id;
40
+	return $gd_page_id;
41 41
 }
42 42
 
43 43
 /**
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
  * @return int|null Return the page ID if present or null if not.
49 49
  */
50 50
 function geodir_success_page_id(){
51
-    $gd_page_id = get_option('geodir_success_page');
51
+	$gd_page_id = get_option('geodir_success_page');
52 52
 
53
-    if (geodir_is_wpml()) {
54
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
55
-    }
53
+	if (geodir_is_wpml()) {
54
+		$gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
55
+	}
56 56
 
57
-    return $gd_page_id;
57
+	return $gd_page_id;
58 58
 }
59 59
 
60 60
 /**
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
  * @return int|null Return the page ID if present or null if not.
66 66
  */
67 67
 function geodir_location_page_id(){
68
-    $gd_page_id = get_option('geodir_location_page');
68
+	$gd_page_id = get_option('geodir_location_page');
69 69
 
70
-    if (geodir_is_wpml()) {
71
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
72
-    }
70
+	if (geodir_is_wpml()) {
71
+		$gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
72
+	}
73 73
 
74
-    return $gd_page_id;
74
+	return $gd_page_id;
75 75
 }
76 76
 
77 77
 /**
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
  * @return int|null Return the page ID if present or null if not.
83 83
  */
84 84
 function geodir_home_page_id(){
85
-    $gd_page_id = get_option('geodir_home_page');
85
+	$gd_page_id = get_option('geodir_home_page');
86 86
 
87
-    if (geodir_is_wpml()) {
88
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
89
-    }
87
+	if (geodir_is_wpml()) {
88
+		$gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
89
+	}
90 90
 
91
-    return $gd_page_id;
91
+	return $gd_page_id;
92 92
 }
93 93
 
94 94
 /**
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
  * @return int|null Return the page ID if present or null if not.
100 100
  */
101 101
 function geodir_info_page_id(){
102
-    $gd_page_id = get_option('geodir_info_page');
102
+	$gd_page_id = get_option('geodir_info_page');
103 103
 
104
-    if (geodir_is_wpml()) {
105
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
106
-    }
104
+	if (geodir_is_wpml()) {
105
+		$gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
106
+	}
107 107
 
108
-    return $gd_page_id;
108
+	return $gd_page_id;
109 109
 }
110 110
 
111 111
 /**
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
  * @return int|null Return the page ID if present or null if not.
117 117
  */
118 118
 function geodir_login_page_id(){
119
-    $gd_page_id = get_option('geodir_login_page');
119
+	$gd_page_id = get_option('geodir_login_page');
120 120
 
121
-    if (geodir_is_wpml()) {
122
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
123
-    }
121
+	if (geodir_is_wpml()) {
122
+		$gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
123
+	}
124 124
 
125
-    return $gd_page_id;
125
+	return $gd_page_id;
126 126
 }
127 127
 
128 128
 
@@ -134,51 +134,51 @@  discard block
 block discarded – undo
134 134
  * @return int|null Return the page ID if present or null if not.
135 135
  */
136 136
 function geodir_login_url($args=array()){
137
-    $gd_page_id = get_option('geodir_login_page');
138
-
139
-    if (geodir_is_wpml()) {
140
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
141
-    }
142
-
143
-    if (function_exists('geodir_location_geo_home_link')) {
144
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
145
-    }
146
-
147
-    if (geodir_is_wpml()){
148
-        $home_url = icl_get_home_url();
149
-    }else{
150
-        $home_url = home_url();
151
-    }
152
-
153
-    if (function_exists('geodir_location_geo_home_link')) {
154
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
155
-    }
156
-
157
-    if($gd_page_id){
158
-        $post = get_post($gd_page_id);
159
-        $slug = $post->post_name;
160
-        //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
161
-        $login_url = trailingslashit($home_url)."$slug/";
162
-    }else{
163
-        $login_url = trailingslashit($home_url)."?geodir_signup=true";
164
-    }
165
-
166
-    if($args){
167
-        $login_url = add_query_arg($args,$login_url );
168
-    }
169
-
170
-    /**
171
-     * Filter the GeoDirectory login page url.
172
-     *
173
-     * This filter can be used to change the GeoDirectory page url.
174
-     *
175
-     * @since 1.5.3
176
-     * @package GeoDirectory
177
-     * @param string $login_url The url of the login page.
178
-     * @param array $args The array of query args used.
179
-     * @param int $gd_page_id The page id of the GD login page.
180
-     */
181
-	    return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id);
137
+	$gd_page_id = get_option('geodir_login_page');
138
+
139
+	if (geodir_is_wpml()) {
140
+		$gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
141
+	}
142
+
143
+	if (function_exists('geodir_location_geo_home_link')) {
144
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
145
+	}
146
+
147
+	if (geodir_is_wpml()){
148
+		$home_url = icl_get_home_url();
149
+	}else{
150
+		$home_url = home_url();
151
+	}
152
+
153
+	if (function_exists('geodir_location_geo_home_link')) {
154
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
155
+	}
156
+
157
+	if($gd_page_id){
158
+		$post = get_post($gd_page_id);
159
+		$slug = $post->post_name;
160
+		//$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
161
+		$login_url = trailingslashit($home_url)."$slug/";
162
+	}else{
163
+		$login_url = trailingslashit($home_url)."?geodir_signup=true";
164
+	}
165
+
166
+	if($args){
167
+		$login_url = add_query_arg($args,$login_url );
168
+	}
169
+
170
+	/**
171
+	 * Filter the GeoDirectory login page url.
172
+	 *
173
+	 * This filter can be used to change the GeoDirectory page url.
174
+	 *
175
+	 * @since 1.5.3
176
+	 * @package GeoDirectory
177
+	 * @param string $login_url The url of the login page.
178
+	 * @param array $args The array of query args used.
179
+	 * @param int $gd_page_id The page id of the GD login page.
180
+	 */
181
+		return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id);
182 182
 }
183 183
 
184 184
 /**
@@ -190,40 +190,40 @@  discard block
 block discarded – undo
190 190
  * @return string Info page url.
191 191
  */
192 192
 function geodir_info_url($args=array()){
193
-    $gd_page_id = get_option('geodir_info_page');
194
-
195
-    if (geodir_is_wpml()) {
196
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
197
-    }
198
-
199
-    if (function_exists('geodir_location_geo_home_link')) {
200
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
201
-    }
202
-
203
-    if (geodir_is_wpml()){
204
-        $home_url = icl_get_home_url();
205
-    }else{
206
-        $home_url = home_url();
207
-    }
208
-
209
-    if (function_exists('geodir_location_geo_home_link')) {
210
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
211
-    }
212
-
213
-    if($gd_page_id){
214
-        $post = get_post($gd_page_id);
215
-        $slug = $post->post_name;
216
-        //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
217
-        $info_url = trailingslashit($home_url)."$slug/";
218
-    }else{
219
-        $info_url = trailingslashit($home_url);
220
-    }
221
-
222
-    if($args){
223
-        $info_url = add_query_arg($args,$info_url );
224
-    }
225
-
226
-    return $info_url;
193
+	$gd_page_id = get_option('geodir_info_page');
194
+
195
+	if (geodir_is_wpml()) {
196
+		$gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
197
+	}
198
+
199
+	if (function_exists('geodir_location_geo_home_link')) {
200
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
201
+	}
202
+
203
+	if (geodir_is_wpml()){
204
+		$home_url = icl_get_home_url();
205
+	}else{
206
+		$home_url = home_url();
207
+	}
208
+
209
+	if (function_exists('geodir_location_geo_home_link')) {
210
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
211
+	}
212
+
213
+	if($gd_page_id){
214
+		$post = get_post($gd_page_id);
215
+		$slug = $post->post_name;
216
+		//$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
217
+		$info_url = trailingslashit($home_url)."$slug/";
218
+	}else{
219
+		$info_url = trailingslashit($home_url);
220
+	}
221
+
222
+	if($args){
223
+		$info_url = add_query_arg($args,$info_url );
224
+	}
225
+
226
+	return $info_url;
227 227
 }
228 228
 
229 229
 /**
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
  * @return string Returns converted string.
240 240
  */
241 241
 function geodir_ucwords($string, $charset='UTF-8') {
242
-    if (function_exists('mb_convert_case')) {
243
-        return mb_convert_case($string, MB_CASE_TITLE, $charset);
244
-    } else {
245
-        return ucwords($string);
246
-    }
242
+	if (function_exists('mb_convert_case')) {
243
+		return mb_convert_case($string, MB_CASE_TITLE, $charset);
244
+	} else {
245
+		return ucwords($string);
246
+	}
247 247
 }
248 248
 
249 249
 /**
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
  * @return string Returns converted string.
260 260
  */
261 261
 function geodir_strtolower($string, $charset='UTF-8') {
262
-    if (function_exists('mb_convert_case')) {
263
-        return mb_convert_case($string, MB_CASE_LOWER, $charset);
264
-    } else {
265
-        return strtolower($string);
266
-    }
262
+	if (function_exists('mb_convert_case')) {
263
+		return mb_convert_case($string, MB_CASE_LOWER, $charset);
264
+	} else {
265
+		return strtolower($string);
266
+	}
267 267
 }
268 268
 
269 269
 /**
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
  * @return string Returns converted string.
280 280
  */
281 281
 function geodir_strtoupper($string, $charset='UTF-8') {
282
-    if (function_exists('mb_convert_case')) {
283
-        return mb_convert_case($string, MB_CASE_UPPER, $charset);
284
-    } else {
285
-        return strtoupper($string);
286
-    }
282
+	if (function_exists('mb_convert_case')) {
283
+		return mb_convert_case($string, MB_CASE_UPPER, $charset);
284
+	} else {
285
+		return strtoupper($string);
286
+	}
287 287
 }
288 288
 
289 289
 /**
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
  * @package GeoDirectory
463 463
  */
464 464
 function _gd_die_handler() {
465
-    if ( defined( 'GD_TESTING_MODE' ) ) {
466
-        return '_gd_die_handler';
467
-    } else {
468
-        die();
469
-    }
465
+	if ( defined( 'GD_TESTING_MODE' ) ) {
466
+		return '_gd_die_handler';
467
+	} else {
468
+		die();
469
+	}
470 470
 }
471 471
 
472 472
 /**
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
  * @param int $status     Optional. Status code.
482 482
  */
483 483
 function gd_die( $message = '', $title = '', $status = 400 ) {
484
-    add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 );
485
-    add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 );
486
-    wp_die( $message, $title, array( 'response' => $status ));
484
+	add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 );
485
+	add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 );
486
+	wp_die( $message, $title, array( 'response' => $status ));
487 487
 }
488 488
 
489 489
 /*
@@ -660,44 +660,44 @@  discard block
 block discarded – undo
660 660
  * @return string The formatted date.
661 661
  */
662 662
 function geodir_date( $date_input, $date_to, $date_from = '', $locale = false ) {
663
-    if ( empty( $date_input ) || empty( $date_to ) ) {
664
-        return NULL;
665
-    }
663
+	if ( empty( $date_input ) || empty( $date_to ) ) {
664
+		return NULL;
665
+	}
666 666
     
667
-    $date_input = geodir_maybe_untranslate_date( $date_input );
667
+	$date_input = geodir_maybe_untranslate_date( $date_input );
668 668
     
669
-    $timestamp = 0;
670
-    if (!empty( $date_from ) && function_exists( 'date_create_from_format' ) ) {
671
-        $datetime = date_create_from_format( $date_from, $date_input );
672
-        if ( !empty( $datetime ) ) {
673
-            $timestamp = $datetime->getTimestamp();
674
-        }
675
-    }
669
+	$timestamp = 0;
670
+	if (!empty( $date_from ) && function_exists( 'date_create_from_format' ) ) {
671
+		$datetime = date_create_from_format( $date_from, $date_input );
672
+		if ( !empty( $datetime ) ) {
673
+			$timestamp = $datetime->getTimestamp();
674
+		}
675
+	}
676 676
     
677
-    if ( empty( $timestamp ) ) {
678
-        $date = strpos( $date_input, '/' ) !== false ? str_replace( '/', '-', $date_input ) : $date_input;
679
-        $timestamp = strtotime( $date );
680
-    }
677
+	if ( empty( $timestamp ) ) {
678
+		$date = strpos( $date_input, '/' ) !== false ? str_replace( '/', '-', $date_input ) : $date_input;
679
+		$timestamp = strtotime( $date );
680
+	}
681 681
     
682
-    $date = date_i18n( $date_to, $timestamp );
682
+	$date = date_i18n( $date_to, $timestamp );
683 683
     
684
-    if ( !$locale ) {
685
-        $date = geodir_maybe_untranslate_date( $date );
686
-    }
684
+	if ( !$locale ) {
685
+		$date = geodir_maybe_untranslate_date( $date );
686
+	}
687 687
     
688
-    /**
689
-     * Filter the the date format conversion.
690
-     *
691
-     * @since 1.6.7
692
-     * @package GeoDirectory
693
-     *
694
-     * @param string $date The date string.
695
-     * @param string $date_input The date input.
696
-     * @param string $date_to The destination date format.
697
-     * @param string $date_from The source date format.
698
-     * @param bool $locale True to retrieve the date in localized format.
699
-     */
700
-    return apply_filters( 'geodir_date', $date, $date_input, $date_to, $date_from, $locale );
688
+	/**
689
+	 * Filter the the date format conversion.
690
+	 *
691
+	 * @since 1.6.7
692
+	 * @package GeoDirectory
693
+	 *
694
+	 * @param string $date The date string.
695
+	 * @param string $date_input The date input.
696
+	 * @param string $date_to The destination date format.
697
+	 * @param string $date_from The source date format.
698
+	 * @param bool $locale True to retrieve the date in localized format.
699
+	 */
700
+	return apply_filters( 'geodir_date', $date, $date_input, $date_to, $date_from, $locale );
701 701
 }
702 702
 
703 703
 /**
@@ -722,91 +722,91 @@  discard block
 block discarded – undo
722 722
  * @return string Trimmed string.
723 723
  */
724 724
 function geodir_excerpt($text, $length = 100, $options = array()) {
725
-    if (!(int)$length > 0) {
726
-        return $text;
727
-    }
728
-    $default = array(
729
-        'ellipsis' => '', 'exact' => true, 'html' => true, 'trimWidth' => false,
725
+	if (!(int)$length > 0) {
726
+		return $text;
727
+	}
728
+	$default = array(
729
+		'ellipsis' => '', 'exact' => true, 'html' => true, 'trimWidth' => false,
730 730
 	);
731
-    if (!empty($options['html']) && function_exists('mb_internal_encoding') && strtolower(mb_internal_encoding()) === 'utf-8') {
732
-        $default['ellipsis'] = "";
733
-    }
734
-    $options += $default;
735
-
736
-    $prefix = '';
737
-    $suffix = $options['ellipsis'];
738
-
739
-    if ($options['html']) {
740
-        $ellipsisLength = geodir_strlen(strip_tags($options['ellipsis']), $options);
741
-
742
-        $truncateLength = 0;
743
-        $totalLength = 0;
744
-        $openTags = array();
745
-        $truncate = '';
746
-
747
-        preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER);
748
-        foreach ($tags as $tag) {
749
-            $contentLength = geodir_strlen($tag[3], $options);
750
-
751
-            if ($truncate === '') {
752
-                if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) {
753
-                    if (preg_match('/<[\w]+[^>]*>/', $tag[0])) {
754
-                        array_unshift($openTags, $tag[2]);
755
-                    } elseif (preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) {
756
-                        $pos = array_search($closeTag[1], $openTags);
757
-                        if ($pos !== false) {
758
-                            array_splice($openTags, $pos, 1);
759
-                        }
760
-                    }
761
-                }
762
-
763
-                $prefix .= $tag[1];
764
-
765
-                if ($totalLength + $contentLength + $ellipsisLength > $length) {
766
-                    $truncate = $tag[3];
767
-                    $truncateLength = $length - $totalLength;
768
-                } else {
769
-                    $prefix .= $tag[3];
770
-                }
771
-            }
772
-
773
-            $totalLength += $contentLength;
774
-            if ($totalLength > $length) {
775
-                break;
776
-            }
777
-        }
778
-
779
-        if ($totalLength <= $length) {
780
-            return $text;
781
-        }
782
-
783
-        $text = $truncate;
784
-        $length = $truncateLength;
785
-
786
-        foreach ($openTags as $tag) {
787
-            $suffix .= '</' . $tag . '>';
788
-        }
789
-    } else {
790
-        if (geodir_strlen($text, $options) <= $length) {
791
-            return $text;
792
-        }
793
-        $ellipsisLength = geodir_strlen($options['ellipsis'], $options);
794
-    }
795
-
796
-    $result = geodir_substr($text, 0, $length - $ellipsisLength, $options);
797
-
798
-    if (!$options['exact']) {
799
-        if (geodir_substr($text, $length - $ellipsisLength, 1, $options) !== ' ') {
800
-            $result = geodir_remove_last_word($result);
801
-        }
802
-
803
-        // Do not need to count ellipsis in the cut, if result is empty.
804
-        if (!strlen($result)) {
805
-            $result = geodir_substr($text, 0, $length, $options);
806
-        }
807
-    }
808
-
809
-    return $prefix . $result . $suffix;
731
+	if (!empty($options['html']) && function_exists('mb_internal_encoding') && strtolower(mb_internal_encoding()) === 'utf-8') {
732
+		$default['ellipsis'] = "";
733
+	}
734
+	$options += $default;
735
+
736
+	$prefix = '';
737
+	$suffix = $options['ellipsis'];
738
+
739
+	if ($options['html']) {
740
+		$ellipsisLength = geodir_strlen(strip_tags($options['ellipsis']), $options);
741
+
742
+		$truncateLength = 0;
743
+		$totalLength = 0;
744
+		$openTags = array();
745
+		$truncate = '';
746
+
747
+		preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER);
748
+		foreach ($tags as $tag) {
749
+			$contentLength = geodir_strlen($tag[3], $options);
750
+
751
+			if ($truncate === '') {
752
+				if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) {
753
+					if (preg_match('/<[\w]+[^>]*>/', $tag[0])) {
754
+						array_unshift($openTags, $tag[2]);
755
+					} elseif (preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) {
756
+						$pos = array_search($closeTag[1], $openTags);
757
+						if ($pos !== false) {
758
+							array_splice($openTags, $pos, 1);
759
+						}
760
+					}
761
+				}
762
+
763
+				$prefix .= $tag[1];
764
+
765
+				if ($totalLength + $contentLength + $ellipsisLength > $length) {
766
+					$truncate = $tag[3];
767
+					$truncateLength = $length - $totalLength;
768
+				} else {
769
+					$prefix .= $tag[3];
770
+				}
771
+			}
772
+
773
+			$totalLength += $contentLength;
774
+			if ($totalLength > $length) {
775
+				break;
776
+			}
777
+		}
778
+
779
+		if ($totalLength <= $length) {
780
+			return $text;
781
+		}
782
+
783
+		$text = $truncate;
784
+		$length = $truncateLength;
785
+
786
+		foreach ($openTags as $tag) {
787
+			$suffix .= '</' . $tag . '>';
788
+		}
789
+	} else {
790
+		if (geodir_strlen($text, $options) <= $length) {
791
+			return $text;
792
+		}
793
+		$ellipsisLength = geodir_strlen($options['ellipsis'], $options);
794
+	}
795
+
796
+	$result = geodir_substr($text, 0, $length - $ellipsisLength, $options);
797
+
798
+	if (!$options['exact']) {
799
+		if (geodir_substr($text, $length - $ellipsisLength, 1, $options) !== ' ') {
800
+			$result = geodir_remove_last_word($result);
801
+		}
802
+
803
+		// Do not need to count ellipsis in the cut, if result is empty.
804
+		if (!strlen($result)) {
805
+			$result = geodir_substr($text, 0, $length, $options);
806
+		}
807
+	}
808
+
809
+	return $prefix . $result . $suffix;
810 810
 }
811 811
 
812 812
 /**
@@ -830,28 +830,28 @@  discard block
 block discarded – undo
830 830
  * @return int
831 831
  */
832 832
 function geodir_strlen($text, array $options) {
833
-    if (empty($options['trimWidth'])) {
834
-        $strlen = 'geodir_utf8_strlen';
835
-    } else {
836
-        $strlen = 'geodir_utf8_strwidth';
837
-    }
838
-
839
-    if (empty($options['html'])) {
840
-        return $strlen($text);
841
-    }
842
-
843
-    $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i';
844
-    $replace = preg_replace_callback(
845
-        $pattern,
846
-        function ($match) use ($strlen) {
847
-            $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8');
848
-
849
-            return str_repeat(' ', $strlen($utf8, 'UTF-8'));
850
-        },
851
-        $text
852
-    );
853
-
854
-    return $strlen($replace);
833
+	if (empty($options['trimWidth'])) {
834
+		$strlen = 'geodir_utf8_strlen';
835
+	} else {
836
+		$strlen = 'geodir_utf8_strwidth';
837
+	}
838
+
839
+	if (empty($options['html'])) {
840
+		return $strlen($text);
841
+	}
842
+
843
+	$pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i';
844
+	$replace = preg_replace_callback(
845
+		$pattern,
846
+		function ($match) use ($strlen) {
847
+			$utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8');
848
+
849
+			return str_repeat(' ', $strlen($utf8, 'UTF-8'));
850
+		},
851
+		$text
852
+	);
853
+
854
+	return $strlen($replace);
855 855
 }
856 856
 
857 857
 /**
@@ -872,80 +872,80 @@  discard block
 block discarded – undo
872 872
  * @return string
873 873
  */
874 874
 function geodir_substr($text, $start, $length, array $options) {
875
-    if (empty($options['trimWidth'])) {
876
-        $substr = 'geodir_utf8_substr';
877
-    } else {
878
-        $substr = 'geodir_utf8_strimwidth';
879
-    }
880
-
881
-    $maxPosition = geodir_strlen($text, array('trimWidth' => false) + $options);
882
-    if ($start < 0) {
883
-        $start += $maxPosition;
884
-        if ($start < 0) {
885
-            $start = 0;
886
-        }
887
-    }
888
-    if ($start >= $maxPosition) {
889
-        return '';
890
-    }
891
-
892
-    if ($length === null) {
893
-        $length = geodir_strlen($text, $options);
894
-    }
895
-
896
-    if ($length < 0) {
897
-        $text = geodir_substr($text, $start, null, $options);
898
-        $start = 0;
899
-        $length += geodir_strlen($text, $options);
900
-    }
901
-
902
-    if ($length <= 0) {
903
-        return '';
904
-    }
905
-
906
-    if (empty($options['html'])) {
907
-        return (string)$substr($text, $start, $length);
908
-    }
909
-
910
-    $totalOffset = 0;
911
-    $totalLength = 0;
912
-    $result = '';
913
-
914
-    $pattern = '/(&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};)/i';
915
-    $parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
916
-    foreach ($parts as $part) {
917
-        $offset = 0;
918
-
919
-        if ($totalOffset < $start) {
920
-            $len = geodir_strlen($part, array('trimWidth' => false) + $options);
921
-            if ($totalOffset + $len <= $start) {
922
-                $totalOffset += $len;
923
-                continue;
924
-            }
925
-
926
-            $offset = $start - $totalOffset;
927
-            $totalOffset = $start;
928
-        }
929
-
930
-        $len = geodir_strlen($part, $options);
931
-        if ($offset !== 0 || $totalLength + $len > $length) {
932
-            if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) {
933
-                // Entities cannot be passed substr.
934
-                continue;
935
-            }
936
-
937
-            $part = $substr($part, $offset, $length - $totalLength);
938
-            $len = geodir_strlen($part, $options);
939
-        }
940
-
941
-        $result .= $part;
942
-        $totalLength += $len;
943
-        if ($totalLength >= $length) {
944
-            break;
945
-        }
946
-    }
947
-
948
-    return $result;
875
+	if (empty($options['trimWidth'])) {
876
+		$substr = 'geodir_utf8_substr';
877
+	} else {
878
+		$substr = 'geodir_utf8_strimwidth';
879
+	}
880
+
881
+	$maxPosition = geodir_strlen($text, array('trimWidth' => false) + $options);
882
+	if ($start < 0) {
883
+		$start += $maxPosition;
884
+		if ($start < 0) {
885
+			$start = 0;
886
+		}
887
+	}
888
+	if ($start >= $maxPosition) {
889
+		return '';
890
+	}
891
+
892
+	if ($length === null) {
893
+		$length = geodir_strlen($text, $options);
894
+	}
895
+
896
+	if ($length < 0) {
897
+		$text = geodir_substr($text, $start, null, $options);
898
+		$start = 0;
899
+		$length += geodir_strlen($text, $options);
900
+	}
901
+
902
+	if ($length <= 0) {
903
+		return '';
904
+	}
905
+
906
+	if (empty($options['html'])) {
907
+		return (string)$substr($text, $start, $length);
908
+	}
909
+
910
+	$totalOffset = 0;
911
+	$totalLength = 0;
912
+	$result = '';
913
+
914
+	$pattern = '/(&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};)/i';
915
+	$parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
916
+	foreach ($parts as $part) {
917
+		$offset = 0;
918
+
919
+		if ($totalOffset < $start) {
920
+			$len = geodir_strlen($part, array('trimWidth' => false) + $options);
921
+			if ($totalOffset + $len <= $start) {
922
+				$totalOffset += $len;
923
+				continue;
924
+			}
925
+
926
+			$offset = $start - $totalOffset;
927
+			$totalOffset = $start;
928
+		}
929
+
930
+		$len = geodir_strlen($part, $options);
931
+		if ($offset !== 0 || $totalLength + $len > $length) {
932
+			if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) {
933
+				// Entities cannot be passed substr.
934
+				continue;
935
+			}
936
+
937
+			$part = $substr($part, $offset, $length - $totalLength);
938
+			$len = geodir_strlen($part, $options);
939
+		}
940
+
941
+		$result .= $part;
942
+		$totalLength += $len;
943
+		if ($totalLength >= $length) {
944
+			break;
945
+		}
946
+	}
947
+
948
+	return $result;
949 949
 }
950 950
 
951 951
 /**
@@ -958,21 +958,21 @@  discard block
 block discarded – undo
958 958
  * @return string
959 959
  */
960 960
 function geodir_remove_last_word($text) {
961
-    $spacepos = geodir_utf8_strrpos($text, ' ');
961
+	$spacepos = geodir_utf8_strrpos($text, ' ');
962 962
 
963
-    if ($spacepos !== false) {
964
-        $lastWord = geodir_utf8_strrpos($text, $spacepos);
963
+	if ($spacepos !== false) {
964
+		$lastWord = geodir_utf8_strrpos($text, $spacepos);
965 965
 
966
-        // Some languages are written without word separation.
967
-        // We recognize a string as a word if it does not contain any full-width characters.
968
-        if (geodir_utf8_strwidth($lastWord) === geodir_utf8_strlen($lastWord)) {
969
-            $text = geodir_utf8_substr($text, 0, $spacepos);
970
-        }
966
+		// Some languages are written without word separation.
967
+		// We recognize a string as a word if it does not contain any full-width characters.
968
+		if (geodir_utf8_strwidth($lastWord) === geodir_utf8_strlen($lastWord)) {
969
+			$text = geodir_utf8_substr($text, 0, $spacepos);
970
+		}
971 971
 
972
-        return $text;
973
-    }
972
+		return $text;
973
+	}
974 974
 
975
-    return '';
975
+	return '';
976 976
 }
977 977
 
978 978
 function geodir_tool_restore_cpt_from_taxonomies(){
@@ -1090,11 +1090,11 @@  discard block
 block discarded – undo
1090 1090
  * @return string
1091 1091
  */
1092 1092
 function geodir_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
1093
-    if ( function_exists( 'mb_strimwidth' ) ) {
1094
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
1095
-    }
1093
+	if ( function_exists( 'mb_strimwidth' ) ) {
1094
+		return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
1095
+	}
1096 1096
     
1097
-    return geodir_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
1097
+	return geodir_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
1098 1098
 }
1099 1099
 
1100 1100
 /**
@@ -1108,11 +1108,11 @@  discard block
 block discarded – undo
1108 1108
  * @return int Returns the number of characters in string.
1109 1109
  */
1110 1110
 function geodir_utf8_strlen( $str, $encoding = 'UTF-8' ) {
1111
-    if ( function_exists( 'mb_strlen' ) ) {
1112
-        return mb_strlen( $str, $encoding );
1113
-    }
1111
+	if ( function_exists( 'mb_strlen' ) ) {
1112
+		return mb_strlen( $str, $encoding );
1113
+	}
1114 1114
         
1115
-    return strlen( $str );
1115
+	return strlen( $str );
1116 1116
 }
1117 1117
 
1118 1118
 /**
@@ -1128,11 +1128,11 @@  discard block
 block discarded – undo
1128 1128
  * @return int Returns the position of the first occurrence of search in the string.
1129 1129
  */
1130 1130
 function geodir_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
1131
-    if ( function_exists( 'mb_strpos' ) ) {
1132
-        return mb_strpos( $str, $find, $offset, $encoding );
1133
-    }
1131
+	if ( function_exists( 'mb_strpos' ) ) {
1132
+		return mb_strpos( $str, $find, $offset, $encoding );
1133
+	}
1134 1134
         
1135
-    return strpos( $str, $find, $offset );
1135
+	return strpos( $str, $find, $offset );
1136 1136
 }
1137 1137
 
1138 1138
 /**
@@ -1148,11 +1148,11 @@  discard block
 block discarded – undo
1148 1148
  * @return int Returns the position of the last occurrence of search.
1149 1149
  */
1150 1150
 function geodir_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
1151
-    if ( function_exists( 'mb_strrpos' ) ) {
1152
-        return mb_strrpos( $str, $find, $offset, $encoding );
1153
-    }
1151
+	if ( function_exists( 'mb_strrpos' ) ) {
1152
+		return mb_strrpos( $str, $find, $offset, $encoding );
1153
+	}
1154 1154
         
1155
-    return strrpos( $str, $find, $offset );
1155
+	return strrpos( $str, $find, $offset );
1156 1156
 }
1157 1157
 
1158 1158
 /**
@@ -1169,15 +1169,15 @@  discard block
 block discarded – undo
1169 1169
  * @return string
1170 1170
  */
1171 1171
 function geodir_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
1172
-    if ( function_exists( 'mb_substr' ) ) {
1173
-        if ( $length === null ) {
1174
-            return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding );
1175
-        } else {
1176
-            return mb_substr( $str, $start, $length, $encoding );
1177
-        }
1178
-    }
1172
+	if ( function_exists( 'mb_substr' ) ) {
1173
+		if ( $length === null ) {
1174
+			return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding );
1175
+		} else {
1176
+			return mb_substr( $str, $start, $length, $encoding );
1177
+		}
1178
+	}
1179 1179
         
1180
-    return substr( $str, $start, $length );
1180
+	return substr( $str, $start, $length );
1181 1181
 }
1182 1182
 
1183 1183
 /**
@@ -1210,20 +1210,20 @@  discard block
 block discarded – undo
1210 1210
  * @return string The resulting string.
1211 1211
  */
1212 1212
 function geodir_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
1213
-    if ( function_exists( 'mb_strlen' ) ) {
1214
-        $first_letter = geodir_strtoupper( geodir_utf8_substr( $str, 0, 1, $encoding ), $encoding );
1215
-        $str_end = "";
1213
+	if ( function_exists( 'mb_strlen' ) ) {
1214
+		$first_letter = geodir_strtoupper( geodir_utf8_substr( $str, 0, 1, $encoding ), $encoding );
1215
+		$str_end = "";
1216 1216
         
1217
-        if ( $lower_str_end ) {
1218
-            $str_end = geodir_strtolower( geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
1219
-        } else {
1220
-            $str_end = geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding );
1221
-        }
1217
+		if ( $lower_str_end ) {
1218
+			$str_end = geodir_strtolower( geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
1219
+		} else {
1220
+			$str_end = geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding );
1221
+		}
1222 1222
         
1223
-        return $first_letter . $str_end;
1224
-    }
1223
+		return $first_letter . $str_end;
1224
+	}
1225 1225
 
1226
-    return ucfirst( $str );
1226
+	return ucfirst( $str );
1227 1227
 }
1228 1228
 
1229 1229
 function geodir_total_listings_count($post_type = false)
Please login to merge, or discard this patch.
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
  * @since 1.4.6
14 14
  * @return int|null Return the page ID if present or null if not.
15 15
  */
16
-function geodir_add_listing_page_id(){
16
+function geodir_add_listing_page_id() {
17 17
     $gd_page_id = get_option('geodir_add_listing_page');
18 18
 
19 19
     if (geodir_is_wpml()) {
20
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
20
+        $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true);
21 21
     }
22 22
 
23 23
     return $gd_page_id;
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
  * @since 1.4.6
31 31
  * @return int|null Return the page ID if present or null if not.
32 32
  */
33
-function geodir_preview_page_id(){
33
+function geodir_preview_page_id() {
34 34
     $gd_page_id = get_option('geodir_preview_page');
35 35
 
36 36
     if (geodir_is_wpml()) {
37
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
37
+        $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true);
38 38
     }
39 39
 
40 40
     return $gd_page_id;
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
  * @since 1.4.6
48 48
  * @return int|null Return the page ID if present or null if not.
49 49
  */
50
-function geodir_success_page_id(){
50
+function geodir_success_page_id() {
51 51
     $gd_page_id = get_option('geodir_success_page');
52 52
 
53 53
     if (geodir_is_wpml()) {
54
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
54
+        $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true);
55 55
     }
56 56
 
57 57
     return $gd_page_id;
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
  * @since 1.4.6
65 65
  * @return int|null Return the page ID if present or null if not.
66 66
  */
67
-function geodir_location_page_id(){
67
+function geodir_location_page_id() {
68 68
     $gd_page_id = get_option('geodir_location_page');
69 69
 
70 70
     if (geodir_is_wpml()) {
71
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
71
+        $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true);
72 72
     }
73 73
 
74 74
     return $gd_page_id;
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
  * @since 1.5.4
82 82
  * @return int|null Return the page ID if present or null if not.
83 83
  */
84
-function geodir_home_page_id(){
84
+function geodir_home_page_id() {
85 85
     $gd_page_id = get_option('geodir_home_page');
86 86
 
87 87
     if (geodir_is_wpml()) {
88
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
88
+        $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true);
89 89
     }
90 90
 
91 91
     return $gd_page_id;
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
  * @since 1.5.3
99 99
  * @return int|null Return the page ID if present or null if not.
100 100
  */
101
-function geodir_info_page_id(){
101
+function geodir_info_page_id() {
102 102
     $gd_page_id = get_option('geodir_info_page');
103 103
 
104 104
     if (geodir_is_wpml()) {
105
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
105
+        $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true);
106 106
     }
107 107
 
108 108
     return $gd_page_id;
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
  * @since 1.5.3
116 116
  * @return int|null Return the page ID if present or null if not.
117 117
  */
118
-function geodir_login_page_id(){
118
+function geodir_login_page_id() {
119 119
     $gd_page_id = get_option('geodir_login_page');
120 120
 
121 121
     if (geodir_is_wpml()) {
122
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
122
+        $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true);
123 123
     }
124 124
 
125 125
     return $gd_page_id;
@@ -133,20 +133,20 @@  discard block
 block discarded – undo
133 133
  * @since 1.5.3
134 134
  * @return int|null Return the page ID if present or null if not.
135 135
  */
136
-function geodir_login_url($args=array()){
136
+function geodir_login_url($args = array()) {
137 137
     $gd_page_id = get_option('geodir_login_page');
138 138
 
139 139
     if (geodir_is_wpml()) {
140
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
140
+        $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true);
141 141
     }
142 142
 
143 143
     if (function_exists('geodir_location_geo_home_link')) {
144 144
         remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
145 145
     }
146 146
 
147
-    if (geodir_is_wpml()){
147
+    if (geodir_is_wpml()) {
148 148
         $home_url = icl_get_home_url();
149
-    }else{
149
+    } else {
150 150
         $home_url = home_url();
151 151
     }
152 152
 
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
         add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
155 155
     }
156 156
 
157
-    if($gd_page_id){
157
+    if ($gd_page_id) {
158 158
         $post = get_post($gd_page_id);
159 159
         $slug = $post->post_name;
160 160
         //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
161 161
         $login_url = trailingslashit($home_url)."$slug/";
162
-    }else{
162
+    } else {
163 163
         $login_url = trailingslashit($home_url)."?geodir_signup=true";
164 164
     }
165 165
 
166
-    if($args){
167
-        $login_url = add_query_arg($args,$login_url );
166
+    if ($args) {
167
+        $login_url = add_query_arg($args, $login_url);
168 168
     }
169 169
 
170 170
     /**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      * @param array $args The array of query args used.
179 179
      * @param int $gd_page_id The page id of the GD login page.
180 180
      */
181
-	    return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id);
181
+	    return apply_filters('geodir_login_url', $login_url, $args, $gd_page_id);
182 182
 }
183 183
 
184 184
 /**
@@ -189,20 +189,20 @@  discard block
 block discarded – undo
189 189
  * @since 1.5.16 Added WPML lang code to url.
190 190
  * @return string Info page url.
191 191
  */
192
-function geodir_info_url($args=array()){
192
+function geodir_info_url($args = array()) {
193 193
     $gd_page_id = get_option('geodir_info_page');
194 194
 
195 195
     if (geodir_is_wpml()) {
196
-        $gd_page_id =  geodir_wpml_object_id($gd_page_id, 'page', true);
196
+        $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true);
197 197
     }
198 198
 
199 199
     if (function_exists('geodir_location_geo_home_link')) {
200 200
         remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
201 201
     }
202 202
 
203
-    if (geodir_is_wpml()){
203
+    if (geodir_is_wpml()) {
204 204
         $home_url = icl_get_home_url();
205
-    }else{
205
+    } else {
206 206
         $home_url = home_url();
207 207
     }
208 208
 
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
         add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
211 211
     }
212 212
 
213
-    if($gd_page_id){
213
+    if ($gd_page_id) {
214 214
         $post = get_post($gd_page_id);
215 215
         $slug = $post->post_name;
216 216
         //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors
217 217
         $info_url = trailingslashit($home_url)."$slug/";
218
-    }else{
218
+    } else {
219 219
         $info_url = trailingslashit($home_url);
220 220
     }
221 221
 
222
-    if($args){
223
-        $info_url = add_query_arg($args,$info_url );
222
+    if ($args) {
223
+        $info_url = add_query_arg($args, $info_url);
224 224
     }
225 225
 
226 226
     return $info_url;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
  * @param string $charset Character set to use for conversion.
239 239
  * @return string Returns converted string.
240 240
  */
241
-function geodir_ucwords($string, $charset='UTF-8') {
241
+function geodir_ucwords($string, $charset = 'UTF-8') {
242 242
     if (function_exists('mb_convert_case')) {
243 243
         return mb_convert_case($string, MB_CASE_TITLE, $charset);
244 244
     } else {
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
  * @param string $charset Character set to use for conversion.
259 259
  * @return string Returns converted string.
260 260
  */
261
-function geodir_strtolower($string, $charset='UTF-8') {
261
+function geodir_strtolower($string, $charset = 'UTF-8') {
262 262
     if (function_exists('mb_convert_case')) {
263 263
         return mb_convert_case($string, MB_CASE_LOWER, $charset);
264 264
     } else {
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
  * @param string $charset Character set to use for conversion.
279 279
  * @return string Returns converted string.
280 280
  */
281
-function geodir_strtoupper($string, $charset='UTF-8') {
281
+function geodir_strtoupper($string, $charset = 'UTF-8') {
282 282
     if (function_exists('mb_convert_case')) {
283 283
         return mb_convert_case($string, MB_CASE_UPPER, $charset);
284 284
     } else {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	
310 310
 	$url = trim($parts[0]);
311 311
 	if ($formatted && $url != '') {
312
-		$url = str_replace( ' ', '%20', $url );
312
+		$url = str_replace(' ', '%20', $url);
313 313
 		$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url);
314 314
 		
315 315
 		if (0 !== stripos($url, 'mailto:')) {
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 		
320 320
 		$url = str_replace(';//', '://', $url);
321 321
 		
322
-		if (strpos($url, ':') === false && ! in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) {
323
-			$url = 'http://' . $url;
322
+		if (strpos($url, ':') === false && !in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) {
323
+			$url = 'http://'.$url;
324 324
 		}
325 325
 		
326 326
 		$url = wp_kses_normalize_entities($url);
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
  * @package GeoDirectory
463 463
  */
464 464
 function _gd_die_handler() {
465
-    if ( defined( 'GD_TESTING_MODE' ) ) {
465
+    if (defined('GD_TESTING_MODE')) {
466 466
         return '_gd_die_handler';
467 467
     } else {
468 468
         die();
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
  * @param string $title   Optional. Error title.
481 481
  * @param int $status     Optional. Status code.
482 482
  */
483
-function gd_die( $message = '', $title = '', $status = 400 ) {
484
-    add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 );
485
-    add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 );
486
-    wp_die( $message, $title, array( 'response' => $status ));
483
+function gd_die($message = '', $title = '', $status = 400) {
484
+    add_filter('wp_die_ajax_handler', '_gd_die_handler', 10, 3);
485
+    add_filter('wp_die_handler', '_gd_die_handler', 10, 3);
486
+    wp_die($message, $title, array('response' => $status));
487 487
 }
488 488
 
489 489
 /*
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
  * @param string $php_format The PHP date format.
494 494
  * @return string The jQuery format date string.
495 495
  */
496
-function geodir_date_format_php_to_jqueryui( $php_format ) {
496
+function geodir_date_format_php_to_jqueryui($php_format) {
497 497
 	$symbols = array(
498 498
 		// Day
499 499
 		'd' => 'dd',
@@ -533,27 +533,27 @@  discard block
 block discarded – undo
533 533
 	$jqueryui_format = "";
534 534
 	$escaping = false;
535 535
 
536
-	for ( $i = 0; $i < strlen( $php_format ); $i++ ) {
536
+	for ($i = 0; $i < strlen($php_format); $i++) {
537 537
 		$char = $php_format[$i];
538 538
 
539 539
 		// PHP date format escaping character
540
-		if ( $char === '\\' ) {
540
+		if ($char === '\\') {
541 541
 			$i++;
542 542
 
543
-			if ( $escaping ) {
543
+			if ($escaping) {
544 544
 				$jqueryui_format .= $php_format[$i];
545 545
 			} else {
546
-				$jqueryui_format .= '\'' . $php_format[$i];
546
+				$jqueryui_format .= '\''.$php_format[$i];
547 547
 			}
548 548
 
549 549
 			$escaping = true;
550 550
 		} else {
551
-			if ( $escaping ) {
551
+			if ($escaping) {
552 552
 				$jqueryui_format .= "'";
553 553
 				$escaping = false;
554 554
 			}
555 555
 
556
-			if ( isset( $symbols[$char] ) ) {
556
+			if (isset($symbols[$char])) {
557 557
 				$jqueryui_format .= $symbols[$char];
558 558
 			} else {
559 559
 				$jqueryui_format .= $char;
@@ -574,79 +574,79 @@  discard block
 block discarded – undo
574 574
  * @since 1.6.22 Genitive month added.
575 575
  * @since 1.6.26 Date translation issue in German language - FIXED.
576 576
  */
577
-function geodir_maybe_untranslate_date( $date ) {
578
-	$date_formated = ' '. $date;
577
+function geodir_maybe_untranslate_date($date) {
578
+	$date_formated = ' '.$date;
579 579
 
580 580
 	$names = array(
581 581
 		// The Weekdays
582
-		'Sunday' => __( 'Sunday' ),
583
-		'Monday' => __( 'Monday' ),
584
-		'Tuesday' => __( 'Tuesday' ),
585
-		'Wednesday' => __( 'Wednesday' ),
586
-		'Thursday' => __( 'Thursday' ),
587
-		'Friday' => __( 'Friday' ),
588
-		'Saturday' => __( 'Saturday' ),
582
+		'Sunday' => __('Sunday'),
583
+		'Monday' => __('Monday'),
584
+		'Tuesday' => __('Tuesday'),
585
+		'Wednesday' => __('Wednesday'),
586
+		'Thursday' => __('Thursday'),
587
+		'Friday' => __('Friday'),
588
+		'Saturday' => __('Saturday'),
589 589
 
590 590
 		// The Months
591
-		'January' => __( 'January' ),
592
-		'February' => __( 'February' ),
593
-		'March' => __( 'March' ),
594
-		'April' => __( 'April' ),
595
-		'May' => __( 'May' ),
596
-		'June' => __( 'June' ),
597
-		'July' => __( 'July' ),
598
-		'August' => __( 'August' ),
599
-		'September' => __( 'September' ),
600
-		'October' => __( 'October' ),
601
-		'November' => __( 'November' ),
602
-		'December' => __( 'December' ),
591
+		'January' => __('January'),
592
+		'February' => __('February'),
593
+		'March' => __('March'),
594
+		'April' => __('April'),
595
+		'May' => __('May'),
596
+		'June' => __('June'),
597
+		'July' => __('July'),
598
+		'August' => __('August'),
599
+		'September' => __('September'),
600
+		'October' => __('October'),
601
+		'November' => __('November'),
602
+		'December' => __('December'),
603 603
 
604 604
 		// Abbreviations for each month.
605
-		'Jan' => _x( 'Jan', 'January abbreviation' ),
606
-		'Feb' => _x( 'Feb', 'February abbreviation' ),
607
-		'Mar' => _x( 'Mar', 'March abbreviation' ),
608
-		'Apr' => _x( 'Apr', 'April abbreviation' ),
609
-		'May' => _x( 'May', 'May abbreviation' ),
610
-		'Jun' => _x( 'Jun', 'June abbreviation' ),
611
-		'Jul' => _x( 'Jul', 'July abbreviation' ),
612
-		'Aug' => _x( 'Aug', 'August abbreviation' ),
613
-		'Sep' => _x( 'Sep', 'September abbreviation' ),
614
-		'Oct' => _x( 'Oct', 'October abbreviation' ),
615
-		'Nov' => _x( 'Nov', 'November abbreviation' ),
616
-		'Dec' => _x( 'Dec', 'December abbreviation' ),
605
+		'Jan' => _x('Jan', 'January abbreviation'),
606
+		'Feb' => _x('Feb', 'February abbreviation'),
607
+		'Mar' => _x('Mar', 'March abbreviation'),
608
+		'Apr' => _x('Apr', 'April abbreviation'),
609
+		'May' => _x('May', 'May abbreviation'),
610
+		'Jun' => _x('Jun', 'June abbreviation'),
611
+		'Jul' => _x('Jul', 'July abbreviation'),
612
+		'Aug' => _x('Aug', 'August abbreviation'),
613
+		'Sep' => _x('Sep', 'September abbreviation'),
614
+		'Oct' => _x('Oct', 'October abbreviation'),
615
+		'Nov' => _x('Nov', 'November abbreviation'),
616
+		'Dec' => _x('Dec', 'December abbreviation'),
617 617
 
618 618
 		// Abbreviations for each day.
619
-		'Sun' => __( 'Sun' ),
620
-		'Mon' => __( 'Mon' ),
621
-		'Tue' => __( 'Tue' ),
622
-		'Wed' => __( 'Wed' ),
623
-		'Thu' => __( 'Thu' ),
624
-		'Fri' => __( 'Fri' ),
625
-		'Sat' => __( 'Sat' ),
619
+		'Sun' => __('Sun'),
620
+		'Mon' => __('Mon'),
621
+		'Tue' => __('Tue'),
622
+		'Wed' => __('Wed'),
623
+		'Thu' => __('Thu'),
624
+		'Fri' => __('Fri'),
625
+		'Sat' => __('Sat'),
626 626
 
627 627
 		// The first letter of each day.
628
-		'S' => _x( 'S', 'Sunday initial' ),
629
-		'M' => _x( 'M', 'Monday initial' ),
630
-		'T' => _x( 'T', 'Tuesday initial' ),
631
-		'W' => _x( 'W', 'Wednesday initial' ),
632
-		'T' => _x( 'T', 'Thursday initial' ),
633
-		'F' => _x( 'F', 'Friday initial' ),
634
-		'S' => _x( 'S', 'Saturday initial' ),
628
+		'S' => _x('S', 'Sunday initial'),
629
+		'M' => _x('M', 'Monday initial'),
630
+		'T' => _x('T', 'Tuesday initial'),
631
+		'W' => _x('W', 'Wednesday initial'),
632
+		'T' => _x('T', 'Thursday initial'),
633
+		'F' => _x('F', 'Friday initial'),
634
+		'S' => _x('S', 'Saturday initial'),
635 635
 
636 636
 		// The Meridiems
637
-		'am' => __( 'am' ),
638
-		'pm' => __( 'pm' ),
639
-		'AM' => __( 'AM' ),
640
-		'PM' => __( 'PM' )
637
+		'am' => __('am'),
638
+		'pm' => __('pm'),
639
+		'AM' => __('AM'),
640
+		'PM' => __('PM')
641 641
 	);
642 642
 
643
-	foreach ( $names as $name => $translation ) {
644
-		$date_formated = preg_replace( "/([^\\\])" . $name . "/", "\\1" . backslashit( $name ), $date_formated );
645
-		$date_formated = preg_replace( "/([^\\\])" . $translation . "/", "\\1" . backslashit( $name ), $date_formated );
643
+	foreach ($names as $name => $translation) {
644
+		$date_formated = preg_replace("/([^\\\])".$name."/", "\\1".backslashit($name), $date_formated);
645
+		$date_formated = preg_replace("/([^\\\])".$translation."/", "\\1".backslashit($name), $date_formated);
646 646
 	}
647 647
 
648
-	$date_formated = substr( $date_formated, 1, strlen( $date_formated ) -1 );
649
-	$date = stripslashes( $date_formated );
648
+	$date_formated = substr($date_formated, 1, strlen($date_formated) - 1);
649
+	$date = stripslashes($date_formated);
650 650
 
651 651
 	return $date;
652 652
 }
@@ -663,30 +663,30 @@  discard block
 block discarded – undo
663 663
  * @param bool $locale True to retrieve the date in localized format. Default false.
664 664
  * @return string The formatted date.
665 665
  */
666
-function geodir_date( $date_input, $date_to, $date_from = '', $locale = false ) {
667
-    if ( empty( $date_input ) || empty( $date_to ) ) {
666
+function geodir_date($date_input, $date_to, $date_from = '', $locale = false) {
667
+    if (empty($date_input) || empty($date_to)) {
668 668
         return NULL;
669 669
     }
670 670
     
671
-    $date_input = geodir_maybe_untranslate_date( $date_input );
671
+    $date_input = geodir_maybe_untranslate_date($date_input);
672 672
     
673 673
     $timestamp = 0;
674
-    if (!empty( $date_from ) && function_exists( 'date_create_from_format' ) ) {
675
-        $datetime = date_create_from_format( $date_from, $date_input );
676
-        if ( !empty( $datetime ) ) {
674
+    if (!empty($date_from) && function_exists('date_create_from_format')) {
675
+        $datetime = date_create_from_format($date_from, $date_input);
676
+        if (!empty($datetime)) {
677 677
             $timestamp = $datetime->getTimestamp();
678 678
         }
679 679
     }
680 680
     
681
-    if ( empty( $timestamp ) ) {
682
-        $date = strpos( $date_input, '/' ) !== false ? str_replace( '/', '-', $date_input ) : $date_input;
683
-        $timestamp = strtotime( $date );
681
+    if (empty($timestamp)) {
682
+        $date = strpos($date_input, '/') !== false ? str_replace('/', '-', $date_input) : $date_input;
683
+        $timestamp = strtotime($date);
684 684
     }
685 685
     
686
-    $date = date_i18n( $date_to, $timestamp );
686
+    $date = date_i18n($date_to, $timestamp);
687 687
     
688
-    if ( !$locale ) {
689
-        $date = geodir_maybe_untranslate_date( $date );
688
+    if (!$locale) {
689
+        $date = geodir_maybe_untranslate_date($date);
690 690
     }
691 691
     
692 692
     /**
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
      * @param string $date_from The source date format.
702 702
      * @param bool $locale True to retrieve the date in localized format.
703 703
      */
704
-    return apply_filters( 'geodir_date', $date, $date_input, $date_to, $date_from, $locale );
704
+    return apply_filters('geodir_date', $date, $date_input, $date_to, $date_from, $locale);
705 705
 }
706 706
 
707 707
 /**
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
  * @return string Trimmed string.
727 727
  */
728 728
 function geodir_excerpt($text, $length = 100, $options = array()) {
729
-    if (!(int)$length > 0) {
729
+    if (!(int) $length > 0) {
730 730
         return $text;
731 731
     }
732 732
     $default = array(
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         $length = $truncateLength;
789 789
 
790 790
         foreach ($openTags as $tag) {
791
-            $suffix .= '</' . $tag . '>';
791
+            $suffix .= '</'.$tag.'>';
792 792
         }
793 793
     } else {
794 794
         if (geodir_strlen($text, $options) <= $length) {
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
         }
811 811
     }
812 812
 
813
-    return $prefix . $result . $suffix;
813
+    return $prefix.$result.$suffix;
814 814
 }
815 815
 
816 816
 /**
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
     $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i';
848 848
     $replace = preg_replace_callback(
849 849
         $pattern,
850
-        function ($match) use ($strlen) {
850
+        function($match) use ($strlen) {
851 851
             $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8');
852 852
 
853 853
             return str_repeat(' ', $strlen($utf8, 'UTF-8'));
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
     }
909 909
 
910 910
     if (empty($options['html'])) {
911
-        return (string)$substr($text, $start, $length);
911
+        return (string) $substr($text, $start, $length);
912 912
     }
913 913
 
914 914
     $totalOffset = 0;
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 
934 934
         $len = geodir_strlen($part, $options);
935 935
         if ($offset !== 0 || $totalLength + $len > $length) {
936
-            if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) {
936
+            if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8')) {
937 937
                 // Entities cannot be passed substr.
938 938
                 continue;
939 939
             }
@@ -979,39 +979,39 @@  discard block
 block discarded – undo
979 979
     return '';
980 980
 }
981 981
 
982
-function geodir_tool_restore_cpt_from_taxonomies(){
982
+function geodir_tool_restore_cpt_from_taxonomies() {
983 983
 
984 984
 	$cpts = get_option('geodir_post_types');
985 985
 
986
-	if(!empty($cpts)){return;}
986
+	if (!empty($cpts)) {return; }
987 987
 
988 988
 	$taxonomies = get_option('geodir_taxonomies');
989 989
 
990
-	if(empty($taxonomies)){return;}
990
+	if (empty($taxonomies)) {return; }
991 991
 
992 992
 	$cpts = array();
993 993
 
994
-	foreach($taxonomies as $key => $val){
994
+	foreach ($taxonomies as $key => $val) {
995 995
 
996
-		if(strpos($val['listing_slug'], '/') === false) {
997
-			$cpts[$val['object_type']] = array('cpt'=>$val['object_type'],'slug'=>$val['listing_slug']);
996
+		if (strpos($val['listing_slug'], '/') === false) {
997
+			$cpts[$val['object_type']] = array('cpt'=>$val['object_type'], 'slug'=>$val['listing_slug']);
998 998
 		}
999 999
 
1000 1000
 	}
1001 1001
 
1002
-	if(empty($cpts)){return;}
1002
+	if (empty($cpts)) {return; }
1003 1003
 
1004 1004
 
1005 1005
 	$cpts_restore = $cpts;
1006 1006
 
1007
-	foreach($cpts as $cpt){
1007
+	foreach ($cpts as $cpt) {
1008 1008
 
1009 1009
 
1010
-		$is_custom = $cpt['cpt']=='gd_place' ? 0 : 1;
1010
+		$is_custom = $cpt['cpt'] == 'gd_place' ? 0 : 1;
1011 1011
 
1012
-		$cpts_restore[$cpt['cpt']] = array (
1012
+		$cpts_restore[$cpt['cpt']] = array(
1013 1013
 				'labels' =>
1014
-					array (
1014
+					array(
1015 1015
 						'name' => $cpt['slug'],
1016 1016
 						'singular_name' => $cpt['slug'],
1017 1017
 						'add_new' => 'Add New',
@@ -1039,14 +1039,14 @@  discard block
 block discarded – undo
1039 1039
 				'public' => true,
1040 1040
 				'query_var' => true,
1041 1041
 				'rewrite' =>
1042
-					array (
1042
+					array(
1043 1043
 						'slug' => $cpt['slug'],
1044 1044
 						'with_front' => false,
1045 1045
 						'hierarchical' => true,
1046 1046
 						'feeds' => true,
1047 1047
 					),
1048 1048
 				'supports' =>
1049
-					array (
1049
+					array(
1050 1050
 						0 => 'title',
1051 1051
 						1 => 'editor',
1052 1052
 						2 => 'author',
@@ -1056,14 +1056,14 @@  discard block
 block discarded – undo
1056 1056
 						6 => 'comments',
1057 1057
 					),
1058 1058
 				'taxonomies' =>
1059
-					array (
1059
+					array(
1060 1060
 						0 => $cpt['cpt'].'category',
1061 1061
 						1 => $cpt['cpt'].'_tags',
1062 1062
 					),
1063 1063
 				'is_custom' => $is_custom,
1064 1064
 				'listing_order' => '1',
1065 1065
 				'seo' =>
1066
-					array (
1066
+					array(
1067 1067
 						'meta_keyword' => '',
1068 1068
 						'meta_description' => '',
1069 1069
 					),
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 	}
1076 1076
 
1077 1077
 
1078
-	update_option('geodir_post_types',$cpts_restore);
1078
+	update_option('geodir_post_types', $cpts_restore);
1079 1079
 
1080 1080
 }
1081 1081
 
@@ -1093,12 +1093,12 @@  discard block
 block discarded – undo
1093 1093
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1094 1094
  * @return string
1095 1095
  */
1096
-function geodir_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
1097
-    if ( function_exists( 'mb_strimwidth' ) ) {
1098
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
1096
+function geodir_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
1097
+    if (function_exists('mb_strimwidth')) {
1098
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
1099 1099
     }
1100 1100
     
1101
-    return geodir_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
1101
+    return geodir_utf8_substr($str, $start, $width, $encoding).$trimmaker;
1102 1102
 }
1103 1103
 
1104 1104
 /**
@@ -1111,12 +1111,12 @@  discard block
 block discarded – undo
1111 1111
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1112 1112
  * @return int Returns the number of characters in string.
1113 1113
  */
1114
-function geodir_utf8_strlen( $str, $encoding = 'UTF-8' ) {
1115
-    if ( function_exists( 'mb_strlen' ) ) {
1116
-        return mb_strlen( $str, $encoding );
1114
+function geodir_utf8_strlen($str, $encoding = 'UTF-8') {
1115
+    if (function_exists('mb_strlen')) {
1116
+        return mb_strlen($str, $encoding);
1117 1117
     }
1118 1118
         
1119
-    return strlen( $str );
1119
+    return strlen($str);
1120 1120
 }
1121 1121
 
1122 1122
 /**
@@ -1131,12 +1131,12 @@  discard block
 block discarded – undo
1131 1131
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1132 1132
  * @return int Returns the position of the first occurrence of search in the string.
1133 1133
  */
1134
-function geodir_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
1135
-    if ( function_exists( 'mb_strpos' ) ) {
1136
-        return mb_strpos( $str, $find, $offset, $encoding );
1134
+function geodir_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
1135
+    if (function_exists('mb_strpos')) {
1136
+        return mb_strpos($str, $find, $offset, $encoding);
1137 1137
     }
1138 1138
         
1139
-    return strpos( $str, $find, $offset );
1139
+    return strpos($str, $find, $offset);
1140 1140
 }
1141 1141
 
1142 1142
 /**
@@ -1151,12 +1151,12 @@  discard block
 block discarded – undo
1151 1151
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1152 1152
  * @return int Returns the position of the last occurrence of search.
1153 1153
  */
1154
-function geodir_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
1155
-    if ( function_exists( 'mb_strrpos' ) ) {
1156
-        return mb_strrpos( $str, $find, $offset, $encoding );
1154
+function geodir_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
1155
+    if (function_exists('mb_strrpos')) {
1156
+        return mb_strrpos($str, $find, $offset, $encoding);
1157 1157
     }
1158 1158
         
1159
-    return strrpos( $str, $find, $offset );
1159
+    return strrpos($str, $find, $offset);
1160 1160
 }
1161 1161
 
1162 1162
 /**
@@ -1172,16 +1172,16 @@  discard block
 block discarded – undo
1172 1172
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1173 1173
  * @return string
1174 1174
  */
1175
-function geodir_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
1176
-    if ( function_exists( 'mb_substr' ) ) {
1177
-        if ( $length === null ) {
1178
-            return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding );
1175
+function geodir_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
1176
+    if (function_exists('mb_substr')) {
1177
+        if ($length === null) {
1178
+            return mb_substr($str, $start, geodir_utf8_strlen($str, $encoding), $encoding);
1179 1179
         } else {
1180
-            return mb_substr( $str, $start, $length, $encoding );
1180
+            return mb_substr($str, $start, $length, $encoding);
1181 1181
         }
1182 1182
     }
1183 1183
         
1184
-    return substr( $str, $start, $length );
1184
+    return substr($str, $start, $length);
1185 1185
 }
1186 1186
 
1187 1187
 /**
@@ -1194,12 +1194,12 @@  discard block
 block discarded – undo
1194 1194
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1195 1195
  * @return string The width of string.
1196 1196
  */
1197
-function geodir_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
1198
-	if ( function_exists( 'mb_strwidth' ) ) {
1199
-		return mb_strwidth( $str, $encoding );
1197
+function geodir_utf8_strwidth($str, $encoding = 'UTF-8') {
1198
+	if (function_exists('mb_strwidth')) {
1199
+		return mb_strwidth($str, $encoding);
1200 1200
 	}
1201 1201
 
1202
-	return geodir_utf8_strlen( $str, $encoding );
1202
+	return geodir_utf8_strlen($str, $encoding);
1203 1203
 }
1204 1204
 
1205 1205
 /**
@@ -1213,21 +1213,21 @@  discard block
 block discarded – undo
1213 1213
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
1214 1214
  * @return string The resulting string.
1215 1215
  */
1216
-function geodir_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
1217
-    if ( function_exists( 'mb_strlen' ) ) {
1218
-        $first_letter = geodir_strtoupper( geodir_utf8_substr( $str, 0, 1, $encoding ), $encoding );
1216
+function geodir_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
1217
+    if (function_exists('mb_strlen')) {
1218
+        $first_letter = geodir_strtoupper(geodir_utf8_substr($str, 0, 1, $encoding), $encoding);
1219 1219
         $str_end = "";
1220 1220
         
1221
-        if ( $lower_str_end ) {
1222
-            $str_end = geodir_strtolower( geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
1221
+        if ($lower_str_end) {
1222
+            $str_end = geodir_strtolower(geodir_utf8_substr($str, 1, geodir_utf8_strlen($str, $encoding), $encoding), $encoding);
1223 1223
         } else {
1224
-            $str_end = geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding );
1224
+            $str_end = geodir_utf8_substr($str, 1, geodir_utf8_strlen($str, $encoding), $encoding);
1225 1225
         }
1226 1226
         
1227
-        return $first_letter . $str_end;
1227
+        return $first_letter.$str_end;
1228 1228
     }
1229 1229
 
1230
-    return ucfirst( $str );
1230
+    return ucfirst($str);
1231 1231
 }
1232 1232
 
1233 1233
 function geodir_total_listings_count($post_type = false)
@@ -1237,13 +1237,13 @@  discard block
 block discarded – undo
1237 1237
 	$count = 0;
1238 1238
 	
1239 1239
 	if ($post_type) {
1240
-		$count = $count + $wpdb->get_var("select count(post_id) from " . $wpdb->prefix . "geodir_" . $post_type . "_detail");
1240
+		$count = $count + $wpdb->get_var("select count(post_id) from ".$wpdb->prefix."geodir_".$post_type."_detail");
1241 1241
 	} else {
1242 1242
 		$all_postypes = geodir_get_posttypes();
1243 1243
 
1244 1244
 		if (!empty($all_postypes)) {
1245 1245
 			foreach ($all_postypes as $key) {
1246
-				$count = $count + $wpdb->get_var("select count(post_id) from " . $wpdb->prefix . "geodir_" . $key . "_detail");
1246
+				$count = $count + $wpdb->get_var("select count(post_id) from ".$wpdb->prefix."geodir_".$key."_detail");
1247 1247
 			}
1248 1248
 		}	
1249 1249
 	}
Please login to merge, or discard this patch.