@@ -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 | |
@@ -262,163 +262,163 @@ discard block |
||
262 | 262 | * @return string Map HTML. |
263 | 263 | */ |
264 | 264 | function geodir_sc_listing_map($atts) { |
265 | - global $add_post_in_marker_array, $gd_sc_map_params; |
|
266 | - $backup_globals = array(); |
|
267 | - $backup_globals['add_post_in_marker_array'] = $add_post_in_marker_array; |
|
268 | - $backup_globals['gd_sc_map_params'] = $gd_sc_map_params; |
|
265 | + global $add_post_in_marker_array, $gd_sc_map_params; |
|
266 | + $backup_globals = array(); |
|
267 | + $backup_globals['add_post_in_marker_array'] = $add_post_in_marker_array; |
|
268 | + $backup_globals['gd_sc_map_params'] = $gd_sc_map_params; |
|
269 | 269 | |
270 | - $defaults = array( |
|
271 | - 'width' => '294', |
|
272 | - 'height' => '370', |
|
273 | - 'zoom' => '13', |
|
274 | - 'autozoom' => '', |
|
275 | - 'sticky' => '', |
|
276 | - 'showall' => '0', |
|
277 | - 'scrollwheel' => '0', |
|
278 | - 'maptype' => 'ROADMAP', |
|
279 | - 'child_collapse' => 0, |
|
280 | - 'marker_cluster' => false, |
|
281 | - 'post_type' => 'gd_place', |
|
282 | - 'category' => '0', |
|
283 | - 'event_type' => 'all' |
|
284 | - ); |
|
285 | - |
|
286 | - $params = shortcode_atts($defaults, $atts); |
|
270 | + $defaults = array( |
|
271 | + 'width' => '294', |
|
272 | + 'height' => '370', |
|
273 | + 'zoom' => '13', |
|
274 | + 'autozoom' => '', |
|
275 | + 'sticky' => '', |
|
276 | + 'showall' => '0', |
|
277 | + 'scrollwheel' => '0', |
|
278 | + 'maptype' => 'ROADMAP', |
|
279 | + 'child_collapse' => 0, |
|
280 | + 'marker_cluster' => false, |
|
281 | + 'post_type' => 'gd_place', |
|
282 | + 'category' => '0', |
|
283 | + 'event_type' => 'all' |
|
284 | + ); |
|
285 | + |
|
286 | + $params = shortcode_atts($defaults, $atts); |
|
287 | 287 | |
288 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
289 | - $params['post_type'] = 'gd_place'; |
|
290 | - } |
|
288 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
289 | + $params['post_type'] = 'gd_place'; |
|
290 | + } |
|
291 | 291 | |
292 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
293 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
294 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
295 | - |
|
296 | - // Make sure we have an array |
|
297 | - if (!(is_array($params['category']))) { |
|
298 | - $params['category'] = explode(',', $params['category']); |
|
299 | - } |
|
300 | - |
|
301 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
302 | - // Otherwise it becomes empty and later on that will mean "All" |
|
303 | - $params['category'] = array_intersect($params['category'], $categories); |
|
292 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
293 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
294 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
295 | + |
|
296 | + // Make sure we have an array |
|
297 | + if (!(is_array($params['category']))) { |
|
298 | + $params['category'] = explode(',', $params['category']); |
|
299 | + } |
|
300 | + |
|
301 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
302 | + // Otherwise it becomes empty and later on that will mean "All" |
|
303 | + $params['category'] = array_intersect($params['category'], $categories); |
|
304 | 304 | |
305 | - if ($params['post_type'] == 'gd_event') { |
|
306 | - $params['event_type'] = gdsc_validate_list_filter_choice($params['event_type']); |
|
307 | - } |
|
305 | + if ($params['post_type'] == 'gd_event') { |
|
306 | + $params['event_type'] = gdsc_validate_list_filter_choice($params['event_type']); |
|
307 | + } |
|
308 | 308 | |
309 | - $params = gdsc_validate_map_args($params); |
|
309 | + $params = gdsc_validate_map_args($params); |
|
310 | 310 | |
311 | - $gd_sc_map_params = $params; |
|
311 | + $gd_sc_map_params = $params; |
|
312 | 312 | |
313 | - $query_args = array( |
|
314 | - 'posts_per_page' => 1000000, |
|
315 | - 'is_geodir_loop' => true, |
|
316 | - 'gd_location' => false, |
|
317 | - ); |
|
313 | + $query_args = array( |
|
314 | + 'posts_per_page' => 1000000, |
|
315 | + 'is_geodir_loop' => true, |
|
316 | + 'gd_location' => false, |
|
317 | + ); |
|
318 | 318 | |
319 | - if (!empty($params['category']) && isset($params['category'][0]) && (int)$params['category'][0] != 0) { |
|
320 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
321 | - |
|
322 | - ######### WPML ######### |
|
323 | - if (function_exists('icl_object_id')) { |
|
324 | - $category = gd_lang_object_ids($params['category'], $category_taxonomy[0]); |
|
325 | - } |
|
326 | - ######### WPML ######### |
|
327 | - |
|
328 | - $tax_query = array( |
|
329 | - 'taxonomy' => $category_taxonomy[0], |
|
330 | - 'field' => 'id', |
|
331 | - 'terms' => $params['category'] |
|
332 | - ); |
|
333 | - |
|
334 | - $query_args['tax_query'] = array($tax_query); |
|
335 | - } |
|
319 | + if (!empty($params['category']) && isset($params['category'][0]) && (int)$params['category'][0] != 0) { |
|
320 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
321 | + |
|
322 | + ######### WPML ######### |
|
323 | + if (function_exists('icl_object_id')) { |
|
324 | + $category = gd_lang_object_ids($params['category'], $category_taxonomy[0]); |
|
325 | + } |
|
326 | + ######### WPML ######### |
|
327 | + |
|
328 | + $tax_query = array( |
|
329 | + 'taxonomy' => $category_taxonomy[0], |
|
330 | + 'field' => 'id', |
|
331 | + 'terms' => $params['category'] |
|
332 | + ); |
|
333 | + |
|
334 | + $query_args['tax_query'] = array($tax_query); |
|
335 | + } |
|
336 | 336 | |
337 | - $add_post_in_marker_array = true; |
|
337 | + $add_post_in_marker_array = true; |
|
338 | 338 | |
339 | - if ($params['post_type'] == 'gd_event' && function_exists('geodir_event_get_widget_events')) { |
|
340 | - global $geodir_event_widget_listview; |
|
341 | - $geodir_event_widget_listview = true; |
|
339 | + if ($params['post_type'] == 'gd_event' && function_exists('geodir_event_get_widget_events')) { |
|
340 | + global $geodir_event_widget_listview; |
|
341 | + $geodir_event_widget_listview = true; |
|
342 | 342 | |
343 | - $query_args['geodir_event_type'] = $params['event_type']; |
|
343 | + $query_args['geodir_event_type'] = $params['event_type']; |
|
344 | 344 | |
345 | - $listings = geodir_event_get_widget_events($query_args); |
|
345 | + $listings = geodir_event_get_widget_events($query_args); |
|
346 | 346 | |
347 | - $geodir_event_widget_listview = false; |
|
348 | - } else { |
|
349 | - $listings = geodir_get_widget_listings($query_args); |
|
350 | - } |
|
351 | - |
|
352 | - if (!empty($listings)) { |
|
353 | - foreach ($listings as $listing) { |
|
354 | - create_marker_jason_of_posts($listing); |
|
355 | - } |
|
356 | - } |
|
347 | + $geodir_event_widget_listview = false; |
|
348 | + } else { |
|
349 | + $listings = geodir_get_widget_listings($query_args); |
|
350 | + } |
|
351 | + |
|
352 | + if (!empty($listings)) { |
|
353 | + foreach ($listings as $listing) { |
|
354 | + create_marker_jason_of_posts($listing); |
|
355 | + } |
|
356 | + } |
|
357 | 357 | |
358 | - ob_start(); |
|
359 | - add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
358 | + ob_start(); |
|
359 | + add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
360 | 360 | |
361 | - add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
361 | + add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
362 | 362 | |
363 | - add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
363 | + add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
364 | 364 | |
365 | - $default_location = geodir_get_default_location(); |
|
365 | + $default_location = geodir_get_default_location(); |
|
366 | 366 | |
367 | - $map_args = array( |
|
368 | - 'map_canvas_name' => 'gd_listing_map', |
|
369 | - 'width' => $params['width'], |
|
370 | - 'height' => $params['height'], |
|
371 | - 'zoom' => $params['zoom'], |
|
372 | - 'autozoom' => $params['autozoom'], |
|
373 | - 'sticky' => $params['sticky'], |
|
374 | - 'showall' => $params['showall'], |
|
375 | - 'scrollwheel' => $params['scrollwheel'], |
|
376 | - 'maptype' => $params['maptype'], |
|
377 | - 'child_collapse' => 0, |
|
378 | - 'enable_cat_filters' => false, |
|
379 | - 'enable_text_search' => false, |
|
380 | - 'enable_post_type_filters' => false, |
|
381 | - 'enable_location_filters' => false, |
|
382 | - 'enable_jason_on_load' => true, |
|
383 | - 'ajax_url' => geodir_get_ajax_url(), |
|
384 | - 'latitude' => isset($default_location->city_latitude) ? $default_location->city_latitude : '', |
|
385 | - 'longitude' => isset($default_location->city_longitude) ? $default_location->city_longitude : '', |
|
386 | - 'streetViewControl' => true, |
|
387 | - 'showPreview' => '0', |
|
388 | - 'maxZoom' => 21, |
|
389 | - 'bubble_size' => 'small', |
|
390 | - ); |
|
367 | + $map_args = array( |
|
368 | + 'map_canvas_name' => 'gd_listing_map', |
|
369 | + 'width' => $params['width'], |
|
370 | + 'height' => $params['height'], |
|
371 | + 'zoom' => $params['zoom'], |
|
372 | + 'autozoom' => $params['autozoom'], |
|
373 | + 'sticky' => $params['sticky'], |
|
374 | + 'showall' => $params['showall'], |
|
375 | + 'scrollwheel' => $params['scrollwheel'], |
|
376 | + 'maptype' => $params['maptype'], |
|
377 | + 'child_collapse' => 0, |
|
378 | + 'enable_cat_filters' => false, |
|
379 | + 'enable_text_search' => false, |
|
380 | + 'enable_post_type_filters' => false, |
|
381 | + 'enable_location_filters' => false, |
|
382 | + 'enable_jason_on_load' => true, |
|
383 | + 'ajax_url' => geodir_get_ajax_url(), |
|
384 | + 'latitude' => isset($default_location->city_latitude) ? $default_location->city_latitude : '', |
|
385 | + 'longitude' => isset($default_location->city_longitude) ? $default_location->city_longitude : '', |
|
386 | + 'streetViewControl' => true, |
|
387 | + 'showPreview' => '0', |
|
388 | + 'maxZoom' => 21, |
|
389 | + 'bubble_size' => 'small', |
|
390 | + ); |
|
391 | 391 | |
392 | - if (is_single()) { |
|
393 | - global $post; |
|
394 | - if (isset($post->post_latitude)) { |
|
395 | - $map_args['latitude'] = $post->post_latitude; |
|
396 | - $map_args['longitude'] = $post->post_longitude; |
|
397 | - } |
|
392 | + if (is_single()) { |
|
393 | + global $post; |
|
394 | + if (isset($post->post_latitude)) { |
|
395 | + $map_args['latitude'] = $post->post_latitude; |
|
396 | + $map_args['longitude'] = $post->post_longitude; |
|
397 | + } |
|
398 | 398 | |
399 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
400 | - } else { |
|
401 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
402 | - } |
|
399 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
400 | + } else { |
|
401 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
402 | + } |
|
403 | 403 | |
404 | - // Add marker cluster |
|
405 | - if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
|
406 | - $map_args['enable_marker_cluster'] = true; |
|
407 | - } else { |
|
408 | - $map_args['enable_marker_cluster'] = false; |
|
409 | - } |
|
404 | + // Add marker cluster |
|
405 | + if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
|
406 | + $map_args['enable_marker_cluster'] = true; |
|
407 | + } else { |
|
408 | + $map_args['enable_marker_cluster'] = false; |
|
409 | + } |
|
410 | 410 | |
411 | - geodir_draw_map($map_args); |
|
411 | + geodir_draw_map($map_args); |
|
412 | 412 | |
413 | - $output = ob_get_contents(); |
|
413 | + $output = ob_get_contents(); |
|
414 | 414 | |
415 | - ob_end_clean(); |
|
415 | + ob_end_clean(); |
|
416 | 416 | |
417 | - foreach ($backup_globals as $global => $value) { |
|
418 | - ${$global} = $value; |
|
419 | - } |
|
417 | + foreach ($backup_globals as $global => $value) { |
|
418 | + ${$global} = $value; |
|
419 | + } |
|
420 | 420 | |
421 | - return $output; |
|
421 | + return $output; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | add_shortcode('gd_listing_slider', 'geodir_sc_listing_slider'); |
@@ -451,120 +451,120 @@ discard block |
||
451 | 451 | */ |
452 | 452 | function geodir_sc_listing_slider($atts) |
453 | 453 | { |
454 | - ob_start(); |
|
455 | - $defaults = array( |
|
456 | - 'post_type' => 'gd_place', |
|
457 | - 'category' => '0', |
|
458 | - 'post_number' => '5', |
|
459 | - 'slideshow' => '0', |
|
460 | - 'animation_loop' => 0, |
|
461 | - 'direction_nav' => 0, |
|
462 | - 'slideshow_speed' => 5000, |
|
463 | - 'animation_speed' => 600, |
|
464 | - 'animation' => 'slide', |
|
465 | - 'order_by' => 'latest', |
|
466 | - 'show_title' => '', |
|
467 | - 'show_featured_only' => '', |
|
468 | - 'title' => '', |
|
469 | - ); |
|
470 | - |
|
471 | - $params = shortcode_atts($defaults, $atts); |
|
472 | - |
|
473 | - |
|
474 | - /* |
|
454 | + ob_start(); |
|
455 | + $defaults = array( |
|
456 | + 'post_type' => 'gd_place', |
|
457 | + 'category' => '0', |
|
458 | + 'post_number' => '5', |
|
459 | + 'slideshow' => '0', |
|
460 | + 'animation_loop' => 0, |
|
461 | + 'direction_nav' => 0, |
|
462 | + 'slideshow_speed' => 5000, |
|
463 | + 'animation_speed' => 600, |
|
464 | + 'animation' => 'slide', |
|
465 | + 'order_by' => 'latest', |
|
466 | + 'show_title' => '', |
|
467 | + 'show_featured_only' => '', |
|
468 | + 'title' => '', |
|
469 | + ); |
|
470 | + |
|
471 | + $params = shortcode_atts($defaults, $atts); |
|
472 | + |
|
473 | + |
|
474 | + /* |
|
475 | 475 | * |
476 | 476 | * Now we begin the validation of the attributes. |
477 | 477 | */ |
478 | - // Check we have a valid post_type |
|
479 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
480 | - $params['post_type'] = 'gd_place'; |
|
481 | - } |
|
482 | - |
|
483 | - // Check we have a valid sort_order |
|
484 | - $params['order_by'] = gdsc_validate_sort_choice($params['order_by']); |
|
485 | - |
|
486 | - // Match the chosen animation to our options |
|
487 | - $animation_list = array('slide', 'fade'); |
|
488 | - if (!(in_array($params['animation'], $animation_list))) { |
|
489 | - $params['animation'] = 'slide'; |
|
490 | - } |
|
491 | - |
|
492 | - // Post_number needs to be a positive integer |
|
493 | - $params['post_number'] = absint($params['post_number']); |
|
494 | - if (0 == $params['post_number']) { |
|
495 | - $params['post_number'] = 1; |
|
496 | - } |
|
497 | - |
|
498 | - // Manage the entered categories |
|
499 | - if (0 != $params['category'] || '' != $params['category']) { |
|
500 | - $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']); |
|
501 | - } |
|
502 | - // Convert show_title to a bool |
|
503 | - $params['show_title'] = intval(gdsc_to_bool_val($params['show_title'])); |
|
504 | - |
|
505 | - // Convert show_featured_only to a bool |
|
506 | - $params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only'])); |
|
507 | - |
|
508 | - /* |
|
478 | + // Check we have a valid post_type |
|
479 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
480 | + $params['post_type'] = 'gd_place'; |
|
481 | + } |
|
482 | + |
|
483 | + // Check we have a valid sort_order |
|
484 | + $params['order_by'] = gdsc_validate_sort_choice($params['order_by']); |
|
485 | + |
|
486 | + // Match the chosen animation to our options |
|
487 | + $animation_list = array('slide', 'fade'); |
|
488 | + if (!(in_array($params['animation'], $animation_list))) { |
|
489 | + $params['animation'] = 'slide'; |
|
490 | + } |
|
491 | + |
|
492 | + // Post_number needs to be a positive integer |
|
493 | + $params['post_number'] = absint($params['post_number']); |
|
494 | + if (0 == $params['post_number']) { |
|
495 | + $params['post_number'] = 1; |
|
496 | + } |
|
497 | + |
|
498 | + // Manage the entered categories |
|
499 | + if (0 != $params['category'] || '' != $params['category']) { |
|
500 | + $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']); |
|
501 | + } |
|
502 | + // Convert show_title to a bool |
|
503 | + $params['show_title'] = intval(gdsc_to_bool_val($params['show_title'])); |
|
504 | + |
|
505 | + // Convert show_featured_only to a bool |
|
506 | + $params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only'])); |
|
507 | + |
|
508 | + /* |
|
509 | 509 | * Hopefully all attributes are now valid, and safe to pass forward |
510 | 510 | */ |
511 | 511 | |
512 | - // redeclare vars after validation |
|
513 | - |
|
514 | - if (isset($params['direction_nav'])) { |
|
515 | - $params['directionNav'] = $params['direction_nav']; |
|
516 | - } |
|
517 | - if (isset($params['animation_loop'])) { |
|
518 | - $params['animationLoop'] = $params['animation_loop']; |
|
519 | - } |
|
520 | - if (isset($params['slideshow_speed'])) { |
|
521 | - $params['slideshowSpeed'] = $params['slideshow_speed']; |
|
522 | - } |
|
523 | - if (isset($params['animation_speed'])) { |
|
524 | - $params['animationSpeed'] = $params['animation_speed']; |
|
525 | - } |
|
526 | - if (isset($params['order_by'])) { |
|
527 | - $params['list_sort'] = $params['order_by']; |
|
528 | - } |
|
529 | - |
|
530 | - $query_args = array( |
|
531 | - 'post_number' => $params['post_number'], |
|
532 | - 'is_geodir_loop' => true, |
|
533 | - 'post_type' => $params['post_type'], |
|
534 | - 'order_by' => $params['order_by'] |
|
535 | - ); |
|
536 | - |
|
537 | - if (1 == $params['show_featured_only']) { |
|
538 | - $query_args['show_featured_only'] = 1; |
|
539 | - } |
|
540 | - |
|
541 | - if (0 != $params['category'] && '' != $params['category']) { |
|
542 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
543 | - $tax_query = array( |
|
544 | - 'taxonomy' => $category_taxonomy[0], |
|
545 | - 'field' => 'id', |
|
546 | - 'terms' => $params['category'], |
|
547 | - ); |
|
548 | - |
|
549 | - $query_args['tax_query'] = array($tax_query); |
|
550 | - } |
|
551 | - |
|
552 | - $defaults = array( |
|
553 | - 'before_widget' => '', |
|
554 | - 'after_widget' => '', |
|
555 | - 'before_title' => '', |
|
556 | - 'after_title' => '', |
|
557 | - ); |
|
558 | - |
|
559 | - $query_args = array_merge($query_args, $params); |
|
560 | - |
|
561 | - geodir_listing_slider_widget_output($defaults, $query_args); |
|
562 | - |
|
563 | - $output = ob_get_contents(); |
|
564 | - |
|
565 | - ob_end_clean(); |
|
566 | - |
|
567 | - return $output; |
|
512 | + // redeclare vars after validation |
|
513 | + |
|
514 | + if (isset($params['direction_nav'])) { |
|
515 | + $params['directionNav'] = $params['direction_nav']; |
|
516 | + } |
|
517 | + if (isset($params['animation_loop'])) { |
|
518 | + $params['animationLoop'] = $params['animation_loop']; |
|
519 | + } |
|
520 | + if (isset($params['slideshow_speed'])) { |
|
521 | + $params['slideshowSpeed'] = $params['slideshow_speed']; |
|
522 | + } |
|
523 | + if (isset($params['animation_speed'])) { |
|
524 | + $params['animationSpeed'] = $params['animation_speed']; |
|
525 | + } |
|
526 | + if (isset($params['order_by'])) { |
|
527 | + $params['list_sort'] = $params['order_by']; |
|
528 | + } |
|
529 | + |
|
530 | + $query_args = array( |
|
531 | + 'post_number' => $params['post_number'], |
|
532 | + 'is_geodir_loop' => true, |
|
533 | + 'post_type' => $params['post_type'], |
|
534 | + 'order_by' => $params['order_by'] |
|
535 | + ); |
|
536 | + |
|
537 | + if (1 == $params['show_featured_only']) { |
|
538 | + $query_args['show_featured_only'] = 1; |
|
539 | + } |
|
540 | + |
|
541 | + if (0 != $params['category'] && '' != $params['category']) { |
|
542 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
543 | + $tax_query = array( |
|
544 | + 'taxonomy' => $category_taxonomy[0], |
|
545 | + 'field' => 'id', |
|
546 | + 'terms' => $params['category'], |
|
547 | + ); |
|
548 | + |
|
549 | + $query_args['tax_query'] = array($tax_query); |
|
550 | + } |
|
551 | + |
|
552 | + $defaults = array( |
|
553 | + 'before_widget' => '', |
|
554 | + 'after_widget' => '', |
|
555 | + 'before_title' => '', |
|
556 | + 'after_title' => '', |
|
557 | + ); |
|
558 | + |
|
559 | + $query_args = array_merge($query_args, $params); |
|
560 | + |
|
561 | + geodir_listing_slider_widget_output($defaults, $query_args); |
|
562 | + |
|
563 | + $output = ob_get_contents(); |
|
564 | + |
|
565 | + ob_end_clean(); |
|
566 | + |
|
567 | + return $output; |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | add_shortcode('gd_login_box', 'geodir_sc_login_box'); |
@@ -588,22 +588,22 @@ discard block |
||
588 | 588 | */ |
589 | 589 | function geodir_sc_login_box($atts) |
590 | 590 | { |
591 | - ob_start(); |
|
591 | + ob_start(); |
|
592 | 592 | |
593 | - $defaults = array( |
|
594 | - 'before_widget' => '', |
|
595 | - 'after_widget' => '', |
|
596 | - 'before_title' => '', |
|
597 | - 'after_title' => '', |
|
598 | - ); |
|
593 | + $defaults = array( |
|
594 | + 'before_widget' => '', |
|
595 | + 'after_widget' => '', |
|
596 | + 'before_title' => '', |
|
597 | + 'after_title' => '', |
|
598 | + ); |
|
599 | 599 | |
600 | - geodir_loginwidget_output($defaults, $defaults); |
|
600 | + geodir_loginwidget_output($defaults, $defaults); |
|
601 | 601 | |
602 | - $output = ob_get_contents(); |
|
602 | + $output = ob_get_contents(); |
|
603 | 603 | |
604 | - ob_end_clean(); |
|
604 | + ob_end_clean(); |
|
605 | 605 | |
606 | - return $output; |
|
606 | + return $output; |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | add_shortcode('gd_popular_post_category', 'geodir_sc_popular_post_category'); |
@@ -634,30 +634,30 @@ discard block |
||
634 | 634 | */ |
635 | 635 | function geodir_sc_popular_post_category($atts) |
636 | 636 | { |
637 | - ob_start(); |
|
638 | - global $geodir_post_category_str; |
|
639 | - $defaults = array( |
|
640 | - 'category_limit' => 15, |
|
641 | - 'before_widget' => '', |
|
642 | - 'after_widget' => '', |
|
643 | - 'before_title' => '', |
|
644 | - 'after_title' => '', |
|
645 | - 'title' => '', |
|
646 | - 'default_post_type' => '', |
|
647 | - 'parent_only' => false, |
|
648 | - ); |
|
649 | - |
|
650 | - $params = shortcode_atts($defaults, $atts, 'popular_post_category'); |
|
651 | - $params['category_limit'] = absint($params['category_limit']); |
|
652 | - $params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : ''; |
|
653 | - $params['parent_only'] = gdsc_to_bool_val($params['parent_only']); |
|
654 | - geodir_popular_post_category_output($params, $params); |
|
655 | - |
|
656 | - $output = ob_get_contents(); |
|
657 | - |
|
658 | - ob_end_clean(); |
|
659 | - |
|
660 | - return $output; |
|
637 | + ob_start(); |
|
638 | + global $geodir_post_category_str; |
|
639 | + $defaults = array( |
|
640 | + 'category_limit' => 15, |
|
641 | + 'before_widget' => '', |
|
642 | + 'after_widget' => '', |
|
643 | + 'before_title' => '', |
|
644 | + 'after_title' => '', |
|
645 | + 'title' => '', |
|
646 | + 'default_post_type' => '', |
|
647 | + 'parent_only' => false, |
|
648 | + ); |
|
649 | + |
|
650 | + $params = shortcode_atts($defaults, $atts, 'popular_post_category'); |
|
651 | + $params['category_limit'] = absint($params['category_limit']); |
|
652 | + $params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : ''; |
|
653 | + $params['parent_only'] = gdsc_to_bool_val($params['parent_only']); |
|
654 | + geodir_popular_post_category_output($params, $params); |
|
655 | + |
|
656 | + $output = ob_get_contents(); |
|
657 | + |
|
658 | + ob_end_clean(); |
|
659 | + |
|
660 | + return $output; |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | add_shortcode('gd_popular_post_view', 'geodir_sc_popular_post_view'); |
@@ -697,97 +697,97 @@ discard block |
||
697 | 697 | */ |
698 | 698 | function geodir_sc_popular_post_view($atts) |
699 | 699 | { |
700 | - ob_start(); |
|
701 | - $defaults = array( |
|
702 | - 'post_type' => 'gd_place', |
|
703 | - 'category' => '0', |
|
704 | - 'post_number' => '5', |
|
705 | - 'layout' => 'gridview_onehalf', |
|
706 | - 'add_location_filter' => '0', |
|
707 | - 'list_sort' => 'latest', |
|
708 | - 'use_viewing_post_type' => '1', |
|
709 | - 'character_count' => '20', |
|
710 | - 'listing_width' => '', |
|
711 | - 'show_featured_only' => '0', |
|
712 | - 'show_special_only' => '0', |
|
713 | - 'with_pics_only' => '0', |
|
714 | - 'with_videos_only' => '0', |
|
715 | - 'before_widget' => '', |
|
716 | - 'after_widget' => '', |
|
717 | - 'before_title' => '<h3 class="widget-title">', |
|
718 | - 'after_title' => '</h3>', |
|
719 | - 'title' => '', |
|
720 | - 'category_title' => '', |
|
721 | - ); |
|
722 | - |
|
723 | - $params = shortcode_atts($defaults, $atts); |
|
724 | - |
|
725 | - /** |
|
726 | - * Validate our incoming params |
|
727 | - */ |
|
700 | + ob_start(); |
|
701 | + $defaults = array( |
|
702 | + 'post_type' => 'gd_place', |
|
703 | + 'category' => '0', |
|
704 | + 'post_number' => '5', |
|
705 | + 'layout' => 'gridview_onehalf', |
|
706 | + 'add_location_filter' => '0', |
|
707 | + 'list_sort' => 'latest', |
|
708 | + 'use_viewing_post_type' => '1', |
|
709 | + 'character_count' => '20', |
|
710 | + 'listing_width' => '', |
|
711 | + 'show_featured_only' => '0', |
|
712 | + 'show_special_only' => '0', |
|
713 | + 'with_pics_only' => '0', |
|
714 | + 'with_videos_only' => '0', |
|
715 | + 'before_widget' => '', |
|
716 | + 'after_widget' => '', |
|
717 | + 'before_title' => '<h3 class="widget-title">', |
|
718 | + 'after_title' => '</h3>', |
|
719 | + 'title' => '', |
|
720 | + 'category_title' => '', |
|
721 | + ); |
|
728 | 722 | |
729 | - // Validate the selected post type, default to gd_place on fail |
|
730 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
731 | - $params['post_type'] = 'gd_place'; |
|
732 | - } |
|
733 | - |
|
734 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
735 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
736 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
737 | - |
|
738 | - // Make sure we have an array |
|
739 | - if (!(is_array($params['category']))) { |
|
740 | - $params['category'] = explode(',', $params['category']); |
|
741 | - } |
|
742 | - |
|
743 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
744 | - // Otherwise it becomes empty and later on that will mean "All" |
|
745 | - $params['category'] = array_intersect($params['category'], $categories); |
|
746 | - |
|
747 | - // Post_number needs to be a positive integer |
|
748 | - $params['post_number'] = absint($params['post_number']); |
|
749 | - if (0 == $params['post_number']) { |
|
750 | - $params['post_number'] = 1; |
|
751 | - } |
|
752 | - |
|
753 | - // Validate our layout choice |
|
754 | - // Outside of the norm, I added some more simple terms to match the existing |
|
755 | - // So now I just run the switch to set it properly. |
|
756 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
757 | - |
|
758 | - // Validate our sorting choice |
|
759 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
760 | - |
|
761 | - // Validate character_count |
|
762 | - $params['character_count'] = absint($params['character_count']); |
|
763 | - if (20 > $params['character_count']) { |
|
764 | - $params['character_count'] = 20; |
|
765 | - } |
|
766 | - |
|
767 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
768 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
769 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
770 | - |
|
771 | - // Validate the checkboxes used on the widget |
|
772 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
773 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
774 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
775 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
776 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
777 | - $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']); |
|
778 | - |
|
779 | - /** |
|
780 | - * End of validation |
|
781 | - */ |
|
723 | + $params = shortcode_atts($defaults, $atts); |
|
724 | + |
|
725 | + /** |
|
726 | + * Validate our incoming params |
|
727 | + */ |
|
728 | + |
|
729 | + // Validate the selected post type, default to gd_place on fail |
|
730 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
731 | + $params['post_type'] = 'gd_place'; |
|
732 | + } |
|
782 | 733 | |
783 | - geodir_popular_postview_output($params, $params); |
|
734 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
735 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
736 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
784 | 737 | |
738 | + // Make sure we have an array |
|
739 | + if (!(is_array($params['category']))) { |
|
740 | + $params['category'] = explode(',', $params['category']); |
|
741 | + } |
|
785 | 742 | |
786 | - $output = ob_get_contents(); |
|
743 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
744 | + // Otherwise it becomes empty and later on that will mean "All" |
|
745 | + $params['category'] = array_intersect($params['category'], $categories); |
|
787 | 746 | |
788 | - ob_end_clean(); |
|
747 | + // Post_number needs to be a positive integer |
|
748 | + $params['post_number'] = absint($params['post_number']); |
|
749 | + if (0 == $params['post_number']) { |
|
750 | + $params['post_number'] = 1; |
|
751 | + } |
|
789 | 752 | |
790 | - return $output; |
|
753 | + // Validate our layout choice |
|
754 | + // Outside of the norm, I added some more simple terms to match the existing |
|
755 | + // So now I just run the switch to set it properly. |
|
756 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
757 | + |
|
758 | + // Validate our sorting choice |
|
759 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
760 | + |
|
761 | + // Validate character_count |
|
762 | + $params['character_count'] = absint($params['character_count']); |
|
763 | + if (20 > $params['character_count']) { |
|
764 | + $params['character_count'] = 20; |
|
765 | + } |
|
766 | + |
|
767 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
768 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
769 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
770 | + |
|
771 | + // Validate the checkboxes used on the widget |
|
772 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
773 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
774 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
775 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
776 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
777 | + $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']); |
|
778 | + |
|
779 | + /** |
|
780 | + * End of validation |
|
781 | + */ |
|
782 | + |
|
783 | + geodir_popular_postview_output($params, $params); |
|
784 | + |
|
785 | + |
|
786 | + $output = ob_get_contents(); |
|
787 | + |
|
788 | + ob_end_clean(); |
|
789 | + |
|
790 | + return $output; |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | add_shortcode('gd_recent_reviews', 'geodir_sc_recent_reviews'); |
@@ -809,37 +809,37 @@ discard block |
||
809 | 809 | * @return string Recent reviews HTML. |
810 | 810 | */ |
811 | 811 | function geodir_sc_recent_reviews($atts) { |
812 | - ob_start(); |
|
813 | - $defaults = array( |
|
812 | + ob_start(); |
|
813 | + $defaults = array( |
|
814 | 814 | 'title' => '', |
815 | 815 | 'count' => 5, |
816 | - ); |
|
816 | + ); |
|
817 | 817 | |
818 | - $params = shortcode_atts($defaults, $atts); |
|
818 | + $params = shortcode_atts($defaults, $atts); |
|
819 | 819 | |
820 | - $count = absint($params['count']); |
|
821 | - if (0 == $count) { |
|
822 | - $count = 1; |
|
823 | - } |
|
820 | + $count = absint($params['count']); |
|
821 | + if (0 == $count) { |
|
822 | + $count = 1; |
|
823 | + } |
|
824 | 824 | |
825 | 825 | $title = !empty($params['title']) ? __($params['title'], 'geodirectory') : ''; |
826 | 826 | |
827 | - $comments_li = geodir_get_recent_reviews(30, $count, 100, false); |
|
827 | + $comments_li = geodir_get_recent_reviews(30, $count, 100, false); |
|
828 | 828 | |
829 | - if ($comments_li) { |
|
830 | - if ($title != '') { ?> |
|
829 | + if ($comments_li) { |
|
830 | + if ($title != '') { ?> |
|
831 | 831 | <h3 class="geodir-sc-recent-reviews-title widget-title"><?php echo $title; ?></h3> |
832 | 832 | <?php } ?> |
833 | 833 | <div class="geodir_sc_recent_reviews_section"> |
834 | 834 | <ul class="geodir_sc_recent_reviews"><?php echo $comments_li; ?></ul> |
835 | 835 | </div> |
836 | 836 | <?php |
837 | - } |
|
838 | - $output = ob_get_contents(); |
|
837 | + } |
|
838 | + $output = ob_get_contents(); |
|
839 | 839 | |
840 | - ob_end_clean(); |
|
840 | + ob_end_clean(); |
|
841 | 841 | |
842 | - return $output; |
|
842 | + return $output; |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | add_shortcode('gd_related_listings', 'geodir_sc_related_listings'); |
@@ -869,64 +869,64 @@ discard block |
||
869 | 869 | */ |
870 | 870 | function geodir_sc_related_listings($atts) |
871 | 871 | { |
872 | - ob_start(); |
|
873 | - $defaults = array( |
|
874 | - 'post_number' => 5, |
|
875 | - 'relate_to' => 'category', |
|
876 | - 'layout' => 'gridview_onehalf', |
|
877 | - 'add_location_filter' => 0, |
|
878 | - 'listing_width' => '', |
|
879 | - 'list_sort' => 'latest', |
|
880 | - 'character_count' => 20, |
|
881 | - 'is_widget' => 1, |
|
882 | - 'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>', |
|
883 | - ); |
|
884 | - // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet. |
|
885 | - |
|
886 | - $params = shortcode_atts($defaults, $atts); |
|
887 | - |
|
888 | - /** |
|
889 | - * Begin validating parameters |
|
890 | - */ |
|
872 | + ob_start(); |
|
873 | + $defaults = array( |
|
874 | + 'post_number' => 5, |
|
875 | + 'relate_to' => 'category', |
|
876 | + 'layout' => 'gridview_onehalf', |
|
877 | + 'add_location_filter' => 0, |
|
878 | + 'listing_width' => '', |
|
879 | + 'list_sort' => 'latest', |
|
880 | + 'character_count' => 20, |
|
881 | + 'is_widget' => 1, |
|
882 | + 'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>', |
|
883 | + ); |
|
884 | + // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet. |
|
891 | 885 | |
892 | - // Validate that post_number is a number and is 1 or higher |
|
893 | - $params['post_number'] = absint($params['post_number']); |
|
894 | - if (0 === $params['post_number']) { |
|
895 | - $params['post_number'] = 1; |
|
896 | - } |
|
886 | + $params = shortcode_atts($defaults, $atts); |
|
897 | 887 | |
898 | - // Validate relate_to - only category or tags |
|
899 | - $params['relate_to'] = geodir_strtolower($params['relate_to']); |
|
900 | - if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) { |
|
901 | - $params['relate_to'] = 'category'; |
|
902 | - } |
|
888 | + /** |
|
889 | + * Begin validating parameters |
|
890 | + */ |
|
903 | 891 | |
904 | - // Validate layout selection |
|
905 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
892 | + // Validate that post_number is a number and is 1 or higher |
|
893 | + $params['post_number'] = absint($params['post_number']); |
|
894 | + if (0 === $params['post_number']) { |
|
895 | + $params['post_number'] = 1; |
|
896 | + } |
|
906 | 897 | |
907 | - // Validate sorting option |
|
908 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
898 | + // Validate relate_to - only category or tags |
|
899 | + $params['relate_to'] = geodir_strtolower($params['relate_to']); |
|
900 | + if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) { |
|
901 | + $params['relate_to'] = 'category'; |
|
902 | + } |
|
909 | 903 | |
910 | - // Validate add_location_filter |
|
911 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
904 | + // Validate layout selection |
|
905 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
912 | 906 | |
913 | - // Validate listing_width |
|
914 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
907 | + // Validate sorting option |
|
908 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
915 | 909 | |
916 | - // Validate character_count |
|
917 | - $params['character_count'] = absint($params['character_count']); |
|
918 | - if (20 > $params['character_count']) { |
|
919 | - $params['character_count'] = 20; |
|
920 | - } |
|
910 | + // Validate add_location_filter |
|
911 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
921 | 912 | |
922 | - if ($related_display = geodir_related_posts_display($params)) { |
|
923 | - echo $related_display; |
|
924 | - } |
|
925 | - $output = ob_get_contents(); |
|
913 | + // Validate listing_width |
|
914 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
926 | 915 | |
927 | - ob_end_clean(); |
|
916 | + // Validate character_count |
|
917 | + $params['character_count'] = absint($params['character_count']); |
|
918 | + if (20 > $params['character_count']) { |
|
919 | + $params['character_count'] = 20; |
|
920 | + } |
|
928 | 921 | |
929 | - return $output; |
|
922 | + if ($related_display = geodir_related_posts_display($params)) { |
|
923 | + echo $related_display; |
|
924 | + } |
|
925 | + $output = ob_get_contents(); |
|
926 | + |
|
927 | + ob_end_clean(); |
|
928 | + |
|
929 | + return $output; |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | /** |
@@ -950,13 +950,13 @@ discard block |
||
950 | 950 | * @return string Advanced search widget HTML. |
951 | 951 | */ |
952 | 952 | function geodir_sc_advanced_search($atts) { |
953 | - $defaults = array( |
|
953 | + $defaults = array( |
|
954 | 954 | 'title' => '', |
955 | 955 | 'before_widget' => '<section id="geodir_advanced_search-1" class="widget geodir-widget geodir_advance_search_widget">', |
956 | - 'after_widget' => '</section>', |
|
957 | - 'before_title' => '<h3 class="widget-title">', |
|
958 | - 'after_title' => '</h3>', |
|
959 | - 'show_adv_search' => 'default', |
|
956 | + 'after_widget' => '</section>', |
|
957 | + 'before_title' => '<h3 class="widget-title">', |
|
958 | + 'after_title' => '</h3>', |
|
959 | + 'show_adv_search' => 'default', |
|
960 | 960 | 'post_type' => '' |
961 | 961 | ); |
962 | 962 | |
@@ -980,9 +980,9 @@ discard block |
||
980 | 980 | the_widget('geodir_advance_search_widget', $params, $params ); |
981 | 981 | |
982 | 982 | $output = ob_get_contents(); |
983 | - ob_end_clean(); |
|
983 | + ob_end_clean(); |
|
984 | 984 | |
985 | - return $output; |
|
985 | + return $output; |
|
986 | 986 | } |
987 | 987 | add_shortcode('gd_advanced_search', 'geodir_sc_advanced_search'); |
988 | 988 | |
@@ -1028,48 +1028,48 @@ discard block |
||
1028 | 1028 | 'add_location_filter' => '1', |
1029 | 1029 | 'tab_layout' => 'bestof-tabs-on-top', |
1030 | 1030 | 'before_widget' => '<section id="bestof_widget-1" class="widget geodir-widget geodir_bestof_widget geodir_sc_bestof_widget">', |
1031 | - 'after_widget' => '</section>', |
|
1032 | - 'before_title' => '<h3 class="widget-title">', |
|
1033 | - 'after_title' => '</h3>', |
|
1031 | + 'after_widget' => '</section>', |
|
1032 | + 'before_title' => '<h3 class="widget-title">', |
|
1033 | + 'after_title' => '</h3>', |
|
1034 | 1034 | ); |
1035 | 1035 | $params = shortcode_atts($defaults, $atts); |
1036 | 1036 | |
1037 | - /** |
|
1038 | - * Validate our incoming params |
|
1039 | - */ |
|
1037 | + /** |
|
1038 | + * Validate our incoming params |
|
1039 | + */ |
|
1040 | 1040 | |
1041 | - // Validate the selected post type, default to gd_place on fail |
|
1042 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
1043 | - $params['post_type'] = 'gd_place'; |
|
1044 | - } |
|
1041 | + // Validate the selected post type, default to gd_place on fail |
|
1042 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
1043 | + $params['post_type'] = 'gd_place'; |
|
1044 | + } |
|
1045 | 1045 | |
1046 | 1046 | // Post limit needs to be a positive integer |
1047 | - $params['post_limit'] = absint($params['post_limit']); |
|
1048 | - if (0 == $params['post_limit']) { |
|
1049 | - $params['post_limit'] = 5; |
|
1050 | - } |
|
1047 | + $params['post_limit'] = absint($params['post_limit']); |
|
1048 | + if (0 == $params['post_limit']) { |
|
1049 | + $params['post_limit'] = 5; |
|
1050 | + } |
|
1051 | 1051 | |
1052 | 1052 | // Category limit needs to be a positive integer |
1053 | - $params['categ_limit'] = absint($params['categ_limit']); |
|
1054 | - if (0 == $params['categ_limit']) { |
|
1055 | - $params['categ_limit'] = 3; |
|
1056 | - } |
|
1053 | + $params['categ_limit'] = absint($params['categ_limit']); |
|
1054 | + if (0 == $params['categ_limit']) { |
|
1055 | + $params['categ_limit'] = 3; |
|
1056 | + } |
|
1057 | 1057 | |
1058 | 1058 | // Tab layout validation |
1059 | - $params['tab_layout'] = $params['tab_layout']; |
|
1060 | - if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
1061 | - $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
1062 | - } |
|
1059 | + $params['tab_layout'] = $params['tab_layout']; |
|
1060 | + if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
1061 | + $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
1062 | + } |
|
1063 | 1063 | |
1064 | 1064 | // Validate character_count |
1065 | - $params['character_count'] = $params['character_count']; |
|
1065 | + $params['character_count'] = $params['character_count']; |
|
1066 | 1066 | |
1067 | 1067 | ob_start(); |
1068 | 1068 | the_widget('geodir_bestof_widget', $params, $params); |
1069 | - $output = ob_get_contents(); |
|
1070 | - ob_end_clean(); |
|
1069 | + $output = ob_get_contents(); |
|
1070 | + ob_end_clean(); |
|
1071 | 1071 | |
1072 | - return $output; |
|
1072 | + return $output; |
|
1073 | 1073 | } |
1074 | 1074 | add_shortcode('gd_bestof_widget', 'geodir_sc_bestof_widget'); |
1075 | 1075 | |
@@ -1117,127 +1117,127 @@ discard block |
||
1117 | 1117 | * @return string HTML content to display geodirectory listings. |
1118 | 1118 | */ |
1119 | 1119 | function geodir_sc_gd_listings($atts, $content = '') { |
1120 | - global $post; |
|
1121 | - $defaults = array( |
|
1122 | - 'title' => '', |
|
1123 | - 'post_type' => 'gd_place', |
|
1124 | - 'category' => 0, |
|
1125 | - 'list_sort' => 'latest', |
|
1126 | - 'event_type' => '', |
|
1127 | - 'post_number' => 10, |
|
1128 | - 'post_author' => '', |
|
1129 | - 'layout' => 'gridview_onehalf', |
|
1130 | - 'listing_width' => '', |
|
1131 | - 'character_count' => 20, |
|
1132 | - 'add_location_filter' => 1, |
|
1133 | - 'show_featured_only' => '', |
|
1134 | - 'show_special_only' => '', |
|
1135 | - 'with_pics_only' => '', |
|
1136 | - 'with_videos_only' => '', |
|
1137 | - 'with_pagination' => '1', |
|
1138 | - 'top_pagination' => '0', |
|
1139 | - 'bottom_pagination' => '1', |
|
1140 | - 'without_no_results' => 0, |
|
1141 | - 'tags' => '' |
|
1142 | - ); |
|
1143 | - $params = shortcode_atts($defaults, $atts); |
|
1144 | - |
|
1145 | - $params['title'] = wp_strip_all_tags($params['title']); |
|
1146 | - $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
1147 | - |
|
1148 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
1149 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
1150 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
1151 | - |
|
1152 | - // Make sure we have an array |
|
1153 | - if (!(is_array($params['category']))) { |
|
1154 | - $params['category'] = explode(',', $params['category']); |
|
1155 | - } |
|
1156 | - |
|
1157 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
1158 | - // Otherwise it becomes empty and later on that will mean "All" |
|
1159 | - $params['category'] = array_intersect($params['category'], $categories); |
|
1160 | - |
|
1161 | - // Post_number needs to be a positive integer |
|
1162 | - $params['post_number'] = absint($params['post_number']); |
|
1163 | - $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
1120 | + global $post; |
|
1121 | + $defaults = array( |
|
1122 | + 'title' => '', |
|
1123 | + 'post_type' => 'gd_place', |
|
1124 | + 'category' => 0, |
|
1125 | + 'list_sort' => 'latest', |
|
1126 | + 'event_type' => '', |
|
1127 | + 'post_number' => 10, |
|
1128 | + 'post_author' => '', |
|
1129 | + 'layout' => 'gridview_onehalf', |
|
1130 | + 'listing_width' => '', |
|
1131 | + 'character_count' => 20, |
|
1132 | + 'add_location_filter' => 1, |
|
1133 | + 'show_featured_only' => '', |
|
1134 | + 'show_special_only' => '', |
|
1135 | + 'with_pics_only' => '', |
|
1136 | + 'with_videos_only' => '', |
|
1137 | + 'with_pagination' => '1', |
|
1138 | + 'top_pagination' => '0', |
|
1139 | + 'bottom_pagination' => '1', |
|
1140 | + 'without_no_results' => 0, |
|
1141 | + 'tags' => '' |
|
1142 | + ); |
|
1143 | + $params = shortcode_atts($defaults, $atts); |
|
1144 | + |
|
1145 | + $params['title'] = wp_strip_all_tags($params['title']); |
|
1146 | + $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
1147 | + |
|
1148 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
1149 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
1150 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
1151 | + |
|
1152 | + // Make sure we have an array |
|
1153 | + if (!(is_array($params['category']))) { |
|
1154 | + $params['category'] = explode(',', $params['category']); |
|
1155 | + } |
|
1156 | + |
|
1157 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
1158 | + // Otherwise it becomes empty and later on that will mean "All" |
|
1159 | + $params['category'] = array_intersect($params['category'], $categories); |
|
1160 | + |
|
1161 | + // Post_number needs to be a positive integer |
|
1162 | + $params['post_number'] = absint($params['post_number']); |
|
1163 | + $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
1164 | 1164 | |
1165 | - // Post_number needs to be a positive integer |
|
1166 | - if (!empty($atts['post_author'])) { |
|
1167 | - if ($atts['post_author'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
1168 | - $params['post_author'] = $post->post_author; |
|
1169 | - } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) { |
|
1170 | - $params['post_author'] = absint($atts['post_author']); |
|
1171 | - } else { |
|
1172 | - unset($params['post_author']); |
|
1173 | - } |
|
1174 | - } else { |
|
1175 | - unset($params['post_author']); |
|
1176 | - } |
|
1177 | - |
|
1178 | - // Validate character_count |
|
1179 | - //todo: is this necessary? |
|
1180 | - $params['character_count'] = $params['character_count']; |
|
1181 | - |
|
1182 | - // Validate our layout choice |
|
1183 | - // Outside of the norm, I added some more simple terms to match the existing |
|
1184 | - // So now I just run the switch to set it properly. |
|
1185 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1186 | - |
|
1187 | - // Validate our sorting choice |
|
1188 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
1189 | - |
|
1190 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
1191 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
1192 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1193 | - |
|
1194 | - // Validate the checkboxes used on the widget |
|
1195 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1196 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
1197 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
1198 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
1199 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
1200 | - $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
1201 | - $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
1202 | - $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
1203 | - |
|
1204 | - // Clean tags |
|
1205 | - if (!empty($params['tags'])) { |
|
1206 | - if (!is_array($params['tags'])) { |
|
1207 | - $comma = _x(',', 'tag delimiter'); |
|
1208 | - if ( ',' !== $comma ) { |
|
1209 | - $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
1210 | - } |
|
1211 | - $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
1212 | - $params['tags'] = array_map('trim', $params['tags']); |
|
1213 | - } |
|
1214 | - } else { |
|
1215 | - $params['tags'] = array(); |
|
1216 | - } |
|
1217 | - |
|
1218 | - /** |
|
1219 | - * End of validation |
|
1220 | - */ |
|
1221 | - if (isset($atts['geodir_ajax'])) { |
|
1222 | - $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
1223 | - unset($atts['geodir_ajax']); |
|
1224 | - } |
|
1225 | - if (isset($atts['pageno'])) { |
|
1226 | - $params['pageno'] = $atts['pageno']; |
|
1227 | - unset($atts['pageno']); |
|
1228 | - } |
|
1229 | - |
|
1230 | - if ( !empty($atts['shortcode_content']) ) { |
|
1231 | - $content = $atts['shortcode_content']; |
|
1232 | - } |
|
1233 | - $params['shortcode_content'] = trim($content); |
|
1234 | - $atts['shortcode_content'] = trim($content); |
|
1165 | + // Post_number needs to be a positive integer |
|
1166 | + if (!empty($atts['post_author'])) { |
|
1167 | + if ($atts['post_author'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
1168 | + $params['post_author'] = $post->post_author; |
|
1169 | + } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) { |
|
1170 | + $params['post_author'] = absint($atts['post_author']); |
|
1171 | + } else { |
|
1172 | + unset($params['post_author']); |
|
1173 | + } |
|
1174 | + } else { |
|
1175 | + unset($params['post_author']); |
|
1176 | + } |
|
1177 | + |
|
1178 | + // Validate character_count |
|
1179 | + //todo: is this necessary? |
|
1180 | + $params['character_count'] = $params['character_count']; |
|
1181 | + |
|
1182 | + // Validate our layout choice |
|
1183 | + // Outside of the norm, I added some more simple terms to match the existing |
|
1184 | + // So now I just run the switch to set it properly. |
|
1185 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1186 | + |
|
1187 | + // Validate our sorting choice |
|
1188 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
1189 | + |
|
1190 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
1191 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
1192 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1193 | + |
|
1194 | + // Validate the checkboxes used on the widget |
|
1195 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1196 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
1197 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
1198 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
1199 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
1200 | + $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
1201 | + $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
1202 | + $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
1203 | + |
|
1204 | + // Clean tags |
|
1205 | + if (!empty($params['tags'])) { |
|
1206 | + if (!is_array($params['tags'])) { |
|
1207 | + $comma = _x(',', 'tag delimiter'); |
|
1208 | + if ( ',' !== $comma ) { |
|
1209 | + $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
1210 | + } |
|
1211 | + $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
1212 | + $params['tags'] = array_map('trim', $params['tags']); |
|
1213 | + } |
|
1214 | + } else { |
|
1215 | + $params['tags'] = array(); |
|
1216 | + } |
|
1217 | + |
|
1218 | + /** |
|
1219 | + * End of validation |
|
1220 | + */ |
|
1221 | + if (isset($atts['geodir_ajax'])) { |
|
1222 | + $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
1223 | + unset($atts['geodir_ajax']); |
|
1224 | + } |
|
1225 | + if (isset($atts['pageno'])) { |
|
1226 | + $params['pageno'] = $atts['pageno']; |
|
1227 | + unset($atts['pageno']); |
|
1228 | + } |
|
1229 | + |
|
1230 | + if ( !empty($atts['shortcode_content']) ) { |
|
1231 | + $content = $atts['shortcode_content']; |
|
1232 | + } |
|
1233 | + $params['shortcode_content'] = trim($content); |
|
1234 | + $atts['shortcode_content'] = trim($content); |
|
1235 | 1235 | |
1236 | - $params['shortcode_atts'] = $atts; |
|
1236 | + $params['shortcode_atts'] = $atts; |
|
1237 | 1237 | |
1238 | - $output = geodir_sc_gd_listings_output($params); |
|
1238 | + $output = geodir_sc_gd_listings_output($params); |
|
1239 | 1239 | |
1240 | - return $output; |
|
1240 | + return $output; |
|
1241 | 1241 | } |
1242 | 1242 | add_shortcode('gd_listings', 'geodir_sc_gd_listings'); |
1243 | 1243 | |
@@ -1277,56 +1277,56 @@ discard block |
||
1277 | 1277 | * @return string HTML content to display CPT categories. |
1278 | 1278 | */ |
1279 | 1279 | function geodir_sc_cpt_categories_widget($atts, $content = '') { |
1280 | - $defaults = array( |
|
1281 | - 'title' => '', |
|
1282 | - 'post_type' => '', // NULL for all |
|
1283 | - 'hide_empty' => '', |
|
1284 | - 'show_count' => '', |
|
1285 | - 'hide_icon' => '', |
|
1286 | - 'cpt_left' => '', |
|
1287 | - 'sort_by' => 'count', |
|
1288 | - 'max_count' => 'all', |
|
1289 | - 'max_level' => '1', |
|
1290 | - 'no_cpt_filter' => '', |
|
1291 | - 'no_cat_filter' => '', |
|
1292 | - 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
1293 | - 'after_widget' => '</section>', |
|
1294 | - 'before_title' => '<h3 class="widget-title">', |
|
1295 | - 'after_title' => '</h3>', |
|
1296 | - ); |
|
1297 | - $params = shortcode_atts($defaults, $atts); |
|
1298 | - |
|
1299 | - /** |
|
1300 | - * Validate our incoming params |
|
1301 | - */ |
|
1302 | - // Make sure we have an array |
|
1303 | - $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
1304 | - |
|
1305 | - // Validate the checkboxes used on the widget |
|
1306 | - $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
1307 | - $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
1308 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1309 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1280 | + $defaults = array( |
|
1281 | + 'title' => '', |
|
1282 | + 'post_type' => '', // NULL for all |
|
1283 | + 'hide_empty' => '', |
|
1284 | + 'show_count' => '', |
|
1285 | + 'hide_icon' => '', |
|
1286 | + 'cpt_left' => '', |
|
1287 | + 'sort_by' => 'count', |
|
1288 | + 'max_count' => 'all', |
|
1289 | + 'max_level' => '1', |
|
1290 | + 'no_cpt_filter' => '', |
|
1291 | + 'no_cat_filter' => '', |
|
1292 | + 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
1293 | + 'after_widget' => '</section>', |
|
1294 | + 'before_title' => '<h3 class="widget-title">', |
|
1295 | + 'after_title' => '</h3>', |
|
1296 | + ); |
|
1297 | + $params = shortcode_atts($defaults, $atts); |
|
1310 | 1298 | |
1311 | - if ($params['max_count'] != 'all') { |
|
1312 | - $params['max_count'] = absint($params['max_count']); |
|
1313 | - } |
|
1299 | + /** |
|
1300 | + * Validate our incoming params |
|
1301 | + */ |
|
1302 | + // Make sure we have an array |
|
1303 | + $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
1304 | + |
|
1305 | + // Validate the checkboxes used on the widget |
|
1306 | + $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
1307 | + $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
1308 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1309 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1310 | + |
|
1311 | + if ($params['max_count'] != 'all') { |
|
1312 | + $params['max_count'] = absint($params['max_count']); |
|
1313 | + } |
|
1314 | 1314 | |
1315 | - if ($params['max_level'] != 'all') { |
|
1316 | - $params['max_level'] = absint($params['max_level']); |
|
1317 | - } |
|
1315 | + if ($params['max_level'] != 'all') { |
|
1316 | + $params['max_level'] = absint($params['max_level']); |
|
1317 | + } |
|
1318 | 1318 | |
1319 | - $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
1320 | - $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
1319 | + $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
1320 | + $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
1321 | 1321 | |
1322 | - $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
1322 | + $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
1323 | 1323 | |
1324 | - ob_start(); |
|
1325 | - the_widget('geodir_cpt_categories_widget', $params, $params); |
|
1326 | - $output = ob_get_contents(); |
|
1327 | - ob_end_clean(); |
|
1324 | + ob_start(); |
|
1325 | + the_widget('geodir_cpt_categories_widget', $params, $params); |
|
1326 | + $output = ob_get_contents(); |
|
1327 | + ob_end_clean(); |
|
1328 | 1328 | |
1329 | - return $output; |
|
1329 | + return $output; |
|
1330 | 1330 | } |
1331 | 1331 | add_shortcode('gd_cpt_categories', 'geodir_sc_cpt_categories_widget'); |
1332 | 1332 | |
@@ -1341,6 +1341,6 @@ discard block |
||
1341 | 1341 | * @return string HTML code. |
1342 | 1342 | */ |
1343 | 1343 | function geodir_sc_responsive_videos($atts, $content) { |
1344 | - return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
1344 | + return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
1345 | 1345 | } |
1346 | 1346 | add_shortcode('gd_video', 'geodir_sc_responsive_videos'); |
1347 | 1347 | \ 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 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | |
301 | 301 | // Array_intersect returns only the items in $params['category'] that are also in our category list |
302 | 302 | // Otherwise it becomes empty and later on that will mean "All" |
303 | - $params['category'] = array_intersect($params['category'], $categories); |
|
303 | + $params['category'] = array_intersect($params['category'], $categories); |
|
304 | 304 | |
305 | 305 | if ($params['post_type'] == 'gd_event') { |
306 | 306 | $params['event_type'] = gdsc_validate_list_filter_choice($params['event_type']); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | 'gd_location' => false, |
317 | 317 | ); |
318 | 318 | |
319 | - if (!empty($params['category']) && isset($params['category'][0]) && (int)$params['category'][0] != 0) { |
|
319 | + if (!empty($params['category']) && isset($params['category'][0]) && (int) $params['category'][0] != 0) { |
|
320 | 320 | $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
321 | 321 | |
322 | 322 | ######### WPML ######### |
@@ -964,20 +964,20 @@ discard block |
||
964 | 964 | |
965 | 965 | $show_adv_search = isset($params['show_adv_search']) && in_array($params['show_adv_search'], array('default', 'always', 'searched')) ? $params['show_adv_search'] : ''; |
966 | 966 | |
967 | - if ($show_adv_search != '' ) { |
|
968 | - $show_adv_class = 'geodir-advance-search-' . $show_adv_search . ' '; |
|
967 | + if ($show_adv_search != '') { |
|
968 | + $show_adv_class = 'geodir-advance-search-'.$show_adv_search.' '; |
|
969 | 969 | if ($show_adv_search == 'searched' && geodir_is_page('search')) { |
970 | 970 | $show_adv_search = 'search'; |
971 | 971 | } |
972 | - $show_adv_attrs = 'data-show-adv="' . $show_adv_search . '"'; |
|
972 | + $show_adv_attrs = 'data-show-adv="'.$show_adv_search.'"'; |
|
973 | 973 | |
974 | - $params['before_widget'] = str_replace('class="', $show_adv_attrs . ' class="' . $show_adv_class, $params['before_widget']); |
|
974 | + $params['before_widget'] = str_replace('class="', $show_adv_attrs.' class="'.$show_adv_class, $params['before_widget']); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | ob_start(); |
978 | 978 | |
979 | 979 | //geodir_get_template_part('listing', 'filter-form'); |
980 | - the_widget('geodir_advance_search_widget', $params, $params ); |
|
980 | + the_widget('geodir_advance_search_widget', $params, $params); |
|
981 | 981 | |
982 | 982 | $output = ob_get_contents(); |
983 | 983 | ob_end_clean(); |
@@ -1177,7 +1177,7 @@ discard block |
||
1177 | 1177 | |
1178 | 1178 | // Validate character_count |
1179 | 1179 | //todo: is this necessary? |
1180 | - $params['character_count'] = $params['character_count']; |
|
1180 | + $params['character_count'] = $params['character_count']; |
|
1181 | 1181 | |
1182 | 1182 | // Validate our layout choice |
1183 | 1183 | // Outside of the norm, I added some more simple terms to match the existing |
@@ -1189,7 +1189,7 @@ discard block |
||
1189 | 1189 | |
1190 | 1190 | // Validate Listing width, used in the template widget-listing-listview.php |
1191 | 1191 | // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
1192 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1192 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1193 | 1193 | |
1194 | 1194 | // Validate the checkboxes used on the widget |
1195 | 1195 | $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
@@ -1205,7 +1205,7 @@ discard block |
||
1205 | 1205 | if (!empty($params['tags'])) { |
1206 | 1206 | if (!is_array($params['tags'])) { |
1207 | 1207 | $comma = _x(',', 'tag delimiter'); |
1208 | - if ( ',' !== $comma ) { |
|
1208 | + if (',' !== $comma) { |
|
1209 | 1209 | $params['tags'] = str_replace($comma, ',', $params['tags']); |
1210 | 1210 | } |
1211 | 1211 | $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
@@ -1227,13 +1227,13 @@ discard block |
||
1227 | 1227 | unset($atts['pageno']); |
1228 | 1228 | } |
1229 | 1229 | |
1230 | - if ( !empty($atts['shortcode_content']) ) { |
|
1230 | + if (!empty($atts['shortcode_content'])) { |
|
1231 | 1231 | $content = $atts['shortcode_content']; |
1232 | 1232 | } |
1233 | 1233 | $params['shortcode_content'] = trim($content); |
1234 | 1234 | $atts['shortcode_content'] = trim($content); |
1235 | 1235 | |
1236 | - $params['shortcode_atts'] = $atts; |
|
1236 | + $params['shortcode_atts'] = $atts; |
|
1237 | 1237 | |
1238 | 1238 | $output = geodir_sc_gd_listings_output($params); |
1239 | 1239 | |
@@ -1305,8 +1305,8 @@ discard block |
||
1305 | 1305 | // Validate the checkboxes used on the widget |
1306 | 1306 | $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
1307 | 1307 | $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
1308 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1309 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1308 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1309 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1310 | 1310 | |
1311 | 1311 | if ($params['max_count'] != 'all') { |
1312 | 1312 | $params['max_count'] = absint($params['max_count']); |