Test Failed
Pull Request — master (#411)
by Kiran
19:19
created
geodirectory-functions/cat-meta-functions/cat_meta.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -11,142 +11,142 @@  discard block
 block discarded – undo
11 11
 //include the main class file
12 12
 require_once("Tax-meta-class.php");
13 13
 if (is_admin()) {
14
-    /*
14
+	/*
15 15
      * prefix of meta keys, optional
16 16
      * use underscore (_) at the beginning to make keys hidden, for example $prefix = '_ba_';
17 17
      *  you also can make prefix empty to disable it
18 18
      *
19 19
      */
20 20
 
21
-    $prefix = 'ct_';
22
-    /*
21
+	$prefix = 'ct_';
22
+	/*
23 23
      * configure your meta box
24 24
      */
25 25
 
26
-    $config = array(
27
-        'id' => 'demo_meta_box',                    // meta box id, unique per meta box
28
-        'title' => __('Demo Meta Box', 'geodirectory'),                    // meta box title
29
-        'pages' => geodir_get_taxonomies(),            // taxonomy name, accept categories, post_tag and custom taxonomies
30
-        'context' => 'normal',                        // where the meta box appear: normal (default), advanced, side; optional
31
-        'fields' => array(),                        // list of meta fields (can be added by field arrays)
32
-        'local_images' => false,                    // Use local or hosted images (meta box images for add/remove)
33
-        'use_with_theme' => true                    //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
34
-    );
26
+	$config = array(
27
+		'id' => 'demo_meta_box',                    // meta box id, unique per meta box
28
+		'title' => __('Demo Meta Box', 'geodirectory'),                    // meta box title
29
+		'pages' => geodir_get_taxonomies(),            // taxonomy name, accept categories, post_tag and custom taxonomies
30
+		'context' => 'normal',                        // where the meta box appear: normal (default), advanced, side; optional
31
+		'fields' => array(),                        // list of meta fields (can be added by field arrays)
32
+		'local_images' => false,                    // Use local or hosted images (meta box images for add/remove)
33
+		'use_with_theme' => true                    //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
34
+	);
35 35
 
36 36
 
37
-    /*
37
+	/*
38 38
      * Initiate your meta box
39 39
      */
40
-    $my_meta = new Geodir_Tax_Meta_Class($config);
41
-    $my_meta->addWysiwyg($prefix . 'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory')));
42
-    $my_meta->addImage($prefix . 'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory')));
43
-    $my_meta->addImage($prefix . 'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty'));
44
-    /*$my_meta->addCheckbox($prefix.'pointless',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'),'style'=>'hidden'));*/// hidden setting to trick WPML
45
-
46
-    $my_meta->addSelect($prefix . 'cat_schema',
47
-    /*
40
+	$my_meta = new Geodir_Tax_Meta_Class($config);
41
+	$my_meta->addWysiwyg($prefix . 'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory')));
42
+	$my_meta->addImage($prefix . 'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory')));
43
+	$my_meta->addImage($prefix . 'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty'));
44
+	/*$my_meta->addCheckbox($prefix.'pointless',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'),'style'=>'hidden'));*/// hidden setting to trick WPML
45
+
46
+	$my_meta->addSelect($prefix . 'cat_schema',
47
+	/*
48 48
      * Allows you to add/filter the cat schema types.
49 49
      *
50 50
      * @since 1.5.7
51 51
      */
52
-        apply_filters('geodir_cat_schemas',array(
53
-            '' => __('Default (LocalBusiness)', 'geodirectory'),
54
-            'AccountingService' => 'AccountingService',
55
-            'Attorney' => 'Attorney',
56
-            'AutoBodyShop' => 'AutoBodyShop',
57
-            'AutoDealer' => 'AutoDealer',
58
-            'AutoPartsStore' => 'AutoPartsStore',
59
-            'AutoRental' => 'AutoRental',
60
-            'AutoRepair' => 'AutoRepair',
61
-            'AutoWash' => 'AutoWash',
62
-            'Bakery' => 'Bakery',
63
-            'BarOrPub' => 'BarOrPub',
64
-            'BeautySalon' => 'BeautySalon',
65
-            'BedAndBreakfast' => 'BedAndBreakfast',
66
-            'BikeStore' => 'BikeStore',
67
-            'BookStore' => 'BookStore',
68
-            'CafeOrCoffeeShop' => 'CafeOrCoffeeShop',
69
-            'Campground' => 'Campground',
70
-            'ChildCare' => 'ChildCare',
71
-            'ClothingStore' => 'ClothingStore',
72
-            'ComputerStore' => 'ComputerStore',
73
-            'DaySpa' => 'DaySpa',
74
-            'Dentist' => 'Dentist',
75
-            'DryCleaningOrLaundry' => 'DryCleaningOrLaundry',
76
-            'Electrician' => 'Electrician',
77
-            'ElectronicsStore' => 'ElectronicsStore',
78
-            'EmergencyService' => 'EmergencyService',
79
-            'EntertainmentBusiness' => 'EntertainmentBusiness',
80
-            'Event' => 'Event',
81
-            'EventVenue' => 'EventVenue',
82
-            'ExerciseGym' => 'ExerciseGym',
83
-            'FinancialService' => 'FinancialService',
84
-            'Florist' => 'Florist',
85
-            'FoodEstablishment' => 'FoodEstablishment',
86
-            'FurnitureStore' => 'FurnitureStore',
87
-            'GardenStore' => 'GardenStore',
88
-            'GeneralContractor' => 'GeneralContractor',
89
-            'GolfCourse' => 'GolfCourse',
90
-            'HairSalon' => 'HairSalon',
91
-            'HardwareStore' => 'HardwareStore',
92
-            'HealthAndBeautyBusiness' => 'HealthAndBeautyBusiness',
93
-            'HobbyShop' => 'HobbyShop',
94
-            'HomeAndConstructionBusiness' => 'HomeAndConstructionBusiness',
95
-            'HomeGoodsStore' => 'HomeGoodsStore',
96
-            'Hospital' => 'Hospital',
97
-            'Hostel' => 'Hostel',
98
-            'Hotel' => 'Hotel',
99
-            'HousePainter' => 'HousePainter',
100
-            'HVACBusiness' => 'HVACBusiness',
101
-            'InsuranceAgency' => 'InsuranceAgency',
102
-            'JewelryStore' => 'JewelryStore',
103
-            'LiquorStore' => 'LiquorStore',
104
-            'Locksmith' => 'Locksmith',
105
-            'LodgingBusiness' => 'LodgingBusiness',
106
-            'MedicalClinic' => 'MedicalClinic',
107
-            'MensClothingStore' => 'MensClothingStore',
108
-            'MobilePhoneStore' => 'MobilePhoneStore',
109
-            'Motel' => 'Motel',
110
-            'MotorcycleDealer' => 'MotorcycleDealer',
111
-            'MotorcycleRepair' => 'MotorcycleRepair',
112
-            'MovingCompany' => 'MovingCompany',
113
-            'MusicStore' => 'MusicStore',
114
-            'NailSalon' => 'NailSalon',
115
-            'NightClub' => 'NightClub',
116
-            'Notary' => 'Notary',
117
-            'OfficeEquipmentStore' => 'OfficeEquipmentStore',
118
-            'Optician' => 'Optician',
119
-            'PetStore' => 'PetStore',
120
-            'Physician' => 'Physician',
121
-            'Plumber' => 'Plumber',
122
-            'ProfessionalService' => 'ProfessionalService',
123
-            'RealEstateAgent' => 'RealEstateAgent',
124
-            'Residence' => 'Residence',
125
-            'Restaurant' => 'Restaurant',
126
-            'RoofingContractor' => 'RoofingContractor',
127
-            'RVPark' => 'RVPark',
128
-            'School' => 'School',
129
-            'SelfStorage' => 'SelfStorage',
130
-            'ShoeStore' => 'ShoeStore',
131
-            'SkiResort' => 'SkiResort',
132
-            'SportingGoodsStore' => 'SportingGoodsStore',
133
-            'SportsClub' => 'SportsClub',
134
-            'Store' => 'Store',
135
-            'TattooParlor' => 'TattooParlor',
136
-            'Taxi' => 'Taxi',
137
-            'TennisComplex' => 'TennisComplex',
138
-            'TireShop' => 'TireShop',
139
-            'TouristAttraction' => 'TouristAttraction',
140
-            'ToyStore' => 'ToyStore',
141
-            'TravelAgency' => 'TravelAgency',
142
-            //'VacationRentals' => 'VacationRentals', // Not recognised by google yet
143
-            'VeterinaryCare' => 'VeterinaryCare',
144
-            'WholesaleStore' => 'WholesaleStore',
145
-            'Winery' => 'Winery'
146
-        )),
147
-        array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory') . "", 'std' => array('selectkey2')));
148
-
149
-    /*$my_meta->addSelect($prefix.'cat_sort',array(''=>__('Default' , 'geodirectory'),
52
+		apply_filters('geodir_cat_schemas',array(
53
+			'' => __('Default (LocalBusiness)', 'geodirectory'),
54
+			'AccountingService' => 'AccountingService',
55
+			'Attorney' => 'Attorney',
56
+			'AutoBodyShop' => 'AutoBodyShop',
57
+			'AutoDealer' => 'AutoDealer',
58
+			'AutoPartsStore' => 'AutoPartsStore',
59
+			'AutoRental' => 'AutoRental',
60
+			'AutoRepair' => 'AutoRepair',
61
+			'AutoWash' => 'AutoWash',
62
+			'Bakery' => 'Bakery',
63
+			'BarOrPub' => 'BarOrPub',
64
+			'BeautySalon' => 'BeautySalon',
65
+			'BedAndBreakfast' => 'BedAndBreakfast',
66
+			'BikeStore' => 'BikeStore',
67
+			'BookStore' => 'BookStore',
68
+			'CafeOrCoffeeShop' => 'CafeOrCoffeeShop',
69
+			'Campground' => 'Campground',
70
+			'ChildCare' => 'ChildCare',
71
+			'ClothingStore' => 'ClothingStore',
72
+			'ComputerStore' => 'ComputerStore',
73
+			'DaySpa' => 'DaySpa',
74
+			'Dentist' => 'Dentist',
75
+			'DryCleaningOrLaundry' => 'DryCleaningOrLaundry',
76
+			'Electrician' => 'Electrician',
77
+			'ElectronicsStore' => 'ElectronicsStore',
78
+			'EmergencyService' => 'EmergencyService',
79
+			'EntertainmentBusiness' => 'EntertainmentBusiness',
80
+			'Event' => 'Event',
81
+			'EventVenue' => 'EventVenue',
82
+			'ExerciseGym' => 'ExerciseGym',
83
+			'FinancialService' => 'FinancialService',
84
+			'Florist' => 'Florist',
85
+			'FoodEstablishment' => 'FoodEstablishment',
86
+			'FurnitureStore' => 'FurnitureStore',
87
+			'GardenStore' => 'GardenStore',
88
+			'GeneralContractor' => 'GeneralContractor',
89
+			'GolfCourse' => 'GolfCourse',
90
+			'HairSalon' => 'HairSalon',
91
+			'HardwareStore' => 'HardwareStore',
92
+			'HealthAndBeautyBusiness' => 'HealthAndBeautyBusiness',
93
+			'HobbyShop' => 'HobbyShop',
94
+			'HomeAndConstructionBusiness' => 'HomeAndConstructionBusiness',
95
+			'HomeGoodsStore' => 'HomeGoodsStore',
96
+			'Hospital' => 'Hospital',
97
+			'Hostel' => 'Hostel',
98
+			'Hotel' => 'Hotel',
99
+			'HousePainter' => 'HousePainter',
100
+			'HVACBusiness' => 'HVACBusiness',
101
+			'InsuranceAgency' => 'InsuranceAgency',
102
+			'JewelryStore' => 'JewelryStore',
103
+			'LiquorStore' => 'LiquorStore',
104
+			'Locksmith' => 'Locksmith',
105
+			'LodgingBusiness' => 'LodgingBusiness',
106
+			'MedicalClinic' => 'MedicalClinic',
107
+			'MensClothingStore' => 'MensClothingStore',
108
+			'MobilePhoneStore' => 'MobilePhoneStore',
109
+			'Motel' => 'Motel',
110
+			'MotorcycleDealer' => 'MotorcycleDealer',
111
+			'MotorcycleRepair' => 'MotorcycleRepair',
112
+			'MovingCompany' => 'MovingCompany',
113
+			'MusicStore' => 'MusicStore',
114
+			'NailSalon' => 'NailSalon',
115
+			'NightClub' => 'NightClub',
116
+			'Notary' => 'Notary',
117
+			'OfficeEquipmentStore' => 'OfficeEquipmentStore',
118
+			'Optician' => 'Optician',
119
+			'PetStore' => 'PetStore',
120
+			'Physician' => 'Physician',
121
+			'Plumber' => 'Plumber',
122
+			'ProfessionalService' => 'ProfessionalService',
123
+			'RealEstateAgent' => 'RealEstateAgent',
124
+			'Residence' => 'Residence',
125
+			'Restaurant' => 'Restaurant',
126
+			'RoofingContractor' => 'RoofingContractor',
127
+			'RVPark' => 'RVPark',
128
+			'School' => 'School',
129
+			'SelfStorage' => 'SelfStorage',
130
+			'ShoeStore' => 'ShoeStore',
131
+			'SkiResort' => 'SkiResort',
132
+			'SportingGoodsStore' => 'SportingGoodsStore',
133
+			'SportsClub' => 'SportsClub',
134
+			'Store' => 'Store',
135
+			'TattooParlor' => 'TattooParlor',
136
+			'Taxi' => 'Taxi',
137
+			'TennisComplex' => 'TennisComplex',
138
+			'TireShop' => 'TireShop',
139
+			'TouristAttraction' => 'TouristAttraction',
140
+			'ToyStore' => 'ToyStore',
141
+			'TravelAgency' => 'TravelAgency',
142
+			//'VacationRentals' => 'VacationRentals', // Not recognised by google yet
143
+			'VeterinaryCare' => 'VeterinaryCare',
144
+			'WholesaleStore' => 'WholesaleStore',
145
+			'Winery' => 'Winery'
146
+		)),
147
+		array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory') . "", 'std' => array('selectkey2')));
148
+
149
+	/*$my_meta->addSelect($prefix.'cat_sort',array(''=>__('Default' , 'geodirectory'),
150 150
     'random'=>__('Random','geodirectory'),
151 151
     'az'=>__('Alphabetical' , 'geodirectory'),
152 152
     'newest'=>__('Newest','geodirectory'),
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
     'low_review'=>__('Lowest Reviews','geodirectory')),
158 158
     array('name'=> __('Sort By','geodirectory'),'desc' => __('Select the default sort option.' ,'geodirectory'), 'std'=> array('selectkey2')));*/
159 159
 
160
-    // Show options for placecategories only
161
-    /*	if(isset($_REQUEST['taxonomy']) && in_array($_REQUEST['taxonomy'],$config['pages']) ){
160
+	// Show options for placecategories only
161
+	/*	if(isset($_REQUEST['taxonomy']) && in_array($_REQUEST['taxonomy'],$config['pages']) ){
162 162
         // Exclude sort options
163 163
         $my_meta->addCheckbox($prefix.'cat_exclude_rating',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory')));
164 164
         $my_meta->addCheckbox($prefix.'cat_exclude_reviews',array('name'=> __('<b>Exclude</b> Reviews sort option','geodirectory')));
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 
171 171
         }*/
172 172
 
173
-    //Finish Meta Box Declaration
174
-    $my_meta->Finish();
173
+	//Finish Meta Box Declaration
174
+	$my_meta->Finish();
175 175
 }
176 176
 
177 177
 
@@ -180,86 +180,86 @@  discard block
 block discarded – undo
180 180
 ##############################################################
181 181
 $gd_taxonomies = geodir_get_taxonomies();
182 182
 if (!empty($gd_taxonomies)) {
183
-    foreach ($gd_taxonomies as $gd_taxonomy) {
183
+	foreach ($gd_taxonomies as $gd_taxonomy) {
184 184
 
185
-        add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2);
186
-        add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3);
185
+		add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2);
186
+		add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3);
187 187
 
