@@ -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 ( function_exists( 'icl_object_id' ) ) { |
|
334 | - $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
335 | - } |
|
336 | - ######### WPML ######### |
|
337 | - |
|
338 | - $tax_query = array( |
|
339 | - 'taxonomy' => $category_taxonomy[0], |
|
340 | - 'field' => 'id', |
|
341 | - 'terms' => $params['category'] |
|
342 | - ); |
|
343 | - |
|
344 | - $query_args['tax_query'] = array( $tax_query ); |
|
345 | - } |
|
346 | - |
|
347 | - $add_post_in_marker_array = true; |
|
348 | - |
|
349 | - if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) { |
|
350 | - global $geodir_event_widget_listview; |
|
351 | - $geodir_event_widget_listview = true; |
|
352 | - |
|
353 | - $query_args['geodir_event_type'] = $params['event_type']; |
|
354 | - |
|
355 | - $listings = geodir_event_get_widget_events( $query_args ); |
|
356 | - |
|
357 | - $geodir_event_widget_listview = false; |
|
358 | - } else { |
|
359 | - $listings = geodir_get_widget_listings( $query_args ); |
|
360 | - } |
|
361 | - |
|
362 | - if ( ! empty( $listings ) ) { |
|
363 | - foreach ( $listings as $listing ) { |
|
364 | - create_marker_jason_of_posts( $listing ); |
|
365 | - } |
|
366 | - } |
|
367 | - |
|
368 | - ob_start(); |
|
369 | - add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array |
|
370 | - |
|
371 | - add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array |
|
372 | - |
|
373 | - add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers |
|
374 | - |
|
375 | - $default_location = geodir_get_default_location(); |
|
376 | - |
|
377 | - $map_args = array( |
|
378 | - 'map_canvas_name' => 'gd_listing_map', |
|
379 | - 'width' => $params['width'], |
|
380 | - 'height' => $params['height'], |
|
381 | - 'zoom' => $params['zoom'], |
|
382 | - 'autozoom' => $params['autozoom'], |
|
383 | - 'sticky' => $params['sticky'], |
|
384 | - 'showall' => $params['showall'], |
|
385 | - 'scrollwheel' => $params['scrollwheel'], |
|
386 | - 'maptype' => $params['maptype'], |
|
387 | - 'child_collapse' => 0, |
|
388 | - 'enable_cat_filters' => false, |
|
389 | - 'enable_text_search' => false, |
|
390 | - 'enable_post_type_filters' => false, |
|
391 | - 'enable_location_filters' => false, |
|
392 | - 'enable_jason_on_load' => true, |
|
393 | - 'ajax_url' => geodir_get_ajax_url(), |
|
394 | - 'latitude' => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '', |
|
395 | - 'longitude' => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '', |
|
396 | - 'streetViewControl' => true, |
|
397 | - 'showPreview' => '0', |
|
398 | - 'maxZoom' => 21, |
|
399 | - 'bubble_size' => 'small', |
|
400 | - ); |
|
401 | - |
|
402 | - if ( is_single() ) { |
|
403 | - global $post; |
|
404 | - if ( isset( $post->post_latitude ) ) { |
|
405 | - $map_args['latitude'] = $post->post_latitude; |
|
406 | - $map_args['longitude'] = $post->post_longitude; |
|
407 | - } |
|
408 | - |
|
409 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
410 | - } else { |
|
411 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
412 | - } |
|
413 | - |
|
414 | - // Add marker cluster |
|
415 | - if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) { |
|
416 | - $map_args['enable_marker_cluster'] = true; |
|
417 | - } else { |
|
418 | - $map_args['enable_marker_cluster'] = false; |
|
419 | - } |
|
420 | - |
|
421 | - geodir_draw_map( $map_args ); |
|
422 | - |
|
423 | - $output = ob_get_contents(); |
|
424 | - |
|
425 | - ob_end_clean(); |
|
426 | - |
|
427 | - foreach ( $backup_globals as $global => $value ) { |
|
428 | - ${$global} = $value; |
|
429 | - } |
|
430 | - |
|
431 | - return $output; |
|
432 | - }else{ |
|
433 | - ob_start(); |
|
434 | - add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
435 | - add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
436 | - add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
437 | - $defaults = array( |
|
438 | - 'width' => '294', |
|
439 | - 'height' => '370', |
|
440 | - 'zoom' => '13', |
|
441 | - 'autozoom' => '', |
|
442 | - 'sticky' => '', |
|
443 | - 'showall' => '0', |
|
444 | - 'scrollwheel' => '0', |
|
445 | - 'maptype' => 'ROADMAP', |
|
446 | - 'child_collapse' => 0, |
|
447 | - 'marker_cluster' => false |
|
448 | - ); |
|
449 | - $params = shortcode_atts($defaults, $atts); |
|
450 | - $params = gdsc_validate_map_args($params); |
|
451 | - $map_args = array( |
|
452 | - 'map_canvas_name' => 'gd_listing_map', |
|
453 | - 'width' => $params['width'], |
|
454 | - 'height' => $params['height'], |
|
455 | - 'zoom' => $params['zoom'], |
|
456 | - 'autozoom' => $params['autozoom'], |
|
457 | - 'sticky' => $params['sticky'], |
|
458 | - 'showall' => $params['showall'], |
|
459 | - 'scrollwheel' => $params['scrollwheel'], |
|
460 | - 'child_collapse' => 0, |
|
461 | - 'enable_cat_filters' => false, |
|
462 | - 'enable_text_search' => false, |
|
463 | - 'enable_post_type_filters' => false, |
|
464 | - 'enable_location_filters' => false, |
|
465 | - 'enable_jason_on_load' => true, |
|
466 | - ); |
|
467 | - if (is_single()) { |
|
468 | - global $post; |
|
469 | - $map_default_lat = $address_latitude = $post->post_latitude; |
|
470 | - $map_default_lng = $address_longitude = $post->post_longitude; |
|
471 | - $mapview = $post->post_mapview; |
|
472 | - $map_args['zoom'] = $post->post_mapzoom; |
|
473 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
474 | - } else { |
|
475 | - $default_location = geodir_get_default_location(); |
|
476 | - $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
477 | - $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
478 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
479 | - } |
|
480 | - if (empty($mapview)) { |
|
481 | - $mapview = 'ROADMAP'; |
|
482 | - } |
|
483 | - // Set default map options |
|
484 | - $map_args['ajax_url'] = geodir_get_ajax_url(); |
|
485 | - $map_args['latitude'] = $map_default_lat; |
|
486 | - $map_args['longitude'] = $map_default_lng; |
|
487 | - $map_args['streetViewControl'] = true; |
|
488 | - $map_args['maptype'] = $mapview; |
|
489 | - $map_args['showPreview'] = '0'; |
|
490 | - $map_args['maxZoom'] = 21; |
|
491 | - $map_args['bubble_size'] = 'small'; |
|
492 | - |
|
493 | - // Add marker cluster |
|
494 | - if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
|
495 | - $map_args['enable_marker_cluster'] = true; |
|
496 | - } else { |
|
497 | - $map_args['enable_marker_cluster'] = false; |
|
498 | - } |
|
499 | - geodir_draw_map($map_args); |
|
500 | - $output = ob_get_contents(); |
|
501 | - ob_end_clean(); |
|
502 | - return $output; |
|
503 | - } |
|
267 | + // if some params are set then we need a new query, if not then we can use the main query |
|
268 | + if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) { |
|
269 | + |
|
270 | + global $add_post_in_marker_array, $gd_sc_map_params; |
|
271 | + $backup_globals = array(); |
|
272 | + $backup_globals['add_post_in_marker_array'] = $add_post_in_marker_array; |
|
273 | + $backup_globals['gd_sc_map_params'] = $gd_sc_map_params; |
|
274 | + |
|
275 | + $defaults = array( |
|
276 | + 'width' => '294', |
|
277 | + 'height' => '370', |
|
278 | + 'zoom' => '13', |
|
279 | + 'autozoom' => '', |
|
280 | + 'sticky' => '', |
|
281 | + 'showall' => '0', |
|
282 | + 'scrollwheel' => '0', |
|
283 | + 'maptype' => 'ROADMAP', |
|
284 | + 'child_collapse' => 0, |
|
285 | + 'marker_cluster' => false, |
|
286 | + 'post_type' => 'gd_place', |
|
287 | + 'category' => '0', |
|
288 | + 'event_type' => 'all' |
|
289 | + ); |
|
290 | + |
|
291 | + $params = shortcode_atts( $defaults, $atts ); |
|
292 | + |
|
293 | + if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) { |
|
294 | + $params['post_type'] = 'gd_place'; |
|
295 | + } |
|
296 | + |
|
297 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
298 | + $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
299 | + $categories = get_terms( $category_taxonomy, array( |
|
300 | + 'orderby' => 'count', |
|
301 | + 'order' => 'DESC', |
|
302 | + 'fields' => 'ids' |
|
303 | + ) ); |
|
304 | + |
|
305 | + // Make sure we have an array |
|
306 | + if ( ! ( is_array( $params['category'] ) ) ) { |
|
307 | + $params['category'] = explode( ',', $params['category'] ); |
|
308 | + } |
|
309 | + |
|
310 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
311 | + // Otherwise it becomes empty and later on that will mean "All" |
|
312 | + $params['category'] = array_intersect( $params['category'], $categories ); |
|
313 | + |
|
314 | + if ( $params['post_type'] == 'gd_event' ) { |
|
315 | + $params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] ); |
|
316 | + } |
|
317 | + |
|
318 | + $params = gdsc_validate_map_args( $params ); |
|
319 | + |
|
320 | + $gd_sc_map_params = $params; |
|
321 | + |
|
322 | + $query_args = array( |
|
323 | + 'posts_per_page' => 1000000, //@todo kiran why was this added? |
|
324 | + 'is_geodir_loop' => true, |
|
325 | + 'gd_location' => false, |
|
326 | + 'post_type' => $params['post_type'], |
|
327 | + ); |
|
328 | + |
|
329 | + if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) { |
|
330 | + $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
331 | + |
|
332 | + ######### WPML ######### |
|
333 | + if ( function_exists( 'icl_object_id' ) ) { |
|
334 | + $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
335 | + } |
|
336 | + ######### WPML ######### |
|
337 | + |
|
338 | + $tax_query = array( |
|
339 | + 'taxonomy' => $category_taxonomy[0], |
|
340 | + 'field' => 'id', |
|
341 | + 'terms' => $params['category'] |
|
342 | + ); |
|
343 | + |
|
344 | + $query_args['tax_query'] = array( $tax_query ); |
|
345 | + } |
|
346 | + |
|
347 | + $add_post_in_marker_array = true; |
|
348 | + |
|
349 | + if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) { |
|
350 | + global $geodir_event_widget_listview; |
|
351 | + $geodir_event_widget_listview = true; |
|
352 | + |
|
353 | + $query_args['geodir_event_type'] = $params['event_type']; |
|
354 | + |
|
355 | + $listings = geodir_event_get_widget_events( $query_args ); |
|
356 | + |
|
357 | + $geodir_event_widget_listview = false; |
|
358 | + } else { |
|
359 | + $listings = geodir_get_widget_listings( $query_args ); |
|
360 | + } |
|
361 | + |
|
362 | + if ( ! empty( $listings ) ) { |
|
363 | + foreach ( $listings as $listing ) { |
|
364 | + create_marker_jason_of_posts( $listing ); |
|
365 | + } |
|
366 | + } |
|
367 | + |
|
368 | + ob_start(); |
|
369 | + add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array |
|
370 | + |
|
371 | + add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array |
|
372 | + |
|
373 | + add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers |
|
374 | + |
|
375 | + $default_location = geodir_get_default_location(); |
|
376 | + |
|
377 | + $map_args = array( |
|
378 | + 'map_canvas_name' => 'gd_listing_map', |
|
379 | + 'width' => $params['width'], |
|
380 | + 'height' => $params['height'], |
|
381 | + 'zoom' => $params['zoom'], |
|
382 | + 'autozoom' => $params['autozoom'], |
|
383 | + 'sticky' => $params['sticky'], |
|
384 | + 'showall' => $params['showall'], |
|
385 | + 'scrollwheel' => $params['scrollwheel'], |
|
386 | + 'maptype' => $params['maptype'], |
|
387 | + 'child_collapse' => 0, |
|
388 | + 'enable_cat_filters' => false, |
|
389 | + 'enable_text_search' => false, |
|
390 | + 'enable_post_type_filters' => false, |
|
391 | + 'enable_location_filters' => false, |
|
392 | + 'enable_jason_on_load' => true, |
|
393 | + 'ajax_url' => geodir_get_ajax_url(), |
|
394 | + 'latitude' => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '', |
|
395 | + 'longitude' => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '', |
|
396 | + 'streetViewControl' => true, |
|
397 | + 'showPreview' => '0', |
|
398 | + 'maxZoom' => 21, |
|
399 | + 'bubble_size' => 'small', |
|
400 | + ); |
|
401 | + |
|
402 | + if ( is_single() ) { |
|
403 | + global $post; |
|
404 | + if ( isset( $post->post_latitude ) ) { |
|
405 | + $map_args['latitude'] = $post->post_latitude; |
|
406 | + $map_args['longitude'] = $post->post_longitude; |
|
407 | + } |
|
408 | + |
|
409 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
410 | + } else { |
|
411 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
412 | + } |
|
413 | + |
|
414 | + // Add marker cluster |
|
415 | + if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) { |
|
416 | + $map_args['enable_marker_cluster'] = true; |
|
417 | + } else { |
|
418 | + $map_args['enable_marker_cluster'] = false; |
|
419 | + } |
|
420 | + |
|
421 | + geodir_draw_map( $map_args ); |
|
422 | + |
|
423 | + $output = ob_get_contents(); |
|
424 | + |
|
425 | + ob_end_clean(); |
|
426 | + |
|
427 | + foreach ( $backup_globals as $global => $value ) { |
|
428 | + ${$global} = $value; |
|
429 | + } |
|
430 | + |
|
431 | + return $output; |
|
432 | + }else{ |
|
433 | + ob_start(); |
|
434 | + add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
435 | + add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
436 | + add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
437 | + $defaults = array( |
|
438 | + 'width' => '294', |
|
439 | + 'height' => '370', |
|
440 | + 'zoom' => '13', |
|
441 | + 'autozoom' => '', |
|
442 | + 'sticky' => '', |
|
443 | + 'showall' => '0', |
|
444 | + 'scrollwheel' => '0', |
|
445 | + 'maptype' => 'ROADMAP', |
|
446 | + 'child_collapse' => 0, |
|
447 | + 'marker_cluster' => false |
|
448 | + ); |
|
449 | + $params = shortcode_atts($defaults, $atts); |
|
450 | + $params = gdsc_validate_map_args($params); |
|
451 | + $map_args = array( |
|
452 | + 'map_canvas_name' => 'gd_listing_map', |
|
453 | + 'width' => $params['width'], |
|
454 | + 'height' => $params['height'], |
|
455 | + 'zoom' => $params['zoom'], |
|
456 | + 'autozoom' => $params['autozoom'], |
|
457 | + 'sticky' => $params['sticky'], |
|
458 | + 'showall' => $params['showall'], |
|
459 | + 'scrollwheel' => $params['scrollwheel'], |
|
460 | + 'child_collapse' => 0, |
|
461 | + 'enable_cat_filters' => false, |
|
462 | + 'enable_text_search' => false, |
|
463 | + 'enable_post_type_filters' => false, |
|
464 | + 'enable_location_filters' => false, |
|
465 | + 'enable_jason_on_load' => true, |
|
466 | + ); |
|
467 | + if (is_single()) { |
|
468 | + global $post; |
|
469 | + $map_default_lat = $address_latitude = $post->post_latitude; |
|
470 | + $map_default_lng = $address_longitude = $post->post_longitude; |
|
471 | + $mapview = $post->post_mapview; |
|
472 | + $map_args['zoom'] = $post->post_mapzoom; |
|
473 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
474 | + } else { |
|
475 | + $default_location = geodir_get_default_location(); |
|
476 | + $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
477 | + $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
478 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
479 | + } |
|
480 | + if (empty($mapview)) { |
|
481 | + $mapview = 'ROADMAP'; |
|
482 | + } |
|
483 | + // Set default map options |
|
484 | + $map_args['ajax_url'] = geodir_get_ajax_url(); |
|
485 | + $map_args['latitude'] = $map_default_lat; |
|
486 | + $map_args['longitude'] = $map_default_lng; |
|
487 | + $map_args['streetViewControl'] = true; |
|
488 | + $map_args['maptype'] = $mapview; |
|
489 | + $map_args['showPreview'] = '0'; |
|
490 | + $map_args['maxZoom'] = 21; |
|
491 | + $map_args['bubble_size'] = 'small'; |
|
492 | + |
|
493 | + // Add marker cluster |
|
494 | + if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
|
495 | + $map_args['enable_marker_cluster'] = true; |
|
496 | + } else { |
|
497 | + $map_args['enable_marker_cluster'] = false; |
|
498 | + } |
|
499 | + geodir_draw_map($map_args); |
|
500 | + $output = ob_get_contents(); |
|
501 | + ob_end_clean(); |
|
502 | + return $output; |
|
503 | + } |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | add_shortcode('gd_listing_slider', 'geodir_sc_listing_slider'); |
@@ -533,120 +533,120 @@ discard block |
||
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'); |
@@ -780,97 +780,97 @@ discard block |
||
780 | 780 | */ |
781 | 781 | function geodir_sc_popular_post_view($atts) |
782 | 782 | { |
783 | - ob_start(); |
|
784 | - $defaults = array( |
|
785 | - 'post_type' => 'gd_place', |
|
786 | - 'category' => '0', |
|
787 | - 'post_number' => '5', |
|
788 | - 'layout' => 'gridview_onehalf', |
|
789 | - 'add_location_filter' => '0', |
|
790 | - 'list_sort' => 'latest', |
|
791 | - 'use_viewing_post_type' => '1', |
|
792 | - 'character_count' => '20', |
|
793 | - 'listing_width' => '', |
|
794 | - 'show_featured_only' => '0', |
|
795 | - 'show_special_only' => '0', |
|
796 | - 'with_pics_only' => '0', |
|
797 | - 'with_videos_only' => '0', |
|
798 | - 'before_widget' => '', |
|
799 | - 'after_widget' => '', |
|
800 | - 'before_title' => '<h3 class="widget-title">', |
|
801 | - 'after_title' => '</h3>', |
|
802 | - 'title' => '', |
|
803 | - 'category_title' => '', |
|
804 | - ); |
|
805 | - |
|
806 | - $params = shortcode_atts($defaults, $atts); |
|
807 | - |
|
808 | - /** |
|
809 | - * Validate our incoming params |
|
810 | - */ |
|
783 | + ob_start(); |
|
784 | + $defaults = array( |
|
785 | + 'post_type' => 'gd_place', |
|
786 | + 'category' => '0', |
|
787 | + 'post_number' => '5', |
|
788 | + 'layout' => 'gridview_onehalf', |
|
789 | + 'add_location_filter' => '0', |
|
790 | + 'list_sort' => 'latest', |
|
791 | + 'use_viewing_post_type' => '1', |
|
792 | + 'character_count' => '20', |
|
793 | + 'listing_width' => '', |
|
794 | + 'show_featured_only' => '0', |
|
795 | + 'show_special_only' => '0', |
|
796 | + 'with_pics_only' => '0', |
|
797 | + 'with_videos_only' => '0', |
|
798 | + 'before_widget' => '', |
|
799 | + 'after_widget' => '', |
|
800 | + 'before_title' => '<h3 class="widget-title">', |
|
801 | + 'after_title' => '</h3>', |
|
802 | + 'title' => '', |
|
803 | + 'category_title' => '', |
|
804 | + ); |
|
811 | 805 | |
812 | - // Validate the selected post type, default to gd_place on fail |
|
813 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
814 | - $params['post_type'] = 'gd_place'; |
|
815 | - } |
|
816 | - |
|
817 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
818 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
819 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
820 | - |
|
821 | - // Make sure we have an array |
|
822 | - if (!(is_array($params['category']))) { |
|
823 | - $params['category'] = explode(',', $params['category']); |
|
824 | - } |
|
825 | - |
|
826 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
827 | - // Otherwise it becomes empty and later on that will mean "All" |
|
828 | - $params['category'] = array_intersect($params['category'], $categories); |
|
829 | - |
|
830 | - // Post_number needs to be a positive integer |
|
831 | - $params['post_number'] = absint($params['post_number']); |
|
832 | - if (0 == $params['post_number']) { |
|
833 | - $params['post_number'] = 1; |
|
834 | - } |
|
835 | - |
|
836 | - // Validate our layout choice |
|
837 | - // Outside of the norm, I added some more simple terms to match the existing |
|
838 | - // So now I just run the switch to set it properly. |
|
839 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
840 | - |
|
841 | - // Validate our sorting choice |
|
842 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
843 | - |
|
844 | - // Validate character_count |
|
845 | - $params['character_count'] = absint($params['character_count']); |
|
846 | - if (20 > $params['character_count']) { |
|
847 | - $params['character_count'] = 20; |
|
848 | - } |
|
849 | - |
|
850 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
851 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
852 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
853 | - |
|
854 | - // Validate the checkboxes used on the widget |
|
855 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
856 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
857 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
858 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
859 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
860 | - $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']); |
|
861 | - |
|
862 | - /** |
|
863 | - * End of validation |
|
864 | - */ |
|
806 | + $params = shortcode_atts($defaults, $atts); |
|
807 | + |
|
808 | + /** |
|
809 | + * Validate our incoming params |
|
810 | + */ |
|
865 | 811 | |
866 | - geodir_popular_postview_output($params, $params); |
|
812 | + // Validate the selected post type, default to gd_place on fail |
|
813 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
814 | + $params['post_type'] = 'gd_place'; |
|
815 | + } |
|
867 | 816 | |
817 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
818 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
819 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
868 | 820 | |
869 | - $output = ob_get_contents(); |
|
821 | + // Make sure we have an array |
|
822 | + if (!(is_array($params['category']))) { |
|
823 | + $params['category'] = explode(',', $params['category']); |
|
824 | + } |
|
870 | 825 | |
871 | - ob_end_clean(); |
|
826 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
827 | + // Otherwise it becomes empty and later on that will mean "All" |
|
828 | + $params['category'] = array_intersect($params['category'], $categories); |
|
872 | 829 | |
873 | - return $output; |
|
830 | + // Post_number needs to be a positive integer |
|
831 | + $params['post_number'] = absint($params['post_number']); |
|
832 | + if (0 == $params['post_number']) { |
|
833 | + $params['post_number'] = 1; |
|
834 | + } |
|
835 | + |
|
836 | + // Validate our layout choice |
|
837 | + // Outside of the norm, I added some more simple terms to match the existing |
|
838 | + // So now I just run the switch to set it properly. |
|
839 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
840 | + |
|
841 | + // Validate our sorting choice |
|
842 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
843 | + |
|
844 | + // Validate character_count |
|
845 | + $params['character_count'] = absint($params['character_count']); |
|
846 | + if (20 > $params['character_count']) { |
|
847 | + $params['character_count'] = 20; |
|
848 | + } |
|
849 | + |
|
850 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
851 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
852 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
853 | + |
|
854 | + // Validate the checkboxes used on the widget |
|
855 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
856 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
857 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
858 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
859 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
860 | + $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']); |
|
861 | + |
|
862 | + /** |
|
863 | + * End of validation |
|
864 | + */ |
|
865 | + |
|
866 | + geodir_popular_postview_output($params, $params); |
|
867 | + |
|
868 | + |
|
869 | + $output = ob_get_contents(); |
|
870 | + |
|
871 | + ob_end_clean(); |
|
872 | + |
|
873 | + return $output; |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | add_shortcode('gd_recent_reviews', 'geodir_sc_recent_reviews'); |
@@ -892,37 +892,37 @@ discard block |
||
892 | 892 | * @return string Recent reviews HTML. |
893 | 893 | */ |
894 | 894 | function geodir_sc_recent_reviews($atts) { |
895 | - ob_start(); |
|
896 | - $defaults = array( |
|
895 | + ob_start(); |
|
896 | + $defaults = array( |
|
897 | 897 | 'title' => '', |
898 | 898 | 'count' => 5, |
899 | - ); |
|
899 | + ); |
|
900 | 900 | |
901 | - $params = shortcode_atts($defaults, $atts); |
|
901 | + $params = shortcode_atts($defaults, $atts); |
|
902 | 902 | |
903 | - $count = absint($params['count']); |
|
904 | - if (0 == $count) { |
|
905 | - $count = 1; |
|
906 | - } |
|
903 | + $count = absint($params['count']); |
|
904 | + if (0 == $count) { |
|
905 | + $count = 1; |
|
906 | + } |
|
907 | 907 | |
908 | 908 | $title = !empty($params['title']) ? __($params['title'], 'geodirectory') : ''; |
909 | 909 | |
910 | - $comments_li = geodir_get_recent_reviews(30, $count, 100, false); |
|
910 | + $comments_li = geodir_get_recent_reviews(30, $count, 100, false); |
|
911 | 911 | |
912 | - if ($comments_li) { |
|
913 | - if ($title != '') { ?> |
|
912 | + if ($comments_li) { |
|
913 | + if ($title != '') { ?> |
|
914 | 914 | <h3 class="geodir-sc-recent-reviews-title widget-title"><?php echo $title; ?></h3> |
915 | 915 | <?php } ?> |
916 | 916 | <div class="geodir_sc_recent_reviews_section"> |
917 | 917 | <ul class="geodir_sc_recent_reviews"><?php echo $comments_li; ?></ul> |
918 | 918 | </div> |
919 | 919 | <?php |
920 | - } |
|
921 | - $output = ob_get_contents(); |
|
920 | + } |
|
921 | + $output = ob_get_contents(); |
|
922 | 922 | |
923 | - ob_end_clean(); |
|
923 | + ob_end_clean(); |
|
924 | 924 | |
925 | - return $output; |
|
925 | + return $output; |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | add_shortcode('gd_related_listings', 'geodir_sc_related_listings'); |
@@ -952,64 +952,64 @@ discard block |
||
952 | 952 | */ |
953 | 953 | function geodir_sc_related_listings($atts) |
954 | 954 | { |
955 | - ob_start(); |
|
956 | - $defaults = array( |
|
957 | - 'post_number' => 5, |
|
958 | - 'relate_to' => 'category', |
|
959 | - 'layout' => 'gridview_onehalf', |
|
960 | - 'add_location_filter' => 0, |
|
961 | - 'listing_width' => '', |
|
962 | - 'list_sort' => 'latest', |
|
963 | - 'character_count' => 20, |
|
964 | - 'is_widget' => 1, |
|
965 | - 'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>', |
|
966 | - ); |
|
967 | - // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet. |
|
968 | - |
|
969 | - $params = shortcode_atts($defaults, $atts); |
|
970 | - |
|
971 | - /** |
|
972 | - * Begin validating parameters |
|
973 | - */ |
|
955 | + ob_start(); |
|
956 | + $defaults = array( |
|
957 | + 'post_number' => 5, |
|
958 | + 'relate_to' => 'category', |
|
959 | + 'layout' => 'gridview_onehalf', |
|
960 | + 'add_location_filter' => 0, |
|
961 | + 'listing_width' => '', |
|
962 | + 'list_sort' => 'latest', |
|
963 | + 'character_count' => 20, |
|
964 | + 'is_widget' => 1, |
|
965 | + 'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>', |
|
966 | + ); |
|
967 | + // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet. |
|
974 | 968 | |
975 | - // Validate that post_number is a number and is 1 or higher |
|
976 | - $params['post_number'] = absint($params['post_number']); |
|
977 | - if (0 === $params['post_number']) { |
|
978 | - $params['post_number'] = 1; |
|
979 | - } |
|
969 | + $params = shortcode_atts($defaults, $atts); |
|
980 | 970 | |
981 | - // Validate relate_to - only category or tags |
|
982 | - $params['relate_to'] = geodir_strtolower($params['relate_to']); |
|
983 | - if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) { |
|
984 | - $params['relate_to'] = 'category'; |
|
985 | - } |
|
971 | + /** |
|
972 | + * Begin validating parameters |
|
973 | + */ |
|
986 | 974 | |
987 | - // Validate layout selection |
|
988 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
975 | + // Validate that post_number is a number and is 1 or higher |
|
976 | + $params['post_number'] = absint($params['post_number']); |
|
977 | + if (0 === $params['post_number']) { |
|
978 | + $params['post_number'] = 1; |
|
979 | + } |
|
989 | 980 | |
990 | - // Validate sorting option |
|
991 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
981 | + // Validate relate_to - only category or tags |
|
982 | + $params['relate_to'] = geodir_strtolower($params['relate_to']); |
|
983 | + if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) { |
|
984 | + $params['relate_to'] = 'category'; |
|
985 | + } |
|
992 | 986 | |
993 | - // Validate add_location_filter |
|
994 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
987 | + // Validate layout selection |
|
988 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
995 | 989 | |
996 | - // Validate listing_width |
|
997 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
990 | + // Validate sorting option |
|
991 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
998 | 992 | |
999 | - // Validate character_count |
|
1000 | - $params['character_count'] = absint($params['character_count']); |
|
1001 | - if (20 > $params['character_count']) { |
|
1002 | - $params['character_count'] = 20; |
|
1003 | - } |
|
993 | + // Validate add_location_filter |
|
994 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1004 | 995 | |
1005 | - if ($related_display = geodir_related_posts_display($params)) { |
|
1006 | - echo $related_display; |
|
1007 | - } |
|
1008 | - $output = ob_get_contents(); |
|
996 | + // Validate listing_width |
|
997 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1009 | 998 | |
1010 | - ob_end_clean(); |
|
999 | + // Validate character_count |
|
1000 | + $params['character_count'] = absint($params['character_count']); |
|
1001 | + if (20 > $params['character_count']) { |
|
1002 | + $params['character_count'] = 20; |
|
1003 | + } |
|
1011 | 1004 | |
1012 | - return $output; |
|
1005 | + if ($related_display = geodir_related_posts_display($params)) { |
|
1006 | + echo $related_display; |
|
1007 | + } |
|
1008 | + $output = ob_get_contents(); |
|
1009 | + |
|
1010 | + ob_end_clean(); |
|
1011 | + |
|
1012 | + return $output; |
|
1013 | 1013 | } |
1014 | 1014 | |
1015 | 1015 | /** |
@@ -1033,13 +1033,13 @@ discard block |
||
1033 | 1033 | * @return string Advanced search widget HTML. |
1034 | 1034 | */ |
1035 | 1035 | function geodir_sc_advanced_search($atts) { |
1036 | - $defaults = array( |
|
1036 | + $defaults = array( |
|
1037 | 1037 | 'title' => '', |
1038 | 1038 | 'before_widget' => '<section id="geodir_advanced_search-1" class="widget geodir-widget geodir_advance_search_widget">', |
1039 | - 'after_widget' => '</section>', |
|
1040 | - 'before_title' => '<h3 class="widget-title">', |
|
1041 | - 'after_title' => '</h3>', |
|
1042 | - 'show_adv_search' => 'default', |
|
1039 | + 'after_widget' => '</section>', |
|
1040 | + 'before_title' => '<h3 class="widget-title">', |
|
1041 | + 'after_title' => '</h3>', |
|
1042 | + 'show_adv_search' => 'default', |
|
1043 | 1043 | 'post_type' => '' |
1044 | 1044 | ); |
1045 | 1045 | |
@@ -1063,9 +1063,9 @@ discard block |
||
1063 | 1063 | the_widget('geodir_advance_search_widget', $params, $params ); |
1064 | 1064 | |
1065 | 1065 | $output = ob_get_contents(); |
1066 | - ob_end_clean(); |
|
1066 | + ob_end_clean(); |
|
1067 | 1067 | |
1068 | - return $output; |
|
1068 | + return $output; |
|
1069 | 1069 | } |
1070 | 1070 | add_shortcode('gd_advanced_search', 'geodir_sc_advanced_search'); |
1071 | 1071 | |
@@ -1111,48 +1111,48 @@ discard block |
||
1111 | 1111 | 'add_location_filter' => '1', |
1112 | 1112 | 'tab_layout' => 'bestof-tabs-on-top', |
1113 | 1113 | 'before_widget' => '<section id="bestof_widget-1" class="widget geodir-widget geodir_bestof_widget geodir_sc_bestof_widget">', |
1114 | - 'after_widget' => '</section>', |
|
1115 | - 'before_title' => '<h3 class="widget-title">', |
|
1116 | - 'after_title' => '</h3>', |
|
1114 | + 'after_widget' => '</section>', |
|
1115 | + 'before_title' => '<h3 class="widget-title">', |
|
1116 | + 'after_title' => '</h3>', |
|
1117 | 1117 | ); |
1118 | 1118 | $params = shortcode_atts($defaults, $atts); |
1119 | 1119 | |
1120 | - /** |
|
1121 | - * Validate our incoming params |
|
1122 | - */ |
|
1120 | + /** |
|
1121 | + * Validate our incoming params |
|
1122 | + */ |
|
1123 | 1123 | |
1124 | - // Validate the selected post type, default to gd_place on fail |
|
1125 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
1126 | - $params['post_type'] = 'gd_place'; |
|
1127 | - } |
|
1124 | + // Validate the selected post type, default to gd_place on fail |
|
1125 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
1126 | + $params['post_type'] = 'gd_place'; |
|
1127 | + } |
|
1128 | 1128 | |
1129 | 1129 | // Post limit needs to be a positive integer |
1130 | - $params['post_limit'] = absint($params['post_limit']); |
|
1131 | - if (0 == $params['post_limit']) { |
|
1132 | - $params['post_limit'] = 5; |
|
1133 | - } |
|
1130 | + $params['post_limit'] = absint($params['post_limit']); |
|
1131 | + if (0 == $params['post_limit']) { |
|
1132 | + $params['post_limit'] = 5; |
|
1133 | + } |
|
1134 | 1134 | |
1135 | 1135 | // Category limit needs to be a positive integer |
1136 | - $params['categ_limit'] = absint($params['categ_limit']); |
|
1137 | - if (0 == $params['categ_limit']) { |
|
1138 | - $params['categ_limit'] = 3; |
|
1139 | - } |
|
1136 | + $params['categ_limit'] = absint($params['categ_limit']); |
|
1137 | + if (0 == $params['categ_limit']) { |
|
1138 | + $params['categ_limit'] = 3; |
|
1139 | + } |
|
1140 | 1140 | |
1141 | 1141 | // Tab layout validation |
1142 | - $params['tab_layout'] = $params['tab_layout']; |
|
1143 | - if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
1144 | - $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
1145 | - } |
|
1142 | + $params['tab_layout'] = $params['tab_layout']; |
|
1143 | + if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
1144 | + $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
1145 | + } |
|
1146 | 1146 | |
1147 | 1147 | // Validate character_count |
1148 | - $params['character_count'] = $params['character_count']; |
|
1148 | + $params['character_count'] = $params['character_count']; |
|
1149 | 1149 | |
1150 | 1150 | ob_start(); |
1151 | 1151 | the_widget('geodir_bestof_widget', $params, $params); |
1152 | - $output = ob_get_contents(); |
|
1153 | - ob_end_clean(); |
|
1152 | + $output = ob_get_contents(); |
|
1153 | + ob_end_clean(); |
|
1154 | 1154 | |
1155 | - return $output; |
|
1155 | + return $output; |
|
1156 | 1156 | } |
1157 | 1157 | add_shortcode('gd_bestof_widget', 'geodir_sc_bestof_widget'); |
1158 | 1158 | |
@@ -1200,127 +1200,127 @@ discard block |
||
1200 | 1200 | * @return string HTML content to display geodirectory listings. |
1201 | 1201 | */ |
1202 | 1202 | function geodir_sc_gd_listings($atts, $content = '') { |
1203 | - global $post; |
|
1204 | - $defaults = array( |
|
1205 | - 'title' => '', |
|
1206 | - 'post_type' => 'gd_place', |
|
1207 | - 'category' => 0, |
|
1208 | - 'list_sort' => 'latest', |
|
1209 | - 'event_type' => '', |
|
1210 | - 'post_number' => 10, |
|
1211 | - 'post_author' => '', |
|
1212 | - 'layout' => 'gridview_onehalf', |
|
1213 | - 'listing_width' => '', |
|
1214 | - 'character_count' => 20, |
|
1215 | - 'add_location_filter' => 1, |
|
1216 | - 'show_featured_only' => '', |
|
1217 | - 'show_special_only' => '', |
|
1218 | - 'with_pics_only' => '', |
|
1219 | - 'with_videos_only' => '', |
|
1220 | - 'with_pagination' => '1', |
|
1221 | - 'top_pagination' => '0', |
|
1222 | - 'bottom_pagination' => '1', |
|
1223 | - 'without_no_results' => 0, |
|
1224 | - 'tags' => '' |
|
1225 | - ); |
|
1226 | - $params = shortcode_atts($defaults, $atts); |
|
1227 | - |
|
1228 | - $params['title'] = wp_strip_all_tags($params['title']); |
|
1229 | - $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
1230 | - |
|
1231 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
1232 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
1233 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
1234 | - |
|
1235 | - // Make sure we have an array |
|
1236 | - if (!(is_array($params['category']))) { |
|
1237 | - $params['category'] = explode(',', $params['category']); |
|
1238 | - } |
|
1239 | - |
|
1240 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
1241 | - // Otherwise it becomes empty and later on that will mean "All" |
|
1242 | - $params['category'] = array_intersect($params['category'], $categories); |
|
1243 | - |
|
1244 | - // Post_number needs to be a positive integer |
|
1245 | - $params['post_number'] = absint($params['post_number']); |
|
1246 | - $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
1203 | + global $post; |
|
1204 | + $defaults = array( |
|
1205 | + 'title' => '', |
|
1206 | + 'post_type' => 'gd_place', |
|
1207 | + 'category' => 0, |
|
1208 | + 'list_sort' => 'latest', |
|
1209 | + 'event_type' => '', |
|
1210 | + 'post_number' => 10, |
|
1211 | + 'post_author' => '', |
|
1212 | + 'layout' => 'gridview_onehalf', |
|
1213 | + 'listing_width' => '', |
|
1214 | + 'character_count' => 20, |
|
1215 | + 'add_location_filter' => 1, |
|
1216 | + 'show_featured_only' => '', |
|
1217 | + 'show_special_only' => '', |
|
1218 | + 'with_pics_only' => '', |
|
1219 | + 'with_videos_only' => '', |
|
1220 | + 'with_pagination' => '1', |
|
1221 | + 'top_pagination' => '0', |
|
1222 | + 'bottom_pagination' => '1', |
|
1223 | + 'without_no_results' => 0, |
|
1224 | + 'tags' => '' |
|
1225 | + ); |
|
1226 | + $params = shortcode_atts($defaults, $atts); |
|
1227 | + |
|
1228 | + $params['title'] = wp_strip_all_tags($params['title']); |
|
1229 | + $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
1230 | + |
|
1231 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
1232 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
1233 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
1234 | + |
|
1235 | + // Make sure we have an array |
|
1236 | + if (!(is_array($params['category']))) { |
|
1237 | + $params['category'] = explode(',', $params['category']); |
|
1238 | + } |
|
1239 | + |
|
1240 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
1241 | + // Otherwise it becomes empty and later on that will mean "All" |
|
1242 | + $params['category'] = array_intersect($params['category'], $categories); |
|
1243 | + |
|
1244 | + // Post_number needs to be a positive integer |
|
1245 | + $params['post_number'] = absint($params['post_number']); |
|
1246 | + $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
1247 | 1247 | |
1248 | - // Post_number needs to be a positive integer |
|
1249 | - if (!empty($atts['post_author'])) { |
|
1250 | - if ($atts['post_author'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
1251 | - $params['post_author'] = $post->post_author; |
|
1252 | - } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) { |
|
1253 | - $params['post_author'] = absint($atts['post_author']); |
|
1254 | - } else { |
|
1255 | - unset($params['post_author']); |
|
1256 | - } |
|
1257 | - } else { |
|
1258 | - unset($params['post_author']); |
|
1259 | - } |
|
1260 | - |
|
1261 | - // Validate character_count |
|
1262 | - //todo: is this necessary? |
|
1263 | - $params['character_count'] = $params['character_count']; |
|
1264 | - |
|
1265 | - // Validate our layout choice |
|
1266 | - // Outside of the norm, I added some more simple terms to match the existing |
|
1267 | - // So now I just run the switch to set it properly. |
|
1268 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1269 | - |
|
1270 | - // Validate our sorting choice |
|
1271 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
1272 | - |
|
1273 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
1274 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
1275 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1276 | - |
|
1277 | - // Validate the checkboxes used on the widget |
|
1278 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1279 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
1280 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
1281 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
1282 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
1283 | - $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
1284 | - $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
1285 | - $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
1286 | - |
|
1287 | - // Clean tags |
|
1288 | - if (!empty($params['tags'])) { |
|
1289 | - if (!is_array($params['tags'])) { |
|
1290 | - $comma = _x(',', 'tag delimiter'); |
|
1291 | - if ( ',' !== $comma ) { |
|
1292 | - $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
1293 | - } |
|
1294 | - $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
1295 | - $params['tags'] = array_map('trim', $params['tags']); |
|
1296 | - } |
|
1297 | - } else { |
|
1298 | - $params['tags'] = array(); |
|
1299 | - } |
|
1300 | - |
|
1301 | - /** |
|
1302 | - * End of validation |
|
1303 | - */ |
|
1304 | - if (isset($atts['geodir_ajax'])) { |
|
1305 | - $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
1306 | - unset($atts['geodir_ajax']); |
|
1307 | - } |
|
1308 | - if (isset($atts['pageno'])) { |
|
1309 | - $params['pageno'] = $atts['pageno']; |
|
1310 | - unset($atts['pageno']); |
|
1311 | - } |
|
1312 | - |
|
1313 | - if ( !empty($atts['shortcode_content']) ) { |
|
1314 | - $content = $atts['shortcode_content']; |
|
1315 | - } |
|
1316 | - $params['shortcode_content'] = trim($content); |
|
1317 | - $atts['shortcode_content'] = trim($content); |
|
1248 | + // Post_number needs to be a positive integer |
|
1249 | + if (!empty($atts['post_author'])) { |
|
1250 | + if ($atts['post_author'] == 'current' && !empty($post) && isset($post->post_author) && $post->post_type != 'page') { |
|
1251 | + $params['post_author'] = $post->post_author; |
|
1252 | + } else if ($atts['post_author'] != 'current' && absint($atts['post_author']) > 0) { |
|
1253 | + $params['post_author'] = absint($atts['post_author']); |
|
1254 | + } else { |
|
1255 | + unset($params['post_author']); |
|
1256 | + } |
|
1257 | + } else { |
|
1258 | + unset($params['post_author']); |
|
1259 | + } |
|
1260 | + |
|
1261 | + // Validate character_count |
|
1262 | + //todo: is this necessary? |
|
1263 | + $params['character_count'] = $params['character_count']; |
|
1264 | + |
|
1265 | + // Validate our layout choice |
|
1266 | + // Outside of the norm, I added some more simple terms to match the existing |
|
1267 | + // So now I just run the switch to set it properly. |
|
1268 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1269 | + |
|
1270 | + // Validate our sorting choice |
|
1271 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
1272 | + |
|
1273 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
1274 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
1275 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1276 | + |
|
1277 | + // Validate the checkboxes used on the widget |
|
1278 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1279 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
1280 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
1281 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
1282 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
1283 | + $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
1284 | + $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
1285 | + $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
1286 | + |
|
1287 | + // Clean tags |
|
1288 | + if (!empty($params['tags'])) { |
|
1289 | + if (!is_array($params['tags'])) { |
|
1290 | + $comma = _x(',', 'tag delimiter'); |
|
1291 | + if ( ',' !== $comma ) { |
|
1292 | + $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
1293 | + } |
|
1294 | + $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
1295 | + $params['tags'] = array_map('trim', $params['tags']); |
|
1296 | + } |
|
1297 | + } else { |
|
1298 | + $params['tags'] = array(); |
|
1299 | + } |
|
1300 | + |
|
1301 | + /** |
|
1302 | + * End of validation |
|
1303 | + */ |
|
1304 | + if (isset($atts['geodir_ajax'])) { |
|
1305 | + $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
1306 | + unset($atts['geodir_ajax']); |
|
1307 | + } |
|
1308 | + if (isset($atts['pageno'])) { |
|
1309 | + $params['pageno'] = $atts['pageno']; |
|
1310 | + unset($atts['pageno']); |
|
1311 | + } |
|
1312 | + |
|
1313 | + if ( !empty($atts['shortcode_content']) ) { |
|
1314 | + $content = $atts['shortcode_content']; |
|
1315 | + } |
|
1316 | + $params['shortcode_content'] = trim($content); |
|
1317 | + $atts['shortcode_content'] = trim($content); |
|
1318 | 1318 | |
1319 | - $params['shortcode_atts'] = $atts; |
|
1319 | + $params['shortcode_atts'] = $atts; |
|
1320 | 1320 | |
1321 | - $output = geodir_sc_gd_listings_output($params); |
|
1321 | + $output = geodir_sc_gd_listings_output($params); |
|
1322 | 1322 | |
1323 | - return $output; |
|
1323 | + return $output; |
|
1324 | 1324 | } |
1325 | 1325 | add_shortcode('gd_listings', 'geodir_sc_gd_listings'); |
1326 | 1326 | |
@@ -1360,56 +1360,56 @@ discard block |
||
1360 | 1360 | * @return string HTML content to display CPT categories. |
1361 | 1361 | */ |
1362 | 1362 | function geodir_sc_cpt_categories_widget($atts, $content = '') { |
1363 | - $defaults = array( |
|
1364 | - 'title' => '', |
|
1365 | - 'post_type' => '', // NULL for all |
|
1366 | - 'hide_empty' => '', |
|
1367 | - 'show_count' => '', |
|
1368 | - 'hide_icon' => '', |
|
1369 | - 'cpt_left' => '', |
|
1370 | - 'sort_by' => 'count', |
|
1371 | - 'max_count' => 'all', |
|
1372 | - 'max_level' => '1', |
|
1373 | - 'no_cpt_filter' => '', |
|
1374 | - 'no_cat_filter' => '', |
|
1375 | - 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
1376 | - 'after_widget' => '</section>', |
|
1377 | - 'before_title' => '<h3 class="widget-title">', |
|
1378 | - 'after_title' => '</h3>', |
|
1379 | - ); |
|
1380 | - $params = shortcode_atts($defaults, $atts); |
|
1381 | - |
|
1382 | - /** |
|
1383 | - * Validate our incoming params |
|
1384 | - */ |
|
1385 | - // Make sure we have an array |
|
1386 | - $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
1387 | - |
|
1388 | - // Validate the checkboxes used on the widget |
|
1389 | - $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
1390 | - $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
1391 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1392 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1363 | + $defaults = array( |
|
1364 | + 'title' => '', |
|
1365 | + 'post_type' => '', // NULL for all |
|
1366 | + 'hide_empty' => '', |
|
1367 | + 'show_count' => '', |
|
1368 | + 'hide_icon' => '', |
|
1369 | + 'cpt_left' => '', |
|
1370 | + 'sort_by' => 'count', |
|
1371 | + 'max_count' => 'all', |
|
1372 | + 'max_level' => '1', |
|
1373 | + 'no_cpt_filter' => '', |
|
1374 | + 'no_cat_filter' => '', |
|
1375 | + 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
1376 | + 'after_widget' => '</section>', |
|
1377 | + 'before_title' => '<h3 class="widget-title">', |
|
1378 | + 'after_title' => '</h3>', |
|
1379 | + ); |
|
1380 | + $params = shortcode_atts($defaults, $atts); |
|
1393 | 1381 | |
1394 | - if ($params['max_count'] != 'all') { |
|
1395 | - $params['max_count'] = absint($params['max_count']); |
|
1396 | - } |
|
1382 | + /** |
|
1383 | + * Validate our incoming params |
|
1384 | + */ |
|
1385 | + // Make sure we have an array |
|
1386 | + $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
1387 | + |
|
1388 | + // Validate the checkboxes used on the widget |
|
1389 | + $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
1390 | + $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
1391 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1392 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1393 | + |
|
1394 | + if ($params['max_count'] != 'all') { |
|
1395 | + $params['max_count'] = absint($params['max_count']); |
|
1396 | + } |
|
1397 | 1397 | |
1398 | - if ($params['max_level'] != 'all') { |
|
1399 | - $params['max_level'] = absint($params['max_level']); |
|
1400 | - } |
|
1398 | + if ($params['max_level'] != 'all') { |
|
1399 | + $params['max_level'] = absint($params['max_level']); |
|
1400 | + } |
|
1401 | 1401 | |
1402 | - $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
1403 | - $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
1402 | + $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
1403 | + $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
1404 | 1404 | |
1405 | - $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
1405 | + $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
1406 | 1406 | |
1407 | - ob_start(); |
|
1408 | - the_widget('geodir_cpt_categories_widget', $params, $params); |
|
1409 | - $output = ob_get_contents(); |
|
1410 | - ob_end_clean(); |
|
1407 | + ob_start(); |
|
1408 | + the_widget('geodir_cpt_categories_widget', $params, $params); |
|
1409 | + $output = ob_get_contents(); |
|
1410 | + ob_end_clean(); |
|
1411 | 1411 | |
1412 | - return $output; |
|
1412 | + return $output; |
|
1413 | 1413 | } |
1414 | 1414 | add_shortcode('gd_cpt_categories', 'geodir_sc_cpt_categories_widget'); |
1415 | 1415 | |
@@ -1424,6 +1424,6 @@ discard block |
||
1424 | 1424 | * @return string HTML code. |
1425 | 1425 | */ |
1426 | 1426 | function geodir_sc_responsive_videos($atts, $content) { |
1427 | - return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
1427 | + return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
1428 | 1428 | } |
1429 | 1429 | add_shortcode('gd_video', 'geodir_sc_responsive_videos'); |
1430 | 1430 | \ 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 ( function_exists( 'icl_object_id' ) ) { |
|
334 | - $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
333 | + if (function_exists('icl_object_id')) { |
|
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 |
@@ -1047,20 +1047,20 @@ discard block |
||
1047 | 1047 | |
1048 | 1048 | $show_adv_search = isset($params['show_adv_search']) && in_array($params['show_adv_search'], array('default', 'always', 'searched')) ? $params['show_adv_search'] : ''; |
1049 | 1049 | |
1050 | - if ($show_adv_search != '' ) { |
|
1051 | - $show_adv_class = 'geodir-advance-search-' . $show_adv_search . ' '; |
|
1050 | + if ($show_adv_search != '') { |
|
1051 | + $show_adv_class = 'geodir-advance-search-'.$show_adv_search.' '; |
|
1052 | 1052 | if ($show_adv_search == 'searched' && geodir_is_page('search')) { |
1053 | 1053 | $show_adv_search = 'search'; |
1054 | 1054 | } |
1055 | - $show_adv_attrs = 'data-show-adv="' . $show_adv_search . '"'; |
|
1055 | + $show_adv_attrs = 'data-show-adv="'.$show_adv_search.'"'; |
|
1056 | 1056 | |
1057 | - $params['before_widget'] = str_replace('class="', $show_adv_attrs . ' class="' . $show_adv_class, $params['before_widget']); |
|
1057 | + $params['before_widget'] = str_replace('class="', $show_adv_attrs.' class="'.$show_adv_class, $params['before_widget']); |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | ob_start(); |
1061 | 1061 | |
1062 | 1062 | //geodir_get_template_part('listing', 'filter-form'); |
1063 | - the_widget('geodir_advance_search_widget', $params, $params ); |
|
1063 | + the_widget('geodir_advance_search_widget', $params, $params); |
|
1064 | 1064 | |
1065 | 1065 | $output = ob_get_contents(); |
1066 | 1066 | ob_end_clean(); |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | |
1261 | 1261 | // Validate character_count |
1262 | 1262 | //todo: is this necessary? |
1263 | - $params['character_count'] = $params['character_count']; |
|
1263 | + $params['character_count'] = $params['character_count']; |
|
1264 | 1264 | |
1265 | 1265 | // Validate our layout choice |
1266 | 1266 | // Outside of the norm, I added some more simple terms to match the existing |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | |
1273 | 1273 | // Validate Listing width, used in the template widget-listing-listview.php |
1274 | 1274 | // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
1275 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1275 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1276 | 1276 | |
1277 | 1277 | // Validate the checkboxes used on the widget |
1278 | 1278 | $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | if (!empty($params['tags'])) { |
1289 | 1289 | if (!is_array($params['tags'])) { |
1290 | 1290 | $comma = _x(',', 'tag delimiter'); |
1291 | - if ( ',' !== $comma ) { |
|
1291 | + if (',' !== $comma) { |
|
1292 | 1292 | $params['tags'] = str_replace($comma, ',', $params['tags']); |
1293 | 1293 | } |
1294 | 1294 | $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
@@ -1310,13 +1310,13 @@ discard block |
||
1310 | 1310 | unset($atts['pageno']); |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - if ( !empty($atts['shortcode_content']) ) { |
|
1313 | + if (!empty($atts['shortcode_content'])) { |
|
1314 | 1314 | $content = $atts['shortcode_content']; |
1315 | 1315 | } |
1316 | 1316 | $params['shortcode_content'] = trim($content); |
1317 | 1317 | $atts['shortcode_content'] = trim($content); |
1318 | 1318 | |
1319 | - $params['shortcode_atts'] = $atts; |
|
1319 | + $params['shortcode_atts'] = $atts; |
|
1320 | 1320 | |
1321 | 1321 | $output = geodir_sc_gd_listings_output($params); |
1322 | 1322 | |
@@ -1388,8 +1388,8 @@ discard block |
||
1388 | 1388 | // Validate the checkboxes used on the widget |
1389 | 1389 | $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
1390 | 1390 | $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
1391 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1392 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1391 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1392 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1393 | 1393 | |
1394 | 1394 | if ($params['max_count'] != 'all') { |
1395 | 1395 | $params['max_count'] = absint($params['max_count']); |
@@ -33,265 +33,265 @@ discard block |
||
33 | 33 | */ |
34 | 34 | function geodir_add_nav_menu_items() |
35 | 35 | { |
36 | - $items = ''; |
|
37 | - // apply filter to add more navigations // -Filter-Location-Manager |
|
38 | - |
|
39 | - if (get_option('geodir_show_listing_nav')) { |
|
40 | - |
|
41 | - $menu_class = ''; |
|
42 | - if (geodir_is_page('listing')) |
|
43 | - $menu_class = 'current-menu-item'; |
|
44 | - |
|
45 | - |
|
46 | - //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION |
|
47 | - $post_types = geodir_get_posttypes('object'); |
|
48 | - $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav'); |
|
49 | - if (!empty($post_types)) { |
|
50 | - foreach ($post_types as $post_type => $args) { |
|
51 | - if (!empty($show_post_type_main_nav)) { |
|
52 | - if (in_array($post_type, $show_post_type_main_nav)) { |
|
53 | - if (get_post_type_archive_link($post_type)) { |
|
54 | - $menu_class = ''; |
|
55 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) |
|
56 | - $menu_class = 'current-menu-item'; |
|
57 | - /** |
|
58 | - * Filter the menu li class. |
|
59 | - * |
|
60 | - * @since 1.0.0 |
|
61 | - * @param string $menu_class The menu HTML class. |
|
62 | - */ |
|
63 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); |
|
64 | - /** |
|
65 | - * Filter the menu a class. |
|
66 | - * |
|
67 | - * @since 1.0.0 |
|
68 | - */ |
|
69 | - $a_class = apply_filters('geodir_menu_a_class', ''); |
|
70 | - $items .= '<li class="' . $li_class . '"> |
|
36 | + $items = ''; |
|
37 | + // apply filter to add more navigations // -Filter-Location-Manager |
|
38 | + |
|
39 | + if (get_option('geodir_show_listing_nav')) { |
|
40 | + |
|
41 | + $menu_class = ''; |
|
42 | + if (geodir_is_page('listing')) |
|
43 | + $menu_class = 'current-menu-item'; |
|
44 | + |
|
45 | + |
|
46 | + //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION |
|
47 | + $post_types = geodir_get_posttypes('object'); |
|
48 | + $show_post_type_main_nav = get_option('geodir_add_posttype_in_main_nav'); |
|
49 | + if (!empty($post_types)) { |
|
50 | + foreach ($post_types as $post_type => $args) { |
|
51 | + if (!empty($show_post_type_main_nav)) { |
|
52 | + if (in_array($post_type, $show_post_type_main_nav)) { |
|
53 | + if (get_post_type_archive_link($post_type)) { |
|
54 | + $menu_class = ''; |
|
55 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) |
|
56 | + $menu_class = 'current-menu-item'; |
|
57 | + /** |
|
58 | + * Filter the menu li class. |
|
59 | + * |
|
60 | + * @since 1.0.0 |
|
61 | + * @param string $menu_class The menu HTML class. |
|
62 | + */ |
|
63 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); |
|
64 | + /** |
|
65 | + * Filter the menu a class. |
|
66 | + * |
|
67 | + * @since 1.0.0 |
|
68 | + */ |
|
69 | + $a_class = apply_filters('geodir_menu_a_class', ''); |
|
70 | + $items .= '<li class="' . $li_class . '"> |
|
71 | 71 | <a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '"> |
72 | 72 | ' . __(ucfirst($args->labels->name),'geodirectory') . ' |
73 | 73 | </a> |
74 | 74 | </li>'; |
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
79 | - } |
|
80 | - //END LISTING OF POST TYPE IN MAIN NAVIGATION |
|
81 | - |
|
82 | - $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav'); |
|
83 | - $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false; |
|
84 | - if ($is_listing_sub_meny_exists) { |
|
85 | - /** |
|
86 | - * Filter the menu li class. |
|
87 | - * |
|
88 | - * @since 1.0.0 |
|
89 | - * @param string $menu_class The menu HTML class. |
|
90 | - */ |
|
91 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class); |
|
92 | - /** |
|
93 | - * Filter the sub menu li class. |
|
94 | - * |
|
95 | - * @since 1.0.0 |
|
96 | - * @param string $menu_class The menu HTML class. |
|
97 | - */ |
|
98 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class); |
|
99 | - /** |
|
100 | - * Filter the sub menu ul class. |
|
101 | - * |
|
102 | - * @since 1.0.0 |
|
103 | - */ |
|
104 | - $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu'); |
|
105 | - /** |
|
106 | - * Filter the menu a class. |
|
107 | - * |
|
108 | - * @since 1.0.0 |
|
109 | - */ |
|
110 | - $a_class = apply_filters('geodir_menu_a_class', ''); |
|
111 | - /** |
|
112 | - * Filter the sub menu a class. |
|
113 | - * |
|
114 | - * @since 1.0.0 |
|
115 | - */ |
|
116 | - $sub_a_class = apply_filters('geodir_sub_menu_a_class', ''); |
|
117 | - $items .= '<li class="' . $li_class . '"> |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | + } |
|
80 | + //END LISTING OF POST TYPE IN MAIN NAVIGATION |
|
81 | + |
|
82 | + $view_posttype_listing = get_option('geodir_add_posttype_in_listing_nav'); |
|
83 | + $is_listing_sub_meny_exists = (!empty($view_posttype_listing)) ? true : false; |
|
84 | + if ($is_listing_sub_meny_exists) { |
|
85 | + /** |
|
86 | + * Filter the menu li class. |
|
87 | + * |
|
88 | + * @since 1.0.0 |
|
89 | + * @param string $menu_class The menu HTML class. |
|
90 | + */ |
|
91 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class); |
|
92 | + /** |
|
93 | + * Filter the sub menu li class. |
|
94 | + * |
|
95 | + * @since 1.0.0 |
|
96 | + * @param string $menu_class The menu HTML class. |
|
97 | + */ |
|
98 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class); |
|
99 | + /** |
|
100 | + * Filter the sub menu ul class. |
|
101 | + * |
|
102 | + * @since 1.0.0 |
|
103 | + */ |
|
104 | + $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu'); |
|
105 | + /** |
|
106 | + * Filter the menu a class. |
|
107 | + * |
|
108 | + * @since 1.0.0 |
|
109 | + */ |
|
110 | + $a_class = apply_filters('geodir_menu_a_class', ''); |
|
111 | + /** |
|
112 | + * Filter the sub menu a class. |
|
113 | + * |
|
114 | + * @since 1.0.0 |
|
115 | + */ |
|
116 | + $sub_a_class = apply_filters('geodir_sub_menu_a_class', ''); |
|
117 | + $items .= '<li class="' . $li_class . '"> |
|
118 | 118 | <a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a> |
119 | 119 | <ul class="' . $sub_ul_class . '">'; |
120 | - $post_types = geodir_get_posttypes('object'); |
|
120 | + $post_types = geodir_get_posttypes('object'); |
|
121 | 121 | |
122 | - $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav'); |
|
122 | + $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav'); |
|
123 | 123 | |
124 | - if (!empty($post_types)) { |
|
125 | - global $geodir_add_location_url; |
|
126 | - $geodir_add_location_url = true; |
|
127 | - foreach ($post_types as $post_type => $args) { |
|
128 | - if (!empty($show_listing_post_types)) { |
|
129 | - if (in_array($post_type, $show_listing_post_types)) { |
|
130 | - if (get_post_type_archive_link($post_type)) { |
|
124 | + if (!empty($post_types)) { |
|
125 | + global $geodir_add_location_url; |
|
126 | + $geodir_add_location_url = true; |
|
127 | + foreach ($post_types as $post_type => $args) { |
|
128 | + if (!empty($show_listing_post_types)) { |
|
129 | + if (in_array($post_type, $show_listing_post_types)) { |
|
130 | + if (get_post_type_archive_link($post_type)) { |
|
131 | 131 | |
132 | - $menu_class = ''; |
|
133 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) |
|
134 | - $menu_class = 'current-menu-item'; |
|
132 | + $menu_class = ''; |
|
133 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) |
|
134 | + $menu_class = 'current-menu-item'; |
|
135 | 135 | |
136 | - $items .= '<li class="' . $sub_li_class . '"> |
|
136 | + $items .= '<li class="' . $sub_li_class . '"> |
|
137 | 137 | <a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '"> |
138 | 138 | ' . __(ucfirst($args->labels->name),'geodirectory') . ' |
139 | 139 | </a> |
140 | 140 | </li>'; |
141 | - } |
|
142 | - } |
|
143 | - } |
|
144 | - } |
|
145 | - $geodir_add_location_url = NULL; |
|
146 | - } |
|
141 | + } |
|
142 | + } |
|
143 | + } |
|
144 | + } |
|
145 | + $geodir_add_location_url = NULL; |
|
146 | + } |
|
147 | 147 | |
148 | - $items .= ' </ul> '; |
|
149 | - /** |
|
150 | - * Filter called after the sub menu closing ul tag for dynamic added menu items. |
|
151 | - * |
|
152 | - * @since 1.5.9 |
|
153 | - */ |
|
154 | - $items .= apply_filters('geodir_menu_after_sub_ul',''); |
|
155 | - $items .= '</li>'; |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - if (get_option('geodir_show_addlisting_nav')) { |
|
160 | - |
|
161 | - $menu_class = ''; |
|
162 | - if (geodir_is_page('add-listing')) |
|
163 | - $menu_class = 'current-menu-item'; |
|
164 | - |
|
165 | - //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
166 | - $post_types = geodir_get_posttypes('object'); |
|
167 | - $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav'); |
|
168 | - $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend'); |
|
169 | - |
|
170 | - if (!empty($post_types)) { |
|
171 | - foreach ($post_types as $post_type => $args) { |
|
172 | - if (!empty($geodir_allow_posttype_frontend)) { |
|
173 | - if (in_array($post_type, $geodir_allow_posttype_frontend)) { |
|
174 | - if (!empty($show_add_listing_post_types_main_nav)) { |
|
175 | - if (in_array($post_type, $show_add_listing_post_types_main_nav)) { |
|
176 | - if (geodir_get_addlisting_link($post_type)) { |
|
177 | - |
|
178 | - $menu_class = ''; |
|
179 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) |
|
180 | - $menu_class = 'current-menu-item'; |
|
181 | - /** |
|
182 | - * Filter the menu li class. |
|
183 | - * |
|
184 | - * @since 1.0.0 |
|
185 | - * @param string $menu_class The menu HTML class. |
|
186 | - */ |
|
187 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); |
|
188 | - /** |
|
189 | - * Filter the menu a class. |
|
190 | - * |
|
191 | - * @since 1.0.0 |
|
192 | - */ |
|
193 | - $a_class = apply_filters('geodir_menu_a_class', ''); |
|
194 | - $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
195 | - $items .= '<li class="' . $li_class . '"> |
|
148 | + $items .= ' </ul> '; |
|
149 | + /** |
|
150 | + * Filter called after the sub menu closing ul tag for dynamic added menu items. |
|
151 | + * |
|
152 | + * @since 1.5.9 |
|
153 | + */ |
|
154 | + $items .= apply_filters('geodir_menu_after_sub_ul',''); |
|
155 | + $items .= '</li>'; |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + if (get_option('geodir_show_addlisting_nav')) { |
|
160 | + |
|
161 | + $menu_class = ''; |
|
162 | + if (geodir_is_page('add-listing')) |
|
163 | + $menu_class = 'current-menu-item'; |
|
164 | + |
|
165 | + //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
166 | + $post_types = geodir_get_posttypes('object'); |
|
167 | + $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_main_nav'); |
|
168 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend'); |
|
169 | + |
|
170 | + if (!empty($post_types)) { |
|
171 | + foreach ($post_types as $post_type => $args) { |
|
172 | + if (!empty($geodir_allow_posttype_frontend)) { |
|
173 | + if (in_array($post_type, $geodir_allow_posttype_frontend)) { |
|
174 | + if (!empty($show_add_listing_post_types_main_nav)) { |
|
175 | + if (in_array($post_type, $show_add_listing_post_types_main_nav)) { |
|
176 | + if (geodir_get_addlisting_link($post_type)) { |
|
177 | + |
|
178 | + $menu_class = ''; |
|
179 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) |
|
180 | + $menu_class = 'current-menu-item'; |
|
181 | + /** |
|
182 | + * Filter the menu li class. |
|
183 | + * |
|
184 | + * @since 1.0.0 |
|
185 | + * @param string $menu_class The menu HTML class. |
|
186 | + */ |
|
187 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); |
|
188 | + /** |
|
189 | + * Filter the menu a class. |
|
190 | + * |
|
191 | + * @since 1.0.0 |
|
192 | + */ |
|
193 | + $a_class = apply_filters('geodir_menu_a_class', ''); |
|
194 | + $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
195 | + $items .= '<li class="' . $li_class . '"> |
|
196 | 196 | <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '"> |
197 | 197 | ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . ' |
198 | 198 | </a> |
199 | 199 | </li>'; |
200 | - } |
|
201 | - } |
|
202 | - } |
|
203 | - } |
|
204 | - } |
|
205 | - } |
|
206 | - } |
|
207 | - //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
208 | - } |
|
209 | - |
|
210 | - $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav'); |
|
211 | - $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false; |
|
212 | - if ($is_add_listing_sub_meny_exists) { |
|
213 | - |
|
214 | - if (get_option('geodir_show_addlisting_nav')) { |
|
215 | - /** |
|
216 | - * Filter the menu li class. |
|
217 | - * |
|
218 | - * @since 1.0.0 |
|
219 | - * @param string $menu_class The menu HTML class. |
|
220 | - */ |
|
221 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class); |
|
222 | - /** |
|
223 | - * Filter the sub menu li class. |
|
224 | - * |
|
225 | - * @since 1.0.0 |
|
226 | - * @param string $menu_class The menu HTML class. |
|
227 | - */ |
|
228 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class); |
|
229 | - /** |
|
230 | - * Filter the sub menu ul class. |
|
231 | - * |
|
232 | - * @since 1.0.0 |
|
233 | - */ |
|
234 | - $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu'); |
|
235 | - /** |
|
236 | - * Filter the menu a class. |
|
237 | - * |
|
238 | - * @since 1.0.0 |
|
239 | - */ |
|
240 | - $a_class = apply_filters('geodir_menu_a_class', ''); |
|
241 | - /** |
|
242 | - * Filter the sub menu a class. |
|
243 | - * |
|
244 | - * @since 1.0.0 |
|
245 | - */ |
|
246 | - $sub_a_class = apply_filters('geodir_sub_menu_a_class', ''); |
|
247 | - $items .= '<li class="' . $li_class . '"> |
|
200 | + } |
|
201 | + } |
|
202 | + } |
|
203 | + } |
|
204 | + } |
|
205 | + } |
|
206 | + } |
|
207 | + //END SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
|
208 | + } |
|
209 | + |
|
210 | + $view_add_posttype_listing = get_option('geodir_add_listing_link_add_listing_nav'); |
|
211 | + $is_add_listing_sub_meny_exists = (!empty($view_add_posttype_listing)) ? true : false; |
|
212 | + if ($is_add_listing_sub_meny_exists) { |
|
213 | + |
|
214 | + if (get_option('geodir_show_addlisting_nav')) { |
|
215 | + /** |
|
216 | + * Filter the menu li class. |
|
217 | + * |
|
218 | + * @since 1.0.0 |
|
219 | + * @param string $menu_class The menu HTML class. |
|
220 | + */ |
|
221 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class); |
|
222 | + /** |
|
223 | + * Filter the sub menu li class. |
|
224 | + * |
|
225 | + * @since 1.0.0 |
|
226 | + * @param string $menu_class The menu HTML class. |
|
227 | + */ |
|
228 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class); |
|
229 | + /** |
|
230 | + * Filter the sub menu ul class. |
|
231 | + * |
|
232 | + * @since 1.0.0 |
|
233 | + */ |
|
234 | + $sub_ul_class = apply_filters('geodir_sub_menu_ul_class', 'sub-menu'); |
|
235 | + /** |
|
236 | + * Filter the menu a class. |
|
237 | + * |
|
238 | + * @since 1.0.0 |
|
239 | + */ |
|
240 | + $a_class = apply_filters('geodir_menu_a_class', ''); |
|
241 | + /** |
|
242 | + * Filter the sub menu a class. |
|
243 | + * |
|
244 | + * @since 1.0.0 |
|
245 | + */ |
|
246 | + $sub_a_class = apply_filters('geodir_sub_menu_a_class', ''); |
|
247 | + $items .= '<li class="' . $li_class . '"> |
|
248 | 248 | <a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a> |
249 | 249 | <ul class="' . $sub_ul_class . '">'; |
250 | 250 | |
251 | - $post_types = geodir_get_posttypes('object'); |
|
252 | - |
|
253 | - $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav'); |
|
254 | - |
|
255 | - if (!empty($post_types)) { |
|
256 | - foreach ($post_types as $post_type => $args) { |
|
257 | - if (!empty($geodir_allow_posttype_frontend)) { |
|
258 | - if (in_array($post_type, $geodir_allow_posttype_frontend)) { |
|
259 | - if (!empty($show_add_listing_post_types)) { |
|
260 | - if (in_array($post_type, $show_add_listing_post_types)) { |
|
261 | - if (geodir_get_addlisting_link($post_type)) { |
|
262 | - |
|
263 | - $menu_class = ''; |
|
264 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) |
|
265 | - $menu_class = 'current-menu-item'; |
|
266 | - /** |
|
267 | - * Filter the menu li class. |
|
268 | - * |
|
269 | - * @since 1.0.0 |
|
270 | - * @param string $menu_class The menu HTML class. |
|
271 | - */ |
|
272 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); |
|
273 | - $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
274 | - $items .= '<li class="' . $li_class . '"> |
|
251 | + $post_types = geodir_get_posttypes('object'); |
|
252 | + |
|
253 | + $show_add_listing_post_types = get_option('geodir_add_listing_link_add_listing_nav'); |
|
254 | + |
|
255 | + if (!empty($post_types)) { |
|
256 | + foreach ($post_types as $post_type => $args) { |
|
257 | + if (!empty($geodir_allow_posttype_frontend)) { |
|
258 | + if (in_array($post_type, $geodir_allow_posttype_frontend)) { |
|
259 | + if (!empty($show_add_listing_post_types)) { |
|
260 | + if (in_array($post_type, $show_add_listing_post_types)) { |
|
261 | + if (geodir_get_addlisting_link($post_type)) { |
|
262 | + |
|
263 | + $menu_class = ''; |
|
264 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) |
|
265 | + $menu_class = 'current-menu-item'; |
|
266 | + /** |
|
267 | + * Filter the menu li class. |
|
268 | + * |
|
269 | + * @since 1.0.0 |
|
270 | + * @param string $menu_class The menu HTML class. |
|
271 | + */ |
|
272 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); |
|
273 | + $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
|
274 | + $items .= '<li class="' . $li_class . '"> |
|
275 | 275 | <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '"> |
276 | 276 | ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . ' |
277 | 277 | </a> |
278 | 278 | </li>'; |
279 | - } |
|
280 | - } |
|
281 | - } |
|
282 | - } |
|
283 | - } |
|
284 | - } |
|
285 | - } |
|
279 | + } |
|
280 | + } |
|
281 | + } |
|
282 | + } |
|
283 | + } |
|
284 | + } |
|
285 | + } |
|
286 | 286 | |
287 | - $items .= ' </ul> '; |
|
288 | - $items .= apply_filters('geodir_menu_after_sub_ul',''); |
|
289 | - $items .= '</li>'; |
|
287 | + $items .= ' </ul> '; |
|
288 | + $items .= apply_filters('geodir_menu_after_sub_ul',''); |
|
289 | + $items .= '</li>'; |
|
290 | 290 | |
291 | - } |
|
292 | - } |
|
293 | - // apply filter to add more navigations // -Filter-Location-Manager |
|
294 | - return $items; |
|
291 | + } |
|
292 | + } |
|
293 | + // apply filter to add more navigations // -Filter-Location-Manager |
|
294 | + return $items; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -309,20 +309,20 @@ discard block |
||
309 | 309 | */ |
310 | 310 | function geodir_pagemenu_items($menu, $args) |
311 | 311 | { |
312 | - $locations = get_nav_menu_locations(); |
|
313 | - $geodir_theme_location = get_option('geodir_theme_location_nav'); |
|
314 | - $geodir_theme_location_nav = array(); |
|
315 | - if (empty($locations) && empty($geodir_theme_location)) { |
|
316 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu); |
|
317 | - $geodir_theme_location_nav[] = $args['theme_location']; |
|
318 | - update_option('geodir_theme_location_nav', $geodir_theme_location_nav); |
|
319 | - } |
|
320 | - //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
|
312 | + $locations = get_nav_menu_locations(); |
|
313 | + $geodir_theme_location = get_option('geodir_theme_location_nav'); |
|
314 | + $geodir_theme_location_nav = array(); |
|
315 | + if (empty($locations) && empty($geodir_theme_location)) { |
|
316 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu); |
|
317 | + $geodir_theme_location_nav[] = $args['theme_location']; |
|
318 | + update_option('geodir_theme_location_nav', $geodir_theme_location_nav); |
|
319 | + } |
|
320 | + //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
|
321 | 321 | // $menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu); |
322 | - else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
|
323 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu); |
|
322 | + else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
|
323 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu); |
|
324 | 324 | |
325 | - return $menu; |
|
325 | + return $menu; |
|
326 | 326 | |
327 | 327 | } |
328 | 328 | |
@@ -342,18 +342,18 @@ discard block |
||
342 | 342 | function geodir_menu_items($items, $args) |
343 | 343 | { |
344 | 344 | |
345 | - $location = $args->theme_location; |
|
345 | + $location = $args->theme_location; |
|
346 | 346 | |
347 | - $geodir_theme_location = get_option('geodir_theme_location_nav'); |
|
347 | + $geodir_theme_location = get_option('geodir_theme_location_nav'); |
|
348 | 348 | |
349 | - if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) { |
|
349 | + if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) { |
|
350 | 350 | |
351 | - $items = $items . geodir_add_nav_menu_items(); |
|
352 | - return $items; |
|
351 | + $items = $items . geodir_add_nav_menu_items(); |
|
352 | + return $items; |
|
353 | 353 | |
354 | - } else { |
|
355 | - return $items; |
|
356 | - } |
|
354 | + } else { |
|
355 | + return $items; |
|
356 | + } |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -368,25 +368,25 @@ discard block |
||
368 | 368 | */ |
369 | 369 | function geodir_get_category_all_array() |
370 | 370 | { |
371 | - global $wpdb; |
|
372 | - $return_array = array(); |
|
373 | - |
|
374 | - $taxonomies = geodir_get_taxonomies(); |
|
375 | - $taxonomies = implode("','", $taxonomies); |
|
376 | - $taxonomies = "'" . $taxonomies . "'"; |
|
377 | - |
|
378 | - $pn_categories = $wpdb->get_results( |
|
379 | - $wpdb->prepare( |
|
380 | - "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
|
381 | - array($wpdb->terms . term_id) |
|
382 | - ) |
|
383 | - ); |
|
384 | - |
|
385 | - foreach ($pn_categories as $pn_categories_obj) { |
|
386 | - $return_array[] = array("id" => $pn_categories_obj->cat_ID, |
|
387 | - "title" => $pn_categories_obj->name,); |
|
388 | - } |
|
389 | - return $return_array; |
|
371 | + global $wpdb; |
|
372 | + $return_array = array(); |
|
373 | + |
|
374 | + $taxonomies = geodir_get_taxonomies(); |
|
375 | + $taxonomies = implode("','", $taxonomies); |
|
376 | + $taxonomies = "'" . $taxonomies . "'"; |
|
377 | + |
|
378 | + $pn_categories = $wpdb->get_results( |
|
379 | + $wpdb->prepare( |
|
380 | + "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
|
381 | + array($wpdb->terms . term_id) |
|
382 | + ) |
|
383 | + ); |
|
384 | + |
|
385 | + foreach ($pn_categories as $pn_categories_obj) { |
|
386 | + $return_array[] = array("id" => $pn_categories_obj->cat_ID, |
|
387 | + "title" => $pn_categories_obj->name,); |
|
388 | + } |
|
389 | + return $return_array; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | |
@@ -401,41 +401,41 @@ discard block |
||
401 | 401 | */ |
402 | 402 | function geodir_get_current_posttype() |
403 | 403 | { |
404 | - global $wp_query, $geodir_post_type; |
|
404 | + global $wp_query, $geodir_post_type; |
|
405 | 405 | |
406 | - $geodir_post_type = get_query_var('post_type'); |
|
406 | + $geodir_post_type = get_query_var('post_type'); |
|
407 | 407 | |
408 | - if (geodir_is_page('add-listing') || geodir_is_page('preview')) { |
|
409 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
410 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
411 | - elseif (isset($_REQUEST['listing_type'])) |
|
412 | - $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
413 | - } |
|
408 | + if (geodir_is_page('add-listing') || geodir_is_page('preview')) { |
|
409 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
410 | + $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
411 | + elseif (isset($_REQUEST['listing_type'])) |
|
412 | + $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
413 | + } |
|
414 | 414 | |
415 | - if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) |
|
416 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
415 | + if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) |
|
416 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
417 | 417 | |
418 | - if (is_tax()) |
|
419 | - $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
418 | + if (is_tax()) |
|
419 | + $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
420 | 420 | |
421 | 421 | |
422 | - $all_postypes = geodir_get_posttypes(); |
|
423 | - $all_postypes = stripslashes_deep($all_postypes); |
|
422 | + $all_postypes = geodir_get_posttypes(); |
|
423 | + $all_postypes = stripslashes_deep($all_postypes); |
|
424 | 424 | |
425 | - if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
426 | - $geodir_post_type = ''; |
|
425 | + if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
426 | + $geodir_post_type = ''; |
|
427 | 427 | |
428 | - if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){ |
|
429 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
430 | - } |
|
428 | + if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){ |
|
429 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
430 | + } |
|
431 | 431 | |
432 | 432 | |
433 | - /** |
|
434 | - * Filter the default CPT return. |
|
435 | - * |
|
436 | - * @since 1.6.9 |
|
437 | - */ |
|
438 | - return apply_filters('geodir_get_current_posttype',$geodir_post_type); |
|
433 | + /** |
|
434 | + * Filter the default CPT return. |
|
435 | + * |
|
436 | + * @since 1.6.9 |
|
437 | + */ |
|
438 | + return apply_filters('geodir_get_current_posttype',$geodir_post_type); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -449,22 +449,22 @@ discard block |
||
449 | 449 | */ |
450 | 450 | function geodir_get_default_posttype() |
451 | 451 | { |
452 | - $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
453 | - |
|
454 | - $stype = false; |
|
455 | - foreach ( $post_types as $post_type => $info ) { |
|
456 | - global $wpdb; |
|
457 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
458 | - if ( $has_posts ) { |
|
459 | - $stype = $post_type; break; |
|
460 | - } |
|
461 | - } |
|
462 | - |
|
463 | - if(!$stype){ |
|
464 | - $stype = 'gd_place'; |
|
465 | - } |
|
466 | - |
|
467 | - return $stype; |
|
452 | + $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
453 | + |
|
454 | + $stype = false; |
|
455 | + foreach ( $post_types as $post_type => $info ) { |
|
456 | + global $wpdb; |
|
457 | + $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
458 | + if ( $has_posts ) { |
|
459 | + $stype = $post_type; break; |
|
460 | + } |
|
461 | + } |
|
462 | + |
|
463 | + if(!$stype){ |
|
464 | + $stype = 'gd_place'; |
|
465 | + } |
|
466 | + |
|
467 | + return $stype; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -478,21 +478,21 @@ discard block |
||
478 | 478 | */ |
479 | 479 | function geodir_get_posttypes($output = 'names') |
480 | 480 | { |
481 | - $post_types = array(); |
|
482 | - $post_types = get_option('geodir_post_types'); |
|
483 | - $post_types = stripslashes_deep($post_types); |
|
484 | - if (!empty($post_types)) { |
|
485 | - switch ($output): |
|
486 | - case 'object': |
|
487 | - case 'Object': |
|
488 | - $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
489 | - break; |
|
490 | - case 'array': |
|
491 | - case 'Array': |
|
492 | - $post_types = (array)$post_types; |
|
493 | - break; |
|
481 | + $post_types = array(); |
|
482 | + $post_types = get_option('geodir_post_types'); |
|
483 | + $post_types = stripslashes_deep($post_types); |
|
484 | + if (!empty($post_types)) { |
|
485 | + switch ($output): |
|
486 | + case 'object': |
|
487 | + case 'Object': |
|
488 | + $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
489 | + break; |
|
490 | + case 'array': |
|
491 | + case 'Array': |
|
492 | + $post_types = (array)$post_types; |
|
493 | + break; |
|
494 | 494 | case 'options': |
495 | - $post_types = (array)$post_types; |
|
495 | + $post_types = (array)$post_types; |
|
496 | 496 | |
497 | 497 | $options = array(); |
498 | 498 | if (!empty($post_types)) { |
@@ -501,17 +501,17 @@ discard block |
||
501 | 501 | } |
502 | 502 | } |
503 | 503 | $post_types = $options; |
504 | - break; |
|
505 | - default: |
|
506 | - $post_types = array_keys($post_types); |
|
507 | - break; |
|
508 | - endswitch; |
|
509 | - } |
|
510 | - |
|
511 | - if (!empty($post_types)) |
|
512 | - return $post_types; |
|
513 | - else |
|
514 | - return array(); |
|
504 | + break; |
|
505 | + default: |
|
506 | + $post_types = array_keys($post_types); |
|
507 | + break; |
|
508 | + endswitch; |
|
509 | + } |
|
510 | + |
|
511 | + if (!empty($post_types)) |
|
512 | + return $post_types; |
|
513 | + else |
|
514 | + return array(); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
@@ -524,108 +524,108 @@ discard block |
||
524 | 524 | */ |
525 | 525 | function geodir_get_posttype_info($post_type = '') |
526 | 526 | { |
527 | - $post_types = array(); |
|
528 | - $post_types = get_option('geodir_post_types'); |
|
529 | - $post_types = stripslashes_deep($post_types); |
|
530 | - if (!empty($post_types) && $post_type != '') { |
|
531 | - return $post_types[$post_type]; |
|
532 | - } else |
|
533 | - return false; |
|
527 | + $post_types = array(); |
|
528 | + $post_types = get_option('geodir_post_types'); |
|
529 | + $post_types = stripslashes_deep($post_types); |
|
530 | + if (!empty($post_types) && $post_type != '') { |
|
531 | + return $post_types[$post_type]; |
|
532 | + } else |
|
533 | + return false; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | if (!function_exists('geodir_get_taxonomies')) { |
537 | - /** |
|
538 | - * Get all custom taxonomies. |
|
539 | - * |
|
540 | - * @since 1.0.0 |
|
541 | - * @package GeoDirectory |
|
542 | - * @param string $post_type The post type. |
|
543 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
544 | - * @return array|bool Taxonomies on success. false on failure. |
|
545 | - */ |
|
546 | - function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) |
|
547 | - { |
|
537 | + /** |
|
538 | + * Get all custom taxonomies. |
|
539 | + * |
|
540 | + * @since 1.0.0 |
|
541 | + * @package GeoDirectory |
|
542 | + * @param string $post_type The post type. |
|
543 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
544 | + * @return array|bool Taxonomies on success. false on failure. |
|
545 | + */ |
|
546 | + function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) |
|
547 | + { |
|
548 | 548 | |
549 | - $taxonomies = array(); |
|
550 | - $gd_taxonomies = array(); |
|
549 | + $taxonomies = array(); |
|
550 | + $gd_taxonomies = array(); |
|
551 | 551 | |
552 | - if ($taxonomies = get_option('geodir_taxonomies')) { |
|
552 | + if ($taxonomies = get_option('geodir_taxonomies')) { |
|
553 | 553 | |
554 | 554 | |
555 | - $gd_taxonomies = array_keys($taxonomies); |
|
555 | + $gd_taxonomies = array_keys($taxonomies); |
|
556 | 556 | |
557 | 557 | |
558 | - if ($post_type != '') |
|
559 | - $gd_taxonomies = array(); |
|
558 | + if ($post_type != '') |
|
559 | + $gd_taxonomies = array(); |
|
560 | 560 | |
561 | - $i = 0; |
|
562 | - foreach ($taxonomies as $taxonomy => $args) { |
|
561 | + $i = 0; |
|
562 | + foreach ($taxonomies as $taxonomy => $args) { |
|
563 | 563 | |
564 | - if ($post_type != '' && $args['object_type'] == $post_type) |
|
565 | - $gd_taxonomies[] = $taxonomy; |
|
564 | + if ($post_type != '' && $args['object_type'] == $post_type) |
|
565 | + $gd_taxonomies[] = $taxonomy; |
|
566 | 566 | |
567 | - if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) { |
|
568 | - if (array_search($taxonomy, $gd_taxonomies) !== false) |
|
569 | - unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
570 | - } |
|
567 | + if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) { |
|
568 | + if (array_search($taxonomy, $gd_taxonomies) !== false) |
|
569 | + unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
570 | + } |
|
571 | 571 | |
572 | - } |
|
572 | + } |
|
573 | 573 | |
574 | - $gd_taxonomies = array_values($gd_taxonomies); |
|
575 | - } |
|
576 | - |
|
577 | - /** |
|
578 | - * Filter the taxonomies. |
|
579 | - * |
|
580 | - * @since 1.0.0 |
|
581 | - * @param array $gd_taxonomies The taxonomy array. |
|
582 | - */ |
|
583 | - $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies); |
|
584 | - |
|
585 | - if (!empty($taxonomies)) { |
|
586 | - return $taxonomies; |
|
587 | - } else { |
|
588 | - return false; |
|
589 | - } |
|
590 | - } |
|
574 | + $gd_taxonomies = array_values($gd_taxonomies); |
|
575 | + } |
|
576 | + |
|
577 | + /** |
|
578 | + * Filter the taxonomies. |
|
579 | + * |
|
580 | + * @since 1.0.0 |
|
581 | + * @param array $gd_taxonomies The taxonomy array. |
|
582 | + */ |
|
583 | + $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies); |
|
584 | + |
|
585 | + if (!empty($taxonomies)) { |
|
586 | + return $taxonomies; |
|
587 | + } else { |
|
588 | + return false; |
|
589 | + } |
|
590 | + } |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | if (!function_exists(' geodir_get_categories_dl')) { |
594 | - /** |
|
595 | - * Get categories dropdown HTML. |
|
596 | - * |
|
597 | - * @since 1.0.0 |
|
598 | - * @package GeoDirectory |
|
599 | - * @param string $post_type The post type. |
|
600 | - * @param string $selected The selected value. |
|
601 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
602 | - * @param bool $echo Prints the HTML when set to true. Default: true. |
|
603 | - * @return void|string Dropdown HTML. |
|
604 | - */ |
|
605 | - function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
606 | - { |
|
607 | - |
|
608 | - $html = ''; |
|
609 | - $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
610 | - |
|
611 | - $categories = get_terms($taxonomies); |
|
612 | - |
|
613 | - $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>'; |
|
614 | - |
|
615 | - foreach ($categories as $category_obj) { |
|
616 | - $select_opt = ''; |
|
617 | - if ($selected == $category_obj->term_id) { |
|
618 | - $select_opt = 'selected="selected"'; |
|
619 | - } |
|
620 | - $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
621 | - . ucfirst($category_obj->name) . '</option>'; |
|
622 | - } |
|
623 | - |
|
624 | - if ($echo) |
|
625 | - echo $html; |
|
626 | - else |
|
627 | - return $html; |
|
628 | - } |
|
594 | + /** |
|
595 | + * Get categories dropdown HTML. |
|
596 | + * |
|
597 | + * @since 1.0.0 |
|
598 | + * @package GeoDirectory |
|
599 | + * @param string $post_type The post type. |
|
600 | + * @param string $selected The selected value. |
|
601 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
602 | + * @param bool $echo Prints the HTML when set to true. Default: true. |
|
603 | + * @return void|string Dropdown HTML. |
|
604 | + */ |
|
605 | + function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
606 | + { |
|
607 | + |
|
608 | + $html = ''; |
|
609 | + $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
610 | + |
|
611 | + $categories = get_terms($taxonomies); |
|
612 | + |
|
613 | + $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>'; |
|
614 | + |
|
615 | + foreach ($categories as $category_obj) { |
|
616 | + $select_opt = ''; |
|
617 | + if ($selected == $category_obj->term_id) { |
|
618 | + $select_opt = 'selected="selected"'; |
|
619 | + } |
|
620 | + $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
621 | + . ucfirst($category_obj->name) . '</option>'; |
|
622 | + } |
|
623 | + |
|
624 | + if ($echo) |
|
625 | + echo $html; |
|
626 | + else |
|
627 | + return $html; |
|
628 | + } |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | |
@@ -640,28 +640,28 @@ discard block |
||
640 | 640 | function geodir_get_listing_slug($object_type = '') |
641 | 641 | { |
642 | 642 | |
643 | - $listing_slug = ''; |
|
643 | + $listing_slug = ''; |
|
644 | 644 | |
645 | - $post_types = get_option('geodir_post_types'); |
|
646 | - $taxonomies = get_option('geodir_taxonomies'); |
|
645 | + $post_types = get_option('geodir_post_types'); |
|
646 | + $taxonomies = get_option('geodir_taxonomies'); |
|
647 | 647 | |
648 | 648 | |
649 | - if ($object_type != '') { |
|
650 | - if (!empty($post_types) && array_key_exists($object_type, $post_types)) { |
|
649 | + if ($object_type != '') { |
|
650 | + if (!empty($post_types) && array_key_exists($object_type, $post_types)) { |
|
651 | 651 | |
652 | - $object_info = $post_types[$object_type]; |
|
653 | - $listing_slug = $object_info['listing_slug']; |
|
654 | - } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) { |
|
655 | - $object_info = $taxonomies[$object_type]; |
|
656 | - $listing_slug = $object_info['listing_slug']; |
|
657 | - } |
|
652 | + $object_info = $post_types[$object_type]; |
|
653 | + $listing_slug = $object_info['listing_slug']; |
|
654 | + } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) { |
|
655 | + $object_info = $taxonomies[$object_type]; |
|
656 | + $listing_slug = $object_info['listing_slug']; |
|
657 | + } |
|
658 | 658 | |
659 | - } |
|
659 | + } |
|
660 | 660 | |
661 | - if (!empty($listing_slug)) |
|
662 | - return $listing_slug; |
|
663 | - else |
|
664 | - return false; |
|
661 | + if (!empty($listing_slug)) |
|
662 | + return $listing_slug; |
|
663 | + else |
|
664 | + return false; |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | |
@@ -676,212 +676,212 @@ discard block |
||
676 | 676 | */ |
677 | 677 | function geodir_get_taxonomy_posttype($taxonomy = '') |
678 | 678 | { |
679 | - global $wp_query; |
|
680 | - |
|
681 | - $post_type = array(); |
|
682 | - $taxonomies = array(); |
|
683 | - |
|
684 | - if (!empty($taxonomy)) { |
|
685 | - $taxonomies[] = $taxonomy; |
|
686 | - } elseif (isset($wp_query->tax_query->queries)) { |
|
687 | - $tax_arr = $wp_query->tax_query->queries; |
|
688 | - //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
689 | - if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);} |
|
690 | - $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
691 | - } |
|
692 | - |
|
693 | - if (!empty($taxonomies)) { |
|
694 | - foreach (geodir_get_posttypes() as $pt) { |
|
695 | - $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
696 | - if (array_intersect($taxonomies, $object_taxonomies)) |
|
697 | - $post_type[] = $pt; |
|
698 | - } |
|
699 | - } |
|
700 | - |
|
701 | - if (!empty($post_type)) |
|
702 | - return $post_type[0]; |
|
703 | - else |
|
704 | - return false; |
|
679 | + global $wp_query; |
|
680 | + |
|
681 | + $post_type = array(); |
|
682 | + $taxonomies = array(); |
|
683 | + |
|
684 | + if (!empty($taxonomy)) { |
|
685 | + $taxonomies[] = $taxonomy; |
|
686 | + } elseif (isset($wp_query->tax_query->queries)) { |
|
687 | + $tax_arr = $wp_query->tax_query->queries; |
|
688 | + //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
689 | + if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);} |
|
690 | + $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
691 | + } |
|
692 | + |
|
693 | + if (!empty($taxonomies)) { |
|
694 | + foreach (geodir_get_posttypes() as $pt) { |
|
695 | + $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
696 | + if (array_intersect($taxonomies, $object_taxonomies)) |
|
697 | + $post_type[] = $pt; |
|
698 | + } |
|
699 | + } |
|
700 | + |
|
701 | + if (!empty($post_type)) |
|
702 | + return $post_type[0]; |
|
703 | + else |
|
704 | + return false; |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | if (!function_exists('geodir_custom_taxonomy_walker')) { |
708 | - /** |
|
709 | - * Custom taxonomy walker function. |
|
710 | - * |
|
711 | - * @since 1.0.0 |
|
712 | - * @package GeoDirectory |
|
713 | - * @param string $cat_taxonomy The taxonomy name. |
|
714 | - * @param int $cat_parent The parent term ID. |
|
715 | - * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
716 | - * @param int $pading CSS padding in pixels. |
|
717 | - * @return string|void taxonomy HTML. |
|
718 | - */ |
|
719 | - function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
720 | - { |
|
721 | - global $cat_display, $post_cat, $exclude_cats; |
|
722 | - |
|
723 | - $search_terms = trim($post_cat, ","); |
|
724 | - |
|
725 | - $search_terms = explode(",", $search_terms); |
|
726 | - |
|
727 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats)); |
|
728 | - |
|
729 | - $display = ''; |
|
730 | - $onchange = ''; |
|
731 | - $term_check = ''; |
|
732 | - $main_list_class = ''; |
|
733 | - $out = ''; |
|
734 | - //If there are terms, start displaying |
|
735 | - if (count($cat_terms) > 0) { |
|
736 | - //Displaying as a list |
|
737 | - $p = $pading * 20; |
|
738 | - $pading++; |
|
739 | - |
|
740 | - |
|
741 | - if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) { |
|
742 | - if ($cat_parent == 0) { |
|
743 | - $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
744 | - $main_list_class = 'class="main_list_selecter"'; |
|
745 | - } else { |
|
746 | - //$display = 'display:none'; |
|
747 | - $list_class = 'sub_list gd-sub-cats-list'; |
|
748 | - } |
|
749 | - } |
|
708 | + /** |
|
709 | + * Custom taxonomy walker function. |
|
710 | + * |
|
711 | + * @since 1.0.0 |
|
712 | + * @package GeoDirectory |
|
713 | + * @param string $cat_taxonomy The taxonomy name. |
|
714 | + * @param int $cat_parent The parent term ID. |
|
715 | + * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
716 | + * @param int $pading CSS padding in pixels. |
|
717 | + * @return string|void taxonomy HTML. |
|
718 | + */ |
|
719 | + function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
720 | + { |
|
721 | + global $cat_display, $post_cat, $exclude_cats; |
|
722 | + |
|
723 | + $search_terms = trim($post_cat, ","); |
|
724 | + |
|
725 | + $search_terms = explode(",", $search_terms); |
|
726 | + |
|
727 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats)); |
|
728 | + |
|
729 | + $display = ''; |
|
730 | + $onchange = ''; |
|
731 | + $term_check = ''; |
|
732 | + $main_list_class = ''; |
|
733 | + $out = ''; |
|
734 | + //If there are terms, start displaying |
|
735 | + if (count($cat_terms) > 0) { |
|
736 | + //Displaying as a list |
|
737 | + $p = $pading * 20; |
|
738 | + $pading++; |
|
739 | + |
|
740 | + |
|
741 | + if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) { |
|
742 | + if ($cat_parent == 0) { |
|
743 | + $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
744 | + $main_list_class = 'class="main_list_selecter"'; |
|
745 | + } else { |
|
746 | + //$display = 'display:none'; |
|
747 | + $list_class = 'sub_list gd-sub-cats-list'; |
|
748 | + } |
|
749 | + } |
|
750 | 750 | |
751 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') { |
|
752 | - $p = 0; |
|
753 | - $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
754 | - } |
|
751 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') { |
|
752 | + $p = 0; |
|
753 | + $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
754 | + } |
|
755 | 755 | |
756 | - foreach ($cat_terms as $cat_term) { |
|
756 | + foreach ($cat_terms as $cat_term) { |
|
757 | 757 | |
758 | - $checked = ''; |
|
758 | + $checked = ''; |
|
759 | 759 | |
760 | - if (in_array($cat_term->term_id, $search_terms)) { |
|
761 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
762 | - $checked = 'selected="selected"'; |
|
763 | - else |
|
764 | - $checked = 'checked="checked"'; |
|
765 | - } |
|
760 | + if (in_array($cat_term->term_id, $search_terms)) { |
|
761 | + if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
762 | + $checked = 'selected="selected"'; |
|
763 | + else |
|
764 | + $checked = 'checked="checked"'; |
|
765 | + } |
|
766 | 766 | |
767 | - if ($cat_display == 'radio') |
|
768 | - $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
769 | - elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
770 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>'; |
|
767 | + if ($cat_display == 'radio') |
|
768 | + $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
769 | + elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
770 | + $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>'; |
|
771 | 771 | |
772 | - else { |
|
773 | - $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
774 | - } |
|
772 | + else { |
|
773 | + $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
774 | + } |
|
775 | 775 | |
776 | - // Call recurson to print sub cats |
|
777 | - $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
776 | + // Call recurson to print sub cats |
|
777 | + $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
778 | 778 | |
779 | - } |
|
779 | + } |
|
780 | 780 | |
781 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
782 | - $out .= '</div>'; |
|
781 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
782 | + $out .= '</div>'; |
|
783 | 783 | |
784 | - return $out; |
|
785 | - } |
|
786 | - return; |
|
787 | - } |
|
784 | + return $out; |
|
785 | + } |
|
786 | + return; |
|
787 | + } |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | if (!function_exists('geodir_custom_taxonomy_walker2')) { |
791 | - /** |
|
792 | - * Custom taxonomy walker function. |
|
793 | - * |
|
794 | - * @since 1.0.0 |
|
795 | - * @package GeoDirectory |
|
796 | - * @global object $post WordPress Post object. |
|
797 | - * @global object $gd_session GeoDirectory Session object. |
|
798 | - * @param string $cat_taxonomy The taxonomy name. |
|
799 | - * @param string $cat_limit Number of categories to display. |
|
800 | - */ |
|
801 | - function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
802 | - { |
|
803 | - $post_category = ''; |
|
804 | - $post_category_str = ''; |
|
805 | - global $exclude_cats, $gd_session; |
|
806 | - |
|
807 | - $cat_exclude = ''; |
|
808 | - if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
809 | - $cat_exclude = serialize($exclude_cats); |
|
810 | - |
|
811 | - if (isset($_REQUEST['backandedit'])) { |
|
812 | - $post = (object)$gd_session->get('listing'); |
|
813 | - |
|
814 | - if (!is_array($post->post_category[$cat_taxonomy])) |
|
815 | - $post_category = $post->post_category[$cat_taxonomy]; |
|
816 | - |
|
817 | - $post_categories = $post->post_category_str; |
|
818 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
819 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
820 | - |
|
821 | - } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) { |
|
822 | - global $post; |
|
823 | - |
|
824 | - $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
825 | - if (empty($post_category) && isset($post->{$cat_taxonomy})) { |
|
826 | - $post_category = $post->{$cat_taxonomy}; |
|
827 | - } |
|
791 | + /** |
|
792 | + * Custom taxonomy walker function. |
|
793 | + * |
|
794 | + * @since 1.0.0 |
|
795 | + * @package GeoDirectory |
|
796 | + * @global object $post WordPress Post object. |
|
797 | + * @global object $gd_session GeoDirectory Session object. |
|
798 | + * @param string $cat_taxonomy The taxonomy name. |
|
799 | + * @param string $cat_limit Number of categories to display. |
|
800 | + */ |
|
801 | + function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
802 | + { |
|
803 | + $post_category = ''; |
|
804 | + $post_category_str = ''; |
|
805 | + global $exclude_cats, $gd_session; |
|
806 | + |
|
807 | + $cat_exclude = ''; |
|
808 | + if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
809 | + $cat_exclude = serialize($exclude_cats); |
|
810 | + |
|
811 | + if (isset($_REQUEST['backandedit'])) { |
|
812 | + $post = (object)$gd_session->get('listing'); |
|
813 | + |
|
814 | + if (!is_array($post->post_category[$cat_taxonomy])) |
|
815 | + $post_category = $post->post_category[$cat_taxonomy]; |
|
816 | + |
|
817 | + $post_categories = $post->post_category_str; |
|
818 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
819 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
820 | + |
|
821 | + } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) { |
|
822 | + global $post; |
|
823 | + |
|
824 | + $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
825 | + if (empty($post_category) && isset($post->{$cat_taxonomy})) { |
|
826 | + $post_category = $post->{$cat_taxonomy}; |
|
827 | + } |
|
828 | 828 | |
829 | - $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
829 | + $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
830 | 830 | |
831 | - if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) { |
|
832 | - foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) { |
|
833 | - if (is_numeric($cat_part)) { |
|
834 | - $cat_part_arr[] = $cat_part; |
|
835 | - } |
|
836 | - } |
|
837 | - if (is_array($cat_part_arr)) { |
|
838 | - $post_category = implode(',', $cat_part_arr); |
|
839 | - } |
|
840 | - } |
|
831 | + if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) { |
|
832 | + foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) { |
|
833 | + if (is_numeric($cat_part)) { |
|
834 | + $cat_part_arr[] = $cat_part; |
|
835 | + } |
|
836 | + } |
|
837 | + if (is_array($cat_part_arr)) { |
|
838 | + $post_category = implode(',', $cat_part_arr); |
|
839 | + } |
|
840 | + } |
|
841 | 841 | |
842 | - if (!empty($post_category)) { |
|
843 | - $cat1 = array_filter(explode(',', $post_category)); |
|
844 | - $post_category = ',' . implode(',', $cat1) . ','; |
|
842 | + if (!empty($post_category)) { |
|
843 | + $cat1 = array_filter(explode(',', $post_category)); |
|
844 | + $post_category = ',' . implode(',', $cat1) . ','; |
|
845 | 845 | |
846 | - } |
|
846 | + } |
|
847 | 847 | |
848 | - if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) { |
|
848 | + if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) { |
|
849 | 849 | |
850 | - $post_category_upd = explode(',', $post_category); |
|
851 | - $post_category_change = ''; |
|
852 | - foreach ($post_category_upd as $cat) { |
|
850 | + $post_category_upd = explode(',', $post_category); |
|
851 | + $post_category_change = ''; |
|
852 | + foreach ($post_category_upd as $cat) { |
|
853 | 853 | |
854 | - if (!in_array($cat, $exclude_cats) && $cat != '') { |
|
855 | - $post_category_change .= ',' . $cat; |
|
856 | - } |
|
857 | - } |
|
858 | - $post_category = $post_category_change; |
|
859 | - } |
|
854 | + if (!in_array($cat, $exclude_cats) && $cat != '') { |
|
855 | + $post_category_change .= ',' . $cat; |
|
856 | + } |
|
857 | + } |
|
858 | + $post_category = $post_category_change; |
|
859 | + } |
|
860 | 860 | |
861 | 861 | |
862 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
863 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
864 | - } |
|
865 | - } |
|
862 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
863 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
864 | + } |
|
865 | + } |
|
866 | 866 | |
867 | - echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
867 | + echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
868 | 868 | |
869 | - echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
869 | + echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
870 | 870 | |
871 | - echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
871 | + echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
872 | 872 | |
873 | 873 | |
874 | - ?> |
|
874 | + ?> |
|
875 | 875 | <div class="cat_sublist"> |
876 | 876 | <?php |
877 | 877 | |
878 | - $post_id = isset($post->ID) ? $post->ID : ''; |
|
878 | + $post_id = isset($post->ID) ? $post->ID : ''; |
|
879 | 879 | |
880 | - if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) { |
|
880 | + if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) { |
|
881 | 881 | |
882 | - geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
883 | - } |
|
884 | - ?> |
|
882 | + geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
883 | + } |
|
884 | + ?> |
|
885 | 885 | </div> |
886 | 886 | <script type="text/javascript"> |
887 | 887 | |
@@ -1004,22 +1004,22 @@ discard block |
||
1004 | 1004 | |
1005 | 1005 | </script> |
1006 | 1006 | <?php |
1007 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
1008 | - $post_cat_str = $post_categories[$cat_taxonomy]; |
|
1009 | - $post_cat_array = explode("#", $post_cat_str); |
|
1010 | - if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
1011 | - $style = "display:none;"; |
|
1012 | - } |
|
1013 | - ?> |
|
1007 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
1008 | + $post_cat_str = $post_categories[$cat_taxonomy]; |
|
1009 | + $post_cat_array = explode("#", $post_cat_str); |
|
1010 | + if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
1011 | + $style = "display:none;"; |
|
1012 | + } |
|
1013 | + ?> |
|
1014 | 1014 | <div class="main_cat_list" style=" <?php if (isset($style)) { |
1015 | - echo $style; |
|
1016 | - }?> "> |
|
1015 | + echo $style; |
|
1016 | + }?> "> |
|
1017 | 1017 | <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
1018 | - ?> |
|
1018 | + ?> |
|
1019 | 1019 | </div> |
1020 | 1020 | <?php |
1021 | 1021 | |
1022 | - } |
|
1022 | + } |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | /** |
@@ -1036,23 +1036,23 @@ discard block |
||
1036 | 1036 | */ |
1037 | 1037 | function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '') |
1038 | 1038 | { |
1039 | - global $exclude_cats; |
|
1039 | + global $exclude_cats; |
|
1040 | 1040 | |
1041 | - if ($exclude != '') { |
|
1042 | - $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
1041 | + if ($exclude != '') { |
|
1042 | + $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
1043 | 1043 | |
1044 | - if(is_array( $exclude_cats)){ |
|
1045 | - $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
1046 | - }else{ |
|
1047 | - $exclude_cats = intval($exclude_cats); |
|
1048 | - } |
|
1044 | + if(is_array( $exclude_cats)){ |
|
1045 | + $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
1046 | + }else{ |
|
1047 | + $exclude_cats = intval($exclude_cats); |
|
1048 | + } |
|
1049 | 1049 | |
1050 | - } |
|
1050 | + } |
|
1051 | 1051 | |
1052 | - if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
1053 | - (!is_array($exclude_cats) || empty($exclude_cats)) |
|
1054 | - ) { |
|
1055 | - ?> |
|
1052 | + if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
1053 | + (!is_array($exclude_cats) || empty($exclude_cats)) |
|
1054 | + ) { |
|
1055 | + ?> |
|
1056 | 1056 | |
1057 | 1057 | <?php $main_cat = get_term($parrent, $request_taxonomy); ?> |
1058 | 1058 | |
@@ -1081,8 +1081,8 @@ discard block |
||
1081 | 1081 | |
1082 | 1082 | <br/> |
1083 | 1083 | <?php |
1084 | - $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats)); |
|
1085 | - if (!empty($cat_terms)) { ?> |
|
1084 | + $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats)); |
|
1085 | + if (!empty($cat_terms)) { ?> |
|
1086 | 1086 | <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span> |
1087 | 1087 | <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?> |
1088 | 1088 | <?php } ?> |
@@ -1104,53 +1104,53 @@ discard block |
||
1104 | 1104 | function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories) |
1105 | 1105 | { |
1106 | 1106 | |
1107 | - if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) { |
|
1108 | - $post_cat_str = $post_categories[$request_taxonomy]; |
|
1109 | - $post_cat_array = explode("#", $post_cat_str); |
|
1110 | - if (is_array($post_cat_array)) { |
|
1111 | - $post_cat_array = array_unique( $post_cat_array ); |
|
1107 | + if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) { |
|
1108 | + $post_cat_str = $post_categories[$request_taxonomy]; |
|
1109 | + $post_cat_array = explode("#", $post_cat_str); |
|
1110 | + if (is_array($post_cat_array)) { |
|
1111 | + $post_cat_array = array_unique( $post_cat_array ); |
|
1112 | 1112 | |
1113 | 1113 | foreach ($post_cat_array as $post_cat_html) { |
1114 | 1114 | |
1115 | - $post_cat_info = explode(":", $post_cat_html); |
|
1116 | - $post_maincat_str = $post_cat_info[0]; |
|
1115 | + $post_cat_info = explode(":", $post_cat_html); |
|
1116 | + $post_maincat_str = $post_cat_info[0]; |
|
1117 | 1117 | |
1118 | - if (!empty($post_maincat_str)) { |
|
1119 | - $post_maincat_info = explode(",", $post_maincat_str); |
|
1120 | - $post_maincat_id = $post_maincat_info[0]; |
|
1121 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
1122 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
1123 | - } |
|
1124 | - $post_sub_catid = ''; |
|
1125 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) { |
|
1126 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
1127 | - } |
|
1118 | + if (!empty($post_maincat_str)) { |
|
1119 | + $post_maincat_info = explode(",", $post_maincat_str); |
|
1120 | + $post_maincat_id = $post_maincat_info[0]; |
|
1121 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
1122 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
1123 | + } |
|
1124 | + $post_sub_catid = ''; |
|
1125 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) { |
|
1126 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
1127 | + } |
|
1128 | 1128 | |
1129 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
1129 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
1130 | 1130 | |
1131 | - } |
|
1132 | - } else { |
|
1131 | + } |
|
1132 | + } else { |
|
1133 | 1133 | |
1134 | - $post_cat_info = explode(":", $post_cat_str); |
|
1135 | - $post_maincat_str = $post_cat_info[0]; |
|
1134 | + $post_cat_info = explode(":", $post_cat_str); |
|
1135 | + $post_maincat_str = $post_cat_info[0]; |
|
1136 | 1136 | |
1137 | - $post_sub_catid = ''; |
|
1137 | + $post_sub_catid = ''; |
|
1138 | 1138 | |
1139 | - if (!empty($post_maincat_str)) { |
|
1140 | - $post_maincat_info = explode(",", $post_maincat_str); |
|
1141 | - $post_maincat_id = $post_maincat_info[0]; |
|
1142 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
1143 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
1144 | - } |
|
1139 | + if (!empty($post_maincat_str)) { |
|
1140 | + $post_maincat_info = explode(",", $post_maincat_str); |
|
1141 | + $post_maincat_id = $post_maincat_info[0]; |
|
1142 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
1143 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
1144 | + } |
|
1145 | 1145 | |
1146 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) { |
|
1147 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
1148 | - } |
|
1146 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) { |
|
1147 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
1148 | + } |
|
1149 | 1149 | |
1150 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
1150 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
1151 | 1151 | |
1152 | - } |
|
1153 | - } |
|
1152 | + } |
|
1153 | + } |
|
1154 | 1154 | } |
1155 | 1155 | |
1156 | 1156 | /** |
@@ -1164,35 +1164,35 @@ discard block |
||
1164 | 1164 | */ |
1165 | 1165 | function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false) |
1166 | 1166 | { |
1167 | - global $exclude_cats; |
|
1167 | + global $exclude_cats; |
|
1168 | 1168 | |
1169 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats)); |
|
1169 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats)); |
|
1170 | 1170 | |
1171 | - if (!empty($cat_terms)) { |
|
1172 | - $onchange = ''; |
|
1173 | - $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
1171 | + if (!empty($cat_terms)) { |
|
1172 | + $onchange = ''; |
|
1173 | + $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
1174 | 1174 | |
1175 | - $option_selected = ''; |
|
1176 | - if (!$selected) |
|
1177 | - $option_slected = ' selected="selected" '; |
|
1175 | + $option_selected = ''; |
|
1176 | + if (!$selected) |
|
1177 | + $option_slected = ' selected="selected" '; |
|
1178 | 1178 | |
1179 | - echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
1179 | + echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
1180 | 1180 | |
1181 | - echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>'; |
|
1181 | + echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>'; |
|
1182 | 1182 | |
1183 | - foreach ($cat_terms as $cat_term) { |
|
1184 | - $option_selected = ''; |
|
1185 | - if ($selected == $cat_term->term_id) |
|
1186 | - $option_selected = ' selected="selected" '; |
|
1183 | + foreach ($cat_terms as $cat_term) { |
|
1184 | + $option_selected = ''; |
|
1185 | + if ($selected == $cat_term->term_id) |
|
1186 | + $option_selected = ' selected="selected" '; |
|
1187 | 1187 | |
1188 | - // Count child terms |
|
1189 | - $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
1190 | - $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
1188 | + // Count child terms |
|
1189 | + $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
1190 | + $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
1191 | 1191 | |
1192 | - echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . ucfirst($cat_term->name) . '</option>'; |
|
1193 | - } |
|
1194 | - echo '</select>'; |
|
1195 | - } |
|
1192 | + echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . ucfirst($cat_term->name) . '</option>'; |
|
1193 | + } |
|
1194 | + echo '</select>'; |
|
1195 | + } |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | /** |
@@ -1208,28 +1208,28 @@ discard block |
||
1208 | 1208 | */ |
1209 | 1209 | function geodir_custom_update_messages($messages) |
1210 | 1210 | { |
1211 | - global $post, $post_ID; |
|
1212 | - |
|
1213 | - $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects'); |
|
1214 | - |
|
1215 | - foreach ($post_types as $post_type => $post_object) { |
|
1216 | - |
|
1217 | - $messages[$post_type] = array( |
|
1218 | - 0 => '', // Unused. Messages start at index 1. |
|
1219 | - 1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name), |
|
1220 | - 2 => __('Custom field updated.', 'geodirectory'), |
|
1221 | - 3 => __('Custom field deleted.', 'geodirectory'), |
|
1222 | - 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name), |
|
1223 | - 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
1224 | - 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name), |
|
1225 | - 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name), |
|
1226 | - 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name), |
|
1227 | - 9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name), |
|
1228 | - 10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name), |
|
1229 | - ); |
|
1230 | - } |
|
1231 | - |
|
1232 | - return $messages; |
|
1211 | + global $post, $post_ID; |
|
1212 | + |
|
1213 | + $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects'); |
|
1214 | + |
|
1215 | + foreach ($post_types as $post_type => $post_object) { |
|
1216 | + |
|
1217 | + $messages[$post_type] = array( |
|
1218 | + 0 => '', // Unused. Messages start at index 1. |
|
1219 | + 1 => sprintf(__('%s updated. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name), |
|
1220 | + 2 => __('Custom field updated.', 'geodirectory'), |
|
1221 | + 3 => __('Custom field deleted.', 'geodirectory'), |
|
1222 | + 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name), |
|
1223 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
1224 | + 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name), |
|
1225 | + 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name), |
|
1226 | + 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name), |
|
1227 | + 9 => sprintf(__('%s scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, date_i18n(__('M j, Y @ G:i', 'geodirectory'), strtotime($post->post_date)), esc_url(get_permalink($post_ID)), $post_object->labels->singular_name), |
|
1228 | + 10 => sprintf(__('%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name), |
|
1229 | + ); |
|
1230 | + } |
|
1231 | + |
|
1232 | + return $messages; |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | 1235 | |
@@ -1244,182 +1244,182 @@ discard block |
||
1244 | 1244 | function geodir_register_defaults() |
1245 | 1245 | { |
1246 | 1246 | |
1247 | - global $wpdb; |
|
1248 | - |
|
1249 | - $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
1250 | - |
|
1251 | - if (!$listing_slug = get_option('geodir_listing_prefix')) |
|
1252 | - $listing_slug = 'places'; |
|
1253 | - |
|
1254 | - /** |
|
1255 | - * Taxonomies |
|
1256 | - **/ |
|
1257 | - //if ( ! taxonomy_exists('gd_place_tags') ) |
|
1258 | - { |
|
1259 | - |
|
1260 | - $gd_placetags = array(); |
|
1261 | - $gd_placetags['object_type'] = 'gd_place'; |
|
1262 | - $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
1263 | - $gd_placetags['args'] = array( |
|
1264 | - 'public' => true, |
|
1265 | - 'hierarchical' => false, |
|
1266 | - 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true), |
|
1267 | - 'query_var' => true, |
|
1268 | - |
|
1269 | - 'labels' => array( |
|
1270 | - 'name' => __('Place Tags', 'geodirectory'), |
|
1271 | - 'singular_name' => __('Place Tag', 'geodirectory'), |
|
1272 | - 'search_items' => __('Search Place Tags', 'geodirectory'), |
|
1273 | - 'popular_items' => __('Popular Place Tags', 'geodirectory'), |
|
1274 | - 'all_items' => __('All Place Tags', 'geodirectory'), |
|
1275 | - 'edit_item' => __('Edit Place Tag', 'geodirectory'), |
|
1276 | - 'update_item' => __('Update Place Tag', 'geodirectory'), |
|
1277 | - 'add_new_item' => __('Add New Place Tag', 'geodirectory'), |
|
1278 | - 'new_item_name' => __('New Place Tag Name', 'geodirectory'), |
|
1279 | - 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'), |
|
1280 | - 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'), |
|
1281 | - 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'), |
|
1282 | - ), |
|
1283 | - ); |
|
1284 | - |
|
1285 | - |
|
1286 | - $geodir_taxonomies = get_option('geodir_taxonomies'); |
|
1287 | - $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
1288 | - update_option('geodir_taxonomies', $geodir_taxonomies); |
|
1289 | - |
|
1290 | - |
|
1291 | - // Update post types and delete tmp options |
|
1292 | - flush_rewrite_rules(); |
|
1293 | - |
|
1294 | - } |
|
1295 | - |
|
1296 | - //if ( ! taxonomy_exists('gd_placecategory') ) |
|
1297 | - { |
|
1298 | - |
|
1299 | - $gd_placecategory = array(); |
|
1300 | - $gd_placecategory['object_type'] = 'gd_place'; |
|
1301 | - $gd_placecategory['listing_slug'] = $listing_slug; |
|
1302 | - $gd_placecategory['args'] = array( |
|
1303 | - 'public' => true, |
|
1304 | - 'hierarchical' => true, |
|
1305 | - 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true), |
|
1306 | - 'query_var' => true, |
|
1307 | - 'labels' => array( |
|
1308 | - 'name' => __('Place Categories', 'geodirectory'), |
|
1309 | - 'singular_name' => __('Place Category', 'geodirectory'), |
|
1310 | - 'search_items' => __('Search Place Categories', 'geodirectory'), |
|
1311 | - 'popular_items' => __('Popular Place Categories', 'geodirectory'), |
|
1312 | - 'all_items' => __('All Place Categories', 'geodirectory'), |
|
1313 | - 'edit_item' => __('Edit Place Category', 'geodirectory'), |
|
1314 | - 'update_item' => __('Update Place Category', 'geodirectory'), |
|
1315 | - 'add_new_item' => __('Add New Place Category', 'geodirectory'), |
|
1316 | - 'new_item_name' => __('New Place Category', 'geodirectory'), |
|
1317 | - 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'), |
|
1318 | - ), |
|
1319 | - ); |
|
1320 | - |
|
1321 | - |
|
1322 | - $geodir_taxonomies = get_option('geodir_taxonomies'); |
|
1323 | - $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
1324 | - update_option('geodir_taxonomies', $geodir_taxonomies); |
|
1325 | - |
|
1326 | - |
|
1327 | - flush_rewrite_rules(); |
|
1328 | - } |
|
1329 | - |
|
1330 | - /** |
|
1331 | - * Post Types |
|
1332 | - **/ |
|
1333 | - |
|
1334 | - //if ( ! post_type_exists('gd_place') ) |
|
1335 | - { |
|
1336 | - |
|
1337 | - $labels = array( |
|
1338 | - 'name' => __('Places', 'geodirectory'), |
|
1339 | - 'singular_name' => __('Place', 'geodirectory'), |
|
1340 | - 'add_new' => __('Add New', 'geodirectory'), |
|
1341 | - 'add_new_item' => __('Add New Place', 'geodirectory'), |
|
1342 | - 'edit_item' => __('Edit Place', 'geodirectory'), |
|
1343 | - 'new_item' => __('New Place', 'geodirectory'), |
|
1344 | - 'view_item' => __('View Place', 'geodirectory'), |
|
1345 | - 'search_items' => __('Search Places', 'geodirectory'), |
|
1346 | - 'not_found' => __('No Place Found', 'geodirectory'), |
|
1347 | - 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory')); |
|
1348 | - |
|
1349 | - $place_default = array( |
|
1350 | - 'labels' => $labels, |
|
1351 | - 'can_export' => true, |
|
1352 | - 'capability_type' => 'post', |
|
1353 | - 'description' => 'Place post type.', |
|
1354 | - 'has_archive' => $listing_slug, |
|
1355 | - 'hierarchical' => false, |
|
1356 | - 'map_meta_cap' => true, |
|
1357 | - 'menu_icon' => $menu_icon, |
|
1358 | - 'public' => true, |
|
1359 | - 'query_var' => true, |
|
1360 | - 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true), |
|
1361 | - 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/), |
|
1362 | - 'taxonomies' => array('gd_placecategory', 'gd_place_tags')); |
|
1363 | - |
|
1364 | - //Update custom post types |
|
1365 | - $geodir_post_types = get_option('geodir_post_types'); |
|
1366 | - $geodir_post_types['gd_place'] = $place_default; |
|
1367 | - update_option('geodir_post_types', $geodir_post_types); |
|
1368 | - |
|
1369 | - // Update post types and delete tmp options |
|
1370 | - flush_rewrite_rules(); |
|
1371 | - } |
|
1372 | - |
|
1373 | - |
|
1374 | - geodir_register_taxonomies(); |
|
1375 | - geodir_register_post_types(); |
|
1376 | - |
|
1377 | - //die; |
|
1247 | + global $wpdb; |
|
1248 | + |
|
1249 | + $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
1250 | + |
|
1251 | + if (!$listing_slug = get_option('geodir_listing_prefix')) |
|
1252 | + $listing_slug = 'places'; |
|
1253 | + |
|
1254 | + /** |
|
1255 | + * Taxonomies |
|
1256 | + **/ |
|
1257 | + //if ( ! taxonomy_exists('gd_place_tags') ) |
|
1258 | + { |
|
1259 | + |
|
1260 | + $gd_placetags = array(); |
|
1261 | + $gd_placetags['object_type'] = 'gd_place'; |
|
1262 | + $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
1263 | + $gd_placetags['args'] = array( |
|
1264 | + 'public' => true, |
|
1265 | + 'hierarchical' => false, |
|
1266 | + 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true), |
|
1267 | + 'query_var' => true, |
|
1268 | + |
|
1269 | + 'labels' => array( |
|
1270 | + 'name' => __('Place Tags', 'geodirectory'), |
|
1271 | + 'singular_name' => __('Place Tag', 'geodirectory'), |
|
1272 | + 'search_items' => __('Search Place Tags', 'geodirectory'), |
|
1273 | + 'popular_items' => __('Popular Place Tags', 'geodirectory'), |
|
1274 | + 'all_items' => __('All Place Tags', 'geodirectory'), |
|
1275 | + 'edit_item' => __('Edit Place Tag', 'geodirectory'), |
|
1276 | + 'update_item' => __('Update Place Tag', 'geodirectory'), |
|
1277 | + 'add_new_item' => __('Add New Place Tag', 'geodirectory'), |
|
1278 | + 'new_item_name' => __('New Place Tag Name', 'geodirectory'), |
|
1279 | + 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'), |
|
1280 | + 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'), |
|
1281 | + 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'), |
|
1282 | + ), |
|
1283 | + ); |
|
1284 | + |
|
1285 | + |
|
1286 | + $geodir_taxonomies = get_option('geodir_taxonomies'); |
|
1287 | + $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
1288 | + update_option('geodir_taxonomies', $geodir_taxonomies); |
|
1289 | + |
|
1290 | + |
|
1291 | + // Update post types and delete tmp options |
|
1292 | + flush_rewrite_rules(); |
|
1293 | + |
|
1294 | + } |
|
1295 | + |
|
1296 | + //if ( ! taxonomy_exists('gd_placecategory') ) |
|
1297 | + { |
|
1298 | + |
|
1299 | + $gd_placecategory = array(); |
|
1300 | + $gd_placecategory['object_type'] = 'gd_place'; |
|
1301 | + $gd_placecategory['listing_slug'] = $listing_slug; |
|
1302 | + $gd_placecategory['args'] = array( |
|
1303 | + 'public' => true, |
|
1304 | + 'hierarchical' => true, |
|
1305 | + 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true), |
|
1306 | + 'query_var' => true, |
|
1307 | + 'labels' => array( |
|
1308 | + 'name' => __('Place Categories', 'geodirectory'), |
|
1309 | + 'singular_name' => __('Place Category', 'geodirectory'), |
|
1310 | + 'search_items' => __('Search Place Categories', 'geodirectory'), |
|
1311 | + 'popular_items' => __('Popular Place Categories', 'geodirectory'), |
|
1312 | + 'all_items' => __('All Place Categories', 'geodirectory'), |
|
1313 | + 'edit_item' => __('Edit Place Category', 'geodirectory'), |
|
1314 | + 'update_item' => __('Update Place Category', 'geodirectory'), |
|
1315 | + 'add_new_item' => __('Add New Place Category', 'geodirectory'), |
|
1316 | + 'new_item_name' => __('New Place Category', 'geodirectory'), |
|
1317 | + 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'), |
|
1318 | + ), |
|
1319 | + ); |
|
1320 | + |
|
1321 | + |
|
1322 | + $geodir_taxonomies = get_option('geodir_taxonomies'); |
|
1323 | + $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
1324 | + update_option('geodir_taxonomies', $geodir_taxonomies); |
|
1325 | + |
|
1326 | + |
|
1327 | + flush_rewrite_rules(); |
|
1328 | + } |
|
1329 | + |
|
1330 | + /** |
|
1331 | + * Post Types |
|
1332 | + **/ |
|
1333 | + |
|
1334 | + //if ( ! post_type_exists('gd_place') ) |
|
1335 | + { |
|
1336 | + |
|
1337 | + $labels = array( |
|
1338 | + 'name' => __('Places', 'geodirectory'), |
|
1339 | + 'singular_name' => __('Place', 'geodirectory'), |
|
1340 | + 'add_new' => __('Add New', 'geodirectory'), |
|
1341 | + 'add_new_item' => __('Add New Place', 'geodirectory'), |
|
1342 | + 'edit_item' => __('Edit Place', 'geodirectory'), |
|
1343 | + 'new_item' => __('New Place', 'geodirectory'), |
|
1344 | + 'view_item' => __('View Place', 'geodirectory'), |
|
1345 | + 'search_items' => __('Search Places', 'geodirectory'), |
|
1346 | + 'not_found' => __('No Place Found', 'geodirectory'), |
|
1347 | + 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory')); |
|
1348 | + |
|
1349 | + $place_default = array( |
|
1350 | + 'labels' => $labels, |
|
1351 | + 'can_export' => true, |
|
1352 | + 'capability_type' => 'post', |
|
1353 | + 'description' => 'Place post type.', |
|
1354 | + 'has_archive' => $listing_slug, |
|
1355 | + 'hierarchical' => false, |
|
1356 | + 'map_meta_cap' => true, |
|
1357 | + 'menu_icon' => $menu_icon, |
|
1358 | + 'public' => true, |
|
1359 | + 'query_var' => true, |
|
1360 | + 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true), |
|
1361 | + 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/), |
|
1362 | + 'taxonomies' => array('gd_placecategory', 'gd_place_tags')); |
|
1363 | + |
|
1364 | + //Update custom post types |
|
1365 | + $geodir_post_types = get_option('geodir_post_types'); |
|
1366 | + $geodir_post_types['gd_place'] = $place_default; |
|
1367 | + update_option('geodir_post_types', $geodir_post_types); |
|
1368 | + |
|
1369 | + // Update post types and delete tmp options |
|
1370 | + flush_rewrite_rules(); |
|
1371 | + } |
|
1372 | + |
|
1373 | + |
|
1374 | + geodir_register_taxonomies(); |
|
1375 | + geodir_register_post_types(); |
|
1376 | + |
|
1377 | + //die; |
|
1378 | 1378 | |
1379 | 1379 | } |
1380 | 1380 | |
1381 | 1381 | $gd_wpml_get_languages = ""; |
1382 | 1382 | function gd_wpml_get_lang_from_url($url) { |
1383 | - global $sitepress, $gd_wpml_get_languages; |
|
1383 | + global $sitepress, $gd_wpml_get_languages; |
|
1384 | 1384 | |
1385 | - if (geodir_is_wpml()) { |
|
1386 | - return $sitepress->get_language_from_url($url); |
|
1387 | - } |
|
1385 | + if (geodir_is_wpml()) { |
|
1386 | + return $sitepress->get_language_from_url($url); |
|
1387 | + } |
|
1388 | 1388 | |
1389 | - if (isset($_REQUEST['lang']) && $_REQUEST['lang']) { |
|
1390 | - return $_REQUEST['lang']; |
|
1391 | - } |
|
1389 | + if (isset($_REQUEST['lang']) && $_REQUEST['lang']) { |
|
1390 | + return $_REQUEST['lang']; |
|
1391 | + } |
|
1392 | 1392 | |
1393 | - $url = str_replace(array("http://","https://"),"",$url); |
|
1393 | + $url = str_replace(array("http://","https://"),"",$url); |
|
1394 | 1394 | |
1395 | - // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang. |
|
1396 | - $site_url = str_replace(array("http://","https://"),"",site_url()); |
|
1395 | + // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang. |
|
1396 | + $site_url = str_replace(array("http://","https://"),"",site_url()); |
|
1397 | 1397 | |
1398 | - $url = str_replace($site_url,"",$url); |
|
1398 | + $url = str_replace($site_url,"",$url); |
|
1399 | 1399 | |
1400 | - $segments = explode('/', trim($url, '/')); |
|
1400 | + $segments = explode('/', trim($url, '/')); |
|
1401 | 1401 | |
1402 | - if ($gd_wpml_get_languages) { |
|
1403 | - $langs = $gd_wpml_get_languages; |
|
1404 | - } else { |
|
1405 | - $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
1406 | - } |
|
1402 | + if ($gd_wpml_get_languages) { |
|
1403 | + $langs = $gd_wpml_get_languages; |
|
1404 | + } else { |
|
1405 | + $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
1406 | + } |
|
1407 | 1407 | |
1408 | - if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) { |
|
1409 | - return $segments[0]; |
|
1410 | - } |
|
1408 | + if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) { |
|
1409 | + return $segments[0]; |
|
1410 | + } |
|
1411 | 1411 | |
1412 | - return false; |
|
1412 | + return false; |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | function gd_wpml_slug_translation_turned_on($post_type) { |
1416 | 1416 | |
1417 | - global $sitepress; |
|
1418 | - $settings = $sitepress->get_settings(); |
|
1419 | - return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
1420 | - && $settings['posts_slug_translation']['types'][$post_type] |
|
1421 | - && isset($settings['posts_slug_translation']['on']) |
|
1422 | - && $settings['posts_slug_translation']['on']; |
|
1417 | + global $sitepress; |
|
1418 | + $settings = $sitepress->get_settings(); |
|
1419 | + return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
1420 | + && $settings['posts_slug_translation']['types'][$post_type] |
|
1421 | + && isset($settings['posts_slug_translation']['on']) |
|
1422 | + && $settings['posts_slug_translation']['on']; |
|
1423 | 1423 | } |
1424 | 1424 | |
1425 | 1425 | |
@@ -1446,150 +1446,150 @@ discard block |
||
1446 | 1446 | */ |
1447 | 1447 | function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample) |
1448 | 1448 | { |
1449 | - //echo $post_link."<br />".$sample ; |
|
1449 | + //echo $post_link."<br />".$sample ; |
|
1450 | 1450 | |
1451 | 1451 | |
1452 | - global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache; |
|
1453 | - if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) { |
|
1454 | - } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') { |
|
1455 | - return $post_link; |
|
1456 | - } else { |
|
1457 | - $orig_post = $post; |
|
1458 | - $post = $post_obj; |
|
1459 | - } |
|
1452 | + global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache; |
|
1453 | + if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) { |
|
1454 | + } elseif (isset($post_obj->post_status) && $post_obj->post_status == 'auto-draft') { |
|
1455 | + return $post_link; |
|
1456 | + } else { |
|
1457 | + $orig_post = $post; |
|
1458 | + $post = $post_obj; |
|
1459 | + } |
|
1460 | 1460 | |
1461 | - if (in_array($post->post_type, geodir_get_posttypes())) { |
|
1461 | + if (in_array($post->post_type, geodir_get_posttypes())) { |
|
1462 | 1462 | |
1463 | 1463 | |
1464 | - $post_types = get_option('geodir_post_types'); |
|
1465 | - $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
1464 | + $post_types = get_option('geodir_post_types'); |
|
1465 | + $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
1466 | 1466 | |
1467 | - // Alter the CPT slug if WPML is set to do so |
|
1468 | - if(function_exists('icl_object_id')){ |
|
1469 | - if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) { |
|
1467 | + // Alter the CPT slug if WPML is set to do so |
|
1468 | + if(function_exists('icl_object_id')){ |
|
1469 | + if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) { |
|
1470 | 1470 | |
1471 | - $org_slug = $slug; |
|
1472 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
1473 | - $slug, |
|
1474 | - 'WordPress', |
|
1475 | - 'URL slug: ' . $slug, |
|
1476 | - $language_code); |
|
1471 | + $org_slug = $slug; |
|
1472 | + $slug = apply_filters( 'wpml_translate_single_string', |
|
1473 | + $slug, |
|
1474 | + 'WordPress', |
|
1475 | + 'URL slug: ' . $slug, |
|
1476 | + $language_code); |
|
1477 | 1477 | |
1478 | - if(!$slug){$slug = $org_slug;} |
|
1478 | + if(!$slug){$slug = $org_slug;} |
|
1479 | 1479 | |
1480 | - } |
|
1481 | - } |
|
1480 | + } |
|
1481 | + } |
|
1482 | 1482 | |
1483 | - if (function_exists('geodir_location_geo_home_link')) { |
|
1484 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
1485 | - } |
|
1483 | + if (function_exists('geodir_location_geo_home_link')) { |
|
1484 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
1485 | + } |
|
1486 | 1486 | |
1487 | - // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
1488 | - $site_url = trailingslashit(get_bloginfo('url')); |
|
1487 | + // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
1488 | + $site_url = trailingslashit(get_bloginfo('url')); |
|
1489 | 1489 | |
1490 | - if (function_exists('geodir_location_geo_home_link')) { |
|
1491 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
1492 | - } |
|
1493 | - |
|
1494 | - $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
1495 | - if ($fix_url) { |
|
1496 | - $post_link = str_replace($site_url, '', $post_link); |
|
1497 | - } |
|
1498 | - |
|
1499 | - $post_link = trailingslashit( |
|
1500 | - preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
1501 | - ); |
|
1502 | - |
|
1503 | - if ($fix_url) { |
|
1504 | - $post_link = $site_url . $post_link; |
|
1505 | - } |
|
1506 | - |
|
1507 | - if (isset($comment_post_cache[$post->ID])) { |
|
1508 | - $post = $comment_post_cache[$post->ID]; |
|
1509 | - } |
|
1510 | - if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) { |
|
1511 | - $post_id = $post->ID; |
|
1512 | - if (isset($orig_post)) { |
|
1513 | - $post = $orig_post; |
|
1514 | - } |
|
1515 | - return $gd_permalink_cache[$post_id]; |
|
1516 | - } |
|
1490 | + if (function_exists('geodir_location_geo_home_link')) { |
|
1491 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
1492 | + } |
|
1493 | + |
|
1494 | + $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
1495 | + if ($fix_url) { |
|
1496 | + $post_link = str_replace($site_url, '', $post_link); |
|
1497 | + } |
|
1517 | 1498 | |
1518 | - if (!isset($post->post_locations)) { |
|
1519 | - $post_type = $post->post_type; |
|
1520 | - $ID = $post->ID; |
|
1521 | - $post2 = $wpdb->get_row( |
|
1522 | - $wpdb->prepare( |
|
1523 | - "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
1524 | - array($post->ID) |
|
1525 | - ) |
|
1526 | - ); |
|
1499 | + $post_link = trailingslashit( |
|
1500 | + preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
1501 | + ); |
|
1527 | 1502 | |
1528 | - $post = (object)array_merge((array)$post, (array)$post2); |
|
1503 | + if ($fix_url) { |
|
1504 | + $post_link = $site_url . $post_link; |
|
1505 | + } |
|
1529 | 1506 | |
1530 | - $comment_post_cache[$post->ID] = $post; |
|
1531 | - } |
|
1507 | + if (isset($comment_post_cache[$post->ID])) { |
|
1508 | + $post = $comment_post_cache[$post->ID]; |
|
1509 | + } |
|
1510 | + if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) { |
|
1511 | + $post_id = $post->ID; |
|
1512 | + if (isset($orig_post)) { |
|
1513 | + $post = $orig_post; |
|
1514 | + } |
|
1515 | + return $gd_permalink_cache[$post_id]; |
|
1516 | + } |
|
1532 | 1517 | |
1518 | + if (!isset($post->post_locations)) { |
|
1519 | + $post_type = $post->post_type; |
|
1520 | + $ID = $post->ID; |
|
1521 | + $post2 = $wpdb->get_row( |
|
1522 | + $wpdb->prepare( |
|
1523 | + "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
1524 | + array($post->ID) |
|
1525 | + ) |
|
1526 | + ); |
|
1533 | 1527 | |
1528 | + $post = (object)array_merge((array)$post, (array)$post2); |
|
1534 | 1529 | |
1535 | - if (false !== strpos($post_link, '%gd_taxonomy%')) { |
|
1530 | + $comment_post_cache[$post->ID] = $post; |
|
1531 | + } |
|
1536 | 1532 | |
1537 | - if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) { |
|
1538 | - $location_request = ''; |
|
1539 | 1533 | |
1540 | 1534 | |
1541 | - if (!empty($post->post_locations)) { |
|
1542 | - $geodir_arr_locations = explode(',', $post->post_locations); |
|
1543 | - if (count($geodir_arr_locations) == 3) { |
|
1544 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]); |
|
1545 | - $post->city_slug = str_replace(']', '', $post->city_slug); |
|
1546 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]); |
|
1547 | - $post->region_slug = str_replace(']', '', $post->region_slug); |
|
1548 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]); |
|
1549 | - $post->country_slug = str_replace(']', '', $post->country_slug); |
|
1535 | + if (false !== strpos($post_link, '%gd_taxonomy%')) { |
|
1550 | 1536 | |
1551 | - $post_location = (object)array('country_slug' => $post->country_slug, |
|
1552 | - 'region_slug' => $post->region_slug, |
|
1553 | - 'city_slug' => $post->city_slug |
|
1554 | - ); |
|
1537 | + if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) { |
|
1538 | + $location_request = ''; |
|
1555 | 1539 | |
1556 | - } else |
|
1557 | - $post_location = geodir_get_location(); |
|
1558 | 1540 | |
1541 | + if (!empty($post->post_locations)) { |
|
1542 | + $geodir_arr_locations = explode(',', $post->post_locations); |
|
1543 | + if (count($geodir_arr_locations) == 3) { |
|
1544 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]); |
|
1545 | + $post->city_slug = str_replace(']', '', $post->city_slug); |
|
1546 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]); |
|
1547 | + $post->region_slug = str_replace(']', '', $post->region_slug); |
|
1548 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]); |
|
1549 | + $post->country_slug = str_replace(']', '', $post->country_slug); |
|
1559 | 1550 | |
1560 | - } else { |
|
1551 | + $post_location = (object)array('country_slug' => $post->country_slug, |
|
1552 | + 'region_slug' => $post->region_slug, |
|
1553 | + 'city_slug' => $post->city_slug |
|
1554 | + ); |
|
1561 | 1555 | |
1562 | - $post_location_sql = $wpdb->get_results( |
|
1563 | - $wpdb->prepare( |
|
1564 | - "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
1565 | - array($post->ID) |
|
1566 | - ) |
|
1567 | - ); |
|
1568 | - |
|
1569 | - if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) { |
|
1570 | - |
|
1571 | - $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations); |
|
1572 | - if (count($geodir_arr_locations) == 3) { |
|
1573 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]); |
|
1574 | - $post->city_slug = str_replace(']', '', $post->city_slug); |
|
1575 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]); |
|
1576 | - $post->region_slug = str_replace(']', '', $post->region_slug); |
|
1577 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]); |
|
1578 | - $post->country_slug = str_replace(']', '', $post->country_slug); |
|
1579 | - |
|
1580 | - $post_location = (object)array('country_slug' => $post->country_slug, |
|
1581 | - 'region_slug' => $post->region_slug, |
|
1582 | - 'city_slug' => $post->city_slug |
|
1583 | - ); |
|
1556 | + } else |
|
1557 | + $post_location = geodir_get_location(); |
|
1584 | 1558 | |
1585 | - } |
|
1586 | - } else |
|
1587 | - $post_location = geodir_get_location(); |
|
1588 | - } |
|
1589 | 1559 | |
1560 | + } else { |
|
1561 | + |
|
1562 | + $post_location_sql = $wpdb->get_results( |
|
1563 | + $wpdb->prepare( |
|
1564 | + "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
1565 | + array($post->ID) |
|
1566 | + ) |
|
1567 | + ); |
|
1568 | + |
|
1569 | + if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) { |
|
1570 | + |
|
1571 | + $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations); |
|
1572 | + if (count($geodir_arr_locations) == 3) { |
|
1573 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]); |
|
1574 | + $post->city_slug = str_replace(']', '', $post->city_slug); |
|
1575 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]); |
|
1576 | + $post->region_slug = str_replace(']', '', $post->region_slug); |
|
1577 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]); |
|
1578 | + $post->country_slug = str_replace(']', '', $post->country_slug); |
|
1579 | + |
|
1580 | + $post_location = (object)array('country_slug' => $post->country_slug, |
|
1581 | + 'region_slug' => $post->region_slug, |
|
1582 | + 'city_slug' => $post->city_slug |
|
1583 | + ); |
|
1584 | + |
|
1585 | + } |
|
1586 | + } else |
|
1587 | + $post_location = geodir_get_location(); |
|
1588 | + } |
|
1590 | 1589 | |
1591 | - if (!empty($post_location)) { |
|
1592 | - $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
1590 | + |
|
1591 | + if (!empty($post_location)) { |
|
1592 | + $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
1593 | 1593 | $region_slug = isset($post_location->region_slug) ? $post_location->region_slug : ''; |
1594 | 1594 | $city_slug = isset($post_location->city_slug) ? $post_location->city_slug : ''; |
1595 | 1595 | |
@@ -1607,84 +1607,84 @@ discard block |
||
1607 | 1607 | $location_slug[] = $city_slug; |
1608 | 1608 | |
1609 | 1609 | $location_request .= implode('/', $location_slug) . '/'; |
1610 | - } |
|
1611 | - } |
|
1610 | + } |
|
1611 | + } |
|
1612 | 1612 | |
1613 | - if (get_option('geodir_add_categories_url')) { |
|
1613 | + if (get_option('geodir_add_categories_url')) { |
|
1614 | 1614 | |
1615 | - $term_request = ''; |
|
1616 | - $taxonomies = geodir_get_taxonomies($post->post_type); |
|
1615 | + $term_request = ''; |
|
1616 | + $taxonomies = geodir_get_taxonomies($post->post_type); |
|
1617 | 1617 | |
1618 | - $taxonomies = end($taxonomies); |
|
1618 | + $taxonomies = end($taxonomies); |
|
1619 | 1619 | |
1620 | - if (!empty($post->default_category)) { |
|
1621 | - $post_terms = $post->default_category; |
|
1622 | - } else { |
|
1623 | - $post_terms = ''; |
|
1620 | + if (!empty($post->default_category)) { |
|
1621 | + $post_terms = $post->default_category; |
|
1622 | + } else { |
|
1623 | + $post_terms = ''; |
|
1624 | 1624 | |
1625 | - if (isset($post->{$taxonomies})) { |
|
1626 | - $post_terms = explode(",", trim($post->{$taxonomies}, ",")); |
|
1627 | - $post_terms = $post_terms[0]; |
|
1628 | - } |
|
1625 | + if (isset($post->{$taxonomies})) { |
|
1626 | + $post_terms = explode(",", trim($post->{$taxonomies}, ",")); |
|
1627 | + $post_terms = $post_terms[0]; |
|
1628 | + } |
|
1629 | 1629 | |
1630 | - if (!$post_terms) |
|
1631 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
1630 | + if (!$post_terms) |
|
1631 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
1632 | 1632 | |
1633 | - if (!$post_terms) { |
|
1634 | - $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
1633 | + if (!$post_terms) { |
|
1634 | + $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
1635 | 1635 | |
1636 | - if ($post_terms) { |
|
1637 | - $post_terms = explode(",", trim($post_terms, ",")); |
|
1638 | - $post_terms = $post_terms[0]; |
|
1639 | - } |
|
1640 | - } |
|
1641 | - } |
|
1636 | + if ($post_terms) { |
|
1637 | + $post_terms = explode(",", trim($post_terms, ",")); |
|
1638 | + $post_terms = $post_terms[0]; |
|
1639 | + } |
|
1640 | + } |
|
1641 | + } |
|
1642 | 1642 | |
1643 | - $term = get_term_by('id', $post_terms, $taxonomies); |
|
1643 | + $term = get_term_by('id', $post_terms, $taxonomies); |
|
1644 | 1644 | |
1645 | - if (!empty($term)) |
|
1646 | - $term_request = $term->slug; |
|
1647 | - //$term_request = $term->slug.'/'; |
|
1648 | - } |
|
1645 | + if (!empty($term)) |
|
1646 | + $term_request = $term->slug; |
|
1647 | + //$term_request = $term->slug.'/'; |
|
1648 | + } |
|
1649 | 1649 | |
1650 | - $request_term = ''; |
|
1651 | - $listingurl_separator = ''; |
|
1652 | - //$detailurl_separator = get_option('geodir_detailurl_separator'); |
|
1653 | - $detailurl_separator = ''; |
|
1654 | - if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') { |
|
1655 | - $request_term = $location_request; |
|
1656 | - //$listingurl_separator = get_option('geodir_listingurl_separator'); |
|
1657 | - //$request_term .= $listingurl_separator.'/'.$term_request; |
|
1658 | - $request_term .= $term_request; |
|
1650 | + $request_term = ''; |
|
1651 | + $listingurl_separator = ''; |
|
1652 | + //$detailurl_separator = get_option('geodir_detailurl_separator'); |
|
1653 | + $detailurl_separator = ''; |
|
1654 | + if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') { |
|
1655 | + $request_term = $location_request; |
|
1656 | + //$listingurl_separator = get_option('geodir_listingurl_separator'); |
|
1657 | + //$request_term .= $listingurl_separator.'/'.$term_request; |
|
1658 | + $request_term .= $term_request; |
|
1659 | 1659 | |
1660 | - } else { |
|
1661 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
1660 | + } else { |
|
1661 | + if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
1662 | 1662 | |
1663 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
1664 | - } |
|
1665 | - $request_term = trim($request_term, '/'); |
|
1663 | + if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
1664 | + } |
|
1665 | + $request_term = trim($request_term, '/'); |
|
1666 | 1666 | |
1667 | - // Fix with WPML the location terms added twice when CPT slug is translated. |
|
1668 | - if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) { |
|
1669 | - $post_link = str_replace('%gd_taxonomy%/', '', $post_link); |
|
1670 | - } |
|
1667 | + // Fix with WPML the location terms added twice when CPT slug is translated. |
|
1668 | + if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) { |
|
1669 | + $post_link = str_replace('%gd_taxonomy%/', '', $post_link); |
|
1670 | + } |
|
1671 | 1671 | |
1672 | - if (!empty($request_term)) |
|
1673 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1674 | - else |
|
1675 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1676 | - //echo $post_link ; |
|
1677 | - } |
|
1678 | - // temp cache the permalink |
|
1679 | - if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) { |
|
1680 | - $gd_permalink_cache[$post->ID] = $post_link; |
|
1681 | - } |
|
1682 | - } |
|
1683 | - if (isset($orig_post)) { |
|
1684 | - $post = $orig_post; |
|
1685 | - } |
|
1686 | - |
|
1687 | - return $post_link; |
|
1672 | + if (!empty($request_term)) |
|
1673 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1674 | + else |
|
1675 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1676 | + //echo $post_link ; |
|
1677 | + } |
|
1678 | + // temp cache the permalink |
|
1679 | + if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) { |
|
1680 | + $gd_permalink_cache[$post->ID] = $post_link; |
|
1681 | + } |
|
1682 | + } |
|
1683 | + if (isset($orig_post)) { |
|
1684 | + $post = $orig_post; |
|
1685 | + } |
|
1686 | + |
|
1687 | + return $post_link; |
|
1688 | 1688 | } |
1689 | 1689 | |
1690 | 1690 | /** |
@@ -1700,99 +1700,99 @@ discard block |
||
1700 | 1700 | * @return string The term link. |
1701 | 1701 | */ |
1702 | 1702 | function geodir_term_link($termlink, $term, $taxonomy) { |
1703 | - $geodir_taxonomies = geodir_get_taxonomies('', true); |
|
1703 | + $geodir_taxonomies = geodir_get_taxonomies('', true); |
|
1704 | 1704 | |
1705 | - if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) { |
|
1706 | - global $geodir_add_location_url, $gd_session; |
|
1707 | - $include_location = false; |
|
1708 | - $request_term = array(); |
|
1709 | - $add_location_url = get_option('geodir_add_location_url'); |
|
1710 | - $location_manager = defined('POST_LOCATION_TABLE') ? true : false; |
|
1705 | + if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) { |
|
1706 | + global $geodir_add_location_url, $gd_session; |
|
1707 | + $include_location = false; |
|
1708 | + $request_term = array(); |
|
1709 | + $add_location_url = get_option('geodir_add_location_url'); |
|
1710 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false; |
|
1711 | 1711 | |
1712 | - $listing_slug = geodir_get_listing_slug($taxonomy); |
|
1712 | + $listing_slug = geodir_get_listing_slug($taxonomy); |
|
1713 | 1713 | |
1714 | - if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') { |
|
1715 | - if ($geodir_add_location_url && $add_location_url) { |
|
1716 | - $include_location = true; |
|
1717 | - } |
|
1718 | - } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) { |
|
1719 | - $include_location = true; |
|
1720 | - } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) { |
|
1721 | - $include_location = true; |
|
1722 | - } |
|
1723 | - |
|
1724 | - if ($include_location) { |
|
1725 | - global $post; |
|
1714 | + if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') { |
|
1715 | + if ($geodir_add_location_url && $add_location_url) { |
|
1716 | + $include_location = true; |
|
1717 | + } |
|
1718 | + } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) { |
|
1719 | + $include_location = true; |
|
1720 | + } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) { |
|
1721 | + $include_location = true; |
|
1722 | + } |
|
1723 | + |
|
1724 | + if ($include_location) { |
|
1725 | + global $post; |
|
1726 | 1726 | |
1727 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false; |
|
1727 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false; |
|
1728 | 1728 | |
1729 | - if (geodir_is_page('detail') && isset($post->country_slug)) { |
|
1730 | - $location_terms = array( |
|
1731 | - 'gd_country' => $post->country_slug, |
|
1732 | - 'gd_region' => $post->region_slug, |
|
1733 | - 'gd_city' => $post->city_slug |
|
1734 | - ); |
|
1729 | + if (geodir_is_page('detail') && isset($post->country_slug)) { |
|
1730 | + $location_terms = array( |
|
1731 | + 'gd_country' => $post->country_slug, |
|
1732 | + 'gd_region' => $post->region_slug, |
|
1733 | + 'gd_city' => $post->city_slug |
|
1734 | + ); |
|
1735 | 1735 | |
1736 | - if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) { |
|
1737 | - $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
1738 | - } |
|
1739 | - } else { |
|
1740 | - $location_terms = geodir_get_current_location_terms('query_vars'); |
|
1741 | - } |
|
1736 | + if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) { |
|
1737 | + $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
1738 | + } |
|
1739 | + } else { |
|
1740 | + $location_terms = geodir_get_current_location_terms('query_vars'); |
|
1741 | + } |
|
1742 | 1742 | |
1743 | - $geodir_show_location_url = get_option('geodir_show_location_url'); |
|
1744 | - $location_terms = geodir_remove_location_terms($location_terms); |
|
1743 | + $geodir_show_location_url = get_option('geodir_show_location_url'); |
|
1744 | + $location_terms = geodir_remove_location_terms($location_terms); |
|
1745 | 1745 | |
1746 | - if (!empty($location_terms)) { |
|
1747 | - $url_separator = ''; |
|
1746 | + if (!empty($location_terms)) { |
|
1747 | + $url_separator = ''; |
|
1748 | 1748 | |
1749 | - if (get_option('permalink_structure') != '') { |
|
1750 | - $old_listing_slug = '/' . $listing_slug . '/'; |
|
1751 | - $request_term = implode("/", $location_terms); |
|
1752 | - $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
1749 | + if (get_option('permalink_structure') != '') { |
|
1750 | + $old_listing_slug = '/' . $listing_slug . '/'; |
|
1751 | + $request_term = implode("/", $location_terms); |
|
1752 | + $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
1753 | 1753 | |
1754 | - $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
|
1755 | - } else { |
|
1756 | - $termlink = geodir_getlink($termlink, $request_term); |
|
1757 | - } |
|
1758 | - } |
|
1759 | - } |
|
1754 | + $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
|
1755 | + } else { |
|
1756 | + $termlink = geodir_getlink($termlink, $request_term); |
|
1757 | + } |
|
1758 | + } |
|
1759 | + } |
|
1760 | 1760 | |
1761 | - // Alter the CPT slug is WPML is set to do so |
|
1762 | - /* we can replace this with the below function |
|
1761 | + // Alter the CPT slug is WPML is set to do so |
|
1762 | + /* we can replace this with the below function |
|
1763 | 1763 | if(function_exists('icl_object_id')){ |
1764 | 1764 | global $sitepress; |
1765 | 1765 | $post_type = str_replace("category","",$taxonomy); |
1766 | 1766 | $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type); |
1767 | 1767 | }*/ |
1768 | 1768 | |
1769 | - // Alter the CPT slug if WPML is set to do so |
|
1770 | - if (function_exists('icl_object_id')) { |
|
1771 | - $post_types = get_option('geodir_post_types'); |
|
1772 | - $post_type = str_replace("category","",$taxonomy); |
|
1773 | - $post_type = str_replace("_tags","",$post_type); |
|
1774 | - $slug = $post_types[$post_type]['rewrite']['slug']; |
|
1775 | - if (gd_wpml_slug_translation_turned_on($post_type)) { |
|
1776 | - global $sitepress; |
|
1777 | - $default_lang = $sitepress->get_default_language(); |
|
1778 | - $language_code = gd_wpml_get_lang_from_url($termlink); |
|
1779 | - if (!$language_code ) { |
|
1780 | - $language_code = $default_lang; |
|
1781 | - } |
|
1769 | + // Alter the CPT slug if WPML is set to do so |
|
1770 | + if (function_exists('icl_object_id')) { |
|
1771 | + $post_types = get_option('geodir_post_types'); |
|
1772 | + $post_type = str_replace("category","",$taxonomy); |
|
1773 | + $post_type = str_replace("_tags","",$post_type); |
|
1774 | + $slug = $post_types[$post_type]['rewrite']['slug']; |
|
1775 | + if (gd_wpml_slug_translation_turned_on($post_type)) { |
|
1776 | + global $sitepress; |
|
1777 | + $default_lang = $sitepress->get_default_language(); |
|
1778 | + $language_code = gd_wpml_get_lang_from_url($termlink); |
|
1779 | + if (!$language_code ) { |
|
1780 | + $language_code = $default_lang; |
|
1781 | + } |
|
1782 | 1782 | |
1783 | - $org_slug = $slug; |
|
1784 | - $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code); |
|
1783 | + $org_slug = $slug; |
|
1784 | + $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code); |
|
1785 | 1785 | |
1786 | - if (!$slug) { |
|
1787 | - $slug = $org_slug; |
|
1788 | - } |
|
1786 | + if (!$slug) { |
|
1787 | + $slug = $org_slug; |
|
1788 | + } |
|
1789 | 1789 | |
1790 | - $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1)); |
|
1791 | - } |
|
1792 | - } |
|
1793 | - } |
|
1790 | + $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1)); |
|
1791 | + } |
|
1792 | + } |
|
1793 | + } |
|
1794 | 1794 | |
1795 | - return $termlink; |
|
1795 | + return $termlink; |
|
1796 | 1796 | } |
1797 | 1797 | |
1798 | 1798 | /** |
@@ -1818,14 +1818,14 @@ discard block |
||
1818 | 1818 | if (in_array($post_type, geodir_get_posttypes())) { |
1819 | 1819 | if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) { |
1820 | 1820 | if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) { |
1821 | - $location_terms = array( |
|
1822 | - 'gd_country' => $post->country_slug, |
|
1823 | - 'gd_region' => $post->region_slug, |
|
1824 | - 'gd_city' => $post->city_slug |
|
1825 | - ); |
|
1826 | - } else { |
|
1827 | - $location_terms = geodir_get_current_location_terms('query_vars'); |
|
1828 | - } |
|
1821 | + $location_terms = array( |
|
1822 | + 'gd_country' => $post->country_slug, |
|
1823 | + 'gd_region' => $post->region_slug, |
|
1824 | + 'gd_city' => $post->city_slug |
|
1825 | + ); |
|
1826 | + } else { |
|
1827 | + $location_terms = geodir_get_current_location_terms('query_vars'); |
|
1828 | + } |
|
1829 | 1829 | |
1830 | 1830 | $location_terms = geodir_remove_location_terms($location_terms); |
1831 | 1831 | |
@@ -1857,17 +1857,17 @@ discard block |
||
1857 | 1857 | * @return void|string Label. |
1858 | 1858 | */ |
1859 | 1859 | function get_post_type_singular_label($post_type, $echo = false, $translate = false) { |
1860 | - $obj_post_type = get_post_type_object($post_type); |
|
1861 | - if (!is_object($obj_post_type)) { |
|
1862 | - return; |
|
1863 | - } |
|
1860 | + $obj_post_type = get_post_type_object($post_type); |
|
1861 | + if (!is_object($obj_post_type)) { |
|
1862 | + return; |
|
1863 | + } |
|
1864 | 1864 | |
1865 | - $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
|
1865 | + $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
|
1866 | 1866 | |
1867 | - if ($echo) |
|
1868 | - echo $label; |
|
1869 | - else |
|
1870 | - return $label; |
|
1867 | + if ($echo) |
|
1868 | + echo $label; |
|
1869 | + else |
|
1870 | + return $label; |
|
1871 | 1871 | } |
1872 | 1872 | |
1873 | 1873 | /** |
@@ -1882,19 +1882,19 @@ discard block |
||
1882 | 1882 | * @return void|string Label. |
1883 | 1883 | */ |
1884 | 1884 | function get_post_type_plural_label($post_type, $echo = false, $translate = false) { |
1885 | - $all_postypes = geodir_get_posttypes(); |
|
1885 | + $all_postypes = geodir_get_posttypes(); |
|
1886 | 1886 | |
1887 | - if (!in_array($post_type, $all_postypes)) |
|
1888 | - return false; |
|
1887 | + if (!in_array($post_type, $all_postypes)) |
|
1888 | + return false; |
|
1889 | 1889 | |
1890 | - $obj_post_type = get_post_type_object($post_type); |
|
1890 | + $obj_post_type = get_post_type_object($post_type); |
|
1891 | 1891 | |
1892 | - $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
|
1892 | + $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
|
1893 | 1893 | |
1894 | - if ($echo) |
|
1895 | - echo $label; |
|
1896 | - else |
|
1897 | - return $label; |
|
1894 | + if ($echo) |
|
1895 | + echo $label; |
|
1896 | + else |
|
1897 | + return $label; |
|
1898 | 1898 | } |
1899 | 1899 | |
1900 | 1900 | /** |
@@ -1912,51 +1912,51 @@ discard block |
||
1912 | 1912 | */ |
1913 | 1913 | function geodir_term_exists($term, $taxonomy = '', $parent = 0) |
1914 | 1914 | { |
1915 | - global $wpdb; |
|
1916 | - |
|
1917 | - $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
1918 | - $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
|
1919 | - |
|
1920 | - if (is_int($term)) { |
|
1921 | - if (0 == $term) |
|
1922 | - return 0; |
|
1923 | - $where = 't.term_id = %d'; |
|
1924 | - if (!empty($taxonomy)) |
|
1925 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
1926 | - else |
|
1927 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
1928 | - } |
|
1915 | + global $wpdb; |
|
1916 | + |
|
1917 | + $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
1918 | + $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
|
1919 | + |
|
1920 | + if (is_int($term)) { |
|
1921 | + if (0 == $term) |
|
1922 | + return 0; |
|
1923 | + $where = 't.term_id = %d'; |
|
1924 | + if (!empty($taxonomy)) |
|
1925 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
1926 | + else |
|
1927 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
1928 | + } |
|
1929 | 1929 | |
1930 | - $term = trim(wp_unslash($term)); |
|
1930 | + $term = trim(wp_unslash($term)); |
|
1931 | 1931 | |
1932 | - if ('' === $slug = sanitize_title($term)) |
|
1933 | - return 0; |
|
1932 | + if ('' === $slug = sanitize_title($term)) |
|
1933 | + return 0; |
|
1934 | 1934 | |
1935 | - $where = 't.slug = %s'; |
|
1935 | + $where = 't.slug = %s'; |
|
1936 | 1936 | |
1937 | - $where_fields = array($slug); |
|
1938 | - if (!empty($taxonomy)) { |
|
1939 | - $parent = (int)$parent; |
|
1940 | - if ($parent > 0) { |
|
1941 | - $where_fields[] = $parent; |
|
1942 | - $else_where_fields[] = $parent; |
|
1943 | - $where .= ' AND tt.parent = %d'; |
|
1937 | + $where_fields = array($slug); |
|
1938 | + if (!empty($taxonomy)) { |
|
1939 | + $parent = (int)$parent; |
|
1940 | + if ($parent > 0) { |
|
1941 | + $where_fields[] = $parent; |
|
1942 | + $else_where_fields[] = $parent; |
|
1943 | + $where .= ' AND tt.parent = %d'; |
|
1944 | 1944 | |
1945 | - } |
|
1945 | + } |
|
1946 | 1946 | |
1947 | - $where_fields[] = $taxonomy; |
|
1947 | + $where_fields[] = $taxonomy; |
|
1948 | 1948 | |
1949 | 1949 | |
1950 | - if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A)) |
|
1951 | - return $result; |
|
1950 | + if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A)) |
|
1951 | + return $result; |
|
1952 | 1952 | |
1953 | - return false; |
|
1954 | - } |
|
1953 | + return false; |
|
1954 | + } |
|
1955 | 1955 | |
1956 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) |
|
1957 | - return $result; |
|
1956 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) |
|
1957 | + return $result; |
|
1958 | 1958 | |
1959 | - return false; |
|
1959 | + return false; |
|
1960 | 1960 | } |
1961 | 1961 | |
1962 | 1962 | /** |
@@ -1968,7 +1968,7 @@ discard block |
||
1968 | 1968 | function geodir_get_term_icon_rebuild() |
1969 | 1969 | { |
1970 | 1970 | |
1971 | - update_option('gd_term_icons', ''); |
|
1971 | + update_option('gd_term_icons', ''); |
|
1972 | 1972 | |
1973 | 1973 | } |
1974 | 1974 | |
@@ -1986,61 +1986,61 @@ discard block |
||
1986 | 1986 | */ |
1987 | 1987 | function geodir_get_term_icon($term_id = false, $rebuild = false) |
1988 | 1988 | { |
1989 | - global $wpdb; |
|
1990 | - if (!$rebuild) { |
|
1991 | - $terms_icons = get_option('gd_term_icons'); |
|
1992 | - } else { |
|
1993 | - $terms_icons = array(); |
|
1994 | - } |
|
1995 | - |
|
1996 | - if (empty($terms_icons)) { |
|
1997 | - $terms_icons = array(); |
|
1998 | - $default_icon_url = get_option('geodir_default_marker_icon'); |
|
1999 | - $taxonomy = geodir_get_taxonomies(); |
|
2000 | - $post_types = geodir_get_posttypes(); |
|
2001 | - $tax_arr = array(); |
|
2002 | - foreach ($post_types as $post_type) { |
|
2003 | - $tax_arr[] = "'" . $post_type . "category'"; |
|
2004 | - } |
|
2005 | - $tax_c = implode(',', $tax_arr); |
|
2006 | - $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)"); |
|
2007 | - //$terms = get_terms( $taxonomy ); |
|
2008 | - |
|
2009 | - if($terms) { |
|
2010 | - foreach ($terms as $term) { |
|
2011 | - $post_type = str_replace("category", "", $term->taxonomy); |
|
2012 | - $a_terms[$post_type][] = $term; |
|
1989 | + global $wpdb; |
|
1990 | + if (!$rebuild) { |
|
1991 | + $terms_icons = get_option('gd_term_icons'); |
|
1992 | + } else { |
|
1993 | + $terms_icons = array(); |
|
1994 | + } |
|
2013 | 1995 | |
2014 | - } |
|
2015 | - } |
|
1996 | + if (empty($terms_icons)) { |
|
1997 | + $terms_icons = array(); |
|
1998 | + $default_icon_url = get_option('geodir_default_marker_icon'); |
|
1999 | + $taxonomy = geodir_get_taxonomies(); |
|
2000 | + $post_types = geodir_get_posttypes(); |
|
2001 | + $tax_arr = array(); |
|
2002 | + foreach ($post_types as $post_type) { |
|
2003 | + $tax_arr[] = "'" . $post_type . "category'"; |
|
2004 | + } |
|
2005 | + $tax_c = implode(',', $tax_arr); |
|
2006 | + $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)"); |
|
2007 | + //$terms = get_terms( $taxonomy ); |
|
2016 | 2008 | |
2017 | - if($a_terms) { |
|
2018 | - foreach ($a_terms as $pt => $t2) { |
|
2009 | + if($terms) { |
|
2010 | + foreach ($terms as $term) { |
|
2011 | + $post_type = str_replace("category", "", $term->taxonomy); |
|
2012 | + $a_terms[$post_type][] = $term; |
|
2019 | 2013 | |
2020 | - foreach ($t2 as $term) { |
|
2021 | - $term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
2022 | - if ($term_icon) { |
|
2023 | - $term_icon_url = $term_icon["src"]; |
|
2024 | - } else { |
|
2025 | - $term_icon_url = $default_icon_url; |
|
2026 | - } |
|
2027 | - $terms_icons[$term->term_id] = $term_icon_url; |
|
2028 | - } |
|
2029 | - } |
|
2030 | - } |
|
2014 | + } |
|
2015 | + } |
|
2031 | 2016 | |
2032 | - update_option('gd_term_icons', $terms_icons); |
|
2033 | - } |
|
2017 | + if($a_terms) { |
|
2018 | + foreach ($a_terms as $pt => $t2) { |
|
2034 | 2019 | |
2035 | - if ($term_id && isset($terms_icons[$term_id])) { |
|
2036 | - return $terms_icons[$term_id]; |
|
2037 | - } elseif ($term_id && !isset($terms_icons[$term_id])) { |
|
2038 | - return get_option('geodir_default_marker_icon'); |
|
2039 | - } |
|
2020 | + foreach ($t2 as $term) { |
|
2021 | + $term_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
2022 | + if ($term_icon) { |
|
2023 | + $term_icon_url = $term_icon["src"]; |
|
2024 | + } else { |
|
2025 | + $term_icon_url = $default_icon_url; |
|
2026 | + } |
|
2027 | + $terms_icons[$term->term_id] = $term_icon_url; |
|
2028 | + } |
|
2029 | + } |
|
2030 | + } |
|
2031 | + |
|
2032 | + update_option('gd_term_icons', $terms_icons); |
|
2033 | + } |
|
2040 | 2034 | |
2041 | - if (is_ssl()) { |
|
2042 | - $terms_icons = str_replace("http:","https:",$terms_icons ); |
|
2043 | - } |
|
2035 | + if ($term_id && isset($terms_icons[$term_id])) { |
|
2036 | + return $terms_icons[$term_id]; |
|
2037 | + } elseif ($term_id && !isset($terms_icons[$term_id])) { |
|
2038 | + return get_option('geodir_default_marker_icon'); |
|
2039 | + } |
|
2040 | + |
|
2041 | + if (is_ssl()) { |
|
2042 | + $terms_icons = str_replace("http:","https:",$terms_icons ); |
|
2043 | + } |
|
2044 | 2044 | |
2045 | - return apply_filters('geodir_get_term_icons', $terms_icons, $term_id); |
|
2045 | + return apply_filters('geodir_get_term_icons', $terms_icons, $term_id); |
|
2046 | 2046 | } |
2047 | 2047 | \ No newline at end of file |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | * @since 1.0.0 |
61 | 61 | * @param string $menu_class The menu HTML class. |
62 | 62 | */ |
63 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); |
|
63 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class); |
|
64 | 64 | /** |
65 | 65 | * Filter the menu a class. |
66 | 66 | * |
67 | 67 | * @since 1.0.0 |
68 | 68 | */ |
69 | 69 | $a_class = apply_filters('geodir_menu_a_class', ''); |
70 | - $items .= '<li class="' . $li_class . '"> |
|
71 | - <a href="' . get_post_type_archive_link($post_type) . '" class="' . $a_class . '"> |
|
72 | - ' . __(ucfirst($args->labels->name),'geodirectory') . ' |
|
70 | + $items .= '<li class="'.$li_class.'"> |
|
71 | + <a href="' . get_post_type_archive_link($post_type).'" class="'.$a_class.'"> |
|
72 | + ' . __(ucfirst($args->labels->name), 'geodirectory').' |
|
73 | 73 | </a> |
74 | 74 | </li>'; |
75 | 75 | } |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | * @since 1.0.0 |
89 | 89 | * @param string $menu_class The menu HTML class. |
90 | 90 | */ |
91 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings ' . $menu_class); |
|
91 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-listings '.$menu_class); |
|
92 | 92 | /** |
93 | 93 | * Filter the sub menu li class. |
94 | 94 | * |
95 | 95 | * @since 1.0.0 |
96 | 96 | * @param string $menu_class The menu HTML class. |
97 | 97 | */ |
98 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class); |
|
98 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class); |
|
99 | 99 | /** |
100 | 100 | * Filter the sub menu ul class. |
101 | 101 | * |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | * @since 1.0.0 |
115 | 115 | */ |
116 | 116 | $sub_a_class = apply_filters('geodir_sub_menu_a_class', ''); |
117 | - $items .= '<li class="' . $li_class . '"> |
|
118 | - <a href="#" class="' . $a_class . '">' . __('Listing', 'geodirectory') . '</a> |
|
119 | - <ul class="' . $sub_ul_class . '">'; |
|
117 | + $items .= '<li class="'.$li_class.'"> |
|
118 | + <a href="#" class="' . $a_class.'">'.__('Listing', 'geodirectory').'</a> |
|
119 | + <ul class="' . $sub_ul_class.'">'; |
|
120 | 120 | $post_types = geodir_get_posttypes('object'); |
121 | 121 | |
122 | 122 | $show_listing_post_types = get_option('geodir_add_posttype_in_listing_nav'); |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) |
134 | 134 | $menu_class = 'current-menu-item'; |
135 | 135 | |
136 | - $items .= '<li class="' . $sub_li_class . '"> |
|
137 | - <a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '"> |
|
138 | - ' . __(ucfirst($args->labels->name),'geodirectory') . ' |
|
136 | + $items .= '<li class="'.$sub_li_class.'"> |
|
137 | + <a href="' . get_post_type_archive_link($post_type).'" class="'.$sub_a_class.'"> |
|
138 | + ' . __(ucfirst($args->labels->name), 'geodirectory').' |
|
139 | 139 | </a> |
140 | 140 | </li>'; |
141 | 141 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @since 1.5.9 |
153 | 153 | */ |
154 | - $items .= apply_filters('geodir_menu_after_sub_ul',''); |
|
154 | + $items .= apply_filters('geodir_menu_after_sub_ul', ''); |
|
155 | 155 | $items .= '</li>'; |
156 | 156 | } |
157 | 157 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @since 1.0.0 |
185 | 185 | * @param string $menu_class The menu HTML class. |
186 | 186 | */ |
187 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); |
|
187 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class); |
|
188 | 188 | /** |
189 | 189 | * Filter the menu a class. |
190 | 190 | * |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | */ |
193 | 193 | $a_class = apply_filters('geodir_menu_a_class', ''); |
194 | 194 | $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
195 | - $items .= '<li class="' . $li_class . '"> |
|
196 | - <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $a_class . '"> |
|
197 | - ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . ' |
|
195 | + $items .= '<li class="'.$li_class.'"> |
|
196 | + <a href="' . geodir_get_addlisting_link($post_type).'" class="'.$a_class.'"> |
|
197 | + ' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).' |
|
198 | 198 | </a> |
199 | 199 | </li>'; |
200 | 200 | } |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @since 1.0.0 |
219 | 219 | * @param string $menu_class The menu HTML class. |
220 | 220 | */ |
221 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing ' . $menu_class); |
|
221 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item menu-item-has-children menu-gd-add-listing '.$menu_class); |
|
222 | 222 | /** |
223 | 223 | * Filter the sub menu li class. |
224 | 224 | * |
225 | 225 | * @since 1.0.0 |
226 | 226 | * @param string $menu_class The menu HTML class. |
227 | 227 | */ |
228 | - $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item ' . $menu_class); |
|
228 | + $sub_li_class = apply_filters('geodir_sub_menu_li_class', 'menu-item '.$menu_class); |
|
229 | 229 | /** |
230 | 230 | * Filter the sub menu ul class. |
231 | 231 | * |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | * @since 1.0.0 |
245 | 245 | */ |
246 | 246 | $sub_a_class = apply_filters('geodir_sub_menu_a_class', ''); |
247 | - $items .= '<li class="' . $li_class . '"> |
|
248 | - <a href="#" class="' . $a_class . '">' . __('Add Listing', 'geodirectory') . '</a> |
|
249 | - <ul class="' . $sub_ul_class . '">'; |
|
247 | + $items .= '<li class="'.$li_class.'"> |
|
248 | + <a href="#" class="' . $a_class.'">'.__('Add Listing', 'geodirectory').'</a> |
|
249 | + <ul class="' . $sub_ul_class.'">'; |
|
250 | 250 | |
251 | 251 | $post_types = geodir_get_posttypes('object'); |
252 | 252 | |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | * @since 1.0.0 |
270 | 270 | * @param string $menu_class The menu HTML class. |
271 | 271 | */ |
272 | - $li_class = apply_filters('geodir_menu_li_class', 'menu-item ' . $menu_class); |
|
272 | + $li_class = apply_filters('geodir_menu_li_class', 'menu-item '.$menu_class); |
|
273 | 273 | $cpt_name = __($args->labels->singular_name, 'geodirectory'); |
274 | - $items .= '<li class="' . $li_class . '"> |
|
275 | - <a href="' . geodir_get_addlisting_link($post_type) . '" class="' . $sub_a_class . '"> |
|
276 | - ' . sprintf( __('Add %s', 'geodirectory'), $cpt_name ) . ' |
|
274 | + $items .= '<li class="'.$li_class.'"> |
|
275 | + <a href="' . geodir_get_addlisting_link($post_type).'" class="'.$sub_a_class.'"> |
|
276 | + ' . sprintf(__('Add %s', 'geodirectory'), $cpt_name).' |
|
277 | 277 | </a> |
278 | 278 | </li>'; |
279 | 279 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | $items .= ' </ul> '; |
288 | - $items .= apply_filters('geodir_menu_after_sub_ul',''); |
|
288 | + $items .= apply_filters('geodir_menu_after_sub_ul', ''); |
|
289 | 289 | $items .= '</li>'; |
290 | 290 | |
291 | 291 | } |
@@ -313,14 +313,14 @@ discard block |
||
313 | 313 | $geodir_theme_location = get_option('geodir_theme_location_nav'); |
314 | 314 | $geodir_theme_location_nav = array(); |
315 | 315 | if (empty($locations) && empty($geodir_theme_location)) { |
316 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu); |
|
316 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu); |
|
317 | 317 | $geodir_theme_location_nav[] = $args['theme_location']; |
318 | 318 | update_option('geodir_theme_location_nav', $geodir_theme_location_nav); |
319 | 319 | } |
320 | 320 | //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
321 | 321 | // $menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu); |
322 | 322 | else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
323 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu); |
|
323 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items()."</ul></div>", $menu); |
|
324 | 324 | |
325 | 325 | return $menu; |
326 | 326 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | |
349 | 349 | if (has_nav_menu($location) == '1' && is_array($geodir_theme_location) && in_array($location, $geodir_theme_location)) { |
350 | 350 | |
351 | - $items = $items . geodir_add_nav_menu_items(); |
|
351 | + $items = $items.geodir_add_nav_menu_items(); |
|
352 | 352 | return $items; |
353 | 353 | |
354 | 354 | } else { |
@@ -373,12 +373,12 @@ discard block |
||
373 | 373 | |
374 | 374 | $taxonomies = geodir_get_taxonomies(); |
375 | 375 | $taxonomies = implode("','", $taxonomies); |
376 | - $taxonomies = "'" . $taxonomies . "'"; |
|
376 | + $taxonomies = "'".$taxonomies."'"; |
|
377 | 377 | |
378 | 378 | $pn_categories = $wpdb->get_results( |
379 | 379 | $wpdb->prepare( |
380 | 380 | "SELECT $wpdb->terms.name as name, $wpdb->term_taxonomy.count as count, $wpdb->terms.term_id as cat_ID FROM $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_taxonomy.term_id = %d AND $wpdb->term_taxonomy.taxonomy in ( $taxonomies ) ORDER BY name", |
381 | - array($wpdb->terms . term_id) |
|
381 | + array($wpdb->terms.term_id) |
|
382 | 382 | ) |
383 | 383 | ); |
384 | 384 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | |
408 | 408 | if (geodir_is_page('add-listing') || geodir_is_page('preview')) { |
409 | 409 | if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
410 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
410 | + $geodir_post_type = get_post_type((int) $_REQUEST['pid']); |
|
411 | 411 | elseif (isset($_REQUEST['listing_type'])) |
412 | 412 | $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
413 | 413 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
426 | 426 | $geodir_post_type = ''; |
427 | 427 | |
428 | - if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){ |
|
428 | + if (defined('DOING_AJAX') && isset($_REQUEST['stype'])) { |
|
429 | 429 | $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
430 | 430 | } |
431 | 431 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @since 1.6.9 |
437 | 437 | */ |
438 | - return apply_filters('geodir_get_current_posttype',$geodir_post_type); |
|
438 | + return apply_filters('geodir_get_current_posttype', $geodir_post_type); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -449,18 +449,18 @@ discard block |
||
449 | 449 | */ |
450 | 450 | function geodir_get_default_posttype() |
451 | 451 | { |
452 | - $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
452 | + $post_types = apply_filters('geodir_get_default_posttype', geodir_get_posttypes('object')); |
|
453 | 453 | |
454 | 454 | $stype = false; |
455 | - foreach ( $post_types as $post_type => $info ) { |
|
455 | + foreach ($post_types as $post_type => $info) { |
|
456 | 456 | global $wpdb; |
457 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
458 | - if ( $has_posts ) { |
|
457 | + $has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type)); |
|
458 | + if ($has_posts) { |
|
459 | 459 | $stype = $post_type; break; |
460 | 460 | } |
461 | 461 | } |
462 | 462 | |
463 | - if(!$stype){ |
|
463 | + if (!$stype) { |
|
464 | 464 | $stype = 'gd_place'; |
465 | 465 | } |
466 | 466 | |
@@ -485,14 +485,14 @@ discard block |
||
485 | 485 | switch ($output): |
486 | 486 | case 'object': |
487 | 487 | case 'Object': |
488 | - $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
488 | + $post_types = json_decode(json_encode($post_types), FALSE); //(object)$post_types; |
|
489 | 489 | break; |
490 | 490 | case 'array': |
491 | 491 | case 'Array': |
492 | - $post_types = (array)$post_types; |
|
492 | + $post_types = (array) $post_types; |
|
493 | 493 | break; |
494 | 494 | case 'options': |
495 | - $post_types = (array)$post_types; |
|
495 | + $post_types = (array) $post_types; |
|
496 | 496 | |
497 | 497 | $options = array(); |
498 | 498 | if (!empty($post_types)) { |
@@ -610,15 +610,15 @@ discard block |
||
610 | 610 | |
611 | 611 | $categories = get_terms($taxonomies); |
612 | 612 | |
613 | - $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>'; |
|
613 | + $html .= '<option value="0">'.__('All', 'geodirectory').'</option>'; |
|
614 | 614 | |
615 | 615 | foreach ($categories as $category_obj) { |
616 | 616 | $select_opt = ''; |
617 | 617 | if ($selected == $category_obj->term_id) { |
618 | 618 | $select_opt = 'selected="selected"'; |
619 | 619 | } |
620 | - $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
621 | - . ucfirst($category_obj->name) . '</option>'; |
|
620 | + $html .= '<option '.$select_opt.' value="'.$category_obj->term_id.'">' |
|
621 | + . ucfirst($category_obj->name).'</option>'; |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | if ($echo) |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | } elseif (isset($wp_query->tax_query->queries)) { |
687 | 687 | $tax_arr = $wp_query->tax_query->queries; |
688 | 688 | //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
689 | - if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);} |
|
689 | + if (isset($tax_arr['relation'])) {unset($tax_arr['relation']); } |
|
690 | 690 | $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
691 | 691 | } |
692 | 692 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | |
741 | 741 | if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) { |
742 | 742 | if ($cat_parent == 0) { |
743 | - $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
743 | + $list_class = 'main_list gd-parent-cats-list gd-cats-display-'.$cat_display; |
|
744 | 744 | $main_list_class = 'class="main_list_selecter"'; |
745 | 745 | } else { |
746 | 746 | //$display = 'display:none'; |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | |
751 | 751 | if ($cat_display == 'checkbox' || $cat_display == 'radio') { |
752 | 752 | $p = 0; |
753 | - $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
753 | + $out = '<div class="'.$list_class.' gd-cat-row-'.$cat_parent.'" style="margin-left:'.$p.'px;'.$display.';">'; |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | foreach ($cat_terms as $cat_term) { |
@@ -765,12 +765,12 @@ discard block |
||
765 | 765 | } |
766 | 766 | |
767 | 767 | if ($cat_display == 'radio') |
768 | - $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
768 | + $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.ucfirst($cat_term->name).'</span>'; |
|
769 | 769 | elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
770 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>'; |
|
770 | + $out .= '<option '.$main_list_class.' style="margin-left:'.$p.'px;" alt="'.$cat_term->taxonomy.'" title="'.ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' >'.$term_check.ucfirst($cat_term->name).'</option>'; |
|
771 | 771 | |
772 | 772 | else { |
773 | - $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
773 | + $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category['.$cat_term->taxonomy.'][]" '.$main_list_class.' alt="'.$cat_term->taxonomy.'" title="'.ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" '.$checked.$onchange.' id="gd-cat-'.$cat_term->term_id.'" >'.$term_check.ucfirst($cat_term->name).'</span>'; |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | // Call recurson to print sub cats |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | $cat_exclude = serialize($exclude_cats); |
810 | 810 | |
811 | 811 | if (isset($_REQUEST['backandedit'])) { |
812 | - $post = (object)$gd_session->get('listing'); |
|
812 | + $post = (object) $gd_session->get('listing'); |
|
813 | 813 | |
814 | 814 | if (!is_array($post->post_category[$cat_taxonomy])) |
815 | 815 | $post_category = $post->post_category[$cat_taxonomy]; |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | |
842 | 842 | if (!empty($post_category)) { |
843 | 843 | $cat1 = array_filter(explode(',', $post_category)); |
844 | - $post_category = ',' . implode(',', $cat1) . ','; |
|
844 | + $post_category = ','.implode(',', $cat1).','; |
|
845 | 845 | |
846 | 846 | } |
847 | 847 | |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | foreach ($post_category_upd as $cat) { |
853 | 853 | |
854 | 854 | if (!in_array($cat, $exclude_cats) && $cat != '') { |
855 | - $post_category_change .= ',' . $cat; |
|
855 | + $post_category_change .= ','.$cat; |
|
856 | 856 | } |
857 | 857 | } |
858 | 858 | $post_category = $post_category_change; |
@@ -864,11 +864,11 @@ discard block |
||
864 | 864 | } |
865 | 865 | } |
866 | 866 | |
867 | - echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
867 | + echo '<input type="hidden" id="cat_limit" value="'.$cat_limit.'" name="cat_limit['.$cat_taxonomy.']" />'; |
|
868 | 868 | |
869 | - echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
869 | + echo '<input type="hidden" id="post_category" value="'.$post_category.'" name="post_category['.$cat_taxonomy.']" />'; |
|
870 | 870 | |
871 | - echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
871 | + echo '<input type="hidden" id="post_category_str" value="'.$post_category_str.'" name="post_category_str['.$cat_taxonomy.']" />'; |
|
872 | 872 | |
873 | 873 | |
874 | 874 | ?> |
@@ -887,14 +887,14 @@ discard block |
||
887 | 887 | |
888 | 888 | function show_subcatlist(main_cat, catObj) { |
889 | 889 | if (main_cat != '') { |
890 | - var url = '<?php echo geodir_get_ajax_url();?>'; |
|
891 | - var cat_taxonomy = '<?php echo $cat_taxonomy;?>'; |
|
892 | - var cat_exclude = '<?php echo base64_encode($cat_exclude);?>'; |
|
890 | + var url = '<?php echo geodir_get_ajax_url(); ?>'; |
|
891 | + var cat_taxonomy = '<?php echo $cat_taxonomy; ?>'; |
|
892 | + var cat_exclude = '<?php echo base64_encode($cat_exclude); ?>'; |
|
893 | 893 | var cat_limit = jQuery('#' + cat_taxonomy).find('#cat_limit').val(); |
894 | - <?php if ((int)$cat_limit > 0) { ?> |
|
894 | + <?php if ((int) $cat_limit > 0) { ?> |
|
895 | 895 | var selected = parseInt(jQuery('#' + cat_taxonomy).find('.cat_sublist > div.post_catlist_item').length); |
896 | 896 | if (cat_limit != '' && selected > 0 && selected >= cat_limit && cat_limit != 0) { |
897 | - alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int)$cat_limit));?>"); |
|
897 | + alert("<?php echo esc_attr(wp_sprintf(__('You have reached category limit of %d categories.', 'geodirectory'), (int) $cat_limit)); ?>"); |
|
898 | 898 | return false; |
899 | 899 | } |
900 | 900 | <?php } ?> |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | } |
934 | 934 | |
935 | 935 | function update_listing_cat(el) { |
936 | - var cat_taxonomy = '<?php echo $cat_taxonomy;?>'; |
|
936 | + var cat_taxonomy = '<?php echo $cat_taxonomy; ?>'; |
|
937 | 937 | var cat_ids = ''; |
938 | 938 | var main_cat = ''; |
939 | 939 | var sub_cat = ''; |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | <div class="main_cat_list" style=" <?php if (isset($style)) { |
1015 | 1015 | echo $style; |
1016 | 1016 | }?> "> |
1017 | - <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
|
1017 | + <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
|
1018 | 1018 | ?> |
1019 | 1019 | </div> |
1020 | 1020 | <?php |
@@ -1041,9 +1041,9 @@ discard block |
||
1041 | 1041 | if ($exclude != '') { |
1042 | 1042 | $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
1043 | 1043 | |
1044 | - if(is_array( $exclude_cats)){ |
|
1045 | - $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
1046 | - }else{ |
|
1044 | + if (is_array($exclude_cats)) { |
|
1045 | + $exclude_cats = array_map('intval', $exclude_cats); |
|
1046 | + } else { |
|
1047 | 1047 | $exclude_cats = intval($exclude_cats); |
1048 | 1048 | } |
1049 | 1049 | |
@@ -1057,25 +1057,25 @@ discard block |
||
1057 | 1057 | <?php $main_cat = get_term($parrent, $request_taxonomy); ?> |
1058 | 1058 | |
1059 | 1059 | <div class="post_catlist_item" style="border:1px solid #CCCCCC; margin:5px auto; padding:5px;"> |
1060 | - <img alt="move icon" src="<?php echo geodir_plugin_url() . '/geodirectory-assets/images/move.png';?>" |
|
1060 | + <img alt="move icon" src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png'; ?>" |
|
1061 | 1061 | onclick="jQuery(this).closest('div').remove();update_listing_cat(this);" align="right"/> |
1062 | 1062 | <?php /* ?> |
1063 | 1063 | <img src="<?php echo geodir_plugin_url().'/geodirectory-assets/images/move.png';?>" onclick="jQuery(this).closest('div').remove();show_subcatlist();" align="right" /> |
1064 | 1064 | <?php */ ?> |
1065 | 1065 | |
1066 | - <input type="checkbox" value="<?php echo $main_cat->term_id;?>" class="listing_main_cat" |
|
1066 | + <input type="checkbox" value="<?php echo $main_cat->term_id; ?>" class="listing_main_cat" |
|
1067 | 1067 | onchange="if(jQuery(this).is(':checked')){jQuery(this).closest('div').find('.post_default_category').prop('checked',false).show();}else{jQuery(this).closest('div').find('.post_default_category').prop('checked',false).hide();};update_listing_cat()" |
1068 | 1068 | checked="checked" disabled="disabled"/> |
1069 | 1069 | <span> |
1070 | - <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name));?> |
|
1070 | + <?php printf(__('Add listing in %s category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?> |
|
1071 | 1071 | </span> |
1072 | 1072 | <br/> |
1073 | 1073 | |
1074 | 1074 | <div class="post_default_category"> |
1075 | - <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>" |
|
1076 | - onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?> /> |
|
1075 | + <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id; ?>" |
|
1076 | + onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" '; ?> /> |
|
1077 | 1077 | <span> |
1078 | - <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?> |
|
1078 | + <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name)); ?> |
|
1079 | 1079 | </span> |
1080 | 1080 | </div> |
1081 | 1081 | |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | $post_cat_str = $post_categories[$request_taxonomy]; |
1109 | 1109 | $post_cat_array = explode("#", $post_cat_str); |
1110 | 1110 | if (is_array($post_cat_array)) { |
1111 | - $post_cat_array = array_unique( $post_cat_array ); |
|
1111 | + $post_cat_array = array_unique($post_cat_array); |
|
1112 | 1112 | |
1113 | 1113 | foreach ($post_cat_array as $post_cat_html) { |
1114 | 1114 | |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | } |
1124 | 1124 | $post_sub_catid = ''; |
1125 | 1125 | if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) { |
1126 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
1126 | + $post_sub_catid = (int) $post_cat_info[1]; |
|
1127 | 1127 | } |
1128 | 1128 | |
1129 | 1129 | geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) { |
1147 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
1147 | + $post_sub_catid = (int) $post_cat_info[1]; |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
@@ -1176,9 +1176,9 @@ discard block |
||
1176 | 1176 | if (!$selected) |
1177 | 1177 | $option_slected = ' selected="selected" '; |
1178 | 1178 | |
1179 | - echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
1179 | + echo '<select field_type="select" id="'.sanitize_text_field($cat_taxonomy).'" class="chosen_select" '.$onchange.' option-ajaxChosen="false" >'; |
|
1180 | 1180 | |
1181 | - echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>'; |
|
1181 | + echo '<option value="" '.$option_selected.' >'.__('Select Category', 'geodirectory').'</option>'; |
|
1182 | 1182 | |
1183 | 1183 | foreach ($cat_terms as $cat_term) { |
1184 | 1184 | $option_selected = ''; |
@@ -1186,10 +1186,10 @@ discard block |
||
1186 | 1186 | $option_selected = ' selected="selected" '; |
1187 | 1187 | |
1188 | 1188 | // Count child terms |
1189 | - $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
1190 | - $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
1189 | + $child_terms = get_terms($cat_taxonomy, array('parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1)); |
|
1190 | + $has_child = !empty($child_terms) ? 't' : 'f'; |
|
1191 | 1191 | |
1192 | - echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . ucfirst($cat_term->name) . '</option>'; |
|
1192 | + echo '<option '.$option_selected.' alt="'.$cat_term->taxonomy.'" title="'.ucfirst($cat_term->name).'" value="'.$cat_term->term_id.'" _hc="'.$has_child.'" >'.ucfirst($cat_term->name).'</option>'; |
|
1193 | 1193 | } |
1194 | 1194 | echo '</select>'; |
1195 | 1195 | } |
@@ -1220,7 +1220,7 @@ discard block |
||
1220 | 1220 | 2 => __('Custom field updated.', 'geodirectory'), |
1221 | 1221 | 3 => __('Custom field deleted.', 'geodirectory'), |
1222 | 1222 | 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name), |
1223 | - 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
1223 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'geodirectory'), $post_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
1224 | 1224 | 6 => sprintf(__('%s published. <a href="%s">View %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(get_permalink($post_ID)), $post_object->labels->singular_name), |
1225 | 1225 | 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name), |
1226 | 1226 | 8 => sprintf(__('%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'geodirectory'), $post_object->labels->singular_name, esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))), $post_object->labels->singular_name), |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | |
1247 | 1247 | global $wpdb; |
1248 | 1248 | |
1249 | - $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
1249 | + $menu_icon = geodir_plugin_url().'/geodirectory-assets/images/favicon.ico'; |
|
1250 | 1250 | |
1251 | 1251 | if (!$listing_slug = get_option('geodir_listing_prefix')) |
1252 | 1252 | $listing_slug = 'places'; |
@@ -1259,11 +1259,11 @@ discard block |
||
1259 | 1259 | |
1260 | 1260 | $gd_placetags = array(); |
1261 | 1261 | $gd_placetags['object_type'] = 'gd_place'; |
1262 | - $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
1262 | + $gd_placetags['listing_slug'] = $listing_slug.'/tags'; |
|
1263 | 1263 | $gd_placetags['args'] = array( |
1264 | 1264 | 'public' => true, |
1265 | 1265 | 'hierarchical' => false, |
1266 | - 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true), |
|
1266 | + 'rewrite' => array('slug' => $listing_slug.'/tags', 'with_front' => false, 'hierarchical' => true), |
|
1267 | 1267 | 'query_var' => true, |
1268 | 1268 | |
1269 | 1269 | 'labels' => array( |
@@ -1357,7 +1357,7 @@ discard block |
||
1357 | 1357 | 'menu_icon' => $menu_icon, |
1358 | 1358 | 'public' => true, |
1359 | 1359 | 'query_var' => true, |
1360 | - 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true), |
|
1360 | + 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true, 'feeds' => true), |
|
1361 | 1361 | 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/), |
1362 | 1362 | 'taxonomies' => array('gd_placecategory', 'gd_place_tags')); |
1363 | 1363 | |
@@ -1390,12 +1390,12 @@ discard block |
||
1390 | 1390 | return $_REQUEST['lang']; |
1391 | 1391 | } |
1392 | 1392 | |
1393 | - $url = str_replace(array("http://","https://"),"",$url); |
|
1393 | + $url = str_replace(array("http://", "https://"), "", $url); |
|
1394 | 1394 | |
1395 | 1395 | // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang. |
1396 | - $site_url = str_replace(array("http://","https://"),"",site_url()); |
|
1396 | + $site_url = str_replace(array("http://", "https://"), "", site_url()); |
|
1397 | 1397 | |
1398 | - $url = str_replace($site_url,"",$url); |
|
1398 | + $url = str_replace($site_url, "", $url); |
|
1399 | 1399 | |
1400 | 1400 | $segments = explode('/', trim($url, '/')); |
1401 | 1401 | |
@@ -1465,17 +1465,17 @@ discard block |
||
1465 | 1465 | $slug = $post_types[$post->post_type]['rewrite']['slug']; |
1466 | 1466 | |
1467 | 1467 | // Alter the CPT slug if WPML is set to do so |
1468 | - if(function_exists('icl_object_id')){ |
|
1469 | - if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) { |
|
1468 | + if (function_exists('icl_object_id')) { |
|
1469 | + if (gd_wpml_slug_translation_turned_on($post->post_type) && $language_code = gd_wpml_get_lang_from_url($post_link)) { |
|
1470 | 1470 | |
1471 | 1471 | $org_slug = $slug; |
1472 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
1472 | + $slug = apply_filters('wpml_translate_single_string', |
|
1473 | 1473 | $slug, |
1474 | 1474 | 'WordPress', |
1475 | - 'URL slug: ' . $slug, |
|
1475 | + 'URL slug: '.$slug, |
|
1476 | 1476 | $language_code); |
1477 | 1477 | |
1478 | - if(!$slug){$slug = $org_slug;} |
|
1478 | + if (!$slug) {$slug = $org_slug; } |
|
1479 | 1479 | |
1480 | 1480 | } |
1481 | 1481 | } |
@@ -1497,11 +1497,11 @@ discard block |
||
1497 | 1497 | } |
1498 | 1498 | |
1499 | 1499 | $post_link = trailingslashit( |
1500 | - preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
1500 | + preg_replace("/".preg_quote($slug, "/")."/", $slug."/%gd_taxonomy%", $post_link, 1) |
|
1501 | 1501 | ); |
1502 | 1502 | |
1503 | 1503 | if ($fix_url) { |
1504 | - $post_link = $site_url . $post_link; |
|
1504 | + $post_link = $site_url.$post_link; |
|
1505 | 1505 | } |
1506 | 1506 | |
1507 | 1507 | if (isset($comment_post_cache[$post->ID])) { |
@@ -1520,12 +1520,12 @@ discard block |
||
1520 | 1520 | $ID = $post->ID; |
1521 | 1521 | $post2 = $wpdb->get_row( |
1522 | 1522 | $wpdb->prepare( |
1523 | - "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
1523 | + "SELECT * from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ", |
|
1524 | 1524 | array($post->ID) |
1525 | 1525 | ) |
1526 | 1526 | ); |
1527 | 1527 | |
1528 | - $post = (object)array_merge((array)$post, (array)$post2); |
|
1528 | + $post = (object) array_merge((array) $post, (array) $post2); |
|
1529 | 1529 | |
1530 | 1530 | $comment_post_cache[$post->ID] = $post; |
1531 | 1531 | } |
@@ -1534,7 +1534,7 @@ discard block |
||
1534 | 1534 | |
1535 | 1535 | if (false !== strpos($post_link, '%gd_taxonomy%')) { |
1536 | 1536 | |
1537 | - if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) { |
|
1537 | + if (apply_filters("geodir_add_location_url_to_url", get_option('geodir_add_location_url'), $post->post_type, $post)) { |
|
1538 | 1538 | $location_request = ''; |
1539 | 1539 | |
1540 | 1540 | |
@@ -1548,7 +1548,7 @@ discard block |
||
1548 | 1548 | $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]); |
1549 | 1549 | $post->country_slug = str_replace(']', '', $post->country_slug); |
1550 | 1550 | |
1551 | - $post_location = (object)array('country_slug' => $post->country_slug, |
|
1551 | + $post_location = (object) array('country_slug' => $post->country_slug, |
|
1552 | 1552 | 'region_slug' => $post->region_slug, |
1553 | 1553 | 'city_slug' => $post->city_slug |
1554 | 1554 | ); |
@@ -1561,7 +1561,7 @@ discard block |
||
1561 | 1561 | |
1562 | 1562 | $post_location_sql = $wpdb->get_results( |
1563 | 1563 | $wpdb->prepare( |
1564 | - "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
1564 | + "SELECT post_locations from ".$plugin_prefix.$post->post_type."_detail WHERE post_id = %d ", |
|
1565 | 1565 | array($post->ID) |
1566 | 1566 | ) |
1567 | 1567 | ); |
@@ -1577,7 +1577,7 @@ discard block |
||
1577 | 1577 | $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]); |
1578 | 1578 | $post->country_slug = str_replace(']', '', $post->country_slug); |
1579 | 1579 | |
1580 | - $post_location = (object)array('country_slug' => $post->country_slug, |
|
1580 | + $post_location = (object) array('country_slug' => $post->country_slug, |
|
1581 | 1581 | 'region_slug' => $post->region_slug, |
1582 | 1582 | 'city_slug' => $post->city_slug |
1583 | 1583 | ); |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | } |
1607 | 1607 | $location_slug[] = $city_slug; |
1608 | 1608 | |
1609 | - $location_request .= implode('/', $location_slug) . '/'; |
|
1609 | + $location_request .= implode('/', $location_slug).'/'; |
|
1610 | 1610 | } |
1611 | 1611 | } |
1612 | 1612 | |
@@ -1665,14 +1665,14 @@ discard block |
||
1665 | 1665 | $request_term = trim($request_term, '/'); |
1666 | 1666 | |
1667 | 1667 | // Fix with WPML the location terms added twice when CPT slug is translated. |
1668 | - if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) { |
|
1668 | + if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/'.$request_term.$detailurl_separator) !== false) { |
|
1669 | 1669 | $post_link = str_replace('%gd_taxonomy%/', '', $post_link); |
1670 | 1670 | } |
1671 | 1671 | |
1672 | 1672 | if (!empty($request_term)) |
1673 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1673 | + $post_link = str_replace('%gd_taxonomy%', $request_term.$detailurl_separator, $post_link); |
|
1674 | 1674 | else |
1675 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1675 | + $post_link = str_replace('/%gd_taxonomy%', $request_term.$detailurl_separator, $post_link); |
|
1676 | 1676 | //echo $post_link ; |
1677 | 1677 | } |
1678 | 1678 | // temp cache the permalink |
@@ -1747,9 +1747,9 @@ discard block |
||
1747 | 1747 | $url_separator = ''; |
1748 | 1748 | |
1749 | 1749 | if (get_option('permalink_structure') != '') { |
1750 | - $old_listing_slug = '/' . $listing_slug . '/'; |
|
1750 | + $old_listing_slug = '/'.$listing_slug.'/'; |
|
1751 | 1751 | $request_term = implode("/", $location_terms); |
1752 | - $new_listing_slug = '/' . $listing_slug . '/' . $request_term . '/'; |
|
1752 | + $new_listing_slug = '/'.$listing_slug.'/'.$request_term.'/'; |
|
1753 | 1753 | |
1754 | 1754 | $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
1755 | 1755 | } else { |
@@ -1769,25 +1769,25 @@ discard block |
||
1769 | 1769 | // Alter the CPT slug if WPML is set to do so |
1770 | 1770 | if (function_exists('icl_object_id')) { |
1771 | 1771 | $post_types = get_option('geodir_post_types'); |
1772 | - $post_type = str_replace("category","",$taxonomy); |
|
1773 | - $post_type = str_replace("_tags","",$post_type); |
|
1772 | + $post_type = str_replace("category", "", $taxonomy); |
|
1773 | + $post_type = str_replace("_tags", "", $post_type); |
|
1774 | 1774 | $slug = $post_types[$post_type]['rewrite']['slug']; |
1775 | 1775 | if (gd_wpml_slug_translation_turned_on($post_type)) { |
1776 | 1776 | global $sitepress; |
1777 | 1777 | $default_lang = $sitepress->get_default_language(); |
1778 | 1778 | $language_code = gd_wpml_get_lang_from_url($termlink); |
1779 | - if (!$language_code ) { |
|
1780 | - $language_code = $default_lang; |
|
1779 | + if (!$language_code) { |
|
1780 | + $language_code = $default_lang; |
|
1781 | 1781 | } |
1782 | 1782 | |
1783 | 1783 | $org_slug = $slug; |
1784 | - $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code); |
|
1784 | + $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: '.$slug, $language_code); |
|
1785 | 1785 | |
1786 | 1786 | if (!$slug) { |
1787 | 1787 | $slug = $org_slug; |
1788 | 1788 | } |
1789 | 1789 | |
1790 | - $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1)); |
|
1790 | + $termlink = trailingslashit(preg_replace("/".preg_quote($org_slug, "/")."/", $slug, $termlink, 1)); |
|
1791 | 1791 | } |
1792 | 1792 | } |
1793 | 1793 | } |
@@ -1817,7 +1817,7 @@ discard block |
||
1817 | 1817 | |
1818 | 1818 | if (in_array($post_type, geodir_get_posttypes())) { |
1819 | 1819 | if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) { |
1820 | - if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) { |
|
1820 | + if (geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) { |
|
1821 | 1821 | $location_terms = array( |
1822 | 1822 | 'gd_country' => $post->country_slug, |
1823 | 1823 | 'gd_region' => $post->region_slug, |
@@ -1834,7 +1834,7 @@ discard block |
||
1834 | 1834 | $location_terms = implode("/", $location_terms); |
1835 | 1835 | $location_terms = rtrim($location_terms, '/'); |
1836 | 1836 | |
1837 | - $link .= urldecode($location_terms) . '/'; |
|
1837 | + $link .= urldecode($location_terms).'/'; |
|
1838 | 1838 | } else { |
1839 | 1839 | $link = geodir_getlink($link, $location_terms); |
1840 | 1840 | } |
@@ -1922,9 +1922,9 @@ discard block |
||
1922 | 1922 | return 0; |
1923 | 1923 | $where = 't.term_id = %d'; |
1924 | 1924 | if (!empty($taxonomy)) |
1925 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
1925 | + return $wpdb->get_row($wpdb->prepare($tax_select.$where." AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
1926 | 1926 | else |
1927 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
1927 | + return $wpdb->get_var($wpdb->prepare($select.$where, $term)); |
|
1928 | 1928 | } |
1929 | 1929 | |
1930 | 1930 | $term = trim(wp_unslash($term)); |
@@ -1936,7 +1936,7 @@ discard block |
||
1936 | 1936 | |
1937 | 1937 | $where_fields = array($slug); |
1938 | 1938 | if (!empty($taxonomy)) { |
1939 | - $parent = (int)$parent; |
|
1939 | + $parent = (int) $parent; |
|
1940 | 1940 | if ($parent > 0) { |
1941 | 1941 | $where_fields[] = $parent; |
1942 | 1942 | $else_where_fields[] = $parent; |
@@ -2000,13 +2000,13 @@ discard block |
||
2000 | 2000 | $post_types = geodir_get_posttypes(); |
2001 | 2001 | $tax_arr = array(); |
2002 | 2002 | foreach ($post_types as $post_type) { |
2003 | - $tax_arr[] = "'" . $post_type . "category'"; |
|
2003 | + $tax_arr[] = "'".$post_type."category'"; |
|
2004 | 2004 | } |
2005 | 2005 | $tax_c = implode(',', $tax_arr); |
2006 | 2006 | $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)"); |
2007 | 2007 | //$terms = get_terms( $taxonomy ); |
2008 | 2008 | |
2009 | - if($terms) { |
|
2009 | + if ($terms) { |
|
2010 | 2010 | foreach ($terms as $term) { |
2011 | 2011 | $post_type = str_replace("category", "", $term->taxonomy); |
2012 | 2012 | $a_terms[$post_type][] = $term; |
@@ -2014,7 +2014,7 @@ discard block |
||
2014 | 2014 | } |
2015 | 2015 | } |
2016 | 2016 | |
2017 | - if($a_terms) { |
|
2017 | + if ($a_terms) { |
|
2018 | 2018 | foreach ($a_terms as $pt => $t2) { |
2019 | 2019 | |
2020 | 2020 | foreach ($t2 as $term) { |
@@ -2039,7 +2039,7 @@ discard block |
||
2039 | 2039 | } |
2040 | 2040 | |
2041 | 2041 | if (is_ssl()) { |
2042 | - $terms_icons = str_replace("http:","https:",$terms_icons ); |
|
2042 | + $terms_icons = str_replace("http:", "https:", $terms_icons); |
|
2043 | 2043 | } |
2044 | 2044 | |
2045 | 2045 | return apply_filters('geodir_get_term_icons', $terms_icons, $term_id); |
@@ -39,8 +39,9 @@ discard block |
||
39 | 39 | if (get_option('geodir_show_listing_nav')) { |
40 | 40 | |
41 | 41 | $menu_class = ''; |
42 | - if (geodir_is_page('listing')) |
|
43 | - $menu_class = 'current-menu-item'; |
|
42 | + if (geodir_is_page('listing')) { |
|
43 | + $menu_class = 'current-menu-item'; |
|
44 | + } |
|
44 | 45 | |
45 | 46 | |
46 | 47 | //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION |
@@ -52,8 +53,9 @@ discard block |
||
52 | 53 | if (in_array($post_type, $show_post_type_main_nav)) { |
53 | 54 | if (get_post_type_archive_link($post_type)) { |
54 | 55 | $menu_class = ''; |
55 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) |
|
56 | - $menu_class = 'current-menu-item'; |
|
56 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) { |
|
57 | + $menu_class = 'current-menu-item'; |
|
58 | + } |
|
57 | 59 | /** |
58 | 60 | * Filter the menu li class. |
59 | 61 | * |
@@ -130,8 +132,9 @@ discard block |
||
130 | 132 | if (get_post_type_archive_link($post_type)) { |
131 | 133 | |
132 | 134 | $menu_class = ''; |
133 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) |
|
134 | - $menu_class = 'current-menu-item'; |
|
135 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) { |
|
136 | + $menu_class = 'current-menu-item'; |
|
137 | + } |
|
135 | 138 | |
136 | 139 | $items .= '<li class="' . $sub_li_class . '"> |
137 | 140 | <a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '"> |
@@ -159,8 +162,9 @@ discard block |
||
159 | 162 | if (get_option('geodir_show_addlisting_nav')) { |
160 | 163 | |
161 | 164 | $menu_class = ''; |
162 | - if (geodir_is_page('add-listing')) |
|
163 | - $menu_class = 'current-menu-item'; |
|
165 | + if (geodir_is_page('add-listing')) { |
|
166 | + $menu_class = 'current-menu-item'; |
|
167 | + } |
|
164 | 168 | |
165 | 169 | //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION |
166 | 170 | $post_types = geodir_get_posttypes('object'); |
@@ -176,8 +180,9 @@ discard block |
||
176 | 180 | if (geodir_get_addlisting_link($post_type)) { |
177 | 181 | |
178 | 182 | $menu_class = ''; |
179 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) |
|
180 | - $menu_class = 'current-menu-item'; |
|
183 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) { |
|
184 | + $menu_class = 'current-menu-item'; |
|
185 | + } |
|
181 | 186 | /** |
182 | 187 | * Filter the menu li class. |
183 | 188 | * |
@@ -261,8 +266,9 @@ discard block |
||
261 | 266 | if (geodir_get_addlisting_link($post_type)) { |
262 | 267 | |
263 | 268 | $menu_class = ''; |
264 | - if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) |
|
265 | - $menu_class = 'current-menu-item'; |
|
269 | + if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) { |
|
270 | + $menu_class = 'current-menu-item'; |
|
271 | + } |
|
266 | 272 | /** |
267 | 273 | * Filter the menu li class. |
268 | 274 | * |
@@ -319,8 +325,9 @@ discard block |
||
319 | 325 | } |
320 | 326 | //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet. |
321 | 327 | // $menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu); |
322 | - else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) |
|
323 | - $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu); |
|
328 | + else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) { |
|
329 | + $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu); |
|
330 | + } |
|
324 | 331 | |
325 | 332 | return $menu; |
326 | 333 | |
@@ -406,24 +413,28 @@ discard block |
||
406 | 413 | $geodir_post_type = get_query_var('post_type'); |
407 | 414 | |
408 | 415 | if (geodir_is_page('add-listing') || geodir_is_page('preview')) { |
409 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
410 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
411 | - elseif (isset($_REQUEST['listing_type'])) |
|
412 | - $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
416 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
417 | + $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
418 | + } elseif (isset($_REQUEST['listing_type'])) { |
|
419 | + $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
420 | + } |
|
413 | 421 | } |
414 | 422 | |
415 | - if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) |
|
416 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
423 | + if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) { |
|
424 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
425 | + } |
|
417 | 426 | |
418 | - if (is_tax()) |
|
419 | - $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
427 | + if (is_tax()) { |
|
428 | + $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
429 | + } |
|
420 | 430 | |
421 | 431 | |
422 | 432 | $all_postypes = geodir_get_posttypes(); |
423 | 433 | $all_postypes = stripslashes_deep($all_postypes); |
424 | 434 | |
425 | - if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
426 | - $geodir_post_type = ''; |
|
435 | + if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) { |
|
436 | + $geodir_post_type = ''; |
|
437 | + } |
|
427 | 438 | |
428 | 439 | if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){ |
429 | 440 | $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
@@ -508,11 +519,12 @@ discard block |
||
508 | 519 | endswitch; |
509 | 520 | } |
510 | 521 | |
511 | - if (!empty($post_types)) |
|
512 | - return $post_types; |
|
513 | - else |
|
514 | - return array(); |
|
515 | -} |
|
522 | + if (!empty($post_types)) { |
|
523 | + return $post_types; |
|
524 | + } else { |
|
525 | + return array(); |
|
526 | + } |
|
527 | + } |
|
516 | 528 | |
517 | 529 | /** |
518 | 530 | * Get Custom Post Type info. |
@@ -529,9 +541,10 @@ discard block |
||
529 | 541 | $post_types = stripslashes_deep($post_types); |
530 | 542 | if (!empty($post_types) && $post_type != '') { |
531 | 543 | return $post_types[$post_type]; |
532 | - } else |
|
533 | - return false; |
|
534 | -} |
|
544 | + } else { |
|
545 | + return false; |
|
546 | + } |
|
547 | + } |
|
535 | 548 | |
536 | 549 | if (!function_exists('geodir_get_taxonomies')) { |
537 | 550 | /** |
@@ -555,18 +568,21 @@ discard block |
||
555 | 568 | $gd_taxonomies = array_keys($taxonomies); |
556 | 569 | |
557 | 570 | |
558 | - if ($post_type != '') |
|
559 | - $gd_taxonomies = array(); |
|
571 | + if ($post_type != '') { |
|
572 | + $gd_taxonomies = array(); |
|
573 | + } |
|
560 | 574 | |
561 | 575 | $i = 0; |
562 | 576 | foreach ($taxonomies as $taxonomy => $args) { |
563 | 577 | |
564 | - if ($post_type != '' && $args['object_type'] == $post_type) |
|
565 | - $gd_taxonomies[] = $taxonomy; |
|
578 | + if ($post_type != '' && $args['object_type'] == $post_type) { |
|
579 | + $gd_taxonomies[] = $taxonomy; |
|
580 | + } |
|
566 | 581 | |
567 | 582 | if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) { |
568 | - if (array_search($taxonomy, $gd_taxonomies) !== false) |
|
569 | - unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
583 | + if (array_search($taxonomy, $gd_taxonomies) !== false) { |
|
584 | + unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
585 | + } |
|
570 | 586 | } |
571 | 587 | |
572 | 588 | } |
@@ -621,10 +637,11 @@ discard block |
||
621 | 637 | . ucfirst($category_obj->name) . '</option>'; |
622 | 638 | } |
623 | 639 | |
624 | - if ($echo) |
|
625 | - echo $html; |
|
626 | - else |
|
627 | - return $html; |
|
640 | + if ($echo) { |
|
641 | + echo $html; |
|
642 | + } else { |
|
643 | + return $html; |
|
644 | + } |
|
628 | 645 | } |
629 | 646 | } |
630 | 647 | |
@@ -658,11 +675,12 @@ discard block |
||
658 | 675 | |
659 | 676 | } |
660 | 677 | |
661 | - if (!empty($listing_slug)) |
|
662 | - return $listing_slug; |
|
663 | - else |
|
664 | - return false; |
|
665 | -} |
|
678 | + if (!empty($listing_slug)) { |
|
679 | + return $listing_slug; |
|
680 | + } else { |
|
681 | + return false; |
|
682 | + } |
|
683 | + } |
|
666 | 684 | |
667 | 685 | |
668 | 686 | /** |
@@ -693,16 +711,18 @@ discard block |
||
693 | 711 | if (!empty($taxonomies)) { |
694 | 712 | foreach (geodir_get_posttypes() as $pt) { |
695 | 713 | $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
696 | - if (array_intersect($taxonomies, $object_taxonomies)) |
|
697 | - $post_type[] = $pt; |
|
714 | + if (array_intersect($taxonomies, $object_taxonomies)) { |
|
715 | + $post_type[] = $pt; |
|
716 | + } |
|
698 | 717 | } |
699 | 718 | } |
700 | 719 | |
701 | - if (!empty($post_type)) |
|
702 | - return $post_type[0]; |
|
703 | - else |
|
704 | - return false; |
|
705 | -} |
|
720 | + if (!empty($post_type)) { |
|
721 | + return $post_type[0]; |
|
722 | + } else { |
|
723 | + return false; |
|
724 | + } |
|
725 | + } |
|
706 | 726 | |
707 | 727 | if (!function_exists('geodir_custom_taxonomy_walker')) { |
708 | 728 | /** |
@@ -758,18 +778,18 @@ discard block |
||
758 | 778 | $checked = ''; |
759 | 779 | |
760 | 780 | if (in_array($cat_term->term_id, $search_terms)) { |
761 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
762 | - $checked = 'selected="selected"'; |
|
763 | - else |
|
764 | - $checked = 'checked="checked"'; |
|
781 | + if ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
782 | + $checked = 'selected="selected"'; |
|
783 | + } else { |
|
784 | + $checked = 'checked="checked"'; |
|
785 | + } |
|
765 | 786 | } |
766 | 787 | |
767 | - if ($cat_display == 'radio') |
|
768 | - $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
769 | - elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
770 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>'; |
|
771 | - |
|
772 | - else { |
|
788 | + if ($cat_display == 'radio') { |
|
789 | + $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
|
790 | + } elseif ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
791 | + $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>'; |
|
792 | + } else { |
|
773 | 793 | $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>'; |
774 | 794 | } |
775 | 795 | |
@@ -778,8 +798,9 @@ discard block |
||
778 | 798 | |
779 | 799 | } |
780 | 800 | |
781 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
782 | - $out .= '</div>'; |
|
801 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') { |
|
802 | + $out .= '</div>'; |
|
803 | + } |
|
783 | 804 | |
784 | 805 | return $out; |
785 | 806 | } |
@@ -805,18 +826,21 @@ discard block |
||
805 | 826 | global $exclude_cats, $gd_session; |
806 | 827 | |
807 | 828 | $cat_exclude = ''; |
808 | - if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
809 | - $cat_exclude = serialize($exclude_cats); |
|
829 | + if (is_array($exclude_cats) && !empty($exclude_cats)) { |
|
830 | + $cat_exclude = serialize($exclude_cats); |
|
831 | + } |
|
810 | 832 | |
811 | 833 | if (isset($_REQUEST['backandedit'])) { |
812 | 834 | $post = (object)$gd_session->get('listing'); |
813 | 835 | |
814 | - if (!is_array($post->post_category[$cat_taxonomy])) |
|
815 | - $post_category = $post->post_category[$cat_taxonomy]; |
|
836 | + if (!is_array($post->post_category[$cat_taxonomy])) { |
|
837 | + $post_category = $post->post_category[$cat_taxonomy]; |
|
838 | + } |
|
816 | 839 | |
817 | 840 | $post_categories = $post->post_category_str; |
818 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
819 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
841 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
842 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
843 | + } |
|
820 | 844 | |
821 | 845 | } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) { |
822 | 846 | global $post; |
@@ -1007,8 +1031,9 @@ discard block |
||
1007 | 1031 | if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
1008 | 1032 | $post_cat_str = $post_categories[$cat_taxonomy]; |
1009 | 1033 | $post_cat_array = explode("#", $post_cat_str); |
1010 | - if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
1011 | - $style = "display:none;"; |
|
1034 | + if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) { |
|
1035 | + $style = "display:none;"; |
|
1036 | + } |
|
1012 | 1037 | } |
1013 | 1038 | ?> |
1014 | 1039 | <div class="main_cat_list" style=" <?php if (isset($style)) { |
@@ -1043,7 +1068,7 @@ discard block |
||
1043 | 1068 | |
1044 | 1069 | if(is_array( $exclude_cats)){ |
1045 | 1070 | $exclude_cats = array_map( 'intval', $exclude_cats ); |
1046 | - }else{ |
|
1071 | + } else{ |
|
1047 | 1072 | $exclude_cats = intval($exclude_cats); |
1048 | 1073 | } |
1049 | 1074 | |
@@ -1073,7 +1098,10 @@ discard block |
||
1073 | 1098 | |
1074 | 1099 | <div class="post_default_category"> |
1075 | 1100 | <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>" |
1076 | - onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?> /> |
|
1101 | + onchange="update_listing_cat()" <?php if ($default) { |
|
1102 | + echo ' checked="checked" '; |
|
1103 | +} |
|
1104 | +?> /> |
|
1077 | 1105 | <span> |
1078 | 1106 | <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?> |
1079 | 1107 | </span> |
@@ -1173,8 +1201,9 @@ discard block |
||
1173 | 1201 | $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
1174 | 1202 | |
1175 | 1203 | $option_selected = ''; |
1176 | - if (!$selected) |
|
1177 | - $option_slected = ' selected="selected" '; |
|
1204 | + if (!$selected) { |
|
1205 | + $option_slected = ' selected="selected" '; |
|
1206 | + } |
|
1178 | 1207 | |
1179 | 1208 | echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
1180 | 1209 | |
@@ -1182,8 +1211,9 @@ discard block |
||
1182 | 1211 | |
1183 | 1212 | foreach ($cat_terms as $cat_term) { |
1184 | 1213 | $option_selected = ''; |
1185 | - if ($selected == $cat_term->term_id) |
|
1186 | - $option_selected = ' selected="selected" '; |
|
1214 | + if ($selected == $cat_term->term_id) { |
|
1215 | + $option_selected = ' selected="selected" '; |
|
1216 | + } |
|
1187 | 1217 | |
1188 | 1218 | // Count child terms |
1189 | 1219 | $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
@@ -1248,8 +1278,9 @@ discard block |
||
1248 | 1278 | |
1249 | 1279 | $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
1250 | 1280 | |
1251 | - if (!$listing_slug = get_option('geodir_listing_prefix')) |
|
1252 | - $listing_slug = 'places'; |
|
1281 | + if (!$listing_slug = get_option('geodir_listing_prefix')) { |
|
1282 | + $listing_slug = 'places'; |
|
1283 | + } |
|
1253 | 1284 | |
1254 | 1285 | /** |
1255 | 1286 | * Taxonomies |
@@ -1553,8 +1584,9 @@ discard block |
||
1553 | 1584 | 'city_slug' => $post->city_slug |
1554 | 1585 | ); |
1555 | 1586 | |
1556 | - } else |
|
1557 | - $post_location = geodir_get_location(); |
|
1587 | + } else { |
|
1588 | + $post_location = geodir_get_location(); |
|
1589 | + } |
|
1558 | 1590 | |
1559 | 1591 | |
1560 | 1592 | } else { |
@@ -1583,8 +1615,9 @@ discard block |
||
1583 | 1615 | ); |
1584 | 1616 | |
1585 | 1617 | } |
1586 | - } else |
|
1587 | - $post_location = geodir_get_location(); |
|
1618 | + } else { |
|
1619 | + $post_location = geodir_get_location(); |
|
1620 | + } |
|
1588 | 1621 | } |
1589 | 1622 | |
1590 | 1623 | |
@@ -1627,8 +1660,9 @@ discard block |
||
1627 | 1660 | $post_terms = $post_terms[0]; |
1628 | 1661 | } |
1629 | 1662 | |
1630 | - if (!$post_terms) |
|
1631 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
1663 | + if (!$post_terms) { |
|
1664 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
1665 | + } |
|
1632 | 1666 | |
1633 | 1667 | if (!$post_terms) { |
1634 | 1668 | $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
@@ -1642,8 +1676,9 @@ discard block |
||
1642 | 1676 | |
1643 | 1677 | $term = get_term_by('id', $post_terms, $taxonomies); |
1644 | 1678 | |
1645 | - if (!empty($term)) |
|
1646 | - $term_request = $term->slug; |
|
1679 | + if (!empty($term)) { |
|
1680 | + $term_request = $term->slug; |
|
1681 | + } |
|
1647 | 1682 | //$term_request = $term->slug.'/'; |
1648 | 1683 | } |
1649 | 1684 | |
@@ -1658,9 +1693,13 @@ discard block |
||
1658 | 1693 | $request_term .= $term_request; |
1659 | 1694 | |
1660 | 1695 | } else { |
1661 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
1696 | + if (isset($location_request) && $location_request != '') { |
|
1697 | + $request_term = $location_request; |
|
1698 | + } |
|
1662 | 1699 | |
1663 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
1700 | + if (isset($term_request) && $term_request != '') { |
|
1701 | + $request_term .= $term_request; |
|
1702 | + } |
|
1664 | 1703 | } |
1665 | 1704 | $request_term = trim($request_term, '/'); |
1666 | 1705 | |
@@ -1669,10 +1708,11 @@ discard block |
||
1669 | 1708 | $post_link = str_replace('%gd_taxonomy%/', '', $post_link); |
1670 | 1709 | } |
1671 | 1710 | |
1672 | - if (!empty($request_term)) |
|
1673 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1674 | - else |
|
1675 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1711 | + if (!empty($request_term)) { |
|
1712 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1713 | + } else { |
|
1714 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1715 | + } |
|
1676 | 1716 | //echo $post_link ; |
1677 | 1717 | } |
1678 | 1718 | // temp cache the permalink |
@@ -1864,11 +1904,12 @@ discard block |
||
1864 | 1904 | |
1865 | 1905 | $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
1866 | 1906 | |
1867 | - if ($echo) |
|
1868 | - echo $label; |
|
1869 | - else |
|
1870 | - return $label; |
|
1871 | -} |
|
1907 | + if ($echo) { |
|
1908 | + echo $label; |
|
1909 | + } else { |
|
1910 | + return $label; |
|
1911 | + } |
|
1912 | + } |
|
1872 | 1913 | |
1873 | 1914 | /** |
1874 | 1915 | * Print or Get post type plural label. |
@@ -1884,18 +1925,20 @@ discard block |
||
1884 | 1925 | function get_post_type_plural_label($post_type, $echo = false, $translate = false) { |
1885 | 1926 | $all_postypes = geodir_get_posttypes(); |
1886 | 1927 | |
1887 | - if (!in_array($post_type, $all_postypes)) |
|
1888 | - return false; |
|
1928 | + if (!in_array($post_type, $all_postypes)) { |
|
1929 | + return false; |
|
1930 | + } |
|
1889 | 1931 | |
1890 | 1932 | $obj_post_type = get_post_type_object($post_type); |
1891 | 1933 | |
1892 | 1934 | $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
1893 | 1935 | |
1894 | - if ($echo) |
|
1895 | - echo $label; |
|
1896 | - else |
|
1897 | - return $label; |
|
1898 | -} |
|
1936 | + if ($echo) { |
|
1937 | + echo $label; |
|
1938 | + } else { |
|
1939 | + return $label; |
|
1940 | + } |
|
1941 | + } |
|
1899 | 1942 | |
1900 | 1943 | /** |
1901 | 1944 | * Checks whether a term exists or not. |
@@ -1918,19 +1961,22 @@ discard block |
||
1918 | 1961 | $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE "; |
1919 | 1962 | |
1920 | 1963 | if (is_int($term)) { |
1921 | - if (0 == $term) |
|
1922 | - return 0; |
|
1964 | + if (0 == $term) { |
|
1965 | + return 0; |
|
1966 | + } |
|
1923 | 1967 | $where = 't.term_id = %d'; |
1924 | - if (!empty($taxonomy)) |
|
1925 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
1926 | - else |
|
1927 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
1968 | + if (!empty($taxonomy)) { |
|
1969 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
1970 | + } else { |
|
1971 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
1972 | + } |
|
1928 | 1973 | } |
1929 | 1974 | |
1930 | 1975 | $term = trim(wp_unslash($term)); |
1931 | 1976 | |
1932 | - if ('' === $slug = sanitize_title($term)) |
|
1933 | - return 0; |
|
1977 | + if ('' === $slug = sanitize_title($term)) { |
|
1978 | + return 0; |
|
1979 | + } |
|
1934 | 1980 | |
1935 | 1981 | $where = 't.slug = %s'; |
1936 | 1982 | |
@@ -1947,14 +1993,16 @@ discard block |
||
1947 | 1993 | $where_fields[] = $taxonomy; |
1948 | 1994 | |
1949 | 1995 | |
1950 | - if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A)) |
|
1951 | - return $result; |
|
1996 | + if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A)) { |
|
1997 | + return $result; |
|
1998 | + } |
|
1952 | 1999 | |
1953 | 2000 | return false; |
1954 | 2001 | } |
1955 | 2002 | |
1956 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) |
|
1957 | - return $result; |
|
2003 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) { |
|
2004 | + return $result; |
|
2005 | + } |
|
1958 | 2006 | |
1959 | 2007 | return false; |
1960 | 2008 | } |