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