188
-    }
188
+	}
189 189
 }
190 190
 
191 191
 function addCat_column($columns)
192 192
 {
193
-    if (isset($columns['description']) && $posts = $columns['description']) {
194
-        unset($columns['description']);
195
-    }
196
-
197
-    $columns['cat_icon'] = 'Icon';
198
-    $columns['cat_default_img'] = __('Default Image', 'geodirectory');
199
-    $columns['cat_ID_num'] = __('Cat ID', 'geodirectory');
200
-    return $columns;
193
+	if (isset($columns['description']) && $posts = $columns['description']) {
194
+		unset($columns['description']);
195
+	}
196
+
197
+	$columns['cat_icon'] = 'Icon';
198
+	$columns['cat_default_img'] = __('Default Image', 'geodirectory');
199
+	$columns['cat_ID_num'] = __('Cat ID', 'geodirectory');
200
+	return $columns;
201 201
 }
202 202
 
203 203
 #############################################################
204 204
 function manage_category_custom_fields($deprecated, $column_name, $term_id)
205 205
 {
206
-    if ($column_name == 'cat_ID_num')
207
-        echo $term_id;
206
+	if ($column_name == 'cat_ID_num')
207
+		echo $term_id;
208 208
 
209
-    if ($column_name == 'cat_icon') {
210
-        $term_icon_url = geodir_get_tax_meta($term_id, 'ct_cat_icon');
209
+	if ($column_name == 'cat_icon') {
210
+		$term_icon_url = geodir_get_tax_meta($term_id, 'ct_cat_icon');
211 211
 
212
-        if ($term_icon_url != '') {
213
-            $file_info = pathinfo($term_icon_url['src']);
212
+		if ($term_icon_url != '') {
213
+			$file_info = pathinfo($term_icon_url['src']);
214 214
 
215
-            if (isset($file_info['dirname'] ) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
216
-                $sub_dir = $file_info['dirname'];
217
-            } else {
218
-                $sub_dir = '';
219
-            }
215
+			if (isset($file_info['dirname'] ) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
216
+				$sub_dir = $file_info['dirname'];
217
+			} else {
218
+				$sub_dir = '';
219
+			}
220 220
 
221
-            $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
222
-            $uploads_baseurl = $uploads['baseurl'];
223
-            $uploads_path = $uploads['path'];
221
+			$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
222
+			$uploads_baseurl = $uploads['baseurl'];
223
+			$uploads_path = $uploads['path'];
224 224
 
225
-            $file_name = $file_info['basename'];
225
+			$file_name = $file_info['basename'];
226 226
 
227
-            if (strpos($sub_dir, 'https://') !== false) {
228
-                $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
229
-            } else {
230
-                $uploads['baseurl'] = str_replace('https://', 'http://', $uploads['baseurl']);
231
-            }
232
-            $sub_dir = str_replace($uploads['baseurl'], '', $sub_dir);
227
+			if (strpos($sub_dir, 'https://') !== false) {
228
+				$uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']);
229
+			} else {
230
+				$uploads['baseurl'] = str_replace('https://', 'http://', $uploads['baseurl']);
231
+			}
232
+			$sub_dir = str_replace($uploads['baseurl'], '', $sub_dir);
233 233
 
234
-            $uploads_url = $uploads_baseurl . $sub_dir;
234
+			$uploads_url = $uploads_baseurl . $sub_dir;
235 235
 
236
-            $term_icon_url['src'] = $uploads_url . '/' . $file_name;
237
-            echo '<img src="' . $term_icon_url['src'] . '" />';
238
-        }
239
-    }
236
+			$term_icon_url['src'] = $uploads_url . '/' . $file_name;
237
+			echo '<img src="' . $term_icon_url['src'] . '" />';
238
+		}
239
+	}
240 240
 
241
-    if ($column_name == 'cat_default_img') {
242
-        $cat_default_img = geodir_get_tax_meta($term_id, 'ct_cat_default_img');
243
-        if ($cat_default_img != '')
244
-            echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>';
241
+	if ($column_name == 'cat_default_img') {
242
+		$cat_default_img = geodir_get_tax_meta($term_id, 'ct_cat_default_img');
243
+		if ($cat_default_img != '')
244
+			echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>';
245 245
 
246
-    }
246
+	}
247 247
 }
248 248
 
249 249
 function geodir_get_default_catimage($term_id, $post_type = 'gd_place')
250 250
 {
251 251
 
252
-    if ($cat_default_img = geodir_get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type))
253
-        return $cat_default_img;
254
-    else
255
-        return false;
252
+	if ($cat_default_img = geodir_get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type))
253
+		return $cat_default_img;
254
+	else
255
+		return false;
256 256
 }
257 257
 
258 258
 //Clear custom fields
259 259
 add_action('in_admin_footer', 'geodir_tax_meta_clear_custom_field');
260 260
 function geodir_tax_meta_clear_custom_field() {
261
-    if (isset($_REQUEST['taxonomy']) && !empty($_REQUEST['taxonomy'])):
262
-        ?>
261
+	if (isset($_REQUEST['taxonomy']) && !empty($_REQUEST['taxonomy'])):
262
+		?>
263 263
         <script type="text/javascript">
264 264
             jQuery(document).ready(function () {
265 265
                 jQuery('#addtag #submit').click(function () {
@@ -288,5 +288,5 @@  discard block
 block discarded – undo
288 288
             });
289 289
         </script>
290 290
     <?php
291
-    endif;
291
+	endif;
292 292
 }
Please login to merge, or discard this patch.
geodirectory_template_tags.php 1 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('geodirectory-googlemap-script', '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('geodirectory-googlemap-script', '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,flash,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,flash,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_shortcodes.php 1 patch
Indentation   +899 added lines, -899 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,243 +264,243 @@  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 ( function_exists( 'icl_object_id' ) ) {
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
-        }
480
-        if (empty($mapview)) {
481
-            $mapview = 'ROADMAP';
482
-        }
483
-        // Set default map options
484
-        $map_args['ajax_url'] = geodir_get_ajax_url();
485
-        $map_args['latitude'] = $map_default_lat;
486
-        $map_args['longitude'] = $map_default_lng;
487
-        $map_args['streetViewControl'] = true;
488
-        $map_args['maptype'] = $mapview;
489
-        $map_args['showPreview'] = '0';
490
-        $map_args['maxZoom'] = 21;
491
-        $map_args['bubble_size'] = 'small';
492
-
493
-        // Add marker cluster
494
-        if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) {
495
-            $map_args['enable_marker_cluster'] = true;
496
-        } else {
497
-            $map_args['enable_marker_cluster'] = false;
498
-        }
499
-        geodir_draw_map($map_args);
500
-        $output = ob_get_contents();
501
-        ob_end_clean();
502
-        return $output;
503
-    }
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 ( function_exists( 'icl_object_id' ) ) {
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
+		}
480
+		if (empty($mapview)) {
481
+			$mapview = 'ROADMAP';
482
+		}
483
+		// Set default map options
484
+		$map_args['ajax_url'] = geodir_get_ajax_url();
485
+		$map_args['latitude'] = $map_default_lat;
486
+		$map_args['longitude'] = $map_default_lng;
487
+		$map_args['streetViewControl'] = true;
488
+		$map_args['maptype'] = $mapview;
489
+		$map_args['showPreview'] = '0';
490
+		$map_args['maxZoom'] = 21;
491
+		$map_args['bubble_size'] = 'small';
492
+
493
+		// Add marker cluster
494
+		if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) {
495
+			$map_args['enable_marker_cluster'] = true;
496
+		} else {
497
+			$map_args['enable_marker_cluster'] = false;
498
+		}
499
+		geodir_draw_map($map_args);
500
+		$output = ob_get_contents();
501
+		ob_end_clean();
502
+		return $output;
503
+	}
504 504
 }
505 505
 
506 506
 add_shortcode('gd_listing_slider', 'geodir_sc_listing_slider');
@@ -533,120 +533,120 @@  discard block
 block discarded – undo
533 533
  */
534 534
 function geodir_sc_listing_slider($atts)
