@@ -427,7 +427,7 @@ |
||
427 | 427 | } |
428 | 428 | |
429 | 429 | return $output; |
430 | - }else{ |
|
430 | + } else{ |
|
431 | 431 | ob_start(); |
432 | 432 | add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
433 | 433 | add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
@@ -7,7 +7,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
264 | 264 | */ |
265 | 265 | function geodir_sc_listing_map($atts) { |
266 | 266 | |
267 | - // if some params are set then we need a new query, if not then we can use the main query |
|
268 | - if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) { |
|
269 | - |
|
270 | - global $add_post_in_marker_array, $gd_sc_map_params; |
|
271 | - $backup_globals = array(); |
|
272 | - $backup_globals['add_post_in_marker_array'] = $add_post_in_marker_array; |
|
273 | - $backup_globals['gd_sc_map_params'] = $gd_sc_map_params; |
|
274 | - |
|
275 | - $defaults = array( |
|
276 | - 'width' => '294', |
|
277 | - 'height' => '370', |
|
278 | - 'zoom' => '13', |
|
279 | - 'autozoom' => '', |
|
280 | - 'sticky' => '', |
|
281 | - 'showall' => '0', |
|
282 | - 'scrollwheel' => '0', |
|
283 | - 'maptype' => 'ROADMAP', |
|
284 | - 'child_collapse' => 0, |
|
285 | - 'marker_cluster' => false, |
|
286 | - 'post_type' => 'gd_place', |
|
287 | - 'category' => '0', |
|
288 | - 'event_type' => 'all' |
|
289 | - ); |
|
290 | - |
|
291 | - $params = shortcode_atts( $defaults, $atts ); |
|
292 | - |
|
293 | - if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) { |
|
294 | - $params['post_type'] = 'gd_place'; |
|
295 | - } |
|
296 | - |
|
297 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
298 | - $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
299 | - $categories = get_terms( $category_taxonomy, array( |
|
300 | - 'orderby' => 'count', |
|
301 | - 'order' => 'DESC', |
|
302 | - 'fields' => 'ids' |
|
303 | - ) ); |
|
304 | - |
|
305 | - // Make sure we have an array |
|
306 | - if ( ! ( is_array( $params['category'] ) ) ) { |
|
307 | - $params['category'] = explode( ',', $params['category'] ); |
|
308 | - } |
|
309 | - |
|
310 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
311 | - // Otherwise it becomes empty and later on that will mean "All" |
|
312 | - $params['category'] = array_intersect( $params['category'], $categories ); |
|
313 | - |
|
314 | - if ( $params['post_type'] == 'gd_event' ) { |
|
315 | - $params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] ); |
|
316 | - } |
|
317 | - |
|
318 | - $params = gdsc_validate_map_args( $params ); |
|
319 | - |
|
320 | - $gd_sc_map_params = $params; |
|
321 | - |
|
322 | - $query_args = array( |
|
323 | - 'posts_per_page' => 1000000, //@todo kiran why was this added? |
|
324 | - 'is_geodir_loop' => true, |
|
325 | - 'gd_location' => false, |
|
326 | - 'post_type' => $params['post_type'], |
|
327 | - ); |
|
328 | - |
|
329 | - if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) { |
|
330 | - $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
331 | - |
|
332 | - ######### WPML ######### |
|
333 | - if ( geodir_wpml_is_taxonomy_translated( $category_taxonomy[0] ) ) { |
|
334 | - $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
335 | - } |
|
336 | - ######### WPML ######### |
|
337 | - |
|
338 | - $tax_query = array( |
|
339 | - 'taxonomy' => $category_taxonomy[0], |
|
340 | - 'field' => 'id', |
|
341 | - 'terms' => $params['category'] |
|
342 | - ); |
|
343 | - |
|
344 | - $query_args['tax_query'] = array( $tax_query ); |
|
345 | - } |
|
346 | - |
|
347 | - $add_post_in_marker_array = true; |
|
348 | - |
|
349 | - if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) { |
|
350 | - global $geodir_event_widget_listview; |
|
351 | - $geodir_event_widget_listview = true; |
|
352 | - |
|
353 | - $query_args['geodir_event_type'] = $params['event_type']; |
|
354 | - |
|
355 | - $listings = geodir_event_get_widget_events( $query_args ); |
|
356 | - |
|
357 | - $geodir_event_widget_listview = false; |
|
358 | - } else { |
|
359 | - $listings = geodir_get_widget_listings( $query_args ); |
|
360 | - } |
|
361 | - |
|
362 | - if ( ! empty( $listings ) ) { |
|
363 | - foreach ( $listings as $listing ) { |
|
364 | - create_marker_jason_of_posts( $listing ); |
|
365 | - } |
|
366 | - } |
|
367 | - |
|
368 | - ob_start(); |
|
369 | - add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array |
|
370 | - |
|
371 | - add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array |
|
372 | - |
|
373 | - add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers |
|
374 | - |
|
375 | - $default_location = geodir_get_default_location(); |
|
376 | - |
|
377 | - $map_args = array( |
|
378 | - 'map_canvas_name' => 'gd_listing_map', |
|
379 | - 'width' => $params['width'], |
|
380 | - 'height' => $params['height'], |
|
381 | - 'zoom' => $params['zoom'], |
|
382 | - 'autozoom' => $params['autozoom'], |
|
383 | - 'sticky' => $params['sticky'], |
|
384 | - 'showall' => $params['showall'], |
|
385 | - 'scrollwheel' => $params['scrollwheel'], |
|
386 | - 'maptype' => $params['maptype'], |
|
387 | - 'child_collapse' => 0, |
|
388 | - 'enable_cat_filters' => false, |
|
389 | - 'enable_text_search' => false, |
|
390 | - 'enable_post_type_filters' => false, |
|
391 | - 'enable_location_filters' => false, |
|
392 | - 'enable_jason_on_load' => true, |
|
393 | - 'ajax_url' => geodir_get_ajax_url(), |
|
394 | - 'latitude' => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '', |
|
395 | - 'longitude' => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '', |
|
396 | - 'streetViewControl' => true, |
|
397 | - 'showPreview' => '0', |
|
398 | - 'maxZoom' => 21, |
|
399 | - 'bubble_size' => 'small', |
|
400 | - ); |
|
401 | - |
|
402 | - if ( is_single() ) { |
|
403 | - global $post; |
|
404 | - if ( isset( $post->post_latitude ) ) { |
|
405 | - $map_args['latitude'] = $post->post_latitude; |
|
406 | - $map_args['longitude'] = $post->post_longitude; |
|
407 | - } |
|
408 | - |
|
409 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
410 | - } else { |
|
411 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
412 | - } |
|
413 | - |
|
414 | - // Add marker cluster |
|
415 | - if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) { |
|
416 | - $map_args['enable_marker_cluster'] = true; |
|
417 | - } else { |
|
418 | - $map_args['enable_marker_cluster'] = false; |
|
419 | - } |
|
420 | - |
|
421 | - geodir_draw_map( $map_args ); |
|
422 | - |
|
423 | - $output = ob_get_contents(); |
|
424 | - |
|
425 | - ob_end_clean(); |
|
426 | - |
|
427 | - foreach ( $backup_globals as $global => $value ) { |
|
428 | - ${$global} = $value; |
|
429 | - } |
|
430 | - |
|
431 | - return $output; |
|
432 | - }else{ |
|
433 | - ob_start(); |
|
434 | - add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
435 | - add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
436 | - add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
437 | - $defaults = array( |
|
438 | - 'width' => '294', |
|
439 | - 'height' => '370', |
|
440 | - 'zoom' => '13', |
|
441 | - 'autozoom' => '', |
|
442 | - 'sticky' => '', |
|
443 | - 'showall' => '0', |
|
444 | - 'scrollwheel' => '0', |
|
445 | - 'maptype' => 'ROADMAP', |
|
446 | - 'child_collapse' => 0, |
|
447 | - 'marker_cluster' => false |
|
448 | - ); |
|
449 | - $params = shortcode_atts($defaults, $atts); |
|
450 | - $params = gdsc_validate_map_args($params); |
|
451 | - $map_args = array( |
|
452 | - 'map_canvas_name' => 'gd_listing_map', |
|
453 | - 'width' => $params['width'], |
|
454 | - 'height' => $params['height'], |
|
455 | - 'zoom' => $params['zoom'], |
|
456 | - 'autozoom' => $params['autozoom'], |
|
457 | - 'sticky' => $params['sticky'], |
|
458 | - 'showall' => $params['showall'], |
|
459 | - 'scrollwheel' => $params['scrollwheel'], |
|
460 | - 'child_collapse' => 0, |
|
461 | - 'enable_cat_filters' => false, |
|
462 | - 'enable_text_search' => false, |
|
463 | - 'enable_post_type_filters' => false, |
|
464 | - 'enable_location_filters' => false, |
|
465 | - 'enable_jason_on_load' => true, |
|
466 | - ); |
|
467 | - if (is_single()) { |
|
468 | - global $post; |
|
469 | - $map_default_lat = $address_latitude = $post->post_latitude; |
|
470 | - $map_default_lng = $address_longitude = $post->post_longitude; |
|
471 | - $mapview = $post->post_mapview; |
|
472 | - $map_args['zoom'] = $post->post_mapzoom; |
|
473 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
474 | - } else { |
|
475 | - $default_location = geodir_get_default_location(); |
|
476 | - $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
477 | - $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
478 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
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 ( geodir_wpml_is_taxonomy_translated( $category_taxonomy[0] ) ) { |
|
334 | + $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
335 | + } |
|
336 | + ######### WPML ######### |
|
337 | + |
|
338 | + $tax_query = array( |
|
339 | + 'taxonomy' => $category_taxonomy[0], |
|
340 | + 'field' => 'id', |
|
341 | + 'terms' => $params['category'] |
|
342 | + ); |
|
343 | + |
|
344 | + $query_args['tax_query'] = array( $tax_query ); |
|
345 | + } |
|
346 | + |
|
347 | + $add_post_in_marker_array = true; |
|
348 | + |
|
349 | + if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) { |
|
350 | + global $geodir_event_widget_listview; |
|
351 | + $geodir_event_widget_listview = true; |
|
352 | + |
|
353 | + $query_args['geodir_event_type'] = $params['event_type']; |
|
354 | + |
|
355 | + $listings = geodir_event_get_widget_events( $query_args ); |
|
356 | + |
|
357 | + $geodir_event_widget_listview = false; |
|
358 | + } else { |
|
359 | + $listings = geodir_get_widget_listings( $query_args ); |
|
360 | + } |
|
361 | + |
|
362 | + if ( ! empty( $listings ) ) { |
|
363 | + foreach ( $listings as $listing ) { |
|
364 | + create_marker_jason_of_posts( $listing ); |
|
365 | + } |
|
366 | + } |
|
367 | + |
|
368 | + ob_start(); |
|
369 | + add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array |
|
370 | + |
|
371 | + add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array |
|
372 | + |
|
373 | + add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers |
|
374 | + |
|
375 | + $default_location = geodir_get_default_location(); |
|
376 | + |
|
377 | + $map_args = array( |
|
378 | + 'map_canvas_name' => 'gd_listing_map', |
|
379 | + 'width' => $params['width'], |
|
380 | + 'height' => $params['height'], |
|
381 | + 'zoom' => $params['zoom'], |
|
382 | + 'autozoom' => $params['autozoom'], |
|
383 | + 'sticky' => $params['sticky'], |
|
384 | + 'showall' => $params['showall'], |
|
385 | + 'scrollwheel' => $params['scrollwheel'], |
|
386 | + 'maptype' => $params['maptype'], |
|
387 | + 'child_collapse' => 0, |
|
388 | + 'enable_cat_filters' => false, |
|
389 | + 'enable_text_search' => false, |
|
390 | + 'enable_post_type_filters' => false, |
|
391 | + 'enable_location_filters' => false, |
|
392 | + 'enable_jason_on_load' => true, |
|
393 | + 'ajax_url' => geodir_get_ajax_url(), |
|
394 | + 'latitude' => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '', |
|
395 | + 'longitude' => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '', |
|
396 | + 'streetViewControl' => true, |
|
397 | + 'showPreview' => '0', |
|
398 | + 'maxZoom' => 21, |
|
399 | + 'bubble_size' => 'small', |
|
400 | + ); |
|
401 | + |
|
402 | + if ( is_single() ) { |
|
403 | + global $post; |
|
404 | + if ( isset( $post->post_latitude ) ) { |
|
405 | + $map_args['latitude'] = $post->post_latitude; |
|
406 | + $map_args['longitude'] = $post->post_longitude; |
|
407 | + } |
|
408 | + |
|
409 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
410 | + } else { |
|
411 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
412 | + } |
|
413 | + |
|
414 | + // Add marker cluster |
|
415 | + if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) { |
|
416 | + $map_args['enable_marker_cluster'] = true; |
|
417 | + } else { |
|
418 | + $map_args['enable_marker_cluster'] = false; |
|
419 | + } |
|
420 | + |
|
421 | + geodir_draw_map( $map_args ); |
|
422 | + |
|
423 | + $output = ob_get_contents(); |
|
424 | + |
|
425 | + ob_end_clean(); |
|
426 | + |
|
427 | + foreach ( $backup_globals as $global => $value ) { |
|
428 | + ${$global} = $value; |
|
429 | + } |
|
430 | + |
|
431 | + return $output; |
|
432 | + }else{ |
|
433 | + ob_start(); |
|
434 | + add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
435 | + add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
436 | + add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
437 | + $defaults = array( |
|
438 | + 'width' => '294', |
|
439 | + 'height' => '370', |
|
440 | + 'zoom' => '13', |
|
441 | + 'autozoom' => '', |
|
442 | + 'sticky' => '', |
|
443 | + 'showall' => '0', |
|
444 | + 'scrollwheel' => '0', |
|
445 | + 'maptype' => 'ROADMAP', |
|
446 | + 'child_collapse' => 0, |
|
447 | + 'marker_cluster' => false |
|
448 | + ); |
|
449 | + $params = shortcode_atts($defaults, $atts); |
|
450 | + $params = gdsc_validate_map_args($params); |
|
451 | + $map_args = array( |
|
452 | + 'map_canvas_name' => 'gd_listing_map', |
|
453 | + 'width' => $params['width'], |
|
454 | + 'height' => $params['height'], |
|
455 | + 'zoom' => $params['zoom'], |
|
456 | + 'autozoom' => $params['autozoom'], |
|
457 | + 'sticky' => $params['sticky'], |
|
458 | + 'showall' => $params['showall'], |
|
459 | + 'scrollwheel' => $params['scrollwheel'], |
|
460 | + 'child_collapse' => 0, |
|
461 | + 'enable_cat_filters' => false, |
|
462 | + 'enable_text_search' => false, |
|
463 | + 'enable_post_type_filters' => false, |
|
464 | + 'enable_location_filters' => false, |
|
465 | + 'enable_jason_on_load' => true, |
|
466 | + ); |
|
467 | + if (is_single()) { |
|
468 | + global $post; |
|
469 | + $map_default_lat = $address_latitude = $post->post_latitude; |
|
470 | + $map_default_lng = $address_longitude = $post->post_longitude; |
|
471 | + $mapview = $post->post_mapview; |
|
472 | + $map_args['zoom'] = $post->post_mapzoom; |
|
473 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
474 | + } else { |
|
475 | + $default_location = geodir_get_default_location(); |
|
476 | + $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
477 | + $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
478 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
479 | + } |
|
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,162 +1208,162 @@ discard block |
||
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($params['post_author'])) { |
|
1260 | - // 'current' left for backwards compatibility |
|
1261 | - if ( $params['post_author'] == 'current' || $params['post_author'] == 'current_author') { |
|
1262 | - if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
|
1263 | - $params['post_author'] = $post->post_author; |
|
1264 | - } else { |
|
1265 | - $params['post_author'] = -1; // Don't show any listings. |
|
1266 | - } |
|
1267 | - } else if ($params['post_author'] == 'current_user' ) { |
|
1268 | - if ($current_user_id = get_current_user_id()) { |
|
1269 | - $params['post_author'] = $current_user_id; |
|
1270 | - } else { |
|
1271 | - $params['post_author'] = -1; // If not logged in then don't show any listings. |
|
1272 | - } |
|
1273 | - } else if (absint($params['post_author']) > 0) { |
|
1274 | - $params['post_author'] = absint($params['post_author']); |
|
1275 | - } else { |
|
1276 | - $params['post_author'] = -1; // Don't show any listings. |
|
1277 | - } |
|
1278 | - } else { |
|
1279 | - unset($params['post_author']); |
|
1280 | - } |
|
1281 | - |
|
1282 | - // Validate character_count |
|
1283 | - //todo: is this necessary? |
|
1284 | - $params['character_count'] = $params['character_count']; |
|
1285 | - |
|
1286 | - // Validate our layout choice |
|
1287 | - // Outside of the norm, I added some more simple terms to match the existing |
|
1288 | - // So now I just run the switch to set it properly. |
|
1289 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1290 | - |
|
1291 | - // Validate our sorting choice |
|
1292 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']); |
|
1293 | - |
|
1294 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
1295 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
1296 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1297 | - |
|
1298 | - // Validate the checkboxes used on the widget |
|
1299 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1300 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
1301 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
1302 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
1303 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
1304 | - $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
1305 | - $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
1306 | - $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
1258 | + // Post_number needs to be a positive integer |
|
1259 | + if (!empty($params['post_author'])) { |
|
1260 | + // 'current' left for backwards compatibility |
|
1261 | + if ( $params['post_author'] == 'current' || $params['post_author'] == 'current_author') { |
|
1262 | + if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
|
1263 | + $params['post_author'] = $post->post_author; |
|
1264 | + } else { |
|
1265 | + $params['post_author'] = -1; // Don't show any listings. |
|
1266 | + } |
|
1267 | + } else if ($params['post_author'] == 'current_user' ) { |
|
1268 | + if ($current_user_id = get_current_user_id()) { |
|
1269 | + $params['post_author'] = $current_user_id; |
|
1270 | + } else { |
|
1271 | + $params['post_author'] = -1; // If not logged in then don't show any listings. |
|
1272 | + } |
|
1273 | + } else if (absint($params['post_author']) > 0) { |
|
1274 | + $params['post_author'] = absint($params['post_author']); |
|
1275 | + } else { |
|
1276 | + $params['post_author'] = -1; // Don't show any listings. |
|
1277 | + } |
|
1278 | + } else { |
|
1279 | + unset($params['post_author']); |
|
1280 | + } |
|
1281 | + |
|
1282 | + // Validate character_count |
|
1283 | + //todo: is this necessary? |
|
1284 | + $params['character_count'] = $params['character_count']; |
|
1285 | + |
|
1286 | + // Validate our layout choice |
|
1287 | + // Outside of the norm, I added some more simple terms to match the existing |
|
1288 | + // So now I just run the switch to set it properly. |
|
1289 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1290 | + |
|
1291 | + // Validate our sorting choice |
|
1292 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']); |
|
1293 | + |
|
1294 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
1295 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
1296 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1297 | + |
|
1298 | + // Validate the checkboxes used on the widget |
|
1299 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1300 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
1301 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
1302 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
1303 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
1304 | + $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
1305 | + $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
1306 | + $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
1307 | 1307 | |
1308 | - // User favorites |
|
1309 | - $params['show_favorites_only'] = gdsc_to_bool_val($params['show_favorites_only']); |
|
1310 | - if (!empty($params['show_favorites_only'])) { |
|
1311 | - if ( $params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') { |
|
1312 | - if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
|
1313 | - $params['favorites_by_user'] = $post->post_author; |
|
1314 | - } else { |
|
1315 | - $params['favorites_by_user'] = 0; |
|
1316 | - } |
|
1317 | - } else if ($params['favorites_by_user'] == 'current_user' || empty($params['favorites_by_user'])) { |
|
1318 | - if ($current_user_id = get_current_user_id()) { |
|
1319 | - $params['favorites_by_user'] = $current_user_id; |
|
1320 | - } else { |
|
1321 | - $params['favorites_by_user'] = 0; |
|
1322 | - } |
|
1323 | - } else if (absint($params['favorites_by_user']) > 0) { |
|
1324 | - $params['favorites_by_user'] = absint($params['favorites_by_user']); |
|
1325 | - } else { |
|
1326 | - $params['favorites_by_user'] = 0; |
|
1327 | - } |
|
1328 | - } |
|
1329 | - |
|
1330 | - // Clean tags |
|
1331 | - if (!empty($params['tags'])) { |
|
1332 | - if (!is_array($params['tags'])) { |
|
1333 | - $comma = _x(',', 'tag delimiter'); |
|
1334 | - if ( ',' !== $comma ) { |
|
1335 | - $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
1336 | - } |
|
1337 | - $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
1338 | - $params['tags'] = array_map('trim', $params['tags']); |
|
1339 | - } |
|
1340 | - } else { |
|
1341 | - $params['tags'] = array(); |
|
1342 | - } |
|
1343 | - |
|
1344 | - /** |
|
1345 | - * End of validation |
|
1346 | - */ |
|
1347 | - if (isset($atts['geodir_ajax'])) { |
|
1348 | - $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
1349 | - unset($atts['geodir_ajax']); |
|
1350 | - } |
|
1351 | - if (isset($atts['pageno'])) { |
|
1352 | - $params['pageno'] = $atts['pageno']; |
|
1353 | - unset($atts['pageno']); |
|
1354 | - } |
|
1355 | - |
|
1356 | - if ( !empty($atts['shortcode_content']) ) { |
|
1357 | - $content = $atts['shortcode_content']; |
|
1358 | - } |
|
1359 | - $params['shortcode_content'] = trim($content); |
|
1360 | - $atts['shortcode_content'] = trim($content); |
|
1308 | + // User favorites |
|
1309 | + $params['show_favorites_only'] = gdsc_to_bool_val($params['show_favorites_only']); |
|
1310 | + if (!empty($params['show_favorites_only'])) { |
|
1311 | + if ( $params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') { |
|
1312 | + if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
|
1313 | + $params['favorites_by_user'] = $post->post_author; |
|
1314 | + } else { |
|
1315 | + $params['favorites_by_user'] = 0; |
|
1316 | + } |
|
1317 | + } else if ($params['favorites_by_user'] == 'current_user' || empty($params['favorites_by_user'])) { |
|
1318 | + if ($current_user_id = get_current_user_id()) { |
|
1319 | + $params['favorites_by_user'] = $current_user_id; |
|
1320 | + } else { |
|
1321 | + $params['favorites_by_user'] = 0; |
|
1322 | + } |
|
1323 | + } else if (absint($params['favorites_by_user']) > 0) { |
|
1324 | + $params['favorites_by_user'] = absint($params['favorites_by_user']); |
|
1325 | + } else { |
|
1326 | + $params['favorites_by_user'] = 0; |
|
1327 | + } |
|
1328 | + } |
|
1329 | + |
|
1330 | + // Clean tags |
|
1331 | + if (!empty($params['tags'])) { |
|
1332 | + if (!is_array($params['tags'])) { |
|
1333 | + $comma = _x(',', 'tag delimiter'); |
|
1334 | + if ( ',' !== $comma ) { |
|
1335 | + $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
1336 | + } |
|
1337 | + $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
1338 | + $params['tags'] = array_map('trim', $params['tags']); |
|
1339 | + } |
|
1340 | + } else { |
|
1341 | + $params['tags'] = array(); |
|
1342 | + } |
|
1343 | + |
|
1344 | + /** |
|
1345 | + * End of validation |
|
1346 | + */ |
|
1347 | + if (isset($atts['geodir_ajax'])) { |
|
1348 | + $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
1349 | + unset($atts['geodir_ajax']); |
|
1350 | + } |
|
1351 | + if (isset($atts['pageno'])) { |
|
1352 | + $params['pageno'] = $atts['pageno']; |
|
1353 | + unset($atts['pageno']); |
|
1354 | + } |
|
1355 | + |
|
1356 | + if ( !empty($atts['shortcode_content']) ) { |
|
1357 | + $content = $atts['shortcode_content']; |
|
1358 | + } |
|
1359 | + $params['shortcode_content'] = trim($content); |
|
1360 | + $atts['shortcode_content'] = trim($content); |
|
1361 | 1361 | |
1362 | - $params['shortcode_atts'] = $atts; |
|
1362 | + $params['shortcode_atts'] = $atts; |
|
1363 | 1363 | |
1364 | - $output = geodir_sc_gd_listings_output($params); |
|
1364 | + $output = geodir_sc_gd_listings_output($params); |
|
1365 | 1365 | |
1366 | - return $output; |
|
1366 | + return $output; |
|
1367 | 1367 | } |
1368 | 1368 | add_shortcode('gd_listings', 'geodir_sc_gd_listings'); |
1369 | 1369 | |
@@ -1403,56 +1403,56 @@ discard block |
||
1403 | 1403 | * @return string HTML content to display CPT categories. |
1404 | 1404 | */ |
1405 | 1405 | function geodir_sc_cpt_categories_widget($atts, $content = '') { |
1406 | - $defaults = array( |
|
1407 | - 'title' => '', |
|
1408 | - 'post_type' => '', // NULL for all |
|
1409 | - 'hide_empty' => '', |
|
1410 | - 'show_count' => '', |
|
1411 | - 'hide_icon' => '', |
|
1412 | - 'cpt_left' => '', |
|
1413 | - 'sort_by' => 'count', |
|
1414 | - 'max_count' => 'all', |
|
1415 | - 'max_level' => '1', |
|
1416 | - 'no_cpt_filter' => '', |
|
1417 | - 'no_cat_filter' => '', |
|
1418 | - 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
1419 | - 'after_widget' => '</section>', |
|
1420 | - 'before_title' => '<h3 class="widget-title">', |
|
1421 | - 'after_title' => '</h3>', |
|
1422 | - ); |
|
1423 | - $params = shortcode_atts($defaults, $atts); |
|
1424 | - |
|
1425 | - /** |
|
1426 | - * Validate our incoming params |
|
1427 | - */ |
|
1428 | - // Make sure we have an array |
|
1429 | - $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
1430 | - |
|
1431 | - // Validate the checkboxes used on the widget |
|
1432 | - $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
1433 | - $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
1434 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1435 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1406 | + $defaults = array( |
|
1407 | + 'title' => '', |
|
1408 | + 'post_type' => '', // NULL for all |
|
1409 | + 'hide_empty' => '', |
|
1410 | + 'show_count' => '', |
|
1411 | + 'hide_icon' => '', |
|
1412 | + 'cpt_left' => '', |
|
1413 | + 'sort_by' => 'count', |
|
1414 | + 'max_count' => 'all', |
|
1415 | + 'max_level' => '1', |
|
1416 | + 'no_cpt_filter' => '', |
|
1417 | + 'no_cat_filter' => '', |
|
1418 | + 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
1419 | + 'after_widget' => '</section>', |
|
1420 | + 'before_title' => '<h3 class="widget-title">', |
|
1421 | + 'after_title' => '</h3>', |
|
1422 | + ); |
|
1423 | + $params = shortcode_atts($defaults, $atts); |
|
1436 | 1424 | |
1437 | - if ($params['max_count'] != 'all') { |
|
1438 | - $params['max_count'] = absint($params['max_count']); |
|
1439 | - } |
|
1425 | + /** |
|
1426 | + * Validate our incoming params |
|
1427 | + */ |
|
1428 | + // Make sure we have an array |
|
1429 | + $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
1430 | + |
|
1431 | + // Validate the checkboxes used on the widget |
|
1432 | + $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
1433 | + $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
1434 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1435 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1436 | + |
|
1437 | + if ($params['max_count'] != 'all') { |
|
1438 | + $params['max_count'] = absint($params['max_count']); |
|
1439 | + } |
|
1440 | 1440 | |
1441 | - if ($params['max_level'] != 'all') { |
|
1442 | - $params['max_level'] = absint($params['max_level']); |
|
1443 | - } |
|
1441 | + if ($params['max_level'] != 'all') { |
|
1442 | + $params['max_level'] = absint($params['max_level']); |
|
1443 | + } |
|
1444 | 1444 | |
1445 | - $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
1446 | - $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
1445 | + $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
1446 | + $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
1447 | 1447 | |
1448 | - $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
1448 | + $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
1449 | 1449 | |
1450 | - ob_start(); |
|
1451 | - the_widget('geodir_cpt_categories_widget', $params, $params); |
|
1452 | - $output = ob_get_contents(); |
|
1453 | - ob_end_clean(); |
|
1450 | + ob_start(); |
|
1451 | + the_widget('geodir_cpt_categories_widget', $params, $params); |
|
1452 | + $output = ob_get_contents(); |
|
1453 | + ob_end_clean(); |
|
1454 | 1454 | |
1455 | - return $output; |
|
1455 | + return $output; |
|
1456 | 1456 | } |
1457 | 1457 | add_shortcode('gd_cpt_categories', 'geodir_sc_cpt_categories_widget'); |
1458 | 1458 | |
@@ -1467,6 +1467,6 @@ discard block |
||
1467 | 1467 | * @return string HTML code. |
1468 | 1468 | */ |
1469 | 1469 | function geodir_sc_responsive_videos($atts, $content) { |
1470 | - return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
1470 | + return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
1471 | 1471 | } |
1472 | 1472 | add_shortcode('gd_video', 'geodir_sc_responsive_videos'); |
1473 | 1473 | \ No newline at end of file |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | // Add marker cluster |
198 | 198 | if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
199 | 199 | $map_args['enable_marker_cluster'] = true; |
200 | - if(get_option('geodir_marker_cluster_type')) { |
|
200 | + if (get_option('geodir_marker_cluster_type')) { |
|
201 | 201 | if ($map_args['autozoom']) { |
202 | 202 | $map_args['enable_marker_cluster_no_reposition'] = false; |
203 | 203 | } else { |
204 | 204 | $map_args['enable_marker_cluster_no_reposition'] = true; |
205 | 205 | } |
206 | 206 | |
207 | - $map_args['enable_marker_cluster_server'] = true ; |
|
207 | + $map_args['enable_marker_cluster_server'] = true; |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | } else { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | // if lat and long set in shortcode, hack it so the map is not repositioned |
215 | - if(!empty($params['latitude']) && !empty($params['longitude']) ){ |
|
215 | + if (!empty($params['latitude']) && !empty($params['longitude'])) { |
|
216 | 216 | $map_args['enable_marker_cluster_no_reposition'] = true; |
217 | 217 | } |
218 | 218 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | function geodir_sc_listing_map($atts) { |
266 | 266 | |
267 | 267 | // if some params are set then we need a new query, if not then we can use the main query |
268 | - if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) { |
|
268 | + if (isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type'])) { |
|
269 | 269 | |
270 | 270 | global $add_post_in_marker_array, $gd_sc_map_params; |
271 | 271 | $backup_globals = array(); |
@@ -288,34 +288,34 @@ discard block |
||
288 | 288 | 'event_type' => 'all' |
289 | 289 | ); |
290 | 290 | |
291 | - $params = shortcode_atts( $defaults, $atts ); |
|
291 | + $params = shortcode_atts($defaults, $atts); |
|
292 | 292 | |
293 | - if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) { |
|
293 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
294 | 294 | $params['post_type'] = 'gd_place'; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Validate the selected category/ies - Grab the current list based on post_type |
298 | - $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
299 | - $categories = get_terms( $category_taxonomy, array( |
|
298 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
299 | + $categories = get_terms($category_taxonomy, array( |
|
300 | 300 | 'orderby' => 'count', |
301 | 301 | 'order' => 'DESC', |
302 | 302 | 'fields' => 'ids' |
303 | - ) ); |
|
303 | + )); |
|
304 | 304 | |
305 | 305 | // Make sure we have an array |
306 | - if ( ! ( is_array( $params['category'] ) ) ) { |
|
307 | - $params['category'] = explode( ',', $params['category'] ); |
|
306 | + if (!(is_array($params['category']))) { |
|
307 | + $params['category'] = explode(',', $params['category']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // Array_intersect returns only the items in $params['category'] that are also in our category list |
311 | 311 | // Otherwise it becomes empty and later on that will mean "All" |
312 | - $params['category'] = array_intersect( $params['category'], $categories ); |
|
312 | + $params['category'] = array_intersect($params['category'], $categories); |
|
313 | 313 | |
314 | - if ( $params['post_type'] == 'gd_event' ) { |
|
315 | - $params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] ); |
|
314 | + if ($params['post_type'] == 'gd_event') { |
|
315 | + $params['event_type'] = gdsc_validate_list_filter_choice($params['event_type']); |
|
316 | 316 | } |
317 | 317 | |
318 | - $params = gdsc_validate_map_args( $params ); |
|
318 | + $params = gdsc_validate_map_args($params); |
|
319 | 319 | |
320 | 320 | $gd_sc_map_params = $params; |
321 | 321 | |
@@ -326,12 +326,12 @@ discard block |
||
326 | 326 | 'post_type' => $params['post_type'], |
327 | 327 | ); |
328 | 328 | |
329 | - if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) { |
|
330 | - $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
329 | + if (!empty($params['category']) && isset($params['category'][0]) && (int) $params['category'][0] != 0) { |
|
330 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
331 | 331 | |
332 | 332 | ######### WPML ######### |
333 | - if ( geodir_wpml_is_taxonomy_translated( $category_taxonomy[0] ) ) { |
|
334 | - $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
333 | + if (geodir_wpml_is_taxonomy_translated($category_taxonomy[0])) { |
|
334 | + $category = gd_lang_object_ids($params['category'], $category_taxonomy[0]); |
|
335 | 335 | } |
336 | 336 | ######### WPML ######### |
337 | 337 | |
@@ -341,36 +341,36 @@ discard block |
||
341 | 341 | 'terms' => $params['category'] |
342 | 342 | ); |
343 | 343 | |
344 | - $query_args['tax_query'] = array( $tax_query ); |
|
344 | + $query_args['tax_query'] = array($tax_query); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | $add_post_in_marker_array = true; |
348 | 348 | |
349 | - if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) { |
|
349 | + if ($params['post_type'] == 'gd_event' && function_exists('geodir_event_get_widget_events')) { |
|
350 | 350 | global $geodir_event_widget_listview; |
351 | 351 | $geodir_event_widget_listview = true; |
352 | 352 | |
353 | 353 | $query_args['geodir_event_type'] = $params['event_type']; |
354 | 354 | |
355 | - $listings = geodir_event_get_widget_events( $query_args ); |
|
355 | + $listings = geodir_event_get_widget_events($query_args); |
|
356 | 356 | |
357 | 357 | $geodir_event_widget_listview = false; |
358 | 358 | } else { |
359 | - $listings = geodir_get_widget_listings( $query_args ); |
|
359 | + $listings = geodir_get_widget_listings($query_args); |
|
360 | 360 | } |
361 | 361 | |
362 | - if ( ! empty( $listings ) ) { |
|
363 | - foreach ( $listings as $listing ) { |
|
364 | - create_marker_jason_of_posts( $listing ); |
|
362 | + if (!empty($listings)) { |
|
363 | + foreach ($listings as $listing) { |
|
364 | + create_marker_jason_of_posts($listing); |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
368 | 368 | ob_start(); |
369 | - add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array |
|
369 | + add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
370 | 370 | |
371 | - add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array |
|
371 | + add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
372 | 372 | |
373 | - add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers |
|
373 | + add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
374 | 374 | |
375 | 375 | $default_location = geodir_get_default_location(); |
376 | 376 | |
@@ -391,17 +391,17 @@ discard block |
||
391 | 391 | 'enable_location_filters' => false, |
392 | 392 | 'enable_jason_on_load' => true, |
393 | 393 | 'ajax_url' => geodir_get_ajax_url(), |
394 | - 'latitude' => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '', |
|
395 | - 'longitude' => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '', |
|
394 | + 'latitude' => isset($default_location->city_latitude) ? $default_location->city_latitude : '', |
|
395 | + 'longitude' => isset($default_location->city_longitude) ? $default_location->city_longitude : '', |
|
396 | 396 | 'streetViewControl' => true, |
397 | 397 | 'showPreview' => '0', |
398 | 398 | 'maxZoom' => 21, |
399 | 399 | 'bubble_size' => 'small', |
400 | 400 | ); |
401 | 401 | |
402 | - if ( is_single() ) { |
|
402 | + if (is_single()) { |
|
403 | 403 | global $post; |
404 | - if ( isset( $post->post_latitude ) ) { |
|
404 | + if (isset($post->post_latitude)) { |
|
405 | 405 | $map_args['latitude'] = $post->post_latitude; |
406 | 406 | $map_args['longitude'] = $post->post_longitude; |
407 | 407 | } |
@@ -412,24 +412,24 @@ discard block |
||
412 | 412 | } |
413 | 413 | |
414 | 414 | // Add marker cluster |
415 | - if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) { |
|
415 | + if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
|
416 | 416 | $map_args['enable_marker_cluster'] = true; |
417 | 417 | } else { |
418 | 418 | $map_args['enable_marker_cluster'] = false; |
419 | 419 | } |
420 | 420 | |
421 | - geodir_draw_map( $map_args ); |
|
421 | + geodir_draw_map($map_args); |
|
422 | 422 | |
423 | 423 | $output = ob_get_contents(); |
424 | 424 | |
425 | 425 | ob_end_clean(); |
426 | 426 | |
427 | - foreach ( $backup_globals as $global => $value ) { |
|
427 | + foreach ($backup_globals as $global => $value) { |
|
428 | 428 | ${$global} = $value; |
429 | 429 | } |
430 | 430 | |
431 | 431 | return $output; |
432 | - }else{ |
|
432 | + } else { |
|
433 | 433 | ob_start(); |
434 | 434 | add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
435 | 435 | add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
@@ -1050,20 +1050,20 @@ discard block |
||
1050 | 1050 | |
1051 | 1051 | $show_adv_search = isset($params['show_adv_search']) && in_array($params['show_adv_search'], array('default', 'always', 'searched')) ? $params['show_adv_search'] : ''; |
1052 | 1052 | |
1053 | - if ($show_adv_search != '' ) { |
|
1054 | - $show_adv_class = 'geodir-advance-search-' . $show_adv_search . ' '; |
|
1053 | + if ($show_adv_search != '') { |
|
1054 | + $show_adv_class = 'geodir-advance-search-'.$show_adv_search.' '; |
|
1055 | 1055 | if ($show_adv_search == 'searched' && geodir_is_page('search')) { |
1056 | 1056 | $show_adv_search = 'search'; |
1057 | 1057 | } |
1058 | - $show_adv_attrs = 'data-show-adv="' . $show_adv_search . '"'; |
|
1058 | + $show_adv_attrs = 'data-show-adv="'.$show_adv_search.'"'; |
|
1059 | 1059 | |
1060 | - $params['before_widget'] = str_replace('class="', $show_adv_attrs . ' class="' . $show_adv_class, $params['before_widget']); |
|
1060 | + $params['before_widget'] = str_replace('class="', $show_adv_attrs.' class="'.$show_adv_class, $params['before_widget']); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | ob_start(); |
1064 | 1064 | |
1065 | 1065 | //geodir_get_template_part('listing', 'filter-form'); |
1066 | - the_widget('geodir_advance_search_widget', $params, $params ); |
|
1066 | + the_widget('geodir_advance_search_widget', $params, $params); |
|
1067 | 1067 | |
1068 | 1068 | $output = ob_get_contents(); |
1069 | 1069 | ob_end_clean(); |
@@ -1258,13 +1258,13 @@ discard block |
||
1258 | 1258 | // Post_number needs to be a positive integer |
1259 | 1259 | if (!empty($params['post_author'])) { |
1260 | 1260 | // 'current' left for backwards compatibility |
1261 | - if ( $params['post_author'] == 'current' || $params['post_author'] == 'current_author') { |
|
1261 | + if ($params['post_author'] == 'current' || $params['post_author'] == 'current_author') { |
|
1262 | 1262 | if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
1263 | 1263 | $params['post_author'] = $post->post_author; |
1264 | 1264 | } else { |
1265 | 1265 | $params['post_author'] = -1; // Don't show any listings. |
1266 | 1266 | } |
1267 | - } else if ($params['post_author'] == 'current_user' ) { |
|
1267 | + } else if ($params['post_author'] == 'current_user') { |
|
1268 | 1268 | if ($current_user_id = get_current_user_id()) { |
1269 | 1269 | $params['post_author'] = $current_user_id; |
1270 | 1270 | } else { |
@@ -1281,7 +1281,7 @@ discard block |
||
1281 | 1281 | |
1282 | 1282 | // Validate character_count |
1283 | 1283 | //todo: is this necessary? |
1284 | - $params['character_count'] = $params['character_count']; |
|
1284 | + $params['character_count'] = $params['character_count']; |
|
1285 | 1285 | |
1286 | 1286 | // Validate our layout choice |
1287 | 1287 | // Outside of the norm, I added some more simple terms to match the existing |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | |
1294 | 1294 | // Validate Listing width, used in the template widget-listing-listview.php |
1295 | 1295 | // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
1296 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1296 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1297 | 1297 | |
1298 | 1298 | // Validate the checkboxes used on the widget |
1299 | 1299 | $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
@@ -1308,7 +1308,7 @@ discard block |
||
1308 | 1308 | // User favorites |
1309 | 1309 | $params['show_favorites_only'] = gdsc_to_bool_val($params['show_favorites_only']); |
1310 | 1310 | if (!empty($params['show_favorites_only'])) { |
1311 | - if ( $params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') { |
|
1311 | + if ($params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') { |
|
1312 | 1312 | if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
1313 | 1313 | $params['favorites_by_user'] = $post->post_author; |
1314 | 1314 | } else { |
@@ -1331,7 +1331,7 @@ discard block |
||
1331 | 1331 | if (!empty($params['tags'])) { |
1332 | 1332 | if (!is_array($params['tags'])) { |
1333 | 1333 | $comma = _x(',', 'tag delimiter'); |
1334 | - if ( ',' !== $comma ) { |
|
1334 | + if (',' !== $comma) { |
|
1335 | 1335 | $params['tags'] = str_replace($comma, ',', $params['tags']); |
1336 | 1336 | } |
1337 | 1337 | $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
@@ -1353,13 +1353,13 @@ discard block |
||
1353 | 1353 | unset($atts['pageno']); |
1354 | 1354 | } |
1355 | 1355 | |
1356 | - if ( !empty($atts['shortcode_content']) ) { |
|
1356 | + if (!empty($atts['shortcode_content'])) { |
|
1357 | 1357 | $content = $atts['shortcode_content']; |
1358 | 1358 | } |
1359 | 1359 | $params['shortcode_content'] = trim($content); |
1360 | 1360 | $atts['shortcode_content'] = trim($content); |
1361 | 1361 | |
1362 | - $params['shortcode_atts'] = $atts; |
|
1362 | + $params['shortcode_atts'] = $atts; |
|
1363 | 1363 | |
1364 | 1364 | $output = geodir_sc_gd_listings_output($params); |
1365 | 1365 | |
@@ -1431,8 +1431,8 @@ discard block |
||
1431 | 1431 | // Validate the checkboxes used on the widget |
1432 | 1432 | $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
1433 | 1433 | $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
1434 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1435 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1434 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1435 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1436 | 1436 | |
1437 | 1437 | if ($params['max_count'] != 'all') { |
1438 | 1438 | $params['max_count'] = absint($params['max_count']); |