@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function geodir_comment_meta_row_action($a) |
33 | 33 | { |
34 | - global $comment; |
|
34 | + global $comment; |
|
35 | 35 | |
36 | - $rating = geodir_get_commentoverall($comment->comment_ID); |
|
37 | - if ($rating != 0) { |
|
38 | - echo geodir_get_rating_stars($rating, $comment->comment_ID); |
|
39 | - } |
|
40 | - return $a; |
|
36 | + $rating = geodir_get_commentoverall($comment->comment_ID); |
|
37 | + if ($rating != 0) { |
|
38 | + echo geodir_get_rating_stars($rating, $comment->comment_ID); |
|
39 | + } |
|
40 | + return $a; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | add_action('add_meta_boxes_comment', 'geodir_comment_add_meta_box'); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function geodir_comment_add_meta_box($comment) |
54 | 54 | { |
55 | - add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high'); |
|
55 | + add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param object $comment The comment object. |
67 | 67 | */ |
68 | 68 | function geodir_comment_rating_meta($comment) { |
69 | - $post_type = get_post_type($comment->comment_post_ID); |
|
69 | + $post_type = get_post_type($comment->comment_post_ID); |
|
70 | 70 | if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) { |
71 | 71 | $rating = geodir_get_commentoverall($comment->comment_ID); |
72 | 72 | |
@@ -106,24 +106,24 @@ discard block |
||
106 | 106 | * @global object $post The post object. |
107 | 107 | */ |
108 | 108 | function geodir_comment_rating_fields() { |
109 | - global $post; |
|
109 | + global $post; |
|
110 | 110 | |
111 | - $post_types = geodir_get_posttypes(); |
|
111 | + $post_types = geodir_get_posttypes(); |
|
112 | 112 | |
113 | - if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) { |
|
114 | - $star_texts = array(); |
|
115 | - $star_texts[] = __('Terrible', 'geodirectory'); |
|
116 | - $star_texts[] = __('Poor', 'geodirectory'); |
|
117 | - $star_texts[] = __('Average', 'geodirectory'); |
|
118 | - $star_texts[] = __('Very Good', 'geodirectory'); |
|
119 | - $star_texts[] = __('Excellent', 'geodirectory'); |
|
113 | + if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) { |
|
114 | + $star_texts = array(); |
|
115 | + $star_texts[] = __('Terrible', 'geodirectory'); |
|
116 | + $star_texts[] = __('Poor', 'geodirectory'); |
|
117 | + $star_texts[] = __('Average', 'geodirectory'); |
|
118 | + $star_texts[] = __('Very Good', 'geodirectory'); |
|
119 | + $star_texts[] = __('Excellent', 'geodirectory'); |
|
120 | 120 | |
121 | - $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts); |
|
122 | - echo $gd_rating_html; |
|
123 | - ?> |
|
121 | + $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts); |
|
122 | + echo $gd_rating_html; |
|
123 | + ?> |
|
124 | 124 | <input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="0"/> |
125 | 125 | <?php |
126 | - } |
|
126 | + } |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | add_filter('comment_reply_link', 'geodir_comment_replaylink'); |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | function geodir_comment_replaylink($link) |
140 | 140 | { |
141 | 141 | |
142 | - if (strpos($link, 'wp-login.php?') !== false) { |
|
143 | - $link = str_replace(wp_login_url(),geodir_login_url(),$link); |
|
144 | - } |
|
145 | - $link = '<div class="gd_comment_replaylink">' . $link . '</div>'; |
|
142 | + if (strpos($link, 'wp-login.php?') !== false) { |
|
143 | + $link = str_replace(wp_login_url(),geodir_login_url(),$link); |
|
144 | + } |
|
145 | + $link = '<div class="gd_comment_replaylink">' . $link . '</div>'; |
|
146 | 146 | |
147 | - return $link; |
|
147 | + return $link; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | add_filter('cancel_comment_reply_link', 'geodir_cancle_replaylink'); |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | function geodir_cancle_replaylink($link) |
160 | 160 | { |
161 | 161 | |
162 | - $link = '<span class="gd-cancel-replaylink">' . $link . '</span>'; |
|
162 | + $link = '<span class="gd-cancel-replaylink">' . $link . '</span>'; |
|
163 | 163 | |
164 | - return $link; |
|
164 | + return $link; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | add_action('comment_post', 'geodir_save_rating'); |
@@ -177,32 +177,32 @@ discard block |
||
177 | 177 | */ |
178 | 178 | function geodir_save_rating($comment = 0) |
179 | 179 | { |
180 | - global $wpdb, $user_ID, $plugin_prefix; |
|
180 | + global $wpdb, $user_ID, $plugin_prefix; |
|
181 | 181 | |
182 | - $comment_info = get_comment($comment); |
|
182 | + $comment_info = get_comment($comment); |
|
183 | 183 | |
184 | - $post_id = $comment_info->comment_post_ID; |
|
185 | - $status = $comment_info->comment_approved; |
|
186 | - $rating_ip = geodir_get_ip(); |
|
184 | + $post_id = $comment_info->comment_post_ID; |
|
185 | + $status = $comment_info->comment_approved; |
|
186 | + $rating_ip = geodir_get_ip(); |
|
187 | 187 | |
188 | - $post = geodir_get_post_info($post_id); |
|
189 | - if (empty($post)) { |
|
190 | - return; |
|
191 | - } |
|
192 | - |
|
193 | - if ($post->post_status == 'publish') { |
|
194 | - $post_status = '1'; |
|
195 | - } else { |
|
196 | - $post_status = '0'; |
|
197 | - } |
|
188 | + $post = geodir_get_post_info($post_id); |
|
189 | + if (empty($post)) { |
|
190 | + return; |
|
191 | + } |
|
192 | + |
|
193 | + if ($post->post_status == 'publish') { |
|
194 | + $post_status = '1'; |
|
195 | + } else { |
|
196 | + $post_status = '0'; |
|
197 | + } |
|
198 | 198 | |
199 | - if (isset($_REQUEST['geodir_overallrating'])) { |
|
200 | - $overall_rating = $_REQUEST['geodir_overallrating']; |
|
199 | + if (isset($_REQUEST['geodir_overallrating'])) { |
|
200 | + $overall_rating = $_REQUEST['geodir_overallrating']; |
|
201 | 201 | |
202 | 202 | if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) { |
203 | - $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
203 | + $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
204 | 204 | |
205 | - $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET |
|
205 | + $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET |
|
206 | 206 | post_id = %d, |
207 | 207 | post_type = %s, |
208 | 208 | post_title = %s, |
@@ -220,35 +220,35 @@ discard block |
||
220 | 220 | post_latitude = %s, |
221 | 221 | comment_content = %s |
222 | 222 | ", |
223 | - array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content) |
|
224 | - ); |
|
225 | - |
|
226 | - $wpdb->query($sqlqry); |
|
227 | - |
|
228 | - /** |
|
229 | - * Called after saving the comment. |
|
230 | - * |
|
231 | - * @since 1.0.0 |
|
232 | - * @package GeoDirectory |
|
233 | - * @param array $_REQUEST { |
|
234 | - * Attributes of the $_REQUEST variable. |
|
235 | - * |
|
236 | - * @type string $geodir_overallrating Overall rating. |
|
237 | - * @type string $comment Comment text. |
|
238 | - * @type string $submit Submit button text. |
|
239 | - * @type string $comment_post_ID Comment post ID. |
|
240 | - * @type string $comment_parent Comment Parent ID. |
|
241 | - * @type string $_wp_unfiltered_html_comment Unfiltered html comment string. |
|
242 | - * |
|
243 | - * } |
|
244 | - */ |
|
245 | - do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post'); |
|
246 | - |
|
247 | - if ($status) { |
|
248 | - geodir_update_postrating($post_id); |
|
249 | - } |
|
250 | - } |
|
251 | - } |
|
223 | + array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content) |
|
224 | + ); |
|
225 | + |
|
226 | + $wpdb->query($sqlqry); |
|
227 | + |
|
228 | + /** |
|
229 | + * Called after saving the comment. |
|
230 | + * |
|
231 | + * @since 1.0.0 |
|
232 | + * @package GeoDirectory |
|
233 | + * @param array $_REQUEST { |
|
234 | + * Attributes of the $_REQUEST variable. |
|
235 | + * |
|
236 | + * @type string $geodir_overallrating Overall rating. |
|
237 | + * @type string $comment Comment text. |
|
238 | + * @type string $submit Submit button text. |
|
239 | + * @type string $comment_post_ID Comment post ID. |
|
240 | + * @type string $comment_parent Comment Parent ID. |
|
241 | + * @type string $_wp_unfiltered_html_comment Unfiltered html comment string. |
|
242 | + * |
|
243 | + * } |
|
244 | + */ |
|
245 | + do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post'); |
|
246 | + |
|
247 | + if ($status) { |
|
248 | + geodir_update_postrating($post_id); |
|
249 | + } |
|
250 | + } |
|
251 | + } |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -266,51 +266,51 @@ discard block |
||
266 | 266 | */ |
267 | 267 | function geodir_update_rating_status_change($comment_id, $status) |
268 | 268 | { |
269 | - if ($status == 'delete') { |
|
270 | - return; |
|
271 | - } |
|
272 | - global $wpdb, $plugin_prefix, $user_ID; |
|
269 | + if ($status == 'delete') { |
|
270 | + return; |
|
271 | + } |
|
272 | + global $wpdb, $plugin_prefix, $user_ID; |
|
273 | 273 | |
274 | - $comment_info = get_comment($comment_id); |
|
274 | + $comment_info = get_comment($comment_id); |
|
275 | 275 | |
276 | - $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : ''; |
|
276 | + $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : ''; |
|
277 | 277 | |
278 | - if (!empty($comment_info)) |
|
279 | - $status = $comment_info->comment_approved; |
|
278 | + if (!empty($comment_info)) |
|
279 | + $status = $comment_info->comment_approved; |
|
280 | 280 | |
281 | - if ($status == 'approve' || $status == 1) { |
|
282 | - $status = 1; |
|
283 | - } else { |
|
284 | - $status = 0; |
|
285 | - } |
|
281 | + if ($status == 'approve' || $status == 1) { |
|
282 | + $status = 1; |
|
283 | + } else { |
|
284 | + $status = 0; |
|
285 | + } |
|
286 | 286 | |
287 | - $comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : ''; |
|
288 | - $old_rating = geodir_get_commentoverall($comment_info_ID); |
|
287 | + $comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : ''; |
|
288 | + $old_rating = geodir_get_commentoverall($comment_info_ID); |
|
289 | 289 | |
290 | - $post_type = get_post_type($post_id); |
|
290 | + $post_type = get_post_type($post_id); |
|
291 | 291 | |
292 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
292 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
293 | 293 | |
294 | - if ($comment_id) { |
|
294 | + if ($comment_id) { |
|
295 | 295 | |
296 | - $overall_rating = $old_rating; |
|
296 | + $overall_rating = $old_rating; |
|
297 | 297 | |
298 | - if (isset($old_rating)) { |
|
298 | + if (isset($old_rating)) { |
|
299 | 299 | |
300 | - $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET |
|
300 | + $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET |
|
301 | 301 | overall_rating = %f, |
302 | 302 | status = %s, |
303 | 303 | comment_content = %s |
304 | 304 | WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id)); |
305 | 305 | |
306 | - $wpdb->query($sqlqry); |
|
306 | + $wpdb->query($sqlqry); |
|
307 | 307 | |
308 | - //update rating |
|
309 | - geodir_update_postrating($post_id, $post_type); |
|
308 | + //update rating |
|
309 | + geodir_update_postrating($post_id, $post_type); |
|
310 | 310 | |
311 | - } |
|
311 | + } |
|
312 | 312 | |
313 | - } |
|
313 | + } |
|
314 | 314 | |
315 | 315 | } |
316 | 316 | |
@@ -329,41 +329,41 @@ discard block |
||
329 | 329 | function geodir_update_rating($comment_id = 0) |
330 | 330 | { |
331 | 331 | |
332 | - global $wpdb, $plugin_prefix, $user_ID; |
|
332 | + global $wpdb, $plugin_prefix, $user_ID; |
|
333 | 333 | |
334 | - $comment_info = get_comment($comment_id); |
|
334 | + $comment_info = get_comment($comment_id); |
|
335 | 335 | |
336 | - $post_id = $comment_info->comment_post_ID; |
|
337 | - $status = $comment_info->comment_approved; |
|
338 | - $old_rating = geodir_get_commentoverall($comment_info->comment_ID); |
|
336 | + $post_id = $comment_info->comment_post_ID; |
|
337 | + $status = $comment_info->comment_approved; |
|
338 | + $old_rating = geodir_get_commentoverall($comment_info->comment_ID); |
|
339 | 339 | |
340 | - $post_type = get_post_type($post_id); |
|
340 | + $post_type = get_post_type($post_id); |
|
341 | 341 | |
342 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
342 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
343 | 343 | |
344 | - if (isset($_REQUEST['geodir_overallrating'])) { |
|
344 | + if (isset($_REQUEST['geodir_overallrating'])) { |
|
345 | 345 | |
346 | - $overall_rating = $_REQUEST['geodir_overallrating']; |
|
346 | + $overall_rating = $_REQUEST['geodir_overallrating']; |
|
347 | 347 | |
348 | - if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) { |
|
349 | - $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
348 | + if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) { |
|
349 | + $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
350 | 350 | |
351 | - if (isset($old_rating)) { |
|
351 | + if (isset($old_rating)) { |
|
352 | 352 | |
353 | - $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET |
|
353 | + $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET |
|
354 | 354 | overall_rating = %f, |
355 | 355 | status = %s, |
356 | 356 | comment_content = %s |
357 | 357 | WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id)); |
358 | 358 | |
359 | - $wpdb->query($sqlqry); |
|
359 | + $wpdb->query($sqlqry); |
|
360 | 360 | |
361 | - //update rating |
|
362 | - geodir_update_postrating($post_id, $post_type); |
|
361 | + //update rating |
|
362 | + geodir_update_postrating($post_id, $post_type); |
|
363 | 363 | |
364 | - } |
|
365 | - } |
|
366 | - } |
|
364 | + } |
|
365 | + } |
|
366 | + } |
|
367 | 367 | |
368 | 368 | |
369 | 369 | } |
@@ -379,19 +379,19 @@ discard block |
||
379 | 379 | */ |
380 | 380 | function geodir_comment_delete_comment($comment_id) |
381 | 381 | { |
382 | - global $wpdb; |
|
382 | + global $wpdb; |
|
383 | 383 | |
384 | - $review_info = geodir_get_review($comment_id); |
|
385 | - if ($review_info) { |
|
386 | - geodir_update_postrating($review_info->post_id); |
|
387 | - } |
|
384 | + $review_info = geodir_get_review($comment_id); |
|
385 | + if ($review_info) { |
|
386 | + geodir_update_postrating($review_info->post_id); |
|
387 | + } |
|
388 | 388 | |
389 | - $wpdb->query( |
|
390 | - $wpdb->prepare( |
|
391 | - "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d", |
|
392 | - array($comment_id) |
|
393 | - ) |
|
394 | - ); |
|
389 | + $wpdb->query( |
|
390 | + $wpdb->prepare( |
|
391 | + "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d", |
|
392 | + array($comment_id) |
|
393 | + ) |
|
394 | + ); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -407,21 +407,21 @@ discard block |
||
407 | 407 | * @return string The comment content. |
408 | 408 | */ |
409 | 409 | function geodir_wrap_comment_text($content, $comment = '') { |
410 | - if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) { |
|
411 | - if (!is_admin()) { |
|
412 | - return '<div class="description">' . $content . '</div>'; |
|
413 | - } else { |
|
414 | - return $content; |
|
415 | - } |
|
416 | - } else { |
|
417 | - $rating = 0; |
|
418 | - if (!empty($comment)) |
|
419 | - $rating = geodir_get_commentoverall($comment->comment_ID); |
|
420 | - if ($rating != 0 && !is_admin()) { |
|
421 | - return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>'; |
|
422 | - } else |
|
423 | - return $content; |
|
424 | - } |
|
410 | + if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) { |
|
411 | + if (!is_admin()) { |
|
412 | + return '<div class="description">' . $content . '</div>'; |
|
413 | + } else { |
|
414 | + return $content; |
|
415 | + } |
|
416 | + } else { |
|
417 | + $rating = 0; |
|
418 | + if (!empty($comment)) |
|
419 | + $rating = geodir_get_commentoverall($comment->comment_ID); |
|
420 | + if ($rating != 0 && !is_admin()) { |
|
421 | + return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>'; |
|
422 | + } else |
|
423 | + return $content; |
|
424 | + } |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | |
@@ -438,41 +438,41 @@ discard block |
||
438 | 438 | */ |
439 | 439 | function geodir_update_postrating($post_id = 0, $post_type = '', $delete = false) |
440 | 440 | { |
441 | - global $wpdb, $plugin_prefix, $comment; |
|
442 | - if (!$post_type) { |
|
443 | - $post_type = get_post_type($post_id); |
|
444 | - } |
|
445 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
446 | - $post_newrating = geodir_get_post_rating($post_id, 1); |
|
447 | - $post_newrating_count = geodir_get_review_count_total($post_id); |
|
441 | + global $wpdb, $plugin_prefix, $comment; |
|
442 | + if (!$post_type) { |
|
443 | + $post_type = get_post_type($post_id); |
|
444 | + } |
|
445 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
446 | + $post_newrating = geodir_get_post_rating($post_id, 1); |
|
447 | + $post_newrating_count = geodir_get_review_count_total($post_id); |
|
448 | 448 | |
449 | 449 | |
450 | - //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ; |
|
450 | + //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ; |
|
451 | 451 | |
452 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) { |
|
452 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) { |
|
453 | 453 | |
454 | - $wpdb->query( |
|
455 | - $wpdb->prepare( |
|
456 | - "UPDATE " . $detail_table . " SET |
|
454 | + $wpdb->query( |
|
455 | + $wpdb->prepare( |
|
456 | + "UPDATE " . $detail_table . " SET |
|
457 | 457 | overall_rating = %f, |
458 | 458 | rating_count = %f |
459 | 459 | where post_id = %d", |
460 | - array($post_newrating, $post_newrating_count, $post_id) |
|
461 | - ) |
|
462 | - ); |
|
463 | - |
|
464 | - update_post_meta($post_id, 'overall_rating', $post_newrating); |
|
465 | - update_post_meta($post_id, 'rating_count', $post_newrating_count); |
|
466 | - } |
|
467 | - /** |
|
468 | - * Called after Updating post overall rating and rating count. |
|
469 | - * |
|
470 | - * @since 1.0.0 |
|
471 | - * @since 1.4.3 Added `$post_id` param. |
|
472 | - * @package GeoDirectory |
|
473 | - * @param int $post_id The post ID. |
|
474 | - */ |
|
475 | - do_action('geodir_update_postrating',$post_id); |
|
460 | + array($post_newrating, $post_newrating_count, $post_id) |
|
461 | + ) |
|
462 | + ); |
|
463 | + |
|
464 | + update_post_meta($post_id, 'overall_rating', $post_newrating); |
|
465 | + update_post_meta($post_id, 'rating_count', $post_newrating_count); |
|
466 | + } |
|
467 | + /** |
|
468 | + * Called after Updating post overall rating and rating count. |
|
469 | + * |
|
470 | + * @since 1.0.0 |
|
471 | + * @since 1.4.3 Added `$post_id` param. |
|
472 | + * @package GeoDirectory |
|
473 | + * @param int $post_id The post ID. |
|
474 | + */ |
|
475 | + do_action('geodir_update_postrating',$post_id); |
|
476 | 476 | |
477 | 477 | } |
478 | 478 | |
@@ -490,29 +490,29 @@ discard block |
||
490 | 490 | */ |
491 | 491 | function geodir_get_postoverall($post_id = 0) |
492 | 492 | { |
493 | - global $wpdb, $plugin_prefix; |
|
493 | + global $wpdb, $plugin_prefix; |
|
494 | 494 | |
495 | - $post_type = get_post_type($post_id); |
|
496 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
495 | + $post_type = get_post_type($post_id); |
|
496 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
497 | 497 | |
498 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) { |
|
498 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) { |
|
499 | 499 | |
500 | - $post_ratings = $wpdb->get_var( |
|
501 | - $wpdb->prepare( |
|
502 | - "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d", |
|
503 | - array($post_id) |
|
504 | - ) |
|
505 | - ); |
|
500 | + $post_ratings = $wpdb->get_var( |
|
501 | + $wpdb->prepare( |
|
502 | + "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d", |
|
503 | + array($post_id) |
|
504 | + ) |
|
505 | + ); |
|
506 | 506 | |
507 | 507 | |
508 | - } else { |
|
509 | - $post_ratings = get_post_meta($post_id, 'overall_rating'); |
|
510 | - } |
|
508 | + } else { |
|
509 | + $post_ratings = get_post_meta($post_id, 'overall_rating'); |
|
510 | + } |
|
511 | 511 | |
512 | - if ($post_ratings) |
|
513 | - return $post_ratings; |
|
514 | - else |
|
515 | - return false; |
|
512 | + if ($post_ratings) |
|
513 | + return $post_ratings; |
|
514 | + else |
|
515 | + return false; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | |
@@ -529,19 +529,19 @@ discard block |
||
529 | 529 | */ |
530 | 530 | function geodir_get_review($comment_id = 0) |
531 | 531 | { |
532 | - global $wpdb; |
|
533 | - |
|
534 | - $reatings = $wpdb->get_row( |
|
535 | - $wpdb->prepare( |
|
536 | - "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
537 | - array($comment_id) |
|
538 | - ) |
|
539 | - ); |
|
540 | - |
|
541 | - if (!empty($reatings)) |
|
542 | - return $reatings; |
|
543 | - else |
|
544 | - return false; |
|
532 | + global $wpdb; |
|
533 | + |
|
534 | + $reatings = $wpdb->get_row( |
|
535 | + $wpdb->prepare( |
|
536 | + "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
537 | + array($comment_id) |
|
538 | + ) |
|
539 | + ); |
|
540 | + |
|
541 | + if (!empty($reatings)) |
|
542 | + return $reatings; |
|
543 | + else |
|
544 | + return false; |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -557,19 +557,19 @@ discard block |
||
557 | 557 | */ |
558 | 558 | function geodir_get_review_total($post_id = 0) |
559 | 559 | { |
560 | - global $wpdb; |
|
561 | - |
|
562 | - $results = $wpdb->get_var( |
|
563 | - $wpdb->prepare( |
|
564 | - "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
565 | - array($post_id) |
|
566 | - ) |
|
567 | - ); |
|
568 | - |
|
569 | - if (!empty($results)) |
|
570 | - return $results; |
|
571 | - else |
|
572 | - return false; |
|
560 | + global $wpdb; |
|
561 | + |
|
562 | + $results = $wpdb->get_var( |
|
563 | + $wpdb->prepare( |
|
564 | + "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
565 | + array($post_id) |
|
566 | + ) |
|
567 | + ); |
|
568 | + |
|
569 | + if (!empty($results)) |
|
570 | + return $results; |
|
571 | + else |
|
572 | + return false; |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -585,18 +585,18 @@ discard block |
||
585 | 585 | */ |
586 | 586 | function geodir_get_review_count_by_user_id($user_id = 0) |
587 | 587 | { |
588 | - global $wpdb; |
|
589 | - $results = $wpdb->get_var( |
|
590 | - $wpdb->prepare( |
|
591 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0", |
|
592 | - array($user_id) |
|
593 | - ) |
|
594 | - ); |
|
595 | - |
|
596 | - if (!empty($results)) |
|
597 | - return $results; |
|
598 | - else |
|
599 | - return false; |
|
588 | + global $wpdb; |
|
589 | + $results = $wpdb->get_var( |
|
590 | + $wpdb->prepare( |
|
591 | + "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0", |
|
592 | + array($user_id) |
|
593 | + ) |
|
594 | + ); |
|
595 | + |
|
596 | + if (!empty($results)) |
|
597 | + return $results; |
|
598 | + else |
|
599 | + return false; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -614,27 +614,27 @@ discard block |
||
614 | 614 | */ |
615 | 615 | function geodir_get_post_rating($post_id = 0, $force_query = 0) |
616 | 616 | { |
617 | - global $wpdb, $post; |
|
618 | - |
|
619 | - if (isset($post->ID) && $post->ID == $post_id && !$force_query) { |
|
620 | - if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) { |
|
621 | - return $post->overall_rating; |
|
622 | - } else { |
|
623 | - return 0; |
|
624 | - } |
|
625 | - } |
|
626 | - |
|
627 | - $results = $wpdb->get_var( |
|
628 | - $wpdb->prepare( |
|
629 | - "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
630 | - array($post_id) |
|
631 | - ) |
|
632 | - ); |
|
633 | - |
|
634 | - if (!empty($results)) |
|
635 | - return $results; |
|
636 | - else |
|
637 | - return false; |
|
617 | + global $wpdb, $post; |
|
618 | + |
|
619 | + if (isset($post->ID) && $post->ID == $post_id && !$force_query) { |
|
620 | + if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) { |
|
621 | + return $post->overall_rating; |
|
622 | + } else { |
|
623 | + return 0; |
|
624 | + } |
|
625 | + } |
|
626 | + |
|
627 | + $results = $wpdb->get_var( |
|
628 | + $wpdb->prepare( |
|
629 | + "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
630 | + array($post_id) |
|
631 | + ) |
|
632 | + ); |
|
633 | + |
|
634 | + if (!empty($results)) |
|
635 | + return $results; |
|
636 | + else |
|
637 | + return false; |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | /** |
@@ -650,19 +650,19 @@ discard block |
||
650 | 650 | */ |
651 | 651 | function geodir_get_review_count_total($post_id = 0) |
652 | 652 | { |
653 | - global $wpdb; |
|
654 | - |
|
655 | - $results = $wpdb->get_var( |
|
656 | - $wpdb->prepare( |
|
657 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
658 | - array($post_id) |
|
659 | - ) |
|
660 | - ); |
|
661 | - |
|
662 | - if (!empty($results)) |
|
663 | - return $results; |
|
664 | - else |
|
665 | - return false; |
|
653 | + global $wpdb; |
|
654 | + |
|
655 | + $results = $wpdb->get_var( |
|
656 | + $wpdb->prepare( |
|
657 | + "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
658 | + array($post_id) |
|
659 | + ) |
|
660 | + ); |
|
661 | + |
|
662 | + if (!empty($results)) |
|
663 | + return $results; |
|
664 | + else |
|
665 | + return false; |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
@@ -679,20 +679,20 @@ discard block |
||
679 | 679 | */ |
680 | 680 | function geodir_get_comments_number($post_id = 0) |
681 | 681 | { |
682 | - global $wpdb; |
|
682 | + global $wpdb; |
|
683 | 683 | |
684 | - $results = $wpdb->get_var( |
|
685 | - $wpdb->prepare( |
|
686 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
687 | - array($post_id) |
|
688 | - ) |
|
689 | - ); |
|
684 | + $results = $wpdb->get_var( |
|
685 | + $wpdb->prepare( |
|
686 | + "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
687 | + array($post_id) |
|
688 | + ) |
|
689 | + ); |
|
690 | 690 | |
691 | 691 | |
692 | - if (!empty($results)) |
|
693 | - return $results; |
|
694 | - else |
|
695 | - return false; |
|
692 | + if (!empty($results)) |
|
693 | + return $results; |
|
694 | + else |
|
695 | + return false; |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
@@ -708,19 +708,19 @@ discard block |
||
708 | 708 | */ |
709 | 709 | function geodir_get_commentoverall($comment_id = 0) |
710 | 710 | { |
711 | - global $wpdb; |
|
712 | - |
|
713 | - $reatings = $wpdb->get_var( |
|
714 | - $wpdb->prepare( |
|
715 | - "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
716 | - array($comment_id) |
|
717 | - ) |
|
718 | - ); |
|
719 | - |
|
720 | - if ($reatings) |
|
721 | - return $reatings; |
|
722 | - else |
|
723 | - return false; |
|
711 | + global $wpdb; |
|
712 | + |
|
713 | + $reatings = $wpdb->get_var( |
|
714 | + $wpdb->prepare( |
|
715 | + "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
716 | + array($comment_id) |
|
717 | + ) |
|
718 | + ); |
|
719 | + |
|
720 | + if ($reatings) |
|
721 | + return $reatings; |
|
722 | + else |
|
723 | + return false; |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | */ |
735 | 735 | function geodir_get_commentoverall_number($post_id = 0) |
736 | 736 | { |
737 | - return geodir_get_post_rating($post_id); |
|
737 | + return geodir_get_post_rating($post_id); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | |
@@ -752,102 +752,102 @@ discard block |
||
752 | 752 | */ |
753 | 753 | function geodir_comment_template($comment_template) |
754 | 754 | { |
755 | - global $post; |
|
755 | + global $post; |
|
756 | 756 | |
757 | - $post_types = geodir_get_posttypes(); |
|
757 | + $post_types = geodir_get_posttypes(); |
|
758 | 758 | |
759 | - if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) { |
|
760 | - return; |
|
761 | - } |
|
762 | - if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business |
|
763 | - if (geodir_cpt_has_rating_disabled($post->post_type)) { |
|
764 | - return $comment_template; |
|
765 | - } |
|
759 | + if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) { |
|
760 | + return; |
|
761 | + } |
|
762 | + if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business |
|
763 | + if (geodir_cpt_has_rating_disabled($post->post_type)) { |
|
764 | + return $comment_template; |
|
765 | + } |
|
766 | 766 | |
767 | - $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available |
|
768 | - if (!$template) { |
|
769 | - $template = dirname(__FILE__) . '/reviews.php'; |
|
770 | - } |
|
771 | - return $template; |
|
772 | - } |
|
767 | + $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available |
|
768 | + if (!$template) { |
|
769 | + $template = dirname(__FILE__) . '/reviews.php'; |
|
770 | + } |
|
771 | + return $template; |
|
772 | + } |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | add_filter("comments_template", "geodir_comment_template"); |
776 | 776 | |
777 | 777 | |
778 | 778 | if (!function_exists('geodir_comment')) { |
779 | - /** |
|
780 | - * Comment HTML markup. |
|
781 | - * |
|
782 | - * @since 1.0.0 |
|
783 | - * @package GeoDirectory |
|
784 | - * @global object $post The current post object. |
|
785 | - * @param object $comment The comment object. |
|
786 | - * @param string|array $args { |
|
787 | - * Optional. Formatting options. |
|
788 | - * |
|
789 | - * @type object $walker Instance of a Walker class to list comments. Default null. |
|
790 | - * @type int $max_depth The maximum comments depth. Default empty. |
|
791 | - * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'. |
|
792 | - * @type string $callback Callback function to use. Default null. |
|
793 | - * @type string $end-callback Callback function to use at the end. Default null. |
|
794 | - * @type string $type Type of comments to list. |
|
795 | - * Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'. |
|
796 | - * @type int $page Page ID to list comments for. Default empty. |
|
797 | - * @type int $per_page Number of comments to list per page. Default empty. |
|
798 | - * @type int $avatar_size Height and width dimensions of the avatar size. Default 32. |
|
799 | - * @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'. |
|
800 | - * @type bool $reverse_children Whether to reverse child comments in the list. Default null. |
|
801 | - * @type string $format How to format the comments list. |
|
802 | - * Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'. |
|
803 | - * @type bool $short_ping Whether to output short pings. Default false. |
|
804 | - * @type bool $echo Whether to echo the output or return it. Default true. |
|
805 | - * } |
|
806 | - * @param int $depth Depth of comment. |
|
807 | - */ |
|
808 | - function geodir_comment($comment, $args, $depth) |
|
809 | - { |
|
810 | - $GLOBALS['comment'] = $comment; |
|
811 | - switch ($comment->comment_type) : |
|
812 | - case 'pingback' : |
|
813 | - case 'trackback' : |
|
814 | - // Display trackbacks differently than normal comments. |
|
815 | - ?> |
|
779 | + /** |
|
780 | + * Comment HTML markup. |
|
781 | + * |
|
782 | + * @since 1.0.0 |
|
783 | + * @package GeoDirectory |
|
784 | + * @global object $post The current post object. |
|
785 | + * @param object $comment The comment object. |
|
786 | + * @param string|array $args { |
|
787 | + * Optional. Formatting options. |
|
788 | + * |
|
789 | + * @type object $walker Instance of a Walker class to list comments. Default null. |
|
790 | + * @type int $max_depth The maximum comments depth. Default empty. |
|
791 | + * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'. |
|
792 | + * @type string $callback Callback function to use. Default null. |
|
793 | + * @type string $end-callback Callback function to use at the end. Default null. |
|
794 | + * @type string $type Type of comments to list. |
|
795 | + * Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'. |
|
796 | + * @type int $page Page ID to list comments for. Default empty. |
|
797 | + * @type int $per_page Number of comments to list per page. Default empty. |
|
798 | + * @type int $avatar_size Height and width dimensions of the avatar size. Default 32. |
|
799 | + * @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'. |
|
800 | + * @type bool $reverse_children Whether to reverse child comments in the list. Default null. |
|
801 | + * @type string $format How to format the comments list. |
|
802 | + * Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'. |
|
803 | + * @type bool $short_ping Whether to output short pings. Default false. |
|
804 | + * @type bool $echo Whether to echo the output or return it. Default true. |
|
805 | + * } |
|
806 | + * @param int $depth Depth of comment. |
|
807 | + */ |
|
808 | + function geodir_comment($comment, $args, $depth) |
|
809 | + { |
|
810 | + $GLOBALS['comment'] = $comment; |
|
811 | + switch ($comment->comment_type) : |
|
812 | + case 'pingback' : |
|
813 | + case 'trackback' : |
|
814 | + // Display trackbacks differently than normal comments. |
|
815 | + ?> |
|
816 | 816 | <li <?php comment_class('geodir-comment'); ?> id="comment-<?php comment_ID(); ?>"> |
817 | 817 | <p><?php _e('Pingback:', 'geodirectory'); ?> <?php comment_author_link(); ?> <?php edit_comment_link(__('(Edit)', 'geodirectory'), '<span class="edit-link">', '</span>'); ?></p> |
818 | 818 | <?php |
819 | - break; |
|
820 | - default : |
|
821 | - // Proceed with normal comments. |
|
822 | - global $post; |
|
823 | - ?> |
|
819 | + break; |
|
820 | + default : |
|
821 | + // Proceed with normal comments. |
|
822 | + global $post; |
|
823 | + ?> |
|
824 | 824 | <li <?php comment_class('geodir-comment'); ?> id="li-comment-<?php comment_ID(); ?>"> |
825 | 825 | <article id="comment-<?php comment_ID(); ?>" class="comment"> |
826 | 826 | <header class="comment-meta comment-author vcard"> |
827 | 827 | <?php |
828 | - /** |
|
829 | - * Filter to modify comment avatar size |
|
830 | - * |
|
831 | - * You can use this filter to change comment avatar size. |
|
832 | - * |
|
833 | - * @since 1.0.0 |
|
834 | - * @package GeoDirectory |
|
835 | - */ |
|
836 | - $avatar_size = apply_filters('geodir_comment_avatar_size', 44); |
|
837 | - echo get_avatar($comment, $avatar_size); |
|
838 | - printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>', |
|
839 | - get_comment_author_link(), |
|
840 | - // If current post author is also comment author, make it known visually. |
|
841 | - ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : '' |
|
842 | - ); |
|
843 | - echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>"; |
|
844 | - printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>', |
|
845 | - esc_url(get_comment_link($comment->comment_ID)), |
|
846 | - get_comment_time('c'), |
|
847 | - /* translators: 1: date, 2: time */ |
|
848 | - sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time()) |
|
849 | - ); |
|
850 | - ?> |
|
828 | + /** |
|
829 | + * Filter to modify comment avatar size |
|
830 | + * |
|
831 | + * You can use this filter to change comment avatar size. |
|
832 | + * |
|
833 | + * @since 1.0.0 |
|
834 | + * @package GeoDirectory |
|
835 | + */ |
|
836 | + $avatar_size = apply_filters('geodir_comment_avatar_size', 44); |
|
837 | + echo get_avatar($comment, $avatar_size); |
|
838 | + printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>', |
|
839 | + get_comment_author_link(), |
|
840 | + // If current post author is also comment author, make it known visually. |
|
841 | + ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : '' |
|
842 | + ); |
|
843 | + echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>"; |
|
844 | + printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>', |
|
845 | + esc_url(get_comment_link($comment->comment_ID)), |
|
846 | + get_comment_time('c'), |
|
847 | + /* translators: 1: date, 2: time */ |
|
848 | + sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time()) |
|
849 | + ); |
|
850 | + ?> |
|
851 | 851 | </header> |
852 | 852 | <!-- .comment-meta --> |
853 | 853 | |
@@ -871,47 +871,47 @@ discard block |
||
871 | 871 | </article> |
872 | 872 | <!-- #comment-## --> |
873 | 873 | <?php |
874 | - break; |
|
875 | - endswitch; // end comment_type check |
|
876 | - } |
|
874 | + break; |
|
875 | + endswitch; // end comment_type check |
|
876 | + } |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | |
880 | 880 | add_filter('get_comments_number', 'geodir_fix_comment_count', 10, 2); |
881 | 881 | if (!function_exists('geodir_fix_comment_count')) { |
882 | - /** |
|
883 | - * Fix comment count by not listing replies as reviews |
|
884 | - * |
|
885 | - * @since 1.0.0 |
|
886 | - * @package GeoDirectory |
|
887 | - * @global object $post The current post object. |
|
888 | - * @param int $count The comment count. |
|
889 | - * @param int $post_id The post ID. |
|
890 | - * @todo $post is unreachable since the function return the count before that variable. |
|
891 | - * @return bool|null|string The comment count. |
|
892 | - */ |
|
893 | - function geodir_fix_comment_count($count, $post_id) |
|
894 | - { |
|
895 | - if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) { |
|
896 | - global $post; |
|
897 | - $post_types = geodir_get_posttypes(); |
|
898 | - |
|
899 | - if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) { |
|
900 | - $review_count = geodir_get_review_count_total($post_id); |
|
901 | - return $review_count; |
|
902 | - |
|
903 | - if ($post && isset($post->rating_count)) { |
|
904 | - return $post->rating_count; |
|
905 | - } else { |
|
906 | - return geodir_get_comments_number($post_id); |
|
907 | - } |
|
908 | - } else { |
|
909 | - return $count; |
|
910 | - } |
|
911 | - } else { |
|
912 | - return $count; |
|
913 | - } |
|
914 | - } |
|
882 | + /** |
|
883 | + * Fix comment count by not listing replies as reviews |
|
884 | + * |
|
885 | + * @since 1.0.0 |
|
886 | + * @package GeoDirectory |
|
887 | + * @global object $post The current post object. |
|
888 | + * @param int $count The comment count. |
|
889 | + * @param int $post_id The post ID. |
|
890 | + * @todo $post is unreachable since the function return the count before that variable. |
|
891 | + * @return bool|null|string The comment count. |
|
892 | + */ |
|
893 | + function geodir_fix_comment_count($count, $post_id) |
|
894 | + { |
|
895 | + if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) { |
|
896 | + global $post; |
|
897 | + $post_types = geodir_get_posttypes(); |
|
898 | + |
|
899 | + if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) { |
|
900 | + $review_count = geodir_get_review_count_total($post_id); |
|
901 | + return $review_count; |
|
902 | + |
|
903 | + if ($post && isset($post->rating_count)) { |
|
904 | + return $post->rating_count; |
|
905 | + } else { |
|
906 | + return geodir_get_comments_number($post_id); |
|
907 | + } |
|
908 | + } else { |
|
909 | + return $count; |
|
910 | + } |
|
911 | + } else { |
|
912 | + return $count; |
|
913 | + } |
|
914 | + } |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | /** |
@@ -929,14 +929,14 @@ discard block |
||
929 | 929 | */ |
930 | 930 | function geodir_get_rating_stars($rating, $post_id, $small = false) |
931 | 931 | { |
932 | - if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) { |
|
933 | - return NULL; |
|
934 | - } |
|
935 | - $a_rating = $rating / 5 * 100; |
|
936 | - |
|
937 | - if ($small) { |
|
938 | - $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>'; |
|
939 | - } else { |
|
932 | + if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) { |
|
933 | + return NULL; |
|
934 | + } |
|
935 | + $a_rating = $rating / 5 * 100; |
|
936 | + |
|
937 | + if ($small) { |
|
938 | + $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>'; |
|
939 | + } else { |
|
940 | 940 | if (function_exists('geodir_reviewrating_draw_overall_rating')) { |
941 | 941 | // Show rating stars from review rating manager |
942 | 942 | $r_html = geodir_reviewrating_draw_overall_rating($rating); |
@@ -953,8 +953,8 @@ discard block |
||
953 | 953 | } |
954 | 954 | $r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>'; |
955 | 955 | } |
956 | - } |
|
957 | - return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5); |
|
956 | + } |
|
957 | + return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5); |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | /** |
@@ -968,23 +968,23 @@ discard block |
||
968 | 968 | function geodir_is_reviews_show($pageview = '') |
969 | 969 | { |
970 | 970 | |
971 | - $active_tabs = get_option('geodir_detail_page_tabs_excluded'); |
|
972 | - |
|
973 | - $is_display = true; |
|
974 | - if (!empty($active_tabs) && in_array('reviews', $active_tabs)) |
|
975 | - $is_display = false; |
|
976 | - |
|
977 | - /** |
|
978 | - * Filter to change display value. |
|
979 | - * |
|
980 | - * You can use this filter to change the is_display value. |
|
981 | - * |
|
982 | - * @since 1.0.0 |
|
983 | - * @package GeoDirectory |
|
984 | - * @param bool $is_display Display ratings when set to true. |
|
985 | - * @param string $pageview The view template. Ex: listview, gridview etc. |
|
986 | - */ |
|
987 | - return apply_filters('geodir_is_reviews_show', $is_display, $pageview); |
|
971 | + $active_tabs = get_option('geodir_detail_page_tabs_excluded'); |
|
972 | + |
|
973 | + $is_display = true; |
|
974 | + if (!empty($active_tabs) && in_array('reviews', $active_tabs)) |
|
975 | + $is_display = false; |
|
976 | + |
|
977 | + /** |
|
978 | + * Filter to change display value. |
|
979 | + * |
|
980 | + * You can use this filter to change the is_display value. |
|
981 | + * |
|
982 | + * @since 1.0.0 |
|
983 | + * @package GeoDirectory |
|
984 | + * @param bool $is_display Display ratings when set to true. |
|
985 | + * @param string $pageview The view template. Ex: listview, gridview etc. |
|
986 | + */ |
|
987 | + return apply_filters('geodir_is_reviews_show', $is_display, $pageview); |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | |
@@ -992,9 +992,9 @@ discard block |
||
992 | 992 | * If Disqus plugin is active, do some fixes to show on blogs but no on GD post types |
993 | 993 | */ |
994 | 994 | if(function_exists('dsq_can_replace')) { |
995 | - remove_filter('comments_template', 'dsq_comments_template'); |
|
996 | - add_filter('comments_template', 'dsq_comments_template', 100); |
|
997 | - add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1); |
|
995 | + remove_filter('comments_template', 'dsq_comments_template'); |
|
996 | + add_filter('comments_template', 'dsq_comments_template', 100); |
|
997 | + add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1); |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | |
@@ -1008,14 +1008,14 @@ discard block |
||
1008 | 1008 | * @return string `1` if active `0` if disabled. |
1009 | 1009 | */ |
1010 | 1010 | function geodir_option_disqus_active($disqus_active){ |
1011 | - global $post; |
|
1012 | - $all_postypes = geodir_get_posttypes(); |
|
1011 | + global $post; |
|
1012 | + $all_postypes = geodir_get_posttypes(); |
|
1013 | 1013 | |
1014 | - if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){ |
|
1015 | - $disqus_active = '0'; |
|
1016 | - } |
|
1014 | + if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){ |
|
1015 | + $disqus_active = '0'; |
|
1016 | + } |
|
1017 | 1017 | |
1018 | - return $disqus_active; |
|
1018 | + return $disqus_active; |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | /** |
@@ -1029,23 +1029,23 @@ discard block |
||
1029 | 1029 | * @return array Modified tabs array. |
1030 | 1030 | */ |
1031 | 1031 | function geodir_detail_reviews_tab_title($tabs_arr) { |
1032 | - $post_type = geodir_get_current_posttype(); |
|
1032 | + $post_type = geodir_get_current_posttype(); |
|
1033 | 1033 | |
1034 | - if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) { |
|
1035 | - $label_reviews = __('Comments', 'geodirectory'); |
|
1034 | + if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) { |
|
1035 | + $label_reviews = __('Comments', 'geodirectory'); |
|
1036 | 1036 | |
1037 | - if (defined('GEODIR_CP_VERSION')) { |
|
1038 | - $post_types = geodir_get_posttypes('array'); |
|
1037 | + if (defined('GEODIR_CP_VERSION')) { |
|
1038 | + $post_types = geodir_get_posttypes('array'); |
|
1039 | 1039 | |
1040 | - if (!empty($post_types[$post_type]['labels']['label_reviews'])) { |
|
1041 | - $label_reviews = stripslashes(__($post_types[$post_type]['labels']['label_reviews'], 'geodirectory')); |
|
1042 | - } |
|
1043 | - } |
|
1040 | + if (!empty($post_types[$post_type]['labels']['label_reviews'])) { |
|
1041 | + $label_reviews = stripslashes(__($post_types[$post_type]['labels']['label_reviews'], 'geodirectory')); |
|
1042 | + } |
|
1043 | + } |
|
1044 | 1044 | |
1045 | - $tabs_arr['reviews']['heading_text'] = $label_reviews; |
|
1046 | - } |
|
1045 | + $tabs_arr['reviews']['heading_text'] = $label_reviews; |
|
1046 | + } |
|
1047 | 1047 | |
1048 | - return $tabs_arr; |
|
1048 | + return $tabs_arr; |
|
1049 | 1049 | } |
1050 | 1050 | add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_reviews_tab_title', 1000, 1); |
1051 | 1051 | |
@@ -1056,13 +1056,13 @@ discard block |
||
1056 | 1056 | * @since 1.6.21 |
1057 | 1057 | */ |
1058 | 1058 | function geodir_jetpack_disable_comments(){ |
1059 | - //only run if jetpack installed |
|
1060 | - if(defined('JETPACK__VERSION')){ |
|
1061 | - $post_types = geodir_get_posttypes(); |
|
1062 | - foreach($post_types as $post_type){ |
|
1063 | - add_filter('jetpack_comment_form_enabled_for_' . $post_type, '__return_false'); |
|
1064 | - } |
|
1065 | - } |
|
1059 | + //only run if jetpack installed |
|
1060 | + if(defined('JETPACK__VERSION')){ |
|
1061 | + $post_types = geodir_get_posttypes(); |
|
1062 | + foreach($post_types as $post_type){ |
|
1063 | + add_filter('jetpack_comment_form_enabled_for_' . $post_type, '__return_false'); |
|
1064 | + } |
|
1065 | + } |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | add_action('plugins_loaded','geodir_jetpack_disable_comments'); |
@@ -1077,13 +1077,13 @@ discard block |
||
1077 | 1077 | * @return bool True if allowed otherwise False. |
1078 | 1078 | */ |
1079 | 1079 | function geodir_check_reviews_open( $open, $post_id ) { |
1080 | - if ( $open && $post_id && geodir_is_page( 'detail' ) ) { |
|
1081 | - if ( in_array( get_post_status( $post_id ), array( 'draft', 'pending', 'auto-draft', 'trash' ) ) ) { |
|
1082 | - $open = false; |
|
1083 | - } |
|
1084 | - } |
|
1080 | + if ( $open && $post_id && geodir_is_page( 'detail' ) ) { |
|
1081 | + if ( in_array( get_post_status( $post_id ), array( 'draft', 'pending', 'auto-draft', 'trash' ) ) ) { |
|
1082 | + $open = false; |
|
1083 | + } |
|
1084 | + } |
|
1085 | 1085 | |
1086 | - return $open; |
|
1086 | + return $open; |
|
1087 | 1087 | } |
1088 | 1088 | add_filter( 'comments_open', 'geodir_check_reviews_open', 10, 2 ); |
1089 | 1089 | |
@@ -1098,10 +1098,10 @@ discard block |
||
1098 | 1098 | * @return string Filtered comment content. |
1099 | 1099 | */ |
1100 | 1100 | function geodir_remove_img_tags_from_comment( $comment_text, $comment = array(), $args = array() ) { |
1101 | - if ( !empty( $comment_text ) && !empty( $comment ) && strpos( $comment_text, '[img' ) !== false && strpos( get_post_type( $comment->comment_post_ID ), 'gd_' ) === 0 ) { |
|
1102 | - $comment_text = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_text ); |
|
1103 | - $comment_text = trim( $comment_text ); |
|
1104 | - } |
|
1105 | - return $comment_text; |
|
1101 | + if ( !empty( $comment_text ) && !empty( $comment ) && strpos( $comment_text, '[img' ) !== false && strpos( get_post_type( $comment->comment_post_ID ), 'gd_' ) === 0 ) { |
|
1102 | + $comment_text = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_text ); |
|
1103 | + $comment_text = trim( $comment_text ); |
|
1104 | + } |
|
1105 | + return $comment_text; |
|
1106 | 1106 | } |
1107 | 1107 | add_filter( 'comment_text', 'geodir_remove_img_tags_from_comment', 10, 3 ); |
1108 | 1108 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | // If this file is called directly, abort. |
11 | 11 | if (!defined('WPINC')) { |
12 | - die; |
|
12 | + die; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
@@ -22,22 +22,22 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function gdsc_validate_measurements($value) |
24 | 24 | { |
25 | - if ((strlen($value) - 1) == strpos(trim($value), '%')) { |
|
26 | - // $value is entered as a percent, so it can't be less than 0 or more than 100 |
|
27 | - $value = preg_replace('/\D/', '', $value); |
|
28 | - if (100 < $value) { |
|
29 | - $value = 100; |
|
30 | - } |
|
31 | - // Re-add the percent symbol |
|
32 | - $value = $value . '%'; |
|
33 | - } elseif ((strlen($value) - 2) == strpos(trim($value), 'px')) { |
|
34 | - // Get the absint & re-add the 'px' |
|
35 | - $value = preg_replace('/\D/', '', $value) . 'px'; |
|
36 | - } else { |
|
37 | - $value = preg_replace('/\D/', '', $value); |
|
38 | - } |
|
25 | + if ((strlen($value) - 1) == strpos(trim($value), '%')) { |
|
26 | + // $value is entered as a percent, so it can't be less than 0 or more than 100 |
|
27 | + $value = preg_replace('/\D/', '', $value); |
|
28 | + if (100 < $value) { |
|
29 | + $value = 100; |
|
30 | + } |
|
31 | + // Re-add the percent symbol |
|
32 | + $value = $value . '%'; |
|
33 | + } elseif ((strlen($value) - 2) == strpos(trim($value), 'px')) { |
|
34 | + // Get the absint & re-add the 'px' |
|
35 | + $value = preg_replace('/\D/', '', $value) . 'px'; |
|
36 | + } else { |
|
37 | + $value = preg_replace('/\D/', '', $value); |
|
38 | + } |
|
39 | 39 | |
40 | - return $value; |
|
40 | + return $value; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -52,35 +52,35 @@ discard block |
||
52 | 52 | function gdsc_validate_map_args($params) |
53 | 53 | { |
54 | 54 | |
55 | - $params['width'] = gdsc_validate_measurements($params['width']); |
|
56 | - $params['height'] = gdsc_validate_measurements($params['height']); |
|
55 | + $params['width'] = gdsc_validate_measurements($params['width']); |
|
56 | + $params['height'] = gdsc_validate_measurements($params['height']); |
|
57 | 57 | |
58 | - // Only accept our 4 maptypes. Otherwise, revert to the default. |
|
59 | - if (!(in_array(geodir_strtoupper($params['maptype']), array('HYBRID', 'SATELLITE', 'ROADMAP', 'TERRAIN')))) { |
|
60 | - $params['maptype'] = 'ROADMAP'; |
|
61 | - } else { |
|
62 | - $params['maptype'] = geodir_strtoupper($params['maptype']); |
|
63 | - } |
|
58 | + // Only accept our 4 maptypes. Otherwise, revert to the default. |
|
59 | + if (!(in_array(geodir_strtoupper($params['maptype']), array('HYBRID', 'SATELLITE', 'ROADMAP', 'TERRAIN')))) { |
|
60 | + $params['maptype'] = 'ROADMAP'; |
|
61 | + } else { |
|
62 | + $params['maptype'] = geodir_strtoupper($params['maptype']); |
|
63 | + } |
|
64 | 64 | |
65 | - // Zoom accepts a value between 1 and 19 |
|
66 | - $params['zoom'] = absint($params['zoom']); |
|
67 | - if (19 < $params['zoom']) { |
|
68 | - $params['zoom'] = '19'; |
|
69 | - } |
|
70 | - if (0 == $params['zoom']) { |
|
71 | - $params['zoom'] = '1'; |
|
72 | - } |
|
65 | + // Zoom accepts a value between 1 and 19 |
|
66 | + $params['zoom'] = absint($params['zoom']); |
|
67 | + if (19 < $params['zoom']) { |
|
68 | + $params['zoom'] = '19'; |
|
69 | + } |
|
70 | + if (0 == $params['zoom']) { |
|
71 | + $params['zoom'] = '1'; |
|
72 | + } |
|
73 | 73 | |
74 | - // Child_collapse must be boolean |
|
75 | - $params['child_collapse'] = gdsc_to_bool_val($params['child_collapse']); |
|
74 | + // Child_collapse must be boolean |
|
75 | + $params['child_collapse'] = gdsc_to_bool_val($params['child_collapse']); |
|
76 | 76 | |
77 | - // Scrollwheel must be boolean |
|
78 | - $params['scrollwheel'] = gdsc_to_bool_val($params['scrollwheel']); |
|
77 | + // Scrollwheel must be boolean |
|
78 | + $params['scrollwheel'] = gdsc_to_bool_val($params['scrollwheel']); |
|
79 | 79 | |
80 | - // Scrollwheel must be boolean |
|
81 | - $params['autozoom'] = gdsc_to_bool_val($params['autozoom']); |
|
80 | + // Scrollwheel must be boolean |
|
81 | + $params['autozoom'] = gdsc_to_bool_val($params['autozoom']); |
|
82 | 82 | |
83 | - return $params; |
|
83 | + return $params; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -99,52 +99,52 @@ discard block |
||
99 | 99 | */ |
100 | 100 | function gdsc_to_bool_val($in, $strict = false) |
101 | 101 | { |
102 | - $out = null; |
|
103 | - |
|
104 | - // if not strict, we only have to check if something is false |
|
105 | - if (in_array($in, array( |
|
106 | - 'false', |
|
107 | - 'False', |
|
108 | - 'FALSE', |
|
109 | - 'no', |
|
110 | - 'No', |
|
111 | - 'n', |
|
112 | - 'N', |
|
113 | - '0', |
|
114 | - 'off', |
|
115 | - 'Off', |
|
116 | - 'OFF', |
|
117 | - false, |
|
118 | - 0, |
|
119 | - null |
|
120 | - ), true)) { |
|
121 | - $out = false; |
|
122 | - } else if ($strict) { |
|
123 | - // if strict, check the equivalent true values |
|
124 | - if (in_array($in, array( |
|
125 | - 'true', |
|
126 | - 'True', |
|
127 | - 'TRUE', |
|
128 | - 'yes', |
|
129 | - 'Yes', |
|
130 | - 'y', |
|
131 | - 'Y', |
|
132 | - '1', |
|
133 | - 'on', |
|
134 | - 'On', |
|
135 | - 'ON', |
|
136 | - true, |
|
137 | - 1 |
|
138 | - ), true)) { |
|
139 | - $out = true; |
|
140 | - } |
|
141 | - } else { |
|
142 | - // not strict? let the regular php bool check figure it out (will |
|
143 | - // largely default to true) |
|
144 | - $out = ($in ? true : false); |
|
145 | - } |
|
102 | + $out = null; |
|
103 | + |
|
104 | + // if not strict, we only have to check if something is false |
|
105 | + if (in_array($in, array( |
|
106 | + 'false', |
|
107 | + 'False', |
|
108 | + 'FALSE', |
|
109 | + 'no', |
|
110 | + 'No', |
|
111 | + 'n', |
|
112 | + 'N', |
|
113 | + '0', |
|
114 | + 'off', |
|
115 | + 'Off', |
|
116 | + 'OFF', |
|
117 | + false, |
|
118 | + 0, |
|
119 | + null |
|
120 | + ), true)) { |
|
121 | + $out = false; |
|
122 | + } else if ($strict) { |
|
123 | + // if strict, check the equivalent true values |
|
124 | + if (in_array($in, array( |
|
125 | + 'true', |
|
126 | + 'True', |
|
127 | + 'TRUE', |
|
128 | + 'yes', |
|
129 | + 'Yes', |
|
130 | + 'y', |
|
131 | + 'Y', |
|
132 | + '1', |
|
133 | + 'on', |
|
134 | + 'On', |
|
135 | + 'ON', |
|
136 | + true, |
|
137 | + 1 |
|
138 | + ), true)) { |
|
139 | + $out = true; |
|
140 | + } |
|
141 | + } else { |
|
142 | + // not strict? let the regular php bool check figure it out (will |
|
143 | + // largely default to true) |
|
144 | + $out = ($in ? true : false); |
|
145 | + } |
|
146 | 146 | |
147 | - return $out; |
|
147 | + return $out; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function gdsc_is_post_type_valid($incoming_post_type) |
159 | 159 | { |
160 | - $post_types = geodir_get_posttypes(); |
|
161 | - $post_types = array_map('geodir_strtolower', $post_types); |
|
162 | - $post_type_found = false; |
|
163 | - foreach ($post_types as $type) { |
|
164 | - if (geodir_strtolower($incoming_post_type) == geodir_strtolower($type)) { |
|
165 | - $post_type_found = true; |
|
166 | - } |
|
167 | - } |
|
160 | + $post_types = geodir_get_posttypes(); |
|
161 | + $post_types = array_map('geodir_strtolower', $post_types); |
|
162 | + $post_type_found = false; |
|
163 | + foreach ($post_types as $type) { |
|
164 | + if (geodir_strtolower($incoming_post_type) == geodir_strtolower($type)) { |
|
165 | + $post_type_found = true; |
|
166 | + } |
|
167 | + } |
|
168 | 168 | |
169 | - return $post_type_found; |
|
169 | + return $post_type_found; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -186,52 +186,52 @@ discard block |
||
186 | 186 | */ |
187 | 187 | function gdsc_listing_loop_filter($query) |
188 | 188 | { |
189 | - global $wp_query, $geodir_post_type, $table, $plugin_prefix, $term; |
|
190 | - |
|
191 | - $geodir_post_type = geodir_get_current_posttype(); |
|
192 | - |
|
193 | - if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) { |
|
194 | - $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy'); |
|
195 | - |
|
196 | - if (isset($wp_query->query[$taxonomies[0]])) { |
|
197 | - $request_term = explode("/", $wp_query->query[$taxonomies[0]]); |
|
198 | - $request_term = end($request_term); |
|
199 | - if (!term_exists($request_term)) { |
|
200 | - $args = array('number' => '1',); |
|
201 | - $terms_arr = get_terms($taxonomies[0], $args); |
|
202 | - foreach ($terms_arr as $location_term) { |
|
203 | - $term_arr = $location_term; |
|
204 | - $term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term)); |
|
205 | - } |
|
206 | - $wp_query->queried_object_id = 1; |
|
207 | - $wp_query->queried_object = $term_arr; |
|
208 | - } |
|
209 | - } |
|
189 | + global $wp_query, $geodir_post_type, $table, $plugin_prefix, $term; |
|
190 | + |
|
191 | + $geodir_post_type = geodir_get_current_posttype(); |
|
192 | + |
|
193 | + if (isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries) { |
|
194 | + $taxonomies = wp_list_pluck($wp_query->tax_query->queries, 'taxonomy'); |
|
195 | + |
|
196 | + if (isset($wp_query->query[$taxonomies[0]])) { |
|
197 | + $request_term = explode("/", $wp_query->query[$taxonomies[0]]); |
|
198 | + $request_term = end($request_term); |
|
199 | + if (!term_exists($request_term)) { |
|
200 | + $args = array('number' => '1',); |
|
201 | + $terms_arr = get_terms($taxonomies[0], $args); |
|
202 | + foreach ($terms_arr as $location_term) { |
|
203 | + $term_arr = $location_term; |
|
204 | + $term_arr->name = geodir_ucwords(str_replace('-', ' ', $request_term)); |
|
205 | + } |
|
206 | + $wp_query->queried_object_id = 1; |
|
207 | + $wp_query->queried_object = $term_arr; |
|
208 | + } |
|
209 | + } |
|
210 | 210 | |
211 | - } |
|
212 | - if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) { |
|
211 | + } |
|
212 | + if (isset($query->query_vars['is_geodir_loop']) && $query->query_vars['is_geodir_loop']) { |
|
213 | 213 | |
214 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
214 | + $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
215 | 215 | |
216 | - add_filter('posts_fields', 'geodir_posts_fields', 1); |
|
217 | - add_filter('posts_join', 'geodir_posts_join', 1); |
|
218 | - geodir_post_where(); |
|
219 | - if (!is_admin()) { |
|
220 | - add_filter('posts_orderby', 'geodir_posts_orderby', 1); |
|
221 | - } |
|
216 | + add_filter('posts_fields', 'geodir_posts_fields', 1); |
|
217 | + add_filter('posts_join', 'geodir_posts_join', 1); |
|
218 | + geodir_post_where(); |
|
219 | + if (!is_admin()) { |
|
220 | + add_filter('posts_orderby', 'geodir_posts_orderby', 1); |
|
221 | + } |
|
222 | 222 | |
223 | - // advanced filter for popular post view widget |
|
224 | - global $wp_query; |
|
225 | - if (!is_admin()) { |
|
226 | - if (!empty($wp_query->query['with_pics_only'])) { |
|
227 | - add_filter('posts_join', 'geodir_filter_widget_join', 1000); |
|
228 | - } |
|
229 | - add_filter('posts_where', 'geodir_filter_widget_where', 1000); |
|
230 | - } |
|
223 | + // advanced filter for popular post view widget |
|
224 | + global $wp_query; |
|
225 | + if (!is_admin()) { |
|
226 | + if (!empty($wp_query->query['with_pics_only'])) { |
|
227 | + add_filter('posts_join', 'geodir_filter_widget_join', 1000); |
|
228 | + } |
|
229 | + add_filter('posts_where', 'geodir_filter_widget_where', 1000); |
|
230 | + } |
|
231 | 231 | |
232 | - } |
|
232 | + } |
|
233 | 233 | |
234 | - return $query; |
|
234 | + return $query; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -245,40 +245,40 @@ discard block |
||
245 | 245 | */ |
246 | 246 | function gdsc_manage_category_choice($post_type, $category) |
247 | 247 | { |
248 | - if (0 == $category || '' == $category) { |
|
249 | - return ''; |
|
250 | - } |
|
248 | + if (0 == $category || '' == $category) { |
|
249 | + return ''; |
|
250 | + } |
|
251 | 251 | |
252 | - if (!(gdsc_is_post_type_valid($post_type))) { |
|
253 | - return ''; |
|
254 | - } |
|
252 | + if (!(gdsc_is_post_type_valid($post_type))) { |
|
253 | + return ''; |
|
254 | + } |
|
255 | 255 | |
256 | - $taxonomies = geodir_get_taxonomies($post_type); |
|
256 | + $taxonomies = geodir_get_taxonomies($post_type); |
|
257 | 257 | |
258 | - $categories = get_terms(array('taxonomy' => $taxonomies[0],'hide_empty' => false)); |
|
258 | + $categories = get_terms(array('taxonomy' => $taxonomies[0],'hide_empty' => false)); |
|
259 | 259 | |
260 | - $cat_id = 0; |
|
260 | + $cat_id = 0; |
|
261 | 261 | |
262 | - foreach ($categories as $cat) { |
|
263 | - if (is_numeric($category)) { |
|
264 | - if (absint($category) == $cat->term_id) { |
|
265 | - $cat_id = $cat->term_id; |
|
266 | - break; |
|
267 | - } |
|
268 | - } else { |
|
269 | - if ($category == $cat->slug) { |
|
270 | - $cat_id = $cat->term_id; |
|
271 | - break; |
|
272 | - } |
|
262 | + foreach ($categories as $cat) { |
|
263 | + if (is_numeric($category)) { |
|
264 | + if (absint($category) == $cat->term_id) { |
|
265 | + $cat_id = $cat->term_id; |
|
266 | + break; |
|
267 | + } |
|
268 | + } else { |
|
269 | + if ($category == $cat->slug) { |
|
270 | + $cat_id = $cat->term_id; |
|
271 | + break; |
|
272 | + } |
|
273 | 273 | |
274 | - if ($category == $cat->name) { |
|
275 | - $cat_id = $cat->term_id; |
|
276 | - break; |
|
277 | - } |
|
278 | - } |
|
279 | - } |
|
274 | + if ($category == $cat->name) { |
|
275 | + $cat_id = $cat->term_id; |
|
276 | + break; |
|
277 | + } |
|
278 | + } |
|
279 | + } |
|
280 | 280 | |
281 | - return $cat_id; |
|
281 | + return $cat_id; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | // @todo: Extract this |
@@ -288,11 +288,11 @@ discard block |
||
288 | 288 | * Adds the script in the page footer for the home page google map. |
289 | 289 | * |
290 | 290 | * @since 1.0.0 |
291 | - * @return string Print the script in page footer. |
|
291 | + * @return string Print the script in page footer. |
|
292 | 292 | */ |
293 | 293 | function geodir_home_map_add_script() |
294 | - { |
|
295 | - ?> |
|
294 | + { |
|
295 | + ?> |
|
296 | 296 | <script type="text/javascript"> |
297 | 297 | jQuery(document).ready(function () { |
298 | 298 | geoDirMapSlide(); |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | } |
366 | 366 | </script> |
367 | 367 | <?php |
368 | - } |
|
368 | + } |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | function geodir_popular_category_add_scripts() |
378 | 378 | { |
379 | - ?> |
|
379 | + ?> |
|
380 | 380 | <script type="text/javascript"> |
381 | 381 | jQuery(function ($) { |
382 | 382 | $('.geodir-showcat').click(function () { |
@@ -406,56 +406,56 @@ discard block |
||
406 | 406 | */ |
407 | 407 | function gdsc_validate_layout_choice($layout_choice) |
408 | 408 | { |
409 | - switch (geodir_strtolower($layout_choice)) { |
|
410 | - case 'list'; |
|
411 | - case 'one'; |
|
412 | - case 'one_column'; |
|
413 | - case 'onecolumn'; |
|
414 | - case '1'; |
|
415 | - $layout_choice = 'list'; |
|
416 | - break; |
|
417 | - case 'gridview_onehalf'; |
|
418 | - case 'two'; |
|
419 | - case 'two_column'; |
|
420 | - case 'two_columns'; |
|
421 | - case 'twocolumn'; |
|
422 | - case 'twocolumns'; |
|
423 | - case '2'; |
|
424 | - $layout_choice = 'gridview_onehalf'; |
|
425 | - break; |
|
426 | - case 'gridview_onethird'; |
|
427 | - case 'three'; |
|
428 | - case 'three_column'; |
|
429 | - case 'three_columns'; |
|
430 | - case 'threecolumn'; |
|
431 | - case 'threecolumns'; |
|
432 | - case '3'; |
|
433 | - $layout_choice = 'gridview_onethird'; |
|
434 | - break; |
|
435 | - case 'gridview_onefourth'; |
|
436 | - case 'four'; |
|
437 | - case 'four_column'; |
|
438 | - case 'four_columns'; |
|
439 | - case 'fourcolumn'; |
|
440 | - case 'fourcolumns'; |
|
441 | - case '4'; |
|
442 | - $layout_choice = 'gridview_onefourth'; |
|
443 | - break; |
|
444 | - case 'gridview_onefifth'; |
|
445 | - case 'five'; |
|
446 | - case 'five_column'; |
|
447 | - case 'five_columns'; |
|
448 | - case 'fivecolumn'; |
|
449 | - case 'fivecolumns'; |
|
450 | - case '5'; |
|
451 | - $layout_choice = 'gridview_onefifth'; |
|
452 | - break; |
|
453 | - default: |
|
454 | - $layout_choice = 'gridview_onehalf'; |
|
455 | - break; |
|
456 | - } |
|
409 | + switch (geodir_strtolower($layout_choice)) { |
|
410 | + case 'list'; |
|
411 | + case 'one'; |
|
412 | + case 'one_column'; |
|
413 | + case 'onecolumn'; |
|
414 | + case '1'; |
|
415 | + $layout_choice = 'list'; |
|
416 | + break; |
|
417 | + case 'gridview_onehalf'; |
|
418 | + case 'two'; |
|
419 | + case 'two_column'; |
|
420 | + case 'two_columns'; |
|
421 | + case 'twocolumn'; |
|
422 | + case 'twocolumns'; |
|
423 | + case '2'; |
|
424 | + $layout_choice = 'gridview_onehalf'; |
|
425 | + break; |
|
426 | + case 'gridview_onethird'; |
|
427 | + case 'three'; |
|
428 | + case 'three_column'; |
|
429 | + case 'three_columns'; |
|
430 | + case 'threecolumn'; |
|
431 | + case 'threecolumns'; |
|
432 | + case '3'; |
|
433 | + $layout_choice = 'gridview_onethird'; |
|
434 | + break; |
|
435 | + case 'gridview_onefourth'; |
|
436 | + case 'four'; |
|
437 | + case 'four_column'; |
|
438 | + case 'four_columns'; |
|
439 | + case 'fourcolumn'; |
|
440 | + case 'fourcolumns'; |
|
441 | + case '4'; |
|
442 | + $layout_choice = 'gridview_onefourth'; |
|
443 | + break; |
|
444 | + case 'gridview_onefifth'; |
|
445 | + case 'five'; |
|
446 | + case 'five_column'; |
|
447 | + case 'five_columns'; |
|
448 | + case 'fivecolumn'; |
|
449 | + case 'fivecolumns'; |
|
450 | + case '5'; |
|
451 | + $layout_choice = 'gridview_onefifth'; |
|
452 | + break; |
|
453 | + default: |
|
454 | + $layout_choice = 'gridview_onehalf'; |
|
455 | + break; |
|
456 | + } |
|
457 | 457 | |
458 | - return $layout_choice; |
|
458 | + return $layout_choice; |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -472,34 +472,34 @@ discard block |
||
472 | 472 | */ |
473 | 473 | function gdsc_validate_sort_choice($sort_choice, $post_type = '') |
474 | 474 | { |
475 | - global $plugin_prefix; |
|
476 | - |
|
477 | - $sorts = array( |
|
478 | - 'az', |
|
479 | - 'latest', |
|
480 | - 'featured', |
|
481 | - 'high_review', |
|
482 | - 'high_rating', |
|
483 | - 'random', |
|
484 | - ); |
|
485 | - |
|
486 | - if (in_array($sort_choice, $sorts)) { |
|
487 | - return $sort_choice; |
|
488 | - } |
|
475 | + global $plugin_prefix; |
|
476 | + |
|
477 | + $sorts = array( |
|
478 | + 'az', |
|
479 | + 'latest', |
|
480 | + 'featured', |
|
481 | + 'high_review', |
|
482 | + 'high_rating', |
|
483 | + 'random', |
|
484 | + ); |
|
485 | + |
|
486 | + if (in_array($sort_choice, $sorts)) { |
|
487 | + return $sort_choice; |
|
488 | + } |
|
489 | 489 | |
490 | - if (!empty($post_type)) { |
|
491 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
490 | + if (!empty($post_type)) { |
|
491 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
492 | 492 | |
493 | - if (!geodir_prepare_custom_sorting($sort_choice, $table)) { |
|
494 | - $sort_choice = ''; |
|
495 | - } |
|
496 | - } |
|
493 | + if (!geodir_prepare_custom_sorting($sort_choice, $table)) { |
|
494 | + $sort_choice = ''; |
|
495 | + } |
|
496 | + } |
|
497 | 497 | |
498 | - if (empty($post_type) || empty($sort_choice)) { |
|
499 | - $sort_choice = 'latest'; |
|
500 | - } |
|
498 | + if (empty($post_type) || empty($sort_choice)) { |
|
499 | + $sort_choice = 'latest'; |
|
500 | + } |
|
501 | 501 | |
502 | - return $sort_choice; |
|
502 | + return $sort_choice; |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
@@ -512,22 +512,22 @@ discard block |
||
512 | 512 | */ |
513 | 513 | function gdsc_validate_listing_width($width_choice) |
514 | 514 | { |
515 | - if (!(empty($width_choice))) { |
|
516 | - $width_choice = absint($width_choice); |
|
517 | - } else { |
|
518 | - return ''; |
|
519 | - } |
|
515 | + if (!(empty($width_choice))) { |
|
516 | + $width_choice = absint($width_choice); |
|
517 | + } else { |
|
518 | + return ''; |
|
519 | + } |
|
520 | 520 | |
521 | - if (100 < $width_choice) { |
|
522 | - $width_choice = 100; |
|
523 | - } |
|
521 | + if (100 < $width_choice) { |
|
522 | + $width_choice = 100; |
|
523 | + } |
|
524 | 524 | |
525 | - // If listing_width is too narrow, it won't work, arbitrarily set to 10% here |
|
526 | - if (10 > $width_choice) { |
|
527 | - $width_choice = 10; |
|
528 | - } |
|
525 | + // If listing_width is too narrow, it won't work, arbitrarily set to 10% here |
|
526 | + if (10 > $width_choice) { |
|
527 | + $width_choice = 10; |
|
528 | + } |
|
529 | 529 | |
530 | - return $width_choice; |
|
530 | + return $width_choice; |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
@@ -540,18 +540,18 @@ discard block |
||
540 | 540 | */ |
541 | 541 | function gdsc_validate_list_filter_choice($filter_choice) |
542 | 542 | { |
543 | - $filters = array( |
|
544 | - 'all', |
|
545 | - 'today', |
|
546 | - 'upcoming', |
|
547 | - 'past', |
|
548 | - ); |
|
549 | - |
|
550 | - if (!(in_array($filter_choice, $filters))) { |
|
551 | - $filter_choice = 'all'; |
|
552 | - } |
|
543 | + $filters = array( |
|
544 | + 'all', |
|
545 | + 'today', |
|
546 | + 'upcoming', |
|
547 | + 'past', |
|
548 | + ); |
|
549 | + |
|
550 | + if (!(in_array($filter_choice, $filters))) { |
|
551 | + $filter_choice = 'all'; |
|
552 | + } |
|
553 | 553 | |
554 | - return $filter_choice; |
|
554 | + return $filter_choice; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * @return string Listings HTML content. |
575 | 575 | */ |
576 | 576 | function geodir_sc_gd_listings_output($args = array()) { |
577 | - $title = !empty($args['title']) ? __($args['title'], 'geodirectory') : ''; |
|
577 | + $title = !empty($args['title']) ? __($args['title'], 'geodirectory') : ''; |
|
578 | 578 | $post_type = !empty($args['post_type']) ? $args['post_type'] : 'gd_place'; |
579 | 579 | $category = !empty($args['category']) ? $args['category'] : '0'; |
580 | 580 | $post_number = !empty($args['post_number']) ? $args['post_number'] : 10; |
@@ -585,17 +585,17 @@ discard block |
||
585 | 585 | $listing_width = !empty($args['listing_width']) ? $args['listing_width'] : ''; |
586 | 586 | $with_pagination = !empty($args['with_pagination']) ? true : false; |
587 | 587 | $event_type = !empty($args['event_type']) ? $args['event_type'] : ''; |
588 | - $shortcode_content = !empty($args['shortcode_content']) ? trim($args['shortcode_content']) : ''; |
|
589 | - $tags = !empty($args['tags']) ? $args['tags'] : array(); |
|
590 | - /** |
|
591 | - * Filter the content text displayed when no listings found. |
|
592 | - * |
|
593 | - * @since 1.6.0 |
|
594 | - * |
|
595 | - * @param string $shortcode_content The shortcode content text. |
|
596 | - * @param array $args Array of arguements to filter listings. |
|
597 | - */ |
|
598 | - $shortcode_content = apply_filters('geodir_sc_gd_listings_not_found_content', $shortcode_content, $args); |
|
588 | + $shortcode_content = !empty($args['shortcode_content']) ? trim($args['shortcode_content']) : ''; |
|
589 | + $tags = !empty($args['tags']) ? $args['tags'] : array(); |
|
590 | + /** |
|
591 | + * Filter the content text displayed when no listings found. |
|
592 | + * |
|
593 | + * @since 1.6.0 |
|
594 | + * |
|
595 | + * @param string $shortcode_content The shortcode content text. |
|
596 | + * @param array $args Array of arguements to filter listings. |
|
597 | + */ |
|
598 | + $shortcode_content = apply_filters('geodir_sc_gd_listings_not_found_content', $shortcode_content, $args); |
|
599 | 599 | |
600 | 600 | $top_pagination = $with_pagination && !empty($args['top_pagination']) ? true : false; |
601 | 601 | $bottom_pagination = $with_pagination && !empty($args['bottom_pagination']) ? true : false; |
@@ -607,92 +607,92 @@ discard block |
||
607 | 607 | $pageno = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1; |
608 | 608 | |
609 | 609 | $query_args = array( |
610 | - 'posts_per_page' => $post_number, |
|
611 | - 'is_geodir_loop' => true, |
|
612 | - 'gd_location' => $add_location_filter, |
|
613 | - 'post_type' => $post_type, |
|
614 | - 'order_by' => $list_sort, |
|
610 | + 'posts_per_page' => $post_number, |
|
611 | + 'is_geodir_loop' => true, |
|
612 | + 'gd_location' => $add_location_filter, |
|
613 | + 'post_type' => $post_type, |
|
614 | + 'order_by' => $list_sort, |
|
615 | 615 | 'pageno' => $pageno |
616 | - ); |
|
616 | + ); |
|
617 | 617 | |
618 | - if ($character_count >= 0) { |
|
619 | - $query_args['excerpt_length'] = $character_count; |
|
620 | - } |
|
618 | + if ($character_count >= 0) { |
|
619 | + $query_args['excerpt_length'] = $character_count; |
|
620 | + } |
|
621 | 621 | |
622 | - if (!empty($args['post_author'])) { |
|
623 | - $query_args['post_author'] = $args['post_author']; |
|
624 | - } |
|
622 | + if (!empty($args['post_author'])) { |
|
623 | + $query_args['post_author'] = $args['post_author']; |
|
624 | + } |
|
625 | 625 | |
626 | - if (!empty($args['show_featured_only'])) { |
|
627 | - $query_args['show_featured_only'] = 1; |
|
628 | - } |
|
626 | + if (!empty($args['show_featured_only'])) { |
|
627 | + $query_args['show_featured_only'] = 1; |
|
628 | + } |
|
629 | 629 | |
630 | - if (!empty($args['show_special_only'])) { |
|
631 | - $query_args['show_special_only'] = 1; |
|
632 | - } |
|
630 | + if (!empty($args['show_special_only'])) { |
|
631 | + $query_args['show_special_only'] = 1; |
|
632 | + } |
|
633 | 633 | |
634 | - if (!empty($args['with_pics_only'])) { |
|
635 | - $query_args['with_pics_only'] = 0; |
|
636 | - $query_args['featured_image_only'] = 1; |
|
637 | - } |
|
634 | + if (!empty($args['with_pics_only'])) { |
|
635 | + $query_args['with_pics_only'] = 0; |
|
636 | + $query_args['featured_image_only'] = 1; |
|
637 | + } |
|
638 | 638 | |
639 | - if (!empty($args['with_videos_only'])) { |
|
640 | - $query_args['with_videos_only'] = 1; |
|
641 | - } |
|
639 | + if (!empty($args['with_videos_only'])) { |
|
640 | + $query_args['with_videos_only'] = 1; |
|
641 | + } |
|
642 | 642 | |
643 | - if (!empty($args['show_favorites_only'])) { |
|
644 | - $query_args['show_favorites_only'] = 1; |
|
645 | - $query_args['favorites_by_user'] = !empty($args['favorites_by_user']) ? $args['favorites_by_user'] : 0; |
|
646 | - } |
|
647 | - $with_no_results = !empty($args['without_no_results']) ? false : true; |
|
643 | + if (!empty($args['show_favorites_only'])) { |
|
644 | + $query_args['show_favorites_only'] = 1; |
|
645 | + $query_args['favorites_by_user'] = !empty($args['favorites_by_user']) ? $args['favorites_by_user'] : 0; |
|
646 | + } |
|
647 | + $with_no_results = !empty($args['without_no_results']) ? false : true; |
|
648 | 648 | |
649 | - if (!empty($category) && isset($category[0]) && $category[0] != '0') { |
|
650 | - $category_taxonomy = geodir_get_taxonomies($post_type); |
|
649 | + if (!empty($category) && isset($category[0]) && $category[0] != '0') { |
|
650 | + $category_taxonomy = geodir_get_taxonomies($post_type); |
|
651 | 651 | |
652 | - ######### WPML ######### |
|
653 | - if (geodir_wpml_is_taxonomy_translated($category_taxonomy[0])) { |
|
654 | - $category = gd_lang_object_ids($category, $category_taxonomy[0]); |
|
655 | - } |
|
656 | - ######### WPML ######### |
|
652 | + ######### WPML ######### |
|
653 | + if (geodir_wpml_is_taxonomy_translated($category_taxonomy[0])) { |
|
654 | + $category = gd_lang_object_ids($category, $category_taxonomy[0]); |
|
655 | + } |
|
656 | + ######### WPML ######### |
|
657 | 657 | |
658 | - $tax_query = array( |
|
659 | - 'taxonomy' => $category_taxonomy[0], |
|
660 | - 'field' => 'id', |
|
661 | - 'terms' => $category |
|
662 | - ); |
|
658 | + $tax_query = array( |
|
659 | + 'taxonomy' => $category_taxonomy[0], |
|
660 | + 'field' => 'id', |
|
661 | + 'terms' => $category |
|
662 | + ); |
|
663 | 663 | |
664 | - $query_args['tax_query'] = array($tax_query); |
|
665 | - } |
|
664 | + $query_args['tax_query'] = array($tax_query); |
|
665 | + } |
|
666 | 666 | |
667 | - if (!empty($tags)) { |
|
668 | - // Clean tags |
|
669 | - if (!is_array($tags)) { |
|
670 | - $comma = _x(',', 'tag delimiter'); |
|
671 | - if ( ',' !== $comma ) { |
|
672 | - $tags = str_replace($comma, ',', $tags); |
|
673 | - } |
|
674 | - $tags = explode(',', trim($tags, " \n\t\r\0\x0B,")); |
|
675 | - $tags = array_map('trim', $tags); |
|
676 | - } |
|
667 | + if (!empty($tags)) { |
|
668 | + // Clean tags |
|
669 | + if (!is_array($tags)) { |
|
670 | + $comma = _x(',', 'tag delimiter'); |
|
671 | + if ( ',' !== $comma ) { |
|
672 | + $tags = str_replace($comma, ',', $tags); |
|
673 | + } |
|
674 | + $tags = explode(',', trim($tags, " \n\t\r\0\x0B,")); |
|
675 | + $tags = array_map('trim', $tags); |
|
676 | + } |
|
677 | 677 | |
678 | - if (!empty($tags)) { |
|
679 | - $tag_query = array( |
|
680 | - 'taxonomy' => $post_type . '_tags', |
|
681 | - 'field' => 'name', |
|
682 | - 'terms' => $tags |
|
683 | - ); |
|
684 | - |
|
685 | - if (!empty($query_args['tax_query'])) { |
|
686 | - $query_args['tax_query'][] = $tag_query; |
|
687 | - } else { |
|
688 | - $query_args['tax_query'] = array($tag_query); |
|
689 | - } |
|
690 | - } |
|
691 | - } |
|
678 | + if (!empty($tags)) { |
|
679 | + $tag_query = array( |
|
680 | + 'taxonomy' => $post_type . '_tags', |
|
681 | + 'field' => 'name', |
|
682 | + 'terms' => $tags |
|
683 | + ); |
|
684 | + |
|
685 | + if (!empty($query_args['tax_query'])) { |
|
686 | + $query_args['tax_query'][] = $tag_query; |
|
687 | + } else { |
|
688 | + $query_args['tax_query'] = array($tag_query); |
|
689 | + } |
|
690 | + } |
|
691 | + } |
|
692 | 692 | |
693 | - global $gridview_columns_widget, $geodir_is_widget_listing; |
|
693 | + global $gridview_columns_widget, $geodir_is_widget_listing; |
|
694 | 694 | |
695 | - if ($post_type == 'gd_event' && function_exists('geodir_event_get_widget_events')) { |
|
695 | + if ($post_type == 'gd_event' && function_exists('geodir_event_get_widget_events')) { |
|
696 | 696 | global $geodir_event_widget_listview; |
697 | 697 | $geodir_event_widget_listview = true; |
698 | 698 | |
@@ -707,16 +707,16 @@ discard block |
||
707 | 707 | $widget_listings = $total_posts > 0 ? geodir_get_widget_listings($query_args) : array(); |
708 | 708 | } |
709 | 709 | $current_gridview_columns_widget = $gridview_columns_widget; |
710 | - $identifier = ' gd-wgt-pagi-' . mt_rand(); |
|
711 | - ob_start(); |
|
710 | + $identifier = ' gd-wgt-pagi-' . mt_rand(); |
|
711 | + ob_start(); |
|
712 | 712 | if (!empty($widget_listings) || $with_no_results) { |
713 | 713 | if (!$geodir_ajax) { |
714 | - /** |
|
715 | - * Called before the shortcode [gd_listings] content is output. |
|
716 | - * |
|
717 | - * @since 1.0.0 |
|
718 | - */ |
|
719 | - do_action('geodir_before_sc_gd_listings'); |
|
714 | + /** |
|
715 | + * Called before the shortcode [gd_listings] content is output. |
|
716 | + * |
|
717 | + * @since 1.0.0 |
|
718 | + */ |
|
719 | + do_action('geodir_before_sc_gd_listings'); |
|
720 | 720 | ?> |
721 | 721 | <div class="geodir_locations geodir_location_listing geodir-sc-gd-listings <?php echo $identifier;?>"> |
722 | 722 | <?php if ($title != '') { ?> |
@@ -727,63 +727,63 @@ discard block |
||
727 | 727 | <div class="gd-sc-loader"> |
728 | 728 | <div class="gd-sc-content"> |
729 | 729 | <?php } |
730 | - if (!(empty($widget_listings) && !empty($shortcode_content))) { |
|
731 | - if (strstr($layout, 'gridview')) { |
|
732 | - $listing_view_exp = explode('_', $layout); |
|
733 | - $gridview_columns_widget = $layout; |
|
734 | - $layout = $listing_view_exp[0]; |
|
735 | - } else { |
|
736 | - $gridview_columns_widget = ''; |
|
737 | - } |
|
738 | - |
|
739 | - /** |
|
740 | - * Filter the widget listing listview template. |
|
741 | - * |
|
742 | - * @since 1.0.0 |
|
743 | - * |
|
744 | - * @param string The template file to display listing. |
|
745 | - */ |
|
746 | - $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview')); |
|
730 | + if (!(empty($widget_listings) && !empty($shortcode_content))) { |
|
731 | + if (strstr($layout, 'gridview')) { |
|
732 | + $listing_view_exp = explode('_', $layout); |
|
733 | + $gridview_columns_widget = $layout; |
|
734 | + $layout = $listing_view_exp[0]; |
|
735 | + } else { |
|
736 | + $gridview_columns_widget = ''; |
|
737 | + } |
|
738 | + |
|
739 | + /** |
|
740 | + * Filter the widget listing listview template. |
|
741 | + * |
|
742 | + * @since 1.0.0 |
|
743 | + * |
|
744 | + * @param string The template file to display listing. |
|
745 | + */ |
|
746 | + $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview')); |
|
747 | 747 | |
748 | - global $post, $map_jason, $map_canvas_arr, $gd_session; |
|
749 | - |
|
750 | - $current_post = $post; |
|
751 | - $current_map_jason = $map_jason; |
|
752 | - $current_map_canvas_arr = $map_canvas_arr; |
|
753 | - $geodir_is_widget_listing = true; |
|
754 | - $gd_session->un_set('gd_listing_view'); |
|
755 | - |
|
756 | - if ($with_pagination && $top_pagination) { |
|
757 | - echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); |
|
758 | - } |
|
759 | - |
|
760 | - /** |
|
761 | - * Includes listing listview template. |
|
762 | - * |
|
763 | - * @since 1.0.0 |
|
764 | - */ |
|
765 | - include($template); |
|
748 | + global $post, $map_jason, $map_canvas_arr, $gd_session; |
|
749 | + |
|
750 | + $current_post = $post; |
|
751 | + $current_map_jason = $map_jason; |
|
752 | + $current_map_canvas_arr = $map_canvas_arr; |
|
753 | + $geodir_is_widget_listing = true; |
|
754 | + $gd_session->un_set('gd_listing_view'); |
|
755 | + |
|
756 | + if ($with_pagination && $top_pagination) { |
|
757 | + echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); |
|
758 | + } |
|
759 | + |
|
760 | + /** |
|
761 | + * Includes listing listview template. |
|
762 | + * |
|
763 | + * @since 1.0.0 |
|
764 | + */ |
|
765 | + include($template); |
|
766 | 766 | |
767 | - if ($with_pagination && $bottom_pagination) { |
|
768 | - echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); |
|
769 | - } |
|
770 | - |
|
771 | - $geodir_is_widget_listing = false; |
|
772 | - |
|
773 | - $GLOBALS['post'] = $current_post; |
|
774 | - if (!empty($current_post)) { |
|
775 | - setup_postdata($current_post); |
|
776 | - } |
|
777 | - $map_jason = $current_map_jason; |
|
778 | - $map_canvas_arr = $current_map_canvas_arr; |
|
779 | - global $gridview_columns_widget; |
|
780 | - $gridview_columns_widget = $current_gridview_columns_widget; |
|
781 | - } else { |
|
782 | - echo $shortcode_content; |
|
783 | - } |
|
767 | + if ($with_pagination && $bottom_pagination) { |
|
768 | + echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); |
|
769 | + } |
|
770 | + |
|
771 | + $geodir_is_widget_listing = false; |
|
772 | + |
|
773 | + $GLOBALS['post'] = $current_post; |
|
774 | + if (!empty($current_post)) { |
|
775 | + setup_postdata($current_post); |
|
776 | + } |
|
777 | + $map_jason = $current_map_jason; |
|
778 | + $map_canvas_arr = $current_map_canvas_arr; |
|
779 | + global $gridview_columns_widget; |
|
780 | + $gridview_columns_widget = $current_gridview_columns_widget; |
|
781 | + } else { |
|
782 | + echo $shortcode_content; |
|
783 | + } |
|
784 | 784 | ?> |
785 | 785 | <?php |
786 | - if (!$geodir_ajax) { |
|
786 | + if (!$geodir_ajax) { |
|
787 | 787 | ?> |
788 | 788 | </div><p class="geodir-sclisting-loading" style="display:none;"><i class="fa fa-cog fa-spin"></i></p></div> |
789 | 789 | <script type="text/javascript"> |
@@ -822,10 +822,10 @@ discard block |
||
822 | 822 | loading.hide(); |
823 | 823 | jQuery(items).html(response); |
824 | 824 | <?php |
825 | - /** |
|
826 | - * if lazyload images enabled then refresh them once ajax page changed. |
|
827 | - */ |
|
828 | - if (get_option('geodir_lazy_load', 1)) { ?> |
|
825 | + /** |
|
826 | + * if lazyload images enabled then refresh them once ajax page changed. |
|
827 | + */ |
|
828 | + if (get_option('geodir_lazy_load', 1)) { ?> |
|
829 | 829 | geodir_init_lazy_load(); |
830 | 830 | <?php } ?> |
831 | 831 | } |
@@ -836,11 +836,11 @@ discard block |
||
836 | 836 | </div> |
837 | 837 | <?php } ?> |
838 | 838 | <?php |
839 | - } |
|
839 | + } |
|
840 | 840 | $output = ob_get_contents(); |
841 | - ob_end_clean(); |
|
841 | + ob_end_clean(); |
|
842 | 842 | |
843 | - return trim($output); |
|
843 | + return trim($output); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -867,15 +867,15 @@ discard block |
||
867 | 867 | * @return string Listings pagination HTML content. |
868 | 868 | */ |
869 | 869 | function geodir_sc_listings_pagination($total_posts, $posts_per_page, $pageno, $before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) { |
870 | - if (empty($prelabel)) { |
|
871 | - $prelabel = '<strong>«</strong>'; |
|
872 | - } |
|
870 | + if (empty($prelabel)) { |
|
871 | + $prelabel = '<strong>«</strong>'; |
|
872 | + } |
|
873 | 873 | |
874 | - if (empty($nxtlabel)) { |
|
875 | - $nxtlabel = '<strong>»</strong>'; |
|
876 | - } |
|
874 | + if (empty($nxtlabel)) { |
|
875 | + $nxtlabel = '<strong>»</strong>'; |
|
876 | + } |
|
877 | 877 | |
878 | - $half_pages_to_show = round($pages_to_show / 2); |
|
878 | + $half_pages_to_show = round($pages_to_show / 2); |
|
879 | 879 | |
880 | 880 | $numposts = $total_posts; |
881 | 881 | |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | } |
909 | 909 | |
910 | 910 | if (($pageno - 1) > 0) { |
911 | - echo '<a class="gd-page-sc-prev gd-wgt-page" data-page="' . (int)($pageno - 1) . '" href="javascript:void(0);">' . $prelabel . '</a> '; |
|
911 | + echo '<a class="gd-page-sc-prev gd-wgt-page" data-page="' . (int)($pageno - 1) . '" href="javascript:void(0);">' . $prelabel . '</a> '; |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | for ($i = $pageno - $half_pages_to_show; $i <= $pageno + $half_pages_to_show; $i++) { |
@@ -931,9 +931,9 @@ discard block |
||
931 | 931 | echo "</div> $after </div>"; |
932 | 932 | } |
933 | 933 | $output = ob_get_contents(); |
934 | - ob_end_clean(); |
|
934 | + ob_end_clean(); |
|
935 | 935 | |
936 | - return trim($output); |
|
936 | + return trim($output); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | /** |
@@ -944,10 +944,10 @@ discard block |
||
944 | 944 | * @return string Listings HTML content. |
945 | 945 | */ |
946 | 946 | function geodir_sclistings_callback() { |
947 | - check_ajax_referer('geodir-sclistings-nonce', 'geodir_sclistings_nonce'); |
|
948 | - //set variables |
|
949 | - $scatts = isset($_POST['scatts']) ? $_POST['scatts'] : NULL; |
|
950 | - $pageno = isset($_POST['pageno']) ? absint($_POST['pageno']) : 1; |
|
947 | + check_ajax_referer('geodir-sclistings-nonce', 'geodir_sclistings_nonce'); |
|
948 | + //set variables |
|
949 | + $scatts = isset($_POST['scatts']) ? $_POST['scatts'] : NULL; |
|
950 | + $pageno = isset($_POST['pageno']) ? absint($_POST['pageno']) : 1; |
|
951 | 951 | |
952 | 952 | $shortcode_atts = !empty($scatts) ? (array)json_decode(stripslashes_deep($scatts)) : NULL; |
953 | 953 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | } else { |
960 | 960 | echo 0; |
961 | 961 | } |
962 | - wp_die(); |
|
962 | + wp_die(); |
|
963 | 963 | } |
964 | 964 | add_action('wp_ajax_geodir_sclistings', 'geodir_sclistings_callback'); |
965 | 965 | add_action('wp_ajax_nopriv_geodir_sclistings', 'geodir_sclistings_callback'); |
966 | 966 | \ No newline at end of file |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | |
9 | 9 | // Enable map cache if set |
10 | 10 | if(get_option('geodir_enable_map_cache')){ |
11 | - add_filter('geodir_get_markers_cache','geodir_get_map_cache'); |
|
12 | - add_filter('geodir_markers_json','geodir_save_map_cache',10); |
|
11 | + add_filter('geodir_get_markers_cache','geodir_get_map_cache'); |
|
12 | + add_filter('geodir_markers_json','geodir_save_map_cache',10); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | |
@@ -23,61 +23,61 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function geodir_get_map_cache($cache){ |
25 | 25 | |
26 | - // if a search is going on then dont even try to check for cache. |
|
27 | - if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){ |
|
28 | - return $cache; |
|
29 | - } |
|
30 | - |
|
31 | - $url_params = array(); |
|
32 | - $url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : ''; |
|
33 | - $url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : ''; |
|
34 | - $url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : ''; |
|
35 | - $url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : ''; |
|
36 | - $url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : ''; |
|
37 | - $url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : ''; |
|
38 | - $url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : ''; |
|
39 | - $url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : ''; |
|
40 | - $url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : ''; |
|
41 | - $url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : ''; |
|
42 | - $url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : ''; |
|
43 | - $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : ''; |
|
44 | - $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : ''; |
|
26 | + // if a search is going on then dont even try to check for cache. |
|
27 | + if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){ |
|
28 | + return $cache; |
|
29 | + } |
|
30 | + |
|
31 | + $url_params = array(); |
|
32 | + $url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : ''; |
|
33 | + $url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : ''; |
|
34 | + $url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : ''; |
|
35 | + $url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : ''; |
|
36 | + $url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : ''; |
|
37 | + $url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : ''; |
|
38 | + $url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : ''; |
|
39 | + $url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : ''; |
|
40 | + $url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : ''; |
|
41 | + $url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : ''; |
|
42 | + $url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : ''; |
|
43 | + $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : ''; |
|
44 | + $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : ''; |
|
45 | 45 | $url_params[] = isset($_REQUEST['my_lat']) ? $_REQUEST['my_lat'] : ''; |
46 | 46 | $url_params[] = isset($_REQUEST['my_lon']) ? $_REQUEST['my_lon'] : ''; |
47 | 47 | |
48 | - $file_name = sanitize_file_name( md5( implode("-",$url_params) ) ); |
|
48 | + $file_name = sanitize_file_name( md5( implode("-",$url_params) ) ); |
|
49 | 49 | |
50 | - $blog_id = get_current_blog_id(); |
|
51 | - if($blog_id>1){ |
|
52 | - $file_name = $blog_id."_".$file_name; |
|
53 | - } |
|
50 | + $blog_id = get_current_blog_id(); |
|
51 | + if($blog_id>1){ |
|
52 | + $file_name = $blog_id."_".$file_name; |
|
53 | + } |
|
54 | 54 | |
55 | - $file_path = realpath(dirname(__FILE__))."/map-cache/"; |
|
55 | + $file_path = realpath(dirname(__FILE__))."/map-cache/"; |
|
56 | 56 | |
57 | 57 | |
58 | - if(file_exists($file_path.$file_name.".json")){ |
|
58 | + if(file_exists($file_path.$file_name.".json")){ |
|
59 | 59 | |
60 | 60 | |
61 | - ob_start(); |
|
62 | - readfile($file_path.$file_name.".json"); // readfile is quicker then file get contents |
|
63 | - $content = ob_get_clean(); |
|
61 | + ob_start(); |
|
62 | + readfile($file_path.$file_name.".json"); // readfile is quicker then file get contents |
|
63 | + $content = ob_get_clean(); |
|
64 | 64 | |
65 | - // do the cache delete stuff |
|
66 | - $cache_time = get_option('geodir_map_cache'); |
|
67 | - if(!$cache_time){ |
|
68 | - $cache_time = time(); |
|
69 | - update_option('geodir_map_cache', $cache_time); |
|
70 | - } |
|
65 | + // do the cache delete stuff |
|
66 | + $cache_time = get_option('geodir_map_cache'); |
|
67 | + if(!$cache_time){ |
|
68 | + $cache_time = time(); |
|
69 | + update_option('geodir_map_cache', $cache_time); |
|
70 | + } |
|
71 | 71 | |
72 | - if((time() - $cache_time) > 86400){ // delete the cache every 24 hours |
|
73 | - geodir_delete_map_cache(); |
|
74 | - } |
|
72 | + if((time() - $cache_time) > 86400){ // delete the cache every 24 hours |
|
73 | + geodir_delete_map_cache(); |
|
74 | + } |
|
75 | 75 | |
76 | - return $content; |
|
76 | + return $content; |
|
77 | 77 | |
78 | - } |
|
78 | + } |
|
79 | 79 | |
80 | - return $cache; |
|
80 | + return $cache; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -90,103 +90,103 @@ discard block |
||
90 | 90 | */ |
91 | 91 | function geodir_save_map_cache($map_json){ |
92 | 92 | |
93 | - // if a search is going on then dont even try to check for cache. |
|
94 | - if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){ |
|
95 | - return $map_json; |
|
96 | - } |
|
97 | - |
|
98 | - $url_params = array(); |
|
99 | - $url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : ''; |
|
100 | - $url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : ''; |
|
101 | - $url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : ''; |
|
102 | - $url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : ''; |
|
103 | - $url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : ''; |
|
104 | - $url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : ''; |
|
105 | - $url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : ''; |
|
106 | - $url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : ''; |
|
107 | - $url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : ''; |
|
108 | - $url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : ''; |
|
109 | - $url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : ''; |
|
110 | - $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : ''; |
|
111 | - $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : ''; |
|
93 | + // if a search is going on then dont even try to check for cache. |
|
94 | + if(isset($_REQUEST['search']) && !empty($_REQUEST['search'])){ |
|
95 | + return $map_json; |
|
96 | + } |
|
97 | + |
|
98 | + $url_params = array(); |
|
99 | + $url_params[] = isset($_REQUEST['cat_id']) ? $_REQUEST['cat_id'] : ''; |
|
100 | + $url_params[] = isset($_REQUEST['zl']) ? $_REQUEST['zl'] : ''; |
|
101 | + $url_params[] = isset($_REQUEST['gd_map_h']) ? $_REQUEST['gd_map_h'] : ''; |
|
102 | + $url_params[] = isset($_REQUEST['gd_map_w']) ? $_REQUEST['gd_map_w'] : ''; |
|
103 | + $url_params[] = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : ''; |
|
104 | + $url_params[] = isset($_REQUEST['lat_ne']) ? $_REQUEST['lat_ne'] : ''; |
|
105 | + $url_params[] = isset($_REQUEST['lon_ne']) ? $_REQUEST['lon_ne'] : ''; |
|
106 | + $url_params[] = isset($_REQUEST['lat_sw']) ? $_REQUEST['lat_sw'] : ''; |
|
107 | + $url_params[] = isset($_REQUEST['lon_sw']) ? $_REQUEST['lon_sw'] : ''; |
|
108 | + $url_params[] = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : ''; |
|
109 | + $url_params[] = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : ''; |
|
110 | + $url_params[] = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : ''; |
|
111 | + $url_params[] = isset($_REQUEST['gd_neighbourhood']) ? $_REQUEST['gd_neighbourhood'] : ''; |
|
112 | 112 | $url_params[] = isset($_REQUEST['my_lat']) ? $_REQUEST['my_lat'] : ''; |
113 | 113 | $url_params[] = isset($_REQUEST['my_lon']) ? $_REQUEST['my_lon'] : ''; |
114 | 114 | |
115 | - $file_name = sanitize_file_name( md5( implode("-",$url_params) ) ); |
|
115 | + $file_name = sanitize_file_name( md5( implode("-",$url_params) ) ); |
|
116 | 116 | |
117 | - $blog_id = get_current_blog_id(); |
|
118 | - if($blog_id>1){ |
|
119 | - $file_name = $blog_id."_".$file_name; |
|
120 | - } |
|
117 | + $blog_id = get_current_blog_id(); |
|
118 | + if($blog_id>1){ |
|
119 | + $file_name = $blog_id."_".$file_name; |
|
120 | + } |
|
121 | 121 | |
122 | - $file_path = realpath(dirname(__FILE__))."/map-cache/"; |
|
122 | + $file_path = realpath(dirname(__FILE__))."/map-cache/"; |
|
123 | 123 | |
124 | 124 | |
125 | - global $wp_filesystem; |
|
126 | - if (empty($wp_filesystem)) { |
|
127 | - require_once (ABSPATH . '/wp-admin/includes/file.php'); |
|
128 | - WP_Filesystem(); |
|
129 | - } |
|
130 | - $wp_filesystem->put_contents( |
|
131 | - $file_path.$file_name.".json", |
|
132 | - $map_json, |
|
133 | - FS_CHMOD_FILE // predefined mode settings for WP files |
|
134 | - ); |
|
125 | + global $wp_filesystem; |
|
126 | + if (empty($wp_filesystem)) { |
|
127 | + require_once (ABSPATH . '/wp-admin/includes/file.php'); |
|
128 | + WP_Filesystem(); |
|
129 | + } |
|
130 | + $wp_filesystem->put_contents( |
|
131 | + $file_path.$file_name.".json", |
|
132 | + $map_json, |
|
133 | + FS_CHMOD_FILE // predefined mode settings for WP files |
|
134 | + ); |
|
135 | 135 | |
136 | 136 | |
137 | - return $map_json; |
|
137 | + return $map_json; |
|
138 | 138 | |
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | 142 | if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'homemap_catlist') { |
143 | - global $gd_session; |
|
144 | - $gd_post_type = sanitize_text_field($_REQUEST['post_type']); |
|
145 | - $gd_session->set('homemap_catlist_ptype', $gd_post_type); |
|
146 | - $post_taxonomy = geodir_get_taxonomies($gd_post_type); |
|
147 | - $map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']); |
|
148 | - $child_collapse = (bool)$_REQUEST['child_collapse']; |
|
149 | - echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true); |
|
150 | - die; |
|
143 | + global $gd_session; |
|
144 | + $gd_post_type = sanitize_text_field($_REQUEST['post_type']); |
|
145 | + $gd_session->set('homemap_catlist_ptype', $gd_post_type); |
|
146 | + $post_taxonomy = geodir_get_taxonomies($gd_post_type); |
|
147 | + $map_canvas_name = sanitize_text_field($_REQUEST['map_canvas']); |
|
148 | + $child_collapse = (bool)$_REQUEST['child_collapse']; |
|
149 | + echo home_map_taxonomy_walker($post_taxonomy, 0, true, 0, $map_canvas_name, $child_collapse, true); |
|
150 | + die; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Send the content-type header with correct encoding |
154 | 154 | header("Content-type: text/javascript; charset=utf-8"); |
155 | 155 | |
156 | 156 | if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'cat') { // Retrives markers data for categories |
157 | - echo get_markers(); |
|
158 | - exit; |
|
157 | + echo get_markers(); |
|
158 | + exit; |
|
159 | 159 | } else if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'info') { // Retrives marker info window html |
160 | - /** |
|
161 | - * @global object $wpdb WordPress Database object. |
|
162 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
163 | - * @global object $gd_session GeoDirectory Session object. |
|
164 | - */ |
|
165 | - global $wpdb, $plugin_prefix, $gd_session, $sitepress; |
|
160 | + /** |
|
161 | + * @global object $wpdb WordPress Database object. |
|
162 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
163 | + * @global object $gd_session GeoDirectory Session object. |
|
164 | + */ |
|
165 | + global $wpdb, $plugin_prefix, $gd_session, $sitepress; |
|
166 | 166 | |
167 | - if ($_REQUEST['m_id'] != '') { |
|
168 | - $pid = (int)$_REQUEST['m_id']; |
|
169 | - } else { |
|
170 | - echo __('No marker data found', 'geodirectory'); |
|
171 | - exit; |
|
172 | - } |
|
167 | + if ($_REQUEST['m_id'] != '') { |
|
168 | + $pid = (int)$_REQUEST['m_id']; |
|
169 | + } else { |
|
170 | + echo __('No marker data found', 'geodirectory'); |
|
171 | + exit; |
|
172 | + } |
|
173 | 173 | |
174 | - if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) { |
|
175 | - $post = (object)$gd_ses_listing; |
|
176 | - echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']); |
|
177 | - } else { |
|
178 | - $geodir_post_type = get_post_type($pid); |
|
174 | + if (isset($_REQUEST['post_preview']) && $_REQUEST['post_preview'] != '' && $gd_ses_listing = $gd_session->get('listing')) { |
|
175 | + $post = (object)$gd_ses_listing; |
|
176 | + echo geodir_get_infowindow_html($post, $_REQUEST['post_preview']); |
|
177 | + } else { |
|
178 | + $geodir_post_type = get_post_type($pid); |
|
179 | 179 | |
180 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
180 | + $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
181 | 181 | |
182 | - $sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid)); |
|
182 | + $sql = $wpdb->prepare("SELECT * FROM " . $table . " WHERE post_id = %d", array($pid)); |
|
183 | 183 | |
184 | - $postinfo = $wpdb->get_results($sql); |
|
184 | + $postinfo = $wpdb->get_results($sql); |
|
185 | 185 | |
186 | - $data_arr = array(); |
|
186 | + $data_arr = array(); |
|
187 | 187 | |
188 | - if ($postinfo) { |
|
189 | - $switch_lang = false; |
|
188 | + if ($postinfo) { |
|
189 | + $switch_lang = false; |
|
190 | 190 | if ( geodir_is_wpml() && is_post_type_translated( $geodir_post_type ) ) { |
191 | 191 | $post_lang = $sitepress->get_language_for_element( $pid, 'post_' . $geodir_post_type ); |
192 | 192 | $current_lang = $sitepress->get_current_language(); |
@@ -197,18 +197,18 @@ discard block |
||
197 | 197 | } |
198 | 198 | |
199 | 199 | $srcharr = array("'", "/", "-", '"', '\\'); |
200 | - $replarr = array("′", "⁄", "–", "“", ''); |
|
200 | + $replarr = array("′", "⁄", "–", "“", ''); |
|
201 | 201 | |
202 | - foreach ($postinfo as $postinfo_obj) { |
|
203 | - echo geodir_get_infowindow_html($postinfo_obj); |
|
204 | - } |
|
202 | + foreach ($postinfo as $postinfo_obj) { |
|
203 | + echo geodir_get_infowindow_html($postinfo_obj); |
|
204 | + } |
|
205 | 205 | |
206 | 206 | if ( $switch_lang !== false ) { |
207 | 207 | $sitepress->switch_lang( $switch_lang, true ); |
208 | 208 | } |
209 | - } |
|
210 | - } |
|
211 | - exit; |
|
209 | + } |
|
210 | + } |
|
211 | + exit; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -227,93 +227,93 @@ discard block |
||
227 | 227 | */ |
228 | 228 | function get_markers() { |
229 | 229 | |
230 | - global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes,$gd_session; |
|
230 | + global $wpdb, $plugin_prefix, $geodir_cat_icons, $gd_marker_sizes,$gd_session; |
|
231 | 231 | |
232 | 232 | |
233 | - /** |
|
234 | - * Filter to allow for any map caching to be output before queries. |
|
235 | - * |
|
236 | - * @since 1.6.22 |
|
237 | - */ |
|
238 | - $map_cache = apply_filters('geodir_get_markers_cache',''); |
|
239 | - if($map_cache){ |
|
240 | - return $map_cache; |
|
241 | - wp_die(); |
|
242 | - } |
|
233 | + /** |
|
234 | + * Filter to allow for any map caching to be output before queries. |
|
235 | + * |
|
236 | + * @since 1.6.22 |
|
237 | + */ |
|
238 | + $map_cache = apply_filters('geodir_get_markers_cache',''); |
|
239 | + if($map_cache){ |
|
240 | + return $map_cache; |
|
241 | + wp_die(); |
|
242 | + } |
|
243 | 243 | |
244 | 244 | |
245 | 245 | |
246 | - $search = ''; |
|
246 | + $search = ''; |
|
247 | 247 | |
248 | - $srcharr = array("'", "/", "-", '"', '\\', '''); |
|
249 | - $replarr = array("′", "⁄", "–", "“", '', "′"); |
|
248 | + $srcharr = array("'", "/", "-", '"', '\\', '''); |
|
249 | + $replarr = array("′", "⁄", "–", "“", '', "′"); |
|
250 | 250 | |
251 | - $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place'; |
|
251 | + $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place'; |
|
252 | 252 | |
253 | - $map_cat_ids_array = array('0'); |
|
254 | - $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)"); |
|
253 | + $map_cat_ids_array = array('0'); |
|
254 | + $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)"); |
|
255 | 255 | |
256 | 256 | |
257 | - $field_default_cat = ''; |
|
258 | - if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') { |
|
259 | - $map_cat_arr = trim($_REQUEST['cat_id'], ','); |
|
257 | + $field_default_cat = ''; |
|
258 | + if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') { |
|
259 | + $map_cat_arr = trim($_REQUEST['cat_id'], ','); |
|
260 | 260 | |
261 | - if (!empty($map_cat_arr)) { |
|
262 | - $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category "; |
|
261 | + if (!empty($map_cat_arr)) { |
|
262 | + $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category "; |
|
263 | 263 | |
264 | - $map_cat_ids_array = explode(',', $map_cat_arr); |
|
265 | - $cat_find_array = array(); |
|
266 | - foreach ($map_cat_ids_array as $cat_id) { |
|
267 | - $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id "; |
|
268 | - $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)"; |
|
269 | - $main_query_array[] = $cat_id; |
|
270 | - } |
|
264 | + $map_cat_ids_array = explode(',', $map_cat_arr); |
|
265 | + $cat_find_array = array(); |
|
266 | + foreach ($map_cat_ids_array as $cat_id) { |
|
267 | + $field_default_cat .= "WHEN (FIND_IN_SET($cat_id, `" . $post_type . "category`) > 0) THEN $cat_id "; |
|
268 | + $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)"; |
|
269 | + $main_query_array[] = $cat_id; |
|
270 | + } |
|
271 | 271 | |
272 | - } |
|
273 | - } |
|
272 | + } |
|
273 | + } |
|
274 | 274 | |
275 | - if (!empty($field_default_cat)) |
|
276 | - $field_default_cat = ''; |
|
275 | + if (!empty($field_default_cat)) |
|
276 | + $field_default_cat = ''; |
|
277 | 277 | |
278 | - if (!empty($cat_find_array)) |
|
279 | - $search .= "AND (" . implode(' OR ', $cat_find_array) . ")"; |
|
278 | + if (!empty($cat_find_array)) |
|
279 | + $search .= "AND (" . implode(' OR ', $cat_find_array) . ")"; |
|
280 | 280 | |
281 | - $main_query_array = $map_cat_ids_array; |
|
281 | + $main_query_array = $map_cat_ids_array; |
|
282 | 282 | |
283 | - if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) { |
|
284 | - $search .= " AND p.post_title LIKE %s"; |
|
285 | - $main_query_array[] = "%" . $_REQUEST['search'] . "%"; |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Filter the marker query search SQL, values are replaces with %s or %d. |
|
290 | - * |
|
291 | - * @since 1.5.3 |
|
292 | - * |
|
293 | - * @param string $search The SQL query for search/where. |
|
294 | - */ |
|
295 | - $search = apply_filters('geodir_marker_search', $search); |
|
296 | - /** |
|
297 | - * Filter the marker query search SQL values %s and %d, this is an array of values. |
|
298 | - * |
|
299 | - * @since 1.5.3 |
|
300 | - * |
|
301 | - * @param array $main_query_array The SQL query values for search/where. |
|
302 | - */ |
|
303 | - $main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array); |
|
304 | - |
|
305 | - $gd_posttype = ''; |
|
306 | - if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') { |
|
307 | - $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail'; |
|
308 | - $gd_posttype = " AND p.post_type = %s"; |
|
309 | - $main_query_array[] = $_REQUEST['gd_posttype']; |
|
310 | - |
|
311 | - } else |
|
312 | - $table = $plugin_prefix . 'gd_place_detail'; |
|
313 | - |
|
314 | - $join = ", " . $table . " AS pd "; |
|
315 | - |
|
316 | - /** |
|
283 | + if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) { |
|
284 | + $search .= " AND p.post_title LIKE %s"; |
|
285 | + $main_query_array[] = "%" . $_REQUEST['search'] . "%"; |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Filter the marker query search SQL, values are replaces with %s or %d. |
|
290 | + * |
|
291 | + * @since 1.5.3 |
|
292 | + * |
|
293 | + * @param string $search The SQL query for search/where. |
|
294 | + */ |
|
295 | + $search = apply_filters('geodir_marker_search', $search); |
|
296 | + /** |
|
297 | + * Filter the marker query search SQL values %s and %d, this is an array of values. |
|
298 | + * |
|
299 | + * @since 1.5.3 |
|
300 | + * |
|
301 | + * @param array $main_query_array The SQL query values for search/where. |
|
302 | + */ |
|
303 | + $main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array); |
|
304 | + |
|
305 | + $gd_posttype = ''; |
|
306 | + if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') { |
|
307 | + $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail'; |
|
308 | + $gd_posttype = " AND p.post_type = %s"; |
|
309 | + $main_query_array[] = $_REQUEST['gd_posttype']; |
|
310 | + |
|
311 | + } else |
|
312 | + $table = $plugin_prefix . 'gd_place_detail'; |
|
313 | + |
|
314 | + $join = ", " . $table . " AS pd "; |
|
315 | + |
|
316 | + /** |
|
317 | 317 | * Filter the SQL JOIN clause for the markers data |
318 | 318 | * |
319 | 319 | * @since 1.0.0 |
@@ -330,16 +330,16 @@ discard block |
||
330 | 330 | * @param string $search Row of searched fields to use in WHERE clause. |
331 | 331 | */ |
332 | 332 | $search = apply_filters('geodir_home_map_listing_where', $search); |
333 | - $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search); |
|
334 | - $cat_type = $post_type . 'category'; |
|
335 | - if ($post_type == 'gd_event') { |
|
336 | - $event_select = ", pd.recurring_dates, pd.is_recurring"; |
|
337 | - } else { |
|
338 | - $event_select = ""; |
|
339 | - } |
|
340 | - |
|
341 | - $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select; |
|
342 | - /** |
|
333 | + $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search); |
|
334 | + $cat_type = $post_type . 'category'; |
|
335 | + if ($post_type == 'gd_event') { |
|
336 | + $event_select = ", pd.recurring_dates, pd.is_recurring"; |
|
337 | + } else { |
|
338 | + $event_select = ""; |
|
339 | + } |
|
340 | + |
|
341 | + $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select; |
|
342 | + /** |
|
343 | 343 | * Filter the SQL SELECT clause to retrive fields data |
344 | 344 | * |
345 | 345 | * @since 1.0.0 |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | */ |
359 | 359 | $groupby = apply_filters('geodir_home_map_listing_groupby', $groupby); |
360 | 360 | |
361 | - $catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array); |
|
361 | + $catsql = $wpdb->prepare("$select $field_default_cat FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby , $main_query_array); |
|
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Filter the SQL query to retrive markers data |
@@ -374,276 +374,276 @@ discard block |
||
374 | 374 | // print_r($gd_session); |
375 | 375 | // print_r($_SESSION); |
376 | 376 | |
377 | - $catinfo = $wpdb->get_results($catsql); |
|
377 | + $catinfo = $wpdb->get_results($catsql); |
|
378 | 378 | |
379 | - $cat_content_info = array(); |
|
380 | - $content_data = array(); |
|
381 | - $post_ids = array(); |
|
382 | - |
|
383 | - /** |
|
384 | - * Called before marker data is processed into JSON. |
|
385 | - * |
|
386 | - * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
387 | - * |
|
388 | - * @since 1.5.3 |
|
389 | - * @param object $catinfo The posts object containing all marker data. |
|
390 | - * @see 'geodir_after_marker_post_process' |
|
391 | - */ |
|
392 | - $catinfo = apply_filters('geodir_before_marker_post_process', $catinfo); |
|
393 | - |
|
394 | - /** |
|
395 | - * Called before marker data is processed into JSON. |
|
396 | - * |
|
397 | - * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
398 | - * |
|
399 | - * @since 1.4.9 |
|
400 | - * @param object $catinfo The posts object containing all marker data. |
|
401 | - * @see 'geodir_after_marker_post_process' |
|
402 | - */ |
|
403 | - do_action('geodir_before_marker_post_process_action', $catinfo); |
|
404 | - |
|
405 | - // Sort any posts into a ajax array |
|
406 | - if (!empty($catinfo)) { |
|
407 | - $geodir_cat_icons = geodir_get_term_icon(); |
|
408 | - global $geodir_date_time_format, $geodir_date_format, $geodir_time_format; |
|
409 | - |
|
410 | - $today = strtotime(date_i18n('Y-m-d')); |
|
411 | - $show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0; |
|
379 | + $cat_content_info = array(); |
|
380 | + $content_data = array(); |
|
381 | + $post_ids = array(); |
|
382 | + |
|
383 | + /** |
|
384 | + * Called before marker data is processed into JSON. |
|
385 | + * |
|
386 | + * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
387 | + * |
|
388 | + * @since 1.5.3 |
|
389 | + * @param object $catinfo The posts object containing all marker data. |
|
390 | + * @see 'geodir_after_marker_post_process' |
|
391 | + */ |
|
392 | + $catinfo = apply_filters('geodir_before_marker_post_process', $catinfo); |
|
393 | + |
|
394 | + /** |
|
395 | + * Called before marker data is processed into JSON. |
|
396 | + * |
|
397 | + * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
398 | + * |
|
399 | + * @since 1.4.9 |
|
400 | + * @param object $catinfo The posts object containing all marker data. |
|
401 | + * @see 'geodir_after_marker_post_process' |
|
402 | + */ |
|
403 | + do_action('geodir_before_marker_post_process_action', $catinfo); |
|
404 | + |
|
405 | + // Sort any posts into a ajax array |
|
406 | + if (!empty($catinfo)) { |
|
407 | + $geodir_cat_icons = geodir_get_term_icon(); |
|
408 | + global $geodir_date_time_format, $geodir_date_format, $geodir_time_format; |
|
409 | + |
|
410 | + $today = strtotime(date_i18n('Y-m-d')); |
|
411 | + $show_dates = $post_type == 'gd_event' ? (int)get_option('geodir_event_infowindow_dates_count', 1) : 0; |
|
412 | 412 | |
413 | - foreach ($catinfo as $catinfo_obj) { |
|
414 | - $post_title = $catinfo_obj->post_title; |
|
413 | + foreach ($catinfo as $catinfo_obj) { |
|
414 | + $post_title = $catinfo_obj->post_title; |
|
415 | 415 | |
416 | - if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates) && $show_dates > 0) { |
|
417 | - $event_dates = ''; |
|
418 | - $recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array(); |
|
416 | + if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates) && $show_dates > 0) { |
|
417 | + $event_dates = ''; |
|
418 | + $recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array(); |
|
419 | 419 | |
420 | - $post_info = geodir_get_post_info($catinfo_obj->post_id); |
|
420 | + $post_info = geodir_get_post_info($catinfo_obj->post_id); |
|
421 | 421 | |
422 | - if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) { |
|
423 | - $starttimes = ''; |
|
424 | - $endtimes = ''; |
|
425 | - $astarttimes = array(); |
|
426 | - $aendtimes = array(); |
|
427 | - if ( !isset( $recurring_data['repeat_type'] ) ) { |
|
428 | - $recurring_data['repeat_type'] = 'custom'; |
|
429 | - } |
|
430 | - $repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom |
|
431 | - $different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false; |
|
422 | + if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) { |
|
423 | + $starttimes = ''; |
|
424 | + $endtimes = ''; |
|
425 | + $astarttimes = array(); |
|
426 | + $aendtimes = array(); |
|
427 | + if ( !isset( $recurring_data['repeat_type'] ) ) { |
|
428 | + $recurring_data['repeat_type'] = 'custom'; |
|
429 | + } |
|
430 | + $repeat_type = isset( $recurring_data['repeat_type'] ) && in_array( $recurring_data['repeat_type'], array( 'day', 'week', 'month', 'year', 'custom' ) ) ? $recurring_data['repeat_type'] : 'year'; // day, week, month, year, custom |
|
431 | + $different_times = isset( $recurring_data['different_times'] ) && !empty( $recurring_data['different_times'] ) ? true : false; |
|
432 | 432 | |
433 | - $recurring_dates = explode(',', $recurring_data['event_recurring_dates']); |
|
433 | + $recurring_dates = explode(',', $recurring_data['event_recurring_dates']); |
|
434 | 434 | |
435 | - if ( !empty( $recurring_dates ) ) { |
|
436 | - if ( empty( $recurring_data['all_day'] ) ) { |
|
437 | - if ( $repeat_type == 'custom' && $different_times ) { |
|
438 | - $astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array(); |
|
439 | - $aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array(); |
|
440 | - } else { |
|
441 | - $starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : ''; |
|
442 | - $endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : ''; |
|
443 | - } |
|
444 | - } |
|
435 | + if ( !empty( $recurring_dates ) ) { |
|
436 | + if ( empty( $recurring_data['all_day'] ) ) { |
|
437 | + if ( $repeat_type == 'custom' && $different_times ) { |
|
438 | + $astarttimes = isset( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array(); |
|
439 | + $aendtimes = isset( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array(); |
|
440 | + } else { |
|
441 | + $starttimes = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : ''; |
|
442 | + $endtimes = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : ''; |
|
443 | + } |
|
444 | + } |
|
445 | 445 | |
446 | - $e = 0; |
|
447 | - foreach( $recurring_dates as $key => $date ) { |
|
448 | - if ( $repeat_type == 'custom' && $different_times ) { |
|
449 | - if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) { |
|
450 | - $starttimes = $astarttimes[$key]; |
|
451 | - $endtimes = $aendtimes[$key]; |
|
452 | - } else { |
|
453 | - $starttimes = ''; |
|
454 | - $endtimes = ''; |
|
455 | - } |
|
456 | - } |
|
446 | + $e = 0; |
|
447 | + foreach( $recurring_dates as $key => $date ) { |
|
448 | + if ( $repeat_type == 'custom' && $different_times ) { |
|
449 | + if ( !empty( $astarttimes ) && isset( $astarttimes[$key] ) ) { |
|
450 | + $starttimes = $astarttimes[$key]; |
|
451 | + $endtimes = $aendtimes[$key]; |
|
452 | + } else { |
|
453 | + $starttimes = ''; |
|
454 | + $endtimes = ''; |
|
455 | + } |
|
456 | + } |
|
457 | 457 | |
458 | - $duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1; |
|
459 | - $duration--; |
|
460 | - $enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) ); |
|
458 | + $duration = isset( $recurring_data['duration_x'] ) && (int)$recurring_data['duration_x'] > 0 ? (int)$recurring_data['duration_x'] : 1; |
|
459 | + $duration--; |
|
460 | + $enddate = date_i18n( 'Y-m-d', strtotime( $date . ' + ' . $duration . ' day' ) ); |
|
461 | 461 | |
462 | - // Hide past dates |
|
463 | - if ( strtotime( $enddate ) < $today ) { |
|
464 | - continue; |
|
465 | - } |
|
462 | + // Hide past dates |
|
463 | + if ( strtotime( $enddate ) < $today ) { |
|
464 | + continue; |
|
465 | + } |
|
466 | 466 | |
467 | - $sdate = strtotime( $date . ' ' . $starttimes ); |
|
468 | - $edate = strtotime( $enddate . ' ' . $endtimes ); |
|
467 | + $sdate = strtotime( $date . ' ' . $starttimes ); |
|
468 | + $edate = strtotime( $enddate . ' ' . $endtimes ); |
|
469 | 469 | |
470 | - $start_date = date_i18n( $geodir_date_time_format, $sdate ); |
|
471 | - $end_date = date_i18n( $geodir_date_time_format, $edate ); |
|
470 | + $start_date = date_i18n( $geodir_date_time_format, $sdate ); |
|
471 | + $end_date = date_i18n( $geodir_date_time_format, $edate ); |
|
472 | 472 | |
473 | - $same_day = false; |
|
474 | - $full_day = false; |
|
475 | - $same_datetime = false; |
|
473 | + $same_day = false; |
|
474 | + $full_day = false; |
|
475 | + $same_datetime = false; |
|
476 | 476 | |
477 | - if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) { |
|
478 | - $full_day = true; |
|
479 | - } |
|
477 | + if ( $starttimes == $endtimes && ( $starttimes == '' || $starttimes == '00:00:00' || $starttimes == '00:00' ) ) { |
|
478 | + $full_day = true; |
|
479 | + } |
|
480 | 480 | |
481 | - if ( $start_date == $end_date && $full_day ) { |
|
482 | - $same_datetime = true; |
|
483 | - } |
|
484 | - |
|
485 | - $link_date = date_i18n( 'Y-m-d', $sdate ); |
|
486 | - $title_date = date_i18n( $geodir_date_format, $sdate ); |
|
487 | - if ( $full_day ) { |
|
488 | - $start_date = $title_date; |
|
489 | - $end_date = date_i18n( $geodir_date_format, $edate ); |
|
490 | - } |
|
481 | + if ( $start_date == $end_date && $full_day ) { |
|
482 | + $same_datetime = true; |
|
483 | + } |
|
484 | + |
|
485 | + $link_date = date_i18n( 'Y-m-d', $sdate ); |
|
486 | + $title_date = date_i18n( $geodir_date_format, $sdate ); |
|
487 | + if ( $full_day ) { |
|
488 | + $start_date = $title_date; |
|
489 | + $end_date = date_i18n( $geodir_date_format, $edate ); |
|
490 | + } |
|
491 | 491 | |
492 | - if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) { |
|
493 | - $same_day = true; |
|
492 | + if ( !$same_datetime && !$full_day && date_i18n( 'Y-m-d', $sdate ) == date_i18n( 'Y-m-d', $edate ) ) { |
|
493 | + $same_day = true; |
|
494 | 494 | |
495 | - $start_date .= ' - ' . date_i18n( $geodir_time_format, $edate ); |
|
496 | - } |
|
495 | + $start_date .= ' - ' . date_i18n( $geodir_time_format, $edate ); |
|
496 | + } |
|
497 | 497 | |
498 | - $event_dates .= ' :: ' . $start_date; |
|
498 | + $event_dates .= ' :: ' . $start_date; |
|
499 | 499 | |
500 | - if ( !$same_day && !$same_datetime ) { |
|
501 | - $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date; |
|
502 | - } |
|
500 | + if ( !$same_day && !$same_datetime ) { |
|
501 | + $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date; |
|
502 | + } |
|
503 | 503 | |
504 | - $e++; |
|
504 | + $e++; |
|
505 | 505 | |
506 | - if ($show_dates > 0 && $e == $show_dates) { // only show 3 event dates |
|
507 | - break; |
|
508 | - } |
|
509 | - } |
|
510 | - } |
|
511 | - } else { |
|
512 | - $start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : ''; |
|
513 | - $end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date; |
|
514 | - $all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false; |
|
515 | - $starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : ''; |
|
516 | - $endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : ''; |
|
506 | + if ($show_dates > 0 && $e == $show_dates) { // only show 3 event dates |
|
507 | + break; |
|
508 | + } |
|
509 | + } |
|
510 | + } |
|
511 | + } else { |
|
512 | + $start_date = isset( $recurring_data['event_start'] ) ? $recurring_data['event_start'] : ''; |
|
513 | + $end_date = isset( $recurring_data['event_end'] ) ? $recurring_data['event_end'] : $start_date; |
|
514 | + $all_day = isset( $recurring_data['all_day'] ) && !empty( $recurring_data['all_day'] ) ? true : false; |
|
515 | + $starttime = isset( $recurring_data['starttime'] ) ? $recurring_data['starttime'] : ''; |
|
516 | + $endtime = isset( $recurring_data['endtime'] ) ? $recurring_data['endtime'] : ''; |
|
517 | 517 | |
518 | - $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
519 | - $starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array(); |
|
520 | - $endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array(); |
|
518 | + $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
519 | + $starttimes = isset( $recurring_data['starttimes'] ) && !empty( $recurring_data['starttimes'] ) ? $recurring_data['starttimes'] : array(); |
|
520 | + $endtimes = isset( $recurring_data['endtimes'] ) && !empty( $recurring_data['endtimes'] ) ? $recurring_data['endtimes'] : array(); |
|
521 | 521 | |
522 | - if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) { |
|
523 | - $start_date = $event_recurring_dates[0]; |
|
524 | - } |
|
522 | + if ( !geodir_event_is_date( $start_date ) && !empty( $event_recurring_dates ) ) { |
|
523 | + $start_date = $event_recurring_dates[0]; |
|
524 | + } |
|
525 | 525 | |
526 | - if ( strtotime( $end_date ) < strtotime( $start_date ) ) { |
|
527 | - $end_date = $start_date; |
|
528 | - } |
|
526 | + if ( strtotime( $end_date ) < strtotime( $start_date ) ) { |
|
527 | + $end_date = $start_date; |
|
528 | + } |
|
529 | 529 | |
530 | - if ($end_date != '' && strtotime($end_date) >= $today) { |
|
531 | - if ( $starttime == '' && !empty( $starttimes ) ) { |
|
532 | - $starttime = $starttimes[0]; |
|
533 | - $endtime = $endtimes[0]; |
|
534 | - } |
|
530 | + if ($end_date != '' && strtotime($end_date) >= $today) { |
|
531 | + if ( $starttime == '' && !empty( $starttimes ) ) { |
|
532 | + $starttime = $starttimes[0]; |
|
533 | + $endtime = $endtimes[0]; |
|
534 | + } |
|
535 | 535 | |
536 | - $same_day = false; |
|
537 | - $one_day = false; |
|
538 | - if ( $start_date == $end_date && $all_day ) { |
|
539 | - $one_day = true; |
|
540 | - } |
|
541 | - |
|
542 | - if ( $all_day ) { |
|
543 | - $start_datetime = strtotime( $start_date ); |
|
544 | - $end_datetime = strtotime( $end_date ); |
|
536 | + $same_day = false; |
|
537 | + $one_day = false; |
|
538 | + if ( $start_date == $end_date && $all_day ) { |
|
539 | + $one_day = true; |
|
540 | + } |
|
541 | + |
|
542 | + if ( $all_day ) { |
|
543 | + $start_datetime = strtotime( $start_date ); |
|
544 | + $end_datetime = strtotime( $end_date ); |
|
545 | 545 | |
546 | - $start_date = date_i18n( $geodir_date_format, $start_datetime ); |
|
547 | - $end_date = date_i18n( $geodir_date_format, $end_datetime ); |
|
548 | - if ( $start_date == $end_date ) { |
|
549 | - $one_day = true; |
|
550 | - } |
|
551 | - } else { |
|
552 | - if ( $start_date == $end_date && $starttime == $endtime ) { |
|
553 | - $end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) ); |
|
554 | - $one_day = false; |
|
555 | - } |
|
556 | - $start_datetime = strtotime( $start_date . ' ' . $starttime ); |
|
557 | - $end_datetime = strtotime( $end_date . ' ' . $endtime ); |
|
546 | + $start_date = date_i18n( $geodir_date_format, $start_datetime ); |
|
547 | + $end_date = date_i18n( $geodir_date_format, $end_datetime ); |
|
548 | + if ( $start_date == $end_date ) { |
|
549 | + $one_day = true; |
|
550 | + } |
|
551 | + } else { |
|
552 | + if ( $start_date == $end_date && $starttime == $endtime ) { |
|
553 | + $end_date = date_i18n( 'Y-m-d', strtotime( $start_date . ' ' . $starttime . ' +1 day' ) ); |
|
554 | + $one_day = false; |
|
555 | + } |
|
556 | + $start_datetime = strtotime( $start_date . ' ' . $starttime ); |
|
557 | + $end_datetime = strtotime( $end_date . ' ' . $endtime ); |
|
558 | 558 | |
559 | - $start_date = date_i18n( $geodir_date_time_format, $start_datetime ); |
|
560 | - $end_date = date_i18n( $geodir_date_time_format, $end_datetime ); |
|
561 | - } |
|
559 | + $start_date = date_i18n( $geodir_date_time_format, $start_datetime ); |
|
560 | + $end_date = date_i18n( $geodir_date_time_format, $end_datetime ); |
|
561 | + } |
|
562 | 562 | |
563 | - if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) { |
|
564 | - $same_day = true; |
|
563 | + if ( !$one_day && date_i18n( 'Y-m-d', $start_datetime ) == date_i18n( 'Y-m-d', $end_datetime ) ) { |
|
564 | + $same_day = true; |
|
565 | 565 | |
566 | - $start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime ); |
|
567 | - } |
|
566 | + $start_date .= ' - ' . date_i18n( $geodir_time_format, $end_datetime ); |
|
567 | + } |
|
568 | 568 | |
569 | - $event_dates .= ' :: ' . $start_date; |
|
569 | + $event_dates .= ' :: ' . $start_date; |
|
570 | 570 | |
571 | - if ( !$same_day && !$one_day ) { |
|
572 | - $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date; |
|
573 | - } |
|
574 | - } |
|
575 | - } |
|
576 | - |
|
577 | - if (empty($event_dates)) { |
|
578 | - continue; |
|
579 | - } |
|
571 | + if ( !$same_day && !$one_day ) { |
|
572 | + $event_dates .= ' ' . __( 'to', 'geodirectory' ) . ' ' . $end_date; |
|
573 | + } |
|
574 | + } |
|
575 | + } |
|
576 | + |
|
577 | + if (empty($event_dates)) { |
|
578 | + continue; |
|
579 | + } |
|
580 | 580 | |
581 | - $post_title .= $event_dates; |
|
582 | - } |
|
581 | + $post_title .= $event_dates; |
|
582 | + } |
|
583 | 583 | |
584 | - $map_cat_ids_array; |
|
585 | - $default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : ''; |
|
584 | + $map_cat_ids_array; |
|
585 | + $default_cat = isset($catinfo_obj->default_category) ? $catinfo_obj->default_category : ''; |
|
586 | 586 | |
587 | - // if single cat lets just show that icon |
|
588 | - if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){ |
|
589 | - $default_cat = (int)$map_cat_ids_array[0]; |
|
590 | - } |
|
587 | + // if single cat lets just show that icon |
|
588 | + if(is_array($map_cat_ids_array) && count($map_cat_ids_array)==1){ |
|
589 | + $default_cat = (int)$map_cat_ids_array[0]; |
|
590 | + } |
|
591 | 591 | |
592 | - $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : ''; |
|
593 | - $mark_extra = (isset($catinfo_obj->marker_extra)) ? $catinfo_obj->marker_extra : ''; |
|
594 | - $title = str_replace($srcharr, $replarr, $post_title); |
|
592 | + $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$default_cat]) ? $geodir_cat_icons[$default_cat] : ''; |
|
593 | + $mark_extra = (isset($catinfo_obj->marker_extra)) ? $catinfo_obj->marker_extra : ''; |
|
594 | + $title = str_replace($srcharr, $replarr, $post_title); |
|
595 | 595 | |
596 | - if ($icon != '') { |
|
597 | - $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; |
|
596 | + if ($icon != '') { |
|
597 | + $gd_marker_sizes = empty($gd_marker_sizes) ? array() : $gd_marker_sizes; |
|
598 | 598 | |
599 | - if (isset($gd_marker_sizes[$icon])) { |
|
600 | - $icon_size = $gd_marker_sizes[$icon]; |
|
601 | - } else { |
|
602 | - $icon_size = geodir_get_marker_size($icon); |
|
603 | - $gd_marker_sizes[$icon] = $icon_size; |
|
604 | - } |
|
605 | - } else { |
|
606 | - $icon_size = array('w' => 36, 'h' => 45); |
|
607 | - } |
|
608 | - |
|
609 | - $content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}'; |
|
610 | - $post_ids[] = $catinfo_obj->post_id; |
|
611 | - } |
|
612 | - } |
|
613 | - |
|
614 | - /** |
|
615 | - * Called after marker data is processed into JSON. |
|
616 | - * |
|
617 | - * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
618 | - * |
|
619 | - * @since 1.4.9 |
|
620 | - * @param array $content_data The array containing all markers in JSON format. |
|
621 | - * @param object $catinfo The posts object containing all marker data. |
|
622 | - * @see 'geodir_before_marker_post_process' |
|
623 | - */ |
|
624 | - do_action('geodir_after_marker_post_process', $content_data, $catinfo); |
|
625 | - |
|
626 | - if (!empty($content_data)) { |
|
627 | - $cat_content_info[] = implode(',', $content_data); |
|
628 | - } |
|
629 | - |
|
630 | - $totalcount = count(array_unique($post_ids)); |
|
631 | - |
|
632 | - if (!empty($cat_content_info)) { |
|
633 | - $map_json = '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']'; |
|
634 | - } |
|
635 | - else { |
|
636 | - $map_json = '[{"totalcount":"0"}]'; |
|
637 | - } |
|
638 | - |
|
639 | - |
|
640 | - /** |
|
641 | - * Filter the marker json return. |
|
642 | - * |
|
643 | - * @since 1.6.22 |
|
644 | - * @param string $map_json The JSON string of the map markers results. |
|
645 | - */ |
|
646 | - return apply_filters('geodir_markers_json',$map_json); |
|
599 | + if (isset($gd_marker_sizes[$icon])) { |
|
600 | + $icon_size = $gd_marker_sizes[$icon]; |
|
601 | + } else { |
|
602 | + $icon_size = geodir_get_marker_size($icon); |
|
603 | + $gd_marker_sizes[$icon] = $icon_size; |
|
604 | + } |
|
605 | + } else { |
|
606 | + $icon_size = array('w' => 36, 'h' => 45); |
|
607 | + } |
|
608 | + |
|
609 | + $content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $default_cat . '","i":"' . $icon . '","w":"' . $icon_size['w'] . '","h":"' . $icon_size['h'] . '"'.$mark_extra.'}'; |
|
610 | + $post_ids[] = $catinfo_obj->post_id; |
|
611 | + } |
|
612 | + } |
|
613 | + |
|
614 | + /** |
|
615 | + * Called after marker data is processed into JSON. |
|
616 | + * |
|
617 | + * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers. |
|
618 | + * |
|
619 | + * @since 1.4.9 |
|
620 | + * @param array $content_data The array containing all markers in JSON format. |
|
621 | + * @param object $catinfo The posts object containing all marker data. |
|
622 | + * @see 'geodir_before_marker_post_process' |
|
623 | + */ |
|
624 | + do_action('geodir_after_marker_post_process', $content_data, $catinfo); |
|
625 | + |
|
626 | + if (!empty($content_data)) { |
|
627 | + $cat_content_info[] = implode(',', $content_data); |
|
628 | + } |
|
629 | + |
|
630 | + $totalcount = count(array_unique($post_ids)); |
|
631 | + |
|
632 | + if (!empty($cat_content_info)) { |
|
633 | + $map_json = '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']'; |
|
634 | + } |
|
635 | + else { |
|
636 | + $map_json = '[{"totalcount":"0"}]'; |
|
637 | + } |
|
638 | + |
|
639 | + |
|
640 | + /** |
|
641 | + * Filter the marker json return. |
|
642 | + * |
|
643 | + * @since 1.6.22 |
|
644 | + * @param string $map_json The JSON string of the map markers results. |
|
645 | + */ |
|
646 | + return apply_filters('geodir_markers_json',$map_json); |
|
647 | 647 | } |
648 | 648 | |
649 | 649 |
@@ -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 | ' . __(geodir_utf8_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 | ' . __(geodir_utf8_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="' . $sub_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="' . $sub_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 | |
@@ -402,52 +402,52 @@ discard block |
||
402 | 402 | * @return string The post type. |
403 | 403 | */ |
404 | 404 | function geodir_get_current_posttype() { |
405 | - global $wp_query, $post, $geodir_post_type; |
|
405 | + global $wp_query, $post, $geodir_post_type; |
|
406 | 406 | |
407 | - $geodir_post_type = get_query_var('post_type'); |
|
407 | + $geodir_post_type = get_query_var('post_type'); |
|
408 | 408 | if (is_array($geodir_post_type) && ! empty($geodir_post_type[0])) { |
409 | 409 | $geodir_post_type = $geodir_post_type[0]; |
410 | 410 | } |
411 | 411 | |
412 | - if (geodir_is_page('add-listing') || geodir_is_page('preview')) { |
|
413 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
414 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
415 | - elseif (isset($_REQUEST['listing_type'])) |
|
416 | - $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
417 | - } |
|
418 | - |
|
419 | - if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) |
|
420 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
421 | - |
|
422 | - if (is_tax()) |
|
423 | - $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
424 | - |
|
425 | - // Retrive post type for map marker html ajax request on preview page. |
|
426 | - if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) { |
|
427 | - if (!empty($post->post_type)) { |
|
428 | - $geodir_post_type = $post->post_type; |
|
429 | - } else if (!empty($post->listing_type)) { |
|
430 | - $geodir_post_type = $post->listing_type; |
|
431 | - } |
|
432 | - } |
|
433 | - |
|
434 | - $all_postypes = geodir_get_posttypes(); |
|
435 | - $all_postypes = stripslashes_deep($all_postypes); |
|
436 | - |
|
437 | - if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
438 | - $geodir_post_type = ''; |
|
439 | - |
|
440 | - if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){ |
|
441 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
442 | - } |
|
443 | - |
|
444 | - |
|
445 | - /** |
|
446 | - * Filter the default CPT return. |
|
447 | - * |
|
448 | - * @since 1.6.9 |
|
449 | - */ |
|
450 | - return apply_filters('geodir_get_current_posttype',$geodir_post_type); |
|
412 | + if (geodir_is_page('add-listing') || geodir_is_page('preview')) { |
|
413 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
414 | + $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
415 | + elseif (isset($_REQUEST['listing_type'])) |
|
416 | + $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
417 | + } |
|
418 | + |
|
419 | + if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) |
|
420 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
421 | + |
|
422 | + if (is_tax()) |
|
423 | + $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
424 | + |
|
425 | + // Retrive post type for map marker html ajax request on preview page. |
|
426 | + if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) { |
|
427 | + if (!empty($post->post_type)) { |
|
428 | + $geodir_post_type = $post->post_type; |
|
429 | + } else if (!empty($post->listing_type)) { |
|
430 | + $geodir_post_type = $post->listing_type; |
|
431 | + } |
|
432 | + } |
|
433 | + |
|
434 | + $all_postypes = geodir_get_posttypes(); |
|
435 | + $all_postypes = stripslashes_deep($all_postypes); |
|
436 | + |
|
437 | + if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
438 | + $geodir_post_type = ''; |
|
439 | + |
|
440 | + if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){ |
|
441 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
442 | + } |
|
443 | + |
|
444 | + |
|
445 | + /** |
|
446 | + * Filter the default CPT return. |
|
447 | + * |
|
448 | + * @since 1.6.9 |
|
449 | + */ |
|
450 | + return apply_filters('geodir_get_current_posttype',$geodir_post_type); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -461,22 +461,22 @@ discard block |
||
461 | 461 | */ |
462 | 462 | function geodir_get_default_posttype() |
463 | 463 | { |
464 | - $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
465 | - |
|
466 | - $stype = false; |
|
467 | - foreach ( $post_types as $post_type => $info ) { |
|
468 | - global $wpdb; |
|
469 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
470 | - if ( $has_posts ) { |
|
471 | - $stype = $post_type; break; |
|
472 | - } |
|
473 | - } |
|
474 | - |
|
475 | - if(!$stype){ |
|
476 | - $stype = 'gd_place'; |
|
477 | - } |
|
478 | - |
|
479 | - return $stype; |
|
464 | + $post_types = apply_filters( 'geodir_get_default_posttype', geodir_get_posttypes( 'object' ) ); |
|
465 | + |
|
466 | + $stype = false; |
|
467 | + foreach ( $post_types as $post_type => $info ) { |
|
468 | + global $wpdb; |
|
469 | + $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
470 | + if ( $has_posts ) { |
|
471 | + $stype = $post_type; break; |
|
472 | + } |
|
473 | + } |
|
474 | + |
|
475 | + if(!$stype){ |
|
476 | + $stype = 'gd_place'; |
|
477 | + } |
|
478 | + |
|
479 | + return $stype; |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | /** |
@@ -490,21 +490,21 @@ discard block |
||
490 | 490 | */ |
491 | 491 | function geodir_get_posttypes($output = 'names') |
492 | 492 | { |
493 | - $post_types = array(); |
|
494 | - $post_types = get_option('geodir_post_types'); |
|
495 | - $post_types = stripslashes_deep($post_types); |
|
496 | - if (!empty($post_types)) { |
|
497 | - switch ($output): |
|
498 | - case 'object': |
|
499 | - case 'Object': |
|
500 | - $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
501 | - break; |
|
502 | - case 'array': |
|
503 | - case 'Array': |
|
504 | - $post_types = (array)$post_types; |
|
505 | - break; |
|
493 | + $post_types = array(); |
|
494 | + $post_types = get_option('geodir_post_types'); |
|
495 | + $post_types = stripslashes_deep($post_types); |
|
496 | + if (!empty($post_types)) { |
|
497 | + switch ($output): |
|
498 | + case 'object': |
|
499 | + case 'Object': |
|
500 | + $post_types = json_decode(json_encode($post_types), FALSE);//(object)$post_types; |
|
501 | + break; |
|
502 | + case 'array': |
|
503 | + case 'Array': |
|
504 | + $post_types = (array)$post_types; |
|
505 | + break; |
|
506 | 506 | case 'options': |
507 | - $post_types = (array)$post_types; |
|
507 | + $post_types = (array)$post_types; |
|
508 | 508 | |
509 | 509 | $options = array(); |
510 | 510 | if (!empty($post_types)) { |
@@ -513,17 +513,17 @@ discard block |
||
513 | 513 | } |
514 | 514 | } |
515 | 515 | $post_types = $options; |
516 | - break; |
|
517 | - default: |
|
518 | - $post_types = array_keys($post_types); |
|
519 | - break; |
|
520 | - endswitch; |
|
521 | - } |
|
522 | - |
|
523 | - if (!empty($post_types)) |
|
524 | - return $post_types; |
|
525 | - else |
|
526 | - return array(); |
|
516 | + break; |
|
517 | + default: |
|
518 | + $post_types = array_keys($post_types); |
|
519 | + break; |
|
520 | + endswitch; |
|
521 | + } |
|
522 | + |
|
523 | + if (!empty($post_types)) |
|
524 | + return $post_types; |
|
525 | + else |
|
526 | + return array(); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -536,104 +536,104 @@ discard block |
||
536 | 536 | */ |
537 | 537 | function geodir_get_posttype_info($post_type = '') |
538 | 538 | { |
539 | - $post_types = array(); |
|
540 | - $post_types = get_option('geodir_post_types'); |
|
541 | - $post_types = stripslashes_deep($post_types); |
|
542 | - if (!empty($post_types) && $post_type != '') { |
|
543 | - return $post_types[$post_type]; |
|
544 | - } else |
|
545 | - return false; |
|
539 | + $post_types = array(); |
|
540 | + $post_types = get_option('geodir_post_types'); |
|
541 | + $post_types = stripslashes_deep($post_types); |
|
542 | + if (!empty($post_types) && $post_type != '') { |
|
543 | + return $post_types[$post_type]; |
|
544 | + } else |
|
545 | + return false; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | if (!function_exists('geodir_get_taxonomies')) { |
549 | - /** |
|
550 | - * Get all custom taxonomies. |
|
551 | - * |
|
552 | - * @since 1.0.0 |
|
553 | - * @package GeoDirectory |
|
554 | - * @param string $post_type The post type. |
|
555 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
556 | - * @return array|bool Taxonomies on success. false on failure. |
|
557 | - */ |
|
558 | - function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) { |
|
559 | - $taxonomies = array(); |
|
560 | - $gd_taxonomies = array(); |
|
561 | - |
|
562 | - if ($taxonomies = get_option('geodir_taxonomies')) { |
|
563 | - $gd_taxonomies = array_keys($taxonomies); |
|
564 | - |
|
565 | - if ($post_type != '') { |
|
566 | - $gd_taxonomies = array(); |
|
567 | - } |
|
549 | + /** |
|
550 | + * Get all custom taxonomies. |
|
551 | + * |
|
552 | + * @since 1.0.0 |
|
553 | + * @package GeoDirectory |
|
554 | + * @param string $post_type The post type. |
|
555 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
556 | + * @return array|bool Taxonomies on success. false on failure. |
|
557 | + */ |
|
558 | + function geodir_get_taxonomies($post_type = '', $tages_taxonomies = false) { |
|
559 | + $taxonomies = array(); |
|
560 | + $gd_taxonomies = array(); |
|
561 | + |
|
562 | + if ($taxonomies = get_option('geodir_taxonomies')) { |
|
563 | + $gd_taxonomies = array_keys($taxonomies); |
|
564 | + |
|
565 | + if ($post_type != '') { |
|
566 | + $gd_taxonomies = array(); |
|
567 | + } |
|
568 | 568 | |
569 | - $i = 0; |
|
570 | - foreach ($taxonomies as $taxonomy => $args) { |
|
571 | - if ($post_type != '' && $args['object_type'] == $post_type) { |
|
572 | - $gd_taxonomies[] = $taxonomy; |
|
573 | - } |
|
569 | + $i = 0; |
|
570 | + foreach ($taxonomies as $taxonomy => $args) { |
|
571 | + if ($post_type != '' && $args['object_type'] == $post_type) { |
|
572 | + $gd_taxonomies[] = $taxonomy; |
|
573 | + } |
|
574 | 574 | |
575 | - if ($tages_taxonomies === false && substr($taxonomy , -5) == '_tags') { |
|
576 | - if (array_search($taxonomy, $gd_taxonomies) !== false) { |
|
577 | - unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
578 | - } |
|
579 | - } |
|
580 | - } |
|
575 | + if ($tages_taxonomies === false && substr($taxonomy , -5) == '_tags') { |
|
576 | + if (array_search($taxonomy, $gd_taxonomies) !== false) { |
|
577 | + unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]); |
|
578 | + } |
|
579 | + } |
|
580 | + } |
|
581 | + |
|
582 | + $gd_taxonomies = array_values($gd_taxonomies); |
|
583 | + } |
|
581 | 584 | |
582 | - $gd_taxonomies = array_values($gd_taxonomies); |
|
583 | - } |
|
584 | - |
|
585 | - /** |
|
586 | - * Filter the taxonomies. |
|
587 | - * |
|
588 | - * @since 1.0.0 |
|
589 | - * @param array $gd_taxonomies The taxonomy array. |
|
590 | - */ |
|
591 | - $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies); |
|
592 | - |
|
593 | - if (!empty($taxonomies)) { |
|
594 | - return $taxonomies; |
|
595 | - } else { |
|
596 | - return false; |
|
597 | - } |
|
598 | - } |
|
585 | + /** |
|
586 | + * Filter the taxonomies. |
|
587 | + * |
|
588 | + * @since 1.0.0 |
|
589 | + * @param array $gd_taxonomies The taxonomy array. |
|
590 | + */ |
|
591 | + $taxonomies = apply_filters('geodir_taxonomy', $gd_taxonomies); |
|
592 | + |
|
593 | + if (!empty($taxonomies)) { |
|
594 | + return $taxonomies; |
|
595 | + } else { |
|
596 | + return false; |
|
597 | + } |
|
598 | + } |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | if (!function_exists(' geodir_get_categories_dl')) { |
602 | - /** |
|
603 | - * Get categories dropdown HTML. |
|
604 | - * |
|
605 | - * @since 1.0.0 |
|
606 | - * @package GeoDirectory |
|
607 | - * @param string $post_type The post type. |
|
608 | - * @param string $selected The selected value. |
|
609 | - * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
610 | - * @param bool $echo Prints the HTML when set to true. Default: true. |
|
611 | - * @return void|string Dropdown HTML. |
|
612 | - */ |
|
613 | - function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
614 | - { |
|
615 | - |
|
616 | - $html = ''; |
|
617 | - $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
618 | - |
|
619 | - $categories = get_terms($taxonomies); |
|
620 | - |
|
621 | - $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>'; |
|
622 | - |
|
623 | - foreach ($categories as $category_obj) { |
|
624 | - $select_opt = ''; |
|
625 | - if ($selected == $category_obj->term_id) { |
|
626 | - $select_opt = 'selected="selected"'; |
|
627 | - } |
|
628 | - $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
629 | - . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
|
630 | - } |
|
631 | - |
|
632 | - if ($echo) |
|
633 | - echo $html; |
|
634 | - else |
|
635 | - return $html; |
|
636 | - } |
|
602 | + /** |
|
603 | + * Get categories dropdown HTML. |
|
604 | + * |
|
605 | + * @since 1.0.0 |
|
606 | + * @package GeoDirectory |
|
607 | + * @param string $post_type The post type. |
|
608 | + * @param string $selected The selected value. |
|
609 | + * @param bool $tages_taxonomies Is this a tag taxonomy?. Default: false. |
|
610 | + * @param bool $echo Prints the HTML when set to true. Default: true. |
|
611 | + * @return void|string Dropdown HTML. |
|
612 | + */ |
|
613 | + function geodir_get_categories_dl($post_type = '', $selected = '', $tages_taxonomies = false, $echo = true) |
|
614 | + { |
|
615 | + |
|
616 | + $html = ''; |
|
617 | + $taxonomies = geodir_get_taxonomies($post_type, $tages_taxonomies); |
|
618 | + |
|
619 | + $categories = get_terms($taxonomies); |
|
620 | + |
|
621 | + $html .= '<option value="0">' . __('All', 'geodirectory') . '</option>'; |
|
622 | + |
|
623 | + foreach ($categories as $category_obj) { |
|
624 | + $select_opt = ''; |
|
625 | + if ($selected == $category_obj->term_id) { |
|
626 | + $select_opt = 'selected="selected"'; |
|
627 | + } |
|
628 | + $html .= '<option ' . $select_opt . ' value="' . $category_obj->term_id . '">' |
|
629 | + . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
|
630 | + } |
|
631 | + |
|
632 | + if ($echo) |
|
633 | + echo $html; |
|
634 | + else |
|
635 | + return $html; |
|
636 | + } |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | |
@@ -648,28 +648,28 @@ discard block |
||
648 | 648 | function geodir_get_listing_slug($object_type = '') |
649 | 649 | { |
650 | 650 | |
651 | - $listing_slug = ''; |
|
651 | + $listing_slug = ''; |
|
652 | 652 | |
653 | - $post_types = get_option('geodir_post_types'); |
|
654 | - $taxonomies = get_option('geodir_taxonomies'); |
|
653 | + $post_types = get_option('geodir_post_types'); |
|
654 | + $taxonomies = get_option('geodir_taxonomies'); |
|
655 | 655 | |
656 | 656 | |
657 | - if ($object_type != '') { |
|
658 | - if (!empty($post_types) && array_key_exists($object_type, $post_types)) { |
|
657 | + if ($object_type != '') { |
|
658 | + if (!empty($post_types) && array_key_exists($object_type, $post_types)) { |
|
659 | 659 | |
660 | - $object_info = $post_types[$object_type]; |
|
661 | - $listing_slug = $object_info['listing_slug']; |
|
662 | - } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) { |
|
663 | - $object_info = $taxonomies[$object_type]; |
|
664 | - $listing_slug = $object_info['listing_slug']; |
|
665 | - } |
|
660 | + $object_info = $post_types[$object_type]; |
|
661 | + $listing_slug = $object_info['listing_slug']; |
|
662 | + } elseif (!empty($taxonomies) && array_key_exists($object_type, $taxonomies)) { |
|
663 | + $object_info = $taxonomies[$object_type]; |
|
664 | + $listing_slug = $object_info['listing_slug']; |
|
665 | + } |
|
666 | 666 | |
667 | - } |
|
667 | + } |
|
668 | 668 | |
669 | - if (!empty($listing_slug)) |
|
670 | - return $listing_slug; |
|
671 | - else |
|
672 | - return false; |
|
669 | + if (!empty($listing_slug)) |
|
670 | + return $listing_slug; |
|
671 | + else |
|
672 | + return false; |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | |
@@ -684,212 +684,212 @@ discard block |
||
684 | 684 | */ |
685 | 685 | function geodir_get_taxonomy_posttype($taxonomy = '') |
686 | 686 | { |
687 | - global $wp_query; |
|
688 | - |
|
689 | - $post_type = array(); |
|
690 | - $taxonomies = array(); |
|
691 | - |
|
692 | - if (!empty($taxonomy)) { |
|
693 | - $taxonomies[] = $taxonomy; |
|
694 | - } elseif (isset($wp_query->tax_query->queries)) { |
|
695 | - $tax_arr = $wp_query->tax_query->queries; |
|
696 | - //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
697 | - if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);} |
|
698 | - $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
699 | - } |
|
700 | - |
|
701 | - if (!empty($taxonomies)) { |
|
702 | - foreach (geodir_get_posttypes() as $pt) { |
|
703 | - $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
704 | - if (array_intersect($taxonomies, $object_taxonomies)) |
|
705 | - $post_type[] = $pt; |
|
706 | - } |
|
707 | - } |
|
708 | - |
|
709 | - if (!empty($post_type)) |
|
710 | - return $post_type[0]; |
|
711 | - else |
|
712 | - return false; |
|
687 | + global $wp_query; |
|
688 | + |
|
689 | + $post_type = array(); |
|
690 | + $taxonomies = array(); |
|
691 | + |
|
692 | + if (!empty($taxonomy)) { |
|
693 | + $taxonomies[] = $taxonomy; |
|
694 | + } elseif (isset($wp_query->tax_query->queries)) { |
|
695 | + $tax_arr = $wp_query->tax_query->queries; |
|
696 | + //if tax query has 'relation' set then it will break wp_list_pluck so we remove it |
|
697 | + if(isset( $tax_arr['relation'])){unset( $tax_arr['relation']);} |
|
698 | + $taxonomies = wp_list_pluck($tax_arr, 'taxonomy'); |
|
699 | + } |
|
700 | + |
|
701 | + if (!empty($taxonomies)) { |
|
702 | + foreach (geodir_get_posttypes() as $pt) { |
|
703 | + $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
|
704 | + if (array_intersect($taxonomies, $object_taxonomies)) |
|
705 | + $post_type[] = $pt; |
|
706 | + } |
|
707 | + } |
|
708 | + |
|
709 | + if (!empty($post_type)) |
|
710 | + return $post_type[0]; |
|
711 | + else |
|
712 | + return false; |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | if (!function_exists('geodir_custom_taxonomy_walker')) { |
716 | - /** |
|
717 | - * Custom taxonomy walker function. |
|
718 | - * |
|
719 | - * @since 1.0.0 |
|
720 | - * @package GeoDirectory |
|
721 | - * @param string $cat_taxonomy The taxonomy name. |
|
722 | - * @param int $cat_parent The parent term ID. |
|
723 | - * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
724 | - * @param int $pading CSS padding in pixels. |
|
725 | - * @return string|void taxonomy HTML. |
|
726 | - */ |
|
727 | - function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
728 | - { |
|
729 | - global $cat_display, $post_cat, $exclude_cats; |
|
730 | - |
|
731 | - $search_terms = trim($post_cat, ","); |
|
732 | - |
|
733 | - $search_terms = explode(",", $search_terms); |
|
734 | - |
|
735 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats)); |
|
736 | - |
|
737 | - $display = ''; |
|
738 | - $onchange = ''; |
|
739 | - $term_check = ''; |
|
740 | - $main_list_class = ''; |
|
741 | - $out = ''; |
|
742 | - //If there are terms, start displaying |
|
743 | - if (count($cat_terms) > 0) { |
|
744 | - //Displaying as a list |
|
745 | - $p = $pading * 20; |
|
746 | - $pading++; |
|
747 | - |
|
748 | - |
|
749 | - if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) { |
|
750 | - if ($cat_parent == 0) { |
|
751 | - $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
752 | - $main_list_class = 'class="main_list_selecter"'; |
|
753 | - } else { |
|
754 | - //$display = 'display:none'; |
|
755 | - $list_class = 'sub_list gd-sub-cats-list'; |
|
756 | - } |
|
757 | - } |
|
716 | + /** |
|
717 | + * Custom taxonomy walker function. |
|
718 | + * |
|
719 | + * @since 1.0.0 |
|
720 | + * @package GeoDirectory |
|
721 | + * @param string $cat_taxonomy The taxonomy name. |
|
722 | + * @param int $cat_parent The parent term ID. |
|
723 | + * @param bool $hide_empty Hide empty taxonomies? Default: false. |
|
724 | + * @param int $pading CSS padding in pixels. |
|
725 | + * @return string|void taxonomy HTML. |
|
726 | + */ |
|
727 | + function geodir_custom_taxonomy_walker($cat_taxonomy, $cat_parent = 0, $hide_empty = false, $pading = 0) |
|
728 | + { |
|
729 | + global $cat_display, $post_cat, $exclude_cats; |
|
730 | + |
|
731 | + $search_terms = trim($post_cat, ","); |
|
732 | + |
|
733 | + $search_terms = explode(",", $search_terms); |
|
734 | + |
|
735 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $cat_parent, 'hide_empty' => $hide_empty, 'exclude' => $exclude_cats)); |
|
736 | + |
|
737 | + $display = ''; |
|
738 | + $onchange = ''; |
|
739 | + $term_check = ''; |
|
740 | + $main_list_class = ''; |
|
741 | + $out = ''; |
|
742 | + //If there are terms, start displaying |
|
743 | + if (count($cat_terms) > 0) { |
|
744 | + //Displaying as a list |
|
745 | + $p = $pading * 20; |
|
746 | + $pading++; |
|
747 | + |
|
748 | + |
|
749 | + if ((!geodir_is_page('listing')) || (is_search() && $_REQUEST['search_taxonomy'] == '')) { |
|
750 | + if ($cat_parent == 0) { |
|
751 | + $list_class = 'main_list gd-parent-cats-list gd-cats-display-' . $cat_display; |
|
752 | + $main_list_class = 'class="main_list_selecter"'; |
|
753 | + } else { |
|
754 | + //$display = 'display:none'; |
|
755 | + $list_class = 'sub_list gd-sub-cats-list'; |
|
756 | + } |
|
757 | + } |
|
758 | 758 | |
759 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') { |
|
760 | - $p = 0; |
|
761 | - $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
762 | - } |
|
759 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') { |
|
760 | + $p = 0; |
|
761 | + $out = '<div class="' . $list_class . ' gd-cat-row-' . $cat_parent . '" style="margin-left:' . $p . 'px;' . $display . ';">'; |
|
762 | + } |
|
763 | 763 | |
764 | - foreach ($cat_terms as $cat_term) { |
|
764 | + foreach ($cat_terms as $cat_term) { |
|
765 | 765 | |
766 | - $checked = ''; |
|
766 | + $checked = ''; |
|
767 | 767 | |
768 | - if (in_array($cat_term->term_id, $search_terms)) { |
|
769 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
770 | - $checked = 'selected="selected"'; |
|
771 | - else |
|
772 | - $checked = 'checked="checked"'; |
|
773 | - } |
|
768 | + if (in_array($cat_term->term_id, $search_terms)) { |
|
769 | + if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
770 | + $checked = 'selected="selected"'; |
|
771 | + else |
|
772 | + $checked = 'checked="checked"'; |
|
773 | + } |
|
774 | 774 | |
775 | - if ($cat_display == 'radio') |
|
776 | - $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="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
777 | - elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
778 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
775 | + if ($cat_display == 'radio') |
|
776 | + $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="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
777 | + elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
778 | + $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
779 | 779 | |
780 | - else { |
|
781 | - $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="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
782 | - } |
|
780 | + else { |
|
781 | + $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="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
782 | + } |
|
783 | 783 | |
784 | - // Call recurson to print sub cats |
|
785 | - $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
784 | + // Call recurson to print sub cats |
|
785 | + $out .= geodir_custom_taxonomy_walker($cat_taxonomy, $cat_term->term_id, $hide_empty, $pading); |
|
786 | 786 | |
787 | - } |
|
787 | + } |
|
788 | 788 | |
789 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
790 | - $out .= '</div>'; |
|
789 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
790 | + $out .= '</div>'; |
|
791 | 791 | |
792 | - return $out; |
|
793 | - } |
|
794 | - return; |
|
795 | - } |
|
792 | + return $out; |
|
793 | + } |
|
794 | + return; |
|
795 | + } |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | if (!function_exists('geodir_custom_taxonomy_walker2')) { |
799 | - /** |
|
800 | - * Custom taxonomy walker function. |
|
801 | - * |
|
802 | - * @since 1.0.0 |
|
803 | - * @package GeoDirectory |
|
804 | - * @global object $post WordPress Post object. |
|
805 | - * @global object $gd_session GeoDirectory Session object. |
|
806 | - * @param string $cat_taxonomy The taxonomy name. |
|
807 | - * @param string $cat_limit Number of categories to display. |
|
808 | - */ |
|
809 | - function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
810 | - { |
|
811 | - $post_category = ''; |
|
812 | - $post_category_str = ''; |
|
813 | - global $exclude_cats, $gd_session; |
|
814 | - |
|
815 | - $cat_exclude = ''; |
|
816 | - if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
817 | - $cat_exclude = serialize($exclude_cats); |
|
818 | - |
|
819 | - if (isset($_REQUEST['backandedit'])) { |
|
820 | - $post = (object)$gd_session->get('listing'); |
|
821 | - |
|
822 | - if (!is_array($post->post_category[$cat_taxonomy])) |
|
823 | - $post_category = $post->post_category[$cat_taxonomy]; |
|
824 | - |
|
825 | - $post_categories = $post->post_category_str; |
|
826 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
827 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
828 | - |
|
829 | - } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) { |
|
830 | - global $post; |
|
831 | - |
|
832 | - $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
833 | - if (empty($post_category) && isset($post->{$cat_taxonomy})) { |
|
834 | - $post_category = $post->{$cat_taxonomy}; |
|
835 | - } |
|
799 | + /** |
|
800 | + * Custom taxonomy walker function. |
|
801 | + * |
|
802 | + * @since 1.0.0 |
|
803 | + * @package GeoDirectory |
|
804 | + * @global object $post WordPress Post object. |
|
805 | + * @global object $gd_session GeoDirectory Session object. |
|
806 | + * @param string $cat_taxonomy The taxonomy name. |
|
807 | + * @param string $cat_limit Number of categories to display. |
|
808 | + */ |
|
809 | + function geodir_custom_taxonomy_walker2($cat_taxonomy, $cat_limit = '') |
|
810 | + { |
|
811 | + $post_category = ''; |
|
812 | + $post_category_str = ''; |
|
813 | + global $exclude_cats, $gd_session; |
|
814 | + |
|
815 | + $cat_exclude = ''; |
|
816 | + if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
817 | + $cat_exclude = serialize($exclude_cats); |
|
818 | + |
|
819 | + if (isset($_REQUEST['backandedit'])) { |
|
820 | + $post = (object)$gd_session->get('listing'); |
|
821 | + |
|
822 | + if (!is_array($post->post_category[$cat_taxonomy])) |
|
823 | + $post_category = $post->post_category[$cat_taxonomy]; |
|
824 | + |
|
825 | + $post_categories = $post->post_category_str; |
|
826 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
827 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
828 | + |
|
829 | + } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) { |
|
830 | + global $post; |
|
831 | + |
|
832 | + $post_category = geodir_get_post_meta($post->ID, $cat_taxonomy, true); |
|
833 | + if (empty($post_category) && isset($post->{$cat_taxonomy})) { |
|
834 | + $post_category = $post->{$cat_taxonomy}; |
|
835 | + } |
|
836 | 836 | |
837 | - $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
837 | + $post_categories = get_post_meta($post->ID, 'post_categories', true); |
|
838 | 838 | |
839 | - if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) { |
|
840 | - foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) { |
|
841 | - if (is_numeric($cat_part)) { |
|
842 | - $cat_part_arr[] = $cat_part; |
|
843 | - } |
|
844 | - } |
|
845 | - if (is_array($cat_part_arr)) { |
|
846 | - $post_category = implode(',', $cat_part_arr); |
|
847 | - } |
|
848 | - } |
|
839 | + if (empty($post_category) && !empty($post_categories) && !empty($post_categories[$cat_taxonomy])) { |
|
840 | + foreach (explode(",", $post_categories[$cat_taxonomy]) as $cat_part) { |
|
841 | + if (is_numeric($cat_part)) { |
|
842 | + $cat_part_arr[] = $cat_part; |
|
843 | + } |
|
844 | + } |
|
845 | + if (is_array($cat_part_arr)) { |
|
846 | + $post_category = implode(',', $cat_part_arr); |
|
847 | + } |
|
848 | + } |
|
849 | 849 | |
850 | - if (!empty($post_category)) { |
|
851 | - $cat1 = array_filter(explode(',', $post_category)); |
|
852 | - $post_category = ',' . implode(',', $cat1) . ','; |
|
850 | + if (!empty($post_category)) { |
|
851 | + $cat1 = array_filter(explode(',', $post_category)); |
|
852 | + $post_category = ',' . implode(',', $cat1) . ','; |
|
853 | 853 | |
854 | - } |
|
854 | + } |
|
855 | 855 | |
856 | - if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) { |
|
856 | + if ($post_category != '' && is_array($exclude_cats) && !empty($exclude_cats)) { |
|
857 | 857 | |
858 | - $post_category_upd = explode(',', $post_category); |
|
859 | - $post_category_change = ''; |
|
860 | - foreach ($post_category_upd as $cat) { |
|
858 | + $post_category_upd = explode(',', $post_category); |
|
859 | + $post_category_change = ''; |
|
860 | + foreach ($post_category_upd as $cat) { |
|
861 | 861 | |
862 | - if (!in_array($cat, $exclude_cats) && $cat != '') { |
|
863 | - $post_category_change .= ',' . $cat; |
|
864 | - } |
|
865 | - } |
|
866 | - $post_category = $post_category_change; |
|
867 | - } |
|
862 | + if (!in_array($cat, $exclude_cats) && $cat != '') { |
|
863 | + $post_category_change .= ',' . $cat; |
|
864 | + } |
|
865 | + } |
|
866 | + $post_category = $post_category_change; |
|
867 | + } |
|
868 | 868 | |
869 | 869 | |
870 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
871 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
872 | - } |
|
873 | - } |
|
870 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
871 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
872 | + } |
|
873 | + } |
|
874 | 874 | |
875 | - echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
875 | + echo '<input type="hidden" id="cat_limit" value="' . $cat_limit . '" name="cat_limit[' . $cat_taxonomy . ']" />'; |
|
876 | 876 | |
877 | - echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
877 | + echo '<input type="hidden" id="post_category" value="' . $post_category . '" name="post_category[' . $cat_taxonomy . ']" />'; |
|
878 | 878 | |
879 | - echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
879 | + echo '<input type="hidden" id="post_category_str" value="' . $post_category_str . '" name="post_category_str[' . $cat_taxonomy . ']" />'; |
|
880 | 880 | |
881 | 881 | |
882 | - ?> |
|
882 | + ?> |
|
883 | 883 | <div class="cat_sublist"> |
884 | 884 | <?php |
885 | 885 | |
886 | - $post_id = isset($post->ID) ? $post->ID : ''; |
|
886 | + $post_id = isset($post->ID) ? $post->ID : ''; |
|
887 | 887 | |
888 | - if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) { |
|
888 | + if ((geodir_is_page('add-listing') || is_admin()) && !empty($post_categories[$cat_taxonomy])) { |
|
889 | 889 | |
890 | - geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
891 | - } |
|
892 | - ?> |
|
890 | + geodir_editpost_categories_html($cat_taxonomy, $post_id, $post_categories); |
|
891 | + } |
|
892 | + ?> |
|
893 | 893 | </div> |
894 | 894 | <script type="text/javascript"> |
895 | 895 | |
@@ -1012,22 +1012,22 @@ discard block |
||
1012 | 1012 | |
1013 | 1013 | </script> |
1014 | 1014 | <?php |
1015 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
1016 | - $post_cat_str = $post_categories[$cat_taxonomy]; |
|
1017 | - $post_cat_array = explode("#", $post_cat_str); |
|
1018 | - if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
1019 | - $style = "display:none;"; |
|
1020 | - } |
|
1021 | - ?> |
|
1015 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
1016 | + $post_cat_str = $post_categories[$cat_taxonomy]; |
|
1017 | + $post_cat_array = explode("#", $post_cat_str); |
|
1018 | + if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
1019 | + $style = "display:none;"; |
|
1020 | + } |
|
1021 | + ?> |
|
1022 | 1022 | <div class="main_cat_list" style=" <?php if (isset($style)) { |
1023 | - echo $style; |
|
1024 | - }?> "> |
|
1023 | + echo $style; |
|
1024 | + }?> "> |
|
1025 | 1025 | <?php geodir_get_catlist($cat_taxonomy, 0); // print main categories list |
1026 | - ?> |
|
1026 | + ?> |
|
1027 | 1027 | </div> |
1028 | 1028 | <?php |
1029 | 1029 | |
1030 | - } |
|
1030 | + } |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | /** |
@@ -1044,23 +1044,23 @@ discard block |
||
1044 | 1044 | */ |
1045 | 1045 | function geodir_addpost_categories_html($request_taxonomy, $parrent, $selected = false, $main_selected = true, $default = false, $exclude = '') |
1046 | 1046 | { |
1047 | - global $exclude_cats; |
|
1047 | + global $exclude_cats; |
|
1048 | 1048 | |
1049 | - if ($exclude != '') { |
|
1050 | - $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
1049 | + if ($exclude != '') { |
|
1050 | + $exclude_cats = maybe_unserialize(base64_decode($exclude)); |
|
1051 | 1051 | |
1052 | - if(is_array( $exclude_cats)){ |
|
1053 | - $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
1054 | - }else{ |
|
1055 | - $exclude_cats = intval($exclude_cats); |
|
1056 | - } |
|
1052 | + if(is_array( $exclude_cats)){ |
|
1053 | + $exclude_cats = array_map( 'intval', $exclude_cats ); |
|
1054 | + }else{ |
|
1055 | + $exclude_cats = intval($exclude_cats); |
|
1056 | + } |
|
1057 | 1057 | |
1058 | - } |
|
1058 | + } |
|
1059 | 1059 | |
1060 | - if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
1061 | - (!is_array($exclude_cats) || empty($exclude_cats)) |
|
1062 | - ) { |
|
1063 | - ?> |
|
1060 | + if ((is_array($exclude_cats) && !empty($exclude_cats) && !in_array($parrent, $exclude_cats)) || |
|
1061 | + (!is_array($exclude_cats) || empty($exclude_cats)) |
|
1062 | + ) { |
|
1063 | + ?> |
|
1064 | 1064 | |
1065 | 1065 | <?php $main_cat = get_term($parrent, $request_taxonomy); ?> |
1066 | 1066 | |
@@ -1089,8 +1089,8 @@ discard block |
||
1089 | 1089 | |
1090 | 1090 | <br/> |
1091 | 1091 | <?php |
1092 | - $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats)); |
|
1093 | - if (!empty($cat_terms)) { ?> |
|
1092 | + $cat_terms = get_terms($request_taxonomy, array('parent' => $main_cat->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats)); |
|
1093 | + if (!empty($cat_terms)) { ?> |
|
1094 | 1094 | <span> <?php printf(__('Add listing in category', 'geodirectory')); ?></span> |
1095 | 1095 | <?php geodir_get_catlist($request_taxonomy, $parrent, $selected) ?> |
1096 | 1096 | <?php } ?> |
@@ -1112,53 +1112,53 @@ discard block |
||
1112 | 1112 | function geodir_editpost_categories_html($request_taxonomy, $request_postid, $post_categories) |
1113 | 1113 | { |
1114 | 1114 | |
1115 | - if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) { |
|
1116 | - $post_cat_str = $post_categories[$request_taxonomy]; |
|
1117 | - $post_cat_array = explode("#", $post_cat_str); |
|
1118 | - if (is_array($post_cat_array)) { |
|
1119 | - $post_cat_array = array_unique( $post_cat_array ); |
|
1115 | + if (!empty($post_categories) && array_key_exists($request_taxonomy, $post_categories)) { |
|
1116 | + $post_cat_str = $post_categories[$request_taxonomy]; |
|
1117 | + $post_cat_array = explode("#", $post_cat_str); |
|
1118 | + if (is_array($post_cat_array)) { |
|
1119 | + $post_cat_array = array_unique( $post_cat_array ); |
|
1120 | 1120 | |
1121 | 1121 | foreach ($post_cat_array as $post_cat_html) { |
1122 | 1122 | |
1123 | - $post_cat_info = explode(":", $post_cat_html); |
|
1124 | - $post_maincat_str = $post_cat_info[0]; |
|
1123 | + $post_cat_info = explode(":", $post_cat_html); |
|
1124 | + $post_maincat_str = $post_cat_info[0]; |
|
1125 | 1125 | |
1126 | - if (!empty($post_maincat_str)) { |
|
1127 | - $post_maincat_info = explode(",", $post_maincat_str); |
|
1128 | - $post_maincat_id = $post_maincat_info[0]; |
|
1129 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
1130 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
1131 | - } |
|
1132 | - $post_sub_catid = ''; |
|
1133 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) { |
|
1134 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
1135 | - } |
|
1126 | + if (!empty($post_maincat_str)) { |
|
1127 | + $post_maincat_info = explode(",", $post_maincat_str); |
|
1128 | + $post_maincat_id = $post_maincat_info[0]; |
|
1129 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
1130 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
1131 | + } |
|
1132 | + $post_sub_catid = ''; |
|
1133 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) { |
|
1134 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
1135 | + } |
|
1136 | 1136 | |
1137 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
1137 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
1138 | 1138 | |
1139 | - } |
|
1140 | - } else { |
|
1139 | + } |
|
1140 | + } else { |
|
1141 | 1141 | |
1142 | - $post_cat_info = explode(":", $post_cat_str); |
|
1143 | - $post_maincat_str = $post_cat_info[0]; |
|
1142 | + $post_cat_info = explode(":", $post_cat_str); |
|
1143 | + $post_maincat_str = $post_cat_info[0]; |
|
1144 | 1144 | |
1145 | - $post_sub_catid = ''; |
|
1145 | + $post_sub_catid = ''; |
|
1146 | 1146 | |
1147 | - if (!empty($post_maincat_str)) { |
|
1148 | - $post_maincat_info = explode(",", $post_maincat_str); |
|
1149 | - $post_maincat_id = $post_maincat_info[0]; |
|
1150 | - ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
1151 | - (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
1152 | - } |
|
1147 | + if (!empty($post_maincat_str)) { |
|
1148 | + $post_maincat_info = explode(",", $post_maincat_str); |
|
1149 | + $post_maincat_id = $post_maincat_info[0]; |
|
1150 | + ($post_maincat_info[1] == 'y') ? $post_maincat_selected = true : $post_maincat_selected = false; |
|
1151 | + (end($post_maincat_info) == 'd') ? $post_maincat_default = true : $post_maincat_default = false; |
|
1152 | + } |
|
1153 | 1153 | |
1154 | - if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) { |
|
1155 | - $post_sub_catid = (int)$post_cat_info[1]; |
|
1156 | - } |
|
1154 | + if (isset($post_cat_info[1]) && !empty($post_cat_info[1])) { |
|
1155 | + $post_sub_catid = (int)$post_cat_info[1]; |
|
1156 | + } |
|
1157 | 1157 | |
1158 | - geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
1158 | + geodir_addpost_categories_html($request_taxonomy, $post_maincat_id, $post_sub_catid, $post_maincat_selected, $post_maincat_default); |
|
1159 | 1159 | |
1160 | - } |
|
1161 | - } |
|
1160 | + } |
|
1161 | + } |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | /** |
@@ -1172,35 +1172,35 @@ discard block |
||
1172 | 1172 | */ |
1173 | 1173 | function geodir_get_catlist($cat_taxonomy, $parrent = 0, $selected = false) |
1174 | 1174 | { |
1175 | - global $exclude_cats; |
|
1175 | + global $exclude_cats; |
|
1176 | 1176 | |
1177 | - $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats)); |
|
1177 | + $cat_terms = get_terms($cat_taxonomy, array('parent' => $parrent, 'hide_empty' => false, 'exclude' => $exclude_cats)); |
|
1178 | 1178 | |
1179 | - if (!empty($cat_terms)) { |
|
1180 | - $onchange = ''; |
|
1181 | - $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
1179 | + if (!empty($cat_terms)) { |
|
1180 | + $onchange = ''; |
|
1181 | + $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
|
1182 | 1182 | |
1183 | - $option_selected = ''; |
|
1184 | - if (!$selected) |
|
1185 | - $option_slected = ' selected="selected" '; |
|
1183 | + $option_selected = ''; |
|
1184 | + if (!$selected) |
|
1185 | + $option_slected = ' selected="selected" '; |
|
1186 | 1186 | |
1187 | - echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
1187 | + echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
|
1188 | 1188 | |
1189 | - echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>'; |
|
1189 | + echo '<option value="" ' . $option_selected . ' >' . __('Select Category', 'geodirectory') . '</option>'; |
|
1190 | 1190 | |
1191 | - foreach ($cat_terms as $cat_term) { |
|
1192 | - $option_selected = ''; |
|
1193 | - if ($selected == $cat_term->term_id) |
|
1194 | - $option_selected = ' selected="selected" '; |
|
1191 | + foreach ($cat_terms as $cat_term) { |
|
1192 | + $option_selected = ''; |
|
1193 | + if ($selected == $cat_term->term_id) |
|
1194 | + $option_selected = ' selected="selected" '; |
|
1195 | 1195 | |
1196 | - // Count child terms |
|
1197 | - $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
1198 | - $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
1196 | + // Count child terms |
|
1197 | + $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
|
1198 | + $has_child = !empty( $child_terms ) ? 't' : 'f'; |
|
1199 | 1199 | |
1200 | - echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
1201 | - } |
|
1202 | - echo '</select>'; |
|
1203 | - } |
|
1200 | + echo '<option ' . $option_selected . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" _hc="' . $has_child . '" >' . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
1201 | + } |
|
1202 | + echo '</select>'; |
|
1203 | + } |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | /** |
@@ -1216,28 +1216,28 @@ discard block |
||
1216 | 1216 | */ |
1217 | 1217 | function geodir_custom_update_messages($messages) |
1218 | 1218 | { |
1219 | - global $post, $post_ID; |
|
1220 | - |
|
1221 | - $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects'); |
|
1222 | - |
|
1223 | - foreach ($post_types as $post_type => $post_object) { |
|
1224 | - |
|
1225 | - $messages[$post_type] = array( |
|
1226 | - 0 => '', // Unused. Messages start at index 1. |
|
1227 | - 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), |
|
1228 | - 2 => __('Custom field updated.', 'geodirectory'), |
|
1229 | - 3 => __('Custom field deleted.', 'geodirectory'), |
|
1230 | - 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name), |
|
1231 | - 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, |
|
1232 | - 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), |
|
1233 | - 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name), |
|
1234 | - 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), |
|
1235 | - 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), |
|
1236 | - 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), |
|
1237 | - ); |
|
1238 | - } |
|
1239 | - |
|
1240 | - return $messages; |
|
1219 | + global $post, $post_ID; |
|
1220 | + |
|
1221 | + $post_types = get_post_types(array('show_ui' => true, '_builtin' => false), 'objects'); |
|
1222 | + |
|
1223 | + foreach ($post_types as $post_type => $post_object) { |
|
1224 | + |
|
1225 | + $messages[$post_type] = array( |
|
1226 | + 0 => '', // Unused. Messages start at index 1. |
|
1227 | + 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), |
|
1228 | + 2 => __('Custom field updated.', 'geodirectory'), |
|
1229 | + 3 => __('Custom field deleted.', 'geodirectory'), |
|
1230 | + 4 => sprintf(__('%s updated.', 'geodirectory'), $post_object->labels->singular_name), |
|
1231 | + 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, |
|
1232 | + 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), |
|
1233 | + 7 => sprintf(__('%s saved.', 'geodirectory'), $post_object->labels->singular_name), |
|
1234 | + 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), |
|
1235 | + 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), |
|
1236 | + 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), |
|
1237 | + ); |
|
1238 | + } |
|
1239 | + |
|
1240 | + return $messages; |
|
1241 | 1241 | } |
1242 | 1242 | |
1243 | 1243 | |
@@ -1252,182 +1252,182 @@ discard block |
||
1252 | 1252 | function geodir_register_defaults() |
1253 | 1253 | { |
1254 | 1254 | |
1255 | - global $wpdb; |
|
1256 | - |
|
1257 | - $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
1258 | - |
|
1259 | - if (!$listing_slug = get_option('geodir_listing_prefix')) |
|
1260 | - $listing_slug = 'places'; |
|
1261 | - |
|
1262 | - /** |
|
1263 | - * Taxonomies |
|
1264 | - **/ |
|
1265 | - //if ( ! taxonomy_exists('gd_place_tags') ) |
|
1266 | - { |
|
1267 | - |
|
1268 | - $gd_placetags = array(); |
|
1269 | - $gd_placetags['object_type'] = 'gd_place'; |
|
1270 | - $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
1271 | - $gd_placetags['args'] = array( |
|
1272 | - 'public' => true, |
|
1273 | - 'hierarchical' => false, |
|
1274 | - 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true), |
|
1275 | - 'query_var' => true, |
|
1276 | - |
|
1277 | - 'labels' => array( |
|
1278 | - 'name' => __('Place Tags', 'geodirectory'), |
|
1279 | - 'singular_name' => __('Place Tag', 'geodirectory'), |
|
1280 | - 'search_items' => __('Search Place Tags', 'geodirectory'), |
|
1281 | - 'popular_items' => __('Popular Place Tags', 'geodirectory'), |
|
1282 | - 'all_items' => __('All Place Tags', 'geodirectory'), |
|
1283 | - 'edit_item' => __('Edit Place Tag', 'geodirectory'), |
|
1284 | - 'update_item' => __('Update Place Tag', 'geodirectory'), |
|
1285 | - 'add_new_item' => __('Add New Place Tag', 'geodirectory'), |
|
1286 | - 'new_item_name' => __('New Place Tag Name', 'geodirectory'), |
|
1287 | - 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'), |
|
1288 | - 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'), |
|
1289 | - 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'), |
|
1290 | - ), |
|
1291 | - ); |
|
1292 | - |
|
1293 | - |
|
1294 | - $geodir_taxonomies = get_option('geodir_taxonomies'); |
|
1295 | - $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
1296 | - update_option('geodir_taxonomies', $geodir_taxonomies); |
|
1297 | - |
|
1298 | - |
|
1299 | - // Update post types and delete tmp options |
|
1300 | - flush_rewrite_rules(); |
|
1301 | - |
|
1302 | - } |
|
1303 | - |
|
1304 | - //if ( ! taxonomy_exists('gd_placecategory') ) |
|
1305 | - { |
|
1306 | - |
|
1307 | - $gd_placecategory = array(); |
|
1308 | - $gd_placecategory['object_type'] = 'gd_place'; |
|
1309 | - $gd_placecategory['listing_slug'] = $listing_slug; |
|
1310 | - $gd_placecategory['args'] = array( |
|
1311 | - 'public' => true, |
|
1312 | - 'hierarchical' => true, |
|
1313 | - 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true), |
|
1314 | - 'query_var' => true, |
|
1315 | - 'labels' => array( |
|
1316 | - 'name' => __('Place Categories', 'geodirectory'), |
|
1317 | - 'singular_name' => __('Place Category', 'geodirectory'), |
|
1318 | - 'search_items' => __('Search Place Categories', 'geodirectory'), |
|
1319 | - 'popular_items' => __('Popular Place Categories', 'geodirectory'), |
|
1320 | - 'all_items' => __('All Place Categories', 'geodirectory'), |
|
1321 | - 'edit_item' => __('Edit Place Category', 'geodirectory'), |
|
1322 | - 'update_item' => __('Update Place Category', 'geodirectory'), |
|
1323 | - 'add_new_item' => __('Add New Place Category', 'geodirectory'), |
|
1324 | - 'new_item_name' => __('New Place Category', 'geodirectory'), |
|
1325 | - 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'), |
|
1326 | - ), |
|
1327 | - ); |
|
1328 | - |
|
1329 | - |
|
1330 | - $geodir_taxonomies = get_option('geodir_taxonomies'); |
|
1331 | - $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
1332 | - update_option('geodir_taxonomies', $geodir_taxonomies); |
|
1333 | - |
|
1334 | - |
|
1335 | - flush_rewrite_rules(); |
|
1336 | - } |
|
1337 | - |
|
1338 | - /** |
|
1339 | - * Post Types |
|
1340 | - **/ |
|
1341 | - |
|
1342 | - //if ( ! post_type_exists('gd_place') ) |
|
1343 | - { |
|
1344 | - |
|
1345 | - $labels = array( |
|
1346 | - 'name' => __('Places', 'geodirectory'), |
|
1347 | - 'singular_name' => __('Place', 'geodirectory'), |
|
1348 | - 'add_new' => __('Add New', 'geodirectory'), |
|
1349 | - 'add_new_item' => __('Add New Place', 'geodirectory'), |
|
1350 | - 'edit_item' => __('Edit Place', 'geodirectory'), |
|
1351 | - 'new_item' => __('New Place', 'geodirectory'), |
|
1352 | - 'view_item' => __('View Place', 'geodirectory'), |
|
1353 | - 'search_items' => __('Search Places', 'geodirectory'), |
|
1354 | - 'not_found' => __('No Place Found', 'geodirectory'), |
|
1355 | - 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory')); |
|
1356 | - |
|
1357 | - $place_default = array( |
|
1358 | - 'labels' => $labels, |
|
1359 | - 'can_export' => true, |
|
1360 | - 'capability_type' => 'post', |
|
1361 | - 'description' => 'Place post type.', |
|
1362 | - 'has_archive' => $listing_slug, |
|
1363 | - 'hierarchical' => false, |
|
1364 | - 'map_meta_cap' => true, |
|
1365 | - 'menu_icon' => $menu_icon, |
|
1366 | - 'public' => true, |
|
1367 | - 'query_var' => true, |
|
1368 | - 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true), |
|
1369 | - 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/), |
|
1370 | - 'taxonomies' => array('gd_placecategory', 'gd_place_tags')); |
|
1371 | - |
|
1372 | - //Update custom post types |
|
1373 | - $geodir_post_types = get_option('geodir_post_types'); |
|
1374 | - $geodir_post_types['gd_place'] = $place_default; |
|
1375 | - update_option('geodir_post_types', $geodir_post_types); |
|
1376 | - |
|
1377 | - // Update post types and delete tmp options |
|
1378 | - flush_rewrite_rules(); |
|
1379 | - } |
|
1380 | - |
|
1381 | - |
|
1382 | - geodir_register_taxonomies(); |
|
1383 | - geodir_register_post_types(); |
|
1384 | - |
|
1385 | - //die; |
|
1255 | + global $wpdb; |
|
1256 | + |
|
1257 | + $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
|
1258 | + |
|
1259 | + if (!$listing_slug = get_option('geodir_listing_prefix')) |
|
1260 | + $listing_slug = 'places'; |
|
1261 | + |
|
1262 | + /** |
|
1263 | + * Taxonomies |
|
1264 | + **/ |
|
1265 | + //if ( ! taxonomy_exists('gd_place_tags') ) |
|
1266 | + { |
|
1267 | + |
|
1268 | + $gd_placetags = array(); |
|
1269 | + $gd_placetags['object_type'] = 'gd_place'; |
|
1270 | + $gd_placetags['listing_slug'] = $listing_slug . '/tags'; |
|
1271 | + $gd_placetags['args'] = array( |
|
1272 | + 'public' => true, |
|
1273 | + 'hierarchical' => false, |
|
1274 | + 'rewrite' => array('slug' => $listing_slug . '/tags', 'with_front' => false, 'hierarchical' => true), |
|
1275 | + 'query_var' => true, |
|
1276 | + |
|
1277 | + 'labels' => array( |
|
1278 | + 'name' => __('Place Tags', 'geodirectory'), |
|
1279 | + 'singular_name' => __('Place Tag', 'geodirectory'), |
|
1280 | + 'search_items' => __('Search Place Tags', 'geodirectory'), |
|
1281 | + 'popular_items' => __('Popular Place Tags', 'geodirectory'), |
|
1282 | + 'all_items' => __('All Place Tags', 'geodirectory'), |
|
1283 | + 'edit_item' => __('Edit Place Tag', 'geodirectory'), |
|
1284 | + 'update_item' => __('Update Place Tag', 'geodirectory'), |
|
1285 | + 'add_new_item' => __('Add New Place Tag', 'geodirectory'), |
|
1286 | + 'new_item_name' => __('New Place Tag Name', 'geodirectory'), |
|
1287 | + 'add_or_remove_items' => __('Add or remove Place tags', 'geodirectory'), |
|
1288 | + 'choose_from_most_used' => __('Choose from the most used Place tags', 'geodirectory'), |
|
1289 | + 'separate_items_with_commas' => __('Separate Place tags with commas', 'geodirectory'), |
|
1290 | + ), |
|
1291 | + ); |
|
1292 | + |
|
1293 | + |
|
1294 | + $geodir_taxonomies = get_option('geodir_taxonomies'); |
|
1295 | + $geodir_taxonomies['gd_place_tags'] = $gd_placetags; |
|
1296 | + update_option('geodir_taxonomies', $geodir_taxonomies); |
|
1297 | + |
|
1298 | + |
|
1299 | + // Update post types and delete tmp options |
|
1300 | + flush_rewrite_rules(); |
|
1301 | + |
|
1302 | + } |
|
1303 | + |
|
1304 | + //if ( ! taxonomy_exists('gd_placecategory') ) |
|
1305 | + { |
|
1306 | + |
|
1307 | + $gd_placecategory = array(); |
|
1308 | + $gd_placecategory['object_type'] = 'gd_place'; |
|
1309 | + $gd_placecategory['listing_slug'] = $listing_slug; |
|
1310 | + $gd_placecategory['args'] = array( |
|
1311 | + 'public' => true, |
|
1312 | + 'hierarchical' => true, |
|
1313 | + 'rewrite' => array('slug' => $listing_slug, 'with_front' => false, 'hierarchical' => true), |
|
1314 | + 'query_var' => true, |
|
1315 | + 'labels' => array( |
|
1316 | + 'name' => __('Place Categories', 'geodirectory'), |
|
1317 | + 'singular_name' => __('Place Category', 'geodirectory'), |
|
1318 | + 'search_items' => __('Search Place Categories', 'geodirectory'), |
|
1319 | + 'popular_items' => __('Popular Place Categories', 'geodirectory'), |
|
1320 | + 'all_items' => __('All Place Categories', 'geodirectory'), |
|
1321 | + 'edit_item' => __('Edit Place Category', 'geodirectory'), |
|
1322 | + 'update_item' => __('Update Place Category', 'geodirectory'), |
|
1323 | + 'add_new_item' => __('Add New Place Category', 'geodirectory'), |
|
1324 | + 'new_item_name' => __('New Place Category', 'geodirectory'), |
|
1325 | + 'add_or_remove_items' => __('Add or remove Place categories', 'geodirectory'), |
|
1326 | + ), |
|
1327 | + ); |
|
1328 | + |
|
1329 | + |
|
1330 | + $geodir_taxonomies = get_option('geodir_taxonomies'); |
|
1331 | + $geodir_taxonomies['gd_placecategory'] = $gd_placecategory; |
|
1332 | + update_option('geodir_taxonomies', $geodir_taxonomies); |
|
1333 | + |
|
1334 | + |
|
1335 | + flush_rewrite_rules(); |
|
1336 | + } |
|
1337 | + |
|
1338 | + /** |
|
1339 | + * Post Types |
|
1340 | + **/ |
|
1341 | + |
|
1342 | + //if ( ! post_type_exists('gd_place') ) |
|
1343 | + { |
|
1344 | + |
|
1345 | + $labels = array( |
|
1346 | + 'name' => __('Places', 'geodirectory'), |
|
1347 | + 'singular_name' => __('Place', 'geodirectory'), |
|
1348 | + 'add_new' => __('Add New', 'geodirectory'), |
|
1349 | + 'add_new_item' => __('Add New Place', 'geodirectory'), |
|
1350 | + 'edit_item' => __('Edit Place', 'geodirectory'), |
|
1351 | + 'new_item' => __('New Place', 'geodirectory'), |
|
1352 | + 'view_item' => __('View Place', 'geodirectory'), |
|
1353 | + 'search_items' => __('Search Places', 'geodirectory'), |
|
1354 | + 'not_found' => __('No Place Found', 'geodirectory'), |
|
1355 | + 'not_found_in_trash' => __('No Place Found In Trash', 'geodirectory')); |
|
1356 | + |
|
1357 | + $place_default = array( |
|
1358 | + 'labels' => $labels, |
|
1359 | + 'can_export' => true, |
|
1360 | + 'capability_type' => 'post', |
|
1361 | + 'description' => 'Place post type.', |
|
1362 | + 'has_archive' => $listing_slug, |
|
1363 | + 'hierarchical' => false, |
|
1364 | + 'map_meta_cap' => true, |
|
1365 | + 'menu_icon' => $menu_icon, |
|
1366 | + 'public' => true, |
|
1367 | + 'query_var' => true, |
|
1368 | + 'rewrite' => array('slug' => $listing_slug , 'with_front' => false, 'hierarchical' => true, 'feeds' => true), |
|
1369 | + 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', /*'revisions', 'post-formats'*/), |
|
1370 | + 'taxonomies' => array('gd_placecategory', 'gd_place_tags')); |
|
1371 | + |
|
1372 | + //Update custom post types |
|
1373 | + $geodir_post_types = get_option('geodir_post_types'); |
|
1374 | + $geodir_post_types['gd_place'] = $place_default; |
|
1375 | + update_option('geodir_post_types', $geodir_post_types); |
|
1376 | + |
|
1377 | + // Update post types and delete tmp options |
|
1378 | + flush_rewrite_rules(); |
|
1379 | + } |
|
1380 | + |
|
1381 | + |
|
1382 | + geodir_register_taxonomies(); |
|
1383 | + geodir_register_post_types(); |
|
1384 | + |
|
1385 | + //die; |
|
1386 | 1386 | |
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | $gd_wpml_get_languages = ""; |
1390 | 1390 | function gd_wpml_get_lang_from_url($url) { |
1391 | - global $sitepress, $gd_wpml_get_languages; |
|
1391 | + global $sitepress, $gd_wpml_get_languages; |
|
1392 | 1392 | |
1393 | - if (geodir_is_wpml()) { |
|
1394 | - return $sitepress->get_language_from_url($url); |
|
1395 | - } |
|
1393 | + if (geodir_is_wpml()) { |
|
1394 | + return $sitepress->get_language_from_url($url); |
|
1395 | + } |
|
1396 | 1396 | |
1397 | - if (isset($_REQUEST['lang']) && $_REQUEST['lang']) { |
|
1398 | - return $_REQUEST['lang']; |
|
1399 | - } |
|
1397 | + if (isset($_REQUEST['lang']) && $_REQUEST['lang']) { |
|
1398 | + return $_REQUEST['lang']; |
|
1399 | + } |
|
1400 | 1400 | |
1401 | - $url = str_replace(array("http://","https://"),"",$url); |
|
1401 | + $url = str_replace(array("http://","https://"),"",$url); |
|
1402 | 1402 | |
1403 | - // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang. |
|
1404 | - $site_url = str_replace(array("http://","https://"),"",site_url()); |
|
1403 | + // site_url() seems to work better than get_bloginfo('url') here, WPML can change get_bloginfo('url') to add the lang. |
|
1404 | + $site_url = str_replace(array("http://","https://"),"",site_url()); |
|
1405 | 1405 | |
1406 | - $url = str_replace($site_url,"",$url); |
|
1406 | + $url = str_replace($site_url,"",$url); |
|
1407 | 1407 | |
1408 | - $segments = explode('/', trim($url, '/')); |
|
1408 | + $segments = explode('/', trim($url, '/')); |
|
1409 | 1409 | |
1410 | - if ($gd_wpml_get_languages) { |
|
1411 | - $langs = $gd_wpml_get_languages; |
|
1412 | - } else { |
|
1413 | - $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
1414 | - } |
|
1410 | + if ($gd_wpml_get_languages) { |
|
1411 | + $langs = $gd_wpml_get_languages; |
|
1412 | + } else { |
|
1413 | + $gd_wpml_get_languages = $sitepress->get_active_languages(); |
|
1414 | + } |
|
1415 | 1415 | |
1416 | - if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) { |
|
1417 | - return $segments[0]; |
|
1418 | - } |
|
1416 | + if (isset($segments[0]) && $segments[0] && array_key_exists($segments[0], $gd_wpml_get_languages)) { |
|
1417 | + return $segments[0]; |
|
1418 | + } |
|
1419 | 1419 | |
1420 | - return false; |
|
1420 | + return false; |
|
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | function gd_wpml_slug_translation_turned_on($post_type) { |
1424 | 1424 | |
1425 | - global $sitepress; |
|
1426 | - $settings = $sitepress->get_settings(); |
|
1427 | - return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
1428 | - && $settings['posts_slug_translation']['types'][$post_type] |
|
1429 | - && isset($settings['posts_slug_translation']['on']) |
|
1430 | - && $settings['posts_slug_translation']['on']; |
|
1425 | + global $sitepress; |
|
1426 | + $settings = $sitepress->get_settings(); |
|
1427 | + return isset($settings['posts_slug_translation']['types'][$post_type]) |
|
1428 | + && $settings['posts_slug_translation']['types'][$post_type] |
|
1429 | + && isset($settings['posts_slug_translation']['on']) |
|
1430 | + && $settings['posts_slug_translation']['on']; |
|
1431 | 1431 | } |
1432 | 1432 | |
1433 | 1433 | |
@@ -1454,162 +1454,162 @@ discard block |
||
1454 | 1454 | */ |
1455 | 1455 | function geodir_listing_permalink_structure($post_link, $post_obj, $leavename, $sample) |
1456 | 1456 | { |
1457 | - //echo $post_link."<br />".$sample ; |
|
1457 | + //echo $post_link."<br />".$sample ; |
|
1458 | 1458 | |
1459 | 1459 | |
1460 | - global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache, $gd_cache_post; |
|
1461 | - if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) { |
|
1462 | - if($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending'){return $post_link;} |
|
1463 | - } elseif (isset($post_obj->post_status) && ($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending')) { |
|
1464 | - return $post_link; |
|
1465 | - } else { |
|
1466 | - $orig_post = $post; |
|
1467 | - $post = $post_obj; |
|
1468 | - } |
|
1460 | + global $wpdb, $wp_query, $plugin_prefix, $post, $comment_post_cache, $gd_permalink_cache, $gd_cache_post; |
|
1461 | + if (isset($post_obj->ID) && isset($post->ID) && $post_obj->ID == $post->ID) { |
|
1462 | + if($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending'){return $post_link;} |
|
1463 | + } elseif (isset($post_obj->post_status) && ($post_obj->post_status == 'auto-draft' || $post_obj->post_status == 'draft' || $post_obj->post_status == 'pending')) { |
|
1464 | + return $post_link; |
|
1465 | + } else { |
|
1466 | + $orig_post = $post; |
|
1467 | + $post = $post_obj; |
|
1468 | + } |
|
1469 | 1469 | |
1470 | 1470 | |
1471 | 1471 | |
1472 | - if (in_array($post->post_type, geodir_get_posttypes())) {//print_r($post );exit; |
|
1472 | + if (in_array($post->post_type, geodir_get_posttypes())) {//print_r($post );exit; |
|
1473 | 1473 | |
1474 | 1474 | |
1475 | - // if we dont have a GD post then try to grab it |
|
1476 | - if(!isset($post->default_category)){ |
|
1477 | - $gd_post = geodir_get_post_info($post->ID); |
|
1478 | - if(!empty($gd_post)){ |
|
1479 | - $post = $gd_post; |
|
1480 | - } |
|
1481 | - } |
|
1475 | + // if we dont have a GD post then try to grab it |
|
1476 | + if(!isset($post->default_category)){ |
|
1477 | + $gd_post = geodir_get_post_info($post->ID); |
|
1478 | + if(!empty($gd_post)){ |
|
1479 | + $post = $gd_post; |
|
1480 | + } |
|
1481 | + } |
|
1482 | 1482 | |
1483 | 1483 | |
1484 | - $post_types = get_option('geodir_post_types'); |
|
1485 | - $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
1484 | + $post_types = get_option('geodir_post_types'); |
|
1485 | + $slug = $post_types[$post->post_type]['rewrite']['slug']; |
|
1486 | 1486 | |
1487 | - // Alter the CPT slug if WPML is set to do so |
|
1488 | - if(geodir_wpml_is_post_type_translated($post->post_type)){ |
|
1489 | - if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) { |
|
1487 | + // Alter the CPT slug if WPML is set to do so |
|
1488 | + if(geodir_wpml_is_post_type_translated($post->post_type)){ |
|
1489 | + if ( gd_wpml_slug_translation_turned_on( $post->post_type ) && $language_code = gd_wpml_get_lang_from_url($post_link)) { |
|
1490 | 1490 | |
1491 | - $org_slug = $slug; |
|
1492 | - $slug = apply_filters( 'wpml_translate_single_string', |
|
1493 | - $slug, |
|
1494 | - 'WordPress', |
|
1495 | - 'URL slug: ' . $slug, |
|
1496 | - $language_code); |
|
1491 | + $org_slug = $slug; |
|
1492 | + $slug = apply_filters( 'wpml_translate_single_string', |
|
1493 | + $slug, |
|
1494 | + 'WordPress', |
|
1495 | + 'URL slug: ' . $slug, |
|
1496 | + $language_code); |
|
1497 | 1497 | |
1498 | - if(!$slug){$slug = $org_slug;} |
|
1498 | + if(!$slug){$slug = $org_slug;} |
|
1499 | 1499 | |
1500 | - } |
|
1501 | - } |
|
1500 | + } |
|
1501 | + } |
|
1502 | 1502 | |
1503 | - if (function_exists('geodir_location_geo_home_link')) { |
|
1504 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
1505 | - } |
|
1503 | + if (function_exists('geodir_location_geo_home_link')) { |
|
1504 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
1505 | + } |
|
1506 | 1506 | |
1507 | - // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
1508 | - $site_url = trailingslashit(get_bloginfo('url')); |
|
1507 | + // Fix slug problem when slug matches part of host or base url/ Ex: url -> www.abcxyz.com & slug -> xyz. |
|
1508 | + $site_url = trailingslashit(get_bloginfo('url')); |
|
1509 | 1509 | |
1510 | - if (function_exists('geodir_location_geo_home_link')) { |
|
1511 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
1512 | - } |
|
1513 | - |
|
1514 | - $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
1515 | - if ($fix_url) { |
|
1516 | - $post_link = str_replace($site_url, '', $post_link); |
|
1517 | - } |
|
1518 | - |
|
1519 | - $post_link = trailingslashit( |
|
1520 | - preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
1521 | - ); |
|
1522 | - |
|
1523 | - if ($fix_url) { |
|
1524 | - $post_link = $site_url . $post_link; |
|
1525 | - } |
|
1526 | - |
|
1527 | - if (isset($comment_post_cache[$post->ID])) { |
|
1528 | - $post = $comment_post_cache[$post->ID]; |
|
1529 | - } |
|
1530 | - if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) { |
|
1531 | - $post_id = $post->ID; |
|
1532 | - if (isset($orig_post)) { |
|
1533 | - $post = $orig_post; |
|
1534 | - } |
|
1535 | - return $gd_permalink_cache[$post_id]; |
|
1536 | - } |
|
1510 | + if (function_exists('geodir_location_geo_home_link')) { |
|
1511 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
1512 | + } |
|
1537 | 1513 | |
1538 | - if (!isset($post->post_locations)) { |
|
1539 | - $post_type = $post->post_type; |
|
1540 | - $ID = $post->ID; |
|
1541 | - $post2 = $wpdb->get_row( |
|
1542 | - $wpdb->prepare( |
|
1543 | - "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
1544 | - array($post->ID) |
|
1545 | - ) |
|
1546 | - ); |
|
1514 | + $fix_url = strpos($post_link, $site_url) === 0 ? true : false; |
|
1515 | + if ($fix_url) { |
|
1516 | + $post_link = str_replace($site_url, '', $post_link); |
|
1517 | + } |
|
1547 | 1518 | |
1548 | - $post = (object)array_merge((array)$post, (array)$post2); |
|
1519 | + $post_link = trailingslashit( |
|
1520 | + preg_replace( "/" . preg_quote( $slug, "/" ) . "/", $slug ."/%gd_taxonomy%",$post_link, 1 ) |
|
1521 | + ); |
|
1549 | 1522 | |
1550 | - $comment_post_cache[$post->ID] = $post; |
|
1551 | - } |
|
1523 | + if ($fix_url) { |
|
1524 | + $post_link = $site_url . $post_link; |
|
1525 | + } |
|
1552 | 1526 | |
1527 | + if (isset($comment_post_cache[$post->ID])) { |
|
1528 | + $post = $comment_post_cache[$post->ID]; |
|
1529 | + } |
|
1530 | + if (isset($gd_permalink_cache[$post->ID]) && $gd_permalink_cache[$post->ID] && !$sample) { |
|
1531 | + $post_id = $post->ID; |
|
1532 | + if (isset($orig_post)) { |
|
1533 | + $post = $orig_post; |
|
1534 | + } |
|
1535 | + return $gd_permalink_cache[$post_id]; |
|
1536 | + } |
|
1553 | 1537 | |
1538 | + if (!isset($post->post_locations)) { |
|
1539 | + $post_type = $post->post_type; |
|
1540 | + $ID = $post->ID; |
|
1541 | + $post2 = $wpdb->get_row( |
|
1542 | + $wpdb->prepare( |
|
1543 | + "SELECT * from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
1544 | + array($post->ID) |
|
1545 | + ) |
|
1546 | + ); |
|
1554 | 1547 | |
1555 | - if (false !== strpos($post_link, '%gd_taxonomy%')) { |
|
1548 | + $post = (object)array_merge((array)$post, (array)$post2); |
|
1556 | 1549 | |
1557 | - if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) { |
|
1558 | - $location_request = ''; |
|
1550 | + $comment_post_cache[$post->ID] = $post; |
|
1551 | + } |
|
1559 | 1552 | |
1560 | 1553 | |
1561 | - if (!empty($post->post_locations)) { |
|
1562 | - $geodir_arr_locations = explode(',', $post->post_locations); |
|
1563 | - if (count($geodir_arr_locations) == 3) { |
|
1564 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]); |
|
1565 | - $post->city_slug = str_replace(']', '', $post->city_slug); |
|
1566 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]); |
|
1567 | - $post->region_slug = str_replace(']', '', $post->region_slug); |
|
1568 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]); |
|
1569 | - $post->country_slug = str_replace(']', '', $post->country_slug); |
|
1570 | 1554 | |
1571 | - $post_location = (object)array('country_slug' => $post->country_slug, |
|
1572 | - 'region_slug' => $post->region_slug, |
|
1573 | - 'city_slug' => $post->city_slug |
|
1574 | - ); |
|
1555 | + if (false !== strpos($post_link, '%gd_taxonomy%')) { |
|
1575 | 1556 | |
1576 | - } else |
|
1577 | - $post_location = geodir_get_location(); |
|
1557 | + if ( apply_filters("geodir_add_location_url_to_url",get_option('geodir_add_location_url'),$post->post_type,$post)) { |
|
1558 | + $location_request = ''; |
|
1578 | 1559 | |
1579 | 1560 | |
1580 | - } else { |
|
1561 | + if (!empty($post->post_locations)) { |
|
1562 | + $geodir_arr_locations = explode(',', $post->post_locations); |
|
1563 | + if (count($geodir_arr_locations) == 3) { |
|
1564 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]); |
|
1565 | + $post->city_slug = str_replace(']', '', $post->city_slug); |
|
1566 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]); |
|
1567 | + $post->region_slug = str_replace(']', '', $post->region_slug); |
|
1568 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]); |
|
1569 | + $post->country_slug = str_replace(']', '', $post->country_slug); |
|
1581 | 1570 | |
1582 | - $post_location_sql = $wpdb->get_results( |
|
1583 | - $wpdb->prepare( |
|
1584 | - "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
1585 | - array($post->ID) |
|
1586 | - ) |
|
1587 | - ); |
|
1588 | - |
|
1589 | - if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) { |
|
1590 | - |
|
1591 | - $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations); |
|
1592 | - if (count($geodir_arr_locations) == 3) { |
|
1593 | - $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]); |
|
1594 | - $post->city_slug = str_replace(']', '', $post->city_slug); |
|
1595 | - $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]); |
|
1596 | - $post->region_slug = str_replace(']', '', $post->region_slug); |
|
1597 | - $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]); |
|
1598 | - $post->country_slug = str_replace(']', '', $post->country_slug); |
|
1599 | - |
|
1600 | - $post_location = (object)array('country_slug' => $post->country_slug, |
|
1601 | - 'region_slug' => $post->region_slug, |
|
1602 | - 'city_slug' => $post->city_slug |
|
1603 | - ); |
|
1571 | + $post_location = (object)array('country_slug' => $post->country_slug, |
|
1572 | + 'region_slug' => $post->region_slug, |
|
1573 | + 'city_slug' => $post->city_slug |
|
1574 | + ); |
|
1604 | 1575 | |
1605 | - } |
|
1606 | - } else |
|
1607 | - $post_location = geodir_get_location(); |
|
1608 | - } |
|
1576 | + } else |
|
1577 | + $post_location = geodir_get_location(); |
|
1578 | + |
|
1579 | + |
|
1580 | + } else { |
|
1581 | + |
|
1582 | + $post_location_sql = $wpdb->get_results( |
|
1583 | + $wpdb->prepare( |
|
1584 | + "SELECT post_locations from " . $plugin_prefix . $post->post_type . "_detail WHERE post_id = %d ", |
|
1585 | + array($post->ID) |
|
1586 | + ) |
|
1587 | + ); |
|
1588 | + |
|
1589 | + if (!empty($post_location_sql) && is_array($post_location_sql) && !empty($post_location_sql[0]->post_locations)) { |
|
1590 | + |
|
1591 | + $geodir_arr_locations = explode(',', $post_location_sql[0]->post_locations); |
|
1592 | + if (count($geodir_arr_locations) == 3) { |
|
1593 | + $post->city_slug = str_replace('[', '', $geodir_arr_locations[0]); |
|
1594 | + $post->city_slug = str_replace(']', '', $post->city_slug); |
|
1595 | + $post->region_slug = str_replace('[', '', $geodir_arr_locations[1]); |
|
1596 | + $post->region_slug = str_replace(']', '', $post->region_slug); |
|
1597 | + $post->country_slug = str_replace('[', '', $geodir_arr_locations[2]); |
|
1598 | + $post->country_slug = str_replace(']', '', $post->country_slug); |
|
1599 | + |
|
1600 | + $post_location = (object)array('country_slug' => $post->country_slug, |
|
1601 | + 'region_slug' => $post->region_slug, |
|
1602 | + 'city_slug' => $post->city_slug |
|
1603 | + ); |
|
1604 | + |
|
1605 | + } |
|
1606 | + } else |
|
1607 | + $post_location = geodir_get_location(); |
|
1608 | + } |
|
1609 | 1609 | |
1610 | 1610 | |
1611 | - if (!empty($post_location)) { |
|
1612 | - $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
1611 | + if (!empty($post_location)) { |
|
1612 | + $country_slug = isset($post_location->country_slug) ? $post_location->country_slug : ''; |
|
1613 | 1613 | $region_slug = isset($post_location->region_slug) ? $post_location->region_slug : ''; |
1614 | 1614 | $city_slug = isset($post_location->city_slug) ? $post_location->city_slug : ''; |
1615 | 1615 | |
@@ -1627,89 +1627,89 @@ discard block |
||
1627 | 1627 | $location_slug[] = $city_slug; |
1628 | 1628 | |
1629 | 1629 | $location_request .= implode('/', $location_slug) . '/'; |
1630 | - } |
|
1631 | - } |
|
1630 | + } |
|
1631 | + } |
|
1632 | 1632 | |
1633 | - if (get_option('geodir_add_categories_url')) { |
|
1633 | + if (get_option('geodir_add_categories_url')) { |
|
1634 | 1634 | |
1635 | - $term_request = ''; |
|
1636 | - $taxonomies = geodir_get_taxonomies($post->post_type); |
|
1637 | - $taxonomies = !empty($taxonomies) && is_array($taxonomies) ? end($taxonomies) : ''; |
|
1635 | + $term_request = ''; |
|
1636 | + $taxonomies = geodir_get_taxonomies($post->post_type); |
|
1637 | + $taxonomies = !empty($taxonomies) && is_array($taxonomies) ? end($taxonomies) : ''; |
|
1638 | 1638 | |
1639 | - if (!empty($post->default_category)) { |
|
1640 | - $post_terms = $post->default_category; |
|
1641 | - } else { |
|
1642 | - $post_terms = ''; |
|
1643 | - |
|
1644 | - if(isset($_POST['post_default_category']) && $_POST['post_default_category']){ |
|
1645 | - $post_terms = absint($_POST['post_default_category']); |
|
1646 | - }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) { |
|
1647 | - $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ",")); |
|
1648 | - $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0; |
|
1649 | - }elseif (isset($post->{$taxonomies})) { |
|
1650 | - $post_terms = explode(",", trim($post->{$taxonomies}, ",")); |
|
1651 | - $post_terms = $post_terms[0]; |
|
1652 | - } |
|
1639 | + if (!empty($post->default_category)) { |
|
1640 | + $post_terms = $post->default_category; |
|
1641 | + } else { |
|
1642 | + $post_terms = ''; |
|
1643 | + |
|
1644 | + if(isset($_POST['post_default_category']) && $_POST['post_default_category']){ |
|
1645 | + $post_terms = absint($_POST['post_default_category']); |
|
1646 | + }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) { |
|
1647 | + $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ",")); |
|
1648 | + $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0; |
|
1649 | + }elseif (isset($post->{$taxonomies})) { |
|
1650 | + $post_terms = explode(",", trim($post->{$taxonomies}, ",")); |
|
1651 | + $post_terms = $post_terms[0]; |
|
1652 | + } |
|
1653 | 1653 | |
1654 | - if (!$post_terms) |
|
1655 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
1654 | + if (!$post_terms) |
|
1655 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
1656 | 1656 | |
1657 | - if (!$post_terms) { |
|
1658 | - $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
1657 | + if (!$post_terms) { |
|
1658 | + $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
|
1659 | 1659 | |
1660 | - if ($post_terms) { |
|
1661 | - $post_terms = explode(",", trim($post_terms, ",")); |
|
1662 | - $post_terms = $post_terms[0]; |
|
1663 | - } |
|
1664 | - } |
|
1665 | - } |
|
1660 | + if ($post_terms) { |
|
1661 | + $post_terms = explode(",", trim($post_terms, ",")); |
|
1662 | + $post_terms = $post_terms[0]; |
|
1663 | + } |
|
1664 | + } |
|
1665 | + } |
|
1666 | 1666 | |
1667 | - $term = get_term_by('id', $post_terms, $taxonomies); |
|
1667 | + $term = get_term_by('id', $post_terms, $taxonomies); |
|
1668 | 1668 | |
1669 | - if (!empty($term)) |
|
1670 | - $term_request = $term->slug; |
|
1671 | - //$term_request = $term->slug.'/'; |
|
1672 | - } |
|
1669 | + if (!empty($term)) |
|
1670 | + $term_request = $term->slug; |
|
1671 | + //$term_request = $term->slug.'/'; |
|
1672 | + } |
|
1673 | 1673 | |
1674 | - $request_term = ''; |
|
1675 | - $listingurl_separator = ''; |
|
1676 | - //$detailurl_separator = get_option('geodir_detailurl_separator'); |
|
1677 | - $detailurl_separator = ''; |
|
1678 | - if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') { |
|
1679 | - $request_term = $location_request; |
|
1680 | - //$listingurl_separator = get_option('geodir_listingurl_separator'); |
|
1681 | - //$request_term .= $listingurl_separator.'/'.$term_request; |
|
1682 | - $request_term .= $term_request; |
|
1674 | + $request_term = ''; |
|
1675 | + $listingurl_separator = ''; |
|
1676 | + //$detailurl_separator = get_option('geodir_detailurl_separator'); |
|
1677 | + $detailurl_separator = ''; |
|
1678 | + if (isset($location_request) && $location_request != '' && isset($term_request) && $term_request != '') { |
|
1679 | + $request_term = $location_request; |
|
1680 | + //$listingurl_separator = get_option('geodir_listingurl_separator'); |
|
1681 | + //$request_term .= $listingurl_separator.'/'.$term_request; |
|
1682 | + $request_term .= $term_request; |
|
1683 | 1683 | |
1684 | - } else { |
|
1685 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
1684 | + } else { |
|
1685 | + if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
1686 | 1686 | |
1687 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
1688 | - } |
|
1689 | - $request_term = trim($request_term, '/'); |
|
1687 | + if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
1688 | + } |
|
1689 | + $request_term = trim($request_term, '/'); |
|
1690 | 1690 | |
1691 | - // Fix with WPML the location terms added twice when CPT slug is translated. |
|
1692 | - if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) { |
|
1693 | - $post_link = str_replace('%gd_taxonomy%/', '', $post_link); |
|
1694 | - } |
|
1691 | + // Fix with WPML the location terms added twice when CPT slug is translated. |
|
1692 | + if ($sample && !empty($location_request) && geodir_is_wpml() && strpos($post_link, '%gd_taxonomy%/' . $request_term . $detailurl_separator) !== false) { |
|
1693 | + $post_link = str_replace('%gd_taxonomy%/', '', $post_link); |
|
1694 | + } |
|
1695 | 1695 | |
1696 | - if (!empty($request_term)) |
|
1697 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1698 | - else |
|
1699 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1700 | - //echo $post_link ; |
|
1701 | - } |
|
1702 | - // temp cache the permalink |
|
1703 | - if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) { |
|
1704 | - $gd_permalink_cache[$post->ID] = $post_link; |
|
1705 | - } |
|
1706 | - } |
|
1707 | - if (isset($orig_post)) { |
|
1708 | - $post = $orig_post; |
|
1709 | - } |
|
1696 | + if (!empty($request_term)) |
|
1697 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1698 | + else |
|
1699 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
1700 | + //echo $post_link ; |
|
1701 | + } |
|
1702 | + // temp cache the permalink |
|
1703 | + if (!$sample && (!isset($_REQUEST['geodir_ajax']) || (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] != 'add_listing'))) { |
|
1704 | + $gd_permalink_cache[$post->ID] = $post_link; |
|
1705 | + } |
|
1706 | + } |
|
1707 | + if (isset($orig_post)) { |
|
1708 | + $post = $orig_post; |
|
1709 | + } |
|
1710 | 1710 | $gd_cache_post = $post; |
1711 | 1711 | |
1712 | - return $post_link; |
|
1712 | + return $post_link; |
|
1713 | 1713 | } |
1714 | 1714 | |
1715 | 1715 | /** |
@@ -1725,73 +1725,73 @@ discard block |
||
1725 | 1725 | * @return string The term link. |
1726 | 1726 | */ |
1727 | 1727 | function geodir_term_link($termlink, $term, $taxonomy) { |
1728 | - $geodir_taxonomies = geodir_get_taxonomies('', true); |
|
1728 | + $geodir_taxonomies = geodir_get_taxonomies('', true); |
|
1729 | 1729 | |
1730 | - if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) { |
|
1731 | - global $geodir_add_location_url, $gd_session; |
|
1732 | - $orig_termlink = $termlink; |
|
1730 | + if (isset($taxonomy) && !empty($geodir_taxonomies) && in_array($taxonomy, $geodir_taxonomies)) { |
|
1731 | + global $geodir_add_location_url, $gd_session; |
|
1732 | + $orig_termlink = $termlink; |
|
1733 | 1733 | $include_location = false; |
1734 | - $request_term = array(); |
|
1735 | - $add_location_url = get_option('geodir_add_location_url'); |
|
1736 | - $location_manager = defined('POST_LOCATION_TABLE') ? true : false; |
|
1734 | + $request_term = array(); |
|
1735 | + $add_location_url = get_option('geodir_add_location_url'); |
|
1736 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false; |
|
1737 | 1737 | |
1738 | - $listing_slug = geodir_get_listing_slug($taxonomy); |
|
1738 | + $listing_slug = geodir_get_listing_slug($taxonomy); |
|
1739 | 1739 | |
1740 | - if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') { |
|
1741 | - if ($geodir_add_location_url && $add_location_url) { |
|
1742 | - $include_location = true; |
|
1743 | - } |
|
1744 | - } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) { |
|
1745 | - $include_location = true; |
|
1746 | - } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) { |
|
1747 | - $include_location = true; |
|
1748 | - } |
|
1749 | - |
|
1750 | - if ($include_location) { |
|
1751 | - global $post; |
|
1752 | - $location_terms = array(); |
|
1740 | + if ($geodir_add_location_url != NULL && $geodir_add_location_url != '') { |
|
1741 | + if ($geodir_add_location_url && $add_location_url) { |
|
1742 | + $include_location = true; |
|
1743 | + } |
|
1744 | + } elseif ($add_location_url && $gd_session->get('gd_multi_location') == 1) { |
|
1745 | + $include_location = true; |
|
1746 | + } elseif ($add_location_url && $location_manager && geodir_is_page('detail')) { |
|
1747 | + $include_location = true; |
|
1748 | + } |
|
1749 | + |
|
1750 | + if ($include_location) { |
|
1751 | + global $post; |
|
1752 | + $location_terms = array(); |
|
1753 | 1753 | |
1754 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false; |
|
1754 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false; |
|
1755 | 1755 | |
1756 | - if (geodir_is_page('detail')) { |
|
1757 | - if (!isset($post->country_slug) && !empty($post->post_locations)) { |
|
1758 | - $post_locations = explode(',', $post->post_locations); |
|
1759 | - |
|
1760 | - if (count($post_locations) == 3) { |
|
1761 | - $post->city_slug = str_replace('[', '', $post_locations[0]); |
|
1762 | - $post->city_slug = str_replace(']', '', $post->city_slug); |
|
1763 | - $post->region_slug = str_replace('[', '', $post_locations[1]); |
|
1764 | - $post->region_slug = str_replace(']', '', $post->region_slug); |
|
1765 | - $post->country_slug = str_replace('[', '', $post_locations[2]); |
|
1766 | - $post->country_slug = str_replace(']', '', $post->country_slug); |
|
1767 | - } |
|
1768 | - } |
|
1756 | + if (geodir_is_page('detail')) { |
|
1757 | + if (!isset($post->country_slug) && !empty($post->post_locations)) { |
|
1758 | + $post_locations = explode(',', $post->post_locations); |
|
1759 | + |
|
1760 | + if (count($post_locations) == 3) { |
|
1761 | + $post->city_slug = str_replace('[', '', $post_locations[0]); |
|
1762 | + $post->city_slug = str_replace(']', '', $post->city_slug); |
|
1763 | + $post->region_slug = str_replace('[', '', $post_locations[1]); |
|
1764 | + $post->region_slug = str_replace(']', '', $post->region_slug); |
|
1765 | + $post->country_slug = str_replace('[', '', $post_locations[2]); |
|
1766 | + $post->country_slug = str_replace(']', '', $post->country_slug); |
|
1767 | + } |
|
1768 | + } |
|
1769 | 1769 | |
1770 | - if (isset($post->country_slug)) { |
|
1771 | - $location_terms = array( |
|
1772 | - 'gd_country' => $post->country_slug, |
|
1773 | - 'gd_region' => $post->region_slug, |
|
1774 | - 'gd_city' => $post->city_slug |
|
1775 | - ); |
|
1770 | + if (isset($post->country_slug)) { |
|
1771 | + $location_terms = array( |
|
1772 | + 'gd_country' => $post->country_slug, |
|
1773 | + 'gd_region' => $post->region_slug, |
|
1774 | + 'gd_city' => $post->city_slug |
|
1775 | + ); |
|
1776 | 1776 | |
1777 | - if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) { |
|
1778 | - $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
1779 | - } |
|
1780 | - } |
|
1781 | - } |
|
1777 | + if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) { |
|
1778 | + $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
1779 | + } |
|
1780 | + } |
|
1781 | + } |
|
1782 | 1782 | |
1783 | - if (empty($location_terms)) { |
|
1784 | - $location_terms = geodir_get_current_location_terms('query_vars'); |
|
1785 | - } |
|
1783 | + if (empty($location_terms)) { |
|
1784 | + $location_terms = geodir_get_current_location_terms('query_vars'); |
|
1785 | + } |
|
1786 | 1786 | |
1787 | - $geodir_show_location_url = get_option('geodir_show_location_url'); |
|
1788 | - $location_terms = geodir_remove_location_terms($location_terms); |
|
1787 | + $geodir_show_location_url = get_option('geodir_show_location_url'); |
|
1788 | + $location_terms = geodir_remove_location_terms($location_terms); |
|
1789 | 1789 | |
1790 | - if (!empty($location_terms)) { |
|
1791 | - $url_separator = ''; |
|
1790 | + if (!empty($location_terms)) { |
|
1791 | + $url_separator = ''; |
|
1792 | 1792 | |
1793 | - if (get_option('permalink_structure') != '') { |
|
1794 | - $found = false; |
|
1793 | + if (get_option('permalink_structure') != '') { |
|
1794 | + $found = false; |
|
1795 | 1795 | $request_term = implode("/", $location_terms); |
1796 | 1796 | if (geodir_is_wpml()) { |
1797 | 1797 | $post_types = get_option('geodir_post_types'); |
@@ -1827,47 +1827,47 @@ discard block |
||
1827 | 1827 | |
1828 | 1828 | $termlink = substr_replace($termlink, $new_listing_slug, strpos($termlink, $old_listing_slug), strlen($old_listing_slug)); |
1829 | 1829 | } |
1830 | - } else { |
|
1831 | - $termlink = geodir_getlink($termlink, $request_term); |
|
1832 | - } |
|
1833 | - } |
|
1834 | - } |
|
1830 | + } else { |
|
1831 | + $termlink = geodir_getlink($termlink, $request_term); |
|
1832 | + } |
|
1833 | + } |
|
1834 | + } |
|
1835 | 1835 | |
1836 | - // Alter the CPT slug is WPML is set to do so |
|
1837 | - /* we can replace this with the below function |
|
1836 | + // Alter the CPT slug is WPML is set to do so |
|
1837 | + /* we can replace this with the below function |
|
1838 | 1838 | if(geodir_is_wpml()){ |
1839 | 1839 | global $sitepress; |
1840 | 1840 | $post_type = str_replace("category","",$taxonomy); |
1841 | 1841 | $termlink = $sitepress->post_type_archive_link_filter( $termlink, $post_type); |
1842 | 1842 | }*/ |
1843 | 1843 | |
1844 | - // Alter the CPT slug if WPML is set to do so |
|
1845 | - if (geodir_is_wpml()) { |
|
1846 | - $post_types = get_option('geodir_post_types'); |
|
1847 | - $post_type = str_replace("category","",$taxonomy); |
|
1848 | - $post_type = str_replace("_tags","",$post_type); |
|
1849 | - $slug = $post_types[$post_type]['rewrite']['slug']; |
|
1850 | - if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) { |
|
1851 | - global $sitepress; |
|
1852 | - $default_lang = $sitepress->get_default_language(); |
|
1853 | - $language_code = gd_wpml_get_lang_from_url($orig_termlink); |
|
1854 | - if (!$language_code ) { |
|
1855 | - $language_code = $default_lang; |
|
1856 | - } |
|
1844 | + // Alter the CPT slug if WPML is set to do so |
|
1845 | + if (geodir_is_wpml()) { |
|
1846 | + $post_types = get_option('geodir_post_types'); |
|
1847 | + $post_type = str_replace("category","",$taxonomy); |
|
1848 | + $post_type = str_replace("_tags","",$post_type); |
|
1849 | + $slug = $post_types[$post_type]['rewrite']['slug']; |
|
1850 | + if (geodir_wpml_is_post_type_translated($post_type) && gd_wpml_slug_translation_turned_on($post_type)) { |
|
1851 | + global $sitepress; |
|
1852 | + $default_lang = $sitepress->get_default_language(); |
|
1853 | + $language_code = gd_wpml_get_lang_from_url($orig_termlink); |
|
1854 | + if (!$language_code ) { |
|
1855 | + $language_code = $default_lang; |
|
1856 | + } |
|
1857 | 1857 | |
1858 | - $org_slug = $slug; |
|
1859 | - $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code); |
|
1858 | + $org_slug = $slug; |
|
1859 | + $slug = apply_filters('wpml_translate_single_string', $slug, 'WordPress', 'URL slug: ' . $slug, $language_code); |
|
1860 | 1860 | |
1861 | - if (!$slug) { |
|
1862 | - $slug = $org_slug; |
|
1863 | - } |
|
1861 | + if (!$slug) { |
|
1862 | + $slug = $org_slug; |
|
1863 | + } |
|
1864 | 1864 | |
1865 | - $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1)); |
|
1866 | - } |
|
1867 | - } |
|
1868 | - } |
|
1865 | + $termlink = trailingslashit(preg_replace("/" . preg_quote($org_slug, "/") . "/", $slug ,$termlink, 1)); |
|
1866 | + } |
|
1867 | + } |
|
1868 | + } |
|
1869 | 1869 | |
1870 | - return $termlink; |
|
1870 | + return $termlink; |
|
1871 | 1871 | } |
1872 | 1872 | |
1873 | 1873 | /** |
@@ -1893,14 +1893,14 @@ discard block |
||
1893 | 1893 | if (in_array($post_type, geodir_get_posttypes())) { |
1894 | 1894 | if (get_option('geodir_add_location_url') && $gd_session->get('gd_multi_location') == 1) { |
1895 | 1895 | if(geodir_is_page('detail') && !empty($post) && isset($post->country_slug)) { |
1896 | - $location_terms = array( |
|
1897 | - 'gd_country' => $post->country_slug, |
|
1898 | - 'gd_region' => $post->region_slug, |
|
1899 | - 'gd_city' => $post->city_slug |
|
1900 | - ); |
|
1901 | - } else { |
|
1902 | - $location_terms = geodir_get_current_location_terms('query_vars'); |
|
1903 | - } |
|
1896 | + $location_terms = array( |
|
1897 | + 'gd_country' => $post->country_slug, |
|
1898 | + 'gd_region' => $post->region_slug, |
|
1899 | + 'gd_city' => $post->city_slug |
|
1900 | + ); |
|
1901 | + } else { |
|
1902 | + $location_terms = geodir_get_current_location_terms('query_vars'); |
|
1903 | + } |
|
1904 | 1904 | |
1905 | 1905 | $location_terms = geodir_remove_location_terms($location_terms); |
1906 | 1906 | |
@@ -1932,17 +1932,17 @@ discard block |
||
1932 | 1932 | * @return void|string Label. |
1933 | 1933 | */ |
1934 | 1934 | function get_post_type_singular_label($post_type, $echo = false, $translate = false) { |
1935 | - $obj_post_type = get_post_type_object($post_type); |
|
1936 | - if (!is_object($obj_post_type)) { |
|
1937 | - return; |
|
1938 | - } |
|
1935 | + $obj_post_type = get_post_type_object($post_type); |
|
1936 | + if (!is_object($obj_post_type)) { |
|
1937 | + return; |
|
1938 | + } |
|
1939 | 1939 | |
1940 | - $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
|
1940 | + $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
|
1941 | 1941 | |
1942 | - if ($echo) |
|
1943 | - echo $label; |
|
1944 | - else |
|
1945 | - return $label; |
|
1942 | + if ($echo) |
|
1943 | + echo $label; |
|
1944 | + else |
|
1945 | + return $label; |
|
1946 | 1946 | } |
1947 | 1947 | |
1948 | 1948 | /** |
@@ -1957,19 +1957,19 @@ discard block |
||
1957 | 1957 | * @return void|string Label. |
1958 | 1958 | */ |
1959 | 1959 | function get_post_type_plural_label($post_type, $echo = false, $translate = false) { |
1960 | - $all_postypes = geodir_get_posttypes(); |
|
1960 | + $all_postypes = geodir_get_posttypes(); |
|
1961 | 1961 | |
1962 | - if (!in_array($post_type, $all_postypes)) |
|
1963 | - return false; |
|
1962 | + if (!in_array($post_type, $all_postypes)) |
|
1963 | + return false; |
|
1964 | 1964 | |
1965 | - $obj_post_type = get_post_type_object($post_type); |
|
1965 | + $obj_post_type = get_post_type_object($post_type); |
|
1966 | 1966 | |
1967 | - $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
|
1967 | + $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
|
1968 | 1968 | |
1969 | - if ($echo) |
|
1970 | - echo $label; |
|
1971 | - else |
|
1972 | - return $label; |
|
1969 | + if ($echo) |
|
1970 | + echo $label; |
|
1971 | + else |
|
1972 | + return $label; |
|
1973 | 1973 | } |
1974 | 1974 | |
1975 | 1975 | /** |
@@ -1987,51 +1987,51 @@ discard block |
||
1987 | 1987 | */ |
1988 | 1988 | function geodir_term_exists($term, $taxonomy = '', $parent = 0) |
1989 | 1989 | { |
1990 | - global $wpdb; |
|
1991 | - |
|
1992 | - $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
1993 | - $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 "; |
|
1994 | - |
|
1995 | - if (is_int($term)) { |
|
1996 | - if (0 == $term) |
|
1997 | - return 0; |
|
1998 | - $where = 't.term_id = %d'; |
|
1999 | - if (!empty($taxonomy)) |
|
2000 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
2001 | - else |
|
2002 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
2003 | - } |
|
1990 | + global $wpdb; |
|
1991 | + |
|
1992 | + $select = "SELECT term_id FROM $wpdb->terms as t WHERE "; |
|
1993 | + $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 "; |
|
1994 | + |
|
1995 | + if (is_int($term)) { |
|
1996 | + if (0 == $term) |
|
1997 | + return 0; |
|
1998 | + $where = 't.term_id = %d'; |
|
1999 | + if (!empty($taxonomy)) |
|
2000 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
2001 | + else |
|
2002 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
2003 | + } |
|
2004 | 2004 | |
2005 | - $term = trim(wp_unslash($term)); |
|
2005 | + $term = trim(wp_unslash($term)); |
|
2006 | 2006 | |
2007 | - if ('' === $slug = sanitize_title($term)) |
|
2008 | - return 0; |
|
2007 | + if ('' === $slug = sanitize_title($term)) |
|
2008 | + return 0; |
|
2009 | 2009 | |
2010 | - $where = 't.slug = %s'; |
|
2010 | + $where = 't.slug = %s'; |
|
2011 | 2011 | |
2012 | - $where_fields = array($slug); |
|
2013 | - if (!empty($taxonomy)) { |
|
2014 | - $parent = (int)$parent; |
|
2015 | - if ($parent > 0) { |
|
2016 | - $where_fields[] = $parent; |
|
2017 | - $else_where_fields[] = $parent; |
|
2018 | - $where .= ' AND tt.parent = %d'; |
|
2012 | + $where_fields = array($slug); |
|
2013 | + if (!empty($taxonomy)) { |
|
2014 | + $parent = (int)$parent; |
|
2015 | + if ($parent > 0) { |
|
2016 | + $where_fields[] = $parent; |
|
2017 | + $else_where_fields[] = $parent; |
|
2018 | + $where .= ' AND tt.parent = %d'; |
|
2019 | 2019 | |
2020 | - } |
|
2020 | + } |
|
2021 | 2021 | |
2022 | - $where_fields[] = $taxonomy; |
|
2022 | + $where_fields[] = $taxonomy; |
|
2023 | 2023 | |
2024 | 2024 | |
2025 | - 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)) |
|
2026 | - return $result; |
|
2025 | + 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)) |
|
2026 | + return $result; |
|
2027 | 2027 | |
2028 | - return false; |
|
2029 | - } |
|
2028 | + return false; |
|
2029 | + } |
|
2030 | 2030 | |
2031 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) |
|
2032 | - return $result; |
|
2031 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) |
|
2032 | + return $result; |
|
2033 | 2033 | |
2034 | - return false; |
|
2034 | + return false; |
|
2035 | 2035 | } |
2036 | 2036 | |
2037 | 2037 | /** |
@@ -2043,7 +2043,7 @@ discard block |
||
2043 | 2043 | function geodir_get_term_icon_rebuild() |
2044 | 2044 | { |
2045 | 2045 | |
2046 | - update_option('gd_term_icons', ''); |
|
2046 | + update_option('gd_term_icons', ''); |
|
2047 | 2047 | |
2048 | 2048 | } |
2049 | 2049 | |
@@ -2061,61 +2061,61 @@ discard block |
||
2061 | 2061 | */ |
2062 | 2062 | function geodir_get_term_icon($term_id = false, $rebuild = false) |
2063 | 2063 | { |
2064 | - global $wpdb; |
|
2065 | - if (!$rebuild) { |
|
2066 | - $terms_icons = get_option('gd_term_icons'); |
|
2067 | - } else { |
|
2068 | - $terms_icons = array(); |
|
2069 | - } |
|
2070 | - |
|
2071 | - if (empty($terms_icons)) { |
|
2072 | - $terms_icons = array(); |
|
2073 | - $default_icon_url = get_option('geodir_default_marker_icon'); |
|
2074 | - $taxonomy = geodir_get_taxonomies(); |
|
2075 | - $post_types = geodir_get_posttypes(); |
|
2076 | - $tax_arr = array(); |
|
2077 | - foreach ($post_types as $post_type) { |
|
2078 | - $tax_arr[] = "'" . $post_type . "category'"; |
|
2079 | - } |
|
2080 | - $tax_c = implode(',', $tax_arr); |
|
2081 | - $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)"); |
|
2082 | - //$terms = get_terms( $taxonomy ); |
|
2083 | - |
|
2084 | - if($terms) { |
|
2085 | - foreach ($terms as $term) { |
|
2086 | - $post_type = str_replace("category", "", $term->taxonomy); |
|
2087 | - $a_terms[$post_type][] = $term; |
|
2064 | + global $wpdb; |
|
2065 | + if (!$rebuild) { |
|
2066 | + $terms_icons = get_option('gd_term_icons'); |
|
2067 | + } else { |
|
2068 | + $terms_icons = array(); |
|
2069 | + } |
|
2088 | 2070 | |
2089 | - } |
|
2090 | - } |
|
2071 | + if (empty($terms_icons)) { |
|
2072 | + $terms_icons = array(); |
|
2073 | + $default_icon_url = get_option('geodir_default_marker_icon'); |
|
2074 | + $taxonomy = geodir_get_taxonomies(); |
|
2075 | + $post_types = geodir_get_posttypes(); |
|
2076 | + $tax_arr = array(); |
|
2077 | + foreach ($post_types as $post_type) { |
|
2078 | + $tax_arr[] = "'" . $post_type . "category'"; |
|
2079 | + } |
|
2080 | + $tax_c = implode(',', $tax_arr); |
|
2081 | + $terms = $wpdb->get_results("SELECT * FROM $wpdb->term_taxonomy WHERE taxonomy IN ($tax_c)"); |
|
2082 | + //$terms = get_terms( $taxonomy ); |
|
2091 | 2083 | |
2092 | - if($a_terms) { |
|
2093 | - foreach ($a_terms as $pt => $t2) { |
|
2084 | + if($terms) { |
|
2085 | + foreach ($terms as $term) { |
|
2086 | + $post_type = str_replace("category", "", $term->taxonomy); |
|
2087 | + $a_terms[$post_type][] = $term; |
|
2094 | 2088 | |
2095 | - foreach ($t2 as $term) { |
|
2096 | - $term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
2097 | - if ($term_icon) { |
|
2098 | - $term_icon_url = $term_icon["src"]; |
|
2099 | - } else { |
|
2100 | - $term_icon_url = $default_icon_url; |
|
2101 | - } |
|
2102 | - $terms_icons[$term->term_id] = $term_icon_url; |
|
2103 | - } |
|
2104 | - } |
|
2105 | - } |
|
2089 | + } |
|
2090 | + } |
|
2106 | 2091 | |
2107 | - update_option('gd_term_icons', $terms_icons); |
|
2108 | - } |
|
2092 | + if($a_terms) { |
|
2093 | + foreach ($a_terms as $pt => $t2) { |
|
2109 | 2094 | |
2110 | - if ($term_id && isset($terms_icons[$term_id])) { |
|
2111 | - return $terms_icons[$term_id]; |
|
2112 | - } elseif ($term_id && !isset($terms_icons[$term_id])) { |
|
2113 | - return get_option('geodir_default_marker_icon'); |
|
2114 | - } |
|
2095 | + foreach ($t2 as $term) { |
|
2096 | + $term_icon = geodir_get_tax_meta($term->term_id, 'ct_cat_icon', false, $pt); |
|
2097 | + if ($term_icon) { |
|
2098 | + $term_icon_url = $term_icon["src"]; |
|
2099 | + } else { |
|
2100 | + $term_icon_url = $default_icon_url; |
|
2101 | + } |
|
2102 | + $terms_icons[$term->term_id] = $term_icon_url; |
|
2103 | + } |
|
2104 | + } |
|
2105 | + } |
|
2106 | + |
|
2107 | + update_option('gd_term_icons', $terms_icons); |
|
2108 | + } |
|
2109 | + |
|
2110 | + if ($term_id && isset($terms_icons[$term_id])) { |
|
2111 | + return $terms_icons[$term_id]; |
|
2112 | + } elseif ($term_id && !isset($terms_icons[$term_id])) { |
|
2113 | + return get_option('geodir_default_marker_icon'); |
|
2114 | + } |
|
2115 | 2115 | |
2116 | - if (is_ssl()) { |
|
2117 | - $terms_icons = str_replace("http:","https:",$terms_icons ); |
|
2118 | - } |
|
2116 | + if (is_ssl()) { |
|
2117 | + $terms_icons = str_replace("http:","https:",$terms_icons ); |
|
2118 | + } |
|
2119 | 2119 | |
2120 | - return apply_filters('geodir_get_term_icons', $terms_icons, $term_id); |
|
2120 | + return apply_filters('geodir_get_term_icons', $terms_icons, $term_id); |
|
2121 | 2121 | } |
2122 | 2122 | \ No newline at end of file |
@@ -36,177 +36,177 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function geodir_templates_scripts() |
38 | 38 | { |
39 | - $is_detail_page = false; |
|
40 | - $geodir_map_name = geodir_map_name(); |
|
39 | + $is_detail_page = false; |
|
40 | + $geodir_map_name = geodir_map_name(); |
|
41 | 41 | |
42 | - if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) { |
|
43 | - $is_detail_page = true; |
|
44 | - } |
|
42 | + if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) { |
|
43 | + $is_detail_page = true; |
|
44 | + } |
|
45 | 45 | |
46 | - wp_enqueue_script('jquery'); |
|
46 | + wp_enqueue_script('jquery'); |
|
47 | 47 | |
48 | - wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION); |
|
49 | - wp_enqueue_script('geodirectory-script'); |
|
48 | + wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION); |
|
49 | + wp_enqueue_script('geodirectory-script'); |
|
50 | 50 | |
51 | - $geodir_vars_data = array( |
|
52 | - 'siteurl' => get_option('siteurl'), |
|
53 | - 'geodir_plugin_url' => geodir_plugin_url(), |
|
54 | - 'geodir_lazy_load' => get_option('geodir_lazy_load',1), |
|
55 | - 'geodir_ajax_url' => geodir_get_ajax_url(), |
|
56 | - 'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'), |
|
57 | - 'is_rtl' => is_rtl() ? 1 : 0, // fix rtl issue |
|
51 | + $geodir_vars_data = array( |
|
52 | + 'siteurl' => get_option('siteurl'), |
|
53 | + 'geodir_plugin_url' => geodir_plugin_url(), |
|
54 | + 'geodir_lazy_load' => get_option('geodir_lazy_load',1), |
|
55 | + 'geodir_ajax_url' => geodir_get_ajax_url(), |
|
56 | + 'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'), |
|
57 | + 'is_rtl' => is_rtl() ? 1 : 0, // fix rtl issue |
|
58 | 58 | 'lightBox_txtImage' => addslashes(__('Image', 'geodirectory')), |
59 | 59 | 'lightBox_txtOf' => addslashes(__('of', 'geodirectory')), |
60 | - ); |
|
61 | - |
|
62 | - /** |
|
63 | - * Filter the `geodir_var` data array that outputs the wp_localize_script() translations and variables. |
|
64 | - * |
|
65 | - * This is used by addons to add JS translatable variables. |
|
66 | - * |
|
67 | - * @since 1.4.4 |
|
68 | - * @param array $geodir_vars_data { |
|
69 | - * geodir var data used by addons to add JS translatable variables. |
|
70 | - * |
|
71 | - * @type string $siteurl Site url. |
|
72 | - * @type string $geodir_plugin_url Geodirectory core plugin url. |
|
73 | - * @type string $geodir_ajax_url Geodirectory plugin ajax url. |
|
74 | - * @type int $geodir_gd_modal Disable GD modal that displays slideshow images in popup?. |
|
75 | - * @type int $is_rtl Checks if current locale is RTL. |
|
76 | - * |
|
77 | - * } |
|
78 | - */ |
|
79 | - $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data); |
|
80 | - |
|
81 | - wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data); |
|
82 | - |
|
83 | - wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true); |
|
84 | - if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');} |
|
85 | - |
|
86 | - wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true); |
|
87 | - wp_enqueue_script('geodirectory-lightbox-jquery'); |
|
88 | - |
|
89 | - wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true); |
|
90 | - if ($is_detail_page) { |
|
91 | - wp_enqueue_script('geodirectory-jquery-simplemodal'); |
|
92 | - } |
|
60 | + ); |
|
61 | + |
|
62 | + /** |
|
63 | + * Filter the `geodir_var` data array that outputs the wp_localize_script() translations and variables. |
|
64 | + * |
|
65 | + * This is used by addons to add JS translatable variables. |
|
66 | + * |
|
67 | + * @since 1.4.4 |
|
68 | + * @param array $geodir_vars_data { |
|
69 | + * geodir var data used by addons to add JS translatable variables. |
|
70 | + * |
|
71 | + * @type string $siteurl Site url. |
|
72 | + * @type string $geodir_plugin_url Geodirectory core plugin url. |
|
73 | + * @type string $geodir_ajax_url Geodirectory plugin ajax url. |
|
74 | + * @type int $geodir_gd_modal Disable GD modal that displays slideshow images in popup?. |
|
75 | + * @type int $is_rtl Checks if current locale is RTL. |
|
76 | + * |
|
77 | + * } |
|
78 | + */ |
|
79 | + $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data); |
|
80 | + |
|
81 | + wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data); |
|
82 | + |
|
83 | + wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true); |
|
84 | + if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');} |
|
85 | + |
|
86 | + wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true); |
|
87 | + wp_enqueue_script('geodirectory-lightbox-jquery'); |
|
88 | + |
|
89 | + wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true); |
|
90 | + if ($is_detail_page) { |
|
91 | + wp_enqueue_script('geodirectory-jquery-simplemodal'); |
|
92 | + } |
|
93 | 93 | |
94 | - if (in_array($geodir_map_name, array('auto', 'google'))) { |
|
95 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
96 | - $map_key = "&key=" . geodir_get_map_api_key(); |
|
97 | - /** |
|
98 | - * Filter the variables that are added to the end of the google maps script call. |
|
99 | - * |
|
100 | - * This i used to change things like google maps language etc. |
|
101 | - * |
|
102 | - * @since 1.0.0 |
|
103 | - * @param string $var The string to filter, default is empty string. |
|
104 | - */ |
|
105 | - $map_extra = apply_filters('geodir_googlemap_script_extra', ''); |
|
106 | - wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL); |
|
94 | + if (in_array($geodir_map_name, array('auto', 'google'))) { |
|
95 | + $map_lang = "&language=" . geodir_get_map_default_language(); |
|
96 | + $map_key = "&key=" . geodir_get_map_api_key(); |
|
97 | + /** |
|
98 | + * Filter the variables that are added to the end of the google maps script call. |
|
99 | + * |
|
100 | + * This i used to change things like google maps language etc. |
|
101 | + * |
|
102 | + * @since 1.0.0 |
|
103 | + * @param string $var The string to filter, default is empty string. |
|
104 | + */ |
|
105 | + $map_extra = apply_filters('geodir_googlemap_script_extra', ''); |
|
106 | + wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL); |
|
107 | 107 | |
108 | - // Overlapping Marker Spiderfier |
|
109 | - wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION); |
|
110 | - wp_enqueue_script('geodirectory-g-overlappingmarker-script'); |
|
111 | - } |
|
108 | + // Overlapping Marker Spiderfier |
|
109 | + wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION); |
|
110 | + wp_enqueue_script('geodirectory-g-overlappingmarker-script'); |
|
111 | + } |
|
112 | 112 | |
113 | - if ($geodir_map_name == 'osm') { |
|
114 | - // Leaflet OpenStreetMap |
|
115 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION); |
|
116 | - wp_enqueue_style('geodirectory-leaflet-style'); |
|
113 | + if ($geodir_map_name == 'osm') { |
|
114 | + // Leaflet OpenStreetMap |
|
115 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION); |
|
116 | + wp_enqueue_style('geodirectory-leaflet-style'); |
|
117 | 117 | |
118 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
119 | - wp_enqueue_script('geodirectory-leaflet-script'); |
|
118 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
119 | + wp_enqueue_script('geodirectory-leaflet-script'); |
|
120 | 120 | |
121 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION); |
|
122 | - wp_enqueue_script('geodirectory-leaflet-geo-script'); |
|
121 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION); |
|
122 | + wp_enqueue_script('geodirectory-leaflet-geo-script'); |
|
123 | 123 | |
124 | - if ($is_detail_page) { |
|
125 | - wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION); |
|
126 | - wp_enqueue_style('geodirectory-leaflet-routing-style'); |
|
124 | + if ($is_detail_page) { |
|
125 | + wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION); |
|
126 | + wp_enqueue_style('geodirectory-leaflet-routing-style'); |
|
127 | 127 | |
128 | - wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION); |
|
129 | - wp_enqueue_script('geodirectory-leaflet-routing-script'); |
|
130 | - } |
|
128 | + wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION); |
|
129 | + wp_enqueue_script('geodirectory-leaflet-routing-script'); |
|
130 | + } |
|
131 | 131 | |
132 | - // Overlapping Marker Spiderfier Leaflet |
|
133 | - wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
134 | - wp_enqueue_script('geodirectory-o-overlappingmarker-script'); |
|
135 | - } |
|
136 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
132 | + // Overlapping Marker Spiderfier Leaflet |
|
133 | + wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
134 | + wp_enqueue_script('geodirectory-o-overlappingmarker-script'); |
|
135 | + } |
|
136 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
137 | 137 | |
138 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true); |
|
139 | - wp_enqueue_script('geodirectory-goMap-script'); |
|
140 | - |
|
141 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION); |
|
142 | - wp_enqueue_script('chosen'); |
|
143 | - |
|
144 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION); |
|
145 | - wp_enqueue_script('geodirectory-choose-ajax'); |
|
146 | - |
|
147 | - wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true); |
|
148 | - |
|
149 | - if (is_page() && geodir_is_page('add-listing')) { |
|
150 | - // SCRIPT FOR UPLOAD |
|
151 | - wp_enqueue_script('plupload-all'); |
|
152 | - wp_enqueue_script('jquery-ui-sortable'); |
|
153 | - |
|
154 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true); |
|
155 | - wp_enqueue_script('geodirectory-plupload-script'); |
|
156 | - // SCRIPT FOR UPLOAD END |
|
157 | - |
|
158 | - // check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls |
|
159 | - if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
160 | - $ajax_url = admin_url('admin-ajax.php'); |
|
161 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
162 | - $ajax_url = admin_url('admin-ajax.php'); |
|
163 | - } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
164 | - $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php')); |
|
165 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
166 | - $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php')); |
|
167 | - } else { |
|
168 | - $ajax_url = admin_url('admin-ajax.php'); |
|
169 | - } |
|
138 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true); |
|
139 | + wp_enqueue_script('geodirectory-goMap-script'); |
|
140 | + |
|
141 | + wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION); |
|
142 | + wp_enqueue_script('chosen'); |
|
143 | + |
|
144 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION); |
|
145 | + wp_enqueue_script('geodirectory-choose-ajax'); |
|
146 | + |
|
147 | + wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true); |
|
148 | + |
|
149 | + if (is_page() && geodir_is_page('add-listing')) { |
|
150 | + // SCRIPT FOR UPLOAD |
|
151 | + wp_enqueue_script('plupload-all'); |
|
152 | + wp_enqueue_script('jquery-ui-sortable'); |
|
153 | + |
|
154 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true); |
|
155 | + wp_enqueue_script('geodirectory-plupload-script'); |
|
156 | + // SCRIPT FOR UPLOAD END |
|
157 | + |
|
158 | + // check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls |
|
159 | + if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
160 | + $ajax_url = admin_url('admin-ajax.php'); |
|
161 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
162 | + $ajax_url = admin_url('admin-ajax.php'); |
|
163 | + } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
164 | + $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php')); |
|
165 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
166 | + $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php')); |
|
167 | + } else { |
|
168 | + $ajax_url = admin_url('admin-ajax.php'); |
|
169 | + } |
|
170 | 170 | |
171 | - // place js config array for plupload |
|
172 | - $plupload_init = array( |
|
173 | - 'runtimes' => 'html5,silverlight,browserplus,gears,html4', |
|
174 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
175 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
176 | - 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
177 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
178 | - 'multiple_queues' => true, |
|
179 | - 'max_file_size' => geodir_max_upload_size(), |
|
180 | - 'url' => $ajax_url, |
|
181 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
|
182 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
|
183 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')), |
|
184 | - 'multipart' => true, |
|
185 | - 'urlstream_upload' => true, |
|
186 | - 'multi_selection' => false, // will be added per uploader |
|
187 | - // additional post data to send to our ajax hook |
|
188 | - 'multipart_params' => array( |
|
189 | - '_ajax_nonce' => "", // will be added per uploader |
|
190 | - 'action' => 'plupload_action', // the ajax action name |
|
191 | - 'imgid' => 0 // will be added per uploader |
|
192 | - ) |
|
193 | - ); |
|
194 | - $base_plupload_config = json_encode($plupload_init); |
|
195 | - |
|
196 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config, |
|
197 | - 'upload_img_size' => geodir_max_upload_size()); |
|
198 | - |
|
199 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init); |
|
200 | - |
|
201 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload'); |
|
202 | - } // End if for add place page |
|
203 | - |
|
204 | - wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
205 | - if ($is_detail_page) { |
|
171 | + // place js config array for plupload |
|
172 | + $plupload_init = array( |
|
173 | + 'runtimes' => 'html5,silverlight,browserplus,gears,html4', |
|
174 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
175 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
176 | + 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
177 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
178 | + 'multiple_queues' => true, |
|
179 | + 'max_file_size' => geodir_max_upload_size(), |
|
180 | + 'url' => $ajax_url, |
|
181 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
|
182 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
|
183 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')), |
|
184 | + 'multipart' => true, |
|
185 | + 'urlstream_upload' => true, |
|
186 | + 'multi_selection' => false, // will be added per uploader |
|
187 | + // additional post data to send to our ajax hook |
|
188 | + 'multipart_params' => array( |
|
189 | + '_ajax_nonce' => "", // will be added per uploader |
|
190 | + 'action' => 'plupload_action', // the ajax action name |
|
191 | + 'imgid' => 0 // will be added per uploader |
|
192 | + ) |
|
193 | + ); |
|
194 | + $base_plupload_config = json_encode($plupload_init); |
|
195 | + |
|
196 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config, |
|
197 | + 'upload_img_size' => geodir_max_upload_size()); |
|
198 | + |
|
199 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init); |
|
200 | + |
|
201 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload'); |
|
202 | + } // End if for add place page |
|
203 | + |
|
204 | + wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
205 | + if ($is_detail_page) { |
|
206 | 206 | wp_enqueue_script('geodirectory-post-custom-js'); |
207 | 207 | } |
208 | 208 | |
209 | - // font awesome rating script |
|
209 | + // font awesome rating script |
|
210 | 210 | if (get_option('geodir_reviewrating_enable_font_awesome')) { |
211 | 211 | wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true); |
212 | 212 | wp_enqueue_script('geodir-barrating-js'); |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | wp_enqueue_script('geodir-jRating-js'); |
216 | 216 | } |
217 | 217 | |
218 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
219 | - wp_enqueue_script('geodir-on-document-load'); |
|
218 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
219 | + wp_enqueue_script('geodir-on-document-load'); |
|
220 | 220 | |
221 | - wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
222 | - wp_enqueue_script('google-geometa'); |
|
221 | + wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
222 | + wp_enqueue_script('google-geometa'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | */ |
234 | 234 | function geodir_header_scripts() |
235 | 235 | { |
236 | - echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>'; |
|
237 | - echo stripslashes(get_option('geodir_header_scripts')); |
|
236 | + echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>'; |
|
237 | + echo stripslashes(get_option('geodir_header_scripts')); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | function geodir_google_analytics_tracking_code() |
249 | 249 | { |
250 | - if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?> |
|
250 | + if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?> |
|
251 | 251 | |
252 | 252 | <script> |
253 | 253 | (function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | </script> |
263 | 263 | |
264 | 264 | <?php |
265 | - }elseif( get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){ |
|
266 | - echo stripslashes(get_option('geodir_ga_tracking_code')); |
|
267 | - } |
|
265 | + }elseif( get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){ |
|
266 | + echo stripslashes(get_option('geodir_ga_tracking_code')); |
|
267 | + } |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -278,16 +278,16 @@ discard block |
||
278 | 278 | function geodir_footer_scripts() |
279 | 279 | { |
280 | 280 | |
281 | - echo stripslashes(get_option('geodir_footer_scripts')); |
|
281 | + echo stripslashes(get_option('geodir_footer_scripts')); |
|
282 | 282 | |
283 | - /* |
|
283 | + /* |
|
284 | 284 | * Apple suck and can't/won't fix bugs: https://bugs.webkit.org/show_bug.cgi?id=136041 |
285 | 285 | * |
286 | 286 | * Flexbox wont wrap on ios for search form items |
287 | 287 | */ |
288 | - if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
289 | - echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>"; |
|
290 | - } |
|
288 | + if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
289 | + echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>"; |
|
290 | + } |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | */ |
302 | 302 | function geodir_add_async_forscript($url) |
303 | 303 | { |
304 | - if (strpos($url, '#asyncload')===false) |
|
305 | - return $url; |
|
306 | - else if (is_admin()) |
|
307 | - return str_replace('#asyncload', '', $url); |
|
308 | - else |
|
309 | - return str_replace('#asyncload', '', $url)."' async='async"; |
|
304 | + if (strpos($url, '#asyncload')===false) |
|
305 | + return $url; |
|
306 | + else if (is_admin()) |
|
307 | + return str_replace('#asyncload', '', $url); |
|
308 | + else |
|
309 | + return str_replace('#asyncload', '', $url)."' async='async"; |
|
310 | 310 | } |
311 | 311 | add_filter('clean_url', 'geodir_add_async_forscript', 11, 1); |
312 | 312 | |
@@ -319,17 +319,17 @@ discard block |
||
319 | 319 | function geodir_templates_styles() |
320 | 320 | { |
321 | 321 | |
322 | - wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION); |
|
323 | - wp_enqueue_style('geodir-core-scss'); |
|
324 | - wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION); |
|
322 | + wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION); |
|
323 | + wp_enqueue_style('geodir-core-scss'); |
|
324 | + wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION); |
|
325 | 325 | |
326 | - if(is_rtl()){ |
|
327 | - wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION); |
|
328 | - wp_enqueue_style('geodirectory-frontend-rtl-style'); |
|
329 | - } |
|
326 | + if(is_rtl()){ |
|
327 | + wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION); |
|
328 | + wp_enqueue_style('geodirectory-frontend-rtl-style'); |
|
329 | + } |
|
330 | 330 | |
331 | - wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION); |
|
332 | - wp_enqueue_style('font-awesome'); |
|
331 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION); |
|
332 | + wp_enqueue_style('font-awesome'); |
|
333 | 333 | |
334 | 334 | |
335 | 335 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | function geodir_get_sidebar() |
345 | 345 | { |
346 | - get_sidebar('geodirectory'); |
|
346 | + get_sidebar('geodirectory'); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -362,122 +362,122 @@ discard block |
||
362 | 362 | * @param bool $always_show Do you want to show the pagination always? Default: false. |
363 | 363 | */ |
364 | 364 | function geodir_pagination($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) { |
365 | - global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id; |
|
365 | + global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id; |
|
366 | 366 | |
367 | - if (empty($prelabel)) { |
|
368 | - $prelabel = '<strong><</strong>'; |
|
369 | - } |
|
367 | + if (empty($prelabel)) { |
|
368 | + $prelabel = '<strong><</strong>'; |
|
369 | + } |
|
370 | 370 | |
371 | - if (empty($nxtlabel)) { |
|
372 | - $nxtlabel = '<strong>></strong>'; |
|
373 | - } |
|
371 | + if (empty($nxtlabel)) { |
|
372 | + $nxtlabel = '<strong>></strong>'; |
|
373 | + } |
|
374 | 374 | |
375 | - $half_pages_to_show = round($pages_to_show / 2); |
|
375 | + $half_pages_to_show = round($pages_to_show / 2); |
|
376 | 376 | |
377 | - if (geodir_is_page('home')) // dont apply default pagination for geodirectory home page. |
|
378 | - return; |
|
377 | + if (geodir_is_page('home')) // dont apply default pagination for geodirectory home page. |
|
378 | + return; |
|
379 | 379 | |
380 | - if (!is_single()) { |
|
381 | - if (function_exists('geodir_location_geo_home_link')) { |
|
382 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
383 | - } |
|
384 | - $numposts = $wp_query->found_posts; |
|
380 | + if (!is_single()) { |
|
381 | + if (function_exists('geodir_location_geo_home_link')) { |
|
382 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
383 | + } |
|
384 | + $numposts = $wp_query->found_posts; |
|
385 | 385 | |
386 | - $max_page = ceil($numposts / $posts_per_page); |
|
386 | + $max_page = ceil($numposts / $posts_per_page); |
|
387 | 387 | |
388 | - if (empty($paged)) { |
|
389 | - $paged = 1; |
|
390 | - } |
|
388 | + if (empty($paged)) { |
|
389 | + $paged = 1; |
|
390 | + } |
|
391 | 391 | |
392 | - $post_type = geodir_get_current_posttype(); |
|
393 | - $listing_type_name = get_post_type_plural_label($post_type); |
|
394 | - if (geodir_is_page('listing') || geodir_is_page('search')) { |
|
395 | - $term = array(); |
|
392 | + $post_type = geodir_get_current_posttype(); |
|
393 | + $listing_type_name = get_post_type_plural_label($post_type); |
|
394 | + if (geodir_is_page('listing') || geodir_is_page('search')) { |
|
395 | + $term = array(); |
|
396 | 396 | |
397 | - if (is_tax()) { |
|
398 | - $term_id = get_queried_object_id(); |
|
399 | - $taxonomy = get_query_var('taxonomy'); |
|
397 | + if (is_tax()) { |
|
398 | + $term_id = get_queried_object_id(); |
|
399 | + $taxonomy = get_query_var('taxonomy'); |
|
400 | 400 | |
401 | - if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) { |
|
402 | - $term = get_term($term_id, $post_type . 'category'); |
|
403 | - } |
|
404 | - } |
|
401 | + if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) { |
|
402 | + $term = get_term($term_id, $post_type . 'category'); |
|
403 | + } |
|
404 | + } |
|
405 | 405 | |
406 | - if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) { |
|
407 | - $taxonomy_search = $_REQUEST['s' . $post_type . 'category']; |
|
406 | + if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) { |
|
407 | + $taxonomy_search = $_REQUEST['s' . $post_type . 'category']; |
|
408 | 408 | |
409 | - if (!is_array($taxonomy_search)) { |
|
410 | - $term = get_term((int)$taxonomy_search, $post_type . 'category'); |
|
411 | - } else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search |
|
412 | - $term = get_term((int)$taxonomy_search[0], $post_type . 'category'); |
|
413 | - } |
|
414 | - } |
|
409 | + if (!is_array($taxonomy_search)) { |
|
410 | + $term = get_term((int)$taxonomy_search, $post_type . 'category'); |
|
411 | + } else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search |
|
412 | + $term = get_term((int)$taxonomy_search[0], $post_type . 'category'); |
|
413 | + } |
|
414 | + } |
|
415 | 415 | |
416 | - if (!empty($term) && !is_wp_error($term)) { |
|
417 | - $listing_type_name = $term->name; |
|
418 | - } |
|
419 | - } |
|
416 | + if (!empty($term) && !is_wp_error($term)) { |
|
417 | + $listing_type_name = $term->name; |
|
418 | + } |
|
419 | + } |
|
420 | 420 | |
421 | - if ($max_page > 1 || $always_show) { |
|
422 | - // Extra pagination info |
|
423 | - $geodir_pagination_more_info = get_option('geodir_pagination_advance_info'); |
|
424 | - $start_no = ( $paged - 1 ) * $posts_per_page + 1; |
|
425 | - $end_no = min($paged * $posts_per_page, $numposts); |
|
421 | + if ($max_page > 1 || $always_show) { |
|
422 | + // Extra pagination info |
|
423 | + $geodir_pagination_more_info = get_option('geodir_pagination_advance_info'); |
|
424 | + $start_no = ( $paged - 1 ) * $posts_per_page + 1; |
|
425 | + $end_no = min($paged * $posts_per_page, $numposts); |
|
426 | 426 | |
427 | - if ($geodir_pagination_more_info != '') { |
|
428 | - if ($listing_type_name) { |
|
429 | - $listing_type_name = __($listing_type_name, 'geodirectory'); |
|
430 | - $pegination_desc = wp_sprintf(__('Showing %s %d-%d of %d', 'geodirectory'), $listing_type_name, $start_no, $end_no, $numposts); |
|
431 | - } else { |
|
432 | - $pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts); |
|
433 | - } |
|
434 | - $pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>'; |
|
435 | - /** |
|
436 | - * Adds an extra pagination info above/under pagination. |
|
437 | - * |
|
438 | - * @since 1.5.9 |
|
439 | - * |
|
440 | - * @param string $pagination_info Extra pagination info content. |
|
441 | - * @param string $listing_type_name Listing results type. |
|
442 | - * @param string $start_no First result number. |
|
443 | - * @param string $end_no Last result number. |
|
444 | - * @param string $numposts Total number of listings. |
|
445 | - * @param string $post_type The post type. |
|
446 | - */ |
|
447 | - $pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type); |
|
427 | + if ($geodir_pagination_more_info != '') { |
|
428 | + if ($listing_type_name) { |
|
429 | + $listing_type_name = __($listing_type_name, 'geodirectory'); |
|
430 | + $pegination_desc = wp_sprintf(__('Showing %s %d-%d of %d', 'geodirectory'), $listing_type_name, $start_no, $end_no, $numposts); |
|
431 | + } else { |
|
432 | + $pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts); |
|
433 | + } |
|
434 | + $pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>'; |
|
435 | + /** |
|
436 | + * Adds an extra pagination info above/under pagination. |
|
437 | + * |
|
438 | + * @since 1.5.9 |
|
439 | + * |
|
440 | + * @param string $pagination_info Extra pagination info content. |
|
441 | + * @param string $listing_type_name Listing results type. |
|
442 | + * @param string $start_no First result number. |
|
443 | + * @param string $end_no Last result number. |
|
444 | + * @param string $numposts Total number of listings. |
|
445 | + * @param string $post_type The post type. |
|
446 | + */ |
|
447 | + $pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type); |
|
448 | 448 | |
449 | - if ($geodir_pagination_more_info == 'before') { |
|
450 | - $before = $before . $pagination_info; |
|
451 | - } else if ($geodir_pagination_more_info == 'after') { |
|
452 | - $after = $pagination_info . $after; |
|
453 | - } |
|
454 | - } |
|
449 | + if ($geodir_pagination_more_info == 'before') { |
|
450 | + $before = $before . $pagination_info; |
|
451 | + } else if ($geodir_pagination_more_info == 'after') { |
|
452 | + $after = $pagination_info . $after; |
|
453 | + } |
|
454 | + } |
|
455 | 455 | |
456 | - echo "$before <div class='Navi gd-navi'>"; |
|
457 | - if ($paged >= ($pages_to_show - 1)) { |
|
458 | - echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link()) . '">«</a>'; |
|
459 | - } |
|
460 | - previous_posts_link($prelabel); |
|
461 | - for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { |
|
462 | - if ($i >= 1 && $i <= $max_page) { |
|
463 | - if ($i == $paged) { |
|
464 | - echo "<strong class='on'>$i</strong>"; |
|
465 | - } else { |
|
466 | - echo ' <a href="' . str_replace('&paged', '&paged', get_pagenum_link($i)) . '">' . $i . '</a> '; |
|
467 | - } |
|
468 | - } |
|
469 | - } |
|
470 | - next_posts_link($nxtlabel, $max_page); |
|
471 | - if (($paged + $half_pages_to_show) < ($max_page)) { |
|
472 | - echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link($max_page)) . '">»</a>'; |
|
473 | - } |
|
474 | - echo "</div> $after"; |
|
475 | - } |
|
456 | + echo "$before <div class='Navi gd-navi'>"; |
|
457 | + if ($paged >= ($pages_to_show - 1)) { |
|
458 | + echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link()) . '">«</a>'; |
|
459 | + } |
|
460 | + previous_posts_link($prelabel); |
|
461 | + for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { |
|
462 | + if ($i >= 1 && $i <= $max_page) { |
|
463 | + if ($i == $paged) { |
|
464 | + echo "<strong class='on'>$i</strong>"; |
|
465 | + } else { |
|
466 | + echo ' <a href="' . str_replace('&paged', '&paged', get_pagenum_link($i)) . '">' . $i . '</a> '; |
|
467 | + } |
|
468 | + } |
|
469 | + } |
|
470 | + next_posts_link($nxtlabel, $max_page); |
|
471 | + if (($paged + $half_pages_to_show) < ($max_page)) { |
|
472 | + echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link($max_page)) . '">»</a>'; |
|
473 | + } |
|
474 | + echo "</div> $after"; |
|
475 | + } |
|
476 | 476 | |
477 | - if (function_exists('geodir_location_geo_home_link')) { |
|
478 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
479 | - } |
|
480 | - } |
|
477 | + if (function_exists('geodir_location_geo_home_link')) { |
|
478 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
479 | + } |
|
480 | + } |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -488,20 +488,20 @@ discard block |
||
488 | 488 | */ |
489 | 489 | function geodir_listingsearch_scripts() |
490 | 490 | { |
491 | - if (get_option('gd_search_dist') != '') { |
|
492 | - $dist = get_option('gd_search_dist'); |
|
493 | - } else { |
|
494 | - $dist = 500; |
|
495 | - } |
|
496 | - $dist_dif = 1000; |
|
497 | - |
|
498 | - if ($dist <= 5000) $dist_dif = 500; |
|
499 | - if ($dist <= 1000) $dist_dif = 100; |
|
500 | - if ($dist <= 500) $dist_dif = 50; |
|
501 | - if ($dist <= 100) $dist_dif = 10; |
|
502 | - if ($dist <= 50) $dist_dif = 5; |
|
503 | - |
|
504 | - ?> |
|
491 | + if (get_option('gd_search_dist') != '') { |
|
492 | + $dist = get_option('gd_search_dist'); |
|
493 | + } else { |
|
494 | + $dist = 500; |
|
495 | + } |
|
496 | + $dist_dif = 1000; |
|
497 | + |
|
498 | + if ($dist <= 5000) $dist_dif = 500; |
|
499 | + if ($dist <= 1000) $dist_dif = 100; |
|
500 | + if ($dist <= 500) $dist_dif = 50; |
|
501 | + if ($dist <= 100) $dist_dif = 10; |
|
502 | + if ($dist <= 50) $dist_dif = 5; |
|
503 | + |
|
504 | + ?> |
|
505 | 505 | <script type="text/javascript"> |
506 | 506 | |
507 | 507 | jQuery(function ($) { |
@@ -559,20 +559,20 @@ discard block |
||
559 | 559 | * @package GeoDirectory |
560 | 560 | */ |
561 | 561 | function geodir_add_sharelocation_scripts() { |
562 | - $default_search_for_text = SEARCH_FOR_TEXT; |
|
563 | - if (get_option('geodir_search_field_default_text')) |
|
564 | - $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory'); |
|
562 | + $default_search_for_text = SEARCH_FOR_TEXT; |
|
563 | + if (get_option('geodir_search_field_default_text')) |
|
564 | + $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory'); |
|
565 | 565 | |
566 | - $default_near_text = NEAR_TEXT; |
|
567 | - if (get_option('geodir_near_field_default_text')) |
|
568 | - $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory'); |
|
566 | + $default_near_text = NEAR_TEXT; |
|
567 | + if (get_option('geodir_near_field_default_text')) |
|
568 | + $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory'); |
|
569 | 569 | |
570 | - $search_location = geodir_get_default_location(); |
|
570 | + $search_location = geodir_get_default_location(); |
|
571 | 571 | |
572 | - $default_search_for_text = addslashes(stripslashes($default_search_for_text)); |
|
573 | - $default_near_text = addslashes(stripslashes($default_near_text)); |
|
574 | - $city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : ''; |
|
575 | - ?> |
|
572 | + $default_search_for_text = addslashes(stripslashes($default_search_for_text)); |
|
573 | + $default_near_text = addslashes(stripslashes($default_near_text)); |
|
574 | + $city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : ''; |
|
575 | + ?> |
|
576 | 576 | <script type="text/javascript"> |
577 | 577 | var default_location = '<?php echo $city ;?>'; |
578 | 578 | var latlng; |
@@ -664,14 +664,14 @@ discard block |
||
664 | 664 | initialise2(); |
665 | 665 | } else { |
666 | 666 | <?php |
667 | - $near_add = get_option('geodir_search_near_addition'); |
|
668 | - /** |
|
669 | - * Adds any extra info to the near search box query when trying to geolocate it via google api. |
|
670 | - * |
|
671 | - * @since 1.0.0 |
|
672 | - */ |
|
673 | - $near_add2 = apply_filters('geodir_search_near_addition', ''); |
|
674 | - ?> |
|
667 | + $near_add = get_option('geodir_search_near_addition'); |
|
668 | + /** |
|
669 | + * Adds any extra info to the near search box query when trying to geolocate it via google api. |
|
670 | + * |
|
671 | + * @since 1.0.0 |
|
672 | + */ |
|
673 | + $near_add2 = apply_filters('geodir_search_near_addition', ''); |
|
674 | + ?> |
|
675 | 675 | if (window.gdMaps === 'google') { |
676 | 676 | Sgeocoder.geocode({'address': address<?php echo ($near_add ? '+", ' . $near_add . '"' : '') . $near_add2;?>}, |
677 | 677 | function (results, status) { |
@@ -785,32 +785,32 @@ discard block |
||
785 | 785 | */ |
786 | 786 | function geodir_show_badges_on_image($which, $post, $link) |
787 | 787 | { |
788 | - $return = ''; |
|
789 | - switch ($which) { |
|
790 | - case 'featured': |
|
791 | - /** |
|
792 | - * Filter the featured image badge html that appears in the listings pages over the thumbnail. |
|
793 | - * |
|
794 | - * @since 1.0.0 |
|
795 | - * @param object $post The post object. |
|
796 | - * @param string $link The link to the post. |
|
797 | - */ |
|
798 | - $return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img"> </span></a>',$post,$link); |
|
799 | - break; |
|
800 | - case 'new' : |
|
801 | - /** |
|
802 | - * Filter the new image badge html that appears in the listings pages over the thumbnail. |
|
803 | - * |
|
804 | - * @since 1.0.0 |
|
805 | - * @param object $post The post object. |
|
806 | - * @param string $link The link to the post. |
|
807 | - */ |
|
808 | - $return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing"> </span></a>',$post,$link); |
|
809 | - break; |
|
810 | - |
|
811 | - } |
|
788 | + $return = ''; |
|
789 | + switch ($which) { |
|
790 | + case 'featured': |
|
791 | + /** |
|
792 | + * Filter the featured image badge html that appears in the listings pages over the thumbnail. |
|
793 | + * |
|
794 | + * @since 1.0.0 |
|
795 | + * @param object $post The post object. |
|
796 | + * @param string $link The link to the post. |
|
797 | + */ |
|
798 | + $return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img"> </span></a>',$post,$link); |
|
799 | + break; |
|
800 | + case 'new' : |
|
801 | + /** |
|
802 | + * Filter the new image badge html that appears in the listings pages over the thumbnail. |
|
803 | + * |
|
804 | + * @since 1.0.0 |
|
805 | + * @param object $post The post object. |
|
806 | + * @param string $link The link to the post. |
|
807 | + */ |
|
808 | + $return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing"> </span></a>',$post,$link); |
|
809 | + break; |
|
810 | + |
|
811 | + } |
|
812 | 812 | |
813 | - return $return; |
|
813 | + return $return; |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
@@ -819,8 +819,8 @@ discard block |
||
819 | 819 | * @since 1.6.22 |
820 | 820 | */ |
821 | 821 | function geodir_fix_script_conflict() { |
822 | - if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) { |
|
823 | - wp_dequeue_script( 'flexslider' ); |
|
824 | - } |
|
822 | + if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) { |
|
823 | + wp_dequeue_script( 'flexslider' ); |
|
824 | + } |
|
825 | 825 | } |
826 | 826 | add_action( 'wp_enqueue_scripts', 'geodir_fix_script_conflict', 100 ); |
827 | 827 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function geodir_get_ajax_url() |
21 | 21 | { |
22 | - return admin_url('admin-ajax.php?action=geodir_ajax_action'); |
|
22 | + return admin_url('admin-ajax.php?action=geodir_ajax_action'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | ///////////////////// |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | add_filter('query_vars', 'geodir_add_geodir_page_var'); |
88 | 88 | add_action('wp', 'geodir_add_page_id_in_query_var'); // problem fix in wordpress 3.8 |
89 | 89 | if (get_option('permalink_structure') != '') |
90 | - add_filter('parse_request', 'geodir_set_location_var_in_session_in_core'); |
|
90 | + add_filter('parse_request', 'geodir_set_location_var_in_session_in_core'); |
|
91 | 91 | |
92 | 92 | add_filter('parse_query', 'geodir_modified_query'); |
93 | 93 | |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | /* POST AND LOOP ACTIONS */ |
155 | 155 | //////////////////////// |
156 | 156 | if (!is_admin()) { |
157 | - add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtual page from everywhere |
|
158 | - add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100); |
|
159 | - /** Exclude Virtual Pages From Pages List **/ |
|
160 | - add_action('pre_get_posts', 'set_listing_request', 0); |
|
161 | - add_action('pre_get_posts', 'geodir_listing_loop_filter', 1); |
|
162 | - add_filter('excerpt_more', 'geodir_excerpt_more', 1000); |
|
163 | - add_filter('excerpt_length', 'geodir_excerpt_length', 1000); |
|
164 | - add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter |
|
157 | + add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtual page from everywhere |
|
158 | + add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100); |
|
159 | + /** Exclude Virtual Pages From Pages List **/ |
|
160 | + add_action('pre_get_posts', 'set_listing_request', 0); |
|
161 | + add_action('pre_get_posts', 'geodir_listing_loop_filter', 1); |
|
162 | + add_filter('excerpt_more', 'geodir_excerpt_more', 1000); |
|
163 | + add_filter('excerpt_length', 'geodir_excerpt_length', 1000); |
|
164 | + add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | */ |
224 | 224 | function geodir_unset_prev_theme_nav_location($newname) |
225 | 225 | { |
226 | - $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname); |
|
227 | - if ($geodir_theme_location) { |
|
228 | - update_option('geodir_theme_location_nav', $geodir_theme_location); |
|
229 | - } else { |
|
230 | - update_option('geodir_theme_location_nav', ''); |
|
231 | - } |
|
226 | + $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname); |
|
227 | + if ($geodir_theme_location) { |
|
228 | + update_option('geodir_theme_location_nav', $geodir_theme_location); |
|
229 | + } else { |
|
230 | + update_option('geodir_theme_location_nav', ''); |
|
231 | + } |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /// add action for theme switch to blank previous theme navigation location setting |
@@ -249,42 +249,42 @@ discard block |
||
249 | 249 | */ |
250 | 250 | function geodir_add_post_filters() |
251 | 251 | { |
252 | - /** |
|
253 | - * Contains all function for filtering listing. |
|
254 | - * |
|
255 | - * @since 1.0.0 |
|
256 | - * @package GeoDirectory |
|
257 | - */ |
|
258 | - include_once('geodirectory-functions/listing_filters.php'); |
|
252 | + /** |
|
253 | + * Contains all function for filtering listing. |
|
254 | + * |
|
255 | + * @since 1.0.0 |
|
256 | + * @package GeoDirectory |
|
257 | + */ |
|
258 | + include_once('geodirectory-functions/listing_filters.php'); |
|
259 | 259 | |
260 | - // Theme My Login compatibility fix |
|
261 | - if ( isset( $_REQUEST['geodir_search'] ) && class_exists( 'Theme_My_Login' ) ) { |
|
262 | - remove_action( 'pre_get_posts', array( Theme_My_Login::get_object(), 'pre_get_posts' ) ); |
|
263 | - } |
|
260 | + // Theme My Login compatibility fix |
|
261 | + if ( isset( $_REQUEST['geodir_search'] ) && class_exists( 'Theme_My_Login' ) ) { |
|
262 | + remove_action( 'pre_get_posts', array( Theme_My_Login::get_object(), 'pre_get_posts' ) ); |
|
263 | + } |
|
264 | 264 | |
265 | - if ( isset( $_REQUEST['geodir_search'] ) ) { |
|
266 | - add_filter( 'geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3 ); |
|
267 | - add_filter( 'geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3 ); |
|
268 | - } |
|
265 | + if ( isset( $_REQUEST['geodir_search'] ) ) { |
|
266 | + add_filter( 'geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3 ); |
|
267 | + add_filter( 'geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3 ); |
|
268 | + } |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
272 | 272 | if (!function_exists('geodir_init_defaults')) { |
273 | - /** |
|
274 | - * Calls the function to register the GeoDirectory default CPT and taxonomies. |
|
275 | - * |
|
276 | - * @since 1.0.0 |
|
277 | - * @package GeoDirectory |
|
278 | - */ |
|
279 | - function geodir_init_defaults() |
|
280 | - { |
|
281 | - if (function_exists('geodir_register_defaults')) { |
|
273 | + /** |
|
274 | + * Calls the function to register the GeoDirectory default CPT and taxonomies. |
|
275 | + * |
|
276 | + * @since 1.0.0 |
|
277 | + * @package GeoDirectory |
|
278 | + */ |
|
279 | + function geodir_init_defaults() |
|
280 | + { |
|
281 | + if (function_exists('geodir_register_defaults')) { |
|
282 | 282 | |
283 | - geodir_register_defaults(); |
|
283 | + geodir_register_defaults(); |
|
284 | 284 | |
285 | - } |
|
285 | + } |
|
286 | 286 | |
287 | - } |
|
287 | + } |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -306,26 +306,26 @@ discard block |
||
306 | 306 | // CALLED ON 'sidebars_widgets' FILTER |
307 | 307 | |
308 | 308 | if (!function_exists('geodir_restrict_widget')) { |
309 | - /** |
|
310 | - * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page. |
|
311 | - * |
|
312 | - * @global bool $is_listing Sets the global value to true if on a GD category page. False if not. |
|
313 | - * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not. |
|
314 | - * @since 1.0.0 |
|
315 | - * @package GeoDirectory |
|
316 | - */ |
|
317 | - function geodir_restrict_widget() |
|
318 | - { |
|
319 | - global $is_listing, $is_single_place; |
|
309 | + /** |
|
310 | + * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page. |
|
311 | + * |
|
312 | + * @global bool $is_listing Sets the global value to true if on a GD category page. False if not. |
|
313 | + * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not. |
|
314 | + * @since 1.0.0 |
|
315 | + * @package GeoDirectory |
|
316 | + */ |
|
317 | + function geodir_restrict_widget() |
|
318 | + { |
|
319 | + global $is_listing, $is_single_place; |
|
320 | 320 | |
321 | - // set is listing |
|
322 | - (geodir_is_page('listing')) ? $is_listing = true : $is_listing = false; |
|
321 | + // set is listing |
|
322 | + (geodir_is_page('listing')) ? $is_listing = true : $is_listing = false; |
|
323 | 323 | |
324 | - // set is single place |
|
325 | - (geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false; |
|
324 | + // set is single place |
|
325 | + (geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false; |
|
326 | 326 | |
327 | 327 | |
328 | - } |
|
328 | + } |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -346,31 +346,31 @@ discard block |
||
346 | 346 | */ |
347 | 347 | function geodir_detail_page_sidebar_content_sorting() |
348 | 348 | { |
349 | - $arr_detail_page_sidebar_content = |
|
350 | - /** |
|
351 | - * An array of functions to be called to be displayed on the details (post) page sidebar. |
|
352 | - * |
|
353 | - * This filter can be used to remove sections of the details page sidebar, |
|
354 | - * add new sections or rearrange the order of the sections. |
|
355 | - * |
|
356 | - * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called. |
|
357 | - * @since 1.0.0 |
|
358 | - */ |
|
359 | - apply_filters('geodir_detail_page_sidebar_content', |
|
360 | - array('geodir_social_sharing_buttons', |
|
361 | - 'geodir_detail_page_google_analytics', |
|
362 | - 'geodir_edit_post_link', |
|
363 | - 'geodir_detail_page_review_rating', |
|
364 | - 'geodir_detail_page_more_info' |
|
365 | - ) // end of array |
|
366 | - ); // end of apply filter |
|
367 | - if (!empty($arr_detail_page_sidebar_content)) { |
|
368 | - foreach ($arr_detail_page_sidebar_content as $content_function) { |
|
369 | - if (function_exists($content_function)) { |
|
370 | - add_action('geodir_detail_page_sidebar', $content_function); |
|
371 | - } |
|
372 | - } |
|
373 | - } |
|
349 | + $arr_detail_page_sidebar_content = |
|
350 | + /** |
|
351 | + * An array of functions to be called to be displayed on the details (post) page sidebar. |
|
352 | + * |
|
353 | + * This filter can be used to remove sections of the details page sidebar, |
|
354 | + * add new sections or rearrange the order of the sections. |
|
355 | + * |
|
356 | + * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called. |
|
357 | + * @since 1.0.0 |
|
358 | + */ |
|
359 | + apply_filters('geodir_detail_page_sidebar_content', |
|
360 | + array('geodir_social_sharing_buttons', |
|
361 | + 'geodir_detail_page_google_analytics', |
|
362 | + 'geodir_edit_post_link', |
|
363 | + 'geodir_detail_page_review_rating', |
|
364 | + 'geodir_detail_page_more_info' |
|
365 | + ) // end of array |
|
366 | + ); // end of apply filter |
|
367 | + if (!empty($arr_detail_page_sidebar_content)) { |
|
368 | + foreach ($arr_detail_page_sidebar_content as $content_function) { |
|
369 | + if (function_exists($content_function)) { |
|
370 | + add_action('geodir_detail_page_sidebar', $content_function); |
|
371 | + } |
|
372 | + } |
|
373 | + } |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | add_action('geodir_after_edit_post_link', 'geodir_add_to_favourite_link', 1); |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | */ |
386 | 386 | function geodir_add_to_favourite_link() |
387 | 387 | { |
388 | - global $post, $preview; |
|
389 | - if (!$preview && geodir_is_page('detail')) { |
|
390 | - ?> |
|
388 | + global $post, $preview; |
|
389 | + if (!$preview && geodir_is_page('detail')) { |
|
390 | + ?> |
|
391 | 391 | <p class="edit_link"> |
392 | 392 | <?php geodir_favourite_html($post->post_author, $post->ID); ?> |
393 | 393 | </p> |
394 | 394 | <?php |
395 | - } |
|
395 | + } |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
@@ -406,41 +406,41 @@ discard block |
||
406 | 406 | */ |
407 | 407 | function geodir_social_sharing_buttons() |
408 | 408 | { |
409 | - global $preview; |
|
410 | - ob_start(); // Start buffering; |
|
411 | - /** |
|
412 | - * This action is called before the social buttons twitter,facebook and google plus are output in a containing div. |
|
413 | - * |
|
414 | - * @since 1.0.0 |
|
415 | - */ |
|
416 | - do_action('geodir_before_social_sharing_buttons'); |
|
417 | - if (!$preview) { |
|
418 | - ?> |
|
409 | + global $preview; |
|
410 | + ob_start(); // Start buffering; |
|
411 | + /** |
|
412 | + * This action is called before the social buttons twitter,facebook and google plus are output in a containing div. |
|
413 | + * |
|
414 | + * @since 1.0.0 |
|
415 | + */ |
|
416 | + do_action('geodir_before_social_sharing_buttons'); |
|
417 | + if (!$preview) { |
|
418 | + ?> |
|
419 | 419 | <div class="likethis"> |
420 | 420 | <?php geodir_twitter_tweet_button(); ?> |
421 | 421 | <?php geodir_fb_like_button(); ?> |
422 | 422 | <?php geodir_google_plus_button(); ?> |
423 | 423 | </div> |
424 | 424 | <?php |
425 | - }// end of if, if its a preview or not |
|
426 | - |
|
427 | - /** |
|
428 | - * This action is called after the social buttons twitter,facebook and google plus are output in a containing div. |
|
429 | - * |
|
430 | - * @since 1.0.0 |
|
431 | - */ |
|
432 | - do_action('geodir_after_social_sharing_buttons'); |
|
433 | - $content_html = ob_get_clean(); |
|
434 | - if (trim($content_html) != '') |
|
435 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
|
436 | - if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) { |
|
437 | - /** |
|
438 | - * Filter the geodir_social_sharing_buttons() function content. |
|
439 | - * |
|
440 | - * @param string $content_html The output html of the geodir_social_sharing_buttons() function. |
|
441 | - */ |
|
442 | - echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html); |
|
443 | - } |
|
425 | + }// end of if, if its a preview or not |
|
426 | + |
|
427 | + /** |
|
428 | + * This action is called after the social buttons twitter,facebook and google plus are output in a containing div. |
|
429 | + * |
|
430 | + * @since 1.0.0 |
|
431 | + */ |
|
432 | + do_action('geodir_after_social_sharing_buttons'); |
|
433 | + $content_html = ob_get_clean(); |
|
434 | + if (trim($content_html) != '') |
|
435 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
|
436 | + if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) { |
|
437 | + /** |
|
438 | + * Filter the geodir_social_sharing_buttons() function content. |
|
439 | + * |
|
440 | + * @param string $content_html The output html of the geodir_social_sharing_buttons() function. |
|
441 | + */ |
|
442 | + echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html); |
|
443 | + } |
|
444 | 444 | |
445 | 445 | |
446 | 446 | } |
@@ -458,46 +458,46 @@ discard block |
||
458 | 458 | */ |
459 | 459 | function geodir_edit_post_link() |
460 | 460 | { |
461 | - global $post, $preview; |
|
462 | - ob_start(); // Start buffering; |
|
463 | - /** |
|
464 | - * This is called before the edit post link html in the function geodir_edit_post_link() |
|
465 | - * |
|
466 | - * @since 1.0.0 |
|
467 | - */ |
|
468 | - do_action('geodir_before_edit_post_link'); |
|
469 | - if (!$preview) { |
|
470 | - $is_current_user_owner = geodir_listing_belong_to_current_user(); |
|
461 | + global $post, $preview; |
|
462 | + ob_start(); // Start buffering; |
|
463 | + /** |
|
464 | + * This is called before the edit post link html in the function geodir_edit_post_link() |
|
465 | + * |
|
466 | + * @since 1.0.0 |
|
467 | + */ |
|
468 | + do_action('geodir_before_edit_post_link'); |
|
469 | + if (!$preview) { |
|
470 | + $is_current_user_owner = geodir_listing_belong_to_current_user(); |
|
471 | 471 | |
472 | - if ($is_current_user_owner) { |
|
473 | - $post_id = $post->ID; |
|
472 | + if ($is_current_user_owner) { |
|
473 | + $post_id = $post->ID; |
|
474 | 474 | |
475 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
476 | - $post_id = (int)$_REQUEST['pid']; |
|
477 | - } |
|
475 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
476 | + $post_id = (int)$_REQUEST['pid']; |
|
477 | + } |
|
478 | 478 | |
479 | - $postlink = get_permalink(geodir_add_listing_page_id()); |
|
480 | - $editlink = geodir_getlink($postlink, array('pid' => $post_id), false); |
|
481 | - echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>'; |
|
482 | - } |
|
483 | - }// end of if, if its a preview or not |
|
484 | - /** |
|
485 | - * This is called after the edit post link html in the function geodir_edit_post_link() |
|
486 | - * |
|
487 | - * @since 1.0.0 |
|
488 | - */ |
|
489 | - do_action('geodir_after_edit_post_link'); |
|
490 | - $content_html = ob_get_clean(); |
|
491 | - if (trim($content_html) != '') |
|
492 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
|
493 | - if ((int)get_option('geodir_disable_user_links_section') != 1) { |
|
494 | - /** |
|
495 | - * Filter the geodir_edit_post_link() function content. |
|
496 | - * |
|
497 | - * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
498 | - */ |
|
499 | - echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html); |
|
500 | - } |
|
479 | + $postlink = get_permalink(geodir_add_listing_page_id()); |
|
480 | + $editlink = geodir_getlink($postlink, array('pid' => $post_id), false); |
|
481 | + echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>'; |
|
482 | + } |
|
483 | + }// end of if, if its a preview or not |
|
484 | + /** |
|
485 | + * This is called after the edit post link html in the function geodir_edit_post_link() |
|
486 | + * |
|
487 | + * @since 1.0.0 |
|
488 | + */ |
|
489 | + do_action('geodir_after_edit_post_link'); |
|
490 | + $content_html = ob_get_clean(); |
|
491 | + if (trim($content_html) != '') |
|
492 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
|
493 | + if ((int)get_option('geodir_disable_user_links_section') != 1) { |
|
494 | + /** |
|
495 | + * Filter the geodir_edit_post_link() function content. |
|
496 | + * |
|
497 | + * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
498 | + */ |
|
499 | + echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html); |
|
500 | + } |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -511,45 +511,45 @@ discard block |
||
511 | 511 | */ |
512 | 512 | function geodir_detail_page_google_analytics() |
513 | 513 | { |
514 | - if ( ! get_option( 'geodir_ga_stats' ) ) { |
|
514 | + if ( ! get_option( 'geodir_ga_stats' ) ) { |
|
515 | 515 | return; |
516 | 516 | } |
517 | 517 | global $post,$preview; |
518 | - if($preview){return '';} |
|
519 | - $package_info = array(); |
|
520 | - $package_info = geodir_post_package_info($package_info, $post); |
|
518 | + if($preview){return '';} |
|
519 | + $package_info = array(); |
|
520 | + $package_info = geodir_post_package_info($package_info, $post); |
|
521 | 521 | |
522 | - $id = trim(get_option('geodir_ga_account_id')); |
|
522 | + $id = trim(get_option('geodir_ga_account_id')); |
|
523 | 523 | |
524 | - if (!$id) { |
|
525 | - return; //if no Google Analytics ID then bail. |
|
526 | - } |
|
524 | + if (!$id) { |
|
525 | + return; //if no Google Analytics ID then bail. |
|
526 | + } |
|
527 | 527 | |
528 | - ob_start(); // Start buffering; |
|
529 | - /** |
|
530 | - * This is called before the edit post link html in the function geodir_detail_page_google_analytics() |
|
531 | - * |
|
532 | - * @since 1.0.0 |
|
533 | - */ |
|
534 | - do_action('geodir_before_google_analytics'); |
|
528 | + ob_start(); // Start buffering; |
|
529 | + /** |
|
530 | + * This is called before the edit post link html in the function geodir_detail_page_google_analytics() |
|
531 | + * |
|
532 | + * @since 1.0.0 |
|
533 | + */ |
|
534 | + do_action('geodir_before_google_analytics'); |
|
535 | 535 | |
536 | - $refresh_time = get_option('geodir_ga_refresh_time', 5); |
|
537 | - /** |
|
538 | - * Filter the time interval to check & refresh new users results. |
|
539 | - * |
|
540 | - * @since 1.5.9 |
|
541 | - * |
|
542 | - * @param int $refresh_time Time interval to check & refresh new users results. |
|
543 | - */ |
|
544 | - $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time); |
|
545 | - $refresh_time = absint($refresh_time * 1000); |
|
536 | + $refresh_time = get_option('geodir_ga_refresh_time', 5); |
|
537 | + /** |
|
538 | + * Filter the time interval to check & refresh new users results. |
|
539 | + * |
|
540 | + * @since 1.5.9 |
|
541 | + * |
|
542 | + * @param int $refresh_time Time interval to check & refresh new users results. |
|
543 | + */ |
|
544 | + $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time); |
|
545 | + $refresh_time = absint($refresh_time * 1000); |
|
546 | 546 | |
547 | - $hide_refresh = get_option('geodir_ga_auto_refresh'); |
|
547 | + $hide_refresh = get_option('geodir_ga_auto_refresh'); |
|
548 | 548 | |
549 | - $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0; |
|
550 | - if (is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) { |
|
551 | - $page_url = urlencode($_SERVER['REQUEST_URI']); |
|
552 | - ?> |
|
549 | + $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0; |
|
550 | + if (is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) { |
|
551 | + $page_url = urlencode($_SERVER['REQUEST_URI']); |
|
552 | + ?> |
|
553 | 553 | <script type="text/javascript"> |
554 | 554 | var gd_gaTimeOut; |
555 | 555 | var gd_gaTime = parseInt('<?php echo $refresh_time;?>'); |
@@ -801,15 +801,15 @@ discard block |
||
801 | 801 | var labels = results[1].rows.map(function(row) { return +row[0]; }); |
802 | 802 | |
803 | 803 | <?php |
804 | - // Here we list the shorthand days of the week so it can be used in translation. |
|
805 | - __("Mon",'geodirectory'); |
|
806 | - __("Tue",'geodirectory'); |
|
807 | - __("Wed",'geodirectory'); |
|
808 | - __("Thu",'geodirectory'); |
|
809 | - __("Fri",'geodirectory'); |
|
810 | - __("Sat",'geodirectory'); |
|
811 | - __("Sun",'geodirectory'); |
|
812 | - ?> |
|
804 | + // Here we list the shorthand days of the week so it can be used in translation. |
|
805 | + __("Mon",'geodirectory'); |
|
806 | + __("Tue",'geodirectory'); |
|
807 | + __("Wed",'geodirectory'); |
|
808 | + __("Thu",'geodirectory'); |
|
809 | + __("Fri",'geodirectory'); |
|
810 | + __("Sat",'geodirectory'); |
|
811 | + __("Sun",'geodirectory'); |
|
812 | + ?> |
|
813 | 813 | |
814 | 814 | labels = [ |
815 | 815 | "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>", |
@@ -1058,24 +1058,24 @@ discard block |
||
1058 | 1058 | </span> |
1059 | 1059 | |
1060 | 1060 | <?php |
1061 | - } |
|
1062 | - /** |
|
1063 | - * This is called after the edit post link html in the function geodir_detail_page_google_analytics() |
|
1064 | - * |
|
1065 | - * @since 1.0.0 |
|
1066 | - */ |
|
1067 | - do_action('geodir_after_google_analytics'); |
|
1068 | - $content_html = ob_get_clean(); |
|
1069 | - if (trim($content_html) != '') |
|
1070 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
|
1071 | - if ((int)get_option('geodir_disable_google_analytics_section') != 1) { |
|
1072 | - /** |
|
1073 | - * Filter the geodir_edit_post_link() function content. |
|
1074 | - * |
|
1075 | - * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
1076 | - */ |
|
1077 | - echo $content_html = apply_filters('geodir_google_analytic_html', $content_html); |
|
1078 | - } |
|
1061 | + } |
|
1062 | + /** |
|
1063 | + * This is called after the edit post link html in the function geodir_detail_page_google_analytics() |
|
1064 | + * |
|
1065 | + * @since 1.0.0 |
|
1066 | + */ |
|
1067 | + do_action('geodir_after_google_analytics'); |
|
1068 | + $content_html = ob_get_clean(); |
|
1069 | + if (trim($content_html) != '') |
|
1070 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
|
1071 | + if ((int)get_option('geodir_disable_google_analytics_section') != 1) { |
|
1072 | + /** |
|
1073 | + * Filter the geodir_edit_post_link() function content. |
|
1074 | + * |
|
1075 | + * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
1076 | + */ |
|
1077 | + echo $content_html = apply_filters('geodir_google_analytic_html', $content_html); |
|
1078 | + } |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | /** |
@@ -1092,94 +1092,94 @@ discard block |
||
1092 | 1092 | */ |
1093 | 1093 | function geodir_detail_page_review_rating() |
1094 | 1094 | { |
1095 | - global $post, $preview, $post_images; |
|
1095 | + global $post, $preview, $post_images; |
|
1096 | 1096 | |
1097 | - if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) { |
|
1098 | - return; |
|
1099 | - } |
|
1100 | - ob_start(); // Start buffering; |
|
1101 | - /** |
|
1102 | - * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1103 | - * |
|
1104 | - * This is called outside the check for an actual rating and the check for preview page. |
|
1105 | - * |
|
1106 | - * @since 1.0.0 |
|
1107 | - */ |
|
1108 | - do_action('geodir_before_detail_page_review_rating'); |
|
1109 | - |
|
1110 | - $comment_count = geodir_get_review_count_total($post->ID); |
|
1111 | - $post_avgratings = geodir_get_post_rating($post->ID); |
|
1112 | - |
|
1113 | - if ($post_avgratings != 0 && !$preview) { |
|
1114 | - /** |
|
1115 | - * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1116 | - * |
|
1117 | - * This is called inside the check for an actual rating and the check for preview page. |
|
1118 | - * |
|
1119 | - * @since 1.0.0 |
|
1120 | - * @param float $post_avgratings Average rating for the current post. |
|
1121 | - * @param int $post->ID Current post ID. |
|
1122 | - */ |
|
1123 | - do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID); |
|
1124 | - |
|
1125 | - $html = '<p style=" float:left;">'; |
|
1126 | - $html .= geodir_get_rating_stars($post_avgratings, $post->ID); |
|
1127 | - $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">'; |
|
1128 | - $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings; |
|
1097 | + if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) { |
|
1098 | + return; |
|
1099 | + } |
|
1100 | + ob_start(); // Start buffering; |
|
1101 | + /** |
|
1102 | + * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1103 | + * |
|
1104 | + * This is called outside the check for an actual rating and the check for preview page. |
|
1105 | + * |
|
1106 | + * @since 1.0.0 |
|
1107 | + */ |
|
1108 | + do_action('geodir_before_detail_page_review_rating'); |
|
1109 | + |
|
1110 | + $comment_count = geodir_get_review_count_total($post->ID); |
|
1111 | + $post_avgratings = geodir_get_post_rating($post->ID); |
|
1112 | + |
|
1113 | + if ($post_avgratings != 0 && !$preview) { |
|
1114 | + /** |
|
1115 | + * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1116 | + * |
|
1117 | + * This is called inside the check for an actual rating and the check for preview page. |
|
1118 | + * |
|
1119 | + * @since 1.0.0 |
|
1120 | + * @param float $post_avgratings Average rating for the current post. |
|
1121 | + * @param int $post->ID Current post ID. |
|
1122 | + */ |
|
1123 | + do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID); |
|
1124 | + |
|
1125 | + $html = '<p style=" float:left;">'; |
|
1126 | + $html .= geodir_get_rating_stars($post_avgratings, $post->ID); |
|
1127 | + $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">'; |
|
1128 | + $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings; |
|
1129 | 1129 | |
1130 | 1130 | $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory'); |
1131 | 1131 | |
1132 | 1132 | $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />'; |
1133 | 1133 | |
1134 | - $html .= '<span class="item">'; |
|
1135 | - $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>'; |
|
1134 | + $html .= '<span class="item">'; |
|
1135 | + $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>'; |
|
1136 | 1136 | |
1137 | - if ($post_images) { |
|
1138 | - foreach ($post_images as $img) { |
|
1139 | - $post_img = $img->src; |
|
1140 | - break; |
|
1141 | - } |
|
1142 | - } |
|
1143 | - |
|
1144 | - if (isset($post_img) && $post_img) { |
|
1145 | - $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />'; |
|
1146 | - } |
|
1147 | - |
|
1148 | - $html .= '</span>'; |
|
1149 | - |
|
1150 | - echo $html .= '</div>'; |
|
1151 | - /** |
|
1152 | - * This is called after the rating html in the function geodir_detail_page_review_rating(). |
|
1153 | - * |
|
1154 | - * This is called inside the check for an actual rating and the check for preview page. |
|
1155 | - * |
|
1156 | - * @since 1.0.0 |
|
1157 | - * @param float $post_avgratings Average rating for the current post. |
|
1158 | - * @param int $post->ID Current post ID. |
|
1159 | - */ |
|
1160 | - do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID); |
|
1161 | - } |
|
1162 | - /** |
|
1163 | - * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1164 | - * |
|
1165 | - * This is called outside the check for an actual rating and the check for preview page. |
|
1166 | - * |
|
1167 | - * @since 1.0.0 |
|
1168 | - */ |
|
1169 | - do_action('geodir_after_detail_page_review_rating'); |
|
1170 | - $content_html = ob_get_clean(); |
|
1171 | - if (trim($content_html) != '') { |
|
1172 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>'; |
|
1173 | - } |
|
1174 | - if ((int)get_option('geodir_disable_rating_info_section') != 1) { |
|
1175 | - /** |
|
1176 | - * Filter the geodir_detail_page_review_rating() function content. |
|
1177 | - * |
|
1178 | - * @since 1.0.0 |
|
1179 | - * @param string $content_html The output html of the geodir_detail_page_review_rating() function. |
|
1180 | - */ |
|
1181 | - echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html); |
|
1182 | - } |
|
1137 | + if ($post_images) { |
|
1138 | + foreach ($post_images as $img) { |
|
1139 | + $post_img = $img->src; |
|
1140 | + break; |
|
1141 | + } |
|
1142 | + } |
|
1143 | + |
|
1144 | + if (isset($post_img) && $post_img) { |
|
1145 | + $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />'; |
|
1146 | + } |
|
1147 | + |
|
1148 | + $html .= '</span>'; |
|
1149 | + |
|
1150 | + echo $html .= '</div>'; |
|
1151 | + /** |
|
1152 | + * This is called after the rating html in the function geodir_detail_page_review_rating(). |
|
1153 | + * |
|
1154 | + * This is called inside the check for an actual rating and the check for preview page. |
|
1155 | + * |
|
1156 | + * @since 1.0.0 |
|
1157 | + * @param float $post_avgratings Average rating for the current post. |
|
1158 | + * @param int $post->ID Current post ID. |
|
1159 | + */ |
|
1160 | + do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID); |
|
1161 | + } |
|
1162 | + /** |
|
1163 | + * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1164 | + * |
|
1165 | + * This is called outside the check for an actual rating and the check for preview page. |
|
1166 | + * |
|
1167 | + * @since 1.0.0 |
|
1168 | + */ |
|
1169 | + do_action('geodir_after_detail_page_review_rating'); |
|
1170 | + $content_html = ob_get_clean(); |
|
1171 | + if (trim($content_html) != '') { |
|
1172 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>'; |
|
1173 | + } |
|
1174 | + if ((int)get_option('geodir_disable_rating_info_section') != 1) { |
|
1175 | + /** |
|
1176 | + * Filter the geodir_detail_page_review_rating() function content. |
|
1177 | + * |
|
1178 | + * @since 1.0.0 |
|
1179 | + * @param string $content_html The output html of the geodir_detail_page_review_rating() function. |
|
1180 | + */ |
|
1181 | + echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html); |
|
1182 | + } |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | /** |
@@ -1191,35 +1191,35 @@ discard block |
||
1191 | 1191 | */ |
1192 | 1192 | function geodir_detail_page_more_info() |
1193 | 1193 | { |
1194 | - ob_start(); // Start buffering; |
|
1195 | - /** |
|
1196 | - * This is called before the info section html. |
|
1197 | - * |
|
1198 | - * @since 1.0.0 |
|
1199 | - */ |
|
1200 | - do_action('geodir_before_detail_page_more_info'); |
|
1201 | - if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) { |
|
1202 | - echo $geodir_post_detail_fields; |
|
1203 | - } |
|
1204 | - /** |
|
1205 | - * This is called after the info section html. |
|
1206 | - * |
|
1207 | - * @since 1.0.0 |
|
1208 | - */ |
|
1209 | - do_action('geodir_after_detail_page_more_info'); |
|
1210 | - |
|
1211 | - $content_html = ob_get_clean(); |
|
1212 | - if (trim($content_html) != '') |
|
1213 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
|
1214 | - if ((int)get_option('geodir_disable_listing_info_section') != 1) { |
|
1215 | - /** |
|
1216 | - * Filter the output html for function geodir_detail_page_more_info(). |
|
1217 | - * |
|
1218 | - * @since 1.0.0 |
|
1219 | - * @param string $content_html The output html of the geodir_detail_page_more_info() function. |
|
1220 | - */ |
|
1221 | - echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html); |
|
1222 | - } |
|
1194 | + ob_start(); // Start buffering; |
|
1195 | + /** |
|
1196 | + * This is called before the info section html. |
|
1197 | + * |
|
1198 | + * @since 1.0.0 |
|
1199 | + */ |
|
1200 | + do_action('geodir_before_detail_page_more_info'); |
|
1201 | + if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) { |
|
1202 | + echo $geodir_post_detail_fields; |
|
1203 | + } |
|
1204 | + /** |
|
1205 | + * This is called after the info section html. |
|
1206 | + * |
|
1207 | + * @since 1.0.0 |
|
1208 | + */ |
|
1209 | + do_action('geodir_after_detail_page_more_info'); |
|
1210 | + |
|
1211 | + $content_html = ob_get_clean(); |
|
1212 | + if (trim($content_html) != '') |
|
1213 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
|
1214 | + if ((int)get_option('geodir_disable_listing_info_section') != 1) { |
|
1215 | + /** |
|
1216 | + * Filter the output html for function geodir_detail_page_more_info(). |
|
1217 | + * |
|
1218 | + * @since 1.0.0 |
|
1219 | + * @param string $content_html The output html of the geodir_detail_page_more_info() function. |
|
1220 | + */ |
|
1221 | + echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html); |
|
1222 | + } |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | |
@@ -1233,15 +1233,15 @@ discard block |
||
1233 | 1233 | */ |
1234 | 1234 | function geodir_localize_all_js_msg() |
1235 | 1235 | {// check_ajax_referer function is used to make sure no files are uploaded remotely but it will fail if used between https and non https so we do the check below of the urls |
1236 | - if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
1237 | - $ajax_url = admin_url('admin-ajax.php'); |
|
1238 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
1239 | - $ajax_url = admin_url('admin-ajax.php'); |
|
1240 | - } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
1241 | - $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php')); |
|
1242 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
1243 | - $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php')); |
|
1244 | - } |
|
1236 | + if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
1237 | + $ajax_url = admin_url('admin-ajax.php'); |
|
1238 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
1239 | + $ajax_url = admin_url('admin-ajax.php'); |
|
1240 | + } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
1241 | + $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php')); |
|
1242 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
1243 | + $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php')); |
|
1244 | + } |
|
1245 | 1245 | |
1246 | 1246 | /** |
1247 | 1247 | * Filter the allowed image type extensions for post images. |
@@ -1251,62 +1251,62 @@ discard block |
||
1251 | 1251 | */ |
1252 | 1252 | $allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png')); |
1253 | 1253 | |
1254 | - $default_marker_icon = get_option('geodir_default_marker_icon'); |
|
1255 | - $default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34)); |
|
1256 | - $default_marker_width = $default_marker_size['w']; |
|
1257 | - $default_marker_height = $default_marker_size['h']; |
|
1254 | + $default_marker_icon = get_option('geodir_default_marker_icon'); |
|
1255 | + $default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34)); |
|
1256 | + $default_marker_width = $default_marker_size['w']; |
|
1257 | + $default_marker_height = $default_marker_size['h']; |
|
1258 | 1258 | |
1259 | - $arr_alert_msg = array( |
|
1260 | - 'geodir_plugin_url' => geodir_plugin_url(), |
|
1261 | - 'geodir_admin_ajax_url' => $ajax_url, |
|
1262 | - 'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'), |
|
1263 | - 'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'), |
|
1264 | - 'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'), |
|
1265 | - 'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'), |
|
1266 | - //start not show alert msg |
|
1267 | - 'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'), |
|
1268 | - 'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'), |
|
1269 | - 'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'), |
|
1270 | - 'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'), |
|
1271 | - 'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'), |
|
1272 | - // end not show alert msg |
|
1273 | - 'my_place_listing_del' => __('Are you sure you wish to delete this listing?', 'geodirectory'), |
|
1274 | - 'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'), |
|
1275 | - //start not show alert msg |
|
1276 | - 'rating_error_msg' => __('Error : please retry', 'geodirectory'), |
|
1277 | - 'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'), |
|
1278 | - 'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'), |
|
1279 | - 'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'), |
|
1280 | - 'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'), |
|
1281 | - 'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'), |
|
1282 | - 'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'), |
|
1283 | - 'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'), |
|
1284 | - 'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'), |
|
1285 | - 'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'), |
|
1286 | - 'geodir_field_id_required' => __('This field is required.', 'geodirectory'), |
|
1287 | - 'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'), |
|
1288 | - 'geodir_default_marker_icon' => $default_marker_icon, |
|
1289 | - 'geodir_default_marker_w' => $default_marker_width, |
|
1290 | - 'geodir_default_marker_h' => $default_marker_height, |
|
1291 | - 'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG, |
|
1292 | - 'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG, |
|
1293 | - 'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'), |
|
1294 | - 'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'), |
|
1295 | - 'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'), |
|
1296 | - 'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'), |
|
1297 | - 'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'), |
|
1298 | - 'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'), |
|
1299 | - 'err_empty_review' => __('Please type a review.', 'geodirectory'), |
|
1300 | - 'err_empty_reply' => __('Please type a reply.', 'geodirectory'), |
|
1301 | - /* on/off dragging for phone devices */ |
|
1302 | - 'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false, |
|
1303 | - 'geodir_is_mobile' => wp_is_mobile() ? true : false, |
|
1304 | - 'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'), |
|
1305 | - 'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'), |
|
1306 | - 'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'), |
|
1307 | - 'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'), |
|
1308 | - 'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'), |
|
1309 | - 'geodir_action_remove' => __('Remove', 'geodirectory'), |
|
1259 | + $arr_alert_msg = array( |
|
1260 | + 'geodir_plugin_url' => geodir_plugin_url(), |
|
1261 | + 'geodir_admin_ajax_url' => $ajax_url, |
|
1262 | + 'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'), |
|
1263 | + 'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'), |
|
1264 | + 'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'), |
|
1265 | + 'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'), |
|
1266 | + //start not show alert msg |
|
1267 | + 'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'), |
|
1268 | + 'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'), |
|
1269 | + 'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'), |
|
1270 | + 'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'), |
|
1271 | + 'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'), |
|
1272 | + // end not show alert msg |
|
1273 | + 'my_place_listing_del' => __('Are you sure you wish to delete this listing?', 'geodirectory'), |
|
1274 | + 'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'), |
|
1275 | + //start not show alert msg |
|
1276 | + 'rating_error_msg' => __('Error : please retry', 'geodirectory'), |
|
1277 | + 'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'), |
|
1278 | + 'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'), |
|
1279 | + 'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'), |
|
1280 | + 'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'), |
|
1281 | + 'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'), |
|
1282 | + 'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'), |
|
1283 | + 'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'), |
|
1284 | + 'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'), |
|
1285 | + 'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'), |
|
1286 | + 'geodir_field_id_required' => __('This field is required.', 'geodirectory'), |
|
1287 | + 'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'), |
|
1288 | + 'geodir_default_marker_icon' => $default_marker_icon, |
|
1289 | + 'geodir_default_marker_w' => $default_marker_width, |
|
1290 | + 'geodir_default_marker_h' => $default_marker_height, |
|
1291 | + 'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG, |
|
1292 | + 'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG, |
|
1293 | + 'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'), |
|
1294 | + 'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'), |
|
1295 | + 'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'), |
|
1296 | + 'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'), |
|
1297 | + 'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'), |
|
1298 | + 'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'), |
|
1299 | + 'err_empty_review' => __('Please type a review.', 'geodirectory'), |
|
1300 | + 'err_empty_reply' => __('Please type a reply.', 'geodirectory'), |
|
1301 | + /* on/off dragging for phone devices */ |
|
1302 | + 'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false, |
|
1303 | + 'geodir_is_mobile' => wp_is_mobile() ? true : false, |
|
1304 | + 'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'), |
|
1305 | + 'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'), |
|
1306 | + 'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'), |
|
1307 | + 'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'), |
|
1308 | + 'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'), |
|
1309 | + 'geodir_action_remove' => __('Remove', 'geodirectory'), |
|
1310 | 1310 | 'geodir_txt_all_files' => __('Allowed files', 'geodirectory'), |
1311 | 1311 | 'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'), |
1312 | 1312 | 'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '', |
@@ -1314,43 +1314,43 @@ discard block |
||
1314 | 1314 | 'geodir_txt_form_searching' => __('Searching...', 'geodirectory'), |
1315 | 1315 | 'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '', |
1316 | 1316 | 'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '', |
1317 | - 'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false, |
|
1318 | - 'geodir_map_name' => geodir_map_name(), |
|
1319 | - 'osmStart' => __('Start', 'geodirectory'), |
|
1320 | - 'osmVia' => __('Via {viaNumber}', 'geodirectory'), |
|
1321 | - 'osmEnd' => __('Enter Your Location', 'geodirectory'), |
|
1322 | - 'ga_delete_check' => __('Do you wish to Deauthorize and break Analytics?', 'geodirectory'), |
|
1323 | - 'geoMyLocation' => __('My Location', 'geodirectory'), |
|
1324 | - 'geoErrUNKNOWN_ERROR' => addslashes(__('Unable to find your location', 'geodirectory')), |
|
1325 | - 'geoErrPERMISSION_DENINED' => addslashes(__('Permission denied in finding your location', 'geodirectory')), |
|
1326 | - 'geoErrPOSITION_UNAVAILABLE' => addslashes(__('Your location is currently unknown', 'geodirectory')), |
|
1327 | - 'geoErrBREAK' => addslashes(__('Attempt to find location took too long', 'geodirectory')), |
|
1328 | - 'geoErrDEFAULT' => addslashes(__('Location detection not supported in browser', 'geodirectory')), |
|
1317 | + 'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false, |
|
1318 | + 'geodir_map_name' => geodir_map_name(), |
|
1319 | + 'osmStart' => __('Start', 'geodirectory'), |
|
1320 | + 'osmVia' => __('Via {viaNumber}', 'geodirectory'), |
|
1321 | + 'osmEnd' => __('Enter Your Location', 'geodirectory'), |
|
1322 | + 'ga_delete_check' => __('Do you wish to Deauthorize and break Analytics?', 'geodirectory'), |
|
1323 | + 'geoMyLocation' => __('My Location', 'geodirectory'), |
|
1324 | + 'geoErrUNKNOWN_ERROR' => addslashes(__('Unable to find your location', 'geodirectory')), |
|
1325 | + 'geoErrPERMISSION_DENINED' => addslashes(__('Permission denied in finding your location', 'geodirectory')), |
|
1326 | + 'geoErrPOSITION_UNAVAILABLE' => addslashes(__('Your location is currently unknown', 'geodirectory')), |
|
1327 | + 'geoErrBREAK' => addslashes(__('Attempt to find location took too long', 'geodirectory')), |
|
1328 | + 'geoErrDEFAULT' => addslashes(__('Location detection not supported in browser', 'geodirectory')), |
|
1329 | 1329 | 'mapLanguage' => geodir_get_map_default_language(), |
1330 | 1330 | 'lightBox_txtImage' => addslashes(__('Image', 'geodirectory')), |
1331 | 1331 | 'lightBox_txtOf' => addslashes(__('of', 'geodirectory')), |
1332 | - ); |
|
1333 | - |
|
1334 | - /** |
|
1335 | - * Filters the translated JS strings from function geodir_localize_all_js_msg(). |
|
1336 | - * |
|
1337 | - * With this filter you can add, remove or change translated JS strings. |
|
1338 | - * You should add your own translations to this if you are building an addon rather than adding another script block. |
|
1339 | - * |
|
1340 | - * @since 1.0.0 |
|
1341 | - */ |
|
1342 | - $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg); |
|
1343 | - |
|
1344 | - foreach ($arr_alert_msg as $key => $value) { |
|
1345 | - if (!is_scalar($value)) |
|
1346 | - continue; |
|
1347 | - $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8'); |
|
1348 | - } |
|
1332 | + ); |
|
1333 | + |
|
1334 | + /** |
|
1335 | + * Filters the translated JS strings from function geodir_localize_all_js_msg(). |
|
1336 | + * |
|
1337 | + * With this filter you can add, remove or change translated JS strings. |
|
1338 | + * You should add your own translations to this if you are building an addon rather than adding another script block. |
|
1339 | + * |
|
1340 | + * @since 1.0.0 |
|
1341 | + */ |
|
1342 | + $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg); |
|
1349 | 1343 | |
1350 | - $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';'; |
|
1351 | - echo '<script>'; |
|
1352 | - echo $script; |
|
1353 | - echo '</script>'; |
|
1344 | + foreach ($arr_alert_msg as $key => $value) { |
|
1345 | + if (!is_scalar($value)) |
|
1346 | + continue; |
|
1347 | + $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8'); |
|
1348 | + } |
|
1349 | + |
|
1350 | + $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';'; |
|
1351 | + echo '<script>'; |
|
1352 | + echo $script; |
|
1353 | + echo '</script>'; |
|
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | add_action('admin_bar_menu', 'geodir_admin_bar_site_menu', 31); |
@@ -1366,11 +1366,11 @@ discard block |
||
1366 | 1366 | */ |
1367 | 1367 | function geodir_admin_bar_site_menu($wp_admin_bar) |
1368 | 1368 | { |
1369 | - if (get_option("geodir_installed")) { |
|
1370 | - if (current_user_can('manage_options')) { |
|
1371 | - $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory'))); |
|
1372 | - } |
|
1373 | - } |
|
1369 | + if (get_option("geodir_installed")) { |
|
1370 | + if (current_user_can('manage_options')) { |
|
1371 | + $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory'))); |
|
1372 | + } |
|
1373 | + } |
|
1374 | 1374 | } |
1375 | 1375 | |
1376 | 1376 | add_action('geodir_before_listing', 'geodir_display_sort_options'); /*function in custom_functions.php*/ |
@@ -1396,25 +1396,25 @@ discard block |
||
1396 | 1396 | */ |
1397 | 1397 | function geodir_store_sidebars() |
1398 | 1398 | { |
1399 | - global $geodir_sidebars; |
|
1400 | - global $sidebars_widgets; |
|
1401 | - |
|
1402 | - if (!is_array($sidebars_widgets)) |
|
1403 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1404 | - $geodir_old_sidebars = array(); |
|
1405 | - |
|
1406 | - if (is_array($geodir_sidebars)) { |
|
1407 | - foreach ($geodir_sidebars as $val) { |
|
1408 | - if (is_array($sidebars_widgets)) { |
|
1409 | - if (array_key_exists($val, $sidebars_widgets)) |
|
1410 | - $geodir_old_sidebars[$val] = $sidebars_widgets[$val]; |
|
1411 | - else |
|
1412 | - $geodir_old_sidebars[$val] = array(); |
|
1413 | - } |
|
1414 | - } |
|
1415 | - } |
|
1416 | - update_option('geodir_sidebars', $geodir_old_sidebars); |
|
1417 | - geodir_option_version_backup('geodir_sidebars'); |
|
1399 | + global $geodir_sidebars; |
|
1400 | + global $sidebars_widgets; |
|
1401 | + |
|
1402 | + if (!is_array($sidebars_widgets)) |
|
1403 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1404 | + $geodir_old_sidebars = array(); |
|
1405 | + |
|
1406 | + if (is_array($geodir_sidebars)) { |
|
1407 | + foreach ($geodir_sidebars as $val) { |
|
1408 | + if (is_array($sidebars_widgets)) { |
|
1409 | + if (array_key_exists($val, $sidebars_widgets)) |
|
1410 | + $geodir_old_sidebars[$val] = $sidebars_widgets[$val]; |
|
1411 | + else |
|
1412 | + $geodir_old_sidebars[$val] = array(); |
|
1413 | + } |
|
1414 | + } |
|
1415 | + } |
|
1416 | + update_option('geodir_sidebars', $geodir_old_sidebars); |
|
1417 | + geodir_option_version_backup('geodir_sidebars'); |
|
1418 | 1418 | |
1419 | 1419 | } |
1420 | 1420 | |
@@ -1428,28 +1428,28 @@ discard block |
||
1428 | 1428 | */ |
1429 | 1429 | function geodir_restore_sidebars() |
1430 | 1430 | { |
1431 | - global $sidebars_widgets; |
|
1432 | - |
|
1433 | - if (!is_array($sidebars_widgets)) |
|
1434 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1435 | - |
|
1436 | - if (is_array($sidebars_widgets)) { |
|
1437 | - $geodir_old_sidebars = get_option('geodir_sidebars'); |
|
1438 | - if (is_array($geodir_old_sidebars)) { |
|
1439 | - foreach ($geodir_old_sidebars as $key => $val) { |
|
1440 | - if(0 === strpos($key, 'geodir_'))// if gd widget |
|
1441 | - { |
|
1442 | - $sidebars_widgets[$key] = $geodir_old_sidebars[$key]; |
|
1443 | - } |
|
1431 | + global $sidebars_widgets; |
|
1444 | 1432 | |
1433 | + if (!is_array($sidebars_widgets)) |
|
1434 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1445 | 1435 | |
1446 | - } |
|
1447 | - } |
|
1436 | + if (is_array($sidebars_widgets)) { |
|
1437 | + $geodir_old_sidebars = get_option('geodir_sidebars'); |
|
1438 | + if (is_array($geodir_old_sidebars)) { |
|
1439 | + foreach ($geodir_old_sidebars as $key => $val) { |
|
1440 | + if(0 === strpos($key, 'geodir_'))// if gd widget |
|
1441 | + { |
|
1442 | + $sidebars_widgets[$key] = $geodir_old_sidebars[$key]; |
|
1443 | + } |
|
1448 | 1444 | |
1449 | - } |
|
1450 | 1445 | |
1451 | - update_option('sidebars_widgets', $sidebars_widgets); |
|
1452 | - update_option('geodir_sidebars', ''); |
|
1446 | + } |
|
1447 | + } |
|
1448 | + |
|
1449 | + } |
|
1450 | + |
|
1451 | + update_option('sidebars_widgets', $sidebars_widgets); |
|
1452 | + update_option('geodir_sidebars', ''); |
|
1453 | 1453 | } |
1454 | 1454 | |
1455 | 1455 | add_action('geodir_after_listing_post_gridview', 'geodir_after_listing_post_gridview'); |
@@ -1462,9 +1462,9 @@ discard block |
||
1462 | 1462 | */ |
1463 | 1463 | function geodir_after_listing_post_gridview() |
1464 | 1464 | { |
1465 | - global $gridview_columns; |
|
1465 | + global $gridview_columns; |
|
1466 | 1466 | |
1467 | - $gridview_columns = ''; |
|
1467 | + $gridview_columns = ''; |
|
1468 | 1468 | |
1469 | 1469 | } |
1470 | 1470 | |
@@ -1492,11 +1492,11 @@ discard block |
||
1492 | 1492 | */ |
1493 | 1493 | function so_handle_038($url, $original_url, $_context) |
1494 | 1494 | { |
1495 | - if (strstr($url, "maps.google.com/maps/api/js") !== false) { |
|
1496 | - $url = str_replace("&", "&", $url); // or $url = $original_url |
|
1497 | - } |
|
1495 | + if (strstr($url, "maps.google.com/maps/api/js") !== false) { |
|
1496 | + $url = str_replace("&", "&", $url); // or $url = $original_url |
|
1497 | + } |
|
1498 | 1498 | |
1499 | - return $url; |
|
1499 | + return $url; |
|
1500 | 1500 | } |
1501 | 1501 | |
1502 | 1502 | |
@@ -1512,34 +1512,34 @@ discard block |
||
1512 | 1512 | function geodir_after_main_form_fields() { |
1513 | 1513 | global $gd_session; |
1514 | 1514 | |
1515 | - if (get_option('geodir_accept_term_condition')) { |
|
1516 | - global $post; |
|
1517 | - $term_condition = ''; |
|
1518 | - if (isset($_REQUEST['backandedit'])) { |
|
1519 | - $post = (object)$gd_session->get('listing'); |
|
1520 | - $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : ''; |
|
1521 | - } |
|
1522 | - |
|
1523 | - ?> |
|
1515 | + if (get_option('geodir_accept_term_condition')) { |
|
1516 | + global $post; |
|
1517 | + $term_condition = ''; |
|
1518 | + if (isset($_REQUEST['backandedit'])) { |
|
1519 | + $post = (object)$gd_session->get('listing'); |
|
1520 | + $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : ''; |
|
1521 | + } |
|
1522 | + |
|
1523 | + ?> |
|
1524 | 1524 | <div id="geodir_accept_term_condition_row" class="required_field geodir_form_row clearfix"> |
1525 | 1525 | <label> </label> |
1526 | 1526 | |
1527 | 1527 | <div class="geodir_taxonomy_field" style="float:left; width:70%;"> |
1528 | 1528 | <span style="display:block"> |
1529 | 1529 | <input class="main_list_selecter" type="checkbox" <?php if ($term_condition == '1') { |
1530 | - echo 'checked="checked"'; |
|
1531 | - } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition" |
|
1530 | + echo 'checked="checked"'; |
|
1531 | + } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition" |
|
1532 | 1532 | class="geodir_textfield" value="1" |
1533 | 1533 | style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a> |
1534 | 1534 | </span> |
1535 | 1535 | </div> |
1536 | 1536 | <span class="geodir_message_error"><?php if (isset($required_msg)) { |
1537 | - _e($required_msg, 'geodirectory'); |
|
1538 | - } ?></span> |
|
1537 | + _e($required_msg, 'geodirectory'); |
|
1538 | + } ?></span> |
|
1539 | 1539 | </div> |
1540 | 1540 | <?php |
1541 | 1541 | |
1542 | - } |
|
1542 | + } |
|
1543 | 1543 | } |
1544 | 1544 | |
1545 | 1545 | |
@@ -1564,42 +1564,42 @@ discard block |
||
1564 | 1564 | */ |
1565 | 1565 | function geodir_detail_page_tab_is_display($is_display, $tab) |
1566 | 1566 | { |
1567 | - global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; |
|
1567 | + global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; |
|
1568 | 1568 | |
1569 | - if ($tab == 'post_profile') { |
|
1570 | - /** This action is documented in geodirectory_template_actions.php */ |
|
1571 | - $desc_limit = apply_filters('geodir_description_field_desc_limit', ''); |
|
1569 | + if ($tab == 'post_profile') { |
|
1570 | + /** This action is documented in geodirectory_template_actions.php */ |
|
1571 | + $desc_limit = apply_filters('geodir_description_field_desc_limit', ''); |
|
1572 | 1572 | |
1573 | - if (!($desc_limit === '' || (int)$desc_limit > 0)) { |
|
1574 | - $is_display = false; |
|
1575 | - } |
|
1576 | - } |
|
1573 | + if (!($desc_limit === '' || (int)$desc_limit > 0)) { |
|
1574 | + $is_display = false; |
|
1575 | + } |
|
1576 | + } |
|
1577 | 1577 | |
1578 | - if ($tab == 'post_info') |
|
1579 | - $is_display = (!empty($geodir_post_detail_fields)) ? true : false; |
|
1578 | + if ($tab == 'post_info') |
|
1579 | + $is_display = (!empty($geodir_post_detail_fields)) ? true : false; |
|
1580 | 1580 | |
1581 | - if ($tab == 'post_images') |
|
1582 | - $is_display = (!empty($post_images)) ? true : false; |
|
1581 | + if ($tab == 'post_images') |
|
1582 | + $is_display = (!empty($post_images)) ? true : false; |
|
1583 | 1583 | |
1584 | - if ($tab == 'post_video') |
|
1585 | - $is_display = (!empty($video)) ? true : false; |
|
1584 | + if ($tab == 'post_video') |
|
1585 | + $is_display = (!empty($video)) ? true : false; |
|
1586 | 1586 | |
1587 | - if ($tab == 'special_offers') |
|
1588 | - $is_display = (!empty($special_offers)) ? true : false; |
|
1587 | + if ($tab == 'special_offers') |
|
1588 | + $is_display = (!empty($special_offers)) ? true : false; |
|
1589 | 1589 | |
1590 | - if ($tab == 'reviews') |
|
1591 | - $is_display = (geodir_is_page('detail')) ? true : false; |
|
1590 | + if ($tab == 'reviews') |
|
1591 | + $is_display = (geodir_is_page('detail')) ? true : false; |
|
1592 | 1592 | |
1593 | - if ($tab == 'related_listing') { |
|
1594 | - $message = __('No listings found which match your selection.', 'geodirectory'); |
|
1593 | + if ($tab == 'related_listing') { |
|
1594 | + $message = __('No listings found which match your selection.', 'geodirectory'); |
|
1595 | 1595 | |
1596 | - /** This action is documented in geodirectory-functions/template_functions.php */ |
|
1597 | - $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false); |
|
1596 | + /** This action is documented in geodirectory-functions/template_functions.php */ |
|
1597 | + $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false); |
|
1598 | 1598 | |
1599 | - $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true; |
|
1600 | - } |
|
1599 | + $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true; |
|
1600 | + } |
|
1601 | 1601 | |
1602 | - return $is_display; |
|
1602 | + return $is_display; |
|
1603 | 1603 | } |
1604 | 1604 | |
1605 | 1605 | |
@@ -1615,69 +1615,69 @@ discard block |
||
1615 | 1615 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
1616 | 1616 | */ |
1617 | 1617 | function geodir_changes_in_custom_fields_table() { |
1618 | - global $wpdb, $plugin_prefix; |
|
1618 | + global $wpdb, $plugin_prefix; |
|
1619 | 1619 | |
1620 | 1620 | // Remove unused virtual page |
1621 | 1621 | $listings_page_id = (int)get_option('geodir_listing_page'); |
1622 | 1622 | if ($listings_page_id) { |
1623 | 1623 | $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page'))); |
1624 | - delete_option('geodir_listing_page'); |
|
1624 | + delete_option('geodir_listing_page'); |
|
1625 | 1625 | } |
1626 | 1626 | |
1627 | - if (!get_option('geodir_changes_in_custom_fields_table')) { |
|
1628 | - $wpdb->query( |
|
1629 | - $wpdb->prepare( |
|
1630 | - "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s", |
|
1631 | - array('1', '1', 'admin') |
|
1632 | - ) |
|
1633 | - ); |
|
1627 | + if (!get_option('geodir_changes_in_custom_fields_table')) { |
|
1628 | + $wpdb->query( |
|
1629 | + $wpdb->prepare( |
|
1630 | + "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s", |
|
1631 | + array('1', '1', 'admin') |
|
1632 | + ) |
|
1633 | + ); |
|
1634 | 1634 | |
1635 | 1635 | |
1636 | - /* --- terms meta value set --- */ |
|
1636 | + /* --- terms meta value set --- */ |
|
1637 | 1637 | |
1638 | - update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png'); |
|
1638 | + update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png'); |
|
1639 | 1639 | |
1640 | - $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%'))); |
|
1640 | + $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%'))); |
|
1641 | 1641 | |
1642 | - if (!empty($options_data)) { |
|
1642 | + if (!empty($options_data)) { |
|
1643 | 1643 | |
1644 | - foreach ($options_data as $optobj) { |
|
1644 | + foreach ($options_data as $optobj) { |
|
1645 | 1645 | |
1646 | - $option_val = str_replace('tax_meta_', '', $optobj->option_name); |
|
1646 | + $option_val = str_replace('tax_meta_', '', $optobj->option_name); |
|
1647 | 1647 | |
1648 | - $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val))); |
|
1648 | + $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val))); |
|
1649 | 1649 | |
1650 | - if (!empty($taxonomies_data)) { |
|
1650 | + if (!empty($taxonomies_data)) { |
|
1651 | 1651 | |
1652 | - foreach ($taxonomies_data as $taxobj) { |
|
1652 | + foreach ($taxonomies_data as $taxobj) { |
|
1653 | 1653 | |
1654 | - $taxObject = get_taxonomy($taxobj->taxonomy); |
|
1655 | - $post_type = $taxObject->object_type[0]; |
|
1654 | + $taxObject = get_taxonomy($taxobj->taxonomy); |
|
1655 | + $post_type = $taxObject->object_type[0]; |
|
1656 | 1656 | |
1657 | - $opt_value = 'tax_meta_' . $post_type . '_' . $option_val; |
|
1657 | + $opt_value = 'tax_meta_' . $post_type . '_' . $option_val; |
|
1658 | 1658 | |
1659 | - $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val))); |
|
1659 | + $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val))); |
|
1660 | 1660 | |
1661 | - if ($duplicate_data) { |
|
1661 | + if ($duplicate_data) { |
|
1662 | 1662 | |
1663 | - $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id))); |
|
1663 | + $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id))); |
|
1664 | 1664 | |
1665 | - } else { |
|
1665 | + } else { |
|
1666 | 1666 | |
1667 | - $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload))); |
|
1667 | + $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload))); |
|
1668 | 1668 | |
1669 | - } |
|
1669 | + } |
|
1670 | 1670 | |
1671 | - } |
|
1671 | + } |
|
1672 | 1672 | |
1673 | - } |
|
1673 | + } |
|
1674 | 1674 | |
1675 | - } |
|
1676 | - } |
|
1675 | + } |
|
1676 | + } |
|
1677 | 1677 | |
1678 | - update_option('geodir_changes_in_custom_fields_table', '1'); |
|
1678 | + update_option('geodir_changes_in_custom_fields_table', '1'); |
|
1679 | 1679 | |
1680 | - } |
|
1680 | + } |
|
1681 | 1681 | |
1682 | 1682 | } |
1683 | 1683 | |
@@ -1696,24 +1696,24 @@ discard block |
||
1696 | 1696 | function geodir_location_slug_check($slug) |
1697 | 1697 | { |
1698 | 1698 | |
1699 | - global $wpdb, $table_prefix; |
|
1699 | + global $wpdb, $table_prefix; |
|
1700 | 1700 | |
1701 | - $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug))); |
|
1701 | + $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug))); |
|
1702 | 1702 | |
1703 | - if ($slug_exists) { |
|
1703 | + if ($slug_exists) { |
|
1704 | 1704 | |
1705 | - $suffix = 1; |
|
1706 | - do { |
|
1707 | - $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
1708 | - $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name))); |
|
1709 | - $suffix++; |
|
1710 | - } while ($location_slug_check && $suffix < 100); |
|
1705 | + $suffix = 1; |
|
1706 | + do { |
|
1707 | + $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
1708 | + $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name))); |
|
1709 | + $suffix++; |
|
1710 | + } while ($location_slug_check && $suffix < 100); |
|
1711 | 1711 | |
1712 | - $slug = $alt_location_name; |
|
1712 | + $slug = $alt_location_name; |
|
1713 | 1713 | |
1714 | - } |
|
1714 | + } |
|
1715 | 1715 | |
1716 | - return $slug; |
|
1716 | + return $slug; |
|
1717 | 1717 | |
1718 | 1718 | } |
1719 | 1719 | |
@@ -1738,42 +1738,42 @@ discard block |
||
1738 | 1738 | function geodir_update_term_slug($term_id, $tt_id, $taxonomy) |
1739 | 1739 | { |
1740 | 1740 | |
1741 | - global $wpdb, $plugin_prefix, $table_prefix; |
|
1741 | + global $wpdb, $plugin_prefix, $table_prefix; |
|
1742 | 1742 | |
1743 | - $tern_data = get_term_by('id', $term_id, $taxonomy); |
|
1743 | + $tern_data = get_term_by('id', $term_id, $taxonomy); |
|
1744 | 1744 | |
1745 | - $slug = $tern_data->slug; |
|
1745 | + $slug = $tern_data->slug; |
|
1746 | 1746 | |
1747 | - /** |
|
1748 | - * Filter if a term slug exists. |
|
1749 | - * |
|
1750 | - * @since 1.0.0 |
|
1751 | - * @package GeoDirectory |
|
1752 | - * @param bool $bool Default: false. |
|
1753 | - * @param string $slug The term slug. |
|
1754 | - * @param int $term_id The term ID. |
|
1755 | - */ |
|
1756 | - $slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id); |
|
1747 | + /** |
|
1748 | + * Filter if a term slug exists. |
|
1749 | + * |
|
1750 | + * @since 1.0.0 |
|
1751 | + * @package GeoDirectory |
|
1752 | + * @param bool $bool Default: false. |
|
1753 | + * @param string $slug The term slug. |
|
1754 | + * @param int $term_id The term ID. |
|
1755 | + */ |
|
1756 | + $slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id); |
|
1757 | 1757 | |
1758 | - if ($slug_exists) { |
|
1758 | + if ($slug_exists) { |
|
1759 | 1759 | |
1760 | - $suffix = 1; |
|
1761 | - do { |
|
1762 | - $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
1760 | + $suffix = 1; |
|
1761 | + do { |
|
1762 | + $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
1763 | 1763 | |
1764 | - /** This action is documented in geodirectory_hooks_actions.php */ |
|
1765 | - $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id); |
|
1764 | + /** This action is documented in geodirectory_hooks_actions.php */ |
|
1765 | + $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id); |
|
1766 | 1766 | |
1767 | - $suffix++; |
|
1768 | - } while ($term_slug_check && $suffix < 100); |
|
1767 | + $suffix++; |
|
1768 | + } while ($term_slug_check && $suffix < 100); |
|
1769 | 1769 | |
1770 | - $slug = $new_slug; |
|
1770 | + $slug = $new_slug; |
|
1771 | 1771 | |
1772 | - //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) ); |
|
1772 | + //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) ); |
|
1773 | 1773 | |
1774 | - $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id))); |
|
1774 | + $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id))); |
|
1775 | 1775 | |
1776 | - } |
|
1776 | + } |
|
1777 | 1777 | |
1778 | 1778 | // Update tag in detail table. |
1779 | 1779 | $taxonomy_obj = get_taxonomy($taxonomy); |
@@ -1814,21 +1814,21 @@ discard block |
||
1814 | 1814 | function geodir_term_slug_is_exists($slug_exists, $slug, $term_id) |
1815 | 1815 | { |
1816 | 1816 | |
1817 | - global $wpdb, $table_prefix; |
|
1817 | + global $wpdb, $table_prefix; |
|
1818 | 1818 | |
1819 | - $default_location = geodir_get_default_location(); |
|
1819 | + $default_location = geodir_get_default_location(); |
|
1820 | 1820 | |
1821 | - $country_slug = $default_location->country_slug; |
|
1822 | - $region_slug = $default_location->region_slug; |
|
1823 | - $city_slug = $default_location->city_slug; |
|
1821 | + $country_slug = $default_location->country_slug; |
|
1822 | + $region_slug = $default_location->region_slug; |
|
1823 | + $city_slug = $default_location->city_slug; |
|
1824 | 1824 | |
1825 | - if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) |
|
1826 | - return $slug_exists = true; |
|
1825 | + if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) |
|
1826 | + return $slug_exists = true; |
|
1827 | 1827 | |
1828 | - if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) |
|
1829 | - return $slug_exists = true; |
|
1828 | + if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) |
|
1829 | + return $slug_exists = true; |
|
1830 | 1830 | |
1831 | - return $slug_exists; |
|
1831 | + return $slug_exists; |
|
1832 | 1832 | } |
1833 | 1833 | |
1834 | 1834 | |
@@ -1848,75 +1848,75 @@ discard block |
||
1848 | 1848 | */ |
1849 | 1849 | function geodir_custom_page_title($title = '', $sep = '') |
1850 | 1850 | { |
1851 | - global $wp; |
|
1852 | - if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) { |
|
1853 | - return $title; |
|
1854 | - } |
|
1851 | + global $wp; |
|
1852 | + if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) { |
|
1853 | + return $title; |
|
1854 | + } |
|
1855 | 1855 | |
1856 | - if ($sep == '') { |
|
1857 | - /** |
|
1858 | - * Filter the page title separator. |
|
1859 | - * |
|
1860 | - * @since 1.0.0 |
|
1861 | - * @package GeoDirectory |
|
1862 | - * @param string $sep The separator, default: `|`. |
|
1863 | - */ |
|
1864 | - $sep = apply_filters('geodir_page_title_separator', '|'); |
|
1865 | - } |
|
1856 | + if ($sep == '') { |
|
1857 | + /** |
|
1858 | + * Filter the page title separator. |
|
1859 | + * |
|
1860 | + * @since 1.0.0 |
|
1861 | + * @package GeoDirectory |
|
1862 | + * @param string $sep The separator, default: `|`. |
|
1863 | + */ |
|
1864 | + $sep = apply_filters('geodir_page_title_separator', '|'); |
|
1865 | + } |
|
1866 | 1866 | |
1867 | 1867 | |
1868 | - $gd_page = ''; |
|
1869 | - if(geodir_is_page('home')){ |
|
1870 | - $gd_page = 'home'; |
|
1871 | - $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title; |
|
1872 | - } |
|
1873 | - elseif(geodir_is_page('detail')){ |
|
1874 | - $gd_page = 'detail'; |
|
1875 | - $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title; |
|
1876 | - } |
|
1877 | - elseif(geodir_is_page('pt')){ |
|
1878 | - $gd_page = 'pt'; |
|
1879 | - $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title; |
|
1880 | - } |
|
1881 | - elseif(geodir_is_page('listing')){ |
|
1882 | - $gd_page = 'listing'; |
|
1883 | - $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title; |
|
1884 | - } |
|
1885 | - elseif(geodir_is_page('location')){ |
|
1886 | - $gd_page = 'location'; |
|
1887 | - $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title; |
|
1888 | - } |
|
1889 | - elseif(geodir_is_page('search')){ |
|
1890 | - $gd_page = 'search'; |
|
1891 | - $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title; |
|
1892 | - } |
|
1893 | - elseif(geodir_is_page('add-listing')){ |
|
1894 | - $gd_page = 'add-listing'; |
|
1895 | - $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title; |
|
1896 | - } |
|
1897 | - elseif(geodir_is_page('author')){ |
|
1898 | - $gd_page = 'author'; |
|
1899 | - $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title; |
|
1900 | - } |
|
1901 | - elseif(geodir_is_page('login')){ |
|
1902 | - $gd_page = 'login'; |
|
1903 | - $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title; |
|
1904 | - } |
|
1905 | - elseif(geodir_is_page('listing-success')){ |
|
1906 | - $gd_page = 'listing-success'; |
|
1907 | - $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title; |
|
1908 | - } |
|
1868 | + $gd_page = ''; |
|
1869 | + if(geodir_is_page('home')){ |
|
1870 | + $gd_page = 'home'; |
|
1871 | + $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title; |
|
1872 | + } |
|
1873 | + elseif(geodir_is_page('detail')){ |
|
1874 | + $gd_page = 'detail'; |
|
1875 | + $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title; |
|
1876 | + } |
|
1877 | + elseif(geodir_is_page('pt')){ |
|
1878 | + $gd_page = 'pt'; |
|
1879 | + $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title; |
|
1880 | + } |
|
1881 | + elseif(geodir_is_page('listing')){ |
|
1882 | + $gd_page = 'listing'; |
|
1883 | + $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title; |
|
1884 | + } |
|
1885 | + elseif(geodir_is_page('location')){ |
|
1886 | + $gd_page = 'location'; |
|
1887 | + $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title; |
|
1888 | + } |
|
1889 | + elseif(geodir_is_page('search')){ |
|
1890 | + $gd_page = 'search'; |
|
1891 | + $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title; |
|
1892 | + } |
|
1893 | + elseif(geodir_is_page('add-listing')){ |
|
1894 | + $gd_page = 'add-listing'; |
|
1895 | + $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title; |
|
1896 | + } |
|
1897 | + elseif(geodir_is_page('author')){ |
|
1898 | + $gd_page = 'author'; |
|
1899 | + $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title; |
|
1900 | + } |
|
1901 | + elseif(geodir_is_page('login')){ |
|
1902 | + $gd_page = 'login'; |
|
1903 | + $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title; |
|
1904 | + } |
|
1905 | + elseif(geodir_is_page('listing-success')){ |
|
1906 | + $gd_page = 'listing-success'; |
|
1907 | + $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title; |
|
1908 | + } |
|
1909 | 1909 | |
1910 | 1910 | |
1911 | - /** |
|
1912 | - * Filter page meta title to replace variables. |
|
1913 | - * |
|
1914 | - * @since 1.5.4 |
|
1915 | - * @param string $title The page title including variables. |
|
1916 | - * @param string $gd_page The GeoDirectory page type if any. |
|
1917 | - * @param string $sep The title separator symbol. |
|
1918 | - */ |
|
1919 | - return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep); |
|
1911 | + /** |
|
1912 | + * Filter page meta title to replace variables. |
|
1913 | + * |
|
1914 | + * @since 1.5.4 |
|
1915 | + * @param string $title The page title including variables. |
|
1916 | + * @param string $gd_page The GeoDirectory page type if any. |
|
1917 | + * @param string $sep The title separator symbol. |
|
1918 | + */ |
|
1919 | + return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep); |
|
1920 | 1920 | |
1921 | 1921 | } |
1922 | 1922 | |
@@ -1932,36 +1932,36 @@ discard block |
||
1932 | 1932 | function geodir_set_post_attachment() |
1933 | 1933 | { |
1934 | 1934 | |
1935 | - if (!get_option('geodir_set_post_attachments')) { |
|
1935 | + if (!get_option('geodir_set_post_attachments')) { |
|
1936 | 1936 | |
1937 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1938 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1937 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1938 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1939 | 1939 | |
1940 | - $all_postypes = geodir_get_posttypes(); |
|
1940 | + $all_postypes = geodir_get_posttypes(); |
|
1941 | 1941 | |
1942 | - foreach($all_postypes as $post_type){ |
|
1943 | - $args = array( |
|
1944 | - 'posts_per_page' => -1, |
|
1945 | - 'post_type' => $post_type, |
|
1946 | - 'post_status' => 'publish'); |
|
1942 | + foreach($all_postypes as $post_type){ |
|
1943 | + $args = array( |
|
1944 | + 'posts_per_page' => -1, |
|
1945 | + 'post_type' => $post_type, |
|
1946 | + 'post_status' => 'publish'); |
|
1947 | 1947 | |
1948 | - $posts_array = get_posts($args); |
|
1948 | + $posts_array = get_posts($args); |
|
1949 | 1949 | |
1950 | - if (!empty($posts_array)) { |
|
1950 | + if (!empty($posts_array)) { |
|
1951 | 1951 | |
1952 | - foreach ($posts_array as $post) { |
|
1952 | + foreach ($posts_array as $post) { |
|
1953 | 1953 | |
1954 | - geodir_set_wp_featured_image($post->ID); |
|
1954 | + geodir_set_wp_featured_image($post->ID); |
|
1955 | 1955 | |
1956 | - } |
|
1956 | + } |
|
1957 | 1957 | |
1958 | - } |
|
1959 | - } |
|
1958 | + } |
|
1959 | + } |
|
1960 | 1960 | |
1961 | 1961 | |
1962 | - update_option('geodir_set_post_attachments', '1'); |
|
1962 | + update_option('geodir_set_post_attachments', '1'); |
|
1963 | 1963 | |
1964 | - } |
|
1964 | + } |
|
1965 | 1965 | |
1966 | 1966 | } |
1967 | 1967 | |
@@ -1978,19 +1978,19 @@ discard block |
||
1978 | 1978 | function geodir_remove_url_seperator() |
1979 | 1979 | { |
1980 | 1980 | |
1981 | - if (!get_option('geodir_remove_url_seperator')) { |
|
1981 | + if (!get_option('geodir_remove_url_seperator')) { |
|
1982 | 1982 | |
1983 | - if (get_option('geodir_listingurl_separator')) |
|
1984 | - delete_option('geodir_listingurl_separator'); |
|
1983 | + if (get_option('geodir_listingurl_separator')) |
|
1984 | + delete_option('geodir_listingurl_separator'); |
|
1985 | 1985 | |
1986 | - if (get_option('geodir_detailurl_separator')) |
|
1987 | - delete_option('geodir_detailurl_separator'); |
|
1986 | + if (get_option('geodir_detailurl_separator')) |
|
1987 | + delete_option('geodir_detailurl_separator'); |
|
1988 | 1988 | |
1989 | - flush_rewrite_rules(false); |
|
1989 | + flush_rewrite_rules(false); |
|
1990 | 1990 | |
1991 | - update_option('geodir_remove_url_seperator', '1'); |
|
1991 | + update_option('geodir_remove_url_seperator', '1'); |
|
1992 | 1992 | |
1993 | - } |
|
1993 | + } |
|
1994 | 1994 | |
1995 | 1995 | } |
1996 | 1996 | |
@@ -2006,19 +2006,19 @@ discard block |
||
2006 | 2006 | */ |
2007 | 2007 | function geodir_remove_url_seperator_form_permalink_settings($permalink_arr) |
2008 | 2008 | { |
2009 | - foreach ($permalink_arr as $key => $value) { |
|
2009 | + foreach ($permalink_arr as $key => $value) { |
|
2010 | 2010 | |
2011 | - if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator') |
|
2012 | - unset($permalink_arr[$key]); |
|
2011 | + if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator') |
|
2012 | + unset($permalink_arr[$key]); |
|
2013 | 2013 | |
2014 | - } |
|
2014 | + } |
|
2015 | 2015 | |
2016 | - return $permalink_arr; |
|
2016 | + return $permalink_arr; |
|
2017 | 2017 | |
2018 | 2018 | } |
2019 | 2019 | |
2020 | 2020 | if (!is_admin()) { |
2021 | - add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post'); |
|
2021 | + add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post'); |
|
2022 | 2022 | } |
2023 | 2023 | /** |
2024 | 2024 | * Set status from draft to publish. |
@@ -2031,16 +2031,16 @@ discard block |
||
2031 | 2031 | */ |
2032 | 2032 | function geodir_set_status_draft_to_publish_for_own_post($post) |
2033 | 2033 | { |
2034 | - $user_id = get_current_user_id(); |
|
2034 | + $user_id = get_current_user_id(); |
|
2035 | 2035 | |
2036 | - if(!$user_id){return $post;} |
|
2036 | + if(!$user_id){return $post;} |
|
2037 | 2037 | |
2038 | - $gd_post_types = geodir_get_posttypes(); |
|
2038 | + $gd_post_types = geodir_get_posttypes(); |
|
2039 | 2039 | |
2040 | - if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) { |
|
2041 | - $post[0]->post_status = 'publish'; |
|
2042 | - } |
|
2043 | - return $post; |
|
2040 | + if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) { |
|
2041 | + $post[0]->post_status = 'publish'; |
|
2042 | + } |
|
2043 | + return $post; |
|
2044 | 2044 | } |
2045 | 2045 | |
2046 | 2046 | |
@@ -2132,33 +2132,33 @@ discard block |
||
2132 | 2132 | */ |
2133 | 2133 | function geodir_detail_page_tab_headings_change($tabs_arr) |
2134 | 2134 | { |
2135 | - global $wpdb; |
|
2135 | + global $wpdb; |
|
2136 | 2136 | |
2137 | - $post_type = geodir_get_current_posttype(); |
|
2137 | + $post_type = geodir_get_current_posttype(); |
|
2138 | 2138 | |
2139 | - $all_postypes = geodir_get_posttypes(); |
|
2139 | + $all_postypes = geodir_get_posttypes(); |
|
2140 | 2140 | |
2141 | - if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) { |
|
2141 | + if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) { |
|
2142 | 2142 | |
2143 | - if (array_key_exists('post_video', $tabs_arr)) { |
|
2143 | + if (array_key_exists('post_video', $tabs_arr)) { |
|
2144 | 2144 | |
2145 | - $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type))); |
|
2145 | + $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type))); |
|
2146 | 2146 | |
2147 | - if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') |
|
2148 | - $tabs_arr['post_video']['heading_text'] = $field_title; |
|
2149 | - } |
|
2147 | + if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') |
|
2148 | + $tabs_arr['post_video']['heading_text'] = $field_title; |
|
2149 | + } |
|
2150 | 2150 | |
2151 | - if (array_key_exists('special_offers', $tabs_arr)) { |
|
2151 | + if (array_key_exists('special_offers', $tabs_arr)) { |
|
2152 | 2152 | |
2153 | - $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type))); |
|
2153 | + $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type))); |
|
2154 | 2154 | |
2155 | - if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') |
|
2156 | - $tabs_arr['special_offers']['heading_text'] = $field_title; |
|
2157 | - } |
|
2155 | + if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') |
|
2156 | + $tabs_arr['special_offers']['heading_text'] = $field_title; |
|
2157 | + } |
|
2158 | 2158 | |
2159 | - } |
|
2159 | + } |
|
2160 | 2160 | |
2161 | - return $tabs_arr; |
|
2161 | + return $tabs_arr; |
|
2162 | 2162 | |
2163 | 2163 | } |
2164 | 2164 | |
@@ -2171,10 +2171,10 @@ discard block |
||
2171 | 2171 | */ |
2172 | 2172 | function geodir_remove_template_redirect_actions() |
2173 | 2173 | { |
2174 | - if (geodir_is_page('login')){ |
|
2175 | - remove_all_actions('template_redirect'); |
|
2176 | - remove_action('init', 'avia_modify_front', 10); |
|
2177 | - } |
|
2174 | + if (geodir_is_page('login')){ |
|
2175 | + remove_all_actions('template_redirect'); |
|
2176 | + remove_action('init', 'avia_modify_front', 10); |
|
2177 | + } |
|
2178 | 2178 | } |
2179 | 2179 | |
2180 | 2180 | |
@@ -2196,51 +2196,51 @@ discard block |
||
2196 | 2196 | function geodirectory_before_featured_image_delete($attachment_id) |
2197 | 2197 | { |
2198 | 2198 | |
2199 | - global $wpdb, $plugin_prefix; |
|
2199 | + global $wpdb, $plugin_prefix; |
|
2200 | 2200 | |
2201 | - $post_id = get_post_field('post_parent', $attachment_id); |
|
2201 | + $post_id = get_post_field('post_parent', $attachment_id); |
|
2202 | 2202 | |
2203 | - $attachment_url = wp_get_attachment_url($attachment_id); |
|
2203 | + $attachment_url = wp_get_attachment_url($attachment_id); |
|
2204 | 2204 | |
2205 | - if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) { |
|
2205 | + if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) { |
|
2206 | 2206 | |
2207 | - $post_type = get_post_type($post_id); |
|
2207 | + $post_type = get_post_type($post_id); |
|
2208 | 2208 | |
2209 | - $all_postypes = geodir_get_posttypes(); |
|
2209 | + $all_postypes = geodir_get_posttypes(); |
|
2210 | 2210 | |
2211 | - if (!in_array($post_type, $all_postypes) || !is_admin()) |
|
2212 | - return false; |
|
2211 | + if (!in_array($post_type, $all_postypes) || !is_admin()) |
|
2212 | + return false; |
|
2213 | 2213 | |
2214 | - $uploads = wp_upload_dir(); |
|
2214 | + $uploads = wp_upload_dir(); |
|
2215 | 2215 | |
2216 | - $split_img_path = explode($uploads['baseurl'], $attachment_url); |
|
2216 | + $split_img_path = explode($uploads['baseurl'], $attachment_url); |
|
2217 | 2217 | |
2218 | - $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
2218 | + $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
2219 | 2219 | |
2220 | - $wpdb->query( |
|
2221 | - $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ", |
|
2222 | - array($post_id, $split_img_file_path) |
|
2223 | - ) |
|
2224 | - ); |
|
2220 | + $wpdb->query( |
|
2221 | + $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ", |
|
2222 | + array($post_id, $split_img_file_path) |
|
2223 | + ) |
|
2224 | + ); |
|
2225 | 2225 | |
2226 | - $attachment_data = $wpdb->get_row( |
|
2227 | - $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d", |
|
2228 | - array($post_id) |
|
2229 | - ) |
|
2230 | - ); |
|
2226 | + $attachment_data = $wpdb->get_row( |
|
2227 | + $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d", |
|
2228 | + array($post_id) |
|
2229 | + ) |
|
2230 | + ); |
|
2231 | 2231 | |
2232 | - if (!empty($attachment_data)) { |
|
2233 | - $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2234 | - } |
|
2232 | + if (!empty($attachment_data)) { |
|
2233 | + $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2234 | + } |
|
2235 | 2235 | |
2236 | 2236 | |
2237 | - $table_name = $plugin_prefix . $post_type . '_detail'; |
|
2237 | + $table_name = $plugin_prefix . $post_type . '_detail'; |
|
2238 | 2238 | |
2239 | - $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id); |
|
2239 | + $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id); |
|
2240 | 2240 | |
2241 | - geodir_set_wp_featured_image($post_id); |
|
2241 | + geodir_set_wp_featured_image($post_id); |
|
2242 | 2242 | |
2243 | - } |
|
2243 | + } |
|
2244 | 2244 | |
2245 | 2245 | } |
2246 | 2246 | |
@@ -2258,79 +2258,79 @@ discard block |
||
2258 | 2258 | function geodir_temp_set_post_attachment() |
2259 | 2259 | { |
2260 | 2260 | |
2261 | - global $wpdb, $plugin_prefix; |
|
2261 | + global $wpdb, $plugin_prefix; |
|
2262 | 2262 | |
2263 | - $all_postypes = geodir_get_posttypes(); |
|
2263 | + $all_postypes = geodir_get_posttypes(); |
|
2264 | 2264 | |
2265 | - foreach ($all_postypes as $posttype) { |
|
2265 | + foreach ($all_postypes as $posttype) { |
|
2266 | 2266 | |
2267 | - $tablename = $plugin_prefix . $posttype . '_detail'; |
|
2267 | + $tablename = $plugin_prefix . $posttype . '_detail'; |
|
2268 | 2268 | |
2269 | - $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename); |
|
2269 | + $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename); |
|
2270 | 2270 | |
2271 | - if (!empty($get_post_data)) { |
|
2271 | + if (!empty($get_post_data)) { |
|
2272 | 2272 | |
2273 | - foreach ($get_post_data as $data) { |
|
2273 | + foreach ($get_post_data as $data) { |
|
2274 | 2274 | |
2275 | - $post_id = $data->post_id; |
|
2275 | + $post_id = $data->post_id; |
|
2276 | 2276 | |
2277 | - $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''"); |
|
2277 | + $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''"); |
|
2278 | 2278 | |
2279 | - if (!empty($attachment_data)) { |
|
2279 | + if (!empty($attachment_data)) { |
|
2280 | 2280 | |
2281 | - foreach ($attachment_data as $attach) { |
|
2281 | + foreach ($attachment_data as $attach) { |
|
2282 | 2282 | |
2283 | - $file_info = pathinfo($attach->file); |
|
2283 | + $file_info = pathinfo($attach->file); |
|
2284 | 2284 | |
2285 | - $sub_dir = ''; |
|
2286 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
2287 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
2285 | + $sub_dir = ''; |
|
2286 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
2287 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
2288 | 2288 | |
2289 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
2290 | - $uploads_path = $uploads['basedir']; |
|
2289 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
2290 | + $uploads_path = $uploads['basedir']; |
|
2291 | 2291 | |
2292 | - $file_name = $file_info['basename']; |
|
2292 | + $file_name = $file_info['basename']; |
|
2293 | 2293 | |
2294 | - $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name; |
|
2294 | + $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name; |
|
2295 | 2295 | |
2296 | - if (!file_exists($img_arr['path'])) { |
|
2296 | + if (!file_exists($img_arr['path'])) { |
|
2297 | 2297 | |
2298 | - $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID); |
|
2298 | + $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID); |
|
2299 | 2299 | |
2300 | - } |
|
2300 | + } |
|
2301 | 2301 | |
2302 | - } |
|
2302 | + } |
|
2303 | 2303 | |
2304 | - $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id"); |
|
2304 | + $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id"); |
|
2305 | 2305 | |
2306 | - if (!empty($attachment_data)) { |
|
2306 | + if (!empty($attachment_data)) { |
|
2307 | 2307 | |
2308 | - if ($attachment_data->ID) |
|
2309 | - $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2308 | + if ($attachment_data->ID) |
|
2309 | + $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2310 | 2310 | |
2311 | - } else { |
|
2311 | + } else { |
|
2312 | 2312 | |
2313 | - if (has_post_thumbnail($post_id)) { |
|
2313 | + if (has_post_thumbnail($post_id)) { |
|
2314 | 2314 | |
2315 | - $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
2315 | + $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
2316 | 2316 | |
2317 | - wp_delete_attachment($post_thumbnail_id); |
|
2317 | + wp_delete_attachment($post_thumbnail_id); |
|
2318 | 2318 | |
2319 | - } |
|
2319 | + } |
|
2320 | 2320 | |
2321 | - } |
|
2321 | + } |
|
2322 | 2322 | |
2323 | - $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id); |
|
2323 | + $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id); |
|
2324 | 2324 | |
2325 | - geodir_set_wp_featured_image($post_id); |
|
2325 | + geodir_set_wp_featured_image($post_id); |
|
2326 | 2326 | |
2327 | - } |
|
2327 | + } |
|
2328 | 2328 | |
2329 | - } |
|
2329 | + } |
|
2330 | 2330 | |
2331 | - } |
|
2331 | + } |
|
2332 | 2332 | |
2333 | - } |
|
2333 | + } |
|
2334 | 2334 | |
2335 | 2335 | } |
2336 | 2336 | |
@@ -2348,9 +2348,9 @@ discard block |
||
2348 | 2348 | function geodir_default_rating_star_icon() |
2349 | 2349 | { |
2350 | 2350 | |
2351 | - if (!get_option('geodir_default_rating_star_icon')) { |
|
2352 | - update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png'); |
|
2353 | - } |
|
2351 | + if (!get_option('geodir_default_rating_star_icon')) { |
|
2352 | + update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png'); |
|
2353 | + } |
|
2354 | 2354 | |
2355 | 2355 | } |
2356 | 2356 | |
@@ -2368,25 +2368,25 @@ discard block |
||
2368 | 2368 | */ |
2369 | 2369 | function geodir_user_post_listing_count($user_id = 0) |
2370 | 2370 | { |
2371 | - global $wpdb, $plugin_prefix, $current_user; |
|
2372 | - if(!$user_id){ |
|
2373 | - $user_id = $current_user->ID; |
|
2374 | - } |
|
2371 | + global $wpdb, $plugin_prefix, $current_user; |
|
2372 | + if(!$user_id){ |
|
2373 | + $user_id = $current_user->ID; |
|
2374 | + } |
|
2375 | 2375 | |
2376 | - $all_posts = get_option('geodir_listing_link_user_dashboard'); |
|
2376 | + $all_posts = get_option('geodir_listing_link_user_dashboard'); |
|
2377 | 2377 | |
2378 | - $user_listing = array(); |
|
2379 | - if ($user_id && is_array($all_posts) && !empty($all_posts)) { |
|
2380 | - foreach ($all_posts as $ptype) { |
|
2381 | - $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )"); |
|
2378 | + $user_listing = array(); |
|
2379 | + if ($user_id && is_array($all_posts) && !empty($all_posts)) { |
|
2380 | + foreach ($all_posts as $ptype) { |
|
2381 | + $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )"); |
|
2382 | 2382 | |
2383 | - if ($total_posts > 0) { |
|
2384 | - $user_listing[$ptype] = $total_posts; |
|
2385 | - } |
|
2386 | - } |
|
2387 | - } |
|
2383 | + if ($total_posts > 0) { |
|
2384 | + $user_listing[$ptype] = $total_posts; |
|
2385 | + } |
|
2386 | + } |
|
2387 | + } |
|
2388 | 2388 | |
2389 | - return $user_listing; |
|
2389 | + return $user_listing; |
|
2390 | 2390 | } |
2391 | 2391 | |
2392 | 2392 | |
@@ -2406,189 +2406,189 @@ discard block |
||
2406 | 2406 | */ |
2407 | 2407 | function geodir_detail_page_custom_field_tab($tabs_arr) |
2408 | 2408 | { |
2409 | - global $post; |
|
2410 | - |
|
2411 | - $post_type = geodir_get_current_posttype(); |
|
2412 | - $all_postypes = geodir_get_posttypes(); |
|
2413 | - |
|
2414 | - if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) { |
|
2415 | - $package_info = array(); |
|
2416 | - $package_info = geodir_post_package_info($package_info, $post); |
|
2417 | - $post_package_id = !empty($package_info->pid) ? $package_info->pid : ''; |
|
2418 | - $fields_location = 'owntab'; |
|
2419 | - |
|
2420 | - $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location); |
|
2421 | - //remove video and special offers if it is already set to show |
|
2422 | - if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){ |
|
2423 | - $unset_video = true; |
|
2424 | - } |
|
2425 | - |
|
2426 | - if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){ |
|
2427 | - $unset_special_offers = true; |
|
2428 | - } |
|
2429 | - if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){ |
|
2430 | - foreach($custom_fields as $key => $custom_field){ |
|
2431 | - if($custom_field['name']=='geodir_video' && isset($unset_video)){ |
|
2432 | - unset($custom_fields[$key]); |
|
2433 | - } |
|
2434 | - if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){ |
|
2435 | - unset($custom_fields[$key]); |
|
2436 | - } |
|
2437 | - } |
|
2438 | - } |
|
2439 | - |
|
2440 | - |
|
2441 | - if (!empty($custom_fields)) { |
|
2442 | - $parse_custom_fields = array(); |
|
2443 | - foreach ($custom_fields as $field) { |
|
2444 | - $field = stripslashes_deep($field); // strip slashes |
|
2445 | - $type = $field; |
|
2446 | - $field_name = $field['htmlvar_name']; |
|
2447 | - if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { |
|
2448 | - $post->{$field_name} = $_REQUEST[$field_name]; |
|
2449 | - } |
|
2409 | + global $post; |
|
2450 | 2410 | |
2451 | - if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { |
|
2452 | - if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) { |
|
2453 | - continue; |
|
2454 | - } |
|
2411 | + $post_type = geodir_get_current_posttype(); |
|
2412 | + $all_postypes = geodir_get_posttypes(); |
|
2455 | 2413 | |
2456 | - $parse_custom_fields[] = $field; |
|
2457 | - } |
|
2458 | - } |
|
2459 | - $custom_fields = $parse_custom_fields; |
|
2460 | - } |
|
2461 | - //print_r($custom_fields); |
|
2462 | - if (!empty($custom_fields)) { |
|
2414 | + if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) { |
|
2415 | + $package_info = array(); |
|
2416 | + $package_info = geodir_post_package_info($package_info, $post); |
|
2417 | + $post_package_id = !empty($package_info->pid) ? $package_info->pid : ''; |
|
2418 | + $fields_location = 'owntab'; |
|
2463 | 2419 | |
2464 | - global $field_set_start; |
|
2420 | + $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location); |
|
2421 | + //remove video and special offers if it is already set to show |
|
2422 | + if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){ |
|
2423 | + $unset_video = true; |
|
2424 | + } |
|
2465 | 2425 | |
2466 | - $post = stripslashes_deep($post); // strip slashes |
|
2467 | - |
|
2468 | - $field_set_start = 0; |
|
2469 | - $fieldset_count = 0; |
|
2470 | - $fieldset = ''; |
|
2471 | - $total_fields = count($custom_fields); |
|
2472 | - $count_field = 0; |
|
2473 | - $fieldset_arr = array(); |
|
2474 | - $i = 0; |
|
2475 | - $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL; |
|
2476 | - |
|
2477 | - foreach ($custom_fields as $field) { |
|
2478 | - $count_field++; |
|
2479 | - $field_name = $field['htmlvar_name']; |
|
2480 | - if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { |
|
2481 | - $post->{$field_name} = $_REQUEST[$field_name]; |
|
2482 | - } |
|
2426 | + if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){ |
|
2427 | + $unset_special_offers = true; |
|
2428 | + } |
|
2429 | + if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){ |
|
2430 | + foreach($custom_fields as $key => $custom_field){ |
|
2431 | + if($custom_field['name']=='geodir_video' && isset($unset_video)){ |
|
2432 | + unset($custom_fields[$key]); |
|
2433 | + } |
|
2434 | + if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){ |
|
2435 | + unset($custom_fields[$key]); |
|
2436 | + } |
|
2437 | + } |
|
2438 | + } |
|
2483 | 2439 | |
2484 | - if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { |
|
2485 | - $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title']; |
|
2486 | - $site_title = trim($field['site_title']); |
|
2487 | - $type = $field; |
|
2488 | - $variables_array = array(); |
|
2489 | 2440 | |
2490 | - if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) { |
|
2491 | - continue; |
|
2492 | - } |
|
2441 | + if (!empty($custom_fields)) { |
|
2442 | + $parse_custom_fields = array(); |
|
2443 | + foreach ($custom_fields as $field) { |
|
2444 | + $field = stripslashes_deep($field); // strip slashes |
|
2445 | + $type = $field; |
|
2446 | + $field_name = $field['htmlvar_name']; |
|
2447 | + if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { |
|
2448 | + $post->{$field_name} = $_REQUEST[$field_name]; |
|
2449 | + } |
|
2493 | 2450 | |
2494 | - if ($type['type'] != 'fieldset') { |
|
2495 | - $i++; |
|
2496 | - $variables_array['post_id'] = $post->ID; |
|
2497 | - $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
2498 | - $variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : ''; |
|
2499 | - |
|
2500 | - }else{ |
|
2501 | - $i = 0; |
|
2502 | - $fieldset_count++; |
|
2503 | - $field_set_start = 1; |
|
2504 | - $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count; |
|
2505 | - $fieldset_arr[$fieldset_count]['label'] = $label; |
|
2506 | - } |
|
2451 | + if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { |
|
2452 | + if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) { |
|
2453 | + continue; |
|
2454 | + } |
|
2507 | 2455 | |
2456 | + $parse_custom_fields[] = $field; |
|
2457 | + } |
|
2458 | + } |
|
2459 | + $custom_fields = $parse_custom_fields; |
|
2460 | + } |
|
2461 | + //print_r($custom_fields); |
|
2462 | + if (!empty($custom_fields)) { |
|
2508 | 2463 | |
2509 | - if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];} |
|
2510 | - $type = stripslashes_deep($type); // strip slashes |
|
2511 | - if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;} |
|
2512 | - $html = ''; |
|
2513 | - $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
2514 | - if($html_var=='post'){$html_var='post_address';} |
|
2515 | - $field_icon = geodir_field_icon_proccess($type); |
|
2516 | - $filed_type = $type['type']; |
|
2517 | - |
|
2518 | - /** |
|
2519 | - * Filter the output for custom fields. |
|
2520 | - * |
|
2521 | - * Here we can remove or add new functions depending on the field type. |
|
2522 | - * |
|
2523 | - * @param string $html The html to be filtered (blank). |
|
2524 | - * @param string $fields_location The location the field is to be show. |
|
2525 | - * @param array $type The array of field values. |
|
2526 | - */ |
|
2527 | - $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
2528 | - |
|
2529 | - |
|
2530 | - /** |
|
2531 | - * Filter custom field output in tab. |
|
2532 | - * |
|
2533 | - * @since 1.5.6 |
|
2534 | - * |
|
2535 | - * @param string $html_var The HTML variable name for the field. |
|
2536 | - * @param string $html Custom field unfiltered HTML. |
|
2537 | - * @param array $variables_array Custom field variables array. |
|
2538 | - */ |
|
2539 | - $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array); |
|
2540 | - |
|
2541 | - $fieldset_html = ''; |
|
2542 | - if ($field_set_start == 1) { |
|
2543 | - $add_html = false; |
|
2544 | - if ($type['type'] == 'fieldset' && $fieldset_count > 1) { |
|
2545 | - if ($fieldset != '') { |
|
2546 | - $add_html = true; |
|
2547 | - $label = $fieldset_arr[$fieldset_count - 1]['label']; |
|
2548 | - $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name']; |
|
2549 | - } |
|
2550 | - $fieldset_html = $fieldset; |
|
2551 | - $fieldset = ''; |
|
2552 | - } else { |
|
2553 | - $fieldset .= $html; |
|
2554 | - if ($total_fields == $count_field && $fieldset != '') { |
|
2555 | - $add_html = true; |
|
2556 | - $label = $fieldset_arr[$fieldset_count]['label']; |
|
2557 | - $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name']; |
|
2558 | - $fieldset_html = $fieldset; |
|
2559 | - } |
|
2560 | - } |
|
2464 | + global $field_set_start; |
|
2561 | 2465 | |
2562 | - if ($add_html) { |
|
2563 | - $tabs_arr[$htmlvar_name] = array( |
|
2564 | - 'heading_text' => __($label, 'geodirectory'), |
|
2565 | - 'is_active_tab' => false, |
|
2566 | - /** |
|
2567 | - * Filter if a custom field should be displayed on the details page tab. |
|
2568 | - * |
|
2569 | - * @since 1.0.0 |
|
2570 | - * @param string $htmlvar_name The field HTML var name. |
|
2571 | - */ |
|
2572 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name), |
|
2573 | - 'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>' |
|
2574 | - ); |
|
2575 | - } |
|
2576 | - } else { |
|
2577 | - if ($html != '') { |
|
2578 | - $tabs_arr[$html_var] = array( |
|
2579 | - 'heading_text' => __($label, 'geodirectory'), |
|
2580 | - 'is_active_tab' => false, |
|
2581 | - /** This action is documented in geodirectory_hooks_actions.php */ |
|
2582 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']), |
|
2583 | - 'tab_content' => $html |
|
2584 | - ); |
|
2585 | - } |
|
2586 | - } |
|
2587 | - } |
|
2588 | - } |
|
2589 | - } |
|
2590 | - } |
|
2591 | - return $tabs_arr; |
|
2466 | + $post = stripslashes_deep($post); // strip slashes |
|
2467 | + |
|
2468 | + $field_set_start = 0; |
|
2469 | + $fieldset_count = 0; |
|
2470 | + $fieldset = ''; |
|
2471 | + $total_fields = count($custom_fields); |
|
2472 | + $count_field = 0; |
|
2473 | + $fieldset_arr = array(); |
|
2474 | + $i = 0; |
|
2475 | + $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL; |
|
2476 | + |
|
2477 | + foreach ($custom_fields as $field) { |
|
2478 | + $count_field++; |
|
2479 | + $field_name = $field['htmlvar_name']; |
|
2480 | + if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { |
|
2481 | + $post->{$field_name} = $_REQUEST[$field_name]; |
|
2482 | + } |
|
2483 | + |
|
2484 | + if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { |
|
2485 | + $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title']; |
|
2486 | + $site_title = trim($field['site_title']); |
|
2487 | + $type = $field; |
|
2488 | + $variables_array = array(); |
|
2489 | + |
|
2490 | + if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) { |
|
2491 | + continue; |
|
2492 | + } |
|
2493 | + |
|
2494 | + if ($type['type'] != 'fieldset') { |
|
2495 | + $i++; |
|
2496 | + $variables_array['post_id'] = $post->ID; |
|
2497 | + $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
2498 | + $variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : ''; |
|
2499 | + |
|
2500 | + }else{ |
|
2501 | + $i = 0; |
|
2502 | + $fieldset_count++; |
|
2503 | + $field_set_start = 1; |
|
2504 | + $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count; |
|
2505 | + $fieldset_arr[$fieldset_count]['label'] = $label; |
|
2506 | + } |
|
2507 | + |
|
2508 | + |
|
2509 | + if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];} |
|
2510 | + $type = stripslashes_deep($type); // strip slashes |
|
2511 | + if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;} |
|
2512 | + $html = ''; |
|
2513 | + $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
2514 | + if($html_var=='post'){$html_var='post_address';} |
|
2515 | + $field_icon = geodir_field_icon_proccess($type); |
|
2516 | + $filed_type = $type['type']; |
|
2517 | + |
|
2518 | + /** |
|
2519 | + * Filter the output for custom fields. |
|
2520 | + * |
|
2521 | + * Here we can remove or add new functions depending on the field type. |
|
2522 | + * |
|
2523 | + * @param string $html The html to be filtered (blank). |
|
2524 | + * @param string $fields_location The location the field is to be show. |
|
2525 | + * @param array $type The array of field values. |
|
2526 | + */ |
|
2527 | + $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
2528 | + |
|
2529 | + |
|
2530 | + /** |
|
2531 | + * Filter custom field output in tab. |
|
2532 | + * |
|
2533 | + * @since 1.5.6 |
|
2534 | + * |
|
2535 | + * @param string $html_var The HTML variable name for the field. |
|
2536 | + * @param string $html Custom field unfiltered HTML. |
|
2537 | + * @param array $variables_array Custom field variables array. |
|
2538 | + */ |
|
2539 | + $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array); |
|
2540 | + |
|
2541 | + $fieldset_html = ''; |
|
2542 | + if ($field_set_start == 1) { |
|
2543 | + $add_html = false; |
|
2544 | + if ($type['type'] == 'fieldset' && $fieldset_count > 1) { |
|
2545 | + if ($fieldset != '') { |
|
2546 | + $add_html = true; |
|
2547 | + $label = $fieldset_arr[$fieldset_count - 1]['label']; |
|
2548 | + $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name']; |
|
2549 | + } |
|
2550 | + $fieldset_html = $fieldset; |
|
2551 | + $fieldset = ''; |
|
2552 | + } else { |
|
2553 | + $fieldset .= $html; |
|
2554 | + if ($total_fields == $count_field && $fieldset != '') { |
|
2555 | + $add_html = true; |
|
2556 | + $label = $fieldset_arr[$fieldset_count]['label']; |
|
2557 | + $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name']; |
|
2558 | + $fieldset_html = $fieldset; |
|
2559 | + } |
|
2560 | + } |
|
2561 | + |
|
2562 | + if ($add_html) { |
|
2563 | + $tabs_arr[$htmlvar_name] = array( |
|
2564 | + 'heading_text' => __($label, 'geodirectory'), |
|
2565 | + 'is_active_tab' => false, |
|
2566 | + /** |
|
2567 | + * Filter if a custom field should be displayed on the details page tab. |
|
2568 | + * |
|
2569 | + * @since 1.0.0 |
|
2570 | + * @param string $htmlvar_name The field HTML var name. |
|
2571 | + */ |
|
2572 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name), |
|
2573 | + 'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>' |
|
2574 | + ); |
|
2575 | + } |
|
2576 | + } else { |
|
2577 | + if ($html != '') { |
|
2578 | + $tabs_arr[$html_var] = array( |
|
2579 | + 'heading_text' => __($label, 'geodirectory'), |
|
2580 | + 'is_active_tab' => false, |
|
2581 | + /** This action is documented in geodirectory_hooks_actions.php */ |
|
2582 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']), |
|
2583 | + 'tab_content' => $html |
|
2584 | + ); |
|
2585 | + } |
|
2586 | + } |
|
2587 | + } |
|
2588 | + } |
|
2589 | + } |
|
2590 | + } |
|
2591 | + return $tabs_arr; |
|
2592 | 2592 | } |
2593 | 2593 | |
2594 | 2594 | /* display add listing page for wpml */ |
@@ -2612,41 +2612,41 @@ discard block |
||
2612 | 2612 | */ |
2613 | 2613 | function geodir_add_post_status_author_page() |
2614 | 2614 | { |
2615 | - global $wpdb, $post; |
|
2616 | - |
|
2617 | - $html = ''; |
|
2618 | - if (get_current_user_id()) { |
|
2619 | - |
|
2620 | - $is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author')); |
|
2621 | - if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) { |
|
2622 | - |
|
2623 | - // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them. |
|
2624 | - $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID"); |
|
2625 | - $status = "<strong>("; |
|
2626 | - $status_icon = '<i class="fa fa-play"></i>'; |
|
2627 | - if ($real_status == 'publish') { |
|
2628 | - $status .= __('Published', 'geodirectory'); |
|
2629 | - }elseif ($real_status == 'pending') { |
|
2630 | - $status .= __('Awaiting Review', 'geodirectory'); |
|
2631 | - } else { |
|
2632 | - $status .= __('Not published', 'geodirectory'); |
|
2633 | - $status_icon = '<i class="fa fa-pause"></i>'; |
|
2634 | - } |
|
2635 | - $status .= ")</strong>"; |
|
2615 | + global $wpdb, $post; |
|
2616 | + |
|
2617 | + $html = ''; |
|
2618 | + if (get_current_user_id()) { |
|
2619 | + |
|
2620 | + $is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author')); |
|
2621 | + if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) { |
|
2622 | + |
|
2623 | + // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them. |
|
2624 | + $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID"); |
|
2625 | + $status = "<strong>("; |
|
2626 | + $status_icon = '<i class="fa fa-play"></i>'; |
|
2627 | + if ($real_status == 'publish') { |
|
2628 | + $status .= __('Published', 'geodirectory'); |
|
2629 | + }elseif ($real_status == 'pending') { |
|
2630 | + $status .= __('Awaiting Review', 'geodirectory'); |
|
2631 | + } else { |
|
2632 | + $status .= __('Not published', 'geodirectory'); |
|
2633 | + $status_icon = '<i class="fa fa-pause"></i>'; |
|
2634 | + } |
|
2635 | + $status .= ")</strong>"; |
|
2636 | 2636 | |
2637 | - $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>'; |
|
2638 | - } |
|
2639 | - } |
|
2637 | + $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>'; |
|
2638 | + } |
|
2639 | + } |
|
2640 | 2640 | |
2641 | - if ($html != '') { |
|
2642 | - /** |
|
2643 | - * Filter the post status text on the author page. |
|
2644 | - * |
|
2645 | - * @since 1.0.0 |
|
2646 | - * @param string $html The HTML of the status. |
|
2647 | - */ |
|
2648 | - echo apply_filters('geodir_filter_status_text_on_author_page', $html); |
|
2649 | - } |
|
2641 | + if ($html != '') { |
|
2642 | + /** |
|
2643 | + * Filter the post status text on the author page. |
|
2644 | + * |
|
2645 | + * @since 1.0.0 |
|
2646 | + * @param string $html The HTML of the status. |
|
2647 | + */ |
|
2648 | + echo apply_filters('geodir_filter_status_text_on_author_page', $html); |
|
2649 | + } |
|
2650 | 2650 | |
2651 | 2651 | |
2652 | 2652 | } |
@@ -2660,9 +2660,9 @@ discard block |
||
2660 | 2660 | * @package GeoDirectory |
2661 | 2661 | */ |
2662 | 2662 | function geodir_init_no_rating() { |
2663 | - if (geodir_rating_disabled_post_types()) { |
|
2664 | - add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2); |
|
2665 | - } |
|
2663 | + if (geodir_rating_disabled_post_types()) { |
|
2664 | + add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2); |
|
2665 | + } |
|
2666 | 2666 | } |
2667 | 2667 | |
2668 | 2668 | /** |
@@ -2676,22 +2676,22 @@ discard block |
||
2676 | 2676 | * @return array Modified sort options array. |
2677 | 2677 | */ |
2678 | 2678 | function geodir_no_rating_get_sort_options($options, $post_type = '') { |
2679 | - if (!empty($post_type) && geodir_cpt_has_rating_disabled($post_type)) { |
|
2680 | - $new_options = array(); |
|
2679 | + if (!empty($post_type) && geodir_cpt_has_rating_disabled($post_type)) { |
|
2680 | + $new_options = array(); |
|
2681 | 2681 | |
2682 | - if (!empty($options)) { |
|
2683 | - foreach ($options as $option) { |
|
2684 | - if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') { |
|
2685 | - continue; |
|
2686 | - } |
|
2687 | - $new_options[] = $option; |
|
2688 | - } |
|
2682 | + if (!empty($options)) { |
|
2683 | + foreach ($options as $option) { |
|
2684 | + if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') { |
|
2685 | + continue; |
|
2686 | + } |
|
2687 | + $new_options[] = $option; |
|
2688 | + } |
|
2689 | 2689 | |
2690 | - $options = $new_options; |
|
2691 | - } |
|
2692 | - } |
|
2690 | + $options = $new_options; |
|
2691 | + } |
|
2692 | + } |
|
2693 | 2693 | |
2694 | - return $options; |
|
2694 | + return $options; |
|
2695 | 2695 | } |
2696 | 2696 | |
2697 | 2697 | /** |
@@ -2703,9 +2703,9 @@ discard block |
||
2703 | 2703 | * @return array Modified class array. |
2704 | 2704 | */ |
2705 | 2705 | function geodir_body_class_active_map($classes = array()) { |
2706 | - $classes[] = 'gd-map-' . geodir_map_name(); |
|
2706 | + $classes[] = 'gd-map-' . geodir_map_name(); |
|
2707 | 2707 | |
2708 | - return $classes; |
|
2708 | + return $classes; |
|
2709 | 2709 | } |
2710 | 2710 | add_filter('body_class', 'geodir_body_class_active_map', 100); |
2711 | 2711 | |
@@ -2718,9 +2718,9 @@ discard block |
||
2718 | 2718 | * @return string Modified class string. |
2719 | 2719 | */ |
2720 | 2720 | function geodir_admin_body_class_active_map($class = '') { |
2721 | - $class .= ' gd-map-' . geodir_map_name(); |
|
2721 | + $class .= ' gd-map-' . geodir_map_name(); |
|
2722 | 2722 | |
2723 | - return $class; |
|
2723 | + return $class; |
|
2724 | 2724 | } |
2725 | 2725 | add_filter('admin_body_class', 'geodir_admin_body_class_active_map', 100); |
2726 | 2726 | |
@@ -2738,36 +2738,36 @@ discard block |
||
2738 | 2738 | * @return array Translation texts. |
2739 | 2739 | */ |
2740 | 2740 | function geodir_load_gd_options_text_translation($translation_texts = array()) { |
2741 | - $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
2742 | - |
|
2743 | - $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin'); |
|
2744 | - |
|
2745 | - /** |
|
2746 | - * Filters the geodirectory option names that requires to add for translation. |
|
2747 | - * |
|
2748 | - * @since 1.5.7 |
|
2749 | - * @package GeoDirectory |
|
2750 | - * |
|
2751 | - * @param array $gd_options Array of option names. |
|
2752 | - */ |
|
2753 | - $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options); |
|
2754 | - $gd_options = array_unique($gd_options); |
|
2755 | - |
|
2756 | - if (!empty($gd_options)) { |
|
2757 | - foreach ($gd_options as $gd_option) { |
|
2758 | - if ($gd_option != '' && $option_value = get_option($gd_option)) { |
|
2759 | - $option_value = is_string($option_value) ? stripslashes_deep($option_value) : ''; |
|
2741 | + $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
2742 | + |
|
2743 | + $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin'); |
|
2744 | + |
|
2745 | + /** |
|
2746 | + * Filters the geodirectory option names that requires to add for translation. |
|
2747 | + * |
|
2748 | + * @since 1.5.7 |
|
2749 | + * @package GeoDirectory |
|
2750 | + * |
|
2751 | + * @param array $gd_options Array of option names. |
|
2752 | + */ |
|
2753 | + $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options); |
|
2754 | + $gd_options = array_unique($gd_options); |
|
2755 | + |
|
2756 | + if (!empty($gd_options)) { |
|
2757 | + foreach ($gd_options as $gd_option) { |
|
2758 | + if ($gd_option != '' && $option_value = get_option($gd_option)) { |
|
2759 | + $option_value = is_string($option_value) ? stripslashes_deep($option_value) : ''; |
|
2760 | 2760 | |
2761 | - if ($option_value != '' && !in_array($option_value, $translation_texts)) { |
|
2762 | - $translation_texts[] = stripslashes_deep($option_value); |
|
2763 | - } |
|
2764 | - } |
|
2765 | - } |
|
2766 | - } |
|
2761 | + if ($option_value != '' && !in_array($option_value, $translation_texts)) { |
|
2762 | + $translation_texts[] = stripslashes_deep($option_value); |
|
2763 | + } |
|
2764 | + } |
|
2765 | + } |
|
2766 | + } |
|
2767 | 2767 | |
2768 | - $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
2768 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
2769 | 2769 | |
2770 | - return $translation_texts; |
|
2770 | + return $translation_texts; |
|
2771 | 2771 | } |
2772 | 2772 | |
2773 | 2773 | add_filter('geodir_load_db_language', 'geodir_load_gd_options_text_translation'); |
@@ -2781,15 +2781,15 @@ discard block |
||
2781 | 2781 | |
2782 | 2782 | add_filter('get_comments_link', 'gd_get_comments_link', 10, 2); |
2783 | 2783 | function gd_get_comments_link($comments_link, $post_id) { |
2784 | - $post_type = get_post_type($post_id); |
|
2784 | + $post_type = get_post_type($post_id); |
|
2785 | 2785 | |
2786 | - $all_postypes = geodir_get_posttypes(); |
|
2787 | - if (in_array($post_type, $all_postypes)) { |
|
2788 | - $comments_link = str_replace('#comments', '#reviews', $comments_link); |
|
2789 | - $comments_link = str_replace('#respond', '#reviews', $comments_link); |
|
2790 | - } |
|
2786 | + $all_postypes = geodir_get_posttypes(); |
|
2787 | + if (in_array($post_type, $all_postypes)) { |
|
2788 | + $comments_link = str_replace('#comments', '#reviews', $comments_link); |
|
2789 | + $comments_link = str_replace('#respond', '#reviews', $comments_link); |
|
2790 | + } |
|
2791 | 2791 | |
2792 | - return $comments_link; |
|
2792 | + return $comments_link; |
|
2793 | 2793 | } |
2794 | 2794 | |
2795 | 2795 | |
@@ -2807,11 +2807,11 @@ discard block |
||
2807 | 2807 | function geodir_add_nav_menu_class( $args ) |
2808 | 2808 | { |
2809 | 2809 | |
2810 | - if(isset($args['menu_class'])){ |
|
2811 | - $args['menu_class'] = $args['menu_class']." gd-menu-z"; |
|
2812 | - } |
|
2810 | + if(isset($args['menu_class'])){ |
|
2811 | + $args['menu_class'] = $args['menu_class']." gd-menu-z"; |
|
2812 | + } |
|
2813 | 2813 | |
2814 | - return $args; |
|
2814 | + return $args; |
|
2815 | 2815 | } |
2816 | 2816 | |
2817 | 2817 | add_filter( 'wp_nav_menu_args', 'geodir_add_nav_menu_class' ); |
@@ -2828,15 +2828,15 @@ discard block |
||
2828 | 2828 | * @return string Filtered locale ID. |
2829 | 2829 | */ |
2830 | 2830 | function geodir_wpml_filter_locale($locale) { |
2831 | - global $sitepress; |
|
2831 | + global $sitepress; |
|
2832 | 2832 | |
2833 | - $post_type = !empty($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (!empty($_REQUEST['post']) ? get_post_type($_REQUEST['post']) : ''); |
|
2833 | + $post_type = !empty($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (!empty($_REQUEST['post']) ? get_post_type($_REQUEST['post']) : ''); |
|
2834 | 2834 | |
2835 | - if (!empty($sitepress) && $sitepress->is_post_edit_screen() && $post_type && in_array($post_type, geodir_get_posttypes()) && $current_lang = $sitepress->get_current_language()) { |
|
2836 | - $locale = $sitepress->get_locale($current_lang); |
|
2837 | - } |
|
2835 | + if (!empty($sitepress) && $sitepress->is_post_edit_screen() && $post_type && in_array($post_type, geodir_get_posttypes()) && $current_lang = $sitepress->get_current_language()) { |
|
2836 | + $locale = $sitepress->get_locale($current_lang); |
|
2837 | + } |
|
2838 | 2838 | |
2839 | - return $locale; |
|
2839 | + return $locale; |
|
2840 | 2840 | } |
2841 | 2841 | |
2842 | 2842 | /** |
@@ -2846,20 +2846,20 @@ discard block |
||
2846 | 2846 | * @package GeoDirectory |
2847 | 2847 | */ |
2848 | 2848 | function geodir_wpml_set_filter() { |
2849 | - if (geodir_is_wpml()) { |
|
2850 | - global $sitepress; |
|
2849 | + if (geodir_is_wpml()) { |
|
2850 | + global $sitepress; |
|
2851 | 2851 | |
2852 | - if ($sitepress->get_setting('sync_comments_on_duplicates')) { |
|
2853 | - add_action('comment_post', 'gepdir_wpml_sync_comment', 100, 1); |
|
2854 | - } |
|
2852 | + if ($sitepress->get_setting('sync_comments_on_duplicates')) { |
|
2853 | + add_action('comment_post', 'gepdir_wpml_sync_comment', 100, 1); |
|
2854 | + } |
|
2855 | 2855 | |
2856 | - add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2); |
|
2857 | - add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 ); |
|
2856 | + add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2); |
|
2857 | + add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 ); |
|
2858 | 2858 | add_action( 'geodir_after_search_form', 'geodir_wpml_add_language_input_field' ); |
2859 | - if (is_admin()) { |
|
2860 | - add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 ); |
|
2861 | - } |
|
2862 | - } |
|
2859 | + if (is_admin()) { |
|
2860 | + add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 ); |
|
2861 | + } |
|
2862 | + } |
|
2863 | 2863 | } |
2864 | 2864 | add_filter('plugins_loaded', 'geodir_wpml_set_filter'); |
2865 | 2865 | |
@@ -2872,38 +2872,38 @@ discard block |
||
2872 | 2872 | * @return array Filtered languages. |
2873 | 2873 | */ |
2874 | 2874 | function geodir_wpml_filter_ls_languages($languages) { |
2875 | - if (geodir_is_geodir_page()) { |
|
2876 | - $keep_vars = array(); |
|
2875 | + if (geodir_is_geodir_page()) { |
|
2876 | + $keep_vars = array(); |
|
2877 | 2877 | |
2878 | - if (geodir_is_page('add-listing')) { |
|
2879 | - $keep_vars = array('listing_type', 'package_id'); |
|
2880 | - } else if (geodir_is_page('search')) { |
|
2881 | - $keep_vars = array('geodir_search', 'stype', 'snear', 'set_location_type', 'set_location_val', 'sgeo_lat', 'sgeo_lon'); |
|
2882 | - } else if (geodir_is_page('author')) { |
|
2883 | - $keep_vars = array('geodir_dashbord', 'stype', 'list'); |
|
2884 | - } else if (geodir_is_page('login')) { |
|
2885 | - $keep_vars = array('forgot', 'signup'); |
|
2886 | - } |
|
2878 | + if (geodir_is_page('add-listing')) { |
|
2879 | + $keep_vars = array('listing_type', 'package_id'); |
|
2880 | + } else if (geodir_is_page('search')) { |
|
2881 | + $keep_vars = array('geodir_search', 'stype', 'snear', 'set_location_type', 'set_location_val', 'sgeo_lat', 'sgeo_lon'); |
|
2882 | + } else if (geodir_is_page('author')) { |
|
2883 | + $keep_vars = array('geodir_dashbord', 'stype', 'list'); |
|
2884 | + } else if (geodir_is_page('login')) { |
|
2885 | + $keep_vars = array('forgot', 'signup'); |
|
2886 | + } |
|
2887 | 2887 | |
2888 | - if (!empty($keep_vars)) { |
|
2889 | - foreach ( $languages as $code => $url) { |
|
2890 | - $filter_url = $url['url']; |
|
2888 | + if (!empty($keep_vars)) { |
|
2889 | + foreach ( $languages as $code => $url) { |
|
2890 | + $filter_url = $url['url']; |
|
2891 | 2891 | |
2892 | - foreach ($keep_vars as $var) { |
|
2893 | - if (isset($_GET[$var]) && !is_array($_GET[$var])) { |
|
2894 | - $filter_url = remove_query_arg(array($var), $filter_url); |
|
2895 | - $filter_url = add_query_arg(array($var => $_GET[$var]), $filter_url); |
|
2896 | - } |
|
2897 | - } |
|
2892 | + foreach ($keep_vars as $var) { |
|
2893 | + if (isset($_GET[$var]) && !is_array($_GET[$var])) { |
|
2894 | + $filter_url = remove_query_arg(array($var), $filter_url); |
|
2895 | + $filter_url = add_query_arg(array($var => $_GET[$var]), $filter_url); |
|
2896 | + } |
|
2897 | + } |
|
2898 | 2898 | |
2899 | - if ($filter_url != $url['url']) { |
|
2900 | - $languages[$code]['url'] = $filter_url; |
|
2901 | - } |
|
2902 | - } |
|
2903 | - } |
|
2904 | - } |
|
2899 | + if ($filter_url != $url['url']) { |
|
2900 | + $languages[$code]['url'] = $filter_url; |
|
2901 | + } |
|
2902 | + } |
|
2903 | + } |
|
2904 | + } |
|
2905 | 2905 | |
2906 | - return $languages; |
|
2906 | + return $languages; |
|
2907 | 2907 | } |
2908 | 2908 | add_filter( 'icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1 ); |
2909 | 2909 | |
@@ -2914,18 +2914,18 @@ discard block |
||
2914 | 2914 | * |
2915 | 2915 | */ |
2916 | 2916 | function geodir_remove_yoast_seo_metas(){ |
2917 | - if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) { |
|
2918 | - $wpseo = WPSEO_Frontend::get_instance(); |
|
2917 | + if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) { |
|
2918 | + $wpseo = WPSEO_Frontend::get_instance(); |
|
2919 | 2919 | |
2920 | - remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 ); |
|
2921 | - remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 ); |
|
2922 | - remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 ); |
|
2923 | - remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 ); |
|
2924 | - remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 ); |
|
2925 | - remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 ); |
|
2920 | + remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 ); |
|
2921 | + remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 ); |
|
2922 | + remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 ); |
|
2923 | + remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 ); |
|
2924 | + remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 ); |
|
2925 | + remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 ); |
|
2926 | 2926 | |
2927 | - remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 ); |
|
2928 | - } |
|
2927 | + remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 ); |
|
2928 | + } |
|
2929 | 2929 | } |
2930 | 2930 | |
2931 | 2931 | /** |
@@ -2939,20 +2939,20 @@ discard block |
||
2939 | 2939 | * |
2940 | 2940 | */ |
2941 | 2941 | function geodir_wpml_ajax_set_guest_lang() { |
2942 | - if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) { |
|
2943 | - if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) { |
|
2944 | - global $sitepress; |
|
2942 | + if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) { |
|
2943 | + if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) { |
|
2944 | + global $sitepress; |
|
2945 | 2945 | |
2946 | - $referer = wp_get_referer(); |
|
2946 | + $referer = wp_get_referer(); |
|
2947 | 2947 | |
2948 | - $current_lang = $sitepress->get_current_language(); |
|
2949 | - $referrer_lang = $sitepress->get_language_from_url( $referer ); |
|
2948 | + $current_lang = $sitepress->get_current_language(); |
|
2949 | + $referrer_lang = $sitepress->get_language_from_url( $referer ); |
|
2950 | 2950 | |
2951 | - if ( $referrer_lang && $current_lang != $referrer_lang ) { |
|
2952 | - $_GET['lang'] = $referrer_lang; |
|
2953 | - } |
|
2954 | - } |
|
2955 | - } |
|
2951 | + if ( $referrer_lang && $current_lang != $referrer_lang ) { |
|
2952 | + $_GET['lang'] = $referrer_lang; |
|
2953 | + } |
|
2954 | + } |
|
2955 | + } |
|
2956 | 2956 | } |
2957 | 2957 | add_action( 'plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1 ); |
2958 | 2958 | |
@@ -2964,36 +2964,36 @@ discard block |
||
2964 | 2964 | * @param object $wp The WordPress object. |
2965 | 2965 | */ |
2966 | 2966 | function geodir_check_redirect($wp) { |
2967 | - if (is_404() || (!empty($wp->query_vars['error']) && $wp->query_vars['error'] == '404')) { |
|
2968 | - $current_url = geodir_curPageURL(); |
|
2969 | - $search = 'czech-republic'; |
|
2970 | - $replace = 'czechia'; |
|
2967 | + if (is_404() || (!empty($wp->query_vars['error']) && $wp->query_vars['error'] == '404')) { |
|
2968 | + $current_url = geodir_curPageURL(); |
|
2969 | + $search = 'czech-republic'; |
|
2970 | + $replace = 'czechia'; |
|
2971 | 2971 | |
2972 | - $has_slash = substr($current_url, -1); |
|
2973 | - if ($has_slash != "/") { |
|
2974 | - $current_url .= '/'; |
|
2975 | - } |
|
2972 | + $has_slash = substr($current_url, -1); |
|
2973 | + if ($has_slash != "/") { |
|
2974 | + $current_url .= '/'; |
|
2975 | + } |
|
2976 | 2976 | |
2977 | - $redirect = false; |
|
2978 | - if (strpos($current_url, '/' . $search . '/') !== false) { |
|
2979 | - $redirect = true; |
|
2980 | - $current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1); |
|
2981 | - } |
|
2977 | + $redirect = false; |
|
2978 | + if (strpos($current_url, '/' . $search . '/') !== false) { |
|
2979 | + $redirect = true; |
|
2980 | + $current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1); |
|
2981 | + } |
|
2982 | 2982 | |
2983 | - if ($has_slash != "/") { |
|
2984 | - $current_url = trim($current_url, '/'); |
|
2985 | - } |
|
2983 | + if ($has_slash != "/") { |
|
2984 | + $current_url = trim($current_url, '/'); |
|
2985 | + } |
|
2986 | 2986 | |
2987 | - if (strpos($current_url, 'gd_country=' . $search) !== false) { |
|
2988 | - $redirect = true; |
|
2989 | - $current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url); |
|
2990 | - } |
|
2991 | - |
|
2992 | - if ($redirect) { |
|
2993 | - wp_redirect($current_url); |
|
2994 | - exit; |
|
2995 | - } |
|
2996 | - } |
|
2987 | + if (strpos($current_url, 'gd_country=' . $search) !== false) { |
|
2988 | + $redirect = true; |
|
2989 | + $current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url); |
|
2990 | + } |
|
2991 | + |
|
2992 | + if ($redirect) { |
|
2993 | + wp_redirect($current_url); |
|
2994 | + exit; |
|
2995 | + } |
|
2996 | + } |
|
2997 | 2997 | } |
2998 | 2998 | add_action('parse_request', 'geodir_check_redirect', 101, 1); |
2999 | 2999 | |
@@ -3013,50 +3013,50 @@ discard block |
||
3013 | 3013 | * @param string $original_slug The original post slug. |
3014 | 3014 | */ |
3015 | 3015 | function geodir_check_post_to_term_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) { |
3016 | - global $wpdb, $sitepress; |
|
3016 | + global $wpdb, $sitepress; |
|
3017 | 3017 | |
3018 | - if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) { |
|
3019 | - $wpml_post_join = ""; |
|
3020 | - $wpml_post_where = ""; |
|
3021 | - $wpml_term_join = ""; |
|
3022 | - $wpml_term_where = ""; |
|
3018 | + if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) { |
|
3019 | + $wpml_post_join = ""; |
|
3020 | + $wpml_post_where = ""; |
|
3021 | + $wpml_term_join = ""; |
|
3022 | + $wpml_term_where = ""; |
|
3023 | 3023 | |
3024 | - if (geodir_wpml_is_post_type_translated($post_type)) { |
|
3025 | - $post_language = $post_ID ? $sitepress->post_translations()->get_element_lang_code($post_ID) : $sitepress->get_current_language(); |
|
3026 | - $post_language = $post_language ? $post_language : $sitepress->post_translations()->get_save_post_lang($post_ID, $sitepress); |
|
3027 | - if (!$post_language) { |
|
3028 | - $post_language = $sitepress->get_current_language(); |
|
3029 | - } |
|
3024 | + if (geodir_wpml_is_post_type_translated($post_type)) { |
|
3025 | + $post_language = $post_ID ? $sitepress->post_translations()->get_element_lang_code($post_ID) : $sitepress->get_current_language(); |
|
3026 | + $post_language = $post_language ? $post_language : $sitepress->post_translations()->get_save_post_lang($post_ID, $sitepress); |
|
3027 | + if (!$post_language) { |
|
3028 | + $post_language = $sitepress->get_current_language(); |
|
3029 | + } |
|
3030 | 3030 | |
3031 | - $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)"; |
|
3032 | - $wpml_post_where = " AND icl_t.language_code = '" . $post_language ."'"; |
|
3031 | + $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)"; |
|
3032 | + $wpml_post_where = " AND icl_t.language_code = '" . $post_language ."'"; |
|
3033 | 3033 | |
3034 | - $wpml_term_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type = CONCAT('tax_', tt.taxonomy)"; |
|
3035 | - $wpml_term_where = " AND icl_t.language_code = '" . $post_language ."'"; |
|
3036 | - } |
|
3034 | + $wpml_term_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type = CONCAT('tax_', tt.taxonomy)"; |
|
3035 | + $wpml_term_where = " AND icl_t.language_code = '" . $post_language ."'"; |
|
3036 | + } |
|
3037 | 3037 | |
3038 | - $term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $slug ) ); |
|
3038 | + $term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $slug ) ); |
|
3039 | 3039 | |
3040 | - if ( $term_slug_check ) { |
|
3041 | - $suffix = 1; |
|
3040 | + if ( $term_slug_check ) { |
|
3041 | + $suffix = 1; |
|
3042 | 3042 | |
3043 | - do { |
|
3044 | - $alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; |
|
3043 | + do { |
|
3044 | + $alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; |
|
3045 | 3045 | |
3046 | - $term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug ) ); |
|
3046 | + $term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug ) ); |
|
3047 | 3047 | |
3048 | - $post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID ) ); |
|
3048 | + $post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID ) ); |
|
3049 | 3049 | |
3050 | - $term_slug_check = $term_check || $post_check; |
|
3050 | + $term_slug_check = $term_check || $post_check; |
|
3051 | 3051 | |
3052 | - $suffix++; |
|
3053 | - } while ( $term_slug_check ); |
|
3052 | + $suffix++; |
|
3053 | + } while ( $term_slug_check ); |
|
3054 | 3054 | |
3055 | - $slug = $alt_slug; |
|
3056 | - } |
|
3057 | - } |
|
3055 | + $slug = $alt_slug; |
|
3056 | + } |
|
3057 | + } |
|
3058 | 3058 | |
3059 | - return $slug; |
|
3059 | + return $slug; |
|
3060 | 3060 | } |
3061 | 3061 | add_filter( 'wp_unique_post_slug', 'geodir_check_post_to_term_slug', 101, 6 ); |
3062 | 3062 | |
@@ -3076,48 +3076,48 @@ discard block |
||
3076 | 3076 | * @return bool true when exists. false when not exists. |
3077 | 3077 | */ |
3078 | 3078 | function geodir_check_term_to_post_slug( $slug_exists, $slug, $term_id ) { |
3079 | - global $wpdb, $gd_term_post_type, $gd_term_taxonomy, $sitepress; |
|
3079 | + global $wpdb, $gd_term_post_type, $gd_term_taxonomy, $sitepress; |
|
3080 | 3080 | |
3081 | - if ( $slug_exists ) { |
|
3082 | - return $slug_exists; |
|
3083 | - } |
|
3081 | + if ( $slug_exists ) { |
|
3082 | + return $slug_exists; |
|
3083 | + } |
|
3084 | 3084 | |
3085 | - if ( !empty( $gd_term_taxonomy ) && isset($gd_term_taxonomy[$term_id]) ) { |
|
3086 | - $taxonomy = $gd_term_taxonomy[$term_id]; |
|
3087 | - } else { |
|
3088 | - $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) ); |
|
3089 | - $gd_term_taxonomy[$term_id] = $taxonomy; |
|
3090 | - } |
|
3085 | + if ( !empty( $gd_term_taxonomy ) && isset($gd_term_taxonomy[$term_id]) ) { |
|
3086 | + $taxonomy = $gd_term_taxonomy[$term_id]; |
|
3087 | + } else { |
|
3088 | + $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) ); |
|
3089 | + $gd_term_taxonomy[$term_id] = $taxonomy; |
|
3090 | + } |
|
3091 | 3091 | |
3092 | - if ( empty($taxonomy) ) { |
|
3093 | - return $slug_exists; |
|
3094 | - } |
|
3092 | + if ( empty($taxonomy) ) { |
|
3093 | + return $slug_exists; |
|
3094 | + } |
|
3095 | 3095 | |
3096 | - if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) { |
|
3097 | - $post_type = $gd_term_post_type[$term_id]; |
|
3098 | - } else { |
|
3099 | - $taxonomy_obj = get_taxonomy( $taxonomy ); |
|
3100 | - $post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL; |
|
3101 | - } |
|
3096 | + if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) { |
|
3097 | + $post_type = $gd_term_post_type[$term_id]; |
|
3098 | + } else { |
|
3099 | + $taxonomy_obj = get_taxonomy( $taxonomy ); |
|
3100 | + $post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL; |
|
3101 | + } |
|
3102 | 3102 | |
3103 | - $wpml_post_join = ""; |
|
3104 | - $wpml_post_where = ""; |
|
3103 | + $wpml_post_join = ""; |
|
3104 | + $wpml_post_where = ""; |
|
3105 | 3105 | |
3106 | - if (geodir_wpml_is_taxonomy_translated($taxonomy) || geodir_wpml_is_post_type_translated($post_type)) { |
|
3107 | - $term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_' . $taxonomy) : $sitepress->get_current_language(); |
|
3108 | - if (!$term_language) { |
|
3109 | - $term_language = $sitepress->get_current_language(); |
|
3110 | - } |
|
3106 | + if (geodir_wpml_is_taxonomy_translated($taxonomy) || geodir_wpml_is_post_type_translated($post_type)) { |
|
3107 | + $term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_' . $taxonomy) : $sitepress->get_current_language(); |
|
3108 | + if (!$term_language) { |
|
3109 | + $term_language = $sitepress->get_current_language(); |
|
3110 | + } |
|
3111 | 3111 | |
3112 | - $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)"; |
|
3113 | - $wpml_post_where = " AND icl_t.language_code = '" . $term_language ."'"; |
|
3114 | - } |
|
3112 | + $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)"; |
|
3113 | + $wpml_post_where = " AND icl_t.language_code = '" . $term_language ."'"; |
|
3114 | + } |
|
3115 | 3115 | |
3116 | - if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s {$wpml_post_where} LIMIT 1", $slug, $post_type ) ) ) { |
|
3117 | - $slug_exists = true; |
|
3118 | - } |
|
3116 | + if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s {$wpml_post_where} LIMIT 1", $slug, $post_type ) ) ) { |
|
3117 | + $slug_exists = true; |
|
3118 | + } |
|
3119 | 3119 | |
3120 | - return $slug_exists; |
|
3120 | + return $slug_exists; |
|
3121 | 3121 | } |
3122 | 3122 | add_filter( 'geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3 ); |
3123 | 3123 |