535 535
 {
536
-    ob_start();
537
-    $defaults = array(
538
-        'post_type' => 'gd_place',
539
-        'category' => '0',
540
-        'post_number' => '5',
541
-        'slideshow' => '0',
542
-        'animation_loop' => 0,
543
-        'direction_nav' => 0,
544
-        'slideshow_speed' => 5000,
545
-        'animation_speed' => 600,
546
-        'animation' => 'slide',
547
-        'order_by' => 'latest',
548
-        'show_title' => '',
549
-        'show_featured_only' => '',
550
-        'title' => '',
551
-    );
552
-
553
-    $params = shortcode_atts($defaults, $atts);
554
-
555
-
556
-    /*
536
+	ob_start();
537
+	$defaults = array(
538
+		'post_type' => 'gd_place',
539
+		'category' => '0',
540
+		'post_number' => '5',
541
+		'slideshow' => '0',
542
+		'animation_loop' => 0,
543
+		'direction_nav' => 0,
544
+		'slideshow_speed' => 5000,
545
+		'animation_speed' => 600,
546
+		'animation' => 'slide',
547
+		'order_by' => 'latest',
548
+		'show_title' => '',
549
+		'show_featured_only' => '',
550
+		'title' => '',
551
+	);
552
+
553
+	$params = shortcode_atts($defaults, $atts);
554
+
555
+
556
+	/*
557 557
      *
558 558
      * Now we begin the validation of the attributes.
559 559
      */
560
-    // Check we have a valid post_type
561
-    if (!(gdsc_is_post_type_valid($params['post_type']))) {
562
-        $params['post_type'] = 'gd_place';
563
-    }
564
-
565
-    // Check we have a valid sort_order
566
-    $params['order_by'] = gdsc_validate_sort_choice($params['order_by']);
567
-
568
-    // Match the chosen animation to our options
569
-    $animation_list = array('slide', 'fade');
570
-    if (!(in_array($params['animation'], $animation_list))) {
571
-        $params['animation'] = 'slide';
572
-    }
573
-
574
-    // Post_number needs to be a positive integer
575
-    $params['post_number'] = absint($params['post_number']);
576
-    if (0 == $params['post_number']) {
577
-        $params['post_number'] = 1;
578
-    }
579
-
580
-    // Manage the entered categories
581
-    if (0 != $params['category'] || '' != $params['category']) {
582
-        $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']);
583
-    }
584
-    // Convert show_title to a bool
585
-    $params['show_title'] = intval(gdsc_to_bool_val($params['show_title']));
586
-
587
-    // Convert show_featured_only to a bool
588
-    $params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only']));
589
-
590
-    /*
560
+	// Check we have a valid post_type
561
+	if (!(gdsc_is_post_type_valid($params['post_type']))) {
562
+		$params['post_type'] = 'gd_place';
563
+	}
564
+
565
+	// Check we have a valid sort_order
566
+	$params['order_by'] = gdsc_validate_sort_choice($params['order_by']);
567
+
568
+	// Match the chosen animation to our options
569
+	$animation_list = array('slide', 'fade');
570
+	if (!(in_array($params['animation'], $animation_list))) {
571
+		$params['animation'] = 'slide';
572
+	}
573
+
574
+	// Post_number needs to be a positive integer
575
+	$params['post_number'] = absint($params['post_number']);
576
+	if (0 == $params['post_number']) {
577
+		$params['post_number'] = 1;
578
+	}
579
+
580
+	// Manage the entered categories
581
+	if (0 != $params['category'] || '' != $params['category']) {
582
+		$params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']);
583
+	}
584
+	// Convert show_title to a bool
585
+	$params['show_title'] = intval(gdsc_to_bool_val($params['show_title']));
586
+
587
+	// Convert show_featured_only to a bool
588
+	$params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only']));
589
+
590
+	/*
591 591
      * Hopefully all attributes are now valid, and safe to pass forward
592 592
      */
593 593
 
594
-    // redeclare vars after validation
595
-
596
-    if (isset($params['direction_nav'])) {
597
-        $params['directionNav'] = $params['direction_nav'];
598
-    }
599
-    if (isset($params['animation_loop'])) {
600
-        $params['animationLoop'] = $params['animation_loop'];
601
-    }
602
-    if (isset($params['slideshow_speed'])) {
603
-        $params['slideshowSpeed'] = $params['slideshow_speed'];
604
-    }
605
-    if (isset($params['animation_speed'])) {
606
-        $params['animationSpeed'] = $params['animation_speed'];
607
-    }
608
-    if (isset($params['order_by'])) {
609
-        $params['list_sort'] = $params['order_by'];
610
-    }
611
-
612
-    $query_args = array(
613
-        'post_number' => $params['post_number'],
614
-        'is_geodir_loop' => true,
615
-        'post_type' => $params['post_type'],
616
-        'order_by' => $params['order_by']
617
-    );
618
-
619
-    if (1 == $params['show_featured_only']) {
620
-        $query_args['show_featured_only'] = 1;
621
-    }
622
-
623
-    if (0 != $params['category'] && '' != $params['category']) {
624
-        $category_taxonomy = geodir_get_taxonomies($params['post_type']);
625
-        $tax_query = array(
626
-            'taxonomy' => $category_taxonomy[0],
627
-            'field' => 'id',
628
-            'terms' => $params['category'],
629
-        );
630
-
631
-        $query_args['tax_query'] = array($tax_query);
632
-    }
633
-
634
-    $defaults = array(
635
-        'before_widget' => '',
636
-        'after_widget' => '',
637
-        'before_title' => '',
638
-        'after_title' => '',
639
-    );
640
-
641
-    $query_args = array_merge($query_args, $params);
642
-
643
-    geodir_listing_slider_widget_output($defaults, $query_args);
644
-
645
-    $output = ob_get_contents();
646
-
647
-    ob_end_clean();
648
-
649
-    return $output;
594
+	// redeclare vars after validation
595
+
596
+	if (isset($params['direction_nav'])) {
597
+		$params['directionNav'] = $params['direction_nav'];
598
+	}
599
+	if (isset($params['animation_loop'])) {
600
+		$params['animationLoop'] = $params['animation_loop'];
601
+	}
602
+	if (isset($params['slideshow_speed'])) {
603
+		$params['slideshowSpeed'] = $params['slideshow_speed'];
604
+	}
605
+	if (isset($params['animation_speed'])) {
606
+		$params['animationSpeed'] = $params['animation_speed'];
607
+	}
608
+	if (isset($params['order_by'])) {
609
+		$params['list_sort'] = $params['order_by'];
610
+	}
611
+
612
+	$query_args = array(
613
+		'post_number' => $params['post_number'],
614
+		'is_geodir_loop' => true,
615
+		'post_type' => $params['post_type'],
616
+		'order_by' => $params['order_by']
617
+	);
618
+
619
+	if (1 == $params['show_featured_only']) {
620
+		$query_args['show_featured_only'] = 1;
621
+	}
622
+
623
+	if (0 != $params['category'] && '' != $params['category']) {
624
+		$category_taxonomy = geodir_get_taxonomies($params['post_type']);
625
+		$tax_query = array(
626
+			'taxonomy' => $category_taxonomy[0],
627
+			'field' => 'id',
628
+			'terms' => $params['category'],
629
+		);
630
+
631
+		$query_args['tax_query'] = array($tax_query);
632
+	}
633
+
634
+	$defaults = array(
635
+		'before_widget' => '',
636
+		'after_widget' => '',
637
+		'before_title' => '',
638
+		'after_title' => '',
639
+	);
640
+
641
+	$query_args = array_merge($query_args, $params);
642
+
643
+	geodir_listing_slider_widget_output($defaults, $query_args);
644
+
645
+	$output = ob_get_contents();
646
+
647
+	ob_end_clean();
648
+
649
+	return $output;
650 650
 }
651 651
 
652 652
 add_shortcode('gd_login_box', 'geodir_sc_login_box');
@@ -670,22 +670,22 @@  discard block
 block discarded – undo
670 670
  */
671 671
 function geodir_sc_login_box($atts)
672 672
 {
673
-    ob_start();
673
+	ob_start();
674 674
 
675
-    $defaults = array(
676
-        'before_widget' => '',
677
-        'after_widget' => '',
678
-        'before_title' => '',
679
-        'after_title' => '',
680
-    );
675
+	$defaults = array(
676
+		'before_widget' => '',
677
+		'after_widget' => '',
678
+		'before_title' => '',
679
+		'after_title' => '',
680
+	);
681 681
 
682
-    geodir_loginwidget_output($defaults, $defaults);
682
+	geodir_loginwidget_output($defaults, $defaults);
683 683
 
684
-    $output = ob_get_contents();
684
+	$output = ob_get_contents();
685 685
 
686
-    ob_end_clean();
686
+	ob_end_clean();
687 687
 
688
-    return $output;
688
+	return $output;
689 689
 }
690 690
 
691 691
 add_shortcode('gd_popular_post_category', 'geodir_sc_popular_post_category');
@@ -716,31 +716,31 @@  discard block
 block discarded – undo
716 716
  */
717 717
 function geodir_sc_popular_post_category($atts)
718 718
 {
719
-    ob_start();
720
-    global $geodir_post_category_str;
721
-    $defaults = array(
722
-        'category_limit' => 15,
723
-        'category_restrict' => false,
724
-        'before_widget' => '',
725
-        'after_widget' => '',
726
-        'before_title' => '',
727
-        'after_title' => '',
728
-        'title' => '',
729
-        'default_post_type' => '',
730
-        'parent_only' => false,
731
-    );
732
-
733
-    $params = shortcode_atts($defaults, $atts, 'popular_post_category');
734
-    $params['category_limit'] = absint($params['category_limit']);
735
-    $params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : '';
736
-    $params['parent_only'] = gdsc_to_bool_val($params['parent_only']);
737
-    geodir_popular_post_category_output($params, $params);
738
-
739
-    $output = ob_get_contents();
740
-
741
-    ob_end_clean();
742
-
743
-    return $output;
719
+	ob_start();
720
+	global $geodir_post_category_str;
721
+	$defaults = array(
722
+		'category_limit' => 15,
723
+		'category_restrict' => false,
724
+		'before_widget' => '',
725
+		'after_widget' => '',
726
+		'before_title' => '',
727
+		'after_title' => '',
728
+		'title' => '',
729
+		'default_post_type' => '',
730
+		'parent_only' => false,
731
+	);
732
+
733
+	$params = shortcode_atts($defaults, $atts, 'popular_post_category');
734
+	$params['category_limit'] = absint($params['category_limit']);
735
+	$params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : '';
736
+	$params['parent_only'] = gdsc_to_bool_val($params['parent_only']);
737
+	geodir_popular_post_category_output($params, $params);
738
+
739
+	$output = ob_get_contents();
740
+
741
+	ob_end_clean();
742
+
743
+	return $output;
744 744
 }
745 745
 
746 746
 add_shortcode('gd_popular_post_view', 'geodir_sc_popular_post_view');
@@ -783,98 +783,98 @@  discard block
 block discarded – undo
783 783
  */
784 784
 function geodir_sc_popular_post_view($atts)
