@@ -44,57 +44,57 @@ discard block |
||
44 | 44 | |
45 | 45 | <?php if (have_posts()) : |
46 | 46 | |
47 | - /** |
|
48 | - * Called inside the `ul` of the listings template, but before any `li` elements. |
|
49 | - * |
|
50 | - * When used by the widget view template then it will only show if there are listings to be shown. |
|
51 | - * |
|
52 | - * @since 1.0.0 |
|
53 | - * @see 'geodir_after_listing_post_listview' |
|
54 | - */ |
|
55 | - do_action('geodir_before_listing_post_listview'); |
|
56 | - |
|
57 | - while (have_posts()) : the_post(); |
|
58 | - global $post, $wpdb, $preview; |
|
59 | - |
|
60 | - /** |
|
61 | - * Add a class to the `li` element of the listings list template. |
|
62 | - * |
|
63 | - * @since 1.0.0 |
|
64 | - * @param string $class The extra class for the `li` element, default empty. |
|
65 | - */ |
|
66 | - $post_view_class = apply_filters('geodir_post_view_extra_class', ''); |
|
67 | - |
|
68 | - /** |
|
69 | - * Add a class to the `article` tag inside the `li` element on the listings list template. |
|
70 | - * |
|
71 | - * @since 1.0.0 |
|
72 | - * @param string $class The extra class for the `article` element, default empty. |
|
73 | - */ |
|
74 | - $post_view_article_class = apply_filters('geodir_post_view_article_extra_class', ''); |
|
75 | - ?> |
|
47 | + /** |
|
48 | + * Called inside the `ul` of the listings template, but before any `li` elements. |
|
49 | + * |
|
50 | + * When used by the widget view template then it will only show if there are listings to be shown. |
|
51 | + * |
|
52 | + * @since 1.0.0 |
|
53 | + * @see 'geodir_after_listing_post_listview' |
|
54 | + */ |
|
55 | + do_action('geodir_before_listing_post_listview'); |
|
56 | + |
|
57 | + while (have_posts()) : the_post(); |
|
58 | + global $post, $wpdb, $preview; |
|
59 | + |
|
60 | + /** |
|
61 | + * Add a class to the `li` element of the listings list template. |
|
62 | + * |
|
63 | + * @since 1.0.0 |
|
64 | + * @param string $class The extra class for the `li` element, default empty. |
|
65 | + */ |
|
66 | + $post_view_class = apply_filters('geodir_post_view_extra_class', ''); |
|
67 | + |
|
68 | + /** |
|
69 | + * Add a class to the `article` tag inside the `li` element on the listings list template. |
|
70 | + * |
|
71 | + * @since 1.0.0 |
|
72 | + * @param string $class The extra class for the `article` element, default empty. |
|
73 | + */ |
|
74 | + $post_view_article_class = apply_filters('geodir_post_view_article_extra_class', ''); |
|
75 | + ?> |
|
76 | 76 | |
77 | 77 | <li class="clearfix <?php if ($grid_view_class) { |
78 | - echo 'geodir-gridview ' . $grid_view_class; |
|
79 | - } else { |
|
80 | - echo ' geodir-listview '; |
|
81 | - } ?> <?php if ($post_view_class) { |
|
82 | - echo $post_view_class; |
|
83 | - } ?>" <?php if (isset($listing_width) && $listing_width) echo "style='width:{$listing_width}%;'"; // Width for widget listing |
|
84 | - |
|
85 | - echo " data-post-id='$post->ID' "; |
|
86 | - /** |
|
87 | - * Called inside the `<li>` tag for listing outputs. |
|
88 | - * |
|
89 | - * @since 1.5.9 |
|
90 | - * @param object $post The post object. |
|
91 | - * @param string $string If called on the listing or widget template. |
|
92 | - */ |
|
93 | - do_action('geodir_listview_inside_li', $post, 'listing'); |
|
94 | - ?> > |
|
78 | + echo 'geodir-gridview ' . $grid_view_class; |
|
79 | + } else { |
|
80 | + echo ' geodir-listview '; |
|
81 | + } ?> <?php if ($post_view_class) { |
|
82 | + echo $post_view_class; |
|
83 | + } ?>" <?php if (isset($listing_width) && $listing_width) echo "style='width:{$listing_width}%;'"; // Width for widget listing |
|
84 | + |
|
85 | + echo " data-post-id='$post->ID' "; |
|
86 | + /** |
|
87 | + * Called inside the `<li>` tag for listing outputs. |
|
88 | + * |
|
89 | + * @since 1.5.9 |
|
90 | + * @param object $post The post object. |
|
91 | + * @param string $string If called on the listing or widget template. |
|
92 | + */ |
|
93 | + do_action('geodir_listview_inside_li', $post, 'listing'); |
|
94 | + ?> > |
|
95 | 95 | <article class="geodir-category-listing <?php if ($post_view_article_class) { |
96 | - echo $post_view_article_class; |
|
97 | - } ?>"> |
|
96 | + echo $post_view_article_class; |
|
97 | + } ?>"> |
|
98 | 98 | <div class="geodir-post-img <?php echo apply_filters('geodir_listing_listview_thumb_extra_class', '', 'listing'); ?>"> |
99 | 99 | <?php if ($fimage = geodir_show_featured_image($post->ID, 'list-thumb', true, false, $post->featured_image)) { ?> |
100 | 100 | |
@@ -102,37 +102,37 @@ discard block |
||
102 | 102 | <?php echo $fimage; ?> |
103 | 103 | </a> |
104 | 104 | <?php |
105 | - /** |
|
106 | - * Called before badges are output. |
|
107 | - * |
|
108 | - * Called on the listings template after the image has been output and before the badges like `new` or `featured` are output. |
|
109 | - * |
|
110 | - * @since 1.0.0 |
|
111 | - * @param object $post The post object. |
|
112 | - * @see 'geodir_after_badge_on_image' |
|
113 | - */ |
|
114 | - do_action('geodir_before_badge_on_image', $post); |
|
115 | - if (isset($post->is_featured) && $post->is_featured) { |
|
116 | - echo geodir_show_badges_on_image('featured', $post, get_permalink()); |
|
117 | - } |
|
118 | - |
|
119 | - $geodir_days_new = (int)get_option('geodir_listing_new_days'); |
|
120 | - |
|
121 | - if (round(abs(strtotime($post->post_date) - strtotime(date('Y-m-d'))) / 86400) < $geodir_days_new) { |
|
122 | - echo geodir_show_badges_on_image('new', $post, get_permalink()); |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Called after badges are output. |
|
127 | - * |
|
128 | - * Called on the listings template after the image and badges like `new` or `featured` have been output. |
|
129 | - * |
|
130 | - * @since 1.0.0 |
|
131 | - * @param object $post The post object. |
|
132 | - * @see 'geodir_before_badge_on_image' |
|
133 | - */ |
|
134 | - do_action('geodir_after_badge_on_image', $post); |
|
135 | - ?> |
|
105 | + /** |
|
106 | + * Called before badges are output. |
|
107 | + * |
|
108 | + * Called on the listings template after the image has been output and before the badges like `new` or `featured` are output. |
|
109 | + * |
|
110 | + * @since 1.0.0 |
|
111 | + * @param object $post The post object. |
|
112 | + * @see 'geodir_after_badge_on_image' |
|
113 | + */ |
|
114 | + do_action('geodir_before_badge_on_image', $post); |
|
115 | + if (isset($post->is_featured) && $post->is_featured) { |
|
116 | + echo geodir_show_badges_on_image('featured', $post, get_permalink()); |
|
117 | + } |
|
118 | + |
|
119 | + $geodir_days_new = (int)get_option('geodir_listing_new_days'); |
|
120 | + |
|
121 | + if (round(abs(strtotime($post->post_date) - strtotime(date('Y-m-d'))) / 86400) < $geodir_days_new) { |
|
122 | + echo geodir_show_badges_on_image('new', $post, get_permalink()); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Called after badges are output. |
|
127 | + * |
|
128 | + * Called on the listings template after the image and badges like `new` or `featured` have been output. |
|
129 | + * |
|
130 | + * @since 1.0.0 |
|
131 | + * @param object $post The post object. |
|
132 | + * @see 'geodir_before_badge_on_image' |
|
133 | + */ |
|
134 | + do_action('geodir_after_badge_on_image', $post); |
|
135 | + ?> |
|
136 | 136 | |
137 | 137 | |
138 | 138 | <?php } ?> |
@@ -142,15 +142,15 @@ discard block |
||
142 | 142 | <div class="geodir-content <?php echo apply_filters('geodir_listing_listview_content_extra_class', '', 'listing'); ?>"> |
143 | 143 | |
144 | 144 | <?php |
145 | - /** |
|
146 | - * Called before the post title on the listings view template. |
|
147 | - * |
|
148 | - * @since 1.0.0 |
|
149 | - * @param string $type The template type, default 'listview'. |
|
150 | - * @param object $post The post object. |
|
151 | - * @see 'geodir_after_listing_post_title' |
|
152 | - */ |
|
153 | - do_action('geodir_before_listing_post_title', 'listview', $post); ?> |
|
145 | + /** |
|
146 | + * Called before the post title on the listings view template. |
|
147 | + * |
|
148 | + * @since 1.0.0 |
|
149 | + * @param string $type The template type, default 'listview'. |
|
150 | + * @param object $post The post object. |
|
151 | + * @see 'geodir_after_listing_post_title' |
|
152 | + */ |
|
153 | + do_action('geodir_before_listing_post_title', 'listview', $post); ?> |
|
154 | 154 | |
155 | 155 | <header class="geodir-entry-header"><h2 class="geodir-entry-title"> |
156 | 156 | <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> |
@@ -162,225 +162,225 @@ discard block |
||
162 | 162 | <!-- .entry-header --> |
163 | 163 | |
164 | 164 | <?php |
165 | - /** |
|
166 | - * Called after the post title on the listings view template. |
|
167 | - * |
|
168 | - * @since 1.0.0 |
|
169 | - * @param string $type The template type, default 'listview'. |
|
170 | - * @param object $post The post object. |
|
171 | - * @see 'geodir_before_listing_post_title' |
|
172 | - */ |
|
173 | - do_action('geodir_after_listing_post_title', 'listview', $post); ?> |
|
165 | + /** |
|
166 | + * Called after the post title on the listings view template. |
|
167 | + * |
|
168 | + * @since 1.0.0 |
|
169 | + * @param string $type The template type, default 'listview'. |
|
170 | + * @param object $post The post object. |
|
171 | + * @see 'geodir_before_listing_post_title' |
|
172 | + */ |
|
173 | + do_action('geodir_after_listing_post_title', 'listview', $post); ?> |
|
174 | 174 | |
175 | 175 | <?php /// Print Distance |
176 | - if ( ( isset( $_REQUEST['sgeo_lat'] ) && $_REQUEST['sgeo_lat'] != '' ) || ( $related_nearest && $related_parent_lat ) ) { |
|
177 | - if ( $related_nearest && $related_parent_lat ) { |
|
178 | - $startPoint = array('latitude' => $related_parent_lat, 'longitude' => $related_parent_lon); |
|
179 | - } else { |
|
180 | - $startPoint = array('latitude' => $_REQUEST['sgeo_lat'], 'longitude' => $_REQUEST['sgeo_lon']); |
|
181 | - } |
|
182 | - |
|
183 | - $endLat = $post->post_latitude; |
|
184 | - $endLon = $post->post_longitude; |
|
185 | - $endPoint = array('latitude' => $endLat, 'longitude' => $endLon); |
|
186 | - $uom = get_option('geodir_search_dist_1'); |
|
187 | - $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); ?> |
|
176 | + if ( ( isset( $_REQUEST['sgeo_lat'] ) && $_REQUEST['sgeo_lat'] != '' ) || ( $related_nearest && $related_parent_lat ) ) { |
|
177 | + if ( $related_nearest && $related_parent_lat ) { |
|
178 | + $startPoint = array('latitude' => $related_parent_lat, 'longitude' => $related_parent_lon); |
|
179 | + } else { |
|
180 | + $startPoint = array('latitude' => $_REQUEST['sgeo_lat'], 'longitude' => $_REQUEST['sgeo_lon']); |
|
181 | + } |
|
182 | + |
|
183 | + $endLat = $post->post_latitude; |
|
184 | + $endLon = $post->post_longitude; |
|
185 | + $endPoint = array('latitude' => $endLat, 'longitude' => $endLon); |
|
186 | + $uom = get_option('geodir_search_dist_1'); |
|
187 | + $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); ?> |
|
188 | 188 | <h3> |
189 | 189 | <?php |
190 | 190 | |
191 | - if (round($distance, 2) == 0) { |
|
192 | - $uom = get_option('geodir_search_dist_2'); |
|
193 | - |
|
194 | - $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); |
|
195 | - if ($uom == 'feet') { |
|
196 | - $uom = __('feet', 'geodirectory'); |
|
197 | - } else { |
|
198 | - $uom = __('meters', 'geodirectory'); |
|
199 | - } |
|
200 | - echo round($distance) . ' ' . $uom . '<br />'; |
|
201 | - } else { |
|
202 | - if ($uom == 'miles') { |
|
203 | - $uom = __('miles', 'geodirectory'); |
|
204 | - } else { |
|
205 | - $uom = __('km', 'geodirectory'); |
|
206 | - } |
|
207 | - echo round($distance, 2) . ' ' . $uom . '<br />'; |
|
208 | - } |
|
209 | - ?> |
|
191 | + if (round($distance, 2) == 0) { |
|
192 | + $uom = get_option('geodir_search_dist_2'); |
|
193 | + |
|
194 | + $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); |
|
195 | + if ($uom == 'feet') { |
|
196 | + $uom = __('feet', 'geodirectory'); |
|
197 | + } else { |
|
198 | + $uom = __('meters', 'geodirectory'); |
|
199 | + } |
|
200 | + echo round($distance) . ' ' . $uom . '<br />'; |
|
201 | + } else { |
|
202 | + if ($uom == 'miles') { |
|
203 | + $uom = __('miles', 'geodirectory'); |
|
204 | + } else { |
|
205 | + $uom = __('km', 'geodirectory'); |
|
206 | + } |
|
207 | + echo round($distance, 2) . ' ' . $uom . '<br />'; |
|
208 | + } |
|
209 | + ?> |
|
210 | 210 | </h3> |
211 | 211 | <?php } ?> |
212 | 212 | |
213 | 213 | |
214 | 214 | <?php |
215 | - /** |
|
216 | - * Called before the post excerpt on the listings view template. |
|
217 | - * |
|
218 | - * @since 1.0.0 |
|
219 | - * @param object $post The post object. |
|
220 | - * @see 'geodir_after_listing_post_excerpt' |
|
221 | - */ |
|
222 | - do_action('geodir_before_listing_post_excerpt', $post); ?> |
|
215 | + /** |
|
216 | + * Called before the post excerpt on the listings view template. |
|
217 | + * |
|
218 | + * @since 1.0.0 |
|
219 | + * @param object $post The post object. |
|
220 | + * @see 'geodir_after_listing_post_excerpt' |
|
221 | + */ |
|
222 | + do_action('geodir_before_listing_post_excerpt', $post); ?> |
|
223 | 223 | <?php echo geodir_show_listing_info('listing'); ?> |
224 | 224 | <div class="geodir-entry-content"> |
225 | 225 | |
226 | 226 | <?php |
227 | - /** |
|
228 | - * Filter to hide the listing excerpt |
|
229 | - * |
|
230 | - * @since 1.5.3 |
|
231 | - * @param bool $display Display the excerpt or not. Default true. |
|
232 | - * @param string $view The view type, default 'listview'. |
|
233 | - * @param object $post The post object. |
|
234 | - */ |
|
235 | - $show_listing_excerpt = apply_filters('geodir_show_listing_post_excerpt', true, 'listview', $post); |
|
236 | - if ($show_listing_excerpt) { |
|
237 | - if ( isset( $character_count ) && ( $character_count || $character_count == '0' ) ) { |
|
238 | - $content_out = geodir_max_excerpt( $character_count ); |
|
239 | - } else { |
|
240 | - $content_out = get_the_excerpt(); |
|
241 | - } |
|
242 | - if ( ! empty( $content_out ) ) { |
|
243 | - echo "<p>" . $content_out . "</p>"; |
|
244 | - } |
|
245 | - } |
|
246 | - ?></div> |
|
227 | + /** |
|
228 | + * Filter to hide the listing excerpt |
|
229 | + * |
|
230 | + * @since 1.5.3 |
|
231 | + * @param bool $display Display the excerpt or not. Default true. |
|
232 | + * @param string $view The view type, default 'listview'. |
|
233 | + * @param object $post The post object. |
|
234 | + */ |
|
235 | + $show_listing_excerpt = apply_filters('geodir_show_listing_post_excerpt', true, 'listview', $post); |
|
236 | + if ($show_listing_excerpt) { |
|
237 | + if ( isset( $character_count ) && ( $character_count || $character_count == '0' ) ) { |
|
238 | + $content_out = geodir_max_excerpt( $character_count ); |
|
239 | + } else { |
|
240 | + $content_out = get_the_excerpt(); |
|
241 | + } |
|
242 | + if ( ! empty( $content_out ) ) { |
|
243 | + echo "<p>" . $content_out . "</p>"; |
|
244 | + } |
|
245 | + } |
|
246 | + ?></div> |
|
247 | 247 | |
248 | 248 | <?php |
249 | - /** |
|
250 | - * Called after the post excerpt on the listings view template. |
|
251 | - * |
|
252 | - * @since 1.0.0 |
|
253 | - * @param object $post The post object. |
|
254 | - * @see 'geodir_before_listing_post_excerpt' |
|
255 | - */ |
|
256 | - do_action('geodir_after_listing_post_excerpt', $post); ?> |
|
249 | + /** |
|
250 | + * Called after the post excerpt on the listings view template. |
|
251 | + * |
|
252 | + * @since 1.0.0 |
|
253 | + * @param object $post The post object. |
|
254 | + * @see 'geodir_before_listing_post_excerpt' |
|
255 | + */ |
|
256 | + do_action('geodir_after_listing_post_excerpt', $post); ?> |
|
257 | 257 | </div> |
258 | 258 | <!-- gd-content ends here--> |
259 | 259 | <?php |
260 | - /** |
|
261 | - * Called after printing listing content. |
|
262 | - * |
|
263 | - * @since 1.5.3 |
|
264 | - * @param object $post The post object. |
|
265 | - * @param string $view The view type, default 'listing'. |
|
266 | - */ |
|
267 | - do_action( 'geodir_after_listing_content', $post, 'listing' ); ?> |
|
260 | + /** |
|
261 | + * Called after printing listing content. |
|
262 | + * |
|
263 | + * @since 1.5.3 |
|
264 | + * @param object $post The post object. |
|
265 | + * @param string $view The view type, default 'listing'. |
|
266 | + */ |
|
267 | + do_action( 'geodir_after_listing_content', $post, 'listing' ); ?> |
|
268 | 268 | <footer class="geodir-entry-meta <?php echo apply_filters('geodir_listing_listview_meta_extra_class', '', 'listing'); ?>"> |
269 | 269 | <div class="geodir-addinfo clearfix <?php echo apply_filters('geodir_listing_listview_addinfo_extra_class', '', 'listing'); ?>"> |
270 | 270 | |
271 | 271 | <?php |
272 | - /** |
|
273 | - * Called before printing review stars html. |
|
274 | - * |
|
275 | - * @since 1.5.3 |
|
276 | - * @param object $post The post object. |
|
277 | - * @param string $view The view type, default 'listing'. |
|
278 | - */ |
|
279 | - do_action( 'geodir_before_review_html', $post, 'listing' ); |
|
280 | - |
|
281 | - $review_show = geodir_is_reviews_show('listview'); |
|
282 | - |
|
283 | - if ($review_show) { |
|
284 | - |
|
285 | - if (!$preview) { |
|
286 | - $post_avgratings = geodir_get_post_rating($post->ID); |
|
287 | - /** |
|
288 | - * Called before the rating stars are output on the listings view template. |
|
289 | - * |
|
290 | - * @since 1.0.0 |
|
291 | - * @param float $post_avgratings The average rating for the post. |
|
292 | - * @param int $post->ID The post ID. |
|
293 | - * @see 'geodir_after_review_rating_stars_on_listview' |
|
294 | - */ |
|
295 | - do_action('geodir_before_review_rating_stars_on_listview', $post_avgratings, $post->ID); |
|
296 | - |
|
297 | - echo geodir_get_rating_stars($post_avgratings, $post->ID); |
|
298 | - |
|
299 | - /** |
|
300 | - * Called after the rating stars are output on the listings view template. |
|
301 | - * |
|
302 | - * @since 1.0.0 |
|
303 | - * @param float $post_avgratings The average rating for the post. |
|
304 | - * @param int $post->ID The post ID. |
|
305 | - * @see 'geodir_before_review_rating_stars_on_listview' |
|
306 | - */ |
|
307 | - do_action('geodir_after_review_rating_stars_on_listview', $post_avgratings, $post->ID); |
|
308 | - } |
|
309 | - ?> |
|
272 | + /** |
|
273 | + * Called before printing review stars html. |
|
274 | + * |
|
275 | + * @since 1.5.3 |
|
276 | + * @param object $post The post object. |
|
277 | + * @param string $view The view type, default 'listing'. |
|
278 | + */ |
|
279 | + do_action( 'geodir_before_review_html', $post, 'listing' ); |
|
280 | + |
|
281 | + $review_show = geodir_is_reviews_show('listview'); |
|
282 | + |
|
283 | + if ($review_show) { |
|
284 | + |
|
285 | + if (!$preview) { |
|
286 | + $post_avgratings = geodir_get_post_rating($post->ID); |
|
287 | + /** |
|
288 | + * Called before the rating stars are output on the listings view template. |
|
289 | + * |
|
290 | + * @since 1.0.0 |
|
291 | + * @param float $post_avgratings The average rating for the post. |
|
292 | + * @param int $post->ID The post ID. |
|
293 | + * @see 'geodir_after_review_rating_stars_on_listview' |
|
294 | + */ |
|
295 | + do_action('geodir_before_review_rating_stars_on_listview', $post_avgratings, $post->ID); |
|
296 | + |
|
297 | + echo geodir_get_rating_stars($post_avgratings, $post->ID); |
|
298 | + |
|
299 | + /** |
|
300 | + * Called after the rating stars are output on the listings view template. |
|
301 | + * |
|
302 | + * @since 1.0.0 |
|
303 | + * @param float $post_avgratings The average rating for the post. |
|
304 | + * @param int $post->ID The post ID. |
|
305 | + * @see 'geodir_before_review_rating_stars_on_listview' |
|
306 | + */ |
|
307 | + do_action('geodir_after_review_rating_stars_on_listview', $post_avgratings, $post->ID); |
|
308 | + } |
|
309 | + ?> |
|
310 | 310 | <a href="<?php comments_link(); ?>" class="geodir-pcomments"><i |
311 | 311 | class="fa fa-comments"></i> |
312 | 312 | <?php geodir_comments_number($post->rating_count); ?></a> |
313 | 313 | <?php |
314 | - } |
|
314 | + } |
|
315 | 315 | |
316 | 316 | |
317 | - /** |
|
318 | - * Called after printing favorite html. |
|
319 | - * |
|
320 | - * @since 1.0.0 |
|
321 | - */ |
|
322 | - do_action( 'geodir_after_favorite_html', $post->ID, 'listing' ); |
|
317 | + /** |
|
318 | + * Called after printing favorite html. |
|
319 | + * |
|
320 | + * @since 1.0.0 |
|
321 | + */ |
|
322 | + do_action( 'geodir_after_favorite_html', $post->ID, 'listing' ); |
|
323 | 323 | |
324 | 324 | |
325 | - /** |
|
326 | - * Called after printing map pin point. |
|
327 | - * |
|
328 | - * @since 1.0.0 |
|
329 | - * @since 1.5.9 Added $post as second param. |
|
330 | - * @param int $post->ID The post id. |
|
331 | - * @param object $post The post object. |
|
332 | - */ |
|
333 | - do_action( 'geodir_listing_after_pinpoint', $post->ID ,$post); |
|
325 | + /** |
|
326 | + * Called after printing map pin point. |
|
327 | + * |
|
328 | + * @since 1.0.0 |
|
329 | + * @since 1.5.9 Added $post as second param. |
|
330 | + * @param int $post->ID The post id. |
|
331 | + * @param object $post The post object. |
|
332 | + */ |
|
333 | + do_action( 'geodir_listing_after_pinpoint', $post->ID ,$post); |
|
334 | 334 | |
335 | - if ($post->post_author == get_current_user_id()) { ?> |
|
335 | + if ($post->post_author == get_current_user_id()) { ?> |
|
336 | 336 | <?php |
337 | - $addplacelink = get_permalink(geodir_add_listing_page_id()); |
|
338 | - $editlink = geodir_getlink($addplacelink, array('pid' => $post->ID), false); |
|
339 | - $upgradelink = geodir_getlink($editlink, array('upgrade' => '1'), false); |
|
337 | + $addplacelink = get_permalink(geodir_add_listing_page_id()); |
|
338 | + $editlink = geodir_getlink($addplacelink, array('pid' => $post->ID), false); |
|
339 | + $upgradelink = geodir_getlink($editlink, array('upgrade' => '1'), false); |
|
340 | 340 | |
341 | - $ajaxlink = geodir_get_ajax_url(); |
|
342 | - $deletelink = geodir_getlink($ajaxlink, array('geodir_ajax' => 'add_listing', 'ajax_action' => 'delete', 'pid' => $post->ID), false); |
|
341 | + $ajaxlink = geodir_get_ajax_url(); |
|
342 | + $deletelink = geodir_getlink($ajaxlink, array('geodir_ajax' => 'add_listing', 'ajax_action' => 'delete', 'pid' => $post->ID), false); |
|
343 | 343 | |
344 | - ?> |
|
344 | + ?> |
|
345 | 345 | |
346 | 346 | <span class="geodir-authorlink clearfix"> |
347 | 347 | |
348 | 348 | <?php if (isset($_REQUEST['geodir_dashbord']) && $_REQUEST['geodir_dashbord']) { |
349 | - /** |
|
350 | - * Called before the edit post link on the listings view template used on the author page. |
|
351 | - * |
|
352 | - * @since 1.0.0 |
|
353 | - * @see 'geodir_after_edit_post_link_on_listing' |
|
354 | - */ |
|
355 | - do_action('geodir_before_edit_post_link_on_listing'); |
|
356 | - ?> |
|
349 | + /** |
|
350 | + * Called before the edit post link on the listings view template used on the author page. |
|
351 | + * |
|
352 | + * @since 1.0.0 |
|
353 | + * @see 'geodir_after_edit_post_link_on_listing' |
|
354 | + */ |
|
355 | + do_action('geodir_before_edit_post_link_on_listing'); |
|
356 | + ?> |
|
357 | 357 | |
358 | 358 | <a href="<?php echo esc_url($editlink); ?>" class="geodir-edit" |
359 | 359 | title="<?php _e('Edit Listing', 'geodirectory'); ?>"> |
360 | 360 | <?php |
361 | - $geodir_listing_edit_icon = apply_filters('geodir_listing_edit_icon', 'fa fa-edit'); |
|
362 | - echo '<i class="'. $geodir_listing_edit_icon .'"></i>'; |
|
363 | - ?> |
|
361 | + $geodir_listing_edit_icon = apply_filters('geodir_listing_edit_icon', 'fa fa-edit'); |
|
362 | + echo '<i class="'. $geodir_listing_edit_icon .'"></i>'; |
|
363 | + ?> |
|
364 | 364 | <?php _e('Edit', 'geodirectory'); ?> |
365 | 365 | </a> |
366 | 366 | <a href="<?php echo esc_url($deletelink); ?>" class="geodir-delete" |
367 | 367 | title="<?php _e('Delete Listing', 'geodirectory'); ?>"> |
368 | 368 | <?php |
369 | - $geodir_listing_delete_icon = apply_filters('geodir_listing_delete_icon', 'fa fa-close'); |
|
370 | - echo '<i class="'. $geodir_listing_delete_icon .'"></i>'; |
|
371 | - ?> |
|
369 | + $geodir_listing_delete_icon = apply_filters('geodir_listing_delete_icon', 'fa fa-close'); |
|
370 | + echo '<i class="'. $geodir_listing_delete_icon .'"></i>'; |
|
371 | + ?> |
|
372 | 372 | <?php _e('Delete', 'geodirectory'); ?> |
373 | 373 | </a> |
374 | 374 | <?php |
375 | 375 | |
376 | - /** |
|
377 | - * Called after the edit post link on the listings view template used on the author page. |
|
378 | - * |
|
379 | - * @since 1.0.0 |
|
380 | - * @see 'geodir_before_edit_post_link_on_listing' |
|
381 | - */ |
|
382 | - do_action('geodir_after_edit_post_link_on_listing'); |
|
383 | - } ?> |
|
376 | + /** |
|
377 | + * Called after the edit post link on the listings view template used on the author page. |
|
378 | + * |
|
379 | + * @since 1.0.0 |
|
380 | + * @see 'geodir_before_edit_post_link_on_listing' |
|
381 | + */ |
|
382 | + do_action('geodir_after_edit_post_link_on_listing'); |
|
383 | + } ?> |
|
384 | 384 | </span> |
385 | 385 | |
386 | 386 | <?php } ?> |
@@ -393,32 +393,32 @@ discard block |
||
393 | 393 | </li> |
394 | 394 | |
395 | 395 | <?php |
396 | - endwhile; |
|
397 | - |
|
398 | - /** |
|
399 | - * Called inside the `ul` of the listings template, but after all `li` elements. |
|
400 | - * |
|
401 | - * When used by the widget view template then it will only show if there are listings to be shown. |
|
402 | - * |
|
403 | - * @since 1.0.0 |
|
404 | - * @see 'geodir_before_listing_post_listview' |
|
405 | - */ |
|
406 | - do_action('geodir_after_listing_post_listview'); |
|
407 | - |
|
408 | - else: |
|
396 | + endwhile; |
|
397 | + |
|
398 | + /** |
|
399 | + * Called inside the `ul` of the listings template, but after all `li` elements. |
|
400 | + * |
|
401 | + * When used by the widget view template then it will only show if there are listings to be shown. |
|
402 | + * |
|
403 | + * @since 1.0.0 |
|
404 | + * @see 'geodir_before_listing_post_listview' |
|
405 | + */ |
|
406 | + do_action('geodir_after_listing_post_listview'); |
|
407 | + |
|
408 | + else: |
|
409 | 409 | $favorite = isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' ? true : false; |
410 | 410 | |
411 | 411 | /** |
412 | - * Called inside the `ul` of the listings template, when no listing found. |
|
413 | - * |
|
414 | - * @since 1.5.5 |
|
412 | + * Called inside the `ul` of the listings template, when no listing found. |
|
413 | + * |
|
414 | + * @since 1.5.5 |
|
415 | 415 | * @param string 'listing-listview' Listing listview template. |
416 | 416 | * @param bool $favorite Are favorite listings results? |
417 | - */ |
|
418 | - do_action('geodir_message_not_found_on_listing', 'listing-listview', $favorite); |
|
419 | - endif; |
|
417 | + */ |
|
418 | + do_action('geodir_message_not_found_on_listing', 'listing-listview', $favorite); |
|
419 | + endif; |
|
420 | 420 | |
421 | - ?> |
|
421 | + ?> |
|
422 | 422 | </ul> <!-- geodir_category_list_view ends here--> |
423 | 423 | |
424 | 424 | <div class="clear"></div> |
@@ -20,72 +20,72 @@ discard block |
||
20 | 20 | /** This action is documented in geodirectory-templates/listing-listview.php */ |
21 | 21 | $grid_view_class = apply_filters('geodir_grid_view_widget_columns', $gridview_columns_widget); |
22 | 22 | if ($gd_session->get('gd_listing_view') && !isset($before_widget)) { |
23 | - $grid_view_class = geodir_convert_listing_view_class($gd_session->get('gd_listing_view')); |
|
23 | + $grid_view_class = geodir_convert_listing_view_class($gd_session->get('gd_listing_view')); |
|
24 | 24 | } |
25 | 25 | ?> |
26 | 26 | <ul class="geodir_category_list_view clearfix <?php echo apply_filters('geodir_listing_listview_ul_extra_class', '', 'widget'); ?>"> |
27 | 27 | <?php |
28 | - if (!empty($widget_listings)) { |
|
29 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
30 | - do_action('geodir_before_listing_post_listview'); |
|
31 | - $all_postypes = geodir_get_posttypes(); |
|
32 | - $geodir_days_new = (int)get_option('geodir_listing_new_days'); |
|
33 | - foreach ($widget_listings as $widget_listing) { |
|
34 | - global $gd_widget_listing_type; |
|
35 | - $post = $widget_listing; |
|
28 | + if (!empty($widget_listings)) { |
|
29 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
30 | + do_action('geodir_before_listing_post_listview'); |
|
31 | + $all_postypes = geodir_get_posttypes(); |
|
32 | + $geodir_days_new = (int)get_option('geodir_listing_new_days'); |
|
33 | + foreach ($widget_listings as $widget_listing) { |
|
34 | + global $gd_widget_listing_type; |
|
35 | + $post = $widget_listing; |
|
36 | 36 | |
37 | - $GLOBALS['post'] = $post; |
|
38 | - setup_postdata($post); |
|
37 | + $GLOBALS['post'] = $post; |
|
38 | + setup_postdata($post); |
|
39 | 39 | |
40 | - $gd_widget_listing_type = $post->post_type; |
|
40 | + $gd_widget_listing_type = $post->post_type; |
|
41 | 41 | |
42 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
43 | - $post_view_class = apply_filters('geodir_post_view_extra_class', '', $all_postypes); |
|
42 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
43 | + $post_view_class = apply_filters('geodir_post_view_extra_class', '', $all_postypes); |
|
44 | 44 | |
45 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
46 | - $post_view_article_class = apply_filters('geodir_post_view_article_extra_class', ''); |
|
47 | - ?> |
|
45 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
46 | + $post_view_article_class = apply_filters('geodir_post_view_article_extra_class', ''); |
|
47 | + ?> |
|
48 | 48 | <li class="clearfix <?php if ($grid_view_class) { |
49 | - echo 'geodir-gridview ' . $grid_view_class; |
|
50 | - } else { |
|
51 | - echo ' geodir-listview '; |
|
52 | - } ?> <?php if ($post_view_class) { |
|
53 | - echo $post_view_class; |
|
54 | - } ?>" <?php if (isset($listing_width) && $listing_width) { |
|
55 | - echo "style='width:{$listing_width}%;'"; |
|
56 | - } |
|
49 | + echo 'geodir-gridview ' . $grid_view_class; |
|
50 | + } else { |
|
51 | + echo ' geodir-listview '; |
|
52 | + } ?> <?php if ($post_view_class) { |
|
53 | + echo $post_view_class; |
|
54 | + } ?>" <?php if (isset($listing_width) && $listing_width) { |
|
55 | + echo "style='width:{$listing_width}%;'"; |
|
56 | + } |
|
57 | 57 | |
58 | - echo " data-post-id='$post->ID' "; |
|
59 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
60 | - do_action('geodir_listview_inside_li', $post, 'widget'); |
|
61 | - ?>> |
|
58 | + echo " data-post-id='$post->ID' "; |
|
59 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
60 | + do_action('geodir_listview_inside_li', $post, 'widget'); |
|
61 | + ?>> |
|
62 | 62 | <article class="geodir-category-listing <?php if ($post_view_article_class) { |
63 | - echo $post_view_article_class; |
|
64 | - } ?>"> |
|
63 | + echo $post_view_article_class; |
|
64 | + } ?>"> |
|
65 | 65 | <div class="geodir-post-img <?php echo apply_filters('geodir_listing_listview_thumb_extra_class', '', 'widget'); ?>"> |
66 | 66 | <?php if ($fimage = geodir_show_featured_image($post->ID, 'list-thumb', true, false, $post->featured_image)) { ?> |
67 | 67 | <a href="<?php the_permalink(); ?>"><?php echo $fimage; ?></a> |
68 | 68 | <?php |
69 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
70 | - do_action('geodir_before_badge_on_image', $post); |
|
71 | - if ($post->is_featured) { |
|
72 | - echo geodir_show_badges_on_image('featured', $post, get_permalink()); |
|
73 | - } |
|
69 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
70 | + do_action('geodir_before_badge_on_image', $post); |
|
71 | + if ($post->is_featured) { |
|
72 | + echo geodir_show_badges_on_image('featured', $post, get_permalink()); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - if (round(abs(strtotime($post->post_date) - strtotime(date('Y-m-d'))) / 86400) < $geodir_days_new) { |
|
77 | - echo geodir_show_badges_on_image('new', $post, get_permalink()); |
|
78 | - } |
|
76 | + if (round(abs(strtotime($post->post_date) - strtotime(date('Y-m-d'))) / 86400) < $geodir_days_new) { |
|
77 | + echo geodir_show_badges_on_image('new', $post, get_permalink()); |
|
78 | + } |
|
79 | 79 | |
80 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
81 | - do_action('geodir_after_badge_on_image', $post); |
|
82 | - } |
|
83 | - ?> |
|
80 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
81 | + do_action('geodir_after_badge_on_image', $post); |
|
82 | + } |
|
83 | + ?> |
|
84 | 84 | </div> |
85 | 85 | <div class="geodir-content <?php echo apply_filters('geodir_listing_listview_content_extra_class', '', 'widget'); ?>"> |
86 | 86 | <?php |
87 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
88 | - do_action('geodir_before_listing_post_title', 'listview', $post); ?> |
|
87 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
88 | + do_action('geodir_before_listing_post_title', 'listview', $post); ?> |
|
89 | 89 | <header class="geodir-entry-header"> |
90 | 90 | <?php $title_tag = !empty($title_tag) ? $title_tag : 'h3'; ?> |
91 | 91 | <<?php echo esc_attr($title_tag); ?> class="geodir-entry-title"> |
@@ -95,162 +95,162 @@ discard block |
||
95 | 95 | </header> |
96 | 96 | <!-- .entry-header --> |
97 | 97 | <?php |
98 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
99 | - do_action('geodir_after_listing_post_title', 'listview', $post); ?> |
|
98 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
99 | + do_action('geodir_after_listing_post_title', 'listview', $post); ?> |
|
100 | 100 | <?php /// Print Distance |
101 | - if ( ( isset( $_REQUEST['sgeo_lat'] ) && $_REQUEST['sgeo_lat'] != '' ) || ( $related_nearest && $related_parent_lat ) ) { |
|
102 | - if ( $related_nearest && $related_parent_lat ) { |
|
103 | - $startPoint = array('latitude' => $related_parent_lat, 'longitude' => $related_parent_lon); |
|
104 | - } else { |
|
105 | - $startPoint = array('latitude' => $_REQUEST['sgeo_lat'], 'longitude' => $_REQUEST['sgeo_lon']); |
|
106 | - } |
|
101 | + if ( ( isset( $_REQUEST['sgeo_lat'] ) && $_REQUEST['sgeo_lat'] != '' ) || ( $related_nearest && $related_parent_lat ) ) { |
|
102 | + if ( $related_nearest && $related_parent_lat ) { |
|
103 | + $startPoint = array('latitude' => $related_parent_lat, 'longitude' => $related_parent_lon); |
|
104 | + } else { |
|
105 | + $startPoint = array('latitude' => $_REQUEST['sgeo_lat'], 'longitude' => $_REQUEST['sgeo_lon']); |
|
106 | + } |
|
107 | 107 | |
108 | - $endLat = $post->post_latitude; |
|
109 | - $endLon = $post->post_longitude; |
|
110 | - $endPoint = array('latitude' => $endLat, 'longitude' => $endLon); |
|
111 | - $uom = get_option('geodir_search_dist_1'); |
|
112 | - $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); |
|
113 | - ?> |
|
108 | + $endLat = $post->post_latitude; |
|
109 | + $endLon = $post->post_longitude; |
|
110 | + $endPoint = array('latitude' => $endLat, 'longitude' => $endLon); |
|
111 | + $uom = get_option('geodir_search_dist_1'); |
|
112 | + $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); |
|
113 | + ?> |
|
114 | 114 | <h3> |
115 | 115 | <?php |
116 | - if (round($distance, 2) == 0) { |
|
117 | - $uom = get_option('geodir_search_dist_2'); |
|
118 | - $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); |
|
119 | - if ($uom == 'feet') { |
|
120 | - $uom = __('feet', 'geodirectory'); |
|
121 | - } else { |
|
122 | - $uom = __('meters', 'geodirectory'); |
|
123 | - } |
|
124 | - echo round($distance) . ' ' . __($uom, 'geodirectory') . ' |
|
116 | + if (round($distance, 2) == 0) { |
|
117 | + $uom = get_option('geodir_search_dist_2'); |
|
118 | + $distance = geodir_calculateDistanceFromLatLong($startPoint, $endPoint, $uom); |
|
119 | + if ($uom == 'feet') { |
|
120 | + $uom = __('feet', 'geodirectory'); |
|
121 | + } else { |
|
122 | + $uom = __('meters', 'geodirectory'); |
|
123 | + } |
|
124 | + echo round($distance) . ' ' . __($uom, 'geodirectory') . ' |
|
125 | 125 | <br /> |
126 | 126 | '; |
127 | - } else { |
|
128 | - if ($uom == 'miles') { |
|
129 | - $uom = __('miles', 'geodirectory'); |
|
130 | - } else { |
|
131 | - $uom = __('km', 'geodirectory'); |
|
132 | - } |
|
133 | - echo round($distance, 2) . ' ' . __($uom, 'geodirectory') . ' |
|
127 | + } else { |
|
128 | + if ($uom == 'miles') { |
|
129 | + $uom = __('miles', 'geodirectory'); |
|
130 | + } else { |
|
131 | + $uom = __('km', 'geodirectory'); |
|
132 | + } |
|
133 | + echo round($distance, 2) . ' ' . __($uom, 'geodirectory') . ' |
|
134 | 134 | <br /> |
135 | 135 | '; |
136 | - } |
|
137 | - ?> |
|
136 | + } |
|
137 | + ?> |
|
138 | 138 | </h3> |
139 | 139 | <?php } ?> |
140 | 140 | <?php |
141 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
142 | - do_action('geodir_before_listing_post_excerpt', $post); ?> |
|
141 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
142 | + do_action('geodir_before_listing_post_excerpt', $post); ?> |
|
143 | 143 | <?php echo geodir_show_listing_info('listing'); ?> |
144 | 144 | <?php if (isset($character_count) && $character_count == '0') { |
145 | - } else { ?> |
|
145 | + } else { ?> |
|
146 | 146 | <div class="geodir-entry-content"> |
147 | 147 | <?php |
148 | - /** |
|
149 | - * Filter to hide the listing excerpt |
|
150 | - * |
|
151 | - * @since 1.5.3 |
|
152 | - * @param bool $display Display the excerpt or not. Default true. |
|
153 | - * @param object $post The post object. |
|
154 | - */ |
|
155 | - $show_listing_excerpt = apply_filters('geodir_show_listing_post_excerpt', true, 'widget', $post); |
|
156 | - if ($show_listing_excerpt) { |
|
157 | - if ( isset( $character_count ) && ( $character_count || $character_count == '0' ) ) { |
|
158 | - $content_out = geodir_max_excerpt( $character_count ); |
|
159 | - } else { |
|
160 | - $content_out = get_the_excerpt(); |
|
161 | - } |
|
162 | - if ( ! empty( $content_out ) ) { |
|
163 | - echo "<p>" . $content_out . "</p>"; |
|
164 | - } |
|
165 | - } |
|
166 | - ?> |
|
148 | + /** |
|
149 | + * Filter to hide the listing excerpt |
|
150 | + * |
|
151 | + * @since 1.5.3 |
|
152 | + * @param bool $display Display the excerpt or not. Default true. |
|
153 | + * @param object $post The post object. |
|
154 | + */ |
|
155 | + $show_listing_excerpt = apply_filters('geodir_show_listing_post_excerpt', true, 'widget', $post); |
|
156 | + if ($show_listing_excerpt) { |
|
157 | + if ( isset( $character_count ) && ( $character_count || $character_count == '0' ) ) { |
|
158 | + $content_out = geodir_max_excerpt( $character_count ); |
|
159 | + } else { |
|
160 | + $content_out = get_the_excerpt(); |
|
161 | + } |
|
162 | + if ( ! empty( $content_out ) ) { |
|
163 | + echo "<p>" . $content_out . "</p>"; |
|
164 | + } |
|
165 | + } |
|
166 | + ?> |
|
167 | 167 | </div> |
168 | 168 | <?php } ?> |
169 | 169 | <?php |
170 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
171 | - do_action('geodir_after_listing_post_excerpt', $post); ?> |
|
170 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
171 | + do_action('geodir_after_listing_post_excerpt', $post); ?> |
|
172 | 172 | </div> |
173 | 173 | <!-- gd-content ends here--> |
174 | 174 | <?php |
175 | - /** |
|
176 | - * Called after printing listing content. |
|
177 | - * |
|
178 | - * @since 1.5.3 |
|
179 | - * @param object $post The post object. |
|
180 | - * @param string $view The view type, default 'widget'. |
|
181 | - */ |
|
182 | - do_action( 'geodir_after_listing_content', $post, 'widget' ); ?> |
|
175 | + /** |
|
176 | + * Called after printing listing content. |
|
177 | + * |
|
178 | + * @since 1.5.3 |
|
179 | + * @param object $post The post object. |
|
180 | + * @param string $view The view type, default 'widget'. |
|
181 | + */ |
|
182 | + do_action( 'geodir_after_listing_content', $post, 'widget' ); ?> |
|
183 | 183 | <footer class="geodir-entry-meta <?php echo apply_filters('geodir_listing_listview_meta_extra_class', '', 'widget'); ?>"> |
184 | 184 | <div class="geodir-addinfo clearfix <?php echo apply_filters('geodir_listing_listview_addinfo_extra_class', '', 'widget'); ?>"> |
185 | 185 | <?php |
186 | - /** |
|
187 | - * Called before printing review stars html. |
|
188 | - * |
|
189 | - * @since 1.5.3 |
|
190 | - * @param object $post The post object. |
|
191 | - * @param string $view The view type, default 'widget'. |
|
192 | - */ |
|
193 | - do_action( 'geodir_before_review_html', $post, 'widget' ); |
|
194 | - $review_show = geodir_is_reviews_show('listview'); |
|
195 | - if ($review_show) { |
|
186 | + /** |
|
187 | + * Called before printing review stars html. |
|
188 | + * |
|
189 | + * @since 1.5.3 |
|
190 | + * @param object $post The post object. |
|
191 | + * @param string $view The view type, default 'widget'. |
|
192 | + */ |
|
193 | + do_action( 'geodir_before_review_html', $post, 'widget' ); |
|
194 | + $review_show = geodir_is_reviews_show('listview'); |
|
195 | + if ($review_show) { |
|
196 | 196 | |
197 | - $post_avgratings = geodir_get_post_rating($post->ID); |
|
197 | + $post_avgratings = geodir_get_post_rating($post->ID); |
|
198 | 198 | |
199 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
200 | - do_action('geodir_before_review_rating_stars_on_listview', $post_avgratings, $post->ID); |
|
199 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
200 | + do_action('geodir_before_review_rating_stars_on_listview', $post_avgratings, $post->ID); |
|
201 | 201 | |
202 | - echo geodir_get_rating_stars($post_avgratings, $post->ID); |
|
202 | + echo geodir_get_rating_stars($post_avgratings, $post->ID); |
|
203 | 203 | |
204 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
205 | - do_action('geodir_after_review_rating_stars_on_listview', $post_avgratings, $post->ID); |
|
206 | - ?><a href="<?php comments_link(); ?>" class="geodir-pcomments"><i |
|
204 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
205 | + do_action('geodir_after_review_rating_stars_on_listview', $post_avgratings, $post->ID); |
|
206 | + ?><a href="<?php comments_link(); ?>" class="geodir-pcomments"><i |
|
207 | 207 | class="fa fa-comments"></i> <?php geodir_comments_number($post->rating_count); ?> |
208 | 208 | </a> |
209 | 209 | <?php |
210 | - } |
|
210 | + } |
|
211 | 211 | |
212 | 212 | |
213 | - /** |
|
214 | - * Called after printing favorite html. |
|
215 | - * |
|
216 | - * @since 1.0.0 |
|
217 | - */ |
|
218 | - do_action( 'geodir_after_favorite_html', $post->ID, 'widget' ); |
|
213 | + /** |
|
214 | + * Called after printing favorite html. |
|
215 | + * |
|
216 | + * @since 1.0.0 |
|
217 | + */ |
|
218 | + do_action( 'geodir_after_favorite_html', $post->ID, 'widget' ); |
|
219 | 219 | |
220 | - if ($post->post_author == get_current_user_id()) { |
|
221 | - $addplacelink = get_permalink(geodir_add_listing_page_id()); |
|
222 | - $editlink = geodir_getlink($addplacelink, array('pid' => $post->ID), false); |
|
223 | - $upgradelink = geodir_getlink($editlink, array('upgrade' => '1'), false); |
|
220 | + if ($post->post_author == get_current_user_id()) { |
|
221 | + $addplacelink = get_permalink(geodir_add_listing_page_id()); |
|
222 | + $editlink = geodir_getlink($addplacelink, array('pid' => $post->ID), false); |
|
223 | + $upgradelink = geodir_getlink($editlink, array('upgrade' => '1'), false); |
|
224 | 224 | |
225 | - $ajaxlink = geodir_get_ajax_url(); |
|
226 | - $deletelink = geodir_getlink($ajaxlink, array('geodir_ajax' => 'add_listing', 'ajax_action' => 'delete', 'pid' => $post->ID), false); |
|
227 | - ?> |
|
225 | + $ajaxlink = geodir_get_ajax_url(); |
|
226 | + $deletelink = geodir_getlink($ajaxlink, array('geodir_ajax' => 'add_listing', 'ajax_action' => 'delete', 'pid' => $post->ID), false); |
|
227 | + ?> |
|
228 | 228 | <span class="geodir-authorlink clearfix"> |
229 | 229 | <?php |
230 | - if (isset($_REQUEST['geodir_dashbord']) && $_REQUEST['geodir_dashbord']) { |
|
231 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
232 | - do_action('geodir_before_edit_post_link_on_listing'); |
|
233 | - ?> |
|
230 | + if (isset($_REQUEST['geodir_dashbord']) && $_REQUEST['geodir_dashbord']) { |
|
231 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
232 | + do_action('geodir_before_edit_post_link_on_listing'); |
|
233 | + ?> |
|
234 | 234 | <a href="<?php echo esc_url($editlink); ?>" class="geodir-edit" |
235 | 235 | title="<?php _e('Edit Listing', 'geodirectory'); ?>"> |
236 | 236 | <?php |
237 | - $geodir_listing_edit_icon = apply_filters('geodir_listing_edit_icon', 'fa fa-edit'); |
|
238 | - echo '<i class="'. $geodir_listing_edit_icon .'"></i>'; |
|
239 | - ?> |
|
237 | + $geodir_listing_edit_icon = apply_filters('geodir_listing_edit_icon', 'fa fa-edit'); |
|
238 | + echo '<i class="'. $geodir_listing_edit_icon .'"></i>'; |
|
239 | + ?> |
|
240 | 240 | <?php _e('Edit', 'geodirectory'); ?> |
241 | 241 | </a> |
242 | 242 | <a href="<?php echo esc_url($deletelink); ?>" class="geodir-delete" |
243 | 243 | title="<?php _e('Delete Listing', 'geodirectory'); ?>"> |
244 | 244 | <?php |
245 | - $geodir_listing_delete_icon = apply_filters('geodir_listing_delete_icon', 'fa fa-close'); |
|
246 | - echo '<i class="'. $geodir_listing_delete_icon .'"></i>'; |
|
247 | - ?> |
|
245 | + $geodir_listing_delete_icon = apply_filters('geodir_listing_delete_icon', 'fa fa-close'); |
|
246 | + echo '<i class="'. $geodir_listing_delete_icon .'"></i>'; |
|
247 | + ?> |
|
248 | 248 | <?php _e('Delete', 'geodirectory'); ?> |
249 | 249 | </a> |
250 | 250 | <?php |
251 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
252 | - do_action('geodir_after_edit_post_link_on_listing'); |
|
253 | - } ?> |
|
251 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
252 | + do_action('geodir_after_edit_post_link_on_listing'); |
|
253 | + } ?> |
|
254 | 254 | </span> |
255 | 255 | <?php } ?> |
256 | 256 | </div> |
@@ -260,17 +260,17 @@ discard block |
||
260 | 260 | </article> |
261 | 261 | </li> |
262 | 262 | <?php |
263 | - unset($gd_widget_listing_type); |
|
264 | - } |
|
265 | - /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
266 | - do_action('geodir_after_listing_post_listview'); |
|
267 | - } else { |
|
263 | + unset($gd_widget_listing_type); |
|
264 | + } |
|
265 | + /** This action is documented in geodirectory-templates/listing-listview.php */ |
|
266 | + do_action('geodir_after_listing_post_listview'); |
|
267 | + } else { |
|
268 | 268 | $favorite = isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' ? true : false; |
269 | 269 | |
270 | 270 | /** This action is documented in geodirectory-templates/listing-listview.php */ |
271 | - do_action('geodir_message_not_found_on_listing', 'widget-listing-listview', $favorite); |
|
272 | - } |
|
273 | - ?> |
|
271 | + do_action('geodir_message_not_found_on_listing', 'widget-listing-listview', $favorite); |
|
272 | + } |
|
273 | + ?> |
|
274 | 274 | </ul> <!-- geodir_category_list_view ends here--> |
275 | 275 | <div class="clear"></div> |
276 | 276 | <?php |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | */ |
10 | 10 | function geodir_get_current_city_lat() |
11 | 11 | { |
12 | - $location = geodir_get_default_location(); |
|
13 | - $lat = isset($location_result->city_latitude) ? $location_result->city_latitude : '39.952484'; |
|
12 | + $location = geodir_get_default_location(); |
|
13 | + $lat = isset($location_result->city_latitude) ? $location_result->city_latitude : '39.952484'; |
|
14 | 14 | |
15 | - return $lat; |
|
15 | + return $lat; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function geodir_get_current_city_lng() |
27 | 27 | { |
28 | - $location = geodir_get_default_location(); |
|
29 | - $lng = isset($location_result->city_longitude) ? $location_result->city_longitude : '-75.163786'; |
|
30 | - return $lng; |
|
28 | + $location = geodir_get_default_location(); |
|
29 | + $lng = isset($location_result->city_longitude) ? $location_result->city_longitude : '-75.163786'; |
|
30 | + return $lng; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function geodir_get_default_location() |
42 | 42 | { |
43 | - /** |
|
44 | - * Filter the default location. |
|
45 | - * |
|
46 | - * @since 1.0.0 |
|
47 | - * @package GeoDirectory |
|
48 | - * |
|
49 | - * @param string $location_result The default location object. |
|
50 | - */ |
|
51 | - return $location_result = apply_filters('geodir_get_default_location', get_option('geodir_default_location')); |
|
43 | + /** |
|
44 | + * Filter the default location. |
|
45 | + * |
|
46 | + * @since 1.0.0 |
|
47 | + * @package GeoDirectory |
|
48 | + * |
|
49 | + * @param string $location_result The default location object. |
|
50 | + */ |
|
51 | + return $location_result = apply_filters('geodir_get_default_location', get_option('geodir_default_location')); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | */ |
61 | 61 | function geodir_is_default_location_set() |
62 | 62 | { |
63 | - $default_location = geodir_get_default_location(); |
|
64 | - if (!empty($default_location)) |
|
65 | - return true; |
|
66 | - else |
|
67 | - return false; |
|
63 | + $default_location = geodir_get_default_location(); |
|
64 | + if (!empty($default_location)) |
|
65 | + return true; |
|
66 | + else |
|
67 | + return false; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | function create_location_slug($location_string) |
79 | 79 | { |
80 | 80 | |
81 | - /** |
|
82 | - * Filter the location slug. |
|
83 | - * |
|
84 | - * @since 1.0.0 |
|
85 | - * @package GeoDirectory |
|
86 | - * |
|
87 | - * @param string $location_string Sanitized location string. |
|
88 | - */ |
|
89 | - return urldecode(apply_filters('geodir_location_slug_check', sanitize_title($location_string))); |
|
81 | + /** |
|
82 | + * Filter the location slug. |
|
83 | + * |
|
84 | + * @since 1.0.0 |
|
85 | + * @package GeoDirectory |
|
86 | + * |
|
87 | + * @param string $location_string Sanitized location string. |
|
88 | + */ |
|
89 | + return urldecode(apply_filters('geodir_location_slug_check', sanitize_title($location_string))); |
|
90 | 90 | |
91 | 91 | } |
92 | 92 | |
@@ -100,15 +100,15 @@ discard block |
||
100 | 100 | */ |
101 | 101 | function geodir_get_location($id = '') |
102 | 102 | { |
103 | - /** |
|
104 | - * Filter the location information. |
|
105 | - * |
|
106 | - * @since 1.0.0 |
|
107 | - * @package GeoDirectory |
|
108 | - * |
|
109 | - * @param string $id The location ID. |
|
110 | - */ |
|
111 | - return $location_result = apply_filters('geodir_get_location_by_id', get_option('geodir_default_location'), $id); |
|
103 | + /** |
|
104 | + * Filter the location information. |
|
105 | + * |
|
106 | + * @since 1.0.0 |
|
107 | + * @package GeoDirectory |
|
108 | + * |
|
109 | + * @param string $id The location ID. |
|
110 | + */ |
|
111 | + return $location_result = apply_filters('geodir_get_location_by_id', get_option('geodir_default_location'), $id); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -122,28 +122,28 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function geodir_get_country_dl($post_country = '', $prefix = '') |
124 | 124 | { |
125 | - global $wpdb; |
|
125 | + global $wpdb; |
|
126 | 126 | |
127 | - $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC"); |
|
127 | + $rows = $wpdb->get_results("SELECT Country,ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " ORDER BY Country ASC"); |
|
128 | 128 | |
129 | - $ISO2 = array(); |
|
130 | - $countries = array(); |
|
129 | + $ISO2 = array(); |
|
130 | + $countries = array(); |
|
131 | 131 | |
132 | - foreach ($rows as $row) { |
|
133 | - $ISO2[$row->Country] = $row->ISO2; |
|
134 | - $countries[$row->Country] = __($row->Country, 'geodirectory'); |
|
135 | - } |
|
132 | + foreach ($rows as $row) { |
|
133 | + $ISO2[$row->Country] = $row->ISO2; |
|
134 | + $countries[$row->Country] = __($row->Country, 'geodirectory'); |
|
135 | + } |
|
136 | 136 | |
137 | - asort($countries); |
|
137 | + asort($countries); |
|
138 | 138 | |
139 | - $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>'; |
|
140 | - foreach ($countries as $country => $name) { |
|
141 | - $ccode = $ISO2[$country]; |
|
139 | + $out_put = '<option ' . selected('', $post_country, false) . ' value="">' . __('Select Country', 'geodirectory') . '</option>'; |
|
140 | + foreach ($countries as $country => $name) { |
|
141 | + $ccode = $ISO2[$country]; |
|
142 | 142 | |
143 | - $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>'; |
|
144 | - } |
|
143 | + $out_put .= '<option ' . selected($post_country, $country, false) . ' value="' . esc_attr($country) . '" data-country_code="' . $ccode . '">' . $name . '</option>'; |
|
144 | + } |
|
145 | 145 | |
146 | - echo $out_put; |
|
146 | + echo $out_put; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -158,40 +158,40 @@ discard block |
||
158 | 158 | function geodir_location_form_submit() |
159 | 159 | { |
160 | 160 | |
161 | - global $wpdb, $plugin_prefix; |
|
162 | - if (isset($_REQUEST['add_location'])) { |
|
161 | + global $wpdb, $plugin_prefix; |
|
162 | + if (isset($_REQUEST['add_location'])) { |
|
163 | 163 | |
164 | - $location_info = array( |
|
165 | - 'city' => $_REQUEST['city'], |
|
166 | - 'region' => $_REQUEST['region'], |
|
167 | - 'country' => $_REQUEST['country'], |
|
168 | - 'geo_lat' => $_REQUEST['latitude'], |
|
169 | - 'geo_lng' => $_REQUEST['longitude'], |
|
170 | - 'is_default' => $_REQUEST['is_default'], |
|
171 | - 'update_city' => $_REQUEST['update_city'] |
|
172 | - ); |
|
164 | + $location_info = array( |
|
165 | + 'city' => $_REQUEST['city'], |
|
166 | + 'region' => $_REQUEST['region'], |
|
167 | + 'country' => $_REQUEST['country'], |
|
168 | + 'geo_lat' => $_REQUEST['latitude'], |
|
169 | + 'geo_lng' => $_REQUEST['longitude'], |
|
170 | + 'is_default' => $_REQUEST['is_default'], |
|
171 | + 'update_city' => $_REQUEST['update_city'] |
|
172 | + ); |
|
173 | 173 | |
174 | - $old_location = geodir_get_default_location(); |
|
174 | + $old_location = geodir_get_default_location(); |
|
175 | 175 | |
176 | - $locationid = geodir_add_new_location($location_info); |
|
176 | + $locationid = geodir_add_new_location($location_info); |
|
177 | 177 | |
178 | - $default_location = geodir_get_location($locationid); |
|
178 | + $default_location = geodir_get_location($locationid); |
|
179 | 179 | |
180 | - //UPDATE AND DELETE LISTING |
|
181 | - $posttype = geodir_get_posttypes(); |
|
182 | - if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') { |
|
180 | + //UPDATE AND DELETE LISTING |
|
181 | + $posttype = geodir_get_posttypes(); |
|
182 | + if (isset($_REQUEST['listing_action']) && $_REQUEST['listing_action'] == 'delete') { |
|
183 | 183 | |
184 | - foreach ($posttype as $posttypeobj) { |
|
185 | - $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location |
|
184 | + foreach ($posttype as $posttypeobj) { |
|
185 | + $post_locations = '[' . $default_location->city_slug . '],[' . $default_location->region_slug . '],[' . $default_location->country_slug . ']'; // set all overall post location |
|
186 | 186 | |
187 | - $sql = $wpdb->prepare( |
|
188 | - "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)", |
|
189 | - array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations) |
|
190 | - ); |
|
191 | - $wpdb->query($sql); |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
187 | + $sql = $wpdb->prepare( |
|
188 | + "UPDATE " . $plugin_prefix . $posttypeobj . "_detail SET post_city=%s, post_region=%s, post_country=%s, post_locations=%s WHERE post_location_id=%d AND ( post_city!=%s OR post_region!=%s OR post_country!=%s OR post_locations!=%s OR post_locations IS NULL)", |
|
189 | + array($_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations, $locationid, $_REQUEST['city'], $_REQUEST['region'], $_REQUEST['country'], $post_locations) |
|
190 | + ); |
|
191 | + $wpdb->query($sql); |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -215,37 +215,37 @@ discard block |
||
215 | 215 | */ |
216 | 216 | function geodir_add_new_location($location_info = array()) |
217 | 217 | { |
218 | - global $wpdb; |
|
219 | - |
|
220 | - if (!empty($location_info)) { |
|
221 | - $location_city = ($location_info['city'] != '') ? $location_info['city'] : 'all'; |
|
222 | - $location_region = ($location_info['region'] != '') ? $location_info['region'] : 'all'; |
|
223 | - $location_country = ($location_info['country'] != '') ? geodir_get_normal_country($location_info['country']) : 'all'; |
|
224 | - $location_lat = ($location_info['geo_lat'] != '') ? $location_info['geo_lat'] : ''; |
|
225 | - $location_lng = ($location_info['geo_lng'] != '') ? $location_info['geo_lng'] : ''; |
|
226 | - $is_default = isset($location_info['is_default']) ? $location_info['is_default'] : ''; |
|
227 | - $country_slug = create_location_slug(__($location_country, 'geodirectory')); |
|
228 | - $region_slug = create_location_slug($location_region); |
|
229 | - $city_slug = create_location_slug($location_city); |
|
218 | + global $wpdb; |
|
219 | + |
|
220 | + if (!empty($location_info)) { |
|
221 | + $location_city = ($location_info['city'] != '') ? $location_info['city'] : 'all'; |
|
222 | + $location_region = ($location_info['region'] != '') ? $location_info['region'] : 'all'; |
|
223 | + $location_country = ($location_info['country'] != '') ? geodir_get_normal_country($location_info['country']) : 'all'; |
|
224 | + $location_lat = ($location_info['geo_lat'] != '') ? $location_info['geo_lat'] : ''; |
|
225 | + $location_lng = ($location_info['geo_lng'] != '') ? $location_info['geo_lng'] : ''; |
|
226 | + $is_default = isset($location_info['is_default']) ? $location_info['is_default'] : ''; |
|
227 | + $country_slug = create_location_slug(__($location_country, 'geodirectory')); |
|
228 | + $region_slug = create_location_slug($location_region); |
|
229 | + $city_slug = create_location_slug($location_city); |
|
230 | 230 | |
231 | - /** |
|
232 | - * Filter add new location data. |
|
233 | - * |
|
234 | - * @since 1.0.0 |
|
235 | - */ |
|
236 | - $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0, |
|
237 | - 'country' => $location_country, |
|
238 | - 'region' => $location_region, |
|
239 | - 'city' => $location_city, |
|
240 | - 'country_slug' => $country_slug, |
|
241 | - 'region_slug' => $region_slug, |
|
242 | - 'city_slug' => $city_slug, |
|
243 | - 'city_latitude' => $location_lat, |
|
244 | - 'city_longitude' => $location_lng, |
|
245 | - 'is_default' => $is_default |
|
246 | - )); |
|
247 | - |
|
248 | - /* // Not allowed to create country in DB : 2016-12-09 |
|
231 | + /** |
|
232 | + * Filter add new location data. |
|
233 | + * |
|
234 | + * @since 1.0.0 |
|
235 | + */ |
|
236 | + $geodir_location = (object)apply_filters('geodir_add_new_location', array('location_id' => 0, |
|
237 | + 'country' => $location_country, |
|
238 | + 'region' => $location_region, |
|
239 | + 'city' => $location_city, |
|
240 | + 'country_slug' => $country_slug, |
|
241 | + 'region_slug' => $region_slug, |
|
242 | + 'city_slug' => $city_slug, |
|
243 | + 'city_latitude' => $location_lat, |
|
244 | + 'city_longitude' => $location_lng, |
|
245 | + 'is_default' => $is_default |
|
246 | + )); |
|
247 | + |
|
248 | + /* // Not allowed to create country in DB : 2016-12-09 |
|
249 | 249 | if ($geodir_location->country) { |
250 | 250 | |
251 | 251 | $get_country = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", array($geodir_location->country))); |
@@ -259,14 +259,14 @@ discard block |
||
259 | 259 | } |
260 | 260 | */ |
261 | 261 | |
262 | - if ($geodir_location->is_default) |
|
263 | - update_option('geodir_default_location', $geodir_location); |
|
262 | + if ($geodir_location->is_default) |
|
263 | + update_option('geodir_default_location', $geodir_location); |
|
264 | 264 | |
265 | - return $geodir_location->location_id; |
|
265 | + return $geodir_location->location_id; |
|
266 | 266 | |
267 | - } else { |
|
268 | - return false; |
|
269 | - } |
|
267 | + } else { |
|
268 | + return false; |
|
269 | + } |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | */ |
281 | 281 | function geodir_random_float($min = 0, $max = 1) |
282 | 282 | { |
283 | - return $min + mt_rand() / mt_getrandmax() * ($max - $min); |
|
283 | + return $min + mt_rand() / mt_getrandmax() * ($max - $min); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -294,23 +294,23 @@ discard block |
||
294 | 294 | */ |
295 | 295 | function geodir_get_address_by_lat_lan($lat, $lng) |
296 | 296 | { |
297 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng);// . "&key=" . geodir_get_map_api_key(); // if we add a key here it will not work if limited to a domain as this is done via curl. |
|
298 | - |
|
299 | - $ch = curl_init(); |
|
300 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
301 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
302 | - curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
303 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
304 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
305 | - $response = curl_exec($ch); |
|
306 | - curl_close($ch); |
|
297 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lat) . ',' . trim($lng);// . "&key=" . geodir_get_map_api_key(); // if we add a key here it will not work if limited to a domain as this is done via curl. |
|
298 | + |
|
299 | + $ch = curl_init(); |
|
300 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
301 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
302 | + curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
303 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
304 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
305 | + $response = curl_exec($ch); |
|
306 | + curl_close($ch); |
|
307 | 307 | |
308 | - $data = json_decode($response); |
|
309 | - $status = $data->status; |
|
310 | - if ($status == "OK") { |
|
311 | - return $data->results[0]->address_components; |
|
312 | - } else |
|
313 | - return false; |
|
308 | + $data = json_decode($response); |
|
309 | + $status = $data->status; |
|
310 | + if ($status == "OK") { |
|
311 | + return $data->results[0]->address_components; |
|
312 | + } else |
|
313 | + return false; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -327,71 +327,71 @@ discard block |
||
327 | 327 | */ |
328 | 328 | function geodir_get_current_location_terms($location_array_from = 'session', $gd_post_type = '') |
329 | 329 | { |
330 | - global $wp, $gd_session; |
|
331 | - $location_array = array(); |
|
332 | - if ($location_array_from == 'session') { |
|
333 | - if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') { |
|
334 | - return $location_array; |
|
335 | - } |
|
330 | + global $wp, $gd_session; |
|
331 | + $location_array = array(); |
|
332 | + if ($location_array_from == 'session') { |
|
333 | + if ($gd_session->get('gd_country') == 'me' || $gd_session->get('gd_region') == 'me' || $gd_session->get('gd_city') == 'me') { |
|
334 | + return $location_array; |
|
335 | + } |
|
336 | 336 | |
337 | - $country = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : $gd_session->get('gd_country'); |
|
338 | - if ($country != '' && $country) |
|
339 | - $location_array['gd_country'] = urldecode($country); |
|
337 | + $country = isset($_REQUEST['gd_country']) ? $_REQUEST['gd_country'] : $gd_session->get('gd_country'); |
|
338 | + if ($country != '' && $country) |
|
339 | + $location_array['gd_country'] = urldecode($country); |
|
340 | 340 | |
341 | - $region = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : $gd_session->get('gd_region'); |
|
342 | - if ($region != '' && $region) |
|
343 | - $location_array['gd_region'] = urldecode($region); |
|
341 | + $region = isset($_REQUEST['gd_region']) ? $_REQUEST['gd_region'] : $gd_session->get('gd_region'); |
|
342 | + if ($region != '' && $region) |
|
343 | + $location_array['gd_region'] = urldecode($region); |
|
344 | 344 | |
345 | - $city = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : $gd_session->get('gd_city'); |
|
346 | - if ($city != '' && $city) |
|
347 | - $location_array['gd_city'] = urldecode($city); |
|
348 | - } else { |
|
349 | - if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) { |
|
350 | - return $location_array; |
|
351 | - } |
|
345 | + $city = isset($_REQUEST['gd_city']) ? $_REQUEST['gd_city'] : $gd_session->get('gd_city'); |
|
346 | + if ($city != '' && $city) |
|
347 | + $location_array['gd_city'] = urldecode($city); |
|
348 | + } else { |
|
349 | + if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) { |
|
350 | + return $location_array; |
|
351 | + } |
|
352 | 352 | |
353 | - $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
353 | + $country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
354 | 354 | |
355 | - $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
355 | + $region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
356 | 356 | |
357 | - $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
357 | + $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
358 | 358 | |
359 | - if ($country != '') |
|
360 | - $location_array['gd_country'] = urldecode($country); |
|
359 | + if ($country != '') |
|
360 | + $location_array['gd_country'] = urldecode($country); |
|
361 | 361 | |
362 | - if ($region != '') |
|
363 | - $location_array['gd_region'] = urldecode($region); |
|
362 | + if ($region != '') |
|
363 | + $location_array['gd_region'] = urldecode($region); |
|
364 | 364 | |
365 | - if ($city != '') |
|
366 | - $location_array['gd_city'] = urldecode($city); |
|
365 | + if ($city != '') |
|
366 | + $location_array['gd_city'] = urldecode($city); |
|
367 | 367 | |
368 | 368 | // Fix category link in ajax popular category widget on change post type |
369 | 369 | if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) { |
370 | 370 | $location_array = geodir_get_current_location_terms('session'); |
371 | 371 | } |
372 | - } |
|
372 | + } |
|
373 | 373 | |
374 | 374 | |
375 | 375 | /** |
376 | 376 | * Filter the location terms. |
377 | 377 | * |
378 | 378 | * @since 1.4.6 |
379 | - * @package GeoDirectory |
|
379 | + * @package GeoDirectory |
|
380 | + * |
|
381 | + * @param array $location_array { |
|
382 | + * Attributes of the location_array. |
|
383 | + * |
|
384 | + * @type string $gd_country The country slug. |
|
385 | + * @type string $gd_region The region slug. |
|
386 | + * @type string $gd_city The city slug. |
|
380 | 387 | * |
381 | - * @param array $location_array { |
|
382 | - * Attributes of the location_array. |
|
383 | - * |
|
384 | - * @type string $gd_country The country slug. |
|
385 | - * @type string $gd_region The region slug. |
|
386 | - * @type string $gd_city The city slug. |
|
387 | - * |
|
388 | - * } |
|
388 | + * } |
|
389 | 389 | * @param string $location_array_from Source type of location terms. Default session. |
390 | 390 | * @param string $gd_post_type WP post type. |
391 | 391 | */ |
392 | 392 | $location_array = apply_filters( 'geodir_current_location_terms', $location_array, $location_array_from, $gd_post_type ); |
393 | 393 | |
394 | - return $location_array; |
|
394 | + return $location_array; |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -404,24 +404,24 @@ discard block |
||
404 | 404 | * @return bool|string |
405 | 405 | */ |
406 | 406 | function geodir_get_location_link($which_location = 'current') { |
407 | - $location_link = get_permalink(geodir_location_page_id()); |
|
408 | - |
|
409 | - if ($which_location == 'base') { |
|
410 | - return $location_link; |
|
411 | - } else { |
|
412 | - $location_terms = geodir_get_current_location_terms(); |
|
413 | - |
|
414 | - if (!empty($location_terms)) { |
|
415 | - if (get_option('permalink_structure') != '') { |
|
416 | - $location_terms = implode("/", $location_terms); |
|
417 | - $location_terms = rtrim($location_terms, '/'); |
|
418 | - $location_link .= $location_terms; |
|
419 | - } else { |
|
420 | - $location_link = geodir_getlink($location_link, $location_terms); |
|
421 | - } |
|
422 | - } |
|
423 | - } |
|
424 | - return $location_link; |
|
407 | + $location_link = get_permalink(geodir_location_page_id()); |
|
408 | + |
|
409 | + if ($which_location == 'base') { |
|
410 | + return $location_link; |
|
411 | + } else { |
|
412 | + $location_terms = geodir_get_current_location_terms(); |
|
413 | + |
|
414 | + if (!empty($location_terms)) { |
|
415 | + if (get_option('permalink_structure') != '') { |
|
416 | + $location_terms = implode("/", $location_terms); |
|
417 | + $location_terms = rtrim($location_terms, '/'); |
|
418 | + $location_link .= $location_terms; |
|
419 | + } else { |
|
420 | + $location_link = geodir_getlink($location_link, $location_terms); |
|
421 | + } |
|
422 | + } |
|
423 | + } |
|
424 | + return $location_link; |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -434,33 +434,33 @@ discard block |
||
434 | 434 | * @return array|bool Returns address on success. |
435 | 435 | */ |
436 | 436 | function geodir_get_osm_address_by_lat_lan($lat, $lng) { |
437 | - $url = 'https://nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email'); |
|
438 | - |
|
439 | - $ch = curl_init(); |
|
440 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
441 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
442 | - curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
443 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
444 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
445 | - $response = curl_exec($ch); |
|
446 | - curl_close($ch); |
|
447 | - $data = json_decode($response); |
|
437 | + $url = 'https://nominatim.openstreetmap.org/reverse?format=json&lat=' . trim($lat) . '&lon=' . trim($lng) . '&zoom=16&addressdetails=1&email=' . get_option('admin_email'); |
|
438 | + |
|
439 | + $ch = curl_init(); |
|
440 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
441 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
442 | + curl_setopt($ch, CURLOPT_PROXYPORT, 3128); |
|
443 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
444 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
445 | + $response = curl_exec($ch); |
|
446 | + curl_close($ch); |
|
447 | + $data = json_decode($response); |
|
448 | 448 | |
449 | - if (!empty($data) && !empty($data->address)) { |
|
450 | - $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb'); |
|
451 | - $formatted_address = (array)$data->address; |
|
449 | + if (!empty($data) && !empty($data->address)) { |
|
450 | + $address_fields = array('public_building', 'house', 'house_number', 'bakery', 'footway', 'street', 'road', 'village', 'attraction', 'pedestrian', 'neighbourhood', 'suburb'); |
|
451 | + $formatted_address = (array)$data->address; |
|
452 | 452 | |
453 | - foreach ( $data->address as $key => $value ) { |
|
454 | - if (!in_array($key, $address_fields)) { |
|
455 | - unset($formatted_address[$key]); |
|
456 | - } |
|
457 | - } |
|
458 | - $data->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : ''; |
|
453 | + foreach ( $data->address as $key => $value ) { |
|
454 | + if (!in_array($key, $address_fields)) { |
|
455 | + unset($formatted_address[$key]); |
|
456 | + } |
|
457 | + } |
|
458 | + $data->formatted_address = !empty($formatted_address) ? implode(', ', $formatted_address) : ''; |
|
459 | 459 | |
460 | - return $data; |
|
461 | - } else { |
|
462 | - return false; |
|
463 | - } |
|
460 | + return $data; |
|
461 | + } else { |
|
462 | + return false; |
|
463 | + } |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -474,51 +474,51 @@ discard block |
||
474 | 474 | * @return string Returns the country. |
475 | 475 | */ |
476 | 476 | function geodir_get_normal_country($country, $default = '1') { |
477 | - global $wpdb; |
|
478 | - if ($result = geodir_get_country_by_name($country)) { |
|
479 | - return $result; |
|
480 | - } |
|
477 | + global $wpdb; |
|
478 | + if ($result = geodir_get_country_by_name($country)) { |
|
479 | + return $result; |
|
480 | + } |
|
481 | 481 | |
482 | - if (defined('POST_LOCATION_TABLE')) { |
|
483 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country)); |
|
484 | - if (!empty($rows)) { |
|
485 | - foreach ($rows as $row) { |
|
486 | - $translated = __($row->country, 'geodirectory'); |
|
487 | - if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) { |
|
488 | - return $result; |
|
489 | - } |
|
490 | - } |
|
491 | - } |
|
482 | + if (defined('POST_LOCATION_TABLE')) { |
|
483 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country NOT LIKE %s ORDER BY location_id ASC", $country)); |
|
484 | + if (!empty($rows)) { |
|
485 | + foreach ($rows as $row) { |
|
486 | + $translated = __($row->country, 'geodirectory'); |
|
487 | + if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) { |
|
488 | + return $result; |
|
489 | + } |
|
490 | + } |
|
491 | + } |
|
492 | 492 | |
493 | - $rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) ); |
|
494 | - if (!empty($rows)) { |
|
495 | - foreach ($rows as $row) { |
|
496 | - $translated = __($row->country, 'geodirectory'); |
|
497 | - if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) { |
|
498 | - return $result; |
|
499 | - } |
|
500 | - } |
|
501 | - } |
|
502 | - } |
|
493 | + $rows = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT country FROM " . POST_LOCATION_TABLE . " WHERE country_slug LIKE %s AND country NOT LIKE %s ORDER BY location_id", $country, $country ) ); |
|
494 | + if (!empty($rows)) { |
|
495 | + foreach ($rows as $row) { |
|
496 | + $translated = __($row->country, 'geodirectory'); |
|
497 | + if (geodir_strtolower($translated) == geodir_strtolower($country) && $result = geodir_get_country_by_name($row->country)) { |
|
498 | + return $result; |
|
499 | + } |
|
500 | + } |
|
501 | + } |
|
502 | + } |
|
503 | 503 | |
504 | - if ( $default === '0' ) { |
|
505 | - return NULL; |
|
506 | - } |
|
504 | + if ( $default === '0' ) { |
|
505 | + return NULL; |
|
506 | + } |
|
507 | 507 | |
508 | - $default_location = geodir_get_default_location(); |
|
509 | - if (!empty($default_location->country) && $result = geodir_get_country_by_name($default_location->country)) { |
|
510 | - return $result; |
|
511 | - } |
|
508 | + $default_location = geodir_get_default_location(); |
|
509 | + if (!empty($default_location->country) && $result = geodir_get_country_by_name($default_location->country)) { |
|
510 | + return $result; |
|
511 | + } |
|
512 | 512 | |
513 | - if (!empty($default_location->country_slug) && $result = geodir_get_country_by_name($default_location->country_slug)) { |
|
514 | - return $result; |
|
515 | - } |
|
513 | + if (!empty($default_location->country_slug) && $result = geodir_get_country_by_name($default_location->country_slug)) { |
|
514 | + return $result; |
|
515 | + } |
|
516 | 516 | |
517 | - if (!empty($default_location->country_ISO2) && $result = geodir_get_country_by_name($default_location->country_ISO2, true)) { |
|
518 | - return $result; |
|
519 | - } |
|
517 | + if (!empty($default_location->country_ISO2) && $result = geodir_get_country_by_name($default_location->country_ISO2, true)) { |
|
518 | + return $result; |
|
519 | + } |
|
520 | 520 | |
521 | - return $country; |
|
521 | + return $country; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -530,16 +530,16 @@ discard block |
||
530 | 530 | * @return string Country ISO2 code. |
531 | 531 | */ |
532 | 532 | function geodir_get_country_iso2($country) { |
533 | - global $wpdb; |
|
533 | + global $wpdb; |
|
534 | 534 | |
535 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) { |
|
536 | - return $result; |
|
537 | - } |
|
538 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) { |
|
539 | - return $result; |
|
540 | - } |
|
535 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) { |
|
536 | + return $result; |
|
537 | + } |
|
538 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", geodir_get_normal_country($country)))) { |
|
539 | + return $result; |
|
540 | + } |
|
541 | 541 | |
542 | - return $country; |
|
542 | + return $country; |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | /** |
@@ -552,16 +552,16 @@ discard block |
||
552 | 552 | * @return string|null Country ISO2 code. |
553 | 553 | */ |
554 | 554 | function geodir_get_country_by_name($country, $iso2 = false) { |
555 | - global $wpdb; |
|
555 | + global $wpdb; |
|
556 | 556 | |
557 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) { |
|
558 | - return $result; |
|
559 | - } |
|
560 | - if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) { |
|
561 | - return $result; |
|
562 | - } |
|
557 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country LIKE %s", $country))) { |
|
558 | + return $result; |
|
559 | + } |
|
560 | + if ($iso2 && $result = $wpdb->get_var($wpdb->prepare("SELECT Country FROM " . GEODIR_COUNTRIES_TABLE . " WHERE ISO2 LIKE %s", $country))) { |
|
561 | + return $result; |
|
562 | + } |
|
563 | 563 | |
564 | - return NULL; |
|
564 | + return NULL; |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | |
@@ -581,158 +581,158 @@ discard block |
||
581 | 581 | */ |
582 | 582 | function geodir_replace_location_variables($content, $location_array = array(), $sep = NULL, $gd_page = '') { |
583 | 583 | |
584 | - if (empty($content)) { |
|
585 | - return $content; |
|
586 | - } |
|
584 | + if (empty($content)) { |
|
585 | + return $content; |
|
586 | + } |
|
587 | 587 | |
588 | 588 | |
589 | - $location_replace_vars = geodir_location_replace_vars($location_array, $sep, $gd_page); |
|
589 | + $location_replace_vars = geodir_location_replace_vars($location_array, $sep, $gd_page); |
|
590 | 590 | |
591 | - if (!empty($location_replace_vars)) { |
|
592 | - foreach ($location_replace_vars as $search => $replace) { |
|
593 | - if (!empty($search) && strpos($content, $search) !== false) { |
|
594 | - $content = str_replace($search, $replace, $content); |
|
595 | - } |
|
596 | - } |
|
597 | - } |
|
591 | + if (!empty($location_replace_vars)) { |
|
592 | + foreach ($location_replace_vars as $search => $replace) { |
|
593 | + if (!empty($search) && strpos($content, $search) !== false) { |
|
594 | + $content = str_replace($search, $replace, $content); |
|
595 | + } |
|
596 | + } |
|
597 | + } |
|
598 | 598 | |
599 | - return $content; |
|
599 | + return $content; |
|
600 | 600 | } |
601 | 601 | add_filter('geodir_replace_location_variables', 'geodir_replace_location_variables'); |
602 | 602 | |
603 | 603 | |
604 | 604 | function geodir_location_replace_vars($location_array = array(), $sep = NULL, $gd_page = ''){ |
605 | 605 | |
606 | - global $wp; |
|
606 | + global $wp; |
|
607 | 607 | |
608 | - $location_manager = defined('GEODIRLOCATION_VERSION') ? true : false; |
|
609 | - |
|
610 | - if (empty($location_array)) { |
|
611 | - $location_array = geodir_get_current_location_terms('query_vars'); |
|
612 | - } |
|
613 | - |
|
614 | - $location_terms = array(); |
|
615 | - $location_terms['gd_neighbourhood'] = !empty($wp->query_vars['gd_neighbourhood']) ? $wp->query_vars['gd_neighbourhood'] : ''; |
|
616 | - $location_terms['gd_city'] = !empty($wp->query_vars['gd_city']) ? $wp->query_vars['gd_city'] : ''; |
|
617 | - $location_terms['gd_region'] = !empty($wp->query_vars['gd_region']) ? $wp->query_vars['gd_region'] : ''; |
|
618 | - $location_terms['gd_country'] = !empty($wp->query_vars['gd_country']) ? $wp->query_vars['gd_country'] : ''; |
|
619 | - |
|
620 | - $location_names = array(); |
|
621 | - foreach ($location_terms as $type => $location) { |
|
622 | - $location_name = $location; |
|
623 | - |
|
624 | - if (!empty($location_name)) { |
|
625 | - if ($location_manager) { |
|
626 | - $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; |
|
627 | - $location_name = get_actual_location_name($location_type, $location, true); |
|
628 | - } else { |
|
629 | - $location_name = preg_replace( '/-(\d+)$/', '', $location_name); |
|
630 | - $location_name = preg_replace( '/[_-]/', ' ', $location_name ); |
|
631 | - $location_name = __(geodir_ucwords($location_name), 'geodirectory'); |
|
632 | - } |
|
633 | - } |
|
634 | - |
|
635 | - $location_names[$type] = $location_name; |
|
636 | - } |
|
637 | - |
|
638 | - $location_single = ''; |
|
639 | - foreach ($location_terms as $type => $location) { |
|
640 | - if (!empty($location)) { |
|
641 | - if (!empty($location_names[$type])) { |
|
642 | - $location_single = $location_names[$type]; |
|
643 | - } else { |
|
644 | - if ($location_manager) { |
|
645 | - $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; |
|
646 | - $location_single = get_actual_location_name($location_type, $location, true); |
|
647 | - } else { |
|
648 | - $location_name = preg_replace( '/-(\d+)$/', '', $location); |
|
649 | - $location_name = preg_replace( '/[_-]/', ' ', $location_name ); |
|
650 | - $location_single = __(geodir_ucwords($location_name), 'geodirectory'); |
|
651 | - } |
|
652 | - } |
|
653 | - break; |
|
654 | - } |
|
655 | - } |
|
656 | - |
|
657 | - $full_location = array(); |
|
658 | - if (!empty($location_array)) { |
|
659 | - $location_array = array_reverse($location_array); |
|
660 | - |
|
661 | - foreach ($location_array as $type => $location) { |
|
662 | - if (!empty($location_names[$type])) { |
|
663 | - $location_name = $location_names[$type]; |
|
664 | - } else { |
|
665 | - if ($location_manager) { |
|
666 | - $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; |
|
667 | - $location_name = get_actual_location_name($location_type, $location, true); |
|
668 | - } else { |
|
669 | - $location_name = preg_replace( '/-(\d+)$/', '', $location); |
|
670 | - $location_name = preg_replace( '/[_-]/', ' ', $location_name ); |
|
671 | - $location_name = __(geodir_ucwords($location_name), 'geodirectory'); |
|
672 | - } |
|
673 | - } |
|
608 | + $location_manager = defined('GEODIRLOCATION_VERSION') ? true : false; |
|
609 | + |
|
610 | + if (empty($location_array)) { |
|
611 | + $location_array = geodir_get_current_location_terms('query_vars'); |
|
612 | + } |
|
613 | + |
|
614 | + $location_terms = array(); |
|
615 | + $location_terms['gd_neighbourhood'] = !empty($wp->query_vars['gd_neighbourhood']) ? $wp->query_vars['gd_neighbourhood'] : ''; |
|
616 | + $location_terms['gd_city'] = !empty($wp->query_vars['gd_city']) ? $wp->query_vars['gd_city'] : ''; |
|
617 | + $location_terms['gd_region'] = !empty($wp->query_vars['gd_region']) ? $wp->query_vars['gd_region'] : ''; |
|
618 | + $location_terms['gd_country'] = !empty($wp->query_vars['gd_country']) ? $wp->query_vars['gd_country'] : ''; |
|
619 | + |
|
620 | + $location_names = array(); |
|
621 | + foreach ($location_terms as $type => $location) { |
|
622 | + $location_name = $location; |
|
623 | + |
|
624 | + if (!empty($location_name)) { |
|
625 | + if ($location_manager) { |
|
626 | + $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; |
|
627 | + $location_name = get_actual_location_name($location_type, $location, true); |
|
628 | + } else { |
|
629 | + $location_name = preg_replace( '/-(\d+)$/', '', $location_name); |
|
630 | + $location_name = preg_replace( '/[_-]/', ' ', $location_name ); |
|
631 | + $location_name = __(geodir_ucwords($location_name), 'geodirectory'); |
|
632 | + } |
|
633 | + } |
|
674 | 634 | |
675 | - $full_location[] = $location_name; |
|
676 | - } |
|
635 | + $location_names[$type] = $location_name; |
|
636 | + } |
|
637 | + |
|
638 | + $location_single = ''; |
|
639 | + foreach ($location_terms as $type => $location) { |
|
640 | + if (!empty($location)) { |
|
641 | + if (!empty($location_names[$type])) { |
|
642 | + $location_single = $location_names[$type]; |
|
643 | + } else { |
|
644 | + if ($location_manager) { |
|
645 | + $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; |
|
646 | + $location_single = get_actual_location_name($location_type, $location, true); |
|
647 | + } else { |
|
648 | + $location_name = preg_replace( '/-(\d+)$/', '', $location); |
|
649 | + $location_name = preg_replace( '/[_-]/', ' ', $location_name ); |
|
650 | + $location_single = __(geodir_ucwords($location_name), 'geodirectory'); |
|
651 | + } |
|
652 | + } |
|
653 | + break; |
|
654 | + } |
|
655 | + } |
|
656 | + |
|
657 | + $full_location = array(); |
|
658 | + if (!empty($location_array)) { |
|
659 | + $location_array = array_reverse($location_array); |
|
660 | + |
|
661 | + foreach ($location_array as $type => $location) { |
|
662 | + if (!empty($location_names[$type])) { |
|
663 | + $location_name = $location_names[$type]; |
|
664 | + } else { |
|
665 | + if ($location_manager) { |
|
666 | + $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; |
|
667 | + $location_name = get_actual_location_name($location_type, $location, true); |
|
668 | + } else { |
|
669 | + $location_name = preg_replace( '/-(\d+)$/', '', $location); |
|
670 | + $location_name = preg_replace( '/[_-]/', ' ', $location_name ); |
|
671 | + $location_name = __(geodir_ucwords($location_name), 'geodirectory'); |
|
672 | + } |
|
673 | + } |
|
674 | + |
|
675 | + $full_location[] = $location_name; |
|
676 | + } |
|
677 | 677 | |
678 | - if (!empty($full_location)) { |
|
679 | - $full_location = array_unique($full_location); |
|
680 | - } |
|
681 | - } |
|
682 | - $full_location = !empty($full_location) ? implode(', ', $full_location): ''; |
|
678 | + if (!empty($full_location)) { |
|
679 | + $full_location = array_unique($full_location); |
|
680 | + } |
|
681 | + } |
|
682 | + $full_location = !empty($full_location) ? implode(', ', $full_location): ''; |
|
683 | 683 | |
684 | - if ( empty( $full_location ) ) { |
|
685 | - /** |
|
686 | - * Filter the text in meta description in full location is empty. |
|
687 | - * |
|
688 | - * @since 1.6.22 |
|
689 | - * |
|
690 | - * @param string $full_location Default: Empty. |
|
691 | - * @param array $location_array The array of location variables. |
|
692 | - * @param string $gd_page The page being filtered. |
|
693 | - * @param string $sep The separator. |
|
694 | - */ |
|
695 | - $full_location = apply_filters( 'geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep ); |
|
696 | - } |
|
684 | + if ( empty( $full_location ) ) { |
|
685 | + /** |
|
686 | + * Filter the text in meta description in full location is empty. |
|
687 | + * |
|
688 | + * @since 1.6.22 |
|
689 | + * |
|
690 | + * @param string $full_location Default: Empty. |
|
691 | + * @param array $location_array The array of location variables. |
|
692 | + * @param string $gd_page The page being filtered. |
|
693 | + * @param string $sep The separator. |
|
694 | + */ |
|
695 | + $full_location = apply_filters( 'geodir_meta_description_location_empty_text', '', $location_array, $gd_page, $sep ); |
|
696 | + } |
|
697 | 697 | |
698 | - if ( empty( $location_single ) ) { |
|
699 | - /** |
|
700 | - * Filter the text in meta description in single location is empty. |
|
701 | - * |
|
702 | - * @since 1.6.22 |
|
703 | - * |
|
704 | - * @param string $location_single Default: Empty. |
|
705 | - * @param array $location_array The array of location variables. |
|
706 | - * @param string $gd_page The page being filtered. |
|
707 | - * @param string $sep The separator. |
|
708 | - */ |
|
709 | - $location_single = apply_filters( 'geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep ); |
|
710 | - } |
|
711 | - |
|
712 | - $location_replace_vars = array(); |
|
713 | - $location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|'; |
|
714 | - $location_replace_vars['%%location%%'] = $full_location; |
|
715 | - $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : ''; |
|
716 | - $location_replace_vars['%%location_single%%'] = $location_single; |
|
717 | - $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : ''; |
|
718 | - |
|
719 | - foreach ($location_names as $type => $name) { |
|
720 | - $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; |
|
721 | - |
|
722 | - $location_replace_vars['%%location_' . $location_type . '%%'] = $name; |
|
723 | - $location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : ''; |
|
724 | - } |
|
725 | - |
|
726 | - /** |
|
727 | - * Filter the location terms variables to search & replace. |
|
728 | - * |
|
729 | - * @since 1.6.16 |
|
730 | - * @package GeoDirectory |
|
731 | - * |
|
732 | - * @param array $location_replace_vars The array of search & replace variables. |
|
733 | - * @param array $location_array The array of location variables. |
|
734 | - * @param string $gd_page The page being filtered. |
|
735 | - * @param string $sep The separator. |
|
736 | - */ |
|
737 | - return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep ); |
|
698 | + if ( empty( $location_single ) ) { |
|
699 | + /** |
|
700 | + * Filter the text in meta description in single location is empty. |
|
701 | + * |
|
702 | + * @since 1.6.22 |
|
703 | + * |
|
704 | + * @param string $location_single Default: Empty. |
|
705 | + * @param array $location_array The array of location variables. |
|
706 | + * @param string $gd_page The page being filtered. |
|
707 | + * @param string $sep The separator. |
|
708 | + */ |
|
709 | + $location_single = apply_filters( 'geodir_meta_description_single_location_empty_text', '', $location_array, $gd_page, $sep ); |
|
710 | + } |
|
711 | + |
|
712 | + $location_replace_vars = array(); |
|
713 | + $location_replace_vars['%%location_sep%%'] = $sep !== NULL ? $sep : '|'; |
|
714 | + $location_replace_vars['%%location%%'] = $full_location; |
|
715 | + $location_replace_vars['%%in_location%%'] = $full_location != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $full_location ) : ''; |
|
716 | + $location_replace_vars['%%location_single%%'] = $location_single; |
|
717 | + $location_replace_vars['%%in_location_single%%'] = $location_single != '' ? sprintf( _x('in %s','in location', 'geodirectory'), $location_single ) : ''; |
|
718 | + |
|
719 | + foreach ($location_names as $type => $name) { |
|
720 | + $location_type = strpos($type, 'gd_') === 0 ? substr($type, 3) : $type; |
|
721 | + |
|
722 | + $location_replace_vars['%%location_' . $location_type . '%%'] = $name; |
|
723 | + $location_replace_vars['%%in_location_' . $location_type . '%%'] = !empty($name) ? sprintf( _x('in %s','in location', 'geodirectory'), $name ) : ''; |
|
724 | + } |
|
725 | + |
|
726 | + /** |
|
727 | + * Filter the location terms variables to search & replace. |
|
728 | + * |
|
729 | + * @since 1.6.16 |
|
730 | + * @package GeoDirectory |
|
731 | + * |
|
732 | + * @param array $location_replace_vars The array of search & replace variables. |
|
733 | + * @param array $location_array The array of location variables. |
|
734 | + * @param string $gd_page The page being filtered. |
|
735 | + * @param string $sep The separator. |
|
736 | + */ |
|
737 | + return apply_filters( 'geodir_filter_location_replace_variables', $location_replace_vars, $location_array, $gd_page, $sep ); |
|
738 | 738 | } |
739 | 739 | \ No newline at end of file |