785 785
 {
786
-    ob_start();
787
-    $defaults = array(
788
-        'post_type' => 'gd_place',
789
-        'category' => '0',
790
-        'post_number' => '5',
791
-        'layout' => 'gridview_onehalf',
792
-        'add_location_filter' => '0',
793
-        'list_sort' => 'latest',
794
-        'use_viewing_post_type' => '1',
795
-        'character_count' => '20',
796
-        'listing_width' => '',
797
-        'show_featured_only' => '0',
798
-        'show_special_only' => '0',
799
-        'with_pics_only' => '0',
800
-        'with_videos_only' => '0',
801
-        'hide_if_empty' => '0',
802
-        'before_widget' => '',
803
-        'after_widget' => '',
804
-        'before_title' => '<h3 class="widget-title">',
805
-        'after_title' => '</h3>',
806
-        'title' => '',
807
-        'category_title' => '',
808
-    );
809
-
810
-    $params = shortcode_atts($defaults, $atts);
811
-
812
-    /**
813
-     * Validate our incoming params
814
-     */
786
+	ob_start();
787
+	$defaults = array(
788
+		'post_type' => 'gd_place',
789
+		'category' => '0',
790
+		'post_number' => '5',
791
+		'layout' => 'gridview_onehalf',
792
+		'add_location_filter' => '0',
793
+		'list_sort' => 'latest',
794
+		'use_viewing_post_type' => '1',
795
+		'character_count' => '20',
796
+		'listing_width' => '',
797
+		'show_featured_only' => '0',
798
+		'show_special_only' => '0',
799
+		'with_pics_only' => '0',
800
+		'with_videos_only' => '0',
801
+		'hide_if_empty' => '0',
802
+		'before_widget' => '',
803
+		'after_widget' => '',
804
+		'before_title' => '<h3 class="widget-title">',
805
+		'after_title' => '</h3>',
806
+		'title' => '',
807
+		'category_title' => '',
808
+	);
815 809
 
816
-    // Validate the selected post type, default to gd_place on fail
817
-    if (!(gdsc_is_post_type_valid($params['post_type']))) {
818
-        $params['post_type'] = 'gd_place';
819
-    }
820
-
821
-    // Validate the selected category/ies - Grab the current list based on post_type
822
-    $category_taxonomy = geodir_get_taxonomies($params['post_type']);
823
-    $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids'));
824
-
825
-    // Make sure we have an array
826
-    if (!(is_array($params['category']))) {
827
-        $params['category'] = explode(',', $params['category']);
828
-    }
829
-
830
-    // Array_intersect returns only the items in $params['category'] that are also in our category list
831
-    // Otherwise it becomes empty and later on that will mean "All"
832
-    $params['category'] = array_intersect($params['category'], $categories);
833
-
834
-    // Post_number needs to be a positive integer
835
-    $params['post_number'] = absint($params['post_number']);
836
-    if (0 == $params['post_number']) {
837
-        $params['post_number'] = 1;
838
-    }
839
-
840
-    // Validate our layout choice
841
-    // Outside of the norm, I added some more simple terms to match the existing
842
-    // So now I just run the switch to set it properly.
843
-    $params['layout'] = gdsc_validate_layout_choice($params['layout']);
844
-
845
-    // Validate our sorting choice
846
-    $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']);
847
-
848
-    // Validate character_count
849
-    if ($params['character_count'] !== '') {
850
-        $params['character_count'] = absint($params['character_count']);
851
-    }
852
-
853
-    // Validate Listing width, used in the template widget-listing-listview.php
854
-    // The context is in width=$listing_width% - So we need a positive number between 0 & 100
855
-    $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']);
856
-
857
-    // Validate the checkboxes used on the widget
858
-    $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']);
859
-    $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']);
860
-    $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']);
861
-    $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']);
862
-    $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']);
863
-    $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']);
864
-    $params['hide_if_empty'] = gdsc_to_bool_val($params['hide_if_empty']);
865
-
866
-    /**
867
-     * End of validation
868
-     */
810
+	$params = shortcode_atts($defaults, $atts);
811
+
812
+	/**
813
+	 * Validate our incoming params
814
+	 */
815
+
816
+	// Validate the selected post type, default to gd_place on fail
817
+	if (!(gdsc_is_post_type_valid($params['post_type']))) {
818
+		$params['post_type'] = 'gd_place';
819
+	}
820
+
821
+	// Validate the selected category/ies - Grab the current list based on post_type
822
+	$category_taxonomy = geodir_get_taxonomies($params['post_type']);
823
+	$categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids'));
824
+
825
+	// Make sure we have an array
826
+	if (!(is_array($params['category']))) {
827
+		$params['category'] = explode(',', $params['category']);
828
+	}
869 829
 
870
-    geodir_popular_postview_output($params, $params);
830
+	// Array_intersect returns only the items in $params['category'] that are also in our category list
831
+	// Otherwise it becomes empty and later on that will mean "All"
832
+	$params['category'] = array_intersect($params['category'], $categories);
871 833
 
834
+	// Post_number needs to be a positive integer
835
+	$params['post_number'] = absint($params['post_number']);
836
+	if (0 == $params['post_number']) {
837
+		$params['post_number'] = 1;
838
+	}
839
+
840
+	// Validate our layout choice
841
+	// Outside of the norm, I added some more simple terms to match the existing
842
+	// So now I just run the switch to set it properly.
843
+	$params['layout'] = gdsc_validate_layout_choice($params['layout']);
844
+
845
+	// Validate our sorting choice
846
+	$params['list_sort'] = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']);
847
+
848
+	// Validate character_count
849
+	if ($params['character_count'] !== '') {
850
+		$params['character_count'] = absint($params['character_count']);
851
+	}
852
+
853
+	// Validate Listing width, used in the template widget-listing-listview.php
854
+	// The context is in width=$listing_width% - So we need a positive number between 0 & 100
855
+	$params['listing_width'] = gdsc_validate_listing_width($params['listing_width']);
872 856
 
873
-    $output = ob_get_contents();
857
+	// Validate the checkboxes used on the widget
858
+	$params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']);
859
+	$params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']);
860
+	$params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']);
861
+	$params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']);
862
+	$params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']);
863
+	$params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']);
864
+	$params['hide_if_empty'] = gdsc_to_bool_val($params['hide_if_empty']);
874 865
 
875
-    ob_end_clean();
866
+	/**
867
+	 * End of validation
868
+	 */
876 869
 
877
-    return $output;
870
+	geodir_popular_postview_output($params, $params);
871
+
872
+
873
+	$output = ob_get_contents();
874
+
875
+	ob_end_clean();
876
+
877
+	return $output;
878 878
 }
879 879
 
880 880
 add_shortcode('gd_recent_reviews', 'geodir_sc_recent_reviews');
@@ -896,37 +896,37 @@  discard block
 block discarded – undo
896 896
  * @return string Recent reviews HTML.
897 897
  */
898 898
 function geodir_sc_recent_reviews($atts) {
899
-    ob_start();
900
-    $defaults = array(
899
+	ob_start();
900
+	$defaults = array(
901 901
 		'title' => '',
902 902
 		'count' => 5,
903
-    );
903
+	);
904 904
 
905
-    $params = shortcode_atts($defaults, $atts);
905
+	$params = shortcode_atts($defaults, $atts);
906 906
 
907
-    $count = absint($params['count']);
908
-    if (0 == $count) {
909
-        $count = 1;
910
-    }
907
+	$count = absint($params['count']);
908
+	if (0 == $count) {
909
+		$count = 1;
910
+	}
911 911
 	
912 912
 	$title = !empty($params['title']) ? __($params['title'], 'geodirectory') : '';
913 913
 
914
-    $comments_li = geodir_get_recent_reviews(30, $count, 100, false);
914
+	$comments_li = geodir_get_recent_reviews(30, $count, 100, false);
915 915
 
916
-    if ($comments_li) {
917
-        if ($title != '') { ?>
916
+	if ($comments_li) {
917
+		if ($title != '') { ?>
918 918
 		<h3 class="geodir-sc-recent-reviews-title widget-title"><?php echo $title; ?></h3>
919 919
 		<?php } ?>
920 920
         <div class="geodir_sc_recent_reviews_section">
921 921
             <ul class="geodir_sc_recent_reviews"><?php echo $comments_li; ?></ul>
922 922
         </div>
923 923
     <?php
924
-    }
925
-    $output = ob_get_contents();
924
+	}
925
+	$output = ob_get_contents();
926 926
 
927
-    ob_end_clean();
927
+	ob_end_clean();
928 928
 
929
-    return $output;
929
+	return $output;
930 930
 }
931 931
 
932 932
 add_shortcode('gd_related_listings', 'geodir_sc_related_listings');
@@ -956,63 +956,63 @@  discard block
 block discarded – undo
956 956
  */
957 957
 function geodir_sc_related_listings($atts)
958 958
 {
959
-    ob_start();
960
-    $defaults = array(
961
-        'post_number' => 5,
962
-        'relate_to' => 'category',
963
-        'layout' => 'gridview_onehalf',
964
-        'add_location_filter' => 0,
965
-        'listing_width' => '',
966
-        'list_sort' => 'latest',
967
-        'character_count' => 20,
968
-        'is_widget' => 1,
969
-        'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>',
970
-    );
971
-    // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet.
972
-
973
-    $params = shortcode_atts($defaults, $atts);
974
-
975
-    /**
976
-     * Begin validating parameters
977
-     */
959
+	ob_start();
960
+	$defaults = array(
961
+		'post_number' => 5,
962
+		'relate_to' => 'category',
963
+		'layout' => 'gridview_onehalf',
964
+		'add_location_filter' => 0,
965
+		'listing_width' => '',
966
+		'list_sort' => 'latest',
967
+		'character_count' => 20,
968
+		'is_widget' => 1,
969
+		'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>',
970
+	);
971
+	// The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet.
978 972
 
979
-    // Validate that post_number is a number and is 1 or higher
980
-    $params['post_number'] = absint($params['post_number']);
981
-    if (0 === $params['post_number']) {
982
-        $params['post_number'] = 1;
983
-    }
973
+	$params = shortcode_atts($defaults, $atts);
984 974
 
985
-    // Validate relate_to - only category or tags
986
-    $params['relate_to'] = geodir_strtolower($params['relate_to']);
987
-    if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) {
988
-        $params['relate_to'] = 'category';
989
-    }
975
+	/**
976
+	 * Begin validating parameters
977
+	 */
990 978
 
991
-    // Validate layout selection
992
-    $params['layout'] = gdsc_validate_layout_choice($params['layout']);
979
+	// Validate that post_number is a number and is 1 or higher
980
+	$params['post_number'] = absint($params['post_number']);
981
+	if (0 === $params['post_number']) {
982
+		$params['post_number'] = 1;
983
+	}
993 984
 
994
-    // Validate sorting option
995
-    $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']);
985
+	// Validate relate_to - only category or tags
986
+	$params['relate_to'] = geodir_strtolower($params['relate_to']);
987
+	if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) {
988
+		$params['relate_to'] = 'category';
989
+	}
990
+
991
+	// Validate layout selection
992
+	$params['layout'] = gdsc_validate_layout_choice($params['layout']);
996 993
 
997
-    // Validate add_location_filter
998
-    $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']);
994
+	// Validate sorting option
995
+	$params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']);
999 996
 
1000
-    // Validate listing_width
1001
-    $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']);
997
+	// Validate add_location_filter
998
+	$params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']);
1002 999
 
1003
-    // Validate character_count
1004
-    if ($params['character_count'] !== '') {
1005
-        $params['character_count'] = absint($params['character_count']);
1006
-    }
1000
+	// Validate listing_width
1001
+	$params['listing_width'] = gdsc_validate_listing_width($params['listing_width']);
1007 1002
 
1008
-    if ($related_display = geodir_related_posts_display($params)) {
1009
-        echo $related_display;
1010
-    }
1011
-    $output = ob_get_contents();
1003
+	// Validate character_count
1004
+	if ($params['character_count'] !== '') {
1005
+		$params['character_count'] = absint($params['character_count']);
1006
+	}
1007
+
1008
+	if ($related_display = geodir_related_posts_display($params)) {
1009
+		echo $related_display;
1010
+	}
1011
+	$output = ob_get_contents();
1012 1012
 
1013
-    ob_end_clean();
1013
+	ob_end_clean();
1014 1014
 
1015
-    return $output;
1015
+	return $output;
1016 1016
 }
1017 1017
 
1018 1018
 /**
@@ -1036,13 +1036,13 @@  discard block
 block discarded – undo
1036 1036
  * @return string Advanced search widget HTML.
1037 1037
  */
1038 1038
 function geodir_sc_advanced_search($atts) {
1039
-    $defaults = array(
1039
+	$defaults = array(
1040 1040
 		'title' => '',
1041 1041
 		'before_widget' => '<section id="geodir_advanced_search-1" class="widget geodir-widget geodir_advance_search_widget">',
1042
-        'after_widget' => '</section>',
1043
-        'before_title' => '<h3 class="widget-title">',
1044
-        'after_title' => '</h3>',
1045
-        'show_adv_search' => 'default',
1042
+		'after_widget' => '</section>',
1043
+		'before_title' => '<h3 class="widget-title">',
1044
+		'after_title' => '</h3>',
1045
+		'show_adv_search' => 'default',
1046 1046
 		'post_type' => ''
1047 1047
 	);
1048 1048
 	
@@ -1066,9 +1066,9 @@  discard block
 block discarded – undo
1066 1066
 	the_widget('geodir_advance_search_widget', $params, $params );
1067 1067
 	
1068 1068
 	$output = ob_get_contents();
1069
-    ob_end_clean();
1069
+	ob_end_clean();
1070 1070
 
1071
-    return $output;
1071
+	return $output;
1072 1072
 }
1073 1073
 add_shortcode('gd_advanced_search', 'geodir_sc_advanced_search');
1074 1074
 
@@ -1114,48 +1114,48 @@  discard block
 block discarded – undo
1114 1114
 		'add_location_filter' => '1',
1115 1115
 		'tab_layout' => 'bestof-tabs-on-top',
1116 1116
 		'before_widget' => '<section id="bestof_widget-1" class="widget geodir-widget geodir_bestof_widget geodir_sc_bestof_widget">',
1117
-        'after_widget' => '</section>',
1118
-        'before_title' => '<h3 class="widget-title">',
1119
-        'after_title' => '</h3>',
1117
+		'after_widget' => '</section>',
1118
+		'before_title' => '<h3 class="widget-title">',
1119
+		'after_title' => '</h3>',
1120 1120
 	);
1121 1121
 	$params = shortcode_atts($defaults, $atts);
1122 1122
 
1123
-    /**
1124
-     * Validate our incoming params
1125
-     */
1123
+	/**
1124
+	 * Validate our incoming params
1125
+	 */
1126 1126
 
1127
-    // Validate the selected post type, default to gd_place on fail
1128
-    if (!(gdsc_is_post_type_valid($params['post_type']))) {
1129
-        $params['post_type'] = 'gd_place';
1130
-    }
1127
+	// Validate the selected post type, default to gd_place on fail
1128
+	if (!(gdsc_is_post_type_valid($params['post_type']))) {
1129
+		$params['post_type'] = 'gd_place';
1130
+	}
1131 1131
 	
1132 1132
 	// Post limit needs to be a positive integer
1133
-    $params['post_limit'] = absint($params['post_limit']);
1134
-    if (0 == $params['post_limit']) {
1135
-        $params['post_limit'] = 5;
1136
-    }
1133
+	$params['post_limit'] = absint($params['post_limit']);
1134
+	if (0 == $params['post_limit']) {
1135
+		$params['post_limit'] = 5;
1136
+	}
1137 1137
 	
1138 1138
 	// Category limit needs to be a positive integer
1139
-    $params['categ_limit'] = absint($params['categ_limit']);
1140
-    if (0 == $params['categ_limit']) {
1141
-        $params['categ_limit'] = 3;
1142
-    }
1139
+	$params['categ_limit'] = absint($params['categ_limit']);
1140
+	if (0 == $params['categ_limit']) {
1141
+		$params['categ_limit'] = 3;
1142
+	}
1143 1143
 	
1144 1144
 	// Tab layout validation
1145
-    $params['tab_layout'] = $params['tab_layout'];
1146
-    if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) {
1147
-        $params['tab_layout'] = 'bestof-tabs-on-top';
1148
-    }
1145
+	$params['tab_layout'] = $params['tab_layout'];
1146
+	if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) {
1147
+		$params['tab_layout'] = 'bestof-tabs-on-top';
1148
+	}
1149 1149
 	
1150 1150
 	// Validate character_count
1151
-    $params['character_count'] = $params['character_count'];
1151
+	$params['character_count'] = $params['character_count'];
1152 1152
 
1153 1153
 	ob_start();
1154 1154
 	the_widget('geodir_bestof_widget', $params, $params);
1155
-    $output = ob_get_contents();
1156
-    ob_end_clean();
1155
+	$output = ob_get_contents();
1156
+	ob_end_clean();
1157 1157
 
1158
-    return $output;
1158
+	return $output;
1159 1159
 }
1160 1160
 add_shortcode('gd_bestof_widget', 'geodir_sc_bestof_widget');
1161 1161
 
@@ -1208,152 +1208,152 @@  discard block
 block discarded – undo
1208 1208
  * @return string HTML content to display geodirectory listings.
1209 1209
  */
1210 1210
 function geodir_sc_gd_listings($atts, $content = '') {
1211
-    global $post;
1212
-    $defaults = array(
1213
-        'title'                 => '',
1214
-        'post_type'             => 'gd_place',
1215
-        'category'              => 0,
1216
-        'list_sort'             => 'latest',
1217
-        'event_type'            => '',
1218
-        'post_number'           => 10,
1219
-        'post_author'           => '',
1220
-        'layout'                => 'gridview_onehalf',
1221
-        'listing_width'         => '',
1222
-        'character_count'       => 20,
1223
-        'add_location_filter'   => 1,
1224
-        'show_featured_only'    => '',
1225
-        'show_special_only'     => '',
1226
-        'with_pics_only'        => '',
1227
-        'with_videos_only'      => '',
1228
-        'with_pagination'       => '1',
1229
-        'top_pagination'        => '0',
1230
-        'bottom_pagination'     => '1',
1231
-        'without_no_results'    => 0,
1232
-        'tags'                  => '',
1233
-        'show_favorites_only'   => '',
1234
-        'favorites_by_user'     => '',
1235
-    );
1236
-    $params = shortcode_atts($defaults, $atts);
1237
-
1238
-    $params['title']        = wp_strip_all_tags($params['title']);
1239
-    $params['post_type']    = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place';
1240
-
1241
-    // Validate the selected category/ies - Grab the current list based on post_type
1242
-    $category_taxonomy      = geodir_get_taxonomies($params['post_type']);
1243
-    $categories             = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids', 'hide_empty' => 0));
1244
-
1245
-    // Make sure we have an array
1246
-    if (!(is_array($params['category']))) {
1247
-        $params['category'] = explode(',', $params['category']);
1248
-    }
1249
-
1250
-    // Array_intersect returns only the items in $params['category'] that are also in our category list
1251
-    // Otherwise it becomes empty and later on that will mean "All"
1252
-    $params['category']     = array_intersect($params['category'], $categories);
1253
-
1254
-    // Post_number needs to be a positive integer
1255
-    $params['post_number']  = absint($params['post_number']);
1256
-    $params['post_number']  = $params['post_number'] > 0 ? $params['post_number'] : 10;
1211
+	global $post;
1212
+	$defaults = array(
1213
+		'title'                 => '',
1214
+		'post_type'             => 'gd_place',
1215
+		'category'              => 0,
1216
+		'list_sort'             => 'latest',
1217
+		'event_type'            => '',
1218
+		'post_number'           => 10,
1219
+		'post_author'           => '',
1220
+		'layout'                => 'gridview_onehalf',
1221
+		'listing_width'         => '',
1222
+		'character_count'       => 20,
1223
+		'add_location_filter'   => 1,
1224
+		'show_featured_only'    => '',
1225
+		'show_special_only'     => '',
1226
+		'with_pics_only'        => '',
1227
+		'with_videos_only'      => '',
1228
+		'with_pagination'       => '1',
1229
+		'top_pagination'        => '0',
1230
+		'bottom_pagination'     => '1',
1231
+		'without_no_results'    => 0,
1232
+		'tags'                  => '',
1233
+		'show_favorites_only'   => '',
1234
+		'favorites_by_user'     => '',
1235
+	);
1236
+	$params = shortcode_atts($defaults, $atts);
1237
+
1238
+	$params['title']        = wp_strip_all_tags($params['title']);
1239
+	$params['post_type']    = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place';
1240
+
1241
+	// Validate the selected category/ies - Grab the current list based on post_type
1242
+	$category_taxonomy      = geodir_get_taxonomies($params['post_type']);
1243
+	$categories             = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids', 'hide_empty' => 0));
1244
+
1245
+	// Make sure we have an array
1246
+	if (!(is_array($params['category']))) {
1247
+		$params['category'] = explode(',', $params['category']);
1248
+	}
1249
+
1250
+	// Array_intersect returns only the items in $params['category'] that are also in our category list
1251
+	// Otherwise it becomes empty and later on that will mean "All"
1252
+	$params['category']     = array_intersect($params['category'], $categories);
1253
+
1254
+	// Post_number needs to be a positive integer
1255
+	$params['post_number']  = absint($params['post_number']);
1256
+	$params['post_number']  = $params['post_number'] > 0 ? $params['post_number'] : 10;
1257 1257
     
1258
-    // Post_number needs to be a positive integer
1259
-    if (!empty($atts['post_author'])) {
1260
-
1261
-        // 'current' left for backwards compatibility
1262
-        if ( ($atts['post_author'] == 'current' || $atts['post_author'] == 'current_author') && !empty($post) && isset($post->post_author) && $post->post_type != 'page') {
1263
-            $params['post_author'] = $post->post_author;
1264
-        } else if ($atts['post_author'] == 'current_user' ) {
1265
-            if($uid = get_current_user_id()){
1266
-                $params['post_author'] = absint($uid);
1267
-            }else{
1268
-                $params['post_author'] = -1;// if not logged in then don't show any listings.
1269
-            }
1270
-
1271
-        } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) {
1272
-            $params['post_author'] = absint($atts['post_author']);
1273
-        } else {
1274
-            unset($params['post_author']);
1275
-        }
1276
-    } else {
1277
-        unset($params['post_author']);
1278
-    }
1279
-
1280
-    // Validate character_count
1281
-    //todo: is this necessary?
1282
-    $params['character_count']  = $params['character_count'];
1283
-
1284
-    // Validate our layout choice
1285
-    // Outside of the norm, I added some more simple terms to match the existing
1286
-    // So now I just run the switch to set it properly.
1287
-    $params['layout']           = gdsc_validate_layout_choice($params['layout']);
1288
-
1289
-    // Validate our sorting choice
1290
-    $params['list_sort']        = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']);
1291
-
1292
-    // Validate Listing width, used in the template widget-listing-listview.php
1293
-    // The context is in width=$listing_width% - So we need a positive number between 0 & 100
1294
-    $params['listing_width']    = gdsc_validate_listing_width($params['listing_width']);
1295
-
1296
-    // Validate the checkboxes used on the widget
1297
-    $params['add_location_filter']  = gdsc_to_bool_val($params['add_location_filter']);
1298
-    $params['show_featured_only']   = gdsc_to_bool_val($params['show_featured_only']);
1299
-    $params['show_special_only']    = gdsc_to_bool_val($params['show_special_only']);
1300
-    $params['with_pics_only']       = gdsc_to_bool_val($params['with_pics_only']);
1301
-    $params['with_videos_only']     = gdsc_to_bool_val($params['with_videos_only']);
1302
-    $params['with_pagination']      = gdsc_to_bool_val($params['with_pagination']);
1303
-    $params['top_pagination']       = gdsc_to_bool_val($params['top_pagination']);
1304
-    $params['bottom_pagination']    = gdsc_to_bool_val($params['bottom_pagination']);
1258
+	// Post_number needs to be a positive integer
1259
+	if (!empty($atts['post_author'])) {
1260
+
1261
+		// 'current' left for backwards compatibility
1262
+		if ( ($atts['post_author'] == 'current' || $atts['post_author'] == 'current_author') && !empty($post) && isset($post->post_author) && $post->post_type != 'page') {
1263
+			$params['post_author'] = $post->post_author;
1264
+		} else if ($atts['post_author'] == 'current_user' ) {
1265
+			if($uid = get_current_user_id()){
1266
+				$params['post_author'] = absint($uid);
1267
+			}else{
1268
+				$params['post_author'] = -1;// if not logged in then don't show any listings.
1269
+			}
1270
+
1271
+		} else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) {
1272
+			$params['post_author'] = absint($atts['post_author']);
1273
+		} else {
1274
+			unset($params['post_author']);
1275
+		}
1276
+	} else {
1277
+		unset($params['post_author']);
1278
+	}
1279
+
1280
+	// Validate character_count
1281
+	//todo: is this necessary?
1282
+	$params['character_count']  = $params['character_count'];
1283
+
1284
+	// Validate our layout choice
1285
+	// Outside of the norm, I added some more simple terms to match the existing
1286
+	// So now I just run the switch to set it properly.
1287
+	$params['layout']           = gdsc_validate_layout_choice($params['layout']);
1288
+
1289
+	// Validate our sorting choice
1290
+	$params['list_sort']        = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']);
1291
+
1292
+	// Validate Listing width, used in the template widget-listing-listview.php
1293
+	// The context is in width=$listing_width% - So we need a positive number between 0 & 100
1294
+	$params['listing_width']    = gdsc_validate_listing_width($params['listing_width']);
1295
+
1296
+	// Validate the checkboxes used on the widget
1297
+	$params['add_location_filter']  = gdsc_to_bool_val($params['add_location_filter']);
1298
+	$params['show_featured_only']   = gdsc_to_bool_val($params['show_featured_only']);
1299
+	$params['show_special_only']    = gdsc_to_bool_val($params['show_special_only']);
1300
+	$params['with_pics_only']       = gdsc_to_bool_val($params['with_pics_only']);
1301
+	$params['with_videos_only']     = gdsc_to_bool_val($params['with_videos_only']);
1302
+	$params['with_pagination']      = gdsc_to_bool_val($params['with_pagination']);
1303
+	$params['top_pagination']       = gdsc_to_bool_val($params['top_pagination']);
1304
+	$params['bottom_pagination']    = gdsc_to_bool_val($params['bottom_pagination']);
1305 1305
     
1306
-    // User favorites
1307
-    $params['show_favorites_only']  = gdsc_to_bool_val($params['show_favorites_only']);
1308
-    if (!empty($params['show_favorites_only'])) {
1309
-        if ($params['favorites_by_user'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') {
1310
-            $params['favorites_by_user'] = $post->post_author;
1311
-        } else if ($params['favorites_by_user'] != 'current' && absint($params['favorites_by_user']) > 0) {
1312
-            $params['favorites_by_user'] = absint($atts['favorites_by_user']);
1313
-        } else if ($params['favorites_by_user'] != 'current' && $current_user_id = get_current_user_id()) {
1314
-            $params['favorites_by_user'] = $current_user_id;
1315
-        } else {
1316
-            $params['favorites_by_user'] = 0;
1317
-        }
1318
-    }
1319
-
1320
-    // Clean tags
1321
-    if (!empty($params['tags'])) {
1322
-        if (!is_array($params['tags'])) {
1323
-            $comma = _x(',', 'tag delimiter');
1324
-            if ( ',' !== $comma ) {
1325
-                $params['tags'] = str_replace($comma, ',', $params['tags']);
1326
-            }
1327
-            $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,"));
1328
-            $params['tags'] = array_map('trim', $params['tags']);
1329
-        }
1330
-    } else {
1331
-        $params['tags'] = array();
1332
-    }
1333
-
1334
-    /**
1335
-     * End of validation
1336
-     */
1337
-    if (isset($atts['geodir_ajax'])) {
1338
-        $params['geodir_ajax'] = $atts['geodir_ajax'];
1339
-        unset($atts['geodir_ajax']);
1340
-    }
1341
-    if (isset($atts['pageno'])) {
1342
-        $params['pageno'] = $atts['pageno'];
1343
-        unset($atts['pageno']);
1344
-    }
1345
-
1346
-    if ( !empty($atts['shortcode_content']) ) {
1347
-        $content = $atts['shortcode_content'];
1348
-    }
1349
-    $params['shortcode_content'] = trim($content);
1350
-    $atts['shortcode_content'] = trim($content);
1306
+	// User favorites
1307
+	$params['show_favorites_only']  = gdsc_to_bool_val($params['show_favorites_only']);
1308
+	if (!empty($params['show_favorites_only'])) {
1309
+		if ($params['favorites_by_user'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') {
1310
+			$params['favorites_by_user'] = $post->post_author;
1311
+		} else if ($params['favorites_by_user'] != 'current' && absint($params['favorites_by_user']) > 0) {
1312
+			$params['favorites_by_user'] = absint($atts['favorites_by_user']);
1313
+		} else if ($params['favorites_by_user'] != 'current' && $current_user_id = get_current_user_id()) {
1314
+			$params['favorites_by_user'] = $current_user_id;
1315
+		} else {
1316
+			$params['favorites_by_user'] = 0;
1317
+		}
1318
+	}
1319
+
1320
+	// Clean tags
1321
+	if (!empty($params['tags'])) {
1322
+		if (!is_array($params['tags'])) {
1323
+			$comma = _x(',', 'tag delimiter');
1324
+			if ( ',' !== $comma ) {
1325
+				$params['tags'] = str_replace($comma, ',', $params['tags']);
1326
+			}
1327
+			$params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,"));
1328
+			$params['tags'] = array_map('trim', $params['tags']);
1329
+		}
1330
+	} else {
1331
+		$params['tags'] = array();
1332
+	}
1333
+
1334
+	/**
1335
+	 * End of validation
1336
+	 */
1337
+	if (isset($atts['geodir_ajax'])) {
1338
+		$params['geodir_ajax'] = $atts['geodir_ajax'];
1339
+		unset($atts['geodir_ajax']);
1340
+	}
1341
+	if (isset($atts['pageno'])) {
1342
+		$params['pageno'] = $atts['pageno'];
1343
+		unset($atts['pageno']);
1344
+	}
1345
+
1346
+	if ( !empty($atts['shortcode_content']) ) {
1347
+		$content = $atts['shortcode_content'];
1348
+	}
1349
+	$params['shortcode_content'] = trim($content);
1350
+	$atts['shortcode_content'] = trim($content);
1351 1351
     
1352
-    $params['shortcode_atts']       = $atts;
1352
+	$params['shortcode_atts']       = $atts;
1353 1353
 
1354
-    $output = geodir_sc_gd_listings_output($params);
1354
+	$output = geodir_sc_gd_listings_output($params);
1355 1355
 
1356
-    return $output;
1356
+	return $output;
1357 1357
 }
1358 1358
 add_shortcode('gd_listings', 'geodir_sc_gd_listings');
1359 1359
 
@@ -1393,56 +1393,56 @@  discard block
 block discarded – undo
1393 1393
  * @return string HTML content to display CPT categories.
1394 1394
  */
1395 1395
 function geodir_sc_cpt_categories_widget($atts, $content = '') {
1396
-    $defaults = array(
1397
-        'title' => '',
1398
-        'post_type' => '', // NULL for all
1399
-        'hide_empty' => '',
1400
-        'show_count' => '',
1401
-        'hide_icon' => '',
1402
-        'cpt_left' => '',
1403
-        'sort_by' => 'count',
1404
-        'max_count' => 'all',
1405
-        'max_level' => '1',
1406
-        'no_cpt_filter' => '',
1407
-        'no_cat_filter' => '',
1408
-        'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">',
1409
-        'after_widget' => '</section>',
1410
-        'before_title' => '<h3 class="widget-title">',
1411
-        'after_title' => '</h3>',
1412
-    );
1413
-    $params = shortcode_atts($defaults, $atts);
1414
-
1415
-    /**
1416
-     * Validate our incoming params
1417
-     */
1418
-    // Make sure we have an array
1419
-    $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array();
1420
-     
1421
-    // Validate the checkboxes used on the widget
1422
-    $params['hide_empty'] 	= gdsc_to_bool_val($params['hide_empty']);
1423
-    $params['show_count'] 	= gdsc_to_bool_val($params['show_count']);
1424
-    $params['hide_icon'] 	= gdsc_to_bool_val($params['hide_icon']);
1425
-    $params['cpt_left'] 	= gdsc_to_bool_val($params['cpt_left']);
1396
+	$defaults = array(
1397
+		'title' => '',
1398
+		'post_type' => '', // NULL for all
1399
+		'hide_empty' => '',
1400
+		'show_count' => '',
1401
+		'hide_icon' => '',
1402
+		'cpt_left' => '',
1403
+		'sort_by' => 'count',
1404
+		'max_count' => 'all',
1405
+		'max_level' => '1',
1406
+		'no_cpt_filter' => '',
1407
+		'no_cat_filter' => '',
1408
+		'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">',
1409
+		'after_widget' => '</section>',
1410
+		'before_title' => '<h3 class="widget-title">',
1411
+		'after_title' => '</h3>',
1412
+	);
1413
+	$params = shortcode_atts($defaults, $atts);
1426 1414
 
1427
-    if ($params['max_count'] != 'all') {
1428
-        $params['max_count'] = absint($params['max_count']);
1429
-    }
1415
+	/**
1416
+	 * Validate our incoming params
1417
+	 */
1418
+	// Make sure we have an array
1419
+	$params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array();
1420
+     
1421
+	// Validate the checkboxes used on the widget
1422
+	$params['hide_empty'] 	= gdsc_to_bool_val($params['hide_empty']);
1423
+	$params['show_count'] 	= gdsc_to_bool_val($params['show_count']);
1424
+	$params['hide_icon'] 	= gdsc_to_bool_val($params['hide_icon']);
1425
+	$params['cpt_left'] 	= gdsc_to_bool_val($params['cpt_left']);
1426
+
1427
+	if ($params['max_count'] != 'all') {
1428
+		$params['max_count'] = absint($params['max_count']);
1429
+	}
1430 1430
 
1431
-    if ($params['max_level'] != 'all') {
1432
-        $params['max_level'] = absint($params['max_level']);
1433
-    }
1431
+	if ($params['max_level'] != 'all') {
1432
+		$params['max_level'] = absint($params['max_level']);
1433
+	}
1434 1434
 
1435
-    $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']);
1436
-    $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']);
1435
+	$params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']);
1436
+	$params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']);
1437 1437
 
1438
-    $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count';
1438
+	$params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count';
1439 1439
 
1440
-    ob_start();
1441
-    the_widget('geodir_cpt_categories_widget', $params, $params);
1442
-    $output = ob_get_contents();
1443
-    ob_end_clean();
1440
+	ob_start();
1441
+	the_widget('geodir_cpt_categories_widget', $params, $params);
1442
+	$output = ob_get_contents();
1443
+	ob_end_clean();
1444 1444
 
1445
-    return $output;
1445
+	return $output;
1446 1446
 }
1447 1447
 add_shortcode('gd_cpt_categories', 'geodir_sc_cpt_categories_widget');
1448 1448
 
@@ -1457,6 +1457,6 @@  discard block
 block discarded – undo
1457 1457
  * @return string HTML code.
1458 1458
  */
1459 1459
 function geodir_sc_responsive_videos($atts, $content) {
1460
-    return '<div class="geodir-video-wrapper">'.$content.'</div>';
1460
+	return '<div class="geodir-video-wrapper">'.$content.'</div>';
1461 1461
 }
1462 1462
 add_shortcode('gd_video', 'geodir_sc_responsive_videos');
1463 1463
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/general_functions.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			break;
328 328
 		case 'preview':
329 329
 			if ( ( is_page() && get_query_var( 'page_id' ) == geodir_preview_page_id() ) && isset( $_REQUEST['listing_type'] )
330
-			     && in_array( $_REQUEST['listing_type'], geodir_get_posttypes() )
330
+				 && in_array( $_REQUEST['listing_type'], geodir_get_posttypes() )
331 331
 			) {
332 332
 				return true;
333 333
 			}
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 
529 529
 //check if homepage
530 530
 		if ( ! isset( $wp->query_vars['gd_is_geodir_page'] )
531
-		     && ! isset( $wp->query_vars['page_id'] )
532
-		     && ! isset( $wp->query_vars['pagename'] )
533
-		     && is_page_geodir_home()
531
+			 && ! isset( $wp->query_vars['page_id'] )
532
+			 && ! isset( $wp->query_vars['pagename'] )
533
+			 && is_page_geodir_home()
534 534
 		) {
535 535
 			$wp->query_vars['gd_is_geodir_page'] = true;
536 536
 		}
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 		$deltaLatitude  = deg2rad( (float) $point2['latitude'] - (float) $point1['latitude'] );
716 716
 		$deltaLongitude = deg2rad( (float) $point2['longitude'] - (float) $point1['longitude'] );
717 717
 		$a              = sin( $deltaLatitude / 2 ) * sin( $deltaLatitude / 2 ) +
718
-		                  cos( deg2rad( (float) $point1['latitude'] ) ) * cos( deg2rad( (float) $point2['latitude'] ) ) *
719
-		                  sin( $deltaLongitude / 2 ) * sin( $deltaLongitude / 2 );
718
+						  cos( deg2rad( (float) $point1['latitude'] ) ) * cos( deg2rad( (float) $point2['latitude'] ) ) *
719
+						  sin( $deltaLongitude / 2 ) * sin( $deltaLongitude / 2 );
720 720
 		$c              = 2 * atan2( sqrt( $a ), sqrt( 1 - $a ) );
721 721
 		$distance       = $earthMeanRadius * $c;
722 722
 
@@ -3856,10 +3856,10 @@  discard block
 block discarded – undo
3856 3856
 			$gridview_columns_widget = '';
3857 3857
 		}
3858 3858
 			/**
3859
-		 * Filter the widget listing listview template path.
3860
-		 *
3861
-		 * @since 1.0.0
3862
-		 */
3859
+			 * Filter the widget listing listview template path.
3860
+			 *
3861
+			 * @since 1.0.0
3862
+			 */
3863 3863
 		$template = apply_filters( "geodir_template_part-widget-listing-listview", geodir_locate_template( 'widget-listing-listview' ) );
3864 3864
 		if ( ! isset( $character_count ) ) {
3865 3865
 			/**
@@ -5241,7 +5241,7 @@  discard block
 block discarded – undo
5241 5241
  * @param string $name The name of the string which helps to know what's being translated.
5242 5242
  */
5243 5243
 function geodir_wpml_register_string( $string, $domain = 'geodirectory', $name = '' ) {
5244
-    do_action( 'wpml_register_single_string', $domain, $name, $string );
5244
+	do_action( 'wpml_register_single_string', $domain, $name, $string );
5245 5245
 }
5246 5246
 
5247 5247
 /**
@@ -5257,5 +5257,5 @@  discard block
 block discarded – undo
5257 5257
  * @return string The translated string.
5258 5258
  */
5259 5259
 function geodir_wpml_translate_string( $string, $domain = 'geodirectory', $name = '', $language_code = NULL ) {
5260
-    return apply_filters( 'wpml_translate_single_string', $string, $domain, $name, $language_code );
5260
+	return apply_filters( 'wpml_translate_single_string', $string, $domain, $name, $language_code );
5261 5261
 }
5262 5262
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-widgets/geodirectory_popular_widget.php 1 patch
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -14,83 +14,83 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class geodir_popular_post_category extends WP_Widget
16 16
 {
17
-    /**
18
-     * Register the popular post category widget.
19
-     *
20
-     * @since 1.0.0
21
-     * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
22
-     */
23
-    public function __construct() {
24
-        $widget_ops = array('classname' => 'geodir_popular_post_category', 'description' => __('GD > Popular Post Category', 'geodirectory'));
25
-        parent::__construct(
26
-            'popular_post_category', // Base ID
27
-            __('GD > Popular Post Category', 'geodirectory'), // Name
28
-            $widget_ops// Args
29
-        );
30
-    }
31
-
32
-    /**
33
-     * Front-end display content for popular post category widget.
34
-     *
35
-     * @since 1.0.0
36
-     * @since 1.5.1 Declare function public.
37
-     *
38
-     * @param array $args     Widget arguments.
39
-     * @param array $instance Saved values from database.
40
-     */
41
-    public function widget($args, $instance)
42
-    {
43
-        geodir_popular_post_category_output($args, $instance);
44
-    }
45
-
46
-    /**
47
-     * Sanitize popular post category widget form values as they are saved.
48
-     *
49
-     * @since 1.0.0
50
-     * @since 1.5.1 Declare function public.
51
-     * @since 1.5.1 Added default_post_type parameter.
52
-     * @since 1.6.9 Added parent_only parameter.
53
-     *
54
-     * @param array $new_instance Values just sent to be saved.
55
-     * @param array $old_instance Previously saved values from database.
56
-     *
57
-     * @return array Updated safe values to be saved.
58
-     */ 
59
-    public function update($new_instance, $old_instance)
60
-    {
61
-        //save the widget
62
-        $instance = $old_instance;
63
-        $instance['title'] = strip_tags($new_instance['title']);
64
-        $category_limit = (int)$new_instance['category_limit'];
65
-        $instance['category_limit'] = $category_limit > 0 ? $category_limit : 15;
66
-        $instance['default_post_type'] = isset($new_instance['default_post_type']) ? $new_instance['default_post_type'] : '';
67
-        $instance['parent_only'] = !empty($new_instance['parent_only']) ? true : false;
68
-        return $instance;
69
-    }
70
-
71
-    /**
72
-     * Back-end popular post category widget settings form.
73
-     *
74
-     * @since 1.0.0
75
-     * @since 1.5.1 Declare function public.
76
-     * @since 1.5.1 Added option to set default post type.
77
-     * @since 1.6.9 Added option to show parent categories only.
78
-     *
79
-     * @param array $instance Previously saved values from database.
80
-     */
81
-    public function form($instance) 
82
-    {
83
-        //widgetform in backend
84
-        $instance = wp_parse_args((array)$instance, array('title' => '', 'category_limit' => 15, 'default_post_type' => '', 'parent_only' => false));
85
-
86
-        $title = strip_tags($instance['title']);
87
-        $category_limit = (int)$instance['category_limit'];
88
-        $category_limit = $category_limit > 0 ? $category_limit : 15;
89
-        $default_post_type = isset($instance['default_post_type']) ? $instance['default_post_type'] : '';
90
-        $parent_only = !empty($instance['parent_only']) ? true: false;
17
+	/**
18
+	 * Register the popular post category widget.
19
+	 *
20
+	 * @since 1.0.0
21
+	 * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
22
+	 */
23
+	public function __construct() {
24
+		$widget_ops = array('classname' => 'geodir_popular_post_category', 'description' => __('GD > Popular Post Category', 'geodirectory'));
25
+		parent::__construct(
26
+			'popular_post_category', // Base ID
27
+			__('GD > Popular Post Category', 'geodirectory'), // Name
28
+			$widget_ops// Args
29
+		);
30
+	}
31
+
32
+	/**
33
+	 * Front-end display content for popular post category widget.
34
+	 *
35
+	 * @since 1.0.0
36
+	 * @since 1.5.1 Declare function public.
37
+	 *
38
+	 * @param array $args     Widget arguments.
39
+	 * @param array $instance Saved values from database.
40
+	 */
41
+	public function widget($args, $instance)
42
+	{
43
+		geodir_popular_post_category_output($args, $instance);
44
+	}
45
+
46
+	/**
47
+	 * Sanitize popular post category widget form values as they are saved.
48
+	 *
49
+	 * @since 1.0.0
50
+	 * @since 1.5.1 Declare function public.
51
+	 * @since 1.5.1 Added default_post_type parameter.
52
+	 * @since 1.6.9 Added parent_only parameter.
53
+	 *
54
+	 * @param array $new_instance Values just sent to be saved.
55
+	 * @param array $old_instance Previously saved values from database.
56
+	 *
57
+	 * @return array Updated safe values to be saved.
58
+	 */ 
59
+	public function update($new_instance, $old_instance)
60
+	{
61
+		//save the widget
62
+		$instance = $old_instance;
63
+		$instance['title'] = strip_tags($new_instance['title']);
64
+		$category_limit = (int)$new_instance['category_limit'];
65
+		$instance['category_limit'] = $category_limit > 0 ? $category_limit : 15;
66
+		$instance['default_post_type'] = isset($new_instance['default_post_type']) ? $new_instance['default_post_type'] : '';
67
+		$instance['parent_only'] = !empty($new_instance['parent_only']) ? true : false;
68
+		return $instance;
69
+	}
70
+
71
+	/**
72
+	 * Back-end popular post category widget settings form.
73
+	 *
74
+	 * @since 1.0.0
75
+	 * @since 1.5.1 Declare function public.
76
+	 * @since 1.5.1 Added option to set default post type.
77
+	 * @since 1.6.9 Added option to show parent categories only.
78
+	 *
79
+	 * @param array $instance Previously saved values from database.
80
+	 */
81
+	public function form($instance) 
82
+	{
83
+		//widgetform in backend
84
+		$instance = wp_parse_args((array)$instance, array('title' => '', 'category_limit' => 15, 'default_post_type' => '', 'parent_only' => false));
85
+
86
+		$title = strip_tags($instance['title']);
87
+		$category_limit = (int)$instance['category_limit'];
88
+		$category_limit = $category_limit > 0 ? $category_limit : 15;
89
+		$default_post_type = isset($instance['default_post_type']) ? $instance['default_post_type'] : '';
90
+		$parent_only = !empty($instance['parent_only']) ? true: false;
91 91
         
92
-        $post_type_options = geodir_get_posttypes('options');
93
-        ?>
92
+		$post_type_options = geodir_get_posttypes('options');
93
+		?>
94 94
         <p>
95 95
             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory'); ?>
96 96
                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>"/>
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             <label for="<?php echo $this->get_field_id('parent_only'); ?>"><?php _e( 'Show parent categories only', 'geodirectory' ); ?></label>
117 117
         </p>
118 118
     <?php
119
-    }
119
+	}
120 120
 } // class geodir_popular_post_category
121 121
 
122 122
 register_widget('geodir_popular_post_category');
@@ -130,40 +130,40 @@  discard block
 block discarded – undo
130 130
 class geodir_popular_postview extends WP_Widget
131 131
 {
132 132
 
133
-    /**
133
+	/**
134 134
 	 * Register the popular posts widget.
135 135
 	 *
136 136
 	 * @since 1.0.0
137
-     * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
137
+	 * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
138 138
 	 */
139
-    public function __construct() {
140
-        $widget_ops = array('classname' => 'geodir_popular_post_view', 'description' => __('GD > Popular Post View', 'geodirectory'));
141
-        parent::__construct(
142
-            'popular_post_view', // Base ID
143
-            __('GD > Popular Post View', 'geodirectory'), // Name
144
-            $widget_ops// Args
145
-        );
146
-    }
139
+	public function __construct() {
140
+		$widget_ops = array('classname' => 'geodir_popular_post_view', 'description' => __('GD > Popular Post View', 'geodirectory'));
141
+		parent::__construct(
142
+			'popular_post_view', // Base ID
143
+			__('GD > Popular Post View', 'geodirectory'), // Name
144
+			$widget_ops// Args
145
+		);
146
+	}
147 147
 
148 148
 	/**
149 149
 	 * Front-end display content for popular posts widget.
150 150
 	 *
151 151
 	 * @since 1.0.0
152
-     * @since 1.5.1 Declare function public.
152
+	 * @since 1.5.1 Declare function public.
153 153
 	 *
154 154
 	 * @param array $args     Widget arguments.
155 155
 	 * @param array $instance Saved values from database.
156 156
 	 */
157 157
 	public function widget($args, $instance)
158
-    {
159
-        geodir_popular_postview_output($args, $instance);
160
-    }
158
+	{
159
+		geodir_popular_postview_output($args, $instance);
160
+	}
161 161
 
162 162
 	/**
163 163
 	 * Sanitize popular posts widget form values as they are saved.
164 164
 	 *
165 165
 	 * @since 1.0.0
166
-     * @since 1.5.1 Declare function public.
166
+	 * @since 1.5.1 Declare function public.
167 167
 	 *
168 168
 	 * @param array $new_instance Values just sent to be saved.
169 169
 	 * @param array $old_instance Previously saved values from database.
@@ -171,102 +171,102 @@  discard block
 block discarded – undo
171 171
 	 * @return array Updated safe values to be saved.
172 172
 	 */
173 173
 	public function update($new_instance, $old_instance)
174
-    {
175
-        //save the widget
176
-        $instance = $old_instance;
177
-
178
-        if ($new_instance['title'] == '') {
179
-            $title = geodir_ucwords(strip_tags($new_instance['category_title']));
180
-            //$instance['title'] = $title;
181
-        }
182
-        $instance['title'] = strip_tags($new_instance['title']);
183
-
184
-        $instance['post_type'] = strip_tags($new_instance['post_type']);
185
-        //$instance['category'] = strip_tags($new_instance['category']);
186
-        $instance['category'] = isset($new_instance['category']) ? $new_instance['category'] : '';
187
-        $instance['category_title'] = strip_tags($new_instance['category_title']);
188
-        $instance['post_number'] = strip_tags($new_instance['post_number']);
189
-        $instance['layout'] = strip_tags($new_instance['layout']);
190
-        $instance['listing_width'] = strip_tags($new_instance['listing_width']);
191
-        $instance['list_sort'] = strip_tags($new_instance['list_sort']);
192
-        $instance['character_count'] = $new_instance['character_count'];
193
-        if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '')
194
-            $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']);
195
-        else
196
-            $instance['add_location_filter'] = '0';
197
-
198
-        $instance['show_featured_only'] = isset($new_instance['show_featured_only']) && $new_instance['show_featured_only'] ? 1 : 0;
199
-        $instance['show_special_only'] = isset($new_instance['show_special_only']) && $new_instance['show_special_only'] ? 1 : 0;
200
-        $instance['with_pics_only'] = isset($new_instance['with_pics_only']) && $new_instance['with_pics_only'] ? 1 : 0;
201
-        $instance['with_videos_only'] = isset($new_instance['with_videos_only']) && $new_instance['with_videos_only'] ? 1 : 0;
202
-        $instance['use_viewing_post_type'] = isset($new_instance['use_viewing_post_type']) && $new_instance['use_viewing_post_type'] ? 1 : 0;
203
-        $instance['hide_if_empty'] = !empty($new_instance['hide_if_empty']) ? 1 : 0;
204
-
205
-        return $instance;
206
-    }
174
+	{
175
+		//save the widget
176
+		$instance = $old_instance;
177
+
178
+		if ($new_instance['title'] == '') {
179
+			$title = geodir_ucwords(strip_tags($new_instance['category_title']));
180
+			//$instance['title'] = $title;
181
+		}
182
+		$instance['title'] = strip_tags($new_instance['title']);
183
+
184
+		$instance['post_type'] = strip_tags($new_instance['post_type']);
185
+		//$instance['category'] = strip_tags($new_instance['category']);
186
+		$instance['category'] = isset($new_instance['category']) ? $new_instance['category'] : '';
187
+		$instance['category_title'] = strip_tags($new_instance['category_title']);
188
+		$instance['post_number'] = strip_tags($new_instance['post_number']);
189
+		$instance['layout'] = strip_tags($new_instance['layout']);
190
+		$instance['listing_width'] = strip_tags($new_instance['listing_width']);
191
+		$instance['list_sort'] = strip_tags($new_instance['list_sort']);
192
+		$instance['character_count'] = $new_instance['character_count'];
193
+		if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '')
194
+			$instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']);
195
+		else
196
+			$instance['add_location_filter'] = '0';
197
+
198
+		$instance['show_featured_only'] = isset($new_instance['show_featured_only']) && $new_instance['show_featured_only'] ? 1 : 0;
199
+		$instance['show_special_only'] = isset($new_instance['show_special_only']) && $new_instance['show_special_only'] ? 1 : 0;
200
+		$instance['with_pics_only'] = isset($new_instance['with_pics_only']) && $new_instance['with_pics_only'] ? 1 : 0;
201
+		$instance['with_videos_only'] = isset($new_instance['with_videos_only']) && $new_instance['with_videos_only'] ? 1 : 0;
202
+		$instance['use_viewing_post_type'] = isset($new_instance['use_viewing_post_type']) && $new_instance['use_viewing_post_type'] ? 1 : 0;
203
+		$instance['hide_if_empty'] = !empty($new_instance['hide_if_empty']) ? 1 : 0;
204
+
205
+		return $instance;
206
+	}
207 207
 
208 208
 	/**
209 209
 	 * Back-end popular posts widget settings form.
210 210
 	 *
211 211
 	 * @since 1.0.0
212
-     * @since 1.5.1 Declare function public.
212
+	 * @since 1.5.1 Declare function public.
213 213
 	 *
214 214
 	 * @param array $instance Previously saved values from database.
215 215
 	 */
216 216
 	public function form($instance)
217
-    {
218
-        //widgetform in backend
219
-        $instance = wp_parse_args((array)$instance,
220
-            array('title' => '',
221
-                'post_type' => '',
222
-                'category' => array(),
223
-                'category_title' => '',
224
-                'list_sort' => '',
225
-                'list_order' => '',
226
-                'post_number' => '5',
227
-                'layout' => 'gridview_onehalf',
228
-                'listing_width' => '',
229
-                'add_location_filter' => '1',
230
-                'character_count' => '20',
231
-                'show_featured_only' => '',
232
-                'show_special_only' => '',
233
-                'with_pics_only' => '',
234
-                'with_videos_only' => '',
235
-                'use_viewing_post_type' => '',
236
-                'hide_if_empty' => ''
237
-            )
238
-        );
217
+	{
218
+		//widgetform in backend
219
+		$instance = wp_parse_args((array)$instance,
220
+			array('title' => '',
221
+				'post_type' => '',
222
+				'category' => array(),
223
+				'category_title' => '',
224
+				'list_sort' => '',
225
+				'list_order' => '',
226
+				'post_number' => '5',
227
+				'layout' => 'gridview_onehalf',
228
+				'listing_width' => '',
229
+				'add_location_filter' => '1',
230
+				'character_count' => '20',
231
+				'show_featured_only' => '',
232
+				'show_special_only' => '',
233
+				'with_pics_only' => '',
234
+				'with_videos_only' => '',
235
+				'use_viewing_post_type' => '',
236
+				'hide_if_empty' => ''
237
+			)
238
+		);
239 239
 
240
-        $title = strip_tags($instance['title']);
240
+		$title = strip_tags($instance['title']);
241 241
 
242
-        $post_type = strip_tags($instance['post_type']);
242
+		$post_type = strip_tags($instance['post_type']);
243 243
 
244
-        $category = $instance['category'];
244
+		$category = $instance['category'];
245 245
 
246
-        $category_title = strip_tags($instance['category_title']);
246
+		$category_title = strip_tags($instance['category_title']);
247 247
 
248
-        $list_sort = strip_tags($instance['list_sort']);
248
+		$list_sort = strip_tags($instance['list_sort']);
249 249
 
250
-        $list_order = strip_tags($instance['list_order']);
250
+		$list_order = strip_tags($instance['list_order']);
251 251
 
252
-        $post_number = strip_tags($instance['post_number']);
252
+		$post_number = strip_tags($instance['post_number']);
253 253
 
254
-        $layout = strip_tags($instance['layout']);
254
+		$layout = strip_tags($instance['layout']);
255 255
 
256
-        $listing_width = strip_tags($instance['listing_width']);
256
+		$listing_width = strip_tags($instance['listing_width']);
257 257
 
258
-        $add_location_filter = strip_tags($instance['add_location_filter']);
258
+		$add_location_filter = strip_tags($instance['add_location_filter']);
259 259
 
260
-        $character_count = $instance['character_count'];
260
+		$character_count = $instance['character_count'];
261 261
 
262
-        $show_featured_only = isset($instance['show_featured_only']) && $instance['show_featured_only'] ? true : false;
263
-        $show_special_only = isset($instance['show_special_only']) && $instance['show_special_only'] ? true : false;
264
-        $with_pics_only = isset($instance['with_pics_only']) && $instance['with_pics_only'] ? true : false;
265
-        $with_videos_only = isset($instance['with_videos_only']) && $instance['with_videos_only'] ? true : false;
266
-        $use_viewing_post_type = isset($instance['use_viewing_post_type']) && $instance['use_viewing_post_type'] ? true : false;
267
-        $hide_if_empty = !empty($instance['hide_if_empty']) ? true : false;
262
+		$show_featured_only = isset($instance['show_featured_only']) && $instance['show_featured_only'] ? true : false;
263
+		$show_special_only = isset($instance['show_special_only']) && $instance['show_special_only'] ? true : false;
264
+		$with_pics_only = isset($instance['with_pics_only']) && $instance['with_pics_only'] ? true : false;
265
+		$with_videos_only = isset($instance['with_videos_only']) && $instance['with_videos_only'] ? true : false;
266
+		$use_viewing_post_type = isset($instance['use_viewing_post_type']) && $instance['use_viewing_post_type'] ? true : false;
267
+		$hide_if_empty = !empty($instance['hide_if_empty']) ? true : false;
268 268
 
269
-        ?>
269
+		?>
270 270
         <p>
271 271
             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory');?>
272 272
                 <small>(%posttype_singular_label% ,
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
                     <?php foreach ($postypes as $postypes_obj) { ?>
301 301
 
302 302
                         <option <?php if ($post_type == $postypes_obj) {
303
-                            echo 'selected="selected"';
304
-                        } ?> value="<?php echo $postypes_obj; ?>"><?php $extvalue = explode('_', $postypes_obj);
305
-                            echo geodir_utf8_ucfirst($extvalue[1]); ?></option>
303
+							echo 'selected="selected"';
304
+						} ?> value="<?php echo $postypes_obj; ?>"><?php $extvalue = explode('_', $postypes_obj);
305
+							echo geodir_utf8_ucfirst($extvalue[1]); ?></option>
306 306
 
307 307
                     <?php } ?>
308 308
 
@@ -317,30 +317,30 @@  discard block
 block discarded – undo
317 317
 
318 318
                 <?php
319 319
 
320
-                $post_type = ($post_type != '') ? $post_type : 'gd_place';
320
+				$post_type = ($post_type != '') ? $post_type : 'gd_place';
321 321
 
322
-                $all_postypes = geodir_get_posttypes();
322
+				$all_postypes = geodir_get_posttypes();
323 323
 
324
-                if (!in_array($post_type, $all_postypes))
325
-                    $post_type = 'gd_place';
324
+				if (!in_array($post_type, $all_postypes))
325
+					$post_type = 'gd_place';
326 326
 
327
-                $category_taxonomy = geodir_get_taxonomies($post_type);
328
-                $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC'));
327
+				$category_taxonomy = geodir_get_taxonomies($post_type);
328
+				$categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC'));
329 329
 
330
-                ?>
330
+				?>
331 331
 
332 332
                 <select multiple="multiple" class="widefat" name="<?php echo $this->get_field_name('category'); ?>[]"
333 333
                         onchange="geodir_popular_widget_cat_title(this)">
334 334
 
335 335
                     <option <?php if (!is_array($category) || (is_array($category) && in_array('0', $category))) {
336
-                        echo 'selected="selected"';
337
-                    } ?> value="0"><?php _e('All', 'geodirectory'); ?></option>
336
+						echo 'selected="selected"';
337
+					} ?> value="0"><?php _e('All', 'geodirectory'); ?></option>
338 338
                     <?php foreach ($categories as $category_obj) {
339
-                        $selected = '';
340
-                        if (is_array($category) && in_array($category_obj->term_id, $category))
341
-                            echo $selected = 'selected="selected"';
339
+						$selected = '';
340
+						if (is_array($category) && in_array($category_obj->term_id, $category))
341
+							echo $selected = 'selected="selected"';
342 342
 
343
-                        ?>
343
+						?>
344 344
 
345 345
                         <option <?php echo $selected; ?>
346 346
                             value="<?php echo $category_obj->term_id; ?>"><?php echo geodir_utf8_ucfirst($category_obj->name); ?></option>
@@ -365,28 +365,28 @@  discard block
 block discarded – undo
365 365
                         name="<?php echo $this->get_field_name('list_sort'); ?>">
366 366
 
367 367
                     <option <?php if ($list_sort == 'az') {
368
-                        echo 'selected="selected"';
369
-                    } ?> value="az"><?php _e('A-Z', 'geodirectory'); ?></option>
368
+						echo 'selected="selected"';
369
+					} ?> value="az"><?php _e('A-Z', 'geodirectory'); ?></option>
370 370
 
371 371
                     <option <?php if ($list_sort == 'latest') {
372
-                        echo 'selected="selected"';
373
-                    } ?> value="latest"><?php _e('Latest', 'geodirectory'); ?></option>
372
+						echo 'selected="selected"';
373
+					} ?> value="latest"><?php _e('Latest', 'geodirectory'); ?></option>
374 374
 
375 375
                     <option <?php if ($list_sort == 'featured') {
376
-                        echo 'selected="selected"';
377
-                    } ?> value="featured"><?php _e('Featured', 'geodirectory'); ?></option>
376
+						echo 'selected="selected"';
377
+					} ?> value="featured"><?php _e('Featured', 'geodirectory'); ?></option>
378 378
 
379 379
                     <option <?php if ($list_sort == 'high_review') {
380
-                        echo 'selected="selected"';
381
-                    } ?> value="high_review"><?php _e('Review', 'geodirectory'); ?></option>
380
+						echo 'selected="selected"';
381
+					} ?> value="high_review"><?php _e('Review', 'geodirectory'); ?></option>
382 382
 
383 383
                     <option <?php if ($list_sort == 'high_rating') {
384
-                        echo 'selected="selected"';
385
-                    } ?> value="high_rating"><?php _e('Rating', 'geodirectory'); ?></option>
384
+						echo 'selected="selected"';
385
+					} ?> value="high_rating"><?php _e('Rating', 'geodirectory'); ?></option>
386 386
 
387 387
                     <option <?php if ($list_sort == 'random') {
388
-                        echo 'selected="selected"';
389
-                    } ?> value="random"><?php _e('Random', 'geodirectory'); ?></option>
388
+						echo 'selected="selected"';
389
+					} ?> value="random"><?php _e('Random', 'geodirectory'); ?></option>
390 390
 
391 391
                 </select>
392 392
             </label>
@@ -409,24 +409,24 @@  discard block
 block discarded – undo
409 409
                 <select class="widefat" id="<?php echo $this->get_field_id('layout'); ?>"
410 410
                         name="<?php echo $this->get_field_name('layout'); ?>">
411 411
                     <option <?php if ($layout == 'gridview_onehalf') {
412
-                        echo 'selected="selected"';
413
-                    } ?>
412
+						echo 'selected="selected"';
413
+					} ?>
414 414
                         value="gridview_onehalf"><?php _e('Grid View (Two Columns)', 'geodirectory'); ?></option>
415 415
                     <option <?php if ($layout == 'gridview_onethird') {
416
-                        echo 'selected="selected"';
417
-                    } ?>
416
+						echo 'selected="selected"';
417
+					} ?>
418 418
                         value="gridview_onethird"><?php _e('Grid View (Three Columns)', 'geodirectory'); ?></option>
419 419
                     <option <?php if ($layout == 'gridview_onefourth') {
420
-                        echo 'selected="selected"';
421
-                    } ?>
420
+						echo 'selected="selected"';
421
+					} ?>
422 422
                         value="gridview_onefourth"><?php _e('Grid View (Four Columns)', 'geodirectory'); ?></option>
423 423
                     <option <?php if ($layout == 'gridview_onefifth') {
424
-                        echo 'selected="selected"';
425
-                    } ?>
424
+						echo 'selected="selected"';
425
+					} ?>
426 426
                         value="gridview_onefifth"><?php _e('Grid View (Five Columns)', 'geodirectory'); ?></option>
427 427
                     <option <?php if ($layout == 'list') {
428
-                        echo 'selected="selected"';
429
-                    } ?> value="list"><?php _e('List view', 'geodirectory'); ?></option>
428
+						echo 'selected="selected"';
429
+					} ?> value="list"><?php _e('List view', 'geodirectory'); ?></option>
430 430
 
431 431
                 </select>
432 432
             </label>
@@ -496,8 +496,8 @@  discard block
 block discarded – undo
496 496
                 for="<?php echo $this->get_field_id('use_viewing_post_type'); ?>"><?php _e('Use current viewing post type:', 'geodirectory'); ?>
497 497
                 <input type="checkbox" id="<?php echo $this->get_field_id('use_viewing_post_type'); ?>"
498 498
                        name="<?php echo $this->get_field_name('use_viewing_post_type'); ?>" <?php if ($use_viewing_post_type) {
499
-                    echo 'checked="checked"';
500
-                } ?>  value="1"/>
499
+					echo 'checked="checked"';
500
+				} ?>  value="1"/>
501 501
             </label>
502 502
         </p>
503 503
         <p>
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
         </script>
546 546
 
547 547
     <?php
548
-    }
548
+	}
549 549
 } // class geodir_popular_postview
550 550
 
551 551
 register_widget('geodir_popular_postview');
552 552
\ No newline at end of file
Please login to merge, or discard this patch.