@@ -17,18 +17,18 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function geodir_is_login($redirect = false) |
19 | 19 | { |
20 | - global $current_user; |
|
21 | - if (!$current_user->ID) { |
|
22 | - if ($redirect) { |
|
23 | - ?> |
|
20 | + global $current_user; |
|
21 | + if (!$current_user->ID) { |
|
22 | + if ($redirect) { |
|
23 | + ?> |
|
24 | 24 | <script type="text/javascript"> |
25 | 25 | window.location.href = '<?php echo geodir_login_url();?>'; |
26 | 26 | </script> |
27 | 27 | <?php |
28 | - } else |
|
29 | - return false; |
|
30 | - } else |
|
31 | - return true; |
|
28 | + } else |
|
29 | + return false; |
|
30 | + } else |
|
31 | + return true; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -42,25 +42,25 @@ discard block |
||
42 | 42 | { |
43 | 43 | |
44 | 44 | // Redirect to https login if forced to use SSL |
45 | - if (force_ssl_admin() && !is_ssl()) { |
|
46 | - if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) { |
|
47 | - wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI'])); |
|
48 | - exit(); |
|
49 | - } else { |
|
50 | - wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
51 | - exit(); |
|
52 | - } |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Filter the login message. |
|
57 | - * |
|
58 | - * @since 1.0.0 |
|
59 | - * |
|
60 | - * @param string $message Login message. |
|
61 | - */ |
|
62 | - $message = apply_filters('login_message', $message); |
|
63 | - if (!empty($message)) echo $message . "\n"; |
|
45 | + if (force_ssl_admin() && !is_ssl()) { |
|
46 | + if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) { |
|
47 | + wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI'])); |
|
48 | + exit(); |
|
49 | + } else { |
|
50 | + wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
51 | + exit(); |
|
52 | + } |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Filter the login message. |
|
57 | + * |
|
58 | + * @since 1.0.0 |
|
59 | + * |
|
60 | + * @param string $message Login message. |
|
61 | + */ |
|
62 | + $message = apply_filters('login_message', $message); |
|
63 | + if (!empty($message)) echo $message . "\n"; |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
@@ -73,59 +73,59 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function geodir_get_site_email_id() |
75 | 75 | { |
76 | - if (get_option('site_email')) { |
|
76 | + if (get_option('site_email')) { |
|
77 | 77 | |
78 | - return get_option('site_email'); |
|
78 | + return get_option('site_email'); |
|
79 | 79 | |
80 | - } else { |
|
80 | + } else { |
|
81 | 81 | |
82 | - return get_option('admin_email'); |
|
82 | + return get_option('admin_email'); |
|
83 | 83 | |
84 | - } |
|
84 | + } |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | 89 | if (!function_exists('get_site_emailName')) { |
90 | - /** |
|
91 | - * Get site name for sending emails. |
|
92 | - * |
|
93 | - * @since 1.0.0 |
|
94 | - * @package GeoDirectory |
|
95 | - * @return string Site name. |
|
96 | - */ |
|
97 | - function get_site_emailName() |
|
90 | + /** |
|
91 | + * Get site name for sending emails. |
|
92 | + * |
|
93 | + * @since 1.0.0 |
|
94 | + * @package GeoDirectory |
|
95 | + * @return string Site name. |
|
96 | + */ |
|
97 | + function get_site_emailName() |
|
98 | 98 | |
99 | - { |
|
99 | + { |
|
100 | 100 | |
101 | - if (get_option('site_email_name')) { |
|
101 | + if (get_option('site_email_name')) { |
|
102 | 102 | |
103 | - return stripslashes(get_option('site_email_name')); |
|
103 | + return stripslashes(get_option('site_email_name')); |
|
104 | 104 | |
105 | - } else { |
|
105 | + } else { |
|
106 | 106 | |
107 | - return stripslashes(get_option('blogname')); |
|
107 | + return stripslashes(get_option('blogname')); |
|
108 | 108 | |
109 | - } |
|
109 | + } |
|
110 | 110 | |
111 | - } |
|
111 | + } |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if (!function_exists('is_allow_user_register')) { |
115 | - /** |
|
116 | - * Checks whether the site allowing user registration or not. |
|
117 | - * |
|
118 | - * @since 1.0.0 |
|
119 | - * @package GeoDirectory |
|
120 | - * @return bool|string |
|
121 | - */ |
|
122 | - function is_allow_user_register() |
|
115 | + /** |
|
116 | + * Checks whether the site allowing user registration or not. |
|
117 | + * |
|
118 | + * @since 1.0.0 |
|
119 | + * @package GeoDirectory |
|
120 | + * @return bool|string |
|
121 | + */ |
|
122 | + function is_allow_user_register() |
|
123 | 123 | |
124 | - { |
|
124 | + { |
|
125 | 125 | |
126 | - return get_option('users_can_register'); |
|
126 | + return get_option('users_can_register'); |
|
127 | 127 | |
128 | - } |
|
128 | + } |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -138,107 +138,107 @@ discard block |
||
138 | 138 | */ |
139 | 139 | function geodir_retrieve_password() |
140 | 140 | { |
141 | - global $wpdb; |
|
142 | - |
|
143 | - $errors = new WP_Error(); |
|
144 | - if (empty($_POST['user_login']) && empty($_POST['user_email'])) |
|
145 | - $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory')); |
|
146 | - |
|
147 | - if (strpos($_POST['user_login'], '@')) { |
|
148 | - //$user_data = get_user_by_email(trim($_POST['user_login'])); |
|
149 | - $user_data = get_user_by('email', trim($_POST['user_login'])); |
|
150 | - if (empty($user_data)) |
|
151 | - $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory')); |
|
152 | - } else { |
|
153 | - $login = trim($_POST['user_login']); |
|
154 | - $user_data = get_user_by('email', $login); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Called in the geodir_retrieve_password() function before any errors are set or any emails are sent. |
|
159 | - * |
|
160 | - * @since 1.0.0 |
|
161 | - */ |
|
162 | - do_action('lostpassword_post'); |
|
163 | - |
|
164 | - if ($errors->get_error_code()) |
|
165 | - return $errors; |
|
166 | - |
|
167 | - if (!$user_data) { |
|
168 | - $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory')); |
|
169 | - return $errors; |
|
170 | - } |
|
171 | - |
|
172 | - // redefining user_login ensures we return the right case in the email |
|
173 | - $user_login = $user_data->user_login; |
|
174 | - $user_email = $user_data->user_email; |
|
175 | - |
|
176 | - /** |
|
177 | - * Called in the geodir_retrieve_password() function before any emails are sent. |
|
178 | - * |
|
179 | - * @since 1.0.0 |
|
180 | - * @param string $user_login The users username. |
|
181 | - */ |
|
182 | - do_action('retrieve_password', $user_login); |
|
183 | - |
|
184 | - //////////////////////////////////// |
|
185 | - $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : ''; |
|
186 | - $user_login = $_POST['user_login']; |
|
187 | - |
|
188 | - $user = $wpdb->get_row( |
|
189 | - $wpdb->prepare( |
|
190 | - "SELECT * FROM $wpdb->users WHERE user_login like %s or user_email like %s", |
|
191 | - array($user_login, $user_login) |
|
192 | - ) |
|
193 | - ); |
|
194 | - |
|
195 | - if (empty($user)) |
|
196 | - return new WP_Error('invalid_key', __('Invalid key', 'geodirectory')); |
|
197 | - |
|
198 | - $new_pass = wp_generate_password(12, false); |
|
199 | - |
|
200 | - /** |
|
201 | - * Called in the geodir_retrieve_password() function before any emails are sent. |
|
202 | - * |
|
203 | - * @since 1.0.0 |
|
204 | - * @param object $user The user object. |
|
205 | - * @param string $new_pass The new pass being sent to the user. |
|
206 | - */ |
|
207 | - do_action('password_reset', $user, $new_pass); |
|
208 | - |
|
209 | - wp_set_password($new_pass, $user->ID); |
|
210 | - update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag. |
|
211 | - $message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>'; |
|
212 | - $message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>"; |
|
213 | - $message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>"; |
|
214 | - //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is : ".home_url()."/?ptype=login</p>"; |
|
215 | - //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>'; |
|
216 | - $user_email = $user_data->user_email; |
|
217 | - $user_name = geodir_get_client_name($user->ID); |
|
218 | - $fromEmail = geodir_get_site_email_id(); |
|
219 | - $fromEmailName = get_site_emailName(); |
|
220 | - $title = sprintf(__('[%s] Your new password', 'geodirectory'), get_option('blogname')); |
|
221 | - /** |
|
222 | - * Filter the password reset email subject part. |
|
223 | - * |
|
224 | - * @since 1.0.0 |
|
225 | - * |
|
226 | - * @param string $title Password reset email subject. |
|
227 | - */ |
|
228 | - $title = apply_filters('password_reset_title', $title); |
|
229 | - /** |
|
230 | - * Filter the password reset email message part. |
|
231 | - * |
|
232 | - * @since 1.0.0 |
|
233 | - * |
|
234 | - * @param string $message Password reset email message. |
|
235 | - * @param string $new_pass The new password string. |
|
236 | - */ |
|
237 | - $message = apply_filters('password_reset_message', $message, $new_pass); |
|
238 | - //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email |
|
239 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email |
|
240 | - |
|
241 | - return true; |
|
141 | + global $wpdb; |
|
142 | + |
|
143 | + $errors = new WP_Error(); |
|
144 | + if (empty($_POST['user_login']) && empty($_POST['user_email'])) |
|
145 | + $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory')); |
|
146 | + |
|
147 | + if (strpos($_POST['user_login'], '@')) { |
|
148 | + //$user_data = get_user_by_email(trim($_POST['user_login'])); |
|
149 | + $user_data = get_user_by('email', trim($_POST['user_login'])); |
|
150 | + if (empty($user_data)) |
|
151 | + $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory')); |
|
152 | + } else { |
|
153 | + $login = trim($_POST['user_login']); |
|
154 | + $user_data = get_user_by('email', $login); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Called in the geodir_retrieve_password() function before any errors are set or any emails are sent. |
|
159 | + * |
|
160 | + * @since 1.0.0 |
|
161 | + */ |
|
162 | + do_action('lostpassword_post'); |
|
163 | + |
|
164 | + if ($errors->get_error_code()) |
|
165 | + return $errors; |
|
166 | + |
|
167 | + if (!$user_data) { |
|
168 | + $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory')); |
|
169 | + return $errors; |
|
170 | + } |
|
171 | + |
|
172 | + // redefining user_login ensures we return the right case in the email |
|
173 | + $user_login = $user_data->user_login; |
|
174 | + $user_email = $user_data->user_email; |
|
175 | + |
|
176 | + /** |
|
177 | + * Called in the geodir_retrieve_password() function before any emails are sent. |
|
178 | + * |
|
179 | + * @since 1.0.0 |
|
180 | + * @param string $user_login The users username. |
|
181 | + */ |
|
182 | + do_action('retrieve_password', $user_login); |
|
183 | + |
|
184 | + //////////////////////////////////// |
|
185 | + $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : ''; |
|
186 | + $user_login = $_POST['user_login']; |
|
187 | + |
|
188 | + $user = $wpdb->get_row( |
|
189 | + $wpdb->prepare( |
|
190 | + "SELECT * FROM $wpdb->users WHERE user_login like %s or user_email like %s", |
|
191 | + array($user_login, $user_login) |
|
192 | + ) |
|
193 | + ); |
|
194 | + |
|
195 | + if (empty($user)) |
|
196 | + return new WP_Error('invalid_key', __('Invalid key', 'geodirectory')); |
|
197 | + |
|
198 | + $new_pass = wp_generate_password(12, false); |
|
199 | + |
|
200 | + /** |
|
201 | + * Called in the geodir_retrieve_password() function before any emails are sent. |
|
202 | + * |
|
203 | + * @since 1.0.0 |
|
204 | + * @param object $user The user object. |
|
205 | + * @param string $new_pass The new pass being sent to the user. |
|
206 | + */ |
|
207 | + do_action('password_reset', $user, $new_pass); |
|
208 | + |
|
209 | + wp_set_password($new_pass, $user->ID); |
|
210 | + update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag. |
|
211 | + $message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>'; |
|
212 | + $message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>"; |
|
213 | + $message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>"; |
|
214 | + //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is : ".home_url()."/?ptype=login</p>"; |
|
215 | + //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>'; |
|
216 | + $user_email = $user_data->user_email; |
|
217 | + $user_name = geodir_get_client_name($user->ID); |
|
218 | + $fromEmail = geodir_get_site_email_id(); |
|
219 | + $fromEmailName = get_site_emailName(); |
|
220 | + $title = sprintf(__('[%s] Your new password', 'geodirectory'), get_option('blogname')); |
|
221 | + /** |
|
222 | + * Filter the password reset email subject part. |
|
223 | + * |
|
224 | + * @since 1.0.0 |
|
225 | + * |
|
226 | + * @param string $title Password reset email subject. |
|
227 | + */ |
|
228 | + $title = apply_filters('password_reset_title', $title); |
|
229 | + /** |
|
230 | + * Filter the password reset email message part. |
|
231 | + * |
|
232 | + * @since 1.0.0 |
|
233 | + * |
|
234 | + * @param string $message Password reset email message. |
|
235 | + * @param string $new_pass The new password string. |
|
236 | + */ |
|
237 | + $message = apply_filters('password_reset_message', $message, $new_pass); |
|
238 | + //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email |
|
239 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email |
|
240 | + |
|
241 | + return true; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -253,80 +253,80 @@ discard block |
||
253 | 253 | */ |
254 | 254 | function geodir_register_new_user($user_login, $user_email) |
255 | 255 | { |
256 | - global $wpdb; |
|
257 | - $errors = new WP_Error(); |
|
258 | - |
|
259 | - |
|
260 | - $user_login = sanitize_user($user_login); |
|
261 | - $user_login = str_replace(",", "", $user_login); |
|
262 | - $user_email = str_replace(",", "", $user_email); |
|
263 | - /** |
|
264 | - * Filter the user registration email. |
|
265 | - * |
|
266 | - * @since 1.0.0 |
|
267 | - * |
|
268 | - * @param string $user_email User registration email. |
|
269 | - */ |
|
270 | - $user_email = apply_filters('user_registration_email', $user_email); |
|
271 | - |
|
272 | - |
|
273 | - if (get_option('geodir_allow_cpass')) { |
|
274 | - $user_pass = $_REQUEST['user_pass']; |
|
275 | - $user_pass2 = $_REQUEST['user_pass2']; |
|
276 | - // Check the password |
|
277 | - if ($user_pass != $user_pass2) { |
|
278 | - $errors->add('pass_match', __('ERROR: Passwords do not match.', 'geodirectory')); |
|
279 | - } elseif (strlen($user_pass) < 7) { |
|
280 | - $errors->add('pass_match', __('ERROR: Password must be 7 characters or more.', 'geodirectory')); |
|
281 | - } |
|
282 | - } |
|
283 | - |
|
284 | - // Check the username |
|
285 | - if ($user_login == '') |
|
286 | - $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory')); |
|
287 | - elseif (!validate_username($user_login)) { |
|
288 | - $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.', 'geodirectory')); |
|
289 | - $user_login = ''; |
|
290 | - } elseif (username_exists($user_login)) |
|
291 | - $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory')); |
|
292 | - |
|
293 | - // Check the e-mail address |
|
294 | - if ($user_email == '') { |
|
295 | - $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'geodirectory')); |
|
296 | - } elseif (!is_email($user_email)) { |
|
297 | - $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.', 'geodirectory')); |
|
298 | - $user_email = ''; |
|
299 | - } elseif (email_exists($user_email)) |
|
300 | - $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory')); |
|
301 | - |
|
302 | - /** |
|
303 | - * Called when registering a new user. |
|
304 | - * |
|
305 | - * This is a WordPress core hook. |
|
306 | - * |
|
307 | - * @link https://codex.wordpress.org/Plugin_API/Action_Reference/register_post |
|
308 | - * @since 1.0.0 |
|
309 | - */ |
|
310 | - do_action('register_post', $user_login, $user_email, $errors); |
|
311 | - /** |
|
312 | - * Filter the registration error messages. |
|
313 | - * |
|
314 | - * @since 1.0.0 |
|
315 | - * |
|
316 | - * @param object $errors Registration error messages. |
|
317 | - */ |
|
318 | - $errors = apply_filters('registration_errors', $errors,$user_login,$user_email); |
|
319 | - |
|
320 | - if ($errors->get_error_code()) |
|
321 | - return $errors; |
|
322 | - |
|
323 | - |
|
324 | - if (!isset($user_pass) || $user_pass == '') { |
|
325 | - $user_pass = wp_generate_password(12, false); |
|
326 | - } |
|
327 | - $user_id = wp_create_user($user_login, $user_pass, $user_email); |
|
328 | - $user_web = ''; |
|
329 | - /*$user_add1 = $_POST['user_add1']; |
|
256 | + global $wpdb; |
|
257 | + $errors = new WP_Error(); |
|
258 | + |
|
259 | + |
|
260 | + $user_login = sanitize_user($user_login); |
|
261 | + $user_login = str_replace(",", "", $user_login); |
|
262 | + $user_email = str_replace(",", "", $user_email); |
|
263 | + /** |
|
264 | + * Filter the user registration email. |
|
265 | + * |
|
266 | + * @since 1.0.0 |
|
267 | + * |
|
268 | + * @param string $user_email User registration email. |
|
269 | + */ |
|
270 | + $user_email = apply_filters('user_registration_email', $user_email); |
|
271 | + |
|
272 | + |
|
273 | + if (get_option('geodir_allow_cpass')) { |
|
274 | + $user_pass = $_REQUEST['user_pass']; |
|
275 | + $user_pass2 = $_REQUEST['user_pass2']; |
|
276 | + // Check the password |
|
277 | + if ($user_pass != $user_pass2) { |
|
278 | + $errors->add('pass_match', __('ERROR: Passwords do not match.', 'geodirectory')); |
|
279 | + } elseif (strlen($user_pass) < 7) { |
|
280 | + $errors->add('pass_match', __('ERROR: Password must be 7 characters or more.', 'geodirectory')); |
|
281 | + } |
|
282 | + } |
|
283 | + |
|
284 | + // Check the username |
|
285 | + if ($user_login == '') |
|
286 | + $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory')); |
|
287 | + elseif (!validate_username($user_login)) { |
|
288 | + $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.', 'geodirectory')); |
|
289 | + $user_login = ''; |
|
290 | + } elseif (username_exists($user_login)) |
|
291 | + $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory')); |
|
292 | + |
|
293 | + // Check the e-mail address |
|
294 | + if ($user_email == '') { |
|
295 | + $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'geodirectory')); |
|
296 | + } elseif (!is_email($user_email)) { |
|
297 | + $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.', 'geodirectory')); |
|
298 | + $user_email = ''; |
|
299 | + } elseif (email_exists($user_email)) |
|
300 | + $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory')); |
|
301 | + |
|
302 | + /** |
|
303 | + * Called when registering a new user. |
|
304 | + * |
|
305 | + * This is a WordPress core hook. |
|
306 | + * |
|
307 | + * @link https://codex.wordpress.org/Plugin_API/Action_Reference/register_post |
|
308 | + * @since 1.0.0 |
|
309 | + */ |
|
310 | + do_action('register_post', $user_login, $user_email, $errors); |
|
311 | + /** |
|
312 | + * Filter the registration error messages. |
|
313 | + * |
|
314 | + * @since 1.0.0 |
|
315 | + * |
|
316 | + * @param object $errors Registration error messages. |
|
317 | + */ |
|
318 | + $errors = apply_filters('registration_errors', $errors,$user_login,$user_email); |
|
319 | + |
|
320 | + if ($errors->get_error_code()) |
|
321 | + return $errors; |
|
322 | + |
|
323 | + |
|
324 | + if (!isset($user_pass) || $user_pass == '') { |
|
325 | + $user_pass = wp_generate_password(12, false); |
|
326 | + } |
|
327 | + $user_id = wp_create_user($user_login, $user_pass, $user_email); |
|
328 | + $user_web = ''; |
|
329 | + /*$user_add1 = $_POST['user_add1']; |
|
330 | 330 | $user_add2 = $_POST['user_add2']; |
331 | 331 | $user_city = $_POST['user_city']; |
332 | 332 | $user_state = $_POST['user_state']; |
@@ -335,79 +335,79 @@ discard block |
||
335 | 335 | $user_web = $_POST['user_web']; |
336 | 336 | $user_phone = $_POST['user_phone']; |
337 | 337 | $user_twitter = $_POST['user_twitter']; */ |
338 | - $user_fname = sanitize_user($_POST['user_fname']); |
|
339 | - $user_fname = str_replace(",", "", $user_fname); |
|
338 | + $user_fname = sanitize_user($_POST['user_fname']); |
|
339 | + $user_fname = str_replace(",", "", $user_fname); |
|
340 | 340 | if ( empty( $user_fname ) ) { |
341 | 341 | $user_fname = strstr( $user_login, '@', true ); |
342 | 342 | } |
343 | 343 | |
344 | - /** |
|
345 | - * Filter the submitted user meta. |
|
346 | - * |
|
347 | - * @since 1.0.0 |
|
348 | - * |
|
349 | - * @param int $user_id User ID. |
|
350 | - */ |
|
351 | - $user_address_info = apply_filters('geodir_manage_user_meta', array( |
|
352 | - "user_add1" => '', |
|
353 | - "user_add2" => '', |
|
354 | - "user_city" => '', |
|
355 | - "user_state" => '', |
|
356 | - "user_country" => '', |
|
357 | - "user_postalcode" => '', |
|
358 | - "user_phone" => '', |
|
359 | - "user_twitter" => '', |
|
360 | - "first_name" => $user_fname, |
|
361 | - "last_name" => '', |
|
362 | - ), $user_id); |
|
363 | - foreach ($user_address_info as $key => $val) { |
|
364 | - update_user_meta($user_id, $key, $val); // User Address Information Here |
|
365 | - } |
|
366 | - //update_user_meta($user_id, 'user_address_info', ($user_address_info)); // User Address Information Here |
|
367 | - $userName = $user_fname; |
|
368 | - update_user_meta($user_id, 'first_name', $userName); // User Address Information Here |
|
369 | - //update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here |
|
370 | - |
|
371 | - $user_nicename = geodir_generate_user_nicename( $userName, $user_login ); |
|
372 | - |
|
373 | - $updateUsersql = $wpdb->prepare("update $wpdb->users set user_url=%s, user_nicename=%s, display_name=%s where ID=%d", array($user_web, $user_nicename, $userName, $user_id)); |
|
374 | - |
|
375 | - $wpdb->query($updateUsersql); |
|
376 | - |
|
377 | - if (!$user_id) { |
|
378 | - $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'geodirectory'), get_option('admin_email'))); |
|
379 | - return $errors; |
|
380 | - } |
|
381 | - global $upload_folder_path; |
|
382 | - |
|
383 | - if ($user_id) { |
|
344 | + /** |
|
345 | + * Filter the submitted user meta. |
|
346 | + * |
|
347 | + * @since 1.0.0 |
|
348 | + * |
|
349 | + * @param int $user_id User ID. |
|
350 | + */ |
|
351 | + $user_address_info = apply_filters('geodir_manage_user_meta', array( |
|
352 | + "user_add1" => '', |
|
353 | + "user_add2" => '', |
|
354 | + "user_city" => '', |
|
355 | + "user_state" => '', |
|
356 | + "user_country" => '', |
|
357 | + "user_postalcode" => '', |
|
358 | + "user_phone" => '', |
|
359 | + "user_twitter" => '', |
|
360 | + "first_name" => $user_fname, |
|
361 | + "last_name" => '', |
|
362 | + ), $user_id); |
|
363 | + foreach ($user_address_info as $key => $val) { |
|
364 | + update_user_meta($user_id, $key, $val); // User Address Information Here |
|
365 | + } |
|
366 | + //update_user_meta($user_id, 'user_address_info', ($user_address_info)); // User Address Information Here |
|
367 | + $userName = $user_fname; |
|
368 | + update_user_meta($user_id, 'first_name', $userName); // User Address Information Here |
|
369 | + //update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here |
|
370 | + |
|
371 | + $user_nicename = geodir_generate_user_nicename( $userName, $user_login ); |
|
372 | + |
|
373 | + $updateUsersql = $wpdb->prepare("update $wpdb->users set user_url=%s, user_nicename=%s, display_name=%s where ID=%d", array($user_web, $user_nicename, $userName, $user_id)); |
|
374 | + |
|
375 | + $wpdb->query($updateUsersql); |
|
376 | + |
|
377 | + if (!$user_id) { |
|
378 | + $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'geodirectory'), get_option('admin_email'))); |
|
379 | + return $errors; |
|
380 | + } |
|
381 | + global $upload_folder_path; |
|
382 | + |
|
383 | + if ($user_id) { |
|
384 | 384 | clean_user_cache($user_id); |
385 | - /** |
|
386 | - * Called after registering a user and before the registration email is sent. |
|
387 | - * |
|
388 | - * @since 1.0.0 |
|
389 | - * @param int $user_id The user ID of the registered user. |
|
390 | - */ |
|
391 | - do_action('geodir_user_register', $user_id); |
|
392 | - ///////REGISTRATION EMAIL START////// |
|
393 | - $fromEmail = geodir_get_site_email_id(); |
|
394 | - $fromEmailName = get_site_emailName(); |
|
395 | - $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p> |
|
385 | + /** |
|
386 | + * Called after registering a user and before the registration email is sent. |
|
387 | + * |
|
388 | + * @since 1.0.0 |
|
389 | + * @param int $user_id The user ID of the registered user. |
|
390 | + */ |
|
391 | + do_action('geodir_user_register', $user_id); |
|
392 | + ///////REGISTRATION EMAIL START////// |
|
393 | + $fromEmail = geodir_get_site_email_id(); |
|
394 | + $fromEmailName = get_site_emailName(); |
|
395 | + $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p> |
|
396 | 396 | <p>' . __('Username:', 'geodirectory') . ' ' . $user_login . '</p> |
397 | 397 | <p>' . __('Password:', 'geodirectory') . ' ' . $user_pass . '</p>'); |
398 | 398 | |
399 | - /////////////customer email////////////// |
|
400 | - //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email |
|
401 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email |
|
402 | - //////REGISTRATION EMAIL END//////// |
|
403 | - } |
|
399 | + /////////////customer email////////////// |
|
400 | + //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email |
|
401 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email |
|
402 | + //////REGISTRATION EMAIL END//////// |
|
403 | + } |
|
404 | 404 | |
405 | - if (get_option('ptthemes_auto_login')) { |
|
406 | - $errors->add('auto_login', __('<strong>SUCCESS</strong>: Thank you for registering, please check your email for your login details.', 'geodirectory')); |
|
407 | - return $errors; |
|
408 | - } |
|
405 | + if (get_option('ptthemes_auto_login')) { |
|
406 | + $errors->add('auto_login', __('<strong>SUCCESS</strong>: Thank you for registering, please check your email for your login details.', 'geodirectory')); |
|
407 | + return $errors; |
|
408 | + } |
|
409 | 409 | |
410 | - return array($user_id, $user_pass); |
|
410 | + return array($user_id, $user_pass); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | /** |
@@ -420,333 +420,333 @@ discard block |
||
420 | 420 | */ |
421 | 421 | function geodir_user_signup() |
422 | 422 | { |
423 | - global $errors; |
|
424 | - $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; |
|
425 | - |
|
426 | - $errors = new WP_Error(); |
|
427 | - |
|
428 | - if (isset($_GET['key'])) |
|
429 | - $action = 'resetpass'; |
|
430 | - |
|
431 | - // validate action so as to default to the login screen |
|
432 | - if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action)) |
|
433 | - $action = 'login'; |
|
434 | - |
|
435 | - nocache_headers(); |
|
436 | - |
|
437 | - if (defined('RELOCATE')) { // Move flag is set |
|
438 | - if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) |
|
439 | - $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); |
|
440 | - |
|
441 | - $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; |
|
442 | - if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) |
|
443 | - update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); |
|
444 | - } |
|
445 | - |
|
446 | - //Set a cookie now to see if they are supported by the browser. |
|
447 | - //setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); |
|
448 | - if (SITECOOKIEPATH != COOKIEPATH) |
|
449 | - setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); |
|
450 | - |
|
451 | - /** |
|
452 | - * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page. |
|
453 | - * |
|
454 | - * Used dynamic hook login_form_$action |
|
455 | - * |
|
456 | - * @since 1.0.0 |
|
457 | - */ |
|
458 | - do_action('login_form_' . $action); |
|
459 | - |
|
460 | - $http_post = ('POST' == $_SERVER['REQUEST_METHOD']); |
|
461 | - |
|
462 | - switch ($action): |
|
463 | - |
|
464 | - case 'logout' : |
|
465 | - //check_admin_referer('log-out'); |
|
466 | - wp_logout(); |
|
467 | - |
|
468 | - $redirect_to = $_SERVER['HTTP_REFERER']; |
|
469 | - //$redirect_to = home_url().'/?ptype=login&loggedout=true'; |
|
470 | - if (isset($_REQUEST['redirect_to'])) |
|
471 | - $redirect_to = $_REQUEST['redirect_to']; |
|
472 | - $redirect_to = home_url(); |
|
473 | - wp_safe_redirect($redirect_to); |
|
474 | - exit(); |
|
475 | - |
|
476 | - break; |
|
477 | - |
|
478 | - case 'lostpassword' : |
|
479 | - case 'retrievepassword' : |
|
480 | - if ($http_post) { |
|
481 | - $errors = geodir_retrieve_password(); |
|
482 | - $error_message = isset($errors->errors['invalid_email'][0]) ? $errors->errors['invalid_email'][0] : ''; |
|
483 | - if (!is_wp_error($errors)) { |
|
484 | - wp_redirect(geodir_login_url(array('checkemail'=>'confirm'))); |
|
485 | - gd_die(); |
|
486 | - } else { |
|
487 | - wp_redirect(geodir_login_url(array('forgot' => 1, 'emsg'=>'fw'))); |
|
488 | - gd_die(); |
|
489 | - } |
|
490 | - } |
|
491 | - if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory')); |
|
492 | - /** |
|
493 | - * Called in the geodir_user_signup() function during the lostpassword case. |
|
494 | - * |
|
495 | - * @since 1.0.0 |
|
496 | - */ |
|
497 | - do_action('lost_password'); |
|
498 | - $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>'; |
|
499 | - $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; |
|
500 | - |
|
501 | - break; |
|
502 | - |
|
503 | - case 'resetpass' : |
|
504 | - case 'rp' : |
|
505 | - $errors = reset_password($_GET['key'], $_GET['login']); |
|
506 | - |
|
507 | - if (!is_wp_error($errors)) { |
|
508 | - wp_redirect(geodir_login_url(array('checkemail'=>'newpass'))); |
|
509 | - exit(); |
|
510 | - } |
|
511 | - |
|
512 | - wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword'))); |
|
513 | - exit(); |
|
514 | - |
|
515 | - break; |
|
516 | - |
|
517 | - case 'register' : |
|
518 | - ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## |
|
519 | - if (!get_option('users_can_register')) { |
|
520 | - wp_redirect(geodir_login_url(array('emsg'=>'regnewusr'))); |
|
521 | - exit(); |
|
522 | - } |
|
523 | - ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## |
|
524 | - global $user_email, $user_fname; |
|
525 | - $user_login = ''; |
|
526 | - $user_email = ''; |
|
527 | - if ($http_post) { |
|
528 | - $user_login = $_POST['user_email']; |
|
529 | - $user_email = $_POST['user_email']; |
|
530 | - $user_fname = $_POST['user_fname']; |
|
531 | - |
|
532 | - $errors = geodir_register_new_user($user_login, $user_email); |
|
533 | - |
|
534 | - /* display error in registration form */ |
|
535 | - if (is_wp_error($errors)) { |
|
536 | - $error_code = $errors->get_error_code(); |
|
537 | - $error_message = $errors->get_error_message($error_code); |
|
538 | - if (!isset($_POST['user_login']) && ($error_code == 'empty_username' || $error_code == 'invalid_username' || $error_code == 'username_exists')) { |
|
539 | - if ($error_code == 'empty_username') { |
|
540 | - $error_code = 'empty_email'; |
|
541 | - } else if ($error_code == 'invalid_username') { |
|
542 | - $error_code = 'invalid_email'; |
|
543 | - } else if ($error_code == 'username_exists') { |
|
544 | - $error_code = 'email_exists'; |
|
545 | - } |
|
546 | - |
|
547 | - $error_message = $errors->get_error_message($error_code); |
|
548 | - } |
|
549 | - global $geodir_signup_error; |
|
550 | - $geodir_signup_error = $error_message; |
|
551 | - } |
|
552 | - |
|
553 | - if (!is_wp_error($errors)) { |
|
554 | - $_POST['log'] = $user_login; |
|
555 | - $_POST['pwd'] = $errors[1]; |
|
556 | - $_POST['testcookie'] = 1; |
|
557 | - |
|
558 | - $secure_cookie = ''; |
|
559 | - // If the user wants ssl but the session is not ssl, force a secure cookie. |
|
560 | - if (!empty($_POST['log'])) { |
|
561 | - $user_name = sanitize_user($_POST['log']); |
|
562 | - if ($user = get_user_by('email', $user_name)) { |
|
563 | - if (get_user_option('use_ssl', $user->ID)) { |
|
564 | - $secure_cookie = true; |
|
565 | - force_ssl_admin(true); |
|
566 | - } |
|
567 | - } |
|
568 | - } |
|
569 | - |
|
570 | - $redirect_to = $_REQUEST['redirect_to']; |
|
571 | - |
|
572 | - if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') { |
|
573 | - if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], home_url())) { |
|
574 | - $redirect_to = $_SERVER['HTTP_REFERER']; |
|
575 | - } else { |
|
576 | - $redirect_to = home_url(); |
|
577 | - } |
|
578 | - |
|
579 | - } |
|
580 | - |
|
581 | - if (isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '') { |
|
582 | - |
|
583 | - $redirect_to = $_REQUEST['redirect_add_listing']; |
|
584 | - } |
|
585 | - |
|
586 | - |
|
587 | - if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) |
|
588 | - $secure_cookie = false; |
|
589 | - |
|
590 | - $user = wp_signon('', $secure_cookie); |
|
591 | - |
|
592 | - $requested_redirect_to = isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '' ? $_REQUEST['redirect_add_listing'] : (isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''); |
|
593 | - /** |
|
594 | - * Filter the login redirect URL. |
|
595 | - * |
|
596 | - * @since 1.4.9 |
|
597 | - * @param string $redirect_to The redirect destination URL. |
|
598 | - * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
|
599 | - * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
|
600 | - */ |
|
601 | - $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user); |
|
602 | - |
|
603 | - |
|
604 | - if (!is_wp_error($user)) { |
|
605 | - wp_safe_redirect($redirect_to); |
|
606 | - exit(); |
|
607 | - } |
|
608 | - exit(); |
|
609 | - } |
|
610 | - } |
|
611 | - |
|
612 | - break; |
|
613 | - |
|
614 | - case 'login' : |
|
615 | - default: |
|
616 | - $secure_cookie = ''; |
|
617 | - |
|
618 | - if (!empty($_POST['log'])) { |
|
619 | - $user_name = sanitize_user($_POST['log']); |
|
620 | - if ($user = get_user_by('login', $user_name)) { |
|
621 | - |
|
622 | - if (get_user_option('use_ssl', $user->ID)) { |
|
623 | - $secure_cookie = true; |
|
624 | - force_ssl_admin(true); |
|
625 | - } |
|
626 | - } elseif ($user = get_user_by('email', $user_name)) { |
|
627 | - $_POST['log'] = $user->user_login; // If signing in by email, set the username for normal WP login |
|
628 | - if (get_user_option('use_ssl', $user->ID)) { |
|
629 | - $secure_cookie = true; |
|
630 | - force_ssl_admin(true); |
|
631 | - } |
|
632 | - } |
|
633 | - } |
|
634 | - /////////////////////////// |
|
635 | - if (isset($_REQUEST['redirect_add_listing'])) { |
|
636 | - $_REQUEST['redirect_to'] = $_REQUEST['redirect_add_listing']; |
|
637 | - } |
|
638 | - |
|
639 | - |
|
640 | - if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') { |
|
641 | - if (is_user_logged_in()) : |
|
642 | - $user_ID = !empty($user->ID) ? $user->ID : get_current_user_id(); |
|
643 | - $post_types = geodir_get_posttypes(); |
|
423 | + global $errors; |
|
424 | + $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; |
|
425 | + |
|
426 | + $errors = new WP_Error(); |
|
427 | + |
|
428 | + if (isset($_GET['key'])) |
|
429 | + $action = 'resetpass'; |
|
430 | + |
|
431 | + // validate action so as to default to the login screen |
|
432 | + if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action)) |
|
433 | + $action = 'login'; |
|
434 | + |
|
435 | + nocache_headers(); |
|
436 | + |
|
437 | + if (defined('RELOCATE')) { // Move flag is set |
|
438 | + if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) |
|
439 | + $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); |
|
440 | + |
|
441 | + $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; |
|
442 | + if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) |
|
443 | + update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); |
|
444 | + } |
|
445 | + |
|
446 | + //Set a cookie now to see if they are supported by the browser. |
|
447 | + //setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); |
|
448 | + if (SITECOOKIEPATH != COOKIEPATH) |
|
449 | + setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); |
|
450 | + |
|
451 | + /** |
|
452 | + * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page. |
|
453 | + * |
|
454 | + * Used dynamic hook login_form_$action |
|
455 | + * |
|
456 | + * @since 1.0.0 |
|
457 | + */ |
|
458 | + do_action('login_form_' . $action); |
|
459 | + |
|
460 | + $http_post = ('POST' == $_SERVER['REQUEST_METHOD']); |
|
461 | + |
|
462 | + switch ($action): |
|
463 | + |
|
464 | + case 'logout' : |
|
465 | + //check_admin_referer('log-out'); |
|
466 | + wp_logout(); |
|
467 | + |
|
468 | + $redirect_to = $_SERVER['HTTP_REFERER']; |
|
469 | + //$redirect_to = home_url().'/?ptype=login&loggedout=true'; |
|
470 | + if (isset($_REQUEST['redirect_to'])) |
|
471 | + $redirect_to = $_REQUEST['redirect_to']; |
|
472 | + $redirect_to = home_url(); |
|
473 | + wp_safe_redirect($redirect_to); |
|
474 | + exit(); |
|
475 | + |
|
476 | + break; |
|
477 | + |
|
478 | + case 'lostpassword' : |
|
479 | + case 'retrievepassword' : |
|
480 | + if ($http_post) { |
|
481 | + $errors = geodir_retrieve_password(); |
|
482 | + $error_message = isset($errors->errors['invalid_email'][0]) ? $errors->errors['invalid_email'][0] : ''; |
|
483 | + if (!is_wp_error($errors)) { |
|
484 | + wp_redirect(geodir_login_url(array('checkemail'=>'confirm'))); |
|
485 | + gd_die(); |
|
486 | + } else { |
|
487 | + wp_redirect(geodir_login_url(array('forgot' => 1, 'emsg'=>'fw'))); |
|
488 | + gd_die(); |
|
489 | + } |
|
490 | + } |
|
491 | + if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory')); |
|
492 | + /** |
|
493 | + * Called in the geodir_user_signup() function during the lostpassword case. |
|
494 | + * |
|
495 | + * @since 1.0.0 |
|
496 | + */ |
|
497 | + do_action('lost_password'); |
|
498 | + $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>'; |
|
499 | + $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; |
|
500 | + |
|
501 | + break; |
|
502 | + |
|
503 | + case 'resetpass' : |
|
504 | + case 'rp' : |
|
505 | + $errors = reset_password($_GET['key'], $_GET['login']); |
|
506 | + |
|
507 | + if (!is_wp_error($errors)) { |
|
508 | + wp_redirect(geodir_login_url(array('checkemail'=>'newpass'))); |
|
509 | + exit(); |
|
510 | + } |
|
511 | + |
|
512 | + wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword'))); |
|
513 | + exit(); |
|
514 | + |
|
515 | + break; |
|
516 | + |
|
517 | + case 'register' : |
|
518 | + ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## |
|
519 | + if (!get_option('users_can_register')) { |
|
520 | + wp_redirect(geodir_login_url(array('emsg'=>'regnewusr'))); |
|
521 | + exit(); |
|
522 | + } |
|
523 | + ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## |
|
524 | + global $user_email, $user_fname; |
|
525 | + $user_login = ''; |
|
526 | + $user_email = ''; |
|
527 | + if ($http_post) { |
|
528 | + $user_login = $_POST['user_email']; |
|
529 | + $user_email = $_POST['user_email']; |
|
530 | + $user_fname = $_POST['user_fname']; |
|
531 | + |
|
532 | + $errors = geodir_register_new_user($user_login, $user_email); |
|
533 | + |
|
534 | + /* display error in registration form */ |
|
535 | + if (is_wp_error($errors)) { |
|
536 | + $error_code = $errors->get_error_code(); |
|
537 | + $error_message = $errors->get_error_message($error_code); |
|
538 | + if (!isset($_POST['user_login']) && ($error_code == 'empty_username' || $error_code == 'invalid_username' || $error_code == 'username_exists')) { |
|
539 | + if ($error_code == 'empty_username') { |
|
540 | + $error_code = 'empty_email'; |
|
541 | + } else if ($error_code == 'invalid_username') { |
|
542 | + $error_code = 'invalid_email'; |
|
543 | + } else if ($error_code == 'username_exists') { |
|
544 | + $error_code = 'email_exists'; |
|
545 | + } |
|
546 | + |
|
547 | + $error_message = $errors->get_error_message($error_code); |
|
548 | + } |
|
549 | + global $geodir_signup_error; |
|
550 | + $geodir_signup_error = $error_message; |
|
551 | + } |
|
552 | + |
|
553 | + if (!is_wp_error($errors)) { |
|
554 | + $_POST['log'] = $user_login; |
|
555 | + $_POST['pwd'] = $errors[1]; |
|
556 | + $_POST['testcookie'] = 1; |
|
557 | + |
|
558 | + $secure_cookie = ''; |
|
559 | + // If the user wants ssl but the session is not ssl, force a secure cookie. |
|
560 | + if (!empty($_POST['log'])) { |
|
561 | + $user_name = sanitize_user($_POST['log']); |
|
562 | + if ($user = get_user_by('email', $user_name)) { |
|
563 | + if (get_user_option('use_ssl', $user->ID)) { |
|
564 | + $secure_cookie = true; |
|
565 | + force_ssl_admin(true); |
|
566 | + } |
|
567 | + } |
|
568 | + } |
|
569 | + |
|
570 | + $redirect_to = $_REQUEST['redirect_to']; |
|
571 | + |
|
572 | + if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') { |
|
573 | + if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], home_url())) { |
|
574 | + $redirect_to = $_SERVER['HTTP_REFERER']; |
|
575 | + } else { |
|
576 | + $redirect_to = home_url(); |
|
577 | + } |
|
578 | + |
|
579 | + } |
|
580 | + |
|
581 | + if (isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '') { |
|
582 | + |
|
583 | + $redirect_to = $_REQUEST['redirect_add_listing']; |
|
584 | + } |
|
585 | + |
|
586 | + |
|
587 | + if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) |
|
588 | + $secure_cookie = false; |
|
589 | + |
|
590 | + $user = wp_signon('', $secure_cookie); |
|
591 | + |
|
592 | + $requested_redirect_to = isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '' ? $_REQUEST['redirect_add_listing'] : (isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''); |
|
593 | + /** |
|
594 | + * Filter the login redirect URL. |
|
595 | + * |
|
596 | + * @since 1.4.9 |
|
597 | + * @param string $redirect_to The redirect destination URL. |
|
598 | + * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
|
599 | + * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
|
600 | + */ |
|
601 | + $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user); |
|
602 | + |
|
603 | + |
|
604 | + if (!is_wp_error($user)) { |
|
605 | + wp_safe_redirect($redirect_to); |
|
606 | + exit(); |
|
607 | + } |
|
608 | + exit(); |
|
609 | + } |
|
610 | + } |
|
611 | + |
|
612 | + break; |
|
613 | + |
|
614 | + case 'login' : |
|
615 | + default: |
|
616 | + $secure_cookie = ''; |
|
617 | + |
|
618 | + if (!empty($_POST['log'])) { |
|
619 | + $user_name = sanitize_user($_POST['log']); |
|
620 | + if ($user = get_user_by('login', $user_name)) { |
|
621 | + |
|
622 | + if (get_user_option('use_ssl', $user->ID)) { |
|
623 | + $secure_cookie = true; |
|
624 | + force_ssl_admin(true); |
|
625 | + } |
|
626 | + } elseif ($user = get_user_by('email', $user_name)) { |
|
627 | + $_POST['log'] = $user->user_login; // If signing in by email, set the username for normal WP login |
|
628 | + if (get_user_option('use_ssl', $user->ID)) { |
|
629 | + $secure_cookie = true; |
|
630 | + force_ssl_admin(true); |
|
631 | + } |
|
632 | + } |
|
633 | + } |
|
634 | + /////////////////////////// |
|
635 | + if (isset($_REQUEST['redirect_add_listing'])) { |
|
636 | + $_REQUEST['redirect_to'] = $_REQUEST['redirect_add_listing']; |
|
637 | + } |
|
638 | + |
|
639 | + |
|
640 | + if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') { |
|
641 | + if (is_user_logged_in()) : |
|
642 | + $user_ID = !empty($user->ID) ? $user->ID : get_current_user_id(); |
|
643 | + $post_types = geodir_get_posttypes(); |
|
644 | 644 | |
645 | - if ( !empty( $_REQUEST['stype'] ) ) { |
|
646 | - $dashboard_post_type = sanitize_text_field($_REQUEST['stype']); |
|
647 | - } else { |
|
648 | - $user_listings = geodir_user_post_listing_count( $user_ID ); |
|
649 | - if ( !empty( $user_listings ) && $dashboard_post_types = array_keys( $user_listings ) ) { |
|
650 | - $dashboard_post_type = $dashboard_post_types[0]; |
|
651 | - } |
|
652 | - } |
|
653 | - if ( !( !empty( $dashboard_post_type ) && in_array( $dashboard_post_type, $post_types ) ) ) { |
|
654 | - $dashboard_post_type = $post_types[0]; |
|
655 | - } |
|
645 | + if ( !empty( $_REQUEST['stype'] ) ) { |
|
646 | + $dashboard_post_type = sanitize_text_field($_REQUEST['stype']); |
|
647 | + } else { |
|
648 | + $user_listings = geodir_user_post_listing_count( $user_ID ); |
|
649 | + if ( !empty( $user_listings ) && $dashboard_post_types = array_keys( $user_listings ) ) { |
|
650 | + $dashboard_post_type = $dashboard_post_types[0]; |
|
651 | + } |
|
652 | + } |
|
653 | + if ( !( !empty( $dashboard_post_type ) && in_array( $dashboard_post_type, $post_types ) ) ) { |
|
654 | + $dashboard_post_type = $post_types[0]; |
|
655 | + } |
|
656 | 656 | |
657 | - $author_link = get_author_posts_url($user_ID); |
|
658 | - $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $dashboard_post_type), false); |
|
659 | - |
|
660 | - /** |
|
661 | - * Filter the author link. |
|
662 | - * |
|
663 | - * @since 1.0.0 |
|
664 | - * |
|
665 | - * @param string $default_author_link Default author link. |
|
666 | - * @param int $user_ID The user ID. |
|
667 | - */ |
|
668 | - $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID); |
|
669 | - |
|
670 | - $_REQUEST['redirect_to'] = $default_author_link; |
|
671 | - else: |
|
672 | - $_REQUEST['redirect_to'] = home_url(); |
|
673 | - endif; |
|
674 | - |
|
675 | - } |
|
676 | - if (isset($_REQUEST['redirect_to'])) { |
|
677 | - $redirect_to = $_REQUEST['redirect_to']; |
|
678 | - // Redirect to https if user wants ssl |
|
679 | - if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) |
|
680 | - $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
|
681 | - } else { |
|
682 | - $redirect_to = admin_url(); |
|
683 | - } |
|
684 | - |
|
685 | - if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) |
|
686 | - $secure_cookie = false; |
|
687 | - $user = wp_signon('', $secure_cookie); |
|
688 | - |
|
689 | - |
|
690 | - /** |
|
691 | - * Filter the login redirect URL. |
|
692 | - * |
|
693 | - * @since 1.4.9 |
|
694 | - * @param string $redirect_to The redirect destination URL. |
|
695 | - * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
|
696 | - */ |
|
697 | - $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user); |
|
698 | - |
|
699 | - if (is_wp_error($user)) { |
|
700 | - if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') { |
|
701 | - wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1'); |
|
702 | - } |
|
703 | - } |
|
704 | - if (!is_wp_error($user)) { |
|
705 | - |
|
706 | - // Some servers are not logging the user in properly after wp_signon, se we set the user here. |
|
707 | - //wp_set_current_user($user->ID); |
|
708 | - //echo '###';exit; |
|
709 | - |
|
710 | - if ($redirect_to) { |
|
711 | - wp_redirect($redirect_to); |
|
712 | - } else { |
|
713 | - wp_redirect(home_url()); |
|
714 | - } |
|
715 | - gd_die(); |
|
716 | - } |
|
717 | - |
|
718 | - $errors = $user; |
|
719 | - |
|
720 | - // Clear errors if loggedout is set. |
|
721 | - if (!empty($_GET['loggedout'])) |
|
722 | - $errors = new WP_Error(); |
|
723 | - // If cookies are disabled we can't log in even with a valid user+pass |
|
724 | - if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) |
|
725 | - $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory')); |
|
726 | - |
|
727 | - // Some parts of this script use the main login form to display a message |
|
728 | - if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) { |
|
729 | - $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>'; |
|
730 | - } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) { |
|
731 | - $successmsg = USER_REG_NOT_ALLOW_MSG; |
|
732 | - } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) { |
|
733 | - $successmsg = EMAIL_CONFIRM_LINK_MSG; |
|
734 | - } elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) { |
|
735 | - $successmsg = NEW_PW_EMAIL_MSG; |
|
736 | - } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) { |
|
737 | - $successmsg = REG_COMPLETE_MSG; |
|
738 | - } |
|
739 | - |
|
740 | - if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) { |
|
741 | - if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') { |
|
742 | - wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); |
|
743 | - } else { |
|
744 | - wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to'])))); |
|
745 | - } |
|
746 | - gd_die(); |
|
747 | - } |
|
748 | - break; |
|
749 | - endswitch; // end action switch |
|
657 | + $author_link = get_author_posts_url($user_ID); |
|
658 | + $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $dashboard_post_type), false); |
|
659 | + |
|
660 | + /** |
|
661 | + * Filter the author link. |
|
662 | + * |
|
663 | + * @since 1.0.0 |
|
664 | + * |
|
665 | + * @param string $default_author_link Default author link. |
|
666 | + * @param int $user_ID The user ID. |
|
667 | + */ |
|
668 | + $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID); |
|
669 | + |
|
670 | + $_REQUEST['redirect_to'] = $default_author_link; |
|
671 | + else: |
|
672 | + $_REQUEST['redirect_to'] = home_url(); |
|
673 | + endif; |
|
674 | + |
|
675 | + } |
|
676 | + if (isset($_REQUEST['redirect_to'])) { |
|
677 | + $redirect_to = $_REQUEST['redirect_to']; |
|
678 | + // Redirect to https if user wants ssl |
|
679 | + if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) |
|
680 | + $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
|
681 | + } else { |
|
682 | + $redirect_to = admin_url(); |
|
683 | + } |
|
684 | + |
|
685 | + if (!$secure_cookie && is_ssl() && force_ssl_admin() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) |
|
686 | + $secure_cookie = false; |
|
687 | + $user = wp_signon('', $secure_cookie); |
|
688 | + |
|
689 | + |
|
690 | + /** |
|
691 | + * Filter the login redirect URL. |
|
692 | + * |
|
693 | + * @since 1.4.9 |
|
694 | + * @param string $redirect_to The redirect destination URL. |
|
695 | + * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
|
696 | + */ |
|
697 | + $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user); |
|
698 | + |
|
699 | + if (is_wp_error($user)) { |
|
700 | + if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') { |
|
701 | + wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1'); |
|
702 | + } |
|
703 | + } |
|
704 | + if (!is_wp_error($user)) { |
|
705 | + |
|
706 | + // Some servers are not logging the user in properly after wp_signon, se we set the user here. |
|
707 | + //wp_set_current_user($user->ID); |
|
708 | + //echo '###';exit; |
|
709 | + |
|
710 | + if ($redirect_to) { |
|
711 | + wp_redirect($redirect_to); |
|
712 | + } else { |
|
713 | + wp_redirect(home_url()); |
|
714 | + } |
|
715 | + gd_die(); |
|
716 | + } |
|
717 | + |
|
718 | + $errors = $user; |
|
719 | + |
|
720 | + // Clear errors if loggedout is set. |
|
721 | + if (!empty($_GET['loggedout'])) |
|
722 | + $errors = new WP_Error(); |
|
723 | + // If cookies are disabled we can't log in even with a valid user+pass |
|
724 | + if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) |
|
725 | + $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory')); |
|
726 | + |
|
727 | + // Some parts of this script use the main login form to display a message |
|
728 | + if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) { |
|
729 | + $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>'; |
|
730 | + } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) { |
|
731 | + $successmsg = USER_REG_NOT_ALLOW_MSG; |
|
732 | + } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) { |
|
733 | + $successmsg = EMAIL_CONFIRM_LINK_MSG; |
|
734 | + } elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) { |
|
735 | + $successmsg = NEW_PW_EMAIL_MSG; |
|
736 | + } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) { |
|
737 | + $successmsg = REG_COMPLETE_MSG; |
|
738 | + } |
|
739 | + |
|
740 | + if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) { |
|
741 | + if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') { |
|
742 | + wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); |
|
743 | + } else { |
|
744 | + wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to'])))); |
|
745 | + } |
|
746 | + gd_die(); |
|
747 | + } |
|
748 | + break; |
|
749 | + endswitch; // end action switch |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | function geodir_generate_user_nicename( $display_name, $user_login ) { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | if ($redirect) { |
23 | 23 | ?> |
24 | 24 | <script type="text/javascript"> |
25 | - window.location.href = '<?php echo geodir_login_url();?>'; |
|
25 | + window.location.href = '<?php echo geodir_login_url(); ?>'; |
|
26 | 26 | </script> |
27 | 27 | <?php |
28 | 28 | } else |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI'])); |
48 | 48 | exit(); |
49 | 49 | } else { |
50 | - wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
50 | + wp_redirect('https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
51 | 51 | exit(); |
52 | 52 | } |
53 | 53 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param string $message Login message. |
61 | 61 | */ |
62 | 62 | $message = apply_filters('login_message', $message); |
63 | - if (!empty($message)) echo $message . "\n"; |
|
63 | + if (!empty($message)) echo $message."\n"; |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | |
209 | 209 | wp_set_password($new_pass, $user->ID); |
210 | 210 | update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag. |
211 | - $message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>'; |
|
212 | - $message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>"; |
|
213 | - $message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>"; |
|
211 | + $message = '<p><b>'.__('Your login Information :', 'geodirectory').'</b></p>'; |
|
212 | + $message .= '<p>'.sprintf(__('Username: %s', 'geodirectory'), $user->user_login)."</p>"; |
|
213 | + $message .= '<p>'.sprintf(__('Password: %s', 'geodirectory'), $new_pass)."</p>"; |
|
214 | 214 | //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is : ".home_url()."/?ptype=login</p>"; |
215 | 215 | //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>'; |
216 | 216 | $user_email = $user_data->user_email; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | $message = apply_filters('password_reset_message', $message, $new_pass); |
238 | 238 | //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email |
239 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email |
|
239 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID); ///forgot password email |
|
240 | 240 | |
241 | 241 | return true; |
242 | 242 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @param object $errors Registration error messages. |
317 | 317 | */ |
318 | - $errors = apply_filters('registration_errors', $errors,$user_login,$user_email); |
|
318 | + $errors = apply_filters('registration_errors', $errors, $user_login, $user_email); |
|
319 | 319 | |
320 | 320 | if ($errors->get_error_code()) |
321 | 321 | return $errors; |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | $user_twitter = $_POST['user_twitter']; */ |
338 | 338 | $user_fname = sanitize_user($_POST['user_fname']); |
339 | 339 | $user_fname = str_replace(",", "", $user_fname); |
340 | - if ( empty( $user_fname ) ) { |
|
341 | - $user_fname = strstr( $user_login, '@', true ); |
|
340 | + if (empty($user_fname)) { |
|
341 | + $user_fname = strstr($user_login, '@', true); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | update_user_meta($user_id, 'first_name', $userName); // User Address Information Here |
369 | 369 | //update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here |
370 | 370 | |
371 | - $user_nicename = geodir_generate_user_nicename( $userName, $user_login ); |
|
371 | + $user_nicename = geodir_generate_user_nicename($userName, $user_login); |
|
372 | 372 | |
373 | 373 | $updateUsersql = $wpdb->prepare("update $wpdb->users set user_url=%s, user_nicename=%s, display_name=%s where ID=%d", array($user_web, $user_nicename, $userName, $user_id)); |
374 | 374 | |
@@ -392,13 +392,13 @@ discard block |
||
392 | 392 | ///////REGISTRATION EMAIL START////// |
393 | 393 | $fromEmail = geodir_get_site_email_id(); |
394 | 394 | $fromEmailName = get_site_emailName(); |
395 | - $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p> |
|
396 | -<p>' . __('Username:', 'geodirectory') . ' ' . $user_login . '</p> |
|
397 | -<p>' . __('Password:', 'geodirectory') . ' ' . $user_pass . '</p>'); |
|
395 | + $message = __('<p><b>'.__('Your login Information :', 'geodirectory').'</b></p> |
|
396 | +<p>' . __('Username:', 'geodirectory').' '.$user_login.'</p> |
|
397 | +<p>' . __('Password:', 'geodirectory').' '.$user_pass.'</p>'); |
|
398 | 398 | |
399 | 399 | /////////////customer email////////////// |
400 | 400 | //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email |
401 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email |
|
401 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id); /// registration email |
|
402 | 402 | //////REGISTRATION EMAIL END//////// |
403 | 403 | } |
404 | 404 | |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | $action = 'resetpass'; |
430 | 430 | |
431 | 431 | // validate action so as to default to the login screen |
432 | - if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action)) |
|
432 | + if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_'.$action)) |
|
433 | 433 | $action = 'login'; |
434 | 434 | |
435 | 435 | nocache_headers(); |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); |
440 | 440 | |
441 | 441 | $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; |
442 | - if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) |
|
443 | - update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); |
|
442 | + if (dirname($schema.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']) != home_url()) |
|
443 | + update_option('siteurl', dirname($schema.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'])); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | //Set a cookie now to see if they are supported by the browser. |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | * |
456 | 456 | * @since 1.0.0 |
457 | 457 | */ |
458 | - do_action('login_form_' . $action); |
|
458 | + do_action('login_form_'.$action); |
|
459 | 459 | |
460 | 460 | $http_post = ('POST' == $_SERVER['REQUEST_METHOD']); |
461 | 461 | |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * @since 1.0.0 |
496 | 496 | */ |
497 | 497 | do_action('lost_password'); |
498 | - $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>'; |
|
498 | + $message = '<div class="sucess_msg">'.ENTER_USER_EMAIL_NEW_PW_MSG.'</div>'; |
|
499 | 499 | $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; |
500 | 500 | |
501 | 501 | break; |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | exit(); |
510 | 510 | } |
511 | 511 | |
512 | - wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword'))); |
|
512 | + wp_redirect(geodir_login_url(array('error'=>'invalidkey', 'action'=>'lostpassword'))); |
|
513 | 513 | exit(); |
514 | 514 | |
515 | 515 | break; |
@@ -642,15 +642,15 @@ discard block |
||
642 | 642 | $user_ID = !empty($user->ID) ? $user->ID : get_current_user_id(); |
643 | 643 | $post_types = geodir_get_posttypes(); |
644 | 644 | |
645 | - if ( !empty( $_REQUEST['stype'] ) ) { |
|
645 | + if (!empty($_REQUEST['stype'])) { |
|
646 | 646 | $dashboard_post_type = sanitize_text_field($_REQUEST['stype']); |
647 | 647 | } else { |
648 | - $user_listings = geodir_user_post_listing_count( $user_ID ); |
|
649 | - if ( !empty( $user_listings ) && $dashboard_post_types = array_keys( $user_listings ) ) { |
|
648 | + $user_listings = geodir_user_post_listing_count($user_ID); |
|
649 | + if (!empty($user_listings) && $dashboard_post_types = array_keys($user_listings)) { |
|
650 | 650 | $dashboard_post_type = $dashboard_post_types[0]; |
651 | 651 | } |
652 | 652 | } |
653 | - if ( !( !empty( $dashboard_post_type ) && in_array( $dashboard_post_type, $post_types ) ) ) { |
|
653 | + if (!(!empty($dashboard_post_type) && in_array($dashboard_post_type, $post_types))) { |
|
654 | 654 | $dashboard_post_type = $post_types[0]; |
655 | 655 | } |
656 | 656 | |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | |
699 | 699 | if (is_wp_error($user)) { |
700 | 700 | if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') { |
701 | - wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1'); |
|
701 | + wp_redirect($_SERVER['HTTP_REFERER'].'&emsg=1'); |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | if (!is_wp_error($user)) { |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | |
727 | 727 | // Some parts of this script use the main login form to display a message |
728 | 728 | if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) { |
729 | - $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>'; |
|
729 | + $successmsg = '<div class="sucess_msg">'.YOU_ARE_LOGED_OUT_MSG.'</div>'; |
|
730 | 730 | } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) { |
731 | 731 | $successmsg = USER_REG_NOT_ALLOW_MSG; |
732 | 732 | } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) { |
@@ -739,9 +739,9 @@ discard block |
||
739 | 739 | |
740 | 740 | if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) { |
741 | 741 | if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') { |
742 | - wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); |
|
742 | + wp_redirect($_REQUEST['pagetype'].'&emsg=1'); |
|
743 | 743 | } else { |
744 | - wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to'])))); |
|
744 | + wp_redirect(geodir_login_url(array('logemsg'=>'1', 'redirect_to'=>urlencode($_REQUEST['redirect_to'])))); |
|
745 | 745 | } |
746 | 746 | gd_die(); |
747 | 747 | } |
@@ -749,28 +749,28 @@ discard block |
||
749 | 749 | endswitch; // end action switch |
750 | 750 | } |
751 | 751 | |
752 | -function geodir_generate_user_nicename( $display_name, $user_login ) { |
|
752 | +function geodir_generate_user_nicename($display_name, $user_login) { |
|
753 | 753 | global $wpdb; |
754 | 754 | $user_nicename = ''; |
755 | - if ( ! empty( $display_name ) ) { |
|
756 | - $user_nicename = sanitize_user( $display_name, true ); |
|
755 | + if (!empty($display_name)) { |
|
756 | + $user_nicename = sanitize_user($display_name, true); |
|
757 | 757 | } |
758 | - if ( empty( $user_nicename ) ) { |
|
758 | + if (empty($user_nicename)) { |
|
759 | 759 | $user_nicename = $user_login; |
760 | 760 | } |
761 | - $user_nicename = mb_substr( $user_nicename, 0, 50 ); |
|
762 | - $user_nicename = sanitize_title( $user_nicename ); |
|
763 | - $user_nicename = apply_filters( 'pre_user_nicename', $user_nicename ); |
|
761 | + $user_nicename = mb_substr($user_nicename, 0, 50); |
|
762 | + $user_nicename = sanitize_title($user_nicename); |
|
763 | + $user_nicename = apply_filters('pre_user_nicename', $user_nicename); |
|
764 | 764 | |
765 | - $user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $user_nicename, $user_login)); |
|
765 | + $user_nicename_check = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $user_nicename, $user_login)); |
|
766 | 766 | |
767 | - if ( $user_nicename_check ) { |
|
767 | + if ($user_nicename_check) { |
|
768 | 768 | $suffix = 2; |
769 | 769 | while ($user_nicename_check) { |
770 | 770 | // user_nicename allows 50 chars. Subtract one for a hyphen, plus the length of the suffix. |
771 | - $base_length = 49 - mb_strlen( $suffix ); |
|
772 | - $alt_user_nicename = mb_substr( $user_nicename, 0, $base_length ) . "-$suffix"; |
|
773 | - $user_nicename_check = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1" , $alt_user_nicename, $user_login)); |
|
771 | + $base_length = 49 - mb_strlen($suffix); |
|
772 | + $alt_user_nicename = mb_substr($user_nicename, 0, $base_length)."-$suffix"; |
|
773 | + $user_nicename_check = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users WHERE user_nicename = %s AND user_login != %s LIMIT 1", $alt_user_nicename, $user_login)); |
|
774 | 774 | $suffix++; |
775 | 775 | } |
776 | 776 | $user_nicename = $alt_user_nicename; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | /* ON TEMPLATE INCLUDE */ |
137 | 137 | ///////////////////////// |
138 | 138 | |
139 | -add_filter('template_include', 'geodir_template_loader',9); |
|
139 | +add_filter('template_include', 'geodir_template_loader', 9); |
|
140 | 140 | |
141 | 141 | ///////////////////////// |
142 | 142 | /* CATEGORY / TAXONOMY / CUSTOM POST ACTIONS */ |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | /* WP REVIEW COUNT ACTIONS */ |
177 | 177 | //////////////////////// |
178 | 178 | |
179 | -add_action('geodir_update_postrating', 'geodir_term_review_count_force_update_single_post', 100,1); |
|
179 | +add_action('geodir_update_postrating', 'geodir_term_review_count_force_update_single_post', 100, 1); |
|
180 | 180 | //add_action('geodir_update_postrating', 'geodir_term_review_count_force_update', 100); |
181 | -add_action('transition_post_status', 'geodir_term_review_count_force_update', 100,3); |
|
181 | +add_action('transition_post_status', 'geodir_term_review_count_force_update', 100, 3); |
|
182 | 182 | //add_action('created_term', 'geodir_term_review_count_force_update', 100); |
183 | 183 | add_action('edited_term', 'geodir_term_review_count_force_update', 100); |
184 | 184 | add_action('delete_term', 'geodir_term_review_count_force_update', 100); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | function geodir_unset_prev_theme_nav_location($newname) |
225 | 225 | { |
226 | - $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname); |
|
226 | + $geodir_theme_location = get_option('geodir_theme_location_nav_'.$newname); |
|
227 | 227 | if ($geodir_theme_location) { |
228 | 228 | update_option('geodir_theme_location_nav', $geodir_theme_location); |
229 | 229 | } else { |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | include_once('geodirectory-functions/listing_filters.php'); |
259 | 259 | |
260 | 260 | // Theme My Login compatibility fix |
261 | - if ( isset( $_REQUEST['geodir_search'] ) && class_exists( 'Theme_My_Login' ) ) { |
|
262 | - remove_action( 'pre_get_posts', array( Theme_My_Login::get_object(), 'pre_get_posts' ) ); |
|
261 | + if (isset($_REQUEST['geodir_search']) && class_exists('Theme_My_Login')) { |
|
262 | + remove_action('pre_get_posts', array(Theme_My_Login::get_object(), 'pre_get_posts')); |
|
263 | 263 | } |
264 | 264 | |
265 | - if ( isset( $_REQUEST['geodir_search'] ) ) { |
|
266 | - add_filter( 'geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3 ); |
|
267 | - add_filter( 'geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3 ); |
|
265 | + if (isset($_REQUEST['geodir_search'])) { |
|
266 | + add_filter('geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3); |
|
267 | + add_filter('geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | |
332 | 332 | /////// GEO DIRECOTORY CUSTOM HOOKS /// |
333 | 333 | |
334 | -add_action('geodir_before_tab_content', 'geodir_before_tab_content');// this function is in custom_functions.php and it is used to wrap detail page tab content |
|
335 | -add_action('geodir_after_tab_content', 'geodir_after_tab_content');// this function is in custom_functions.php and it is used to wrap detail page tab content |
|
334 | +add_action('geodir_before_tab_content', 'geodir_before_tab_content'); // this function is in custom_functions.php and it is used to wrap detail page tab content |
|
335 | +add_action('geodir_after_tab_content', 'geodir_after_tab_content'); // this function is in custom_functions.php and it is used to wrap detail page tab content |
|
336 | 336 | |
337 | 337 | // Detail page sidebar content |
338 | 338 | add_action('geodir_detail_page_sidebar', 'geodir_detail_page_sidebar_content_sorting', 1); |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | do_action('geodir_after_social_sharing_buttons'); |
433 | 433 | $content_html = ob_get_clean(); |
434 | 434 | if (trim($content_html) != '') |
435 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
|
436 | - if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) { |
|
435 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">'.$content_html.'</div>'; |
|
436 | + if ((int) get_option('geodir_disable_tfg_buttons_section') != 1) { |
|
437 | 437 | /** |
438 | 438 | * Filter the geodir_social_sharing_buttons() function content. |
439 | 439 | * |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | $post_id = $post->ID; |
474 | 474 | |
475 | 475 | if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
476 | - $post_id = (int)$_REQUEST['pid']; |
|
476 | + $post_id = (int) $_REQUEST['pid']; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | $postlink = get_permalink(geodir_add_listing_page_id()); |
480 | 480 | $editlink = geodir_getlink($postlink, array('pid' => $post_id), false); |
481 | - echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>'; |
|
481 | + echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="'.esc_url($editlink).'">'.__('Edit this Post', 'geodirectory').'</a></p>'; |
|
482 | 482 | } |
483 | 483 | }// end of if, if its a preview or not |
484 | 484 | /** |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | do_action('geodir_after_edit_post_link'); |
490 | 490 | $content_html = ob_get_clean(); |
491 | 491 | if (trim($content_html) != '') |
492 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
|
493 | - if ((int)get_option('geodir_disable_user_links_section') != 1) { |
|
492 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">'.$content_html.'</div>'; |
|
493 | + if ((int) get_option('geodir_disable_user_links_section') != 1) { |
|
494 | 494 | /** |
495 | 495 | * Filter the geodir_edit_post_link() function content. |
496 | 496 | * |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | */ |
512 | 512 | function geodir_detail_page_google_analytics() |
513 | 513 | { |
514 | - global $post,$preview; |
|
515 | - if($preview){return '';} |
|
514 | + global $post, $preview; |
|
515 | + if ($preview) {return ''; } |
|
516 | 516 | $package_info = array(); |
517 | 517 | $package_info = geodir_post_package_info($package_info, $post); |
518 | 518 | |
@@ -544,14 +544,14 @@ discard block |
||
544 | 544 | $hide_refresh = get_option('geodir_ga_auto_refresh'); |
545 | 545 | |
546 | 546 | $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0; |
547 | - if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) { |
|
547 | + if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id() == $post->post_author || current_user_can('manage_options'))) { |
|
548 | 548 | $page_url = urlencode($_SERVER['REQUEST_URI']); |
549 | 549 | ?> |
550 | 550 | <script type="text/javascript"> |
551 | 551 | var gd_gaTimeOut; |
552 | - var gd_gaTime = parseInt('<?php echo $refresh_time;?>'); |
|
553 | - var gd_gaHideRefresh = <?php echo (int)$hide_refresh;?>; |
|
554 | - var gd_gaAutoRefresh = <?php echo $auto_refresh;?>; |
|
552 | + var gd_gaTime = parseInt('<?php echo $refresh_time; ?>'); |
|
553 | + var gd_gaHideRefresh = <?php echo (int) $hide_refresh; ?>; |
|
554 | + var gd_gaAutoRefresh = <?php echo $auto_refresh; ?>; |
|
555 | 555 | ga_data1 = false; |
556 | 556 | ga_data2 = false; |
557 | 557 | ga_data3 = false; |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | } |
693 | 693 | |
694 | 694 | function gdga_noResults() { |
695 | - jQuery('#gdga-chart-container').html('<?php _e('No results available','geodirectory');?>'); |
|
695 | + jQuery('#gdga-chart-container').html('<?php _e('No results available', 'geodirectory'); ?>'); |
|
696 | 696 | jQuery('#gdga-legend-container').html(''); |
697 | 697 | } |
698 | 698 | |
@@ -724,18 +724,18 @@ discard block |
||
724 | 724 | var data2 = results[1].rows.map(function(row) { return +row[2]; }); |
725 | 725 | //var labelsN = results[0].rows.map(function(row) { return +row[1]; }); |
726 | 726 | |
727 | - var labels = ['<?php _e('Jan', 'geodirectory');?>', |
|
728 | - '<?php _e('Feb', 'geodirectory');?>', |
|
729 | - '<?php _e('Mar', 'geodirectory');?>', |
|
730 | - '<?php _e('Apr', 'geodirectory');?>', |
|
731 | - '<?php _e('May', 'geodirectory');?>', |
|
732 | - '<?php _e('Jun', 'geodirectory');?>', |
|
733 | - '<?php _e('Jul', 'geodirectory');?>', |
|
734 | - '<?php _e('Aug', 'geodirectory');?>', |
|
735 | - '<?php _e('Sep', 'geodirectory');?>', |
|
736 | - '<?php _e('Oct', 'geodirectory');?>', |
|
737 | - '<?php _e('Nov', 'geodirectory');?>', |
|
738 | - '<?php _e('Dec', 'geodirectory');?>']; |
|
727 | + var labels = ['<?php _e('Jan', 'geodirectory'); ?>', |
|
728 | + '<?php _e('Feb', 'geodirectory'); ?>', |
|
729 | + '<?php _e('Mar', 'geodirectory'); ?>', |
|
730 | + '<?php _e('Apr', 'geodirectory'); ?>', |
|
731 | + '<?php _e('May', 'geodirectory'); ?>', |
|
732 | + '<?php _e('Jun', 'geodirectory'); ?>', |
|
733 | + '<?php _e('Jul', 'geodirectory'); ?>', |
|
734 | + '<?php _e('Aug', 'geodirectory'); ?>', |
|
735 | + '<?php _e('Sep', 'geodirectory'); ?>', |
|
736 | + '<?php _e('Oct', 'geodirectory'); ?>', |
|
737 | + '<?php _e('Nov', 'geodirectory'); ?>', |
|
738 | + '<?php _e('Dec', 'geodirectory'); ?>']; |
|
739 | 739 | |
740 | 740 | // Ensure the data arrays are at least as long as the labels array. |
741 | 741 | // Chart.js bar charts don't (yet) accept sparse datasets. |
@@ -748,13 +748,13 @@ discard block |
||
748 | 748 | labels : labels, |
749 | 749 | datasets : [ |
750 | 750 | { |
751 | - label: '<?php _e('Last Year', 'geodirectory');?>', |
|
751 | + label: '<?php _e('Last Year', 'geodirectory'); ?>', |
|
752 | 752 | fillColor : "rgba(220,220,220,0.5)", |
753 | 753 | strokeColor : "rgba(220,220,220,1)", |
754 | 754 | data : data2 |
755 | 755 | }, |
756 | 756 | { |
757 | - label: '<?php _e('This Year', 'geodirectory');?>', |
|
757 | + label: '<?php _e('This Year', 'geodirectory'); ?>', |
|
758 | 758 | fillColor : "rgba(151,187,205,0.5)", |
759 | 759 | strokeColor : "rgba(151,187,205,1)", |
760 | 760 | data : data1 |
@@ -799,30 +799,30 @@ discard block |
||
799 | 799 | |
800 | 800 | <?php |
801 | 801 | // Here we list the shorthand days of the week so it can be used in translation. |
802 | - __("Mon",'geodirectory'); |
|
803 | - __("Tue",'geodirectory'); |
|
804 | - __("Wed",'geodirectory'); |
|
805 | - __("Thu",'geodirectory'); |
|
806 | - __("Fri",'geodirectory'); |
|
807 | - __("Sat",'geodirectory'); |
|
808 | - __("Sun",'geodirectory'); |
|
802 | + __("Mon", 'geodirectory'); |
|
803 | + __("Tue", 'geodirectory'); |
|
804 | + __("Wed", 'geodirectory'); |
|
805 | + __("Thu", 'geodirectory'); |
|
806 | + __("Fri", 'geodirectory'); |
|
807 | + __("Sat", 'geodirectory'); |
|
808 | + __("Sun", 'geodirectory'); |
|
809 | 809 | ?> |
810 | 810 | |
811 | 811 | labels = [ |
812 | - "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>", |
|
813 | - "<?php _e(date('D', strtotime("+2 day")),'geodirectory'); ?>", |
|
814 | - "<?php _e(date('D', strtotime("+3 day")),'geodirectory'); ?>", |
|
815 | - "<?php _e(date('D', strtotime("+4 day")),'geodirectory'); ?>", |
|
816 | - "<?php _e(date('D', strtotime("+5 day")),'geodirectory'); ?>", |
|
817 | - "<?php _e(date('D', strtotime("+6 day")),'geodirectory'); ?>", |
|
818 | - "<?php _e(date('D', strtotime("+7 day")),'geodirectory'); ?>" |
|
812 | + "<?php _e(date('D', strtotime("+1 day")), 'geodirectory'); ?>", |
|
813 | + "<?php _e(date('D', strtotime("+2 day")), 'geodirectory'); ?>", |
|
814 | + "<?php _e(date('D', strtotime("+3 day")), 'geodirectory'); ?>", |
|
815 | + "<?php _e(date('D', strtotime("+4 day")), 'geodirectory'); ?>", |
|
816 | + "<?php _e(date('D', strtotime("+5 day")), 'geodirectory'); ?>", |
|
817 | + "<?php _e(date('D', strtotime("+6 day")), 'geodirectory'); ?>", |
|
818 | + "<?php _e(date('D', strtotime("+7 day")), 'geodirectory'); ?>" |
|
819 | 819 | ]; |
820 | 820 | |
821 | 821 | var data = { |
822 | 822 | labels : labels, |
823 | 823 | datasets : [ |
824 | 824 | { |
825 | - label: '<?php _e('Last Week', 'geodirectory');?>', |
|
825 | + label: '<?php _e('Last Week', 'geodirectory'); ?>', |
|
826 | 826 | fillColor : "rgba(220,220,220,0.5)", |
827 | 827 | strokeColor : "rgba(220,220,220,1)", |
828 | 828 | pointColor : "rgba(220,220,220,1)", |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | data : data2 |
831 | 831 | }, |
832 | 832 | { |
833 | - label: '<?php _e('This Week', 'geodirectory');?>', |
|
833 | + label: '<?php _e('This Week', 'geodirectory'); ?>', |
|
834 | 834 | fillColor : "rgba(151,187,205,0.5)", |
835 | 835 | strokeColor : "rgba(151,187,205,1)", |
836 | 836 | pointColor : "rgba(151,187,205,1)", |
@@ -1037,18 +1037,18 @@ discard block |
||
1037 | 1037 | </style> |
1038 | 1038 | <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script> |
1039 | 1039 | <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script> |
1040 | - <button type="button" class="gdga-show-analytics"><?php _e('Show Google Analytics', 'geodirectory');?></button> |
|
1040 | + <button type="button" class="gdga-show-analytics"><?php _e('Show Google Analytics', 'geodirectory'); ?></button> |
|
1041 | 1041 | <span id="ga_stats" class="gdga-analytics-box" style="display:none"> |
1042 | - <div id="ga-analytics-title"><?php _e("Analytics", 'geodirectory');?></div> |
|
1042 | + <div id="ga-analytics-title"><?php _e("Analytics", 'geodirectory'); ?></div> |
|
1043 | 1043 | <div id="gd-active-users-container"> |
1044 | - <div class="gd-ActiveUsers"><i id="gdga-loader-icon" class="fa fa-refresh fa-spin" title="<?php esc_attr_e("Refresh", 'geodirectory');?>"></i><?php _e("Active Users:", 'geodirectory');?> |
|
1044 | + <div class="gd-ActiveUsers"><i id="gdga-loader-icon" class="fa fa-refresh fa-spin" title="<?php esc_attr_e("Refresh", 'geodirectory'); ?>"></i><?php _e("Active Users:", 'geodirectory'); ?> |
|
1045 | 1045 | <b class="gd-ActiveUsers-value">0</b> |
1046 | 1046 | </div> |
1047 | 1047 | </div> |
1048 | 1048 | <select id="gdga-select-analytic" onchange="gdga_select_option();" style="display: none;"> |
1049 | - <option value="weeks"><?php _e("Last Week vs This Week", 'geodirectory');?></option> |
|
1050 | - <option value="years"><?php _e("This Year vs Last Year", 'geodirectory');?></option> |
|
1051 | - <option value="country"><?php _e("Top Countries", 'geodirectory');?></option> |
|
1049 | + <option value="weeks"><?php _e("Last Week vs This Week", 'geodirectory'); ?></option> |
|
1050 | + <option value="years"><?php _e("This Year vs Last Year", 'geodirectory'); ?></option> |
|
1051 | + <option value="country"><?php _e("Top Countries", 'geodirectory'); ?></option> |
|
1052 | 1052 | </select> |
1053 | 1053 | <div class="Chartjs-figure" id="gdga-chart-container"></div> |
1054 | 1054 | <ol class="Chartjs-legend" id="gdga-legend-container"></ol> |
@@ -1064,8 +1064,8 @@ discard block |
||
1064 | 1064 | do_action('geodir_after_google_analytics'); |
1065 | 1065 | $content_html = ob_get_clean(); |
1066 | 1066 | if (trim($content_html) != '') |
1067 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
|
1068 | - if ((int)get_option('geodir_disable_google_analytics_section') != 1) { |
|
1067 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">'.$content_html.'</div>'; |
|
1068 | + if ((int) get_option('geodir_disable_google_analytics_section') != 1) { |
|
1069 | 1069 | /** |
1070 | 1070 | * Filter the geodir_edit_post_link() function content. |
1071 | 1071 | * |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | { |
1092 | 1092 | global $post, $preview, $post_images; |
1093 | 1093 | |
1094 | - if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) { |
|
1094 | + if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int) $post->ID)) { |
|
1095 | 1095 | return; |
1096 | 1096 | } |
1097 | 1097 | ob_start(); // Start buffering; |
@@ -1126,10 +1126,10 @@ discard block |
||
1126 | 1126 | |
1127 | 1127 | $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory'); |
1128 | 1128 | |
1129 | - $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />'; |
|
1129 | + $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="'.$post_avgratings.'">'.$post_avgratings.'</span> / <span itemprop="best" content="5">5</span> '.__("based on", 'geodirectory').' </span><span class="count" itemprop="count" content="'.$comment_count.'">'.$comment_count.' '.$reviews_text.'</span><br />'; |
|
1130 | 1130 | |
1131 | 1131 | $html .= '<span class="item">'; |
1132 | - $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>'; |
|
1132 | + $html .= '<span class="fn" itemprop="itemreviewed">'.$post->post_title.'</span>'; |
|
1133 | 1133 | |
1134 | 1134 | if ($post_images) { |
1135 | 1135 | foreach ($post_images as $img) { |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | if (isset($post_img) && $post_img) { |
1142 | - $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />'; |
|
1142 | + $html .= '<br /><img src="'.$post_img.'" class="photo" alt="'.esc_attr($post->post_title).'" itemprop="photo" content="'.$post_img.'" class="photo" />'; |
|
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | $html .= '</span>'; |
@@ -1166,9 +1166,9 @@ discard block |
||
1166 | 1166 | do_action('geodir_after_detail_page_review_rating'); |
1167 | 1167 | $content_html = ob_get_clean(); |
1168 | 1168 | if (trim($content_html) != '') { |
1169 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>'; |
|
1169 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">'.$content_html.'</div>'; |
|
1170 | 1170 | } |
1171 | - if ((int)get_option('geodir_disable_rating_info_section') != 1) { |
|
1171 | + if ((int) get_option('geodir_disable_rating_info_section') != 1) { |
|
1172 | 1172 | /** |
1173 | 1173 | * Filter the geodir_detail_page_review_rating() function content. |
1174 | 1174 | * |
@@ -1207,8 +1207,8 @@ discard block |
||
1207 | 1207 | |
1208 | 1208 | $content_html = ob_get_clean(); |
1209 | 1209 | if (trim($content_html) != '') |
1210 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
|
1211 | - if ((int)get_option('geodir_disable_listing_info_section') != 1) { |
|
1210 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">'.$content_html.'</div>'; |
|
1211 | + if ((int) get_option('geodir_disable_listing_info_section') != 1) { |
|
1212 | 1212 | /** |
1213 | 1213 | * Filter the output html for function geodir_detail_page_more_info(). |
1214 | 1214 | * |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | 'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '', |
1310 | 1310 | 'geodir_txt_form_wait' => __('Wait...', 'geodirectory'), |
1311 | 1311 | 'geodir_txt_form_searching' => __('Searching...', 'geodirectory'), |
1312 | - 'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '', |
|
1312 | + 'fa_rating' => (int) get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '', |
|
1313 | 1313 | 'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '', |
1314 | 1314 | 'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false, |
1315 | 1315 | 'geodir_map_name' => geodir_map_name(), |
@@ -1338,10 +1338,10 @@ discard block |
||
1338 | 1338 | foreach ($arr_alert_msg as $key => $value) { |
1339 | 1339 | if (!is_scalar($value)) |
1340 | 1340 | continue; |
1341 | - $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8'); |
|
1341 | + $arr_alert_msg[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
1342 | 1342 | } |
1343 | 1343 | |
1344 | - $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';'; |
|
1344 | + $script = "var geodir_all_js_msg = ".json_encode($arr_alert_msg).';'; |
|
1345 | 1345 | echo '<script>'; |
1346 | 1346 | echo $script; |
1347 | 1347 | echo '</script>'; |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | $geodir_old_sidebars = get_option('geodir_sidebars'); |
1432 | 1432 | if (is_array($geodir_old_sidebars)) { |
1433 | 1433 | foreach ($geodir_old_sidebars as $key => $val) { |
1434 | - if(0 === strpos($key, 'geodir_'))// if gd widget |
|
1434 | + if (0 === strpos($key, 'geodir_'))// if gd widget |
|
1435 | 1435 | { |
1436 | 1436 | $sidebars_widgets[$key] = $geodir_old_sidebars[$key]; |
1437 | 1437 | } |
@@ -1510,7 +1510,7 @@ discard block |
||
1510 | 1510 | global $post; |
1511 | 1511 | $term_condition = ''; |
1512 | 1512 | if (isset($_REQUEST['backandedit'])) { |
1513 | - $post = (object)$gd_session->get('listing'); |
|
1513 | + $post = (object) $gd_session->get('listing'); |
|
1514 | 1514 | $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : ''; |
1515 | 1515 | } |
1516 | 1516 | |
@@ -1524,7 +1524,7 @@ discard block |
||
1524 | 1524 | echo 'checked="checked"'; |
1525 | 1525 | } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition" |
1526 | 1526 | class="geodir_textfield" value="1" |
1527 | - style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a> |
|
1527 | + style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if ($terms_page) { echo get_permalink($terms_page); }?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a> |
|
1528 | 1528 | </span> |
1529 | 1529 | </div> |
1530 | 1530 | <span class="geodir_message_error"><?php if (isset($required_msg)) { |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | /** This action is documented in geodirectory_template_actions.php */ |
1565 | 1565 | $desc_limit = apply_filters('geodir_description_field_desc_limit', ''); |
1566 | 1566 | |
1567 | - if (!($desc_limit === '' || (int)$desc_limit > 0)) { |
|
1567 | + if (!($desc_limit === '' || (int) $desc_limit > 0)) { |
|
1568 | 1568 | $is_display = false; |
1569 | 1569 | } |
1570 | 1570 | } |
@@ -1612,16 +1612,16 @@ discard block |
||
1612 | 1612 | global $wpdb, $plugin_prefix; |
1613 | 1613 | |
1614 | 1614 | // Remove unused virtual page |
1615 | - $listings_page_id = (int)get_option('geodir_listing_page'); |
|
1615 | + $listings_page_id = (int) get_option('geodir_listing_page'); |
|
1616 | 1616 | if ($listings_page_id) { |
1617 | - $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page'))); |
|
1617 | + $wpdb->query($wpdb->prepare("DELETE FROM ".$wpdb->posts." WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page'))); |
|
1618 | 1618 | delete_option('geodir_listing_page'); |
1619 | 1619 | } |
1620 | 1620 | |
1621 | 1621 | if (!get_option('geodir_changes_in_custom_fields_table')) { |
1622 | 1622 | $wpdb->query( |
1623 | 1623 | $wpdb->prepare( |
1624 | - "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s", |
|
1624 | + "UPDATE ".GEODIR_CUSTOM_FIELDS_TABLE." SET is_default=%s, is_admin=%s WHERE is_default=%s", |
|
1625 | 1625 | array('1', '1', 'admin') |
1626 | 1626 | ) |
1627 | 1627 | ); |
@@ -1629,9 +1629,9 @@ discard block |
||
1629 | 1629 | |
1630 | 1630 | /* --- terms meta value set --- */ |
1631 | 1631 | |
1632 | - update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png'); |
|
1632 | + update_option('geodir_default_marker_icon', geodir_plugin_url().'/geodirectory-functions/map-functions/icons/pin.png'); |
|
1633 | 1633 | |
1634 | - $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%'))); |
|
1634 | + $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."options WHERE option_name LIKE %s", array('%tax_meta_%'))); |
|
1635 | 1635 | |
1636 | 1636 | if (!empty($options_data)) { |
1637 | 1637 | |
@@ -1639,7 +1639,7 @@ discard block |
||
1639 | 1639 | |
1640 | 1640 | $option_val = str_replace('tax_meta_', '', $optobj->option_name); |
1641 | 1641 | |
1642 | - $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val))); |
|
1642 | + $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM ".$wpdb->prefix."term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val))); |
|
1643 | 1643 | |
1644 | 1644 | if (!empty($taxonomies_data)) { |
1645 | 1645 | |
@@ -1648,17 +1648,17 @@ discard block |
||
1648 | 1648 | $taxObject = get_taxonomy($taxobj->taxonomy); |
1649 | 1649 | $post_type = $taxObject->object_type[0]; |
1650 | 1650 | |
1651 | - $opt_value = 'tax_meta_' . $post_type . '_' . $option_val; |
|
1651 | + $opt_value = 'tax_meta_'.$post_type.'_'.$option_val; |
|
1652 | 1652 | |
1653 | - $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val))); |
|
1653 | + $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM ".$wpdb->prefix."options WHERE option_name=%s", array('tax_meta_'.$option_val))); |
|
1654 | 1654 | |
1655 | 1655 | if ($duplicate_data) { |
1656 | 1656 | |
1657 | - $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id))); |
|
1657 | + $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."options SET option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id))); |
|
1658 | 1658 | |
1659 | 1659 | } else { |
1660 | 1660 | |
1661 | - $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload))); |
|
1661 | + $wpdb->query($wpdb->prepare("INSERT INTO ".$wpdb->prefix."options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload))); |
|
1662 | 1662 | |
1663 | 1663 | } |
1664 | 1664 | |
@@ -1692,14 +1692,14 @@ discard block |
||
1692 | 1692 | |
1693 | 1693 | global $wpdb, $table_prefix; |
1694 | 1694 | |
1695 | - $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug))); |
|
1695 | + $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM ".$table_prefix."terms WHERE slug=%s", array($slug))); |
|
1696 | 1696 | |
1697 | 1697 | if ($slug_exists) { |
1698 | 1698 | |
1699 | 1699 | $suffix = 1; |
1700 | 1700 | do { |
1701 | - $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
1702 | - $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name))); |
|
1701 | + $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix"; |
|
1702 | + $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM ".$table_prefix."terms WHERE slug=%s", array($alt_location_name))); |
|
1703 | 1703 | $suffix++; |
1704 | 1704 | } while ($location_slug_check && $suffix < 100); |
1705 | 1705 | |
@@ -1753,7 +1753,7 @@ discard block |
||
1753 | 1753 | |
1754 | 1754 | $suffix = 1; |
1755 | 1755 | do { |
1756 | - $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
1756 | + $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1))."-$suffix"; |
|
1757 | 1757 | |
1758 | 1758 | /** This action is documented in geodirectory_hooks_actions.php */ |
1759 | 1759 | $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id); |
@@ -1765,7 +1765,7 @@ discard block |
||
1765 | 1765 | |
1766 | 1766 | //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) ); |
1767 | 1767 | |
1768 | - $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id))); |
|
1768 | + $wpdb->query($wpdb->prepare("UPDATE ".$table_prefix."terms SET slug=%s WHERE term_id=%d", array($slug, $term_id))); |
|
1769 | 1769 | |
1770 | 1770 | } |
1771 | 1771 | |
@@ -1774,18 +1774,18 @@ discard block |
||
1774 | 1774 | $post_type = !empty($taxonomy_obj) ? $taxonomy_obj->object_type[0] : NULL; |
1775 | 1775 | |
1776 | 1776 | $post_types = geodir_get_posttypes(); |
1777 | - if ($post_type && in_array($post_type, $post_types) && $post_type . '_tags' == $taxonomy) { |
|
1778 | - $posts_obj = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM " . $wpdb->term_relationships . " WHERE term_taxonomy_id = %d", array($tt_id))); |
|
1777 | + if ($post_type && in_array($post_type, $post_types) && $post_type.'_tags' == $taxonomy) { |
|
1778 | + $posts_obj = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM ".$wpdb->term_relationships." WHERE term_taxonomy_id = %d", array($tt_id))); |
|
1779 | 1779 | |
1780 | 1780 | if (!empty($posts_obj)) { |
1781 | 1781 | foreach ($posts_obj as $post_obj) { |
1782 | 1782 | $post_id = $post_obj->object_id; |
1783 | 1783 | |
1784 | - $raw_tags = wp_get_object_terms($post_id, $post_type . '_tags', array('fields' => 'names')); |
|
1784 | + $raw_tags = wp_get_object_terms($post_id, $post_type.'_tags', array('fields' => 'names')); |
|
1785 | 1785 | $post_tags = !empty($raw_tags) ? implode(',', $raw_tags) : ''; |
1786 | 1786 | |
1787 | - $listing_table = $plugin_prefix . $post_type . '_detail'; |
|
1788 | - $wpdb->query($wpdb->prepare("UPDATE " . $listing_table . " SET post_tags=%s WHERE post_id =%d", array($post_tags, $post_id))); |
|
1787 | + $listing_table = $plugin_prefix.$post_type.'_detail'; |
|
1788 | + $wpdb->query($wpdb->prepare("UPDATE ".$listing_table." SET post_tags=%s WHERE post_id =%d", array($post_tags, $post_id))); |
|
1789 | 1789 | } |
1790 | 1790 | } |
1791 | 1791 | } |
@@ -1819,7 +1819,7 @@ discard block |
||
1819 | 1819 | if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) |
1820 | 1820 | return $slug_exists = true; |
1821 | 1821 | |
1822 | - if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) |
|
1822 | + if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM ".$table_prefix."terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) |
|
1823 | 1823 | return $slug_exists = true; |
1824 | 1824 | |
1825 | 1825 | return $slug_exists; |
@@ -1860,43 +1860,43 @@ discard block |
||
1860 | 1860 | |
1861 | 1861 | |
1862 | 1862 | $gd_page = ''; |
1863 | - if(geodir_is_page('home')){ |
|
1863 | + if (geodir_is_page('home')) { |
|
1864 | 1864 | $gd_page = 'home'; |
1865 | 1865 | $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title; |
1866 | 1866 | } |
1867 | - elseif(geodir_is_page('detail')){ |
|
1867 | + elseif (geodir_is_page('detail')) { |
|
1868 | 1868 | $gd_page = 'detail'; |
1869 | 1869 | $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title; |
1870 | 1870 | } |
1871 | - elseif(geodir_is_page('pt')){ |
|
1871 | + elseif (geodir_is_page('pt')) { |
|
1872 | 1872 | $gd_page = 'pt'; |
1873 | 1873 | $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title; |
1874 | 1874 | } |
1875 | - elseif(geodir_is_page('listing')){ |
|
1875 | + elseif (geodir_is_page('listing')) { |
|
1876 | 1876 | $gd_page = 'listing'; |
1877 | 1877 | $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title; |
1878 | 1878 | } |
1879 | - elseif(geodir_is_page('location')){ |
|
1879 | + elseif (geodir_is_page('location')) { |
|
1880 | 1880 | $gd_page = 'location'; |
1881 | 1881 | $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title; |
1882 | 1882 | } |
1883 | - elseif(geodir_is_page('search')){ |
|
1883 | + elseif (geodir_is_page('search')) { |
|
1884 | 1884 | $gd_page = 'search'; |
1885 | 1885 | $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title; |
1886 | 1886 | } |
1887 | - elseif(geodir_is_page('add-listing')){ |
|
1887 | + elseif (geodir_is_page('add-listing')) { |
|
1888 | 1888 | $gd_page = 'add-listing'; |
1889 | 1889 | $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title; |
1890 | 1890 | } |
1891 | - elseif(geodir_is_page('author')){ |
|
1891 | + elseif (geodir_is_page('author')) { |
|
1892 | 1892 | $gd_page = 'author'; |
1893 | 1893 | $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title; |
1894 | 1894 | } |
1895 | - elseif(geodir_is_page('login')){ |
|
1895 | + elseif (geodir_is_page('login')) { |
|
1896 | 1896 | $gd_page = 'login'; |
1897 | 1897 | $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title; |
1898 | 1898 | } |
1899 | - elseif(geodir_is_page('listing-success')){ |
|
1899 | + elseif (geodir_is_page('listing-success')) { |
|
1900 | 1900 | $gd_page = 'listing-success'; |
1901 | 1901 | $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title; |
1902 | 1902 | } |
@@ -1928,12 +1928,12 @@ discard block |
||
1928 | 1928 | |
1929 | 1929 | if (!get_option('geodir_set_post_attachments')) { |
1930 | 1930 | |
1931 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1932 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1931 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
1932 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
1933 | 1933 | |
1934 | 1934 | $all_postypes = geodir_get_posttypes(); |
1935 | 1935 | |
1936 | - foreach($all_postypes as $post_type){ |
|
1936 | + foreach ($all_postypes as $post_type) { |
|
1937 | 1937 | $args = array( |
1938 | 1938 | 'posts_per_page' => -1, |
1939 | 1939 | 'post_type' => $post_type, |
@@ -2027,7 +2027,7 @@ discard block |
||
2027 | 2027 | { |
2028 | 2028 | $user_id = get_current_user_id(); |
2029 | 2029 | |
2030 | - if(!$user_id){return $post;} |
|
2030 | + if (!$user_id) {return $post; } |
|
2031 | 2031 | |
2032 | 2032 | $gd_post_types = geodir_get_posttypes(); |
2033 | 2033 | |
@@ -2136,7 +2136,7 @@ discard block |
||
2136 | 2136 | |
2137 | 2137 | if (array_key_exists('post_video', $tabs_arr)) { |
2138 | 2138 | |
2139 | - $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type))); |
|
2139 | + $field_title = $wpdb->get_var($wpdb->prepare("select site_title from ".GEODIR_CUSTOM_FIELDS_TABLE." where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type))); |
|
2140 | 2140 | |
2141 | 2141 | if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') |
2142 | 2142 | $tabs_arr['post_video']['heading_text'] = $field_title; |
@@ -2144,7 +2144,7 @@ discard block |
||
2144 | 2144 | |
2145 | 2145 | if (array_key_exists('special_offers', $tabs_arr)) { |
2146 | 2146 | |
2147 | - $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type))); |
|
2147 | + $field_title = $wpdb->get_var($wpdb->prepare("select site_title from ".GEODIR_CUSTOM_FIELDS_TABLE." where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type))); |
|
2148 | 2148 | |
2149 | 2149 | if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') |
2150 | 2150 | $tabs_arr['special_offers']['heading_text'] = $field_title; |
@@ -2165,7 +2165,7 @@ discard block |
||
2165 | 2165 | */ |
2166 | 2166 | function geodir_remove_template_redirect_actions() |
2167 | 2167 | { |
2168 | - if (geodir_is_page('login')){ |
|
2168 | + if (geodir_is_page('login')) { |
|
2169 | 2169 | remove_all_actions('template_redirect'); |
2170 | 2170 | remove_action('init', 'avia_modify_front', 10); |
2171 | 2171 | } |
@@ -2212,25 +2212,25 @@ discard block |
||
2212 | 2212 | $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
2213 | 2213 | |
2214 | 2214 | $wpdb->query( |
2215 | - $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ", |
|
2215 | + $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = %d AND file=%s ", |
|
2216 | 2216 | array($post_id, $split_img_file_path) |
2217 | 2217 | ) |
2218 | 2218 | ); |
2219 | 2219 | |
2220 | 2220 | $attachment_data = $wpdb->get_row( |
2221 | - $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d", |
|
2221 | + $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id=%d", |
|
2222 | 2222 | array($post_id) |
2223 | 2223 | ) |
2224 | 2224 | ); |
2225 | 2225 | |
2226 | 2226 | if (!empty($attachment_data)) { |
2227 | - $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2227 | + $wpdb->query("UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order=1 WHERE ID=".$attachment_data->ID); |
|
2228 | 2228 | } |
2229 | 2229 | |
2230 | 2230 | |
2231 | - $table_name = $plugin_prefix . $post_type . '_detail'; |
|
2231 | + $table_name = $plugin_prefix.$post_type.'_detail'; |
|
2232 | 2232 | |
2233 | - $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id); |
|
2233 | + $wpdb->query("UPDATE ".$table_name." SET featured_image='' WHERE post_id =".$post_id); |
|
2234 | 2234 | |
2235 | 2235 | geodir_set_wp_featured_image($post_id); |
2236 | 2236 | |
@@ -2258,9 +2258,9 @@ discard block |
||
2258 | 2258 | |
2259 | 2259 | foreach ($all_postypes as $posttype) { |
2260 | 2260 | |
2261 | - $tablename = $plugin_prefix . $posttype . '_detail'; |
|
2261 | + $tablename = $plugin_prefix.$posttype.'_detail'; |
|
2262 | 2262 | |
2263 | - $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename); |
|
2263 | + $get_post_data = $wpdb->get_results("SELECT post_id FROM ".$tablename); |
|
2264 | 2264 | |
2265 | 2265 | if (!empty($get_post_data)) { |
2266 | 2266 | |
@@ -2268,7 +2268,7 @@ discard block |
||
2268 | 2268 | |
2269 | 2269 | $post_id = $data->post_id; |
2270 | 2270 | |
2271 | - $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''"); |
|
2271 | + $attachment_data = $wpdb->get_results("SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id =".$post_id." AND file!=''"); |
|
2272 | 2272 | |
2273 | 2273 | if (!empty($attachment_data)) { |
2274 | 2274 | |
@@ -2285,22 +2285,22 @@ discard block |
||
2285 | 2285 | |
2286 | 2286 | $file_name = $file_info['basename']; |
2287 | 2287 | |
2288 | - $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name; |
|
2288 | + $img_arr['path'] = $uploads_path.$sub_dir.'/'.$file_name; |
|
2289 | 2289 | |
2290 | 2290 | if (!file_exists($img_arr['path'])) { |
2291 | 2291 | |
2292 | - $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID); |
|
2292 | + $wpdb->query("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE ID=".$attach->ID); |
|
2293 | 2293 | |
2294 | 2294 | } |
2295 | 2295 | |
2296 | 2296 | } |
2297 | 2297 | |
2298 | - $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id"); |
|
2298 | + $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id=".$post_id." GROUP BY post_id"); |
|
2299 | 2299 | |
2300 | 2300 | if (!empty($attachment_data)) { |
2301 | 2301 | |
2302 | 2302 | if ($attachment_data->ID) |
2303 | - $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2303 | + $wpdb->query("UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order=1 WHERE ID=".$attachment_data->ID); |
|
2304 | 2304 | |
2305 | 2305 | } else { |
2306 | 2306 | |
@@ -2314,7 +2314,7 @@ discard block |
||
2314 | 2314 | |
2315 | 2315 | } |
2316 | 2316 | |
2317 | - $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id); |
|
2317 | + $wpdb->query("UPDATE ".$tablename." SET featured_image='' WHERE post_id =".$post_id); |
|
2318 | 2318 | |
2319 | 2319 | geodir_set_wp_featured_image($post_id); |
2320 | 2320 | |
@@ -2343,7 +2343,7 @@ discard block |
||
2343 | 2343 | { |
2344 | 2344 | |
2345 | 2345 | if (!get_option('geodir_default_rating_star_icon')) { |
2346 | - update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png'); |
|
2346 | + update_option('geodir_default_rating_star_icon', geodir_plugin_url().'/geodirectory-assets/images/stars.png'); |
|
2347 | 2347 | } |
2348 | 2348 | |
2349 | 2349 | } |
@@ -2363,7 +2363,7 @@ discard block |
||
2363 | 2363 | function geodir_user_post_listing_count($user_id = 0) |
2364 | 2364 | { |
2365 | 2365 | global $wpdb, $plugin_prefix, $current_user; |
2366 | - if(!$user_id){ |
|
2366 | + if (!$user_id) { |
|
2367 | 2367 | $user_id = $current_user->ID; |
2368 | 2368 | } |
2369 | 2369 | |
@@ -2372,7 +2372,7 @@ discard block |
||
2372 | 2372 | $user_listing = array(); |
2373 | 2373 | if ($user_id && is_array($all_posts) && !empty($all_posts)) { |
2374 | 2374 | foreach ($all_posts as $ptype) { |
2375 | - $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )"); |
|
2375 | + $total_posts = $wpdb->get_var("SELECT count( ID ) FROM ".$wpdb->prefix."posts WHERE post_author=".$user_id." AND post_type='".$ptype."' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )"); |
|
2376 | 2376 | |
2377 | 2377 | if ($total_posts > 0) { |
2378 | 2378 | $user_listing[$ptype] = $total_posts; |
@@ -2413,19 +2413,19 @@ discard block |
||
2413 | 2413 | |
2414 | 2414 | $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location); |
2415 | 2415 | //remove video and special offers if it is already set to show |
2416 | - if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){ |
|
2416 | + if (isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']) { |
|
2417 | 2417 | $unset_video = true; |
2418 | 2418 | } |
2419 | 2419 | |
2420 | - if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){ |
|
2420 | + if (isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']) { |
|
2421 | 2421 | $unset_special_offers = true; |
2422 | 2422 | } |
2423 | - if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){ |
|
2424 | - foreach($custom_fields as $key => $custom_field){ |
|
2425 | - if($custom_field['name']=='geodir_video' && isset($unset_video)){ |
|
2423 | + if (isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)) { |
|
2424 | + foreach ($custom_fields as $key => $custom_field) { |
|
2425 | + if ($custom_field['name'] == 'geodir_video' && isset($unset_video)) { |
|
2426 | 2426 | unset($custom_fields[$key]); |
2427 | 2427 | } |
2428 | - if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){ |
|
2428 | + if ($custom_field['name'] == 'geodir_special_offers' && isset($unset_special_offers)) { |
|
2429 | 2429 | unset($custom_fields[$key]); |
2430 | 2430 | } |
2431 | 2431 | } |
@@ -2442,7 +2442,7 @@ discard block |
||
2442 | 2442 | $post->{$field_name} = $_REQUEST[$field_name]; |
2443 | 2443 | } |
2444 | 2444 | |
2445 | - if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { |
|
2445 | + if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file', 'address', 'taxonomy'))) { |
|
2446 | 2446 | if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) { |
2447 | 2447 | continue; |
2448 | 2448 | } |
@@ -2475,7 +2475,7 @@ discard block |
||
2475 | 2475 | $post->{$field_name} = $_REQUEST[$field_name]; |
2476 | 2476 | } |
2477 | 2477 | |
2478 | - if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { |
|
2478 | + if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file', 'address', 'taxonomy'))) { |
|
2479 | 2479 | $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title']; |
2480 | 2480 | $site_title = trim($field['site_title']); |
2481 | 2481 | $type = $field; |
@@ -2491,21 +2491,21 @@ discard block |
||
2491 | 2491 | $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
2492 | 2492 | $variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : ''; |
2493 | 2493 | |
2494 | - }else{ |
|
2494 | + } else { |
|
2495 | 2495 | $i = 0; |
2496 | 2496 | $fieldset_count++; |
2497 | 2497 | $field_set_start = 1; |
2498 | - $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count; |
|
2498 | + $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_'.$fieldset_count; |
|
2499 | 2499 | $fieldset_arr[$fieldset_count]['label'] = $label; |
2500 | 2500 | } |
2501 | 2501 | |
2502 | 2502 | |
2503 | - if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];} |
|
2503 | + if (isset($type['extra_fields'])) {$extra_fields = $type['extra_fields']; } |
|
2504 | 2504 | $type = stripslashes_deep($type); // strip slashes |
2505 | - if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;} |
|
2505 | + if (isset($type['extra_fields'])) {$type['extra_fields'] = $extra_fields; } |
|
2506 | 2506 | $html = ''; |
2507 | 2507 | $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
2508 | - if($html_var=='post'){$html_var='post_address';} |
|
2508 | + if ($html_var == 'post') {$html_var = 'post_address'; } |
|
2509 | 2509 | $field_icon = geodir_field_icon_proccess($type); |
2510 | 2510 | $filed_type = $type['type']; |
2511 | 2511 | |
@@ -2518,7 +2518,7 @@ discard block |
||
2518 | 2518 | * @param string $fields_location The location the field is to be show. |
2519 | 2519 | * @param array $type The array of field values. |
2520 | 2520 | */ |
2521 | - $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
2521 | + $html = apply_filters("geodir_custom_field_output_{$filed_type}", $html, $fields_location, $type); |
|
2522 | 2522 | |
2523 | 2523 | |
2524 | 2524 | /** |
@@ -2564,7 +2564,7 @@ discard block |
||
2564 | 2564 | * @param string $htmlvar_name The field HTML var name. |
2565 | 2565 | */ |
2566 | 2566 | 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name), |
2567 | - 'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>' |
|
2567 | + 'tab_content' => '<div class="geodir-company_info field-group xxx">'.$fieldset_html.'</div>' |
|
2568 | 2568 | ); |
2569 | 2569 | } |
2570 | 2570 | } else { |
@@ -2628,7 +2628,7 @@ discard block |
||
2628 | 2628 | } |
2629 | 2629 | $status .= ")</strong>"; |
2630 | 2630 | |
2631 | - $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>'; |
|
2631 | + $html = '<span class="geodir-post-status">'.$status_icon.' <font class="geodir-status-label">'.__('Status: ', 'geodirectory').'</font>'.$status.'</span>'; |
|
2632 | 2632 | } |
2633 | 2633 | } |
2634 | 2634 | |
@@ -2697,7 +2697,7 @@ discard block |
||
2697 | 2697 | * @return array Modified class array. |
2698 | 2698 | */ |
2699 | 2699 | function geodir_body_class_active_map($classes = array()) { |
2700 | - $classes[] = 'gd-map-' . geodir_map_name(); |
|
2700 | + $classes[] = 'gd-map-'.geodir_map_name(); |
|
2701 | 2701 | |
2702 | 2702 | return $classes; |
2703 | 2703 | } |
@@ -2712,7 +2712,7 @@ discard block |
||
2712 | 2712 | * @return string Modified class string. |
2713 | 2713 | */ |
2714 | 2714 | function geodir_admin_body_class_active_map($class = '') { |
2715 | - $class .= ' gd-map-' . geodir_map_name(); |
|
2715 | + $class .= ' gd-map-'.geodir_map_name(); |
|
2716 | 2716 | |
2717 | 2717 | return $class; |
2718 | 2718 | } |
@@ -2732,7 +2732,7 @@ discard block |
||
2732 | 2732 | * @return array Translation texts. |
2733 | 2733 | */ |
2734 | 2734 | function geodir_load_gd_options_text_translation($translation_texts = array()) { |
2735 | - $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
2735 | + $translation_texts = !empty($translation_texts) && is_array($translation_texts) ? $translation_texts : array(); |
|
2736 | 2736 | |
2737 | 2737 | $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin'); |
2738 | 2738 | |
@@ -2798,17 +2798,17 @@ discard block |
||
2798 | 2798 | * @param array $args The array of menu arguments. |
2799 | 2799 | * @return array The modified arguments. |
2800 | 2800 | */ |
2801 | -function geodir_add_nav_menu_class( $args ) |
|
2801 | +function geodir_add_nav_menu_class($args) |
|
2802 | 2802 | { |
2803 | 2803 | |
2804 | - if(isset($args['menu_class'])){ |
|
2804 | + if (isset($args['menu_class'])) { |
|
2805 | 2805 | $args['menu_class'] = $args['menu_class']." gd-menu-z"; |
2806 | 2806 | } |
2807 | 2807 | |
2808 | 2808 | return $args; |
2809 | 2809 | } |
2810 | 2810 | |
2811 | -add_filter( 'wp_nav_menu_args', 'geodir_add_nav_menu_class' ); |
|
2811 | +add_filter('wp_nav_menu_args', 'geodir_add_nav_menu_class'); |
|
2812 | 2812 | |
2813 | 2813 | /** |
2814 | 2814 | * Filters WordPress locale ID. |
@@ -2848,10 +2848,10 @@ discard block |
||
2848 | 2848 | } |
2849 | 2849 | |
2850 | 2850 | add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2); |
2851 | - add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 ); |
|
2852 | - add_action( 'geodir_after_search_form', 'geodir_wpml_add_language_input_field' ); |
|
2851 | + add_action('geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1); |
|
2852 | + add_action('geodir_after_search_form', 'geodir_wpml_add_language_input_field'); |
|
2853 | 2853 | if (is_admin()) { |
2854 | - add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 ); |
|
2854 | + add_filter('geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1); |
|
2855 | 2855 | } |
2856 | 2856 | } |
2857 | 2857 | } |
@@ -2880,7 +2880,7 @@ discard block |
||
2880 | 2880 | } |
2881 | 2881 | |
2882 | 2882 | if (!empty($keep_vars)) { |
2883 | - foreach ( $languages as $code => $url) { |
|
2883 | + foreach ($languages as $code => $url) { |
|
2884 | 2884 | $filter_url = $url['url']; |
2885 | 2885 | |
2886 | 2886 | foreach ($keep_vars as $var) { |
@@ -2899,7 +2899,7 @@ discard block |
||
2899 | 2899 | |
2900 | 2900 | return $languages; |
2901 | 2901 | } |
2902 | -add_filter( 'icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1 ); |
|
2902 | +add_filter('icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1); |
|
2903 | 2903 | |
2904 | 2904 | /** |
2905 | 2905 | * Remove Yoast SEO hook if disabled on GD pages. |
@@ -2907,18 +2907,18 @@ discard block |
||
2907 | 2907 | * @since 1.6.18 |
2908 | 2908 | * |
2909 | 2909 | */ |
2910 | -function geodir_remove_yoast_seo_metas(){ |
|
2911 | - if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) { |
|
2910 | +function geodir_remove_yoast_seo_metas() { |
|
2911 | + if (class_exists('WPSEO_Frontend') && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas()) { |
|
2912 | 2912 | $wpseo = WPSEO_Frontend::get_instance(); |
2913 | 2913 | |
2914 | - remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 ); |
|
2915 | - remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 ); |
|
2916 | - remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 ); |
|
2917 | - remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 ); |
|
2918 | - remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 ); |
|
2919 | - remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 ); |
|
2914 | + remove_action('wp_head', array($wpseo, 'metadesc'), 6); |
|
2915 | + remove_action('wp_head', array($wpseo, 'metakeywords'), 11); |
|
2916 | + remove_filter('pre_get_document_title', array($wpseo, 'title'), 15); |
|
2917 | + remove_filter('wp_title', array($wpseo, 'title'), 15, 3); |
|
2918 | + remove_filter('thematic_doctitle', array($wpseo, 'title'), 15); |
|
2919 | + remove_filter('woo_title', array($wpseo, 'fix_woo_title'), 99); |
|
2920 | 2920 | |
2921 | - remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 ); |
|
2921 | + remove_action('template_redirect', 'wpseo_frontend_head_init', 999); |
|
2922 | 2922 | } |
2923 | 2923 | } |
2924 | 2924 | |
@@ -2933,22 +2933,22 @@ discard block |
||
2933 | 2933 | * |
2934 | 2934 | */ |
2935 | 2935 | function geodir_wpml_ajax_set_guest_lang() { |
2936 | - if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) { |
|
2937 | - if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) { |
|
2936 | + if (geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in()) { |
|
2937 | + if (empty($_GET['lang']) && !(!empty($_SERVER['REQUEST_URI']) && preg_match('@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename(preg_replace('@\?.*$@', '', $_SERVER['REQUEST_URI']))))) { |
|
2938 | 2938 | global $sitepress; |
2939 | 2939 | |
2940 | 2940 | $referer = wp_get_referer(); |
2941 | 2941 | |
2942 | 2942 | $current_lang = $sitepress->get_current_language(); |
2943 | - $referrer_lang = $sitepress->get_language_from_url( $referer ); |
|
2943 | + $referrer_lang = $sitepress->get_language_from_url($referer); |
|
2944 | 2944 | |
2945 | - if ( $referrer_lang && $current_lang != $referrer_lang ) { |
|
2945 | + if ($referrer_lang && $current_lang != $referrer_lang) { |
|
2946 | 2946 | $_GET['lang'] = $referrer_lang; |
2947 | 2947 | } |
2948 | 2948 | } |
2949 | 2949 | } |
2950 | 2950 | } |
2951 | -add_action( 'plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1 ); |
|
2951 | +add_action('plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1); |
|
2952 | 2952 | |
2953 | 2953 | /** |
2954 | 2954 | * Change country slug czech-republic to czechia and redirect. |
@@ -2969,18 +2969,18 @@ discard block |
||
2969 | 2969 | } |
2970 | 2970 | |
2971 | 2971 | $redirect = false; |
2972 | - if (strpos($current_url, '/' . $search . '/') !== false) { |
|
2972 | + if (strpos($current_url, '/'.$search.'/') !== false) { |
|
2973 | 2973 | $redirect = true; |
2974 | - $current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1); |
|
2974 | + $current_url = preg_replace('/\/'.$search.'\//', '/'.$replace.'/', $current_url, 1); |
|
2975 | 2975 | } |
2976 | 2976 | |
2977 | 2977 | if ($has_slash != "/") { |
2978 | 2978 | $current_url = trim($current_url, '/'); |
2979 | 2979 | } |
2980 | 2980 | |
2981 | - if (strpos($current_url, 'gd_country=' . $search) !== false) { |
|
2981 | + if (strpos($current_url, 'gd_country='.$search) !== false) { |
|
2982 | 2982 | $redirect = true; |
2983 | - $current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url); |
|
2983 | + $current_url = str_replace('gd_country='.$search, 'gd_country='.$replace, $current_url); |
|
2984 | 2984 | } |
2985 | 2985 | |
2986 | 2986 | if ($redirect) { |
@@ -3006,10 +3006,10 @@ discard block |
||
3006 | 3006 | * @param int $post_parent Post parent ID |
3007 | 3007 | * @param string $original_slug The original post slug. |
3008 | 3008 | */ |
3009 | -function geodir_check_post_to_term_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) { |
|
3009 | +function geodir_check_post_to_term_slug($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug) { |
|
3010 | 3010 | global $wpdb, $sitepress; |
3011 | 3011 | |
3012 | - if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) { |
|
3012 | + if ($post_type && strpos($post_type, 'gd_') === 0) { |
|
3013 | 3013 | $wpml_post_join = ""; |
3014 | 3014 | $wpml_post_where = ""; |
3015 | 3015 | $wpml_term_join = ""; |
@@ -3023,28 +3023,28 @@ discard block |
||
3023 | 3023 | } |
3024 | 3024 | |
3025 | 3025 | $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)"; |
3026 | - $wpml_post_where = " AND icl_t.language_code = '" . $post_language ."'"; |
|
3026 | + $wpml_post_where = " AND icl_t.language_code = '".$post_language."'"; |
|
3027 | 3027 | |
3028 | 3028 | $wpml_term_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type = CONCAT('tax_', tt.taxonomy)"; |
3029 | - $wpml_term_where = " AND icl_t.language_code = '" . $post_language ."'"; |
|
3029 | + $wpml_term_where = " AND icl_t.language_code = '".$post_language."'"; |
|
3030 | 3030 | } |
3031 | 3031 | |
3032 | - $term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $slug ) ); |
|
3032 | + $term_slug_check = $wpdb->get_var($wpdb->prepare("SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '".$post_type."category' OR tt.taxonomy = '".$post_type."_tags' ) {$wpml_term_where} LIMIT 1", $slug)); |
|
3033 | 3033 | |
3034 | - if ( $term_slug_check ) { |
|
3034 | + if ($term_slug_check) { |
|
3035 | 3035 | $suffix = 1; |
3036 | 3036 | |
3037 | 3037 | do { |
3038 | - $alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; |
|
3038 | + $alt_slug = _truncate_post_slug($original_slug, 200 - (strlen($suffix) + 1))."-$suffix"; |
|
3039 | 3039 | |
3040 | - $term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug ) ); |
|
3040 | + $term_check = $wpdb->get_var($wpdb->prepare("SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '".$post_type."category' OR tt.taxonomy = '".$post_type."_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug)); |
|
3041 | 3041 | |
3042 | - $post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID ) ); |
|
3042 | + $post_check = !$term_check && $wpdb->get_var($wpdb->prepare("SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID)); |
|
3043 | 3043 | |
3044 | 3044 | $term_slug_check = $term_check || $post_check; |
3045 | 3045 | |
3046 | 3046 | $suffix++; |
3047 | - } while ( $term_slug_check ); |
|
3047 | + } while ($term_slug_check); |
|
3048 | 3048 | |
3049 | 3049 | $slug = $alt_slug; |
3050 | 3050 | } |
@@ -3052,7 +3052,7 @@ discard block |
||
3052 | 3052 | |
3053 | 3053 | return $slug; |
3054 | 3054 | } |
3055 | -add_filter( 'wp_unique_post_slug', 'geodir_check_post_to_term_slug', 101, 6 ); |
|
3055 | +add_filter('wp_unique_post_slug', 'geodir_check_post_to_term_slug', 101, 6); |
|
3056 | 3056 | |
3057 | 3057 | /** |
3058 | 3058 | * Check whether a post name with slug exists or not. |
@@ -3069,51 +3069,51 @@ discard block |
||
3069 | 3069 | * @param int $term_id The term ID. |
3070 | 3070 | * @return bool true when exists. false when not exists. |
3071 | 3071 | */ |
3072 | -function geodir_check_term_to_post_slug( $slug_exists, $slug, $term_id ) { |
|
3072 | +function geodir_check_term_to_post_slug($slug_exists, $slug, $term_id) { |
|
3073 | 3073 | global $wpdb, $gd_term_post_type, $gd_term_taxonomy, $sitepress; |
3074 | 3074 | |
3075 | - if ( $slug_exists ) { |
|
3075 | + if ($slug_exists) { |
|
3076 | 3076 | return $slug_exists; |
3077 | 3077 | } |
3078 | 3078 | |
3079 | - if ( !empty( $gd_term_taxonomy ) && isset($gd_term_taxonomy[$term_id]) ) { |
|
3079 | + if (!empty($gd_term_taxonomy) && isset($gd_term_taxonomy[$term_id])) { |
|
3080 | 3080 | $taxonomy = $gd_term_taxonomy[$term_id]; |
3081 | 3081 | } else { |
3082 | - $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) ); |
|
3082 | + $taxonomy = $wpdb->get_var($wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id)); |
|
3083 | 3083 | $gd_term_taxonomy[$term_id] = $taxonomy; |
3084 | 3084 | } |
3085 | 3085 | |
3086 | - if ( empty($taxonomy) ) { |
|
3086 | + if (empty($taxonomy)) { |
|
3087 | 3087 | return $slug_exists; |
3088 | 3088 | } |
3089 | 3089 | |
3090 | - if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) { |
|
3090 | + if (!empty($gd_term_post_type) && $gd_term_post_type[$term_id]) { |
|
3091 | 3091 | $post_type = $gd_term_post_type[$term_id]; |
3092 | 3092 | } else { |
3093 | - $taxonomy_obj = get_taxonomy( $taxonomy ); |
|
3094 | - $post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL; |
|
3093 | + $taxonomy_obj = get_taxonomy($taxonomy); |
|
3094 | + $post_type = !empty($taxonomy_obj->object_type) ? $taxonomy_obj->object_type[0] : NULL; |
|
3095 | 3095 | } |
3096 | 3096 | |
3097 | 3097 | $wpml_post_join = ""; |
3098 | 3098 | $wpml_post_where = ""; |
3099 | 3099 | |
3100 | 3100 | if (geodir_wpml_is_taxonomy_translated($taxonomy) || geodir_wpml_is_post_type_translated($post_type)) { |
3101 | - $term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_' . $taxonomy) : $sitepress->get_current_language(); |
|
3101 | + $term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_'.$taxonomy) : $sitepress->get_current_language(); |
|
3102 | 3102 | if (!$term_language) { |
3103 | 3103 | $term_language = $sitepress->get_current_language(); |
3104 | 3104 | } |
3105 | 3105 | |
3106 | 3106 | $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)"; |
3107 | - $wpml_post_where = " AND icl_t.language_code = '" . $term_language ."'"; |
|
3107 | + $wpml_post_where = " AND icl_t.language_code = '".$term_language."'"; |
|
3108 | 3108 | } |
3109 | 3109 | |
3110 | - if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s {$wpml_post_where} LIMIT 1", $slug, $post_type ) ) ) { |
|
3110 | + if ($post_type && $wpdb->get_var($wpdb->prepare("SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s {$wpml_post_where} LIMIT 1", $slug, $post_type))) { |
|
3111 | 3111 | $slug_exists = true; |
3112 | 3112 | } |
3113 | 3113 | |
3114 | 3114 | return $slug_exists; |
3115 | 3115 | } |
3116 | -add_filter( 'geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3 ); |
|
3116 | +add_filter('geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3); |
|
3117 | 3117 | |
3118 | 3118 | /** |
3119 | 3119 | * Add hidden WPML language input field. |
@@ -3127,7 +3127,7 @@ discard block |
||
3127 | 3127 | function geodir_wpml_add_language_input_field() { |
3128 | 3128 | global $sitepress; |
3129 | 3129 | |
3130 | - if ( function_exists( 'wpml_add_language_form_field_action' ) && WPML_LANGUAGE_NEGOTIATION_TYPE_PARAMETER === (int) $sitepress->get_setting( 'language_negotiation_type' ) ) { |
|
3130 | + if (function_exists('wpml_add_language_form_field_action') && WPML_LANGUAGE_NEGOTIATION_TYPE_PARAMETER === (int) $sitepress->get_setting('language_negotiation_type')) { |
|
3131 | 3131 | wpml_add_language_form_field_action(); |
3132 | 3132 | } |
3133 | 3133 | } |
3134 | 3134 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function geodir_get_ajax_url() |
21 | 21 | { |
22 | - return admin_url('admin-ajax.php?action=geodir_ajax_action'); |
|
22 | + return admin_url('admin-ajax.php?action=geodir_ajax_action'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | ///////////////////// |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | add_filter('query_vars', 'geodir_add_geodir_page_var'); |
88 | 88 | add_action('wp', 'geodir_add_page_id_in_query_var'); // problem fix in wordpress 3.8 |
89 | 89 | if (get_option('permalink_structure') != '') |
90 | - add_filter('parse_request', 'geodir_set_location_var_in_session_in_core'); |
|
90 | + add_filter('parse_request', 'geodir_set_location_var_in_session_in_core'); |
|
91 | 91 | |
92 | 92 | add_filter('parse_query', 'geodir_modified_query'); |
93 | 93 | |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | /* POST AND LOOP ACTIONS */ |
155 | 155 | //////////////////////// |
156 | 156 | if (!is_admin()) { |
157 | - add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtual page from everywhere |
|
158 | - add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100); |
|
159 | - /** Exclude Virtual Pages From Pages List **/ |
|
160 | - add_action('pre_get_posts', 'set_listing_request', 0); |
|
161 | - add_action('pre_get_posts', 'geodir_listing_loop_filter', 1); |
|
162 | - add_filter('excerpt_more', 'geodir_excerpt_more', 1000); |
|
163 | - add_filter('excerpt_length', 'geodir_excerpt_length', 1000); |
|
164 | - add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter |
|
157 | + add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtual page from everywhere |
|
158 | + add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100); |
|
159 | + /** Exclude Virtual Pages From Pages List **/ |
|
160 | + add_action('pre_get_posts', 'set_listing_request', 0); |
|
161 | + add_action('pre_get_posts', 'geodir_listing_loop_filter', 1); |
|
162 | + add_filter('excerpt_more', 'geodir_excerpt_more', 1000); |
|
163 | + add_filter('excerpt_length', 'geodir_excerpt_length', 1000); |
|
164 | + add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | */ |
224 | 224 | function geodir_unset_prev_theme_nav_location($newname) |
225 | 225 | { |
226 | - $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname); |
|
227 | - if ($geodir_theme_location) { |
|
228 | - update_option('geodir_theme_location_nav', $geodir_theme_location); |
|
229 | - } else { |
|
230 | - update_option('geodir_theme_location_nav', ''); |
|
231 | - } |
|
226 | + $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname); |
|
227 | + if ($geodir_theme_location) { |
|
228 | + update_option('geodir_theme_location_nav', $geodir_theme_location); |
|
229 | + } else { |
|
230 | + update_option('geodir_theme_location_nav', ''); |
|
231 | + } |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /// add action for theme switch to blank previous theme navigation location setting |
@@ -249,42 +249,42 @@ discard block |
||
249 | 249 | */ |
250 | 250 | function geodir_add_post_filters() |
251 | 251 | { |
252 | - /** |
|
253 | - * Contains all function for filtering listing. |
|
254 | - * |
|
255 | - * @since 1.0.0 |
|
256 | - * @package GeoDirectory |
|
257 | - */ |
|
258 | - include_once('geodirectory-functions/listing_filters.php'); |
|
252 | + /** |
|
253 | + * Contains all function for filtering listing. |
|
254 | + * |
|
255 | + * @since 1.0.0 |
|
256 | + * @package GeoDirectory |
|
257 | + */ |
|
258 | + include_once('geodirectory-functions/listing_filters.php'); |
|
259 | 259 | |
260 | - // Theme My Login compatibility fix |
|
261 | - if ( isset( $_REQUEST['geodir_search'] ) && class_exists( 'Theme_My_Login' ) ) { |
|
262 | - remove_action( 'pre_get_posts', array( Theme_My_Login::get_object(), 'pre_get_posts' ) ); |
|
263 | - } |
|
260 | + // Theme My Login compatibility fix |
|
261 | + if ( isset( $_REQUEST['geodir_search'] ) && class_exists( 'Theme_My_Login' ) ) { |
|
262 | + remove_action( 'pre_get_posts', array( Theme_My_Login::get_object(), 'pre_get_posts' ) ); |
|
263 | + } |
|
264 | 264 | |
265 | - if ( isset( $_REQUEST['geodir_search'] ) ) { |
|
266 | - add_filter( 'geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3 ); |
|
267 | - add_filter( 'geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3 ); |
|
268 | - } |
|
265 | + if ( isset( $_REQUEST['geodir_search'] ) ) { |
|
266 | + add_filter( 'geodir_filter_widget_listings_fields', 'geodir_search_widget_location_filter_fields', 100, 3 ); |
|
267 | + add_filter( 'geodir_filter_widget_listings_orderby', 'geodir_search_widget_location_filter_orderby', 100, 3 ); |
|
268 | + } |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | |
272 | 272 | if (!function_exists('geodir_init_defaults')) { |
273 | - /** |
|
274 | - * Calls the function to register the GeoDirectory default CPT and taxonomies. |
|
275 | - * |
|
276 | - * @since 1.0.0 |
|
277 | - * @package GeoDirectory |
|
278 | - */ |
|
279 | - function geodir_init_defaults() |
|
280 | - { |
|
281 | - if (function_exists('geodir_register_defaults')) { |
|
273 | + /** |
|
274 | + * Calls the function to register the GeoDirectory default CPT and taxonomies. |
|
275 | + * |
|
276 | + * @since 1.0.0 |
|
277 | + * @package GeoDirectory |
|
278 | + */ |
|
279 | + function geodir_init_defaults() |
|
280 | + { |
|
281 | + if (function_exists('geodir_register_defaults')) { |
|
282 | 282 | |
283 | - geodir_register_defaults(); |
|
283 | + geodir_register_defaults(); |
|
284 | 284 | |
285 | - } |
|
285 | + } |
|
286 | 286 | |
287 | - } |
|
287 | + } |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -306,26 +306,26 @@ discard block |
||
306 | 306 | // CALLED ON 'sidebars_widgets' FILTER |
307 | 307 | |
308 | 308 | if (!function_exists('geodir_restrict_widget')) { |
309 | - /** |
|
310 | - * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page. |
|
311 | - * |
|
312 | - * @global bool $is_listing Sets the global value to true if on a GD category page. False if not. |
|
313 | - * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not. |
|
314 | - * @since 1.0.0 |
|
315 | - * @package GeoDirectory |
|
316 | - */ |
|
317 | - function geodir_restrict_widget() |
|
318 | - { |
|
319 | - global $is_listing, $is_single_place; |
|
309 | + /** |
|
310 | + * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page. |
|
311 | + * |
|
312 | + * @global bool $is_listing Sets the global value to true if on a GD category page. False if not. |
|
313 | + * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not. |
|
314 | + * @since 1.0.0 |
|
315 | + * @package GeoDirectory |
|
316 | + */ |
|
317 | + function geodir_restrict_widget() |
|
318 | + { |
|
319 | + global $is_listing, $is_single_place; |
|
320 | 320 | |
321 | - // set is listing |
|
322 | - (geodir_is_page('listing')) ? $is_listing = true : $is_listing = false; |
|
321 | + // set is listing |
|
322 | + (geodir_is_page('listing')) ? $is_listing = true : $is_listing = false; |
|
323 | 323 | |
324 | - // set is single place |
|
325 | - (geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false; |
|
324 | + // set is single place |
|
325 | + (geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false; |
|
326 | 326 | |
327 | 327 | |
328 | - } |
|
328 | + } |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -346,31 +346,31 @@ discard block |
||
346 | 346 | */ |
347 | 347 | function geodir_detail_page_sidebar_content_sorting() |
348 | 348 | { |
349 | - $arr_detail_page_sidebar_content = |
|
350 | - /** |
|
351 | - * An array of functions to be called to be displayed on the details (post) page sidebar. |
|
352 | - * |
|
353 | - * This filter can be used to remove sections of the details page sidebar, |
|
354 | - * add new sections or rearrange the order of the sections. |
|
355 | - * |
|
356 | - * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called. |
|
357 | - * @since 1.0.0 |
|
358 | - */ |
|
359 | - apply_filters('geodir_detail_page_sidebar_content', |
|
360 | - array('geodir_social_sharing_buttons', |
|
361 | - 'geodir_detail_page_google_analytics', |
|
362 | - 'geodir_edit_post_link', |
|
363 | - 'geodir_detail_page_review_rating', |
|
364 | - 'geodir_detail_page_more_info' |
|
365 | - ) // end of array |
|
366 | - ); // end of apply filter |
|
367 | - if (!empty($arr_detail_page_sidebar_content)) { |
|
368 | - foreach ($arr_detail_page_sidebar_content as $content_function) { |
|
369 | - if (function_exists($content_function)) { |
|
370 | - add_action('geodir_detail_page_sidebar', $content_function); |
|
371 | - } |
|
372 | - } |
|
373 | - } |
|
349 | + $arr_detail_page_sidebar_content = |
|
350 | + /** |
|
351 | + * An array of functions to be called to be displayed on the details (post) page sidebar. |
|
352 | + * |
|
353 | + * This filter can be used to remove sections of the details page sidebar, |
|
354 | + * add new sections or rearrange the order of the sections. |
|
355 | + * |
|
356 | + * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called. |
|
357 | + * @since 1.0.0 |
|
358 | + */ |
|
359 | + apply_filters('geodir_detail_page_sidebar_content', |
|
360 | + array('geodir_social_sharing_buttons', |
|
361 | + 'geodir_detail_page_google_analytics', |
|
362 | + 'geodir_edit_post_link', |
|
363 | + 'geodir_detail_page_review_rating', |
|
364 | + 'geodir_detail_page_more_info' |
|
365 | + ) // end of array |
|
366 | + ); // end of apply filter |
|
367 | + if (!empty($arr_detail_page_sidebar_content)) { |
|
368 | + foreach ($arr_detail_page_sidebar_content as $content_function) { |
|
369 | + if (function_exists($content_function)) { |
|
370 | + add_action('geodir_detail_page_sidebar', $content_function); |
|
371 | + } |
|
372 | + } |
|
373 | + } |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | add_action('geodir_after_edit_post_link', 'geodir_add_to_favourite_link', 1); |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | */ |
386 | 386 | function geodir_add_to_favourite_link() |
387 | 387 | { |
388 | - global $post, $preview; |
|
389 | - if (!$preview && geodir_is_page('detail')) { |
|
390 | - ?> |
|
388 | + global $post, $preview; |
|
389 | + if (!$preview && geodir_is_page('detail')) { |
|
390 | + ?> |
|
391 | 391 | <p class="edit_link"> |
392 | 392 | <?php geodir_favourite_html($post->post_author, $post->ID); ?> |
393 | 393 | </p> |
394 | 394 | <?php |
395 | - } |
|
395 | + } |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
@@ -406,41 +406,41 @@ discard block |
||
406 | 406 | */ |
407 | 407 | function geodir_social_sharing_buttons() |
408 | 408 | { |
409 | - global $preview; |
|
410 | - ob_start(); // Start buffering; |
|
411 | - /** |
|
412 | - * This action is called before the social buttons twitter,facebook and google plus are output in a containing div. |
|
413 | - * |
|
414 | - * @since 1.0.0 |
|
415 | - */ |
|
416 | - do_action('geodir_before_social_sharing_buttons'); |
|
417 | - if (!$preview) { |
|
418 | - ?> |
|
409 | + global $preview; |
|
410 | + ob_start(); // Start buffering; |
|
411 | + /** |
|
412 | + * This action is called before the social buttons twitter,facebook and google plus are output in a containing div. |
|
413 | + * |
|
414 | + * @since 1.0.0 |
|
415 | + */ |
|
416 | + do_action('geodir_before_social_sharing_buttons'); |
|
417 | + if (!$preview) { |
|
418 | + ?> |
|
419 | 419 | <div class="likethis"> |
420 | 420 | <?php geodir_twitter_tweet_button(); ?> |
421 | 421 | <?php geodir_fb_like_button(); ?> |
422 | 422 | <?php geodir_google_plus_button(); ?> |
423 | 423 | </div> |
424 | 424 | <?php |
425 | - }// end of if, if its a preview or not |
|
426 | - |
|
427 | - /** |
|
428 | - * This action is called after the social buttons twitter,facebook and google plus are output in a containing div. |
|
429 | - * |
|
430 | - * @since 1.0.0 |
|
431 | - */ |
|
432 | - do_action('geodir_after_social_sharing_buttons'); |
|
433 | - $content_html = ob_get_clean(); |
|
434 | - if (trim($content_html) != '') |
|
435 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
|
436 | - if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) { |
|
437 | - /** |
|
438 | - * Filter the geodir_social_sharing_buttons() function content. |
|
439 | - * |
|
440 | - * @param string $content_html The output html of the geodir_social_sharing_buttons() function. |
|
441 | - */ |
|
442 | - echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html); |
|
443 | - } |
|
425 | + }// end of if, if its a preview or not |
|
426 | + |
|
427 | + /** |
|
428 | + * This action is called after the social buttons twitter,facebook and google plus are output in a containing div. |
|
429 | + * |
|
430 | + * @since 1.0.0 |
|
431 | + */ |
|
432 | + do_action('geodir_after_social_sharing_buttons'); |
|
433 | + $content_html = ob_get_clean(); |
|
434 | + if (trim($content_html) != '') |
|
435 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
|
436 | + if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) { |
|
437 | + /** |
|
438 | + * Filter the geodir_social_sharing_buttons() function content. |
|
439 | + * |
|
440 | + * @param string $content_html The output html of the geodir_social_sharing_buttons() function. |
|
441 | + */ |
|
442 | + echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html); |
|
443 | + } |
|
444 | 444 | |
445 | 445 | |
446 | 446 | } |
@@ -458,46 +458,46 @@ discard block |
||
458 | 458 | */ |
459 | 459 | function geodir_edit_post_link() |
460 | 460 | { |
461 | - global $post, $preview; |
|
462 | - ob_start(); // Start buffering; |
|
463 | - /** |
|
464 | - * This is called before the edit post link html in the function geodir_edit_post_link() |
|
465 | - * |
|
466 | - * @since 1.0.0 |
|
467 | - */ |
|
468 | - do_action('geodir_before_edit_post_link'); |
|
469 | - if (!$preview) { |
|
470 | - $is_current_user_owner = geodir_listing_belong_to_current_user(); |
|
461 | + global $post, $preview; |
|
462 | + ob_start(); // Start buffering; |
|
463 | + /** |
|
464 | + * This is called before the edit post link html in the function geodir_edit_post_link() |
|
465 | + * |
|
466 | + * @since 1.0.0 |
|
467 | + */ |
|
468 | + do_action('geodir_before_edit_post_link'); |
|
469 | + if (!$preview) { |
|
470 | + $is_current_user_owner = geodir_listing_belong_to_current_user(); |
|
471 | 471 | |
472 | - if ($is_current_user_owner) { |
|
473 | - $post_id = $post->ID; |
|
472 | + if ($is_current_user_owner) { |
|
473 | + $post_id = $post->ID; |
|
474 | 474 | |
475 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
476 | - $post_id = (int)$_REQUEST['pid']; |
|
477 | - } |
|
475 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
476 | + $post_id = (int)$_REQUEST['pid']; |
|
477 | + } |
|
478 | 478 | |
479 | - $postlink = get_permalink(geodir_add_listing_page_id()); |
|
480 | - $editlink = geodir_getlink($postlink, array('pid' => $post_id), false); |
|
481 | - echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>'; |
|
482 | - } |
|
483 | - }// end of if, if its a preview or not |
|
484 | - /** |
|
485 | - * This is called after the edit post link html in the function geodir_edit_post_link() |
|
486 | - * |
|
487 | - * @since 1.0.0 |
|
488 | - */ |
|
489 | - do_action('geodir_after_edit_post_link'); |
|
490 | - $content_html = ob_get_clean(); |
|
491 | - if (trim($content_html) != '') |
|
492 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
|
493 | - if ((int)get_option('geodir_disable_user_links_section') != 1) { |
|
494 | - /** |
|
495 | - * Filter the geodir_edit_post_link() function content. |
|
496 | - * |
|
497 | - * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
498 | - */ |
|
499 | - echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html); |
|
500 | - } |
|
479 | + $postlink = get_permalink(geodir_add_listing_page_id()); |
|
480 | + $editlink = geodir_getlink($postlink, array('pid' => $post_id), false); |
|
481 | + echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>'; |
|
482 | + } |
|
483 | + }// end of if, if its a preview or not |
|
484 | + /** |
|
485 | + * This is called after the edit post link html in the function geodir_edit_post_link() |
|
486 | + * |
|
487 | + * @since 1.0.0 |
|
488 | + */ |
|
489 | + do_action('geodir_after_edit_post_link'); |
|
490 | + $content_html = ob_get_clean(); |
|
491 | + if (trim($content_html) != '') |
|
492 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
|
493 | + if ((int)get_option('geodir_disable_user_links_section') != 1) { |
|
494 | + /** |
|
495 | + * Filter the geodir_edit_post_link() function content. |
|
496 | + * |
|
497 | + * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
498 | + */ |
|
499 | + echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html); |
|
500 | + } |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -511,42 +511,42 @@ discard block |
||
511 | 511 | */ |
512 | 512 | function geodir_detail_page_google_analytics() |
513 | 513 | { |
514 | - global $post,$preview; |
|
515 | - if($preview){return '';} |
|
516 | - $package_info = array(); |
|
517 | - $package_info = geodir_post_package_info($package_info, $post); |
|
514 | + global $post,$preview; |
|
515 | + if($preview){return '';} |
|
516 | + $package_info = array(); |
|
517 | + $package_info = geodir_post_package_info($package_info, $post); |
|
518 | 518 | |
519 | - $id = trim(get_option('geodir_ga_account_id')); |
|
519 | + $id = trim(get_option('geodir_ga_account_id')); |
|
520 | 520 | |
521 | - if (!$id) { |
|
522 | - return; //if no Google Analytics ID then bail. |
|
523 | - } |
|
521 | + if (!$id) { |
|
522 | + return; //if no Google Analytics ID then bail. |
|
523 | + } |
|
524 | 524 | |
525 | - ob_start(); // Start buffering; |
|
526 | - /** |
|
527 | - * This is called before the edit post link html in the function geodir_detail_page_google_analytics() |
|
528 | - * |
|
529 | - * @since 1.0.0 |
|
530 | - */ |
|
531 | - do_action('geodir_before_google_analytics'); |
|
525 | + ob_start(); // Start buffering; |
|
526 | + /** |
|
527 | + * This is called before the edit post link html in the function geodir_detail_page_google_analytics() |
|
528 | + * |
|
529 | + * @since 1.0.0 |
|
530 | + */ |
|
531 | + do_action('geodir_before_google_analytics'); |
|
532 | 532 | |
533 | - $refresh_time = get_option('geodir_ga_refresh_time', 5); |
|
534 | - /** |
|
535 | - * Filter the time interval to check & refresh new users results. |
|
536 | - * |
|
537 | - * @since 1.5.9 |
|
538 | - * |
|
539 | - * @param int $refresh_time Time interval to check & refresh new users results. |
|
540 | - */ |
|
541 | - $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time); |
|
542 | - $refresh_time = absint($refresh_time * 1000); |
|
533 | + $refresh_time = get_option('geodir_ga_refresh_time', 5); |
|
534 | + /** |
|
535 | + * Filter the time interval to check & refresh new users results. |
|
536 | + * |
|
537 | + * @since 1.5.9 |
|
538 | + * |
|
539 | + * @param int $refresh_time Time interval to check & refresh new users results. |
|
540 | + */ |
|
541 | + $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time); |
|
542 | + $refresh_time = absint($refresh_time * 1000); |
|
543 | 543 | |
544 | - $hide_refresh = get_option('geodir_ga_auto_refresh'); |
|
544 | + $hide_refresh = get_option('geodir_ga_auto_refresh'); |
|
545 | 545 | |
546 | - $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0; |
|
547 | - if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) { |
|
548 | - $page_url = urlencode($_SERVER['REQUEST_URI']); |
|
549 | - ?> |
|
546 | + $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0; |
|
547 | + if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) { |
|
548 | + $page_url = urlencode($_SERVER['REQUEST_URI']); |
|
549 | + ?> |
|
550 | 550 | <script type="text/javascript"> |
551 | 551 | var gd_gaTimeOut; |
552 | 552 | var gd_gaTime = parseInt('<?php echo $refresh_time;?>'); |
@@ -798,15 +798,15 @@ discard block |
||
798 | 798 | var labels = results[1].rows.map(function(row) { return +row[0]; }); |
799 | 799 | |
800 | 800 | <?php |
801 | - // Here we list the shorthand days of the week so it can be used in translation. |
|
802 | - __("Mon",'geodirectory'); |
|
803 | - __("Tue",'geodirectory'); |
|
804 | - __("Wed",'geodirectory'); |
|
805 | - __("Thu",'geodirectory'); |
|
806 | - __("Fri",'geodirectory'); |
|
807 | - __("Sat",'geodirectory'); |
|
808 | - __("Sun",'geodirectory'); |
|
809 | - ?> |
|
801 | + // Here we list the shorthand days of the week so it can be used in translation. |
|
802 | + __("Mon",'geodirectory'); |
|
803 | + __("Tue",'geodirectory'); |
|
804 | + __("Wed",'geodirectory'); |
|
805 | + __("Thu",'geodirectory'); |
|
806 | + __("Fri",'geodirectory'); |
|
807 | + __("Sat",'geodirectory'); |
|
808 | + __("Sun",'geodirectory'); |
|
809 | + ?> |
|
810 | 810 | |
811 | 811 | labels = [ |
812 | 812 | "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>", |
@@ -1055,24 +1055,24 @@ discard block |
||
1055 | 1055 | </span> |
1056 | 1056 | |
1057 | 1057 | <?php |
1058 | - } |
|
1059 | - /** |
|
1060 | - * This is called after the edit post link html in the function geodir_detail_page_google_analytics() |
|
1061 | - * |
|
1062 | - * @since 1.0.0 |
|
1063 | - */ |
|
1064 | - do_action('geodir_after_google_analytics'); |
|
1065 | - $content_html = ob_get_clean(); |
|
1066 | - if (trim($content_html) != '') |
|
1067 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
|
1068 | - if ((int)get_option('geodir_disable_google_analytics_section') != 1) { |
|
1069 | - /** |
|
1070 | - * Filter the geodir_edit_post_link() function content. |
|
1071 | - * |
|
1072 | - * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
1073 | - */ |
|
1074 | - echo $content_html = apply_filters('geodir_google_analytic_html', $content_html); |
|
1075 | - } |
|
1058 | + } |
|
1059 | + /** |
|
1060 | + * This is called after the edit post link html in the function geodir_detail_page_google_analytics() |
|
1061 | + * |
|
1062 | + * @since 1.0.0 |
|
1063 | + */ |
|
1064 | + do_action('geodir_after_google_analytics'); |
|
1065 | + $content_html = ob_get_clean(); |
|
1066 | + if (trim($content_html) != '') |
|
1067 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
|
1068 | + if ((int)get_option('geodir_disable_google_analytics_section') != 1) { |
|
1069 | + /** |
|
1070 | + * Filter the geodir_edit_post_link() function content. |
|
1071 | + * |
|
1072 | + * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
1073 | + */ |
|
1074 | + echo $content_html = apply_filters('geodir_google_analytic_html', $content_html); |
|
1075 | + } |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | /** |
@@ -1089,94 +1089,94 @@ discard block |
||
1089 | 1089 | */ |
1090 | 1090 | function geodir_detail_page_review_rating() |
1091 | 1091 | { |
1092 | - global $post, $preview, $post_images; |
|
1092 | + global $post, $preview, $post_images; |
|
1093 | 1093 | |
1094 | - if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) { |
|
1095 | - return; |
|
1096 | - } |
|
1097 | - ob_start(); // Start buffering; |
|
1098 | - /** |
|
1099 | - * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1100 | - * |
|
1101 | - * This is called outside the check for an actual rating and the check for preview page. |
|
1102 | - * |
|
1103 | - * @since 1.0.0 |
|
1104 | - */ |
|
1105 | - do_action('geodir_before_detail_page_review_rating'); |
|
1106 | - |
|
1107 | - $comment_count = geodir_get_review_count_total($post->ID); |
|
1108 | - $post_avgratings = geodir_get_post_rating($post->ID); |
|
1109 | - |
|
1110 | - if ($post_avgratings != 0 && !$preview) { |
|
1111 | - /** |
|
1112 | - * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1113 | - * |
|
1114 | - * This is called inside the check for an actual rating and the check for preview page. |
|
1115 | - * |
|
1116 | - * @since 1.0.0 |
|
1117 | - * @param float $post_avgratings Average rating for the current post. |
|
1118 | - * @param int $post->ID Current post ID. |
|
1119 | - */ |
|
1120 | - do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID); |
|
1121 | - |
|
1122 | - $html = '<p style=" float:left;">'; |
|
1123 | - $html .= geodir_get_rating_stars($post_avgratings, $post->ID); |
|
1124 | - $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">'; |
|
1125 | - $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings; |
|
1094 | + if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) { |
|
1095 | + return; |
|
1096 | + } |
|
1097 | + ob_start(); // Start buffering; |
|
1098 | + /** |
|
1099 | + * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1100 | + * |
|
1101 | + * This is called outside the check for an actual rating and the check for preview page. |
|
1102 | + * |
|
1103 | + * @since 1.0.0 |
|
1104 | + */ |
|
1105 | + do_action('geodir_before_detail_page_review_rating'); |
|
1106 | + |
|
1107 | + $comment_count = geodir_get_review_count_total($post->ID); |
|
1108 | + $post_avgratings = geodir_get_post_rating($post->ID); |
|
1109 | + |
|
1110 | + if ($post_avgratings != 0 && !$preview) { |
|
1111 | + /** |
|
1112 | + * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1113 | + * |
|
1114 | + * This is called inside the check for an actual rating and the check for preview page. |
|
1115 | + * |
|
1116 | + * @since 1.0.0 |
|
1117 | + * @param float $post_avgratings Average rating for the current post. |
|
1118 | + * @param int $post->ID Current post ID. |
|
1119 | + */ |
|
1120 | + do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID); |
|
1121 | + |
|
1122 | + $html = '<p style=" float:left;">'; |
|
1123 | + $html .= geodir_get_rating_stars($post_avgratings, $post->ID); |
|
1124 | + $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">'; |
|
1125 | + $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings; |
|
1126 | 1126 | |
1127 | 1127 | $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory'); |
1128 | 1128 | |
1129 | 1129 | $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />'; |
1130 | 1130 | |
1131 | - $html .= '<span class="item">'; |
|
1132 | - $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>'; |
|
1131 | + $html .= '<span class="item">'; |
|
1132 | + $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>'; |
|
1133 | 1133 | |
1134 | - if ($post_images) { |
|
1135 | - foreach ($post_images as $img) { |
|
1136 | - $post_img = $img->src; |
|
1137 | - break; |
|
1138 | - } |
|
1139 | - } |
|
1140 | - |
|
1141 | - if (isset($post_img) && $post_img) { |
|
1142 | - $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />'; |
|
1143 | - } |
|
1144 | - |
|
1145 | - $html .= '</span>'; |
|
1146 | - |
|
1147 | - echo $html .= '</div>'; |
|
1148 | - /** |
|
1149 | - * This is called after the rating html in the function geodir_detail_page_review_rating(). |
|
1150 | - * |
|
1151 | - * This is called inside the check for an actual rating and the check for preview page. |
|
1152 | - * |
|
1153 | - * @since 1.0.0 |
|
1154 | - * @param float $post_avgratings Average rating for the current post. |
|
1155 | - * @param int $post->ID Current post ID. |
|
1156 | - */ |
|
1157 | - do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID); |
|
1158 | - } |
|
1159 | - /** |
|
1160 | - * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1161 | - * |
|
1162 | - * This is called outside the check for an actual rating and the check for preview page. |
|
1163 | - * |
|
1164 | - * @since 1.0.0 |
|
1165 | - */ |
|
1166 | - do_action('geodir_after_detail_page_review_rating'); |
|
1167 | - $content_html = ob_get_clean(); |
|
1168 | - if (trim($content_html) != '') { |
|
1169 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>'; |
|
1170 | - } |
|
1171 | - if ((int)get_option('geodir_disable_rating_info_section') != 1) { |
|
1172 | - /** |
|
1173 | - * Filter the geodir_detail_page_review_rating() function content. |
|
1174 | - * |
|
1175 | - * @since 1.0.0 |
|
1176 | - * @param string $content_html The output html of the geodir_detail_page_review_rating() function. |
|
1177 | - */ |
|
1178 | - echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html); |
|
1179 | - } |
|
1134 | + if ($post_images) { |
|
1135 | + foreach ($post_images as $img) { |
|
1136 | + $post_img = $img->src; |
|
1137 | + break; |
|
1138 | + } |
|
1139 | + } |
|
1140 | + |
|
1141 | + if (isset($post_img) && $post_img) { |
|
1142 | + $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />'; |
|
1143 | + } |
|
1144 | + |
|
1145 | + $html .= '</span>'; |
|
1146 | + |
|
1147 | + echo $html .= '</div>'; |
|
1148 | + /** |
|
1149 | + * This is called after the rating html in the function geodir_detail_page_review_rating(). |
|
1150 | + * |
|
1151 | + * This is called inside the check for an actual rating and the check for preview page. |
|
1152 | + * |
|
1153 | + * @since 1.0.0 |
|
1154 | + * @param float $post_avgratings Average rating for the current post. |
|
1155 | + * @param int $post->ID Current post ID. |
|
1156 | + */ |
|
1157 | + do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID); |
|
1158 | + } |
|
1159 | + /** |
|
1160 | + * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
1161 | + * |
|
1162 | + * This is called outside the check for an actual rating and the check for preview page. |
|
1163 | + * |
|
1164 | + * @since 1.0.0 |
|
1165 | + */ |
|
1166 | + do_action('geodir_after_detail_page_review_rating'); |
|
1167 | + $content_html = ob_get_clean(); |
|
1168 | + if (trim($content_html) != '') { |
|
1169 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>'; |
|
1170 | + } |
|
1171 | + if ((int)get_option('geodir_disable_rating_info_section') != 1) { |
|
1172 | + /** |
|
1173 | + * Filter the geodir_detail_page_review_rating() function content. |
|
1174 | + * |
|
1175 | + * @since 1.0.0 |
|
1176 | + * @param string $content_html The output html of the geodir_detail_page_review_rating() function. |
|
1177 | + */ |
|
1178 | + echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html); |
|
1179 | + } |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | /** |
@@ -1188,35 +1188,35 @@ discard block |
||
1188 | 1188 | */ |
1189 | 1189 | function geodir_detail_page_more_info() |
1190 | 1190 | { |
1191 | - ob_start(); // Start buffering; |
|
1192 | - /** |
|
1193 | - * This is called before the info section html. |
|
1194 | - * |
|
1195 | - * @since 1.0.0 |
|
1196 | - */ |
|
1197 | - do_action('geodir_before_detail_page_more_info'); |
|
1198 | - if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) { |
|
1199 | - echo $geodir_post_detail_fields; |
|
1200 | - } |
|
1201 | - /** |
|
1202 | - * This is called after the info section html. |
|
1203 | - * |
|
1204 | - * @since 1.0.0 |
|
1205 | - */ |
|
1206 | - do_action('geodir_after_detail_page_more_info'); |
|
1207 | - |
|
1208 | - $content_html = ob_get_clean(); |
|
1209 | - if (trim($content_html) != '') |
|
1210 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
|
1211 | - if ((int)get_option('geodir_disable_listing_info_section') != 1) { |
|
1212 | - /** |
|
1213 | - * Filter the output html for function geodir_detail_page_more_info(). |
|
1214 | - * |
|
1215 | - * @since 1.0.0 |
|
1216 | - * @param string $content_html The output html of the geodir_detail_page_more_info() function. |
|
1217 | - */ |
|
1218 | - echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html); |
|
1219 | - } |
|
1191 | + ob_start(); // Start buffering; |
|
1192 | + /** |
|
1193 | + * This is called before the info section html. |
|
1194 | + * |
|
1195 | + * @since 1.0.0 |
|
1196 | + */ |
|
1197 | + do_action('geodir_before_detail_page_more_info'); |
|
1198 | + if ($geodir_post_detail_fields = geodir_show_listing_info('detail')) { |
|
1199 | + echo $geodir_post_detail_fields; |
|
1200 | + } |
|
1201 | + /** |
|
1202 | + * This is called after the info section html. |
|
1203 | + * |
|
1204 | + * @since 1.0.0 |
|
1205 | + */ |
|
1206 | + do_action('geodir_after_detail_page_more_info'); |
|
1207 | + |
|
1208 | + $content_html = ob_get_clean(); |
|
1209 | + if (trim($content_html) != '') |
|
1210 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
|
1211 | + if ((int)get_option('geodir_disable_listing_info_section') != 1) { |
|
1212 | + /** |
|
1213 | + * Filter the output html for function geodir_detail_page_more_info(). |
|
1214 | + * |
|
1215 | + * @since 1.0.0 |
|
1216 | + * @param string $content_html The output html of the geodir_detail_page_more_info() function. |
|
1217 | + */ |
|
1218 | + echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html); |
|
1219 | + } |
|
1220 | 1220 | } |
1221 | 1221 | |
1222 | 1222 | |
@@ -1230,15 +1230,15 @@ discard block |
||
1230 | 1230 | */ |
1231 | 1231 | function geodir_localize_all_js_msg() |
1232 | 1232 | {// check_ajax_referer function is used to make sure no files are uploaded remotely but it will fail if used between https and non https so we do the check below of the urls |
1233 | - if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
1234 | - $ajax_url = admin_url('admin-ajax.php'); |
|
1235 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
1236 | - $ajax_url = admin_url('admin-ajax.php'); |
|
1237 | - } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
1238 | - $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php')); |
|
1239 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
1240 | - $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php')); |
|
1241 | - } |
|
1233 | + if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
1234 | + $ajax_url = admin_url('admin-ajax.php'); |
|
1235 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
1236 | + $ajax_url = admin_url('admin-ajax.php'); |
|
1237 | + } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
1238 | + $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php')); |
|
1239 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
1240 | + $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php')); |
|
1241 | + } |
|
1242 | 1242 | |
1243 | 1243 | /** |
1244 | 1244 | * Filter the allowed image type extensions for post images. |
@@ -1248,62 +1248,62 @@ discard block |
||
1248 | 1248 | */ |
1249 | 1249 | $allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png')); |
1250 | 1250 | |
1251 | - $default_marker_icon = get_option('geodir_default_marker_icon'); |
|
1252 | - $default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34)); |
|
1253 | - $default_marker_width = $default_marker_size['w']; |
|
1254 | - $default_marker_height = $default_marker_size['h']; |
|
1251 | + $default_marker_icon = get_option('geodir_default_marker_icon'); |
|
1252 | + $default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34)); |
|
1253 | + $default_marker_width = $default_marker_size['w']; |
|
1254 | + $default_marker_height = $default_marker_size['h']; |
|
1255 | 1255 | |
1256 | - $arr_alert_msg = array( |
|
1257 | - 'geodir_plugin_url' => geodir_plugin_url(), |
|
1258 | - 'geodir_admin_ajax_url' => $ajax_url, |
|
1259 | - 'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'), |
|
1260 | - 'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'), |
|
1261 | - 'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'), |
|
1262 | - 'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'), |
|
1263 | - //start not show alert msg |
|
1264 | - 'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'), |
|
1265 | - 'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'), |
|
1266 | - 'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'), |
|
1267 | - 'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'), |
|
1268 | - 'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'), |
|
1269 | - // end not show alert msg |
|
1270 | - 'my_place_listing_del' => __('Are you sure you wish to delete this listing?', 'geodirectory'), |
|
1271 | - 'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'), |
|
1272 | - //start not show alert msg |
|
1273 | - 'rating_error_msg' => __('Error : please retry', 'geodirectory'), |
|
1274 | - 'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'), |
|
1275 | - 'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'), |
|
1276 | - 'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'), |
|
1277 | - 'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'), |
|
1278 | - 'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'), |
|
1279 | - 'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'), |
|
1280 | - 'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'), |
|
1281 | - 'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'), |
|
1282 | - 'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'), |
|
1283 | - 'geodir_field_id_required' => __('This field is required.', 'geodirectory'), |
|
1284 | - 'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'), |
|
1285 | - 'geodir_default_marker_icon' => $default_marker_icon, |
|
1286 | - 'geodir_default_marker_w' => $default_marker_width, |
|
1287 | - 'geodir_default_marker_h' => $default_marker_height, |
|
1288 | - 'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG, |
|
1289 | - 'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG, |
|
1290 | - 'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'), |
|
1291 | - 'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'), |
|
1292 | - 'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'), |
|
1293 | - 'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'), |
|
1294 | - 'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'), |
|
1295 | - 'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'), |
|
1296 | - 'err_empty_review' => __('Please type a review.', 'geodirectory'), |
|
1297 | - 'err_empty_reply' => __('Please type a reply.', 'geodirectory'), |
|
1298 | - /* on/off dragging for phone devices */ |
|
1299 | - 'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false, |
|
1300 | - 'geodir_is_mobile' => wp_is_mobile() ? true : false, |
|
1301 | - 'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'), |
|
1302 | - 'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'), |
|
1303 | - 'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'), |
|
1304 | - 'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'), |
|
1305 | - 'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'), |
|
1306 | - 'geodir_action_remove' => __('Remove', 'geodirectory'), |
|
1256 | + $arr_alert_msg = array( |
|
1257 | + 'geodir_plugin_url' => geodir_plugin_url(), |
|
1258 | + 'geodir_admin_ajax_url' => $ajax_url, |
|
1259 | + 'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'), |
|
1260 | + 'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'), |
|
1261 | + 'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'), |
|
1262 | + 'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'), |
|
1263 | + //start not show alert msg |
|
1264 | + 'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'), |
|
1265 | + 'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'), |
|
1266 | + 'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'), |
|
1267 | + 'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'), |
|
1268 | + 'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'), |
|
1269 | + // end not show alert msg |
|
1270 | + 'my_place_listing_del' => __('Are you sure you wish to delete this listing?', 'geodirectory'), |
|
1271 | + 'my_main_listing_del' => __('Deleting the main listing of a franchise will turn all franchises in regular listings. Are you sure wish to delete this main listing?', 'geodirectory'), |
|
1272 | + //start not show alert msg |
|
1273 | + 'rating_error_msg' => __('Error : please retry', 'geodirectory'), |
|
1274 | + 'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'), |
|
1275 | + 'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'), |
|
1276 | + 'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'), |
|
1277 | + 'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'), |
|
1278 | + 'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'), |
|
1279 | + 'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'), |
|
1280 | + 'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'), |
|
1281 | + 'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'), |
|
1282 | + 'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'), |
|
1283 | + 'geodir_field_id_required' => __('This field is required.', 'geodirectory'), |
|
1284 | + 'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'), |
|
1285 | + 'geodir_default_marker_icon' => $default_marker_icon, |
|
1286 | + 'geodir_default_marker_w' => $default_marker_width, |
|
1287 | + 'geodir_default_marker_h' => $default_marker_height, |
|
1288 | + 'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG, |
|
1289 | + 'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG, |
|
1290 | + 'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'), |
|
1291 | + 'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'), |
|
1292 | + 'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'), |
|
1293 | + 'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'), |
|
1294 | + 'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'), |
|
1295 | + 'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'), |
|
1296 | + 'err_empty_review' => __('Please type a review.', 'geodirectory'), |
|
1297 | + 'err_empty_reply' => __('Please type a reply.', 'geodirectory'), |
|
1298 | + /* on/off dragging for phone devices */ |
|
1299 | + 'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false, |
|
1300 | + 'geodir_is_mobile' => wp_is_mobile() ? true : false, |
|
1301 | + 'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'), |
|
1302 | + 'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'), |
|
1303 | + 'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'), |
|
1304 | + 'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'), |
|
1305 | + 'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'), |
|
1306 | + 'geodir_action_remove' => __('Remove', 'geodirectory'), |
|
1307 | 1307 | 'geodir_txt_all_files' => __('Allowed files', 'geodirectory'), |
1308 | 1308 | 'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'), |
1309 | 1309 | 'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '', |
@@ -1311,41 +1311,41 @@ discard block |
||
1311 | 1311 | 'geodir_txt_form_searching' => __('Searching...', 'geodirectory'), |
1312 | 1312 | 'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '', |
1313 | 1313 | 'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '', |
1314 | - 'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false, |
|
1315 | - 'geodir_map_name' => geodir_map_name(), |
|
1316 | - 'osmStart' => __('Start', 'geodirectory'), |
|
1317 | - 'osmVia' => __('Via {viaNumber}', 'geodirectory'), |
|
1318 | - 'osmEnd' => __('Enter Your Location', 'geodirectory'), |
|
1319 | - 'ga_delete_check' => __('Do you wish to Deauthorize and break Analytics?', 'geodirectory'), |
|
1320 | - 'geoMyLocation' => __('My Location', 'geodirectory'), |
|
1321 | - 'geoErrUNKNOWN_ERROR' => addslashes(__('Unable to find your location', 'geodirectory')), |
|
1322 | - 'geoErrPERMISSION_DENINED' => addslashes(__('Permission denied in finding your location', 'geodirectory')), |
|
1323 | - 'geoErrPOSITION_UNAVAILABLE' => addslashes(__('Your location is currently unknown', 'geodirectory')), |
|
1324 | - 'geoErrBREAK' => addslashes(__('Attempt to find location took too long', 'geodirectory')), |
|
1325 | - 'geoErrDEFAULT' => addslashes(__('Location detection not supported in browser', 'geodirectory')), |
|
1314 | + 'multirating' => defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_rating') ? true : false, |
|
1315 | + 'geodir_map_name' => geodir_map_name(), |
|
1316 | + 'osmStart' => __('Start', 'geodirectory'), |
|
1317 | + 'osmVia' => __('Via {viaNumber}', 'geodirectory'), |
|
1318 | + 'osmEnd' => __('Enter Your Location', 'geodirectory'), |
|
1319 | + 'ga_delete_check' => __('Do you wish to Deauthorize and break Analytics?', 'geodirectory'), |
|
1320 | + 'geoMyLocation' => __('My Location', 'geodirectory'), |
|
1321 | + 'geoErrUNKNOWN_ERROR' => addslashes(__('Unable to find your location', 'geodirectory')), |
|
1322 | + 'geoErrPERMISSION_DENINED' => addslashes(__('Permission denied in finding your location', 'geodirectory')), |
|
1323 | + 'geoErrPOSITION_UNAVAILABLE' => addslashes(__('Your location is currently unknown', 'geodirectory')), |
|
1324 | + 'geoErrBREAK' => addslashes(__('Attempt to find location took too long', 'geodirectory')), |
|
1325 | + 'geoErrDEFAULT' => addslashes(__('Location detection not supported in browser', 'geodirectory')), |
|
1326 | 1326 | 'mapLanguage' => geodir_get_map_default_language() |
1327 | - ); |
|
1328 | - |
|
1329 | - /** |
|
1330 | - * Filters the translated JS strings from function geodir_localize_all_js_msg(). |
|
1331 | - * |
|
1332 | - * With this filter you can add, remove or change translated JS strings. |
|
1333 | - * You should add your own translations to this if you are building an addon rather than adding another script block. |
|
1334 | - * |
|
1335 | - * @since 1.0.0 |
|
1336 | - */ |
|
1337 | - $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg); |
|
1338 | - |
|
1339 | - foreach ($arr_alert_msg as $key => $value) { |
|
1340 | - if (!is_scalar($value)) |
|
1341 | - continue; |
|
1342 | - $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8'); |
|
1343 | - } |
|
1327 | + ); |
|
1328 | + |
|
1329 | + /** |
|
1330 | + * Filters the translated JS strings from function geodir_localize_all_js_msg(). |
|
1331 | + * |
|
1332 | + * With this filter you can add, remove or change translated JS strings. |
|
1333 | + * You should add your own translations to this if you are building an addon rather than adding another script block. |
|
1334 | + * |
|
1335 | + * @since 1.0.0 |
|
1336 | + */ |
|
1337 | + $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg); |
|
1344 | 1338 | |
1345 | - $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';'; |
|
1346 | - echo '<script>'; |
|
1347 | - echo $script; |
|
1348 | - echo '</script>'; |
|
1339 | + foreach ($arr_alert_msg as $key => $value) { |
|
1340 | + if (!is_scalar($value)) |
|
1341 | + continue; |
|
1342 | + $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8'); |
|
1343 | + } |
|
1344 | + |
|
1345 | + $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';'; |
|
1346 | + echo '<script>'; |
|
1347 | + echo $script; |
|
1348 | + echo '</script>'; |
|
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | add_action('admin_bar_menu', 'geodir_admin_bar_site_menu', 31); |
@@ -1361,11 +1361,11 @@ discard block |
||
1361 | 1361 | */ |
1362 | 1362 | function geodir_admin_bar_site_menu($wp_admin_bar) |
1363 | 1363 | { |
1364 | - if (get_option("geodir_installed")) { |
|
1365 | - if (current_user_can('manage_options')) { |
|
1366 | - $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory'))); |
|
1367 | - } |
|
1368 | - } |
|
1364 | + if (get_option("geodir_installed")) { |
|
1365 | + if (current_user_can('manage_options')) { |
|
1366 | + $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory'))); |
|
1367 | + } |
|
1368 | + } |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | add_action('geodir_before_listing', 'geodir_display_sort_options'); /*function in custom_functions.php*/ |
@@ -1391,25 +1391,25 @@ discard block |
||
1391 | 1391 | */ |
1392 | 1392 | function geodir_store_sidebars() |
1393 | 1393 | { |
1394 | - global $geodir_sidebars; |
|
1395 | - global $sidebars_widgets; |
|
1396 | - |
|
1397 | - if (!is_array($sidebars_widgets)) |
|
1398 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1399 | - $geodir_old_sidebars = array(); |
|
1400 | - |
|
1401 | - if (is_array($geodir_sidebars)) { |
|
1402 | - foreach ($geodir_sidebars as $val) { |
|
1403 | - if (is_array($sidebars_widgets)) { |
|
1404 | - if (array_key_exists($val, $sidebars_widgets)) |
|
1405 | - $geodir_old_sidebars[$val] = $sidebars_widgets[$val]; |
|
1406 | - else |
|
1407 | - $geodir_old_sidebars[$val] = array(); |
|
1408 | - } |
|
1409 | - } |
|
1410 | - } |
|
1411 | - update_option('geodir_sidebars', $geodir_old_sidebars); |
|
1412 | - geodir_option_version_backup('geodir_sidebars'); |
|
1394 | + global $geodir_sidebars; |
|
1395 | + global $sidebars_widgets; |
|
1396 | + |
|
1397 | + if (!is_array($sidebars_widgets)) |
|
1398 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1399 | + $geodir_old_sidebars = array(); |
|
1400 | + |
|
1401 | + if (is_array($geodir_sidebars)) { |
|
1402 | + foreach ($geodir_sidebars as $val) { |
|
1403 | + if (is_array($sidebars_widgets)) { |
|
1404 | + if (array_key_exists($val, $sidebars_widgets)) |
|
1405 | + $geodir_old_sidebars[$val] = $sidebars_widgets[$val]; |
|
1406 | + else |
|
1407 | + $geodir_old_sidebars[$val] = array(); |
|
1408 | + } |
|
1409 | + } |
|
1410 | + } |
|
1411 | + update_option('geodir_sidebars', $geodir_old_sidebars); |
|
1412 | + geodir_option_version_backup('geodir_sidebars'); |
|
1413 | 1413 | |
1414 | 1414 | } |
1415 | 1415 | |
@@ -1423,28 +1423,28 @@ discard block |
||
1423 | 1423 | */ |
1424 | 1424 | function geodir_restore_sidebars() |
1425 | 1425 | { |
1426 | - global $sidebars_widgets; |
|
1427 | - |
|
1428 | - if (!is_array($sidebars_widgets)) |
|
1429 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1430 | - |
|
1431 | - if (is_array($sidebars_widgets)) { |
|
1432 | - $geodir_old_sidebars = get_option('geodir_sidebars'); |
|
1433 | - if (is_array($geodir_old_sidebars)) { |
|
1434 | - foreach ($geodir_old_sidebars as $key => $val) { |
|
1435 | - if(0 === strpos($key, 'geodir_'))// if gd widget |
|
1436 | - { |
|
1437 | - $sidebars_widgets[$key] = $geodir_old_sidebars[$key]; |
|
1438 | - } |
|
1426 | + global $sidebars_widgets; |
|
1439 | 1427 | |
1428 | + if (!is_array($sidebars_widgets)) |
|
1429 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1440 | 1430 | |
1441 | - } |
|
1442 | - } |
|
1431 | + if (is_array($sidebars_widgets)) { |
|
1432 | + $geodir_old_sidebars = get_option('geodir_sidebars'); |
|
1433 | + if (is_array($geodir_old_sidebars)) { |
|
1434 | + foreach ($geodir_old_sidebars as $key => $val) { |
|
1435 | + if(0 === strpos($key, 'geodir_'))// if gd widget |
|
1436 | + { |
|
1437 | + $sidebars_widgets[$key] = $geodir_old_sidebars[$key]; |
|
1438 | + } |
|
1443 | 1439 | |
1444 | - } |
|
1445 | 1440 | |
1446 | - update_option('sidebars_widgets', $sidebars_widgets); |
|
1447 | - update_option('geodir_sidebars', ''); |
|
1441 | + } |
|
1442 | + } |
|
1443 | + |
|
1444 | + } |
|
1445 | + |
|
1446 | + update_option('sidebars_widgets', $sidebars_widgets); |
|
1447 | + update_option('geodir_sidebars', ''); |
|
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | add_action('geodir_after_listing_post_gridview', 'geodir_after_listing_post_gridview'); |
@@ -1457,9 +1457,9 @@ discard block |
||
1457 | 1457 | */ |
1458 | 1458 | function geodir_after_listing_post_gridview() |
1459 | 1459 | { |
1460 | - global $gridview_columns; |
|
1460 | + global $gridview_columns; |
|
1461 | 1461 | |
1462 | - $gridview_columns = ''; |
|
1462 | + $gridview_columns = ''; |
|
1463 | 1463 | |
1464 | 1464 | } |
1465 | 1465 | |
@@ -1487,11 +1487,11 @@ discard block |
||
1487 | 1487 | */ |
1488 | 1488 | function so_handle_038($url, $original_url, $_context) |
1489 | 1489 | { |
1490 | - if (strstr($url, "maps.google.com/maps/api/js") !== false) { |
|
1491 | - $url = str_replace("&", "&", $url); // or $url = $original_url |
|
1492 | - } |
|
1490 | + if (strstr($url, "maps.google.com/maps/api/js") !== false) { |
|
1491 | + $url = str_replace("&", "&", $url); // or $url = $original_url |
|
1492 | + } |
|
1493 | 1493 | |
1494 | - return $url; |
|
1494 | + return $url; |
|
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | |
@@ -1507,34 +1507,34 @@ discard block |
||
1507 | 1507 | function geodir_after_main_form_fields() { |
1508 | 1508 | global $gd_session; |
1509 | 1509 | |
1510 | - if (get_option('geodir_accept_term_condition')) { |
|
1511 | - global $post; |
|
1512 | - $term_condition = ''; |
|
1513 | - if (isset($_REQUEST['backandedit'])) { |
|
1514 | - $post = (object)$gd_session->get('listing'); |
|
1515 | - $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : ''; |
|
1516 | - } |
|
1517 | - |
|
1518 | - ?> |
|
1510 | + if (get_option('geodir_accept_term_condition')) { |
|
1511 | + global $post; |
|
1512 | + $term_condition = ''; |
|
1513 | + if (isset($_REQUEST['backandedit'])) { |
|
1514 | + $post = (object)$gd_session->get('listing'); |
|
1515 | + $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : ''; |
|
1516 | + } |
|
1517 | + |
|
1518 | + ?> |
|
1519 | 1519 | <div id="geodir_accept_term_condition_row" class="required_field geodir_form_row clearfix"> |
1520 | 1520 | <label> </label> |
1521 | 1521 | |
1522 | 1522 | <div class="geodir_taxonomy_field" style="float:left; width:70%;"> |
1523 | 1523 | <span style="display:block"> |
1524 | 1524 | <input class="main_list_selecter" type="checkbox" <?php if ($term_condition == '1') { |
1525 | - echo 'checked="checked"'; |
|
1526 | - } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition" |
|
1525 | + echo 'checked="checked"'; |
|
1526 | + } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition" |
|
1527 | 1527 | class="geodir_textfield" value="1" |
1528 | 1528 | style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a> |
1529 | 1529 | </span> |
1530 | 1530 | </div> |
1531 | 1531 | <span class="geodir_message_error"><?php if (isset($required_msg)) { |
1532 | - _e($required_msg, 'geodirectory'); |
|
1533 | - } ?></span> |
|
1532 | + _e($required_msg, 'geodirectory'); |
|
1533 | + } ?></span> |
|
1534 | 1534 | </div> |
1535 | 1535 | <?php |
1536 | 1536 | |
1537 | - } |
|
1537 | + } |
|
1538 | 1538 | } |
1539 | 1539 | |
1540 | 1540 | |
@@ -1559,42 +1559,42 @@ discard block |
||
1559 | 1559 | */ |
1560 | 1560 | function geodir_detail_page_tab_is_display($is_display, $tab) |
1561 | 1561 | { |
1562 | - global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; |
|
1562 | + global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; |
|
1563 | 1563 | |
1564 | - if ($tab == 'post_profile') { |
|
1565 | - /** This action is documented in geodirectory_template_actions.php */ |
|
1566 | - $desc_limit = apply_filters('geodir_description_field_desc_limit', ''); |
|
1564 | + if ($tab == 'post_profile') { |
|
1565 | + /** This action is documented in geodirectory_template_actions.php */ |
|
1566 | + $desc_limit = apply_filters('geodir_description_field_desc_limit', ''); |
|
1567 | 1567 | |
1568 | - if (!($desc_limit === '' || (int)$desc_limit > 0)) { |
|
1569 | - $is_display = false; |
|
1570 | - } |
|
1571 | - } |
|
1568 | + if (!($desc_limit === '' || (int)$desc_limit > 0)) { |
|
1569 | + $is_display = false; |
|
1570 | + } |
|
1571 | + } |
|
1572 | 1572 | |
1573 | - if ($tab == 'post_info') |
|
1574 | - $is_display = (!empty($geodir_post_detail_fields)) ? true : false; |
|
1573 | + if ($tab == 'post_info') |
|
1574 | + $is_display = (!empty($geodir_post_detail_fields)) ? true : false; |
|
1575 | 1575 | |
1576 | - if ($tab == 'post_images') |
|
1577 | - $is_display = (!empty($post_images)) ? true : false; |
|
1576 | + if ($tab == 'post_images') |
|
1577 | + $is_display = (!empty($post_images)) ? true : false; |
|
1578 | 1578 | |
1579 | - if ($tab == 'post_video') |
|
1580 | - $is_display = (!empty($video)) ? true : false; |
|
1579 | + if ($tab == 'post_video') |
|
1580 | + $is_display = (!empty($video)) ? true : false; |
|
1581 | 1581 | |
1582 | - if ($tab == 'special_offers') |
|
1583 | - $is_display = (!empty($special_offers)) ? true : false; |
|
1582 | + if ($tab == 'special_offers') |
|
1583 | + $is_display = (!empty($special_offers)) ? true : false; |
|
1584 | 1584 | |
1585 | - if ($tab == 'reviews') |
|
1586 | - $is_display = (geodir_is_page('detail')) ? true : false; |
|
1585 | + if ($tab == 'reviews') |
|
1586 | + $is_display = (geodir_is_page('detail')) ? true : false; |
|
1587 | 1587 | |
1588 | - if ($tab == 'related_listing') { |
|
1589 | - $message = __('No listings found which match your selection.', 'geodirectory'); |
|
1588 | + if ($tab == 'related_listing') { |
|
1589 | + $message = __('No listings found which match your selection.', 'geodirectory'); |
|
1590 | 1590 | |
1591 | - /** This action is documented in geodirectory-functions/template_functions.php */ |
|
1592 | - $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false); |
|
1591 | + /** This action is documented in geodirectory-functions/template_functions.php */ |
|
1592 | + $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false); |
|
1593 | 1593 | |
1594 | - $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true; |
|
1595 | - } |
|
1594 | + $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true; |
|
1595 | + } |
|
1596 | 1596 | |
1597 | - return $is_display; |
|
1597 | + return $is_display; |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | |
@@ -1610,69 +1610,69 @@ discard block |
||
1610 | 1610 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
1611 | 1611 | */ |
1612 | 1612 | function geodir_changes_in_custom_fields_table() { |
1613 | - global $wpdb, $plugin_prefix; |
|
1613 | + global $wpdb, $plugin_prefix; |
|
1614 | 1614 | |
1615 | 1615 | // Remove unused virtual page |
1616 | 1616 | $listings_page_id = (int)get_option('geodir_listing_page'); |
1617 | 1617 | if ($listings_page_id) { |
1618 | 1618 | $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page'))); |
1619 | - delete_option('geodir_listing_page'); |
|
1619 | + delete_option('geodir_listing_page'); |
|
1620 | 1620 | } |
1621 | 1621 | |
1622 | - if (!get_option('geodir_changes_in_custom_fields_table')) { |
|
1623 | - $wpdb->query( |
|
1624 | - $wpdb->prepare( |
|
1625 | - "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s", |
|
1626 | - array('1', '1', 'admin') |
|
1627 | - ) |
|
1628 | - ); |
|
1622 | + if (!get_option('geodir_changes_in_custom_fields_table')) { |
|
1623 | + $wpdb->query( |
|
1624 | + $wpdb->prepare( |
|
1625 | + "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s", |
|
1626 | + array('1', '1', 'admin') |
|
1627 | + ) |
|
1628 | + ); |
|
1629 | 1629 | |
1630 | 1630 | |
1631 | - /* --- terms meta value set --- */ |
|
1631 | + /* --- terms meta value set --- */ |
|
1632 | 1632 | |
1633 | - update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png'); |
|
1633 | + update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png'); |
|
1634 | 1634 | |
1635 | - $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%'))); |
|
1635 | + $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%'))); |
|
1636 | 1636 | |
1637 | - if (!empty($options_data)) { |
|
1637 | + if (!empty($options_data)) { |
|
1638 | 1638 | |
1639 | - foreach ($options_data as $optobj) { |
|
1639 | + foreach ($options_data as $optobj) { |
|
1640 | 1640 | |
1641 | - $option_val = str_replace('tax_meta_', '', $optobj->option_name); |
|
1641 | + $option_val = str_replace('tax_meta_', '', $optobj->option_name); |
|
1642 | 1642 | |
1643 | - $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val))); |
|
1643 | + $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val))); |
|
1644 | 1644 | |
1645 | - if (!empty($taxonomies_data)) { |
|
1645 | + if (!empty($taxonomies_data)) { |
|
1646 | 1646 | |
1647 | - foreach ($taxonomies_data as $taxobj) { |
|
1647 | + foreach ($taxonomies_data as $taxobj) { |
|
1648 | 1648 | |
1649 | - $taxObject = get_taxonomy($taxobj->taxonomy); |
|
1650 | - $post_type = $taxObject->object_type[0]; |
|
1649 | + $taxObject = get_taxonomy($taxobj->taxonomy); |
|
1650 | + $post_type = $taxObject->object_type[0]; |
|
1651 | 1651 | |
1652 | - $opt_value = 'tax_meta_' . $post_type . '_' . $option_val; |
|
1652 | + $opt_value = 'tax_meta_' . $post_type . '_' . $option_val; |
|
1653 | 1653 | |
1654 | - $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val))); |
|
1654 | + $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val))); |
|
1655 | 1655 | |
1656 | - if ($duplicate_data) { |
|
1656 | + if ($duplicate_data) { |
|
1657 | 1657 | |
1658 | - $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id))); |
|
1658 | + $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id))); |
|
1659 | 1659 | |
1660 | - } else { |
|
1660 | + } else { |
|
1661 | 1661 | |
1662 | - $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload))); |
|
1662 | + $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload))); |
|
1663 | 1663 | |
1664 | - } |
|
1664 | + } |
|
1665 | 1665 | |
1666 | - } |
|
1666 | + } |
|
1667 | 1667 | |
1668 | - } |
|
1668 | + } |
|
1669 | 1669 | |
1670 | - } |
|
1671 | - } |
|
1670 | + } |
|
1671 | + } |
|
1672 | 1672 | |
1673 | - update_option('geodir_changes_in_custom_fields_table', '1'); |
|
1673 | + update_option('geodir_changes_in_custom_fields_table', '1'); |
|
1674 | 1674 | |
1675 | - } |
|
1675 | + } |
|
1676 | 1676 | |
1677 | 1677 | } |
1678 | 1678 | |
@@ -1691,24 +1691,24 @@ discard block |
||
1691 | 1691 | function geodir_location_slug_check($slug) |
1692 | 1692 | { |
1693 | 1693 | |
1694 | - global $wpdb, $table_prefix; |
|
1694 | + global $wpdb, $table_prefix; |
|
1695 | 1695 | |
1696 | - $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug))); |
|
1696 | + $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug))); |
|
1697 | 1697 | |
1698 | - if ($slug_exists) { |
|
1698 | + if ($slug_exists) { |
|
1699 | 1699 | |
1700 | - $suffix = 1; |
|
1701 | - do { |
|
1702 | - $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
1703 | - $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name))); |
|
1704 | - $suffix++; |
|
1705 | - } while ($location_slug_check && $suffix < 100); |
|
1700 | + $suffix = 1; |
|
1701 | + do { |
|
1702 | + $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
1703 | + $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name))); |
|
1704 | + $suffix++; |
|
1705 | + } while ($location_slug_check && $suffix < 100); |
|
1706 | 1706 | |
1707 | - $slug = $alt_location_name; |
|
1707 | + $slug = $alt_location_name; |
|
1708 | 1708 | |
1709 | - } |
|
1709 | + } |
|
1710 | 1710 | |
1711 | - return $slug; |
|
1711 | + return $slug; |
|
1712 | 1712 | |
1713 | 1713 | } |
1714 | 1714 | |
@@ -1733,42 +1733,42 @@ discard block |
||
1733 | 1733 | function geodir_update_term_slug($term_id, $tt_id, $taxonomy) |
1734 | 1734 | { |
1735 | 1735 | |
1736 | - global $wpdb, $plugin_prefix, $table_prefix; |
|
1736 | + global $wpdb, $plugin_prefix, $table_prefix; |
|
1737 | 1737 | |
1738 | - $tern_data = get_term_by('id', $term_id, $taxonomy); |
|
1738 | + $tern_data = get_term_by('id', $term_id, $taxonomy); |
|
1739 | 1739 | |
1740 | - $slug = $tern_data->slug; |
|
1740 | + $slug = $tern_data->slug; |
|
1741 | 1741 | |
1742 | - /** |
|
1743 | - * Filter if a term slug exists. |
|
1744 | - * |
|
1745 | - * @since 1.0.0 |
|
1746 | - * @package GeoDirectory |
|
1747 | - * @param bool $bool Default: false. |
|
1748 | - * @param string $slug The term slug. |
|
1749 | - * @param int $term_id The term ID. |
|
1750 | - */ |
|
1751 | - $slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id); |
|
1742 | + /** |
|
1743 | + * Filter if a term slug exists. |
|
1744 | + * |
|
1745 | + * @since 1.0.0 |
|
1746 | + * @package GeoDirectory |
|
1747 | + * @param bool $bool Default: false. |
|
1748 | + * @param string $slug The term slug. |
|
1749 | + * @param int $term_id The term ID. |
|
1750 | + */ |
|
1751 | + $slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id); |
|
1752 | 1752 | |
1753 | - if ($slug_exists) { |
|
1753 | + if ($slug_exists) { |
|
1754 | 1754 | |
1755 | - $suffix = 1; |
|
1756 | - do { |
|
1757 | - $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
1755 | + $suffix = 1; |
|
1756 | + do { |
|
1757 | + $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
1758 | 1758 | |
1759 | - /** This action is documented in geodirectory_hooks_actions.php */ |
|
1760 | - $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id); |
|
1759 | + /** This action is documented in geodirectory_hooks_actions.php */ |
|
1760 | + $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id); |
|
1761 | 1761 | |
1762 | - $suffix++; |
|
1763 | - } while ($term_slug_check && $suffix < 100); |
|
1762 | + $suffix++; |
|
1763 | + } while ($term_slug_check && $suffix < 100); |
|
1764 | 1764 | |
1765 | - $slug = $new_slug; |
|
1765 | + $slug = $new_slug; |
|
1766 | 1766 | |
1767 | - //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) ); |
|
1767 | + //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) ); |
|
1768 | 1768 | |
1769 | - $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id))); |
|
1769 | + $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id))); |
|
1770 | 1770 | |
1771 | - } |
|
1771 | + } |
|
1772 | 1772 | |
1773 | 1773 | // Update tag in detail table. |
1774 | 1774 | $taxonomy_obj = get_taxonomy($taxonomy); |
@@ -1809,21 +1809,21 @@ discard block |
||
1809 | 1809 | function geodir_term_slug_is_exists($slug_exists, $slug, $term_id) |
1810 | 1810 | { |
1811 | 1811 | |
1812 | - global $wpdb, $table_prefix; |
|
1812 | + global $wpdb, $table_prefix; |
|
1813 | 1813 | |
1814 | - $default_location = geodir_get_default_location(); |
|
1814 | + $default_location = geodir_get_default_location(); |
|
1815 | 1815 | |
1816 | - $country_slug = $default_location->country_slug; |
|
1817 | - $region_slug = $default_location->region_slug; |
|
1818 | - $city_slug = $default_location->city_slug; |
|
1816 | + $country_slug = $default_location->country_slug; |
|
1817 | + $region_slug = $default_location->region_slug; |
|
1818 | + $city_slug = $default_location->city_slug; |
|
1819 | 1819 | |
1820 | - if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) |
|
1821 | - return $slug_exists = true; |
|
1820 | + if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) |
|
1821 | + return $slug_exists = true; |
|
1822 | 1822 | |
1823 | - if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) |
|
1824 | - return $slug_exists = true; |
|
1823 | + if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) |
|
1824 | + return $slug_exists = true; |
|
1825 | 1825 | |
1826 | - return $slug_exists; |
|
1826 | + return $slug_exists; |
|
1827 | 1827 | } |
1828 | 1828 | |
1829 | 1829 | |
@@ -1843,75 +1843,75 @@ discard block |
||
1843 | 1843 | */ |
1844 | 1844 | function geodir_custom_page_title($title = '', $sep = '') |
1845 | 1845 | { |
1846 | - global $wp; |
|
1847 | - if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) { |
|
1848 | - return $title; |
|
1849 | - } |
|
1846 | + global $wp; |
|
1847 | + if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) { |
|
1848 | + return $title; |
|
1849 | + } |
|
1850 | 1850 | |
1851 | - if ($sep == '') { |
|
1852 | - /** |
|
1853 | - * Filter the page title separator. |
|
1854 | - * |
|
1855 | - * @since 1.0.0 |
|
1856 | - * @package GeoDirectory |
|
1857 | - * @param string $sep The separator, default: `|`. |
|
1858 | - */ |
|
1859 | - $sep = apply_filters('geodir_page_title_separator', '|'); |
|
1860 | - } |
|
1851 | + if ($sep == '') { |
|
1852 | + /** |
|
1853 | + * Filter the page title separator. |
|
1854 | + * |
|
1855 | + * @since 1.0.0 |
|
1856 | + * @package GeoDirectory |
|
1857 | + * @param string $sep The separator, default: `|`. |
|
1858 | + */ |
|
1859 | + $sep = apply_filters('geodir_page_title_separator', '|'); |
|
1860 | + } |
|
1861 | 1861 | |
1862 | 1862 | |
1863 | - $gd_page = ''; |
|
1864 | - if(geodir_is_page('home')){ |
|
1865 | - $gd_page = 'home'; |
|
1866 | - $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title; |
|
1867 | - } |
|
1868 | - elseif(geodir_is_page('detail')){ |
|
1869 | - $gd_page = 'detail'; |
|
1870 | - $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title; |
|
1871 | - } |
|
1872 | - elseif(geodir_is_page('pt')){ |
|
1873 | - $gd_page = 'pt'; |
|
1874 | - $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title; |
|
1875 | - } |
|
1876 | - elseif(geodir_is_page('listing')){ |
|
1877 | - $gd_page = 'listing'; |
|
1878 | - $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title; |
|
1879 | - } |
|
1880 | - elseif(geodir_is_page('location')){ |
|
1881 | - $gd_page = 'location'; |
|
1882 | - $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title; |
|
1883 | - } |
|
1884 | - elseif(geodir_is_page('search')){ |
|
1885 | - $gd_page = 'search'; |
|
1886 | - $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title; |
|
1887 | - } |
|
1888 | - elseif(geodir_is_page('add-listing')){ |
|
1889 | - $gd_page = 'add-listing'; |
|
1890 | - $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title; |
|
1891 | - } |
|
1892 | - elseif(geodir_is_page('author')){ |
|
1893 | - $gd_page = 'author'; |
|
1894 | - $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title; |
|
1895 | - } |
|
1896 | - elseif(geodir_is_page('login')){ |
|
1897 | - $gd_page = 'login'; |
|
1898 | - $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title; |
|
1899 | - } |
|
1900 | - elseif(geodir_is_page('listing-success')){ |
|
1901 | - $gd_page = 'listing-success'; |
|
1902 | - $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title; |
|
1903 | - } |
|
1863 | + $gd_page = ''; |
|
1864 | + if(geodir_is_page('home')){ |
|
1865 | + $gd_page = 'home'; |
|
1866 | + $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title; |
|
1867 | + } |
|
1868 | + elseif(geodir_is_page('detail')){ |
|
1869 | + $gd_page = 'detail'; |
|
1870 | + $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title; |
|
1871 | + } |
|
1872 | + elseif(geodir_is_page('pt')){ |
|
1873 | + $gd_page = 'pt'; |
|
1874 | + $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title; |
|
1875 | + } |
|
1876 | + elseif(geodir_is_page('listing')){ |
|
1877 | + $gd_page = 'listing'; |
|
1878 | + $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title; |
|
1879 | + } |
|
1880 | + elseif(geodir_is_page('location')){ |
|
1881 | + $gd_page = 'location'; |
|
1882 | + $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title; |
|
1883 | + } |
|
1884 | + elseif(geodir_is_page('search')){ |
|
1885 | + $gd_page = 'search'; |
|
1886 | + $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title; |
|
1887 | + } |
|
1888 | + elseif(geodir_is_page('add-listing')){ |
|
1889 | + $gd_page = 'add-listing'; |
|
1890 | + $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title; |
|
1891 | + } |
|
1892 | + elseif(geodir_is_page('author')){ |
|
1893 | + $gd_page = 'author'; |
|
1894 | + $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title; |
|
1895 | + } |
|
1896 | + elseif(geodir_is_page('login')){ |
|
1897 | + $gd_page = 'login'; |
|
1898 | + $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title; |
|
1899 | + } |
|
1900 | + elseif(geodir_is_page('listing-success')){ |
|
1901 | + $gd_page = 'listing-success'; |
|
1902 | + $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title; |
|
1903 | + } |
|
1904 | 1904 | |
1905 | 1905 | |
1906 | - /** |
|
1907 | - * Filter page meta title to replace variables. |
|
1908 | - * |
|
1909 | - * @since 1.5.4 |
|
1910 | - * @param string $title The page title including variables. |
|
1911 | - * @param string $gd_page The GeoDirectory page type if any. |
|
1912 | - * @param string $sep The title separator symbol. |
|
1913 | - */ |
|
1914 | - return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep); |
|
1906 | + /** |
|
1907 | + * Filter page meta title to replace variables. |
|
1908 | + * |
|
1909 | + * @since 1.5.4 |
|
1910 | + * @param string $title The page title including variables. |
|
1911 | + * @param string $gd_page The GeoDirectory page type if any. |
|
1912 | + * @param string $sep The title separator symbol. |
|
1913 | + */ |
|
1914 | + return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep); |
|
1915 | 1915 | |
1916 | 1916 | } |
1917 | 1917 | |
@@ -1927,36 +1927,36 @@ discard block |
||
1927 | 1927 | function geodir_set_post_attachment() |
1928 | 1928 | { |
1929 | 1929 | |
1930 | - if (!get_option('geodir_set_post_attachments')) { |
|
1930 | + if (!get_option('geodir_set_post_attachments')) { |
|
1931 | 1931 | |
1932 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1933 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1932 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1933 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1934 | 1934 | |
1935 | - $all_postypes = geodir_get_posttypes(); |
|
1935 | + $all_postypes = geodir_get_posttypes(); |
|
1936 | 1936 | |
1937 | - foreach($all_postypes as $post_type){ |
|
1938 | - $args = array( |
|
1939 | - 'posts_per_page' => -1, |
|
1940 | - 'post_type' => $post_type, |
|
1941 | - 'post_status' => 'publish'); |
|
1937 | + foreach($all_postypes as $post_type){ |
|
1938 | + $args = array( |
|
1939 | + 'posts_per_page' => -1, |
|
1940 | + 'post_type' => $post_type, |
|
1941 | + 'post_status' => 'publish'); |
|
1942 | 1942 | |
1943 | - $posts_array = get_posts($args); |
|
1943 | + $posts_array = get_posts($args); |
|
1944 | 1944 | |
1945 | - if (!empty($posts_array)) { |
|
1945 | + if (!empty($posts_array)) { |
|
1946 | 1946 | |
1947 | - foreach ($posts_array as $post) { |
|
1947 | + foreach ($posts_array as $post) { |
|
1948 | 1948 | |
1949 | - geodir_set_wp_featured_image($post->ID); |
|
1949 | + geodir_set_wp_featured_image($post->ID); |
|
1950 | 1950 | |
1951 | - } |
|
1951 | + } |
|
1952 | 1952 | |
1953 | - } |
|
1954 | - } |
|
1953 | + } |
|
1954 | + } |
|
1955 | 1955 | |
1956 | 1956 | |
1957 | - update_option('geodir_set_post_attachments', '1'); |
|
1957 | + update_option('geodir_set_post_attachments', '1'); |
|
1958 | 1958 | |
1959 | - } |
|
1959 | + } |
|
1960 | 1960 | |
1961 | 1961 | } |
1962 | 1962 | |
@@ -1973,19 +1973,19 @@ discard block |
||
1973 | 1973 | function geodir_remove_url_seperator() |
1974 | 1974 | { |
1975 | 1975 | |
1976 | - if (!get_option('geodir_remove_url_seperator')) { |
|
1976 | + if (!get_option('geodir_remove_url_seperator')) { |
|
1977 | 1977 | |
1978 | - if (get_option('geodir_listingurl_separator')) |
|
1979 | - delete_option('geodir_listingurl_separator'); |
|
1978 | + if (get_option('geodir_listingurl_separator')) |
|
1979 | + delete_option('geodir_listingurl_separator'); |
|
1980 | 1980 | |
1981 | - if (get_option('geodir_detailurl_separator')) |
|
1982 | - delete_option('geodir_detailurl_separator'); |
|
1981 | + if (get_option('geodir_detailurl_separator')) |
|
1982 | + delete_option('geodir_detailurl_separator'); |
|
1983 | 1983 | |
1984 | - flush_rewrite_rules(false); |
|
1984 | + flush_rewrite_rules(false); |
|
1985 | 1985 | |
1986 | - update_option('geodir_remove_url_seperator', '1'); |
|
1986 | + update_option('geodir_remove_url_seperator', '1'); |
|
1987 | 1987 | |
1988 | - } |
|
1988 | + } |
|
1989 | 1989 | |
1990 | 1990 | } |
1991 | 1991 | |
@@ -2001,19 +2001,19 @@ discard block |
||
2001 | 2001 | */ |
2002 | 2002 | function geodir_remove_url_seperator_form_permalink_settings($permalink_arr) |
2003 | 2003 | { |
2004 | - foreach ($permalink_arr as $key => $value) { |
|
2004 | + foreach ($permalink_arr as $key => $value) { |
|
2005 | 2005 | |
2006 | - if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator') |
|
2007 | - unset($permalink_arr[$key]); |
|
2006 | + if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator') |
|
2007 | + unset($permalink_arr[$key]); |
|
2008 | 2008 | |
2009 | - } |
|
2009 | + } |
|
2010 | 2010 | |
2011 | - return $permalink_arr; |
|
2011 | + return $permalink_arr; |
|
2012 | 2012 | |
2013 | 2013 | } |
2014 | 2014 | |
2015 | 2015 | if (!is_admin()) { |
2016 | - add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post'); |
|
2016 | + add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post'); |
|
2017 | 2017 | } |
2018 | 2018 | /** |
2019 | 2019 | * Set status from draft to publish. |
@@ -2026,16 +2026,16 @@ discard block |
||
2026 | 2026 | */ |
2027 | 2027 | function geodir_set_status_draft_to_publish_for_own_post($post) |
2028 | 2028 | { |
2029 | - $user_id = get_current_user_id(); |
|
2029 | + $user_id = get_current_user_id(); |
|
2030 | 2030 | |
2031 | - if(!$user_id){return $post;} |
|
2031 | + if(!$user_id){return $post;} |
|
2032 | 2032 | |
2033 | - $gd_post_types = geodir_get_posttypes(); |
|
2033 | + $gd_post_types = geodir_get_posttypes(); |
|
2034 | 2034 | |
2035 | - if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) { |
|
2036 | - $post[0]->post_status = 'publish'; |
|
2037 | - } |
|
2038 | - return $post; |
|
2035 | + if (!empty($post) && $post[0]->post_author == $user_id && in_array($post[0]->post_type, $gd_post_types) && !isset($_REQUEST['fl_builder'])) { |
|
2036 | + $post[0]->post_status = 'publish'; |
|
2037 | + } |
|
2038 | + return $post; |
|
2039 | 2039 | } |
2040 | 2040 | |
2041 | 2041 | |
@@ -2127,33 +2127,33 @@ discard block |
||
2127 | 2127 | */ |
2128 | 2128 | function geodir_detail_page_tab_headings_change($tabs_arr) |
2129 | 2129 | { |
2130 | - global $wpdb; |
|
2130 | + global $wpdb; |
|
2131 | 2131 | |
2132 | - $post_type = geodir_get_current_posttype(); |
|
2132 | + $post_type = geodir_get_current_posttype(); |
|
2133 | 2133 | |
2134 | - $all_postypes = geodir_get_posttypes(); |
|
2134 | + $all_postypes = geodir_get_posttypes(); |
|
2135 | 2135 | |
2136 | - if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) { |
|
2136 | + if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) { |
|
2137 | 2137 | |
2138 | - if (array_key_exists('post_video', $tabs_arr)) { |
|
2138 | + if (array_key_exists('post_video', $tabs_arr)) { |
|
2139 | 2139 | |
2140 | - $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type))); |
|
2140 | + $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type))); |
|
2141 | 2141 | |
2142 | - if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') |
|
2143 | - $tabs_arr['post_video']['heading_text'] = $field_title; |
|
2144 | - } |
|
2142 | + if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') |
|
2143 | + $tabs_arr['post_video']['heading_text'] = $field_title; |
|
2144 | + } |
|
2145 | 2145 | |
2146 | - if (array_key_exists('special_offers', $tabs_arr)) { |
|
2146 | + if (array_key_exists('special_offers', $tabs_arr)) { |
|
2147 | 2147 | |
2148 | - $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type))); |
|
2148 | + $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type))); |
|
2149 | 2149 | |
2150 | - if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') |
|
2151 | - $tabs_arr['special_offers']['heading_text'] = $field_title; |
|
2152 | - } |
|
2150 | + if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') |
|
2151 | + $tabs_arr['special_offers']['heading_text'] = $field_title; |
|
2152 | + } |
|
2153 | 2153 | |
2154 | - } |
|
2154 | + } |
|
2155 | 2155 | |
2156 | - return $tabs_arr; |
|
2156 | + return $tabs_arr; |
|
2157 | 2157 | |
2158 | 2158 | } |
2159 | 2159 | |
@@ -2166,10 +2166,10 @@ discard block |
||
2166 | 2166 | */ |
2167 | 2167 | function geodir_remove_template_redirect_actions() |
2168 | 2168 | { |
2169 | - if (geodir_is_page('login')){ |
|
2170 | - remove_all_actions('template_redirect'); |
|
2171 | - remove_action('init', 'avia_modify_front', 10); |
|
2172 | - } |
|
2169 | + if (geodir_is_page('login')){ |
|
2170 | + remove_all_actions('template_redirect'); |
|
2171 | + remove_action('init', 'avia_modify_front', 10); |
|
2172 | + } |
|
2173 | 2173 | } |
2174 | 2174 | |
2175 | 2175 | |
@@ -2191,51 +2191,51 @@ discard block |
||
2191 | 2191 | function geodirectory_before_featured_image_delete($attachment_id) |
2192 | 2192 | { |
2193 | 2193 | |
2194 | - global $wpdb, $plugin_prefix; |
|
2194 | + global $wpdb, $plugin_prefix; |
|
2195 | 2195 | |
2196 | - $post_id = get_post_field('post_parent', $attachment_id); |
|
2196 | + $post_id = get_post_field('post_parent', $attachment_id); |
|
2197 | 2197 | |
2198 | - $attachment_url = wp_get_attachment_url($attachment_id); |
|
2198 | + $attachment_url = wp_get_attachment_url($attachment_id); |
|
2199 | 2199 | |
2200 | - if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) { |
|
2200 | + if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) { |
|
2201 | 2201 | |
2202 | - $post_type = get_post_type($post_id); |
|
2202 | + $post_type = get_post_type($post_id); |
|
2203 | 2203 | |
2204 | - $all_postypes = geodir_get_posttypes(); |
|
2204 | + $all_postypes = geodir_get_posttypes(); |
|
2205 | 2205 | |
2206 | - if (!in_array($post_type, $all_postypes) || !is_admin()) |
|
2207 | - return false; |
|
2206 | + if (!in_array($post_type, $all_postypes) || !is_admin()) |
|
2207 | + return false; |
|
2208 | 2208 | |
2209 | - $uploads = wp_upload_dir(); |
|
2209 | + $uploads = wp_upload_dir(); |
|
2210 | 2210 | |
2211 | - $split_img_path = explode($uploads['baseurl'], $attachment_url); |
|
2211 | + $split_img_path = explode($uploads['baseurl'], $attachment_url); |
|
2212 | 2212 | |
2213 | - $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
2213 | + $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
2214 | 2214 | |
2215 | - $wpdb->query( |
|
2216 | - $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ", |
|
2217 | - array($post_id, $split_img_file_path) |
|
2218 | - ) |
|
2219 | - ); |
|
2215 | + $wpdb->query( |
|
2216 | + $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ", |
|
2217 | + array($post_id, $split_img_file_path) |
|
2218 | + ) |
|
2219 | + ); |
|
2220 | 2220 | |
2221 | - $attachment_data = $wpdb->get_row( |
|
2222 | - $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d", |
|
2223 | - array($post_id) |
|
2224 | - ) |
|
2225 | - ); |
|
2221 | + $attachment_data = $wpdb->get_row( |
|
2222 | + $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d", |
|
2223 | + array($post_id) |
|
2224 | + ) |
|
2225 | + ); |
|
2226 | 2226 | |
2227 | - if (!empty($attachment_data)) { |
|
2228 | - $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2229 | - } |
|
2227 | + if (!empty($attachment_data)) { |
|
2228 | + $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2229 | + } |
|
2230 | 2230 | |
2231 | 2231 | |
2232 | - $table_name = $plugin_prefix . $post_type . '_detail'; |
|
2232 | + $table_name = $plugin_prefix . $post_type . '_detail'; |
|
2233 | 2233 | |
2234 | - $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id); |
|
2234 | + $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id); |
|
2235 | 2235 | |
2236 | - geodir_set_wp_featured_image($post_id); |
|
2236 | + geodir_set_wp_featured_image($post_id); |
|
2237 | 2237 | |
2238 | - } |
|
2238 | + } |
|
2239 | 2239 | |
2240 | 2240 | } |
2241 | 2241 | |
@@ -2253,79 +2253,79 @@ discard block |
||
2253 | 2253 | function geodir_temp_set_post_attachment() |
2254 | 2254 | { |
2255 | 2255 | |
2256 | - global $wpdb, $plugin_prefix; |
|
2256 | + global $wpdb, $plugin_prefix; |
|
2257 | 2257 | |
2258 | - $all_postypes = geodir_get_posttypes(); |
|
2258 | + $all_postypes = geodir_get_posttypes(); |
|
2259 | 2259 | |
2260 | - foreach ($all_postypes as $posttype) { |
|
2260 | + foreach ($all_postypes as $posttype) { |
|
2261 | 2261 | |
2262 | - $tablename = $plugin_prefix . $posttype . '_detail'; |
|
2262 | + $tablename = $plugin_prefix . $posttype . '_detail'; |
|
2263 | 2263 | |
2264 | - $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename); |
|
2264 | + $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename); |
|
2265 | 2265 | |
2266 | - if (!empty($get_post_data)) { |
|
2266 | + if (!empty($get_post_data)) { |
|
2267 | 2267 | |
2268 | - foreach ($get_post_data as $data) { |
|
2268 | + foreach ($get_post_data as $data) { |
|
2269 | 2269 | |
2270 | - $post_id = $data->post_id; |
|
2270 | + $post_id = $data->post_id; |
|
2271 | 2271 | |
2272 | - $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''"); |
|
2272 | + $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''"); |
|
2273 | 2273 | |
2274 | - if (!empty($attachment_data)) { |
|
2274 | + if (!empty($attachment_data)) { |
|
2275 | 2275 | |
2276 | - foreach ($attachment_data as $attach) { |
|
2276 | + foreach ($attachment_data as $attach) { |
|
2277 | 2277 | |
2278 | - $file_info = pathinfo($attach->file); |
|
2278 | + $file_info = pathinfo($attach->file); |
|
2279 | 2279 | |
2280 | - $sub_dir = ''; |
|
2281 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
2282 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
2280 | + $sub_dir = ''; |
|
2281 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
2282 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
2283 | 2283 | |
2284 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
2285 | - $uploads_path = $uploads['basedir']; |
|
2284 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
2285 | + $uploads_path = $uploads['basedir']; |
|
2286 | 2286 | |
2287 | - $file_name = $file_info['basename']; |
|
2287 | + $file_name = $file_info['basename']; |
|
2288 | 2288 | |
2289 | - $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name; |
|
2289 | + $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name; |
|
2290 | 2290 | |
2291 | - if (!file_exists($img_arr['path'])) { |
|
2291 | + if (!file_exists($img_arr['path'])) { |
|
2292 | 2292 | |
2293 | - $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID); |
|
2293 | + $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID); |
|
2294 | 2294 | |
2295 | - } |
|
2295 | + } |
|
2296 | 2296 | |
2297 | - } |
|
2297 | + } |
|
2298 | 2298 | |
2299 | - $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id"); |
|
2299 | + $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id"); |
|
2300 | 2300 | |
2301 | - if (!empty($attachment_data)) { |
|
2301 | + if (!empty($attachment_data)) { |
|
2302 | 2302 | |
2303 | - if ($attachment_data->ID) |
|
2304 | - $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2303 | + if ($attachment_data->ID) |
|
2304 | + $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2305 | 2305 | |
2306 | - } else { |
|
2306 | + } else { |
|
2307 | 2307 | |
2308 | - if (has_post_thumbnail($post_id)) { |
|
2308 | + if (has_post_thumbnail($post_id)) { |
|
2309 | 2309 | |
2310 | - $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
2310 | + $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
2311 | 2311 | |
2312 | - wp_delete_attachment($post_thumbnail_id); |
|
2312 | + wp_delete_attachment($post_thumbnail_id); |
|
2313 | 2313 | |
2314 | - } |
|
2314 | + } |
|
2315 | 2315 | |
2316 | - } |
|
2316 | + } |
|
2317 | 2317 | |
2318 | - $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id); |
|
2318 | + $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id); |
|
2319 | 2319 | |
2320 | - geodir_set_wp_featured_image($post_id); |
|
2320 | + geodir_set_wp_featured_image($post_id); |
|
2321 | 2321 | |
2322 | - } |
|
2322 | + } |
|
2323 | 2323 | |
2324 | - } |
|
2324 | + } |
|
2325 | 2325 | |
2326 | - } |
|
2326 | + } |
|
2327 | 2327 | |
2328 | - } |
|
2328 | + } |
|
2329 | 2329 | |
2330 | 2330 | } |
2331 | 2331 | |
@@ -2343,9 +2343,9 @@ discard block |
||
2343 | 2343 | function geodir_default_rating_star_icon() |
2344 | 2344 | { |
2345 | 2345 | |
2346 | - if (!get_option('geodir_default_rating_star_icon')) { |
|
2347 | - update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png'); |
|
2348 | - } |
|
2346 | + if (!get_option('geodir_default_rating_star_icon')) { |
|
2347 | + update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png'); |
|
2348 | + } |
|
2349 | 2349 | |
2350 | 2350 | } |
2351 | 2351 | |
@@ -2363,25 +2363,25 @@ discard block |
||
2363 | 2363 | */ |
2364 | 2364 | function geodir_user_post_listing_count($user_id = 0) |
2365 | 2365 | { |
2366 | - global $wpdb, $plugin_prefix, $current_user; |
|
2367 | - if(!$user_id){ |
|
2368 | - $user_id = $current_user->ID; |
|
2369 | - } |
|
2366 | + global $wpdb, $plugin_prefix, $current_user; |
|
2367 | + if(!$user_id){ |
|
2368 | + $user_id = $current_user->ID; |
|
2369 | + } |
|
2370 | 2370 | |
2371 | - $all_posts = get_option('geodir_listing_link_user_dashboard'); |
|
2371 | + $all_posts = get_option('geodir_listing_link_user_dashboard'); |
|
2372 | 2372 | |
2373 | - $user_listing = array(); |
|
2374 | - if ($user_id && is_array($all_posts) && !empty($all_posts)) { |
|
2375 | - foreach ($all_posts as $ptype) { |
|
2376 | - $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )"); |
|
2373 | + $user_listing = array(); |
|
2374 | + if ($user_id && is_array($all_posts) && !empty($all_posts)) { |
|
2375 | + foreach ($all_posts as $ptype) { |
|
2376 | + $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' OR post_status = 'pending' )"); |
|
2377 | 2377 | |
2378 | - if ($total_posts > 0) { |
|
2379 | - $user_listing[$ptype] = $total_posts; |
|
2380 | - } |
|
2381 | - } |
|
2382 | - } |
|
2378 | + if ($total_posts > 0) { |
|
2379 | + $user_listing[$ptype] = $total_posts; |
|
2380 | + } |
|
2381 | + } |
|
2382 | + } |
|
2383 | 2383 | |
2384 | - return $user_listing; |
|
2384 | + return $user_listing; |
|
2385 | 2385 | } |
2386 | 2386 | |
2387 | 2387 | |
@@ -2401,189 +2401,189 @@ discard block |
||
2401 | 2401 | */ |
2402 | 2402 | function geodir_detail_page_custom_field_tab($tabs_arr) |
2403 | 2403 | { |
2404 | - global $post; |
|
2405 | - |
|
2406 | - $post_type = geodir_get_current_posttype(); |
|
2407 | - $all_postypes = geodir_get_posttypes(); |
|
2408 | - |
|
2409 | - if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) { |
|
2410 | - $package_info = array(); |
|
2411 | - $package_info = geodir_post_package_info($package_info, $post); |
|
2412 | - $post_package_id = !empty($package_info->pid) ? $package_info->pid : ''; |
|
2413 | - $fields_location = 'owntab'; |
|
2414 | - |
|
2415 | - $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location); |
|
2416 | - //remove video and special offers if it is already set to show |
|
2417 | - if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){ |
|
2418 | - $unset_video = true; |
|
2419 | - } |
|
2420 | - |
|
2421 | - if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){ |
|
2422 | - $unset_special_offers = true; |
|
2423 | - } |
|
2424 | - if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){ |
|
2425 | - foreach($custom_fields as $key => $custom_field){ |
|
2426 | - if($custom_field['name']=='geodir_video' && isset($unset_video)){ |
|
2427 | - unset($custom_fields[$key]); |
|
2428 | - } |
|
2429 | - if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){ |
|
2430 | - unset($custom_fields[$key]); |
|
2431 | - } |
|
2432 | - } |
|
2433 | - } |
|
2434 | - |
|
2435 | - |
|
2436 | - if (!empty($custom_fields)) { |
|
2437 | - $parse_custom_fields = array(); |
|
2438 | - foreach ($custom_fields as $field) { |
|
2439 | - $field = stripslashes_deep($field); // strip slashes |
|
2440 | - $type = $field; |
|
2441 | - $field_name = $field['htmlvar_name']; |
|
2442 | - if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { |
|
2443 | - $post->{$field_name} = $_REQUEST[$field_name]; |
|
2444 | - } |
|
2404 | + global $post; |
|
2445 | 2405 | |
2446 | - if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { |
|
2447 | - if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) { |
|
2448 | - continue; |
|
2449 | - } |
|
2406 | + $post_type = geodir_get_current_posttype(); |
|
2407 | + $all_postypes = geodir_get_posttypes(); |
|
2450 | 2408 | |
2451 | - $parse_custom_fields[] = $field; |
|
2452 | - } |
|
2453 | - } |
|
2454 | - $custom_fields = $parse_custom_fields; |
|
2455 | - } |
|
2456 | - //print_r($custom_fields); |
|
2457 | - if (!empty($custom_fields)) { |
|
2409 | + if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) { |
|
2410 | + $package_info = array(); |
|
2411 | + $package_info = geodir_post_package_info($package_info, $post); |
|
2412 | + $post_package_id = !empty($package_info->pid) ? $package_info->pid : ''; |
|
2413 | + $fields_location = 'owntab'; |
|
2458 | 2414 | |
2459 | - global $field_set_start; |
|
2415 | + $custom_fields = geodir_post_custom_fields($post_package_id, 'all', $post_type, $fields_location); |
|
2416 | + //remove video and special offers if it is already set to show |
|
2417 | + if(isset($tabs_arr['post_video']['is_display']) && $tabs_arr['post_video']['is_display']){ |
|
2418 | + $unset_video = true; |
|
2419 | + } |
|
2460 | 2420 | |
2461 | - $post = stripslashes_deep($post); // strip slashes |
|
2462 | - |
|
2463 | - $field_set_start = 0; |
|
2464 | - $fieldset_count = 0; |
|
2465 | - $fieldset = ''; |
|
2466 | - $total_fields = count($custom_fields); |
|
2467 | - $count_field = 0; |
|
2468 | - $fieldset_arr = array(); |
|
2469 | - $i = 0; |
|
2470 | - $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL; |
|
2471 | - |
|
2472 | - foreach ($custom_fields as $field) { |
|
2473 | - $count_field++; |
|
2474 | - $field_name = $field['htmlvar_name']; |
|
2475 | - if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { |
|
2476 | - $post->{$field_name} = $_REQUEST[$field_name]; |
|
2477 | - } |
|
2421 | + if(isset($tabs_arr['special_offers']['is_display']) && $tabs_arr['special_offers']['is_display']){ |
|
2422 | + $unset_special_offers = true; |
|
2423 | + } |
|
2424 | + if(isset($unset_video) || isset($unset_special_offers) && !empty($custom_fields)){ |
|
2425 | + foreach($custom_fields as $key => $custom_field){ |
|
2426 | + if($custom_field['name']=='geodir_video' && isset($unset_video)){ |
|
2427 | + unset($custom_fields[$key]); |
|
2428 | + } |
|
2429 | + if($custom_field['name']=='geodir_special_offers' && isset($unset_special_offers)){ |
|
2430 | + unset($custom_fields[$key]); |
|
2431 | + } |
|
2432 | + } |
|
2433 | + } |
|
2478 | 2434 | |
2479 | - if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { |
|
2480 | - $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title']; |
|
2481 | - $site_title = trim($field['site_title']); |
|
2482 | - $type = $field; |
|
2483 | - $variables_array = array(); |
|
2484 | 2435 | |
2485 | - if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) { |
|
2486 | - continue; |
|
2487 | - } |
|
2436 | + if (!empty($custom_fields)) { |
|
2437 | + $parse_custom_fields = array(); |
|
2438 | + foreach ($custom_fields as $field) { |
|
2439 | + $field = stripslashes_deep($field); // strip slashes |
|
2440 | + $type = $field; |
|
2441 | + $field_name = $field['htmlvar_name']; |
|
2442 | + if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { |
|
2443 | + $post->{$field_name} = $_REQUEST[$field_name]; |
|
2444 | + } |
|
2488 | 2445 | |
2489 | - if ($type['type'] != 'fieldset') { |
|
2490 | - $i++; |
|
2491 | - $variables_array['post_id'] = $post->ID; |
|
2492 | - $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
2493 | - $variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : ''; |
|
2494 | - |
|
2495 | - }else{ |
|
2496 | - $i = 0; |
|
2497 | - $fieldset_count++; |
|
2498 | - $field_set_start = 1; |
|
2499 | - $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count; |
|
2500 | - $fieldset_arr[$fieldset_count]['label'] = $label; |
|
2501 | - } |
|
2446 | + if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { |
|
2447 | + if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) { |
|
2448 | + continue; |
|
2449 | + } |
|
2502 | 2450 | |
2451 | + $parse_custom_fields[] = $field; |
|
2452 | + } |
|
2453 | + } |
|
2454 | + $custom_fields = $parse_custom_fields; |
|
2455 | + } |
|
2456 | + //print_r($custom_fields); |
|
2457 | + if (!empty($custom_fields)) { |
|
2503 | 2458 | |
2504 | - if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];} |
|
2505 | - $type = stripslashes_deep($type); // strip slashes |
|
2506 | - if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;} |
|
2507 | - $html = ''; |
|
2508 | - $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
2509 | - if($html_var=='post'){$html_var='post_address';} |
|
2510 | - $field_icon = geodir_field_icon_proccess($type); |
|
2511 | - $filed_type = $type['type']; |
|
2512 | - |
|
2513 | - /** |
|
2514 | - * Filter the output for custom fields. |
|
2515 | - * |
|
2516 | - * Here we can remove or add new functions depending on the field type. |
|
2517 | - * |
|
2518 | - * @param string $html The html to be filtered (blank). |
|
2519 | - * @param string $fields_location The location the field is to be show. |
|
2520 | - * @param array $type The array of field values. |
|
2521 | - */ |
|
2522 | - $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
2523 | - |
|
2524 | - |
|
2525 | - /** |
|
2526 | - * Filter custom field output in tab. |
|
2527 | - * |
|
2528 | - * @since 1.5.6 |
|
2529 | - * |
|
2530 | - * @param string $html_var The HTML variable name for the field. |
|
2531 | - * @param string $html Custom field unfiltered HTML. |
|
2532 | - * @param array $variables_array Custom field variables array. |
|
2533 | - */ |
|
2534 | - $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array); |
|
2535 | - |
|
2536 | - $fieldset_html = ''; |
|
2537 | - if ($field_set_start == 1) { |
|
2538 | - $add_html = false; |
|
2539 | - if ($type['type'] == 'fieldset' && $fieldset_count > 1) { |
|
2540 | - if ($fieldset != '') { |
|
2541 | - $add_html = true; |
|
2542 | - $label = $fieldset_arr[$fieldset_count - 1]['label']; |
|
2543 | - $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name']; |
|
2544 | - } |
|
2545 | - $fieldset_html = $fieldset; |
|
2546 | - $fieldset = ''; |
|
2547 | - } else { |
|
2548 | - $fieldset .= $html; |
|
2549 | - if ($total_fields == $count_field && $fieldset != '') { |
|
2550 | - $add_html = true; |
|
2551 | - $label = $fieldset_arr[$fieldset_count]['label']; |
|
2552 | - $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name']; |
|
2553 | - $fieldset_html = $fieldset; |
|
2554 | - } |
|
2555 | - } |
|
2459 | + global $field_set_start; |
|
2556 | 2460 | |
2557 | - if ($add_html) { |
|
2558 | - $tabs_arr[$htmlvar_name] = array( |
|
2559 | - 'heading_text' => __($label, 'geodirectory'), |
|
2560 | - 'is_active_tab' => false, |
|
2561 | - /** |
|
2562 | - * Filter if a custom field should be displayed on the details page tab. |
|
2563 | - * |
|
2564 | - * @since 1.0.0 |
|
2565 | - * @param string $htmlvar_name The field HTML var name. |
|
2566 | - */ |
|
2567 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name), |
|
2568 | - 'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>' |
|
2569 | - ); |
|
2570 | - } |
|
2571 | - } else { |
|
2572 | - if ($html != '') { |
|
2573 | - $tabs_arr[$html_var] = array( |
|
2574 | - 'heading_text' => __($label, 'geodirectory'), |
|
2575 | - 'is_active_tab' => false, |
|
2576 | - /** This action is documented in geodirectory_hooks_actions.php */ |
|
2577 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']), |
|
2578 | - 'tab_content' => $html |
|
2579 | - ); |
|
2580 | - } |
|
2581 | - } |
|
2582 | - } |
|
2583 | - } |
|
2584 | - } |
|
2585 | - } |
|
2586 | - return $tabs_arr; |
|
2461 | + $post = stripslashes_deep($post); // strip slashes |
|
2462 | + |
|
2463 | + $field_set_start = 0; |
|
2464 | + $fieldset_count = 0; |
|
2465 | + $fieldset = ''; |
|
2466 | + $total_fields = count($custom_fields); |
|
2467 | + $count_field = 0; |
|
2468 | + $fieldset_arr = array(); |
|
2469 | + $i = 0; |
|
2470 | + $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL; |
|
2471 | + |
|
2472 | + foreach ($custom_fields as $field) { |
|
2473 | + $count_field++; |
|
2474 | + $field_name = $field['htmlvar_name']; |
|
2475 | + if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) { |
|
2476 | + $post->{$field_name} = $_REQUEST[$field_name]; |
|
2477 | + } |
|
2478 | + |
|
2479 | + if (isset($field['show_in']) && strpos($field['show_in'], '[owntab]') !== false && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset' || $field['type'] == 'address') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file','address','taxonomy'))) { |
|
2480 | + $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title']; |
|
2481 | + $site_title = trim($field['site_title']); |
|
2482 | + $type = $field; |
|
2483 | + $variables_array = array(); |
|
2484 | + |
|
2485 | + if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) { |
|
2486 | + continue; |
|
2487 | + } |
|
2488 | + |
|
2489 | + if ($type['type'] != 'fieldset') { |
|
2490 | + $i++; |
|
2491 | + $variables_array['post_id'] = $post->ID; |
|
2492 | + $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
2493 | + $variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : ''; |
|
2494 | + |
|
2495 | + }else{ |
|
2496 | + $i = 0; |
|
2497 | + $fieldset_count++; |
|
2498 | + $field_set_start = 1; |
|
2499 | + $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count; |
|
2500 | + $fieldset_arr[$fieldset_count]['label'] = $label; |
|
2501 | + } |
|
2502 | + |
|
2503 | + |
|
2504 | + if(isset($type['extra_fields'])){$extra_fields= $type['extra_fields'];} |
|
2505 | + $type = stripslashes_deep($type); // strip slashes |
|
2506 | + if(isset($type['extra_fields'])){$type['extra_fields'] = $extra_fields;} |
|
2507 | + $html = ''; |
|
2508 | + $html_var = isset($type['htmlvar_name']) ? $type['htmlvar_name'] : ''; |
|
2509 | + if($html_var=='post'){$html_var='post_address';} |
|
2510 | + $field_icon = geodir_field_icon_proccess($type); |
|
2511 | + $filed_type = $type['type']; |
|
2512 | + |
|
2513 | + /** |
|
2514 | + * Filter the output for custom fields. |
|
2515 | + * |
|
2516 | + * Here we can remove or add new functions depending on the field type. |
|
2517 | + * |
|
2518 | + * @param string $html The html to be filtered (blank). |
|
2519 | + * @param string $fields_location The location the field is to be show. |
|
2520 | + * @param array $type The array of field values. |
|
2521 | + */ |
|
2522 | + $html = apply_filters("geodir_custom_field_output_{$filed_type}",$html,$fields_location,$type); |
|
2523 | + |
|
2524 | + |
|
2525 | + /** |
|
2526 | + * Filter custom field output in tab. |
|
2527 | + * |
|
2528 | + * @since 1.5.6 |
|
2529 | + * |
|
2530 | + * @param string $html_var The HTML variable name for the field. |
|
2531 | + * @param string $html Custom field unfiltered HTML. |
|
2532 | + * @param array $variables_array Custom field variables array. |
|
2533 | + */ |
|
2534 | + $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array); |
|
2535 | + |
|
2536 | + $fieldset_html = ''; |
|
2537 | + if ($field_set_start == 1) { |
|
2538 | + $add_html = false; |
|
2539 | + if ($type['type'] == 'fieldset' && $fieldset_count > 1) { |
|
2540 | + if ($fieldset != '') { |
|
2541 | + $add_html = true; |
|
2542 | + $label = $fieldset_arr[$fieldset_count - 1]['label']; |
|
2543 | + $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name']; |
|
2544 | + } |
|
2545 | + $fieldset_html = $fieldset; |
|
2546 | + $fieldset = ''; |
|
2547 | + } else { |
|
2548 | + $fieldset .= $html; |
|
2549 | + if ($total_fields == $count_field && $fieldset != '') { |
|
2550 | + $add_html = true; |
|
2551 | + $label = $fieldset_arr[$fieldset_count]['label']; |
|
2552 | + $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name']; |
|
2553 | + $fieldset_html = $fieldset; |
|
2554 | + } |
|
2555 | + } |
|
2556 | + |
|
2557 | + if ($add_html) { |
|
2558 | + $tabs_arr[$htmlvar_name] = array( |
|
2559 | + 'heading_text' => __($label, 'geodirectory'), |
|
2560 | + 'is_active_tab' => false, |
|
2561 | + /** |
|
2562 | + * Filter if a custom field should be displayed on the details page tab. |
|
2563 | + * |
|
2564 | + * @since 1.0.0 |
|
2565 | + * @param string $htmlvar_name The field HTML var name. |
|
2566 | + */ |
|
2567 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name), |
|
2568 | + 'tab_content' => '<div class="geodir-company_info field-group xxx">' . $fieldset_html . '</div>' |
|
2569 | + ); |
|
2570 | + } |
|
2571 | + } else { |
|
2572 | + if ($html != '') { |
|
2573 | + $tabs_arr[$html_var] = array( |
|
2574 | + 'heading_text' => __($label, 'geodirectory'), |
|
2575 | + 'is_active_tab' => false, |
|
2576 | + /** This action is documented in geodirectory_hooks_actions.php */ |
|
2577 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']), |
|
2578 | + 'tab_content' => $html |
|
2579 | + ); |
|
2580 | + } |
|
2581 | + } |
|
2582 | + } |
|
2583 | + } |
|
2584 | + } |
|
2585 | + } |
|
2586 | + return $tabs_arr; |
|
2587 | 2587 | } |
2588 | 2588 | |
2589 | 2589 | /* display add listing page for wpml */ |
@@ -2607,41 +2607,41 @@ discard block |
||
2607 | 2607 | */ |
2608 | 2608 | function geodir_add_post_status_author_page() |
2609 | 2609 | { |
2610 | - global $wpdb, $post; |
|
2611 | - |
|
2612 | - $html = ''; |
|
2613 | - if (get_current_user_id()) { |
|
2614 | - |
|
2615 | - $is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author')); |
|
2616 | - if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) { |
|
2617 | - |
|
2618 | - // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them. |
|
2619 | - $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID"); |
|
2620 | - $status = "<strong>("; |
|
2621 | - $status_icon = '<i class="fa fa-play"></i>'; |
|
2622 | - if ($real_status == 'publish') { |
|
2623 | - $status .= __('Published', 'geodirectory'); |
|
2624 | - }elseif ($real_status == 'pending') { |
|
2625 | - $status .= __('Awaiting Review', 'geodirectory'); |
|
2626 | - } else { |
|
2627 | - $status .= __('Not published', 'geodirectory'); |
|
2628 | - $status_icon = '<i class="fa fa-pause"></i>'; |
|
2629 | - } |
|
2630 | - $status .= ")</strong>"; |
|
2610 | + global $wpdb, $post; |
|
2611 | + |
|
2612 | + $html = ''; |
|
2613 | + if (get_current_user_id()) { |
|
2614 | + |
|
2615 | + $is_author_page = apply_filters('geodir_post_status_is_author_page', geodir_is_page('author')); |
|
2616 | + if ($is_author_page && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) { |
|
2617 | + |
|
2618 | + // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them. |
|
2619 | + $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID"); |
|
2620 | + $status = "<strong>("; |
|
2621 | + $status_icon = '<i class="fa fa-play"></i>'; |
|
2622 | + if ($real_status == 'publish') { |
|
2623 | + $status .= __('Published', 'geodirectory'); |
|
2624 | + }elseif ($real_status == 'pending') { |
|
2625 | + $status .= __('Awaiting Review', 'geodirectory'); |
|
2626 | + } else { |
|
2627 | + $status .= __('Not published', 'geodirectory'); |
|
2628 | + $status_icon = '<i class="fa fa-pause"></i>'; |
|
2629 | + } |
|
2630 | + $status .= ")</strong>"; |
|
2631 | 2631 | |
2632 | - $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>'; |
|
2633 | - } |
|
2634 | - } |
|
2632 | + $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>'; |
|
2633 | + } |
|
2634 | + } |
|
2635 | 2635 | |
2636 | - if ($html != '') { |
|
2637 | - /** |
|
2638 | - * Filter the post status text on the author page. |
|
2639 | - * |
|
2640 | - * @since 1.0.0 |
|
2641 | - * @param string $html The HTML of the status. |
|
2642 | - */ |
|
2643 | - echo apply_filters('geodir_filter_status_text_on_author_page', $html); |
|
2644 | - } |
|
2636 | + if ($html != '') { |
|
2637 | + /** |
|
2638 | + * Filter the post status text on the author page. |
|
2639 | + * |
|
2640 | + * @since 1.0.0 |
|
2641 | + * @param string $html The HTML of the status. |
|
2642 | + */ |
|
2643 | + echo apply_filters('geodir_filter_status_text_on_author_page', $html); |
|
2644 | + } |
|
2645 | 2645 | |
2646 | 2646 | |
2647 | 2647 | } |
@@ -2655,9 +2655,9 @@ discard block |
||
2655 | 2655 | * @package GeoDirectory |
2656 | 2656 | */ |
2657 | 2657 | function geodir_init_no_rating() { |
2658 | - if (geodir_rating_disabled_post_types()) { |
|
2659 | - add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2); |
|
2660 | - } |
|
2658 | + if (geodir_rating_disabled_post_types()) { |
|
2659 | + add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2); |
|
2660 | + } |
|
2661 | 2661 | } |
2662 | 2662 | |
2663 | 2663 | /** |
@@ -2671,22 +2671,22 @@ discard block |
||
2671 | 2671 | * @return array Modified sort options array. |
2672 | 2672 | */ |
2673 | 2673 | function geodir_no_rating_get_sort_options($options, $post_type = '') { |
2674 | - if (!empty($post_type) && geodir_cpt_has_rating_disabled($post_type)) { |
|
2675 | - $new_options = array(); |
|
2674 | + if (!empty($post_type) && geodir_cpt_has_rating_disabled($post_type)) { |
|
2675 | + $new_options = array(); |
|
2676 | 2676 | |
2677 | - if (!empty($options)) { |
|
2678 | - foreach ($options as $option) { |
|
2679 | - if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') { |
|
2680 | - continue; |
|
2681 | - } |
|
2682 | - $new_options[] = $option; |
|
2683 | - } |
|
2677 | + if (!empty($options)) { |
|
2678 | + foreach ($options as $option) { |
|
2679 | + if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') { |
|
2680 | + continue; |
|
2681 | + } |
|
2682 | + $new_options[] = $option; |
|
2683 | + } |
|
2684 | 2684 | |
2685 | - $options = $new_options; |
|
2686 | - } |
|
2687 | - } |
|
2685 | + $options = $new_options; |
|
2686 | + } |
|
2687 | + } |
|
2688 | 2688 | |
2689 | - return $options; |
|
2689 | + return $options; |
|
2690 | 2690 | } |
2691 | 2691 | |
2692 | 2692 | /** |
@@ -2698,9 +2698,9 @@ discard block |
||
2698 | 2698 | * @return array Modified class array. |
2699 | 2699 | */ |
2700 | 2700 | function geodir_body_class_active_map($classes = array()) { |
2701 | - $classes[] = 'gd-map-' . geodir_map_name(); |
|
2701 | + $classes[] = 'gd-map-' . geodir_map_name(); |
|
2702 | 2702 | |
2703 | - return $classes; |
|
2703 | + return $classes; |
|
2704 | 2704 | } |
2705 | 2705 | add_filter('body_class', 'geodir_body_class_active_map', 100); |
2706 | 2706 | |
@@ -2713,9 +2713,9 @@ discard block |
||
2713 | 2713 | * @return string Modified class string. |
2714 | 2714 | */ |
2715 | 2715 | function geodir_admin_body_class_active_map($class = '') { |
2716 | - $class .= ' gd-map-' . geodir_map_name(); |
|
2716 | + $class .= ' gd-map-' . geodir_map_name(); |
|
2717 | 2717 | |
2718 | - return $class; |
|
2718 | + return $class; |
|
2719 | 2719 | } |
2720 | 2720 | add_filter('admin_body_class', 'geodir_admin_body_class_active_map', 100); |
2721 | 2721 | |
@@ -2733,36 +2733,36 @@ discard block |
||
2733 | 2733 | * @return array Translation texts. |
2734 | 2734 | */ |
2735 | 2735 | function geodir_load_gd_options_text_translation($translation_texts = array()) { |
2736 | - $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
2737 | - |
|
2738 | - $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin'); |
|
2739 | - |
|
2740 | - /** |
|
2741 | - * Filters the geodirectory option names that requires to add for translation. |
|
2742 | - * |
|
2743 | - * @since 1.5.7 |
|
2744 | - * @package GeoDirectory |
|
2745 | - * |
|
2746 | - * @param array $gd_options Array of option names. |
|
2747 | - */ |
|
2748 | - $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options); |
|
2749 | - $gd_options = array_unique($gd_options); |
|
2750 | - |
|
2751 | - if (!empty($gd_options)) { |
|
2752 | - foreach ($gd_options as $gd_option) { |
|
2753 | - if ($gd_option != '' && $option_value = get_option($gd_option)) { |
|
2754 | - $option_value = is_string($option_value) ? stripslashes_deep($option_value) : ''; |
|
2736 | + $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
2737 | + |
|
2738 | + $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin'); |
|
2739 | + |
|
2740 | + /** |
|
2741 | + * Filters the geodirectory option names that requires to add for translation. |
|
2742 | + * |
|
2743 | + * @since 1.5.7 |
|
2744 | + * @package GeoDirectory |
|
2745 | + * |
|
2746 | + * @param array $gd_options Array of option names. |
|
2747 | + */ |
|
2748 | + $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options); |
|
2749 | + $gd_options = array_unique($gd_options); |
|
2750 | + |
|
2751 | + if (!empty($gd_options)) { |
|
2752 | + foreach ($gd_options as $gd_option) { |
|
2753 | + if ($gd_option != '' && $option_value = get_option($gd_option)) { |
|
2754 | + $option_value = is_string($option_value) ? stripslashes_deep($option_value) : ''; |
|
2755 | 2755 | |
2756 | - if ($option_value != '' && !in_array($option_value, $translation_texts)) { |
|
2757 | - $translation_texts[] = stripslashes_deep($option_value); |
|
2758 | - } |
|
2759 | - } |
|
2760 | - } |
|
2761 | - } |
|
2756 | + if ($option_value != '' && !in_array($option_value, $translation_texts)) { |
|
2757 | + $translation_texts[] = stripslashes_deep($option_value); |
|
2758 | + } |
|
2759 | + } |
|
2760 | + } |
|
2761 | + } |
|
2762 | 2762 | |
2763 | - $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
2763 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
2764 | 2764 | |
2765 | - return $translation_texts; |
|
2765 | + return $translation_texts; |
|
2766 | 2766 | } |
2767 | 2767 | |
2768 | 2768 | add_filter('geodir_load_db_language', 'geodir_load_gd_options_text_translation'); |
@@ -2776,15 +2776,15 @@ discard block |
||
2776 | 2776 | |
2777 | 2777 | add_filter('get_comments_link', 'gd_get_comments_link', 10, 2); |
2778 | 2778 | function gd_get_comments_link($comments_link, $post_id) { |
2779 | - $post_type = get_post_type($post_id); |
|
2779 | + $post_type = get_post_type($post_id); |
|
2780 | 2780 | |
2781 | - $all_postypes = geodir_get_posttypes(); |
|
2782 | - if (in_array($post_type, $all_postypes)) { |
|
2783 | - $comments_link = str_replace('#comments', '#reviews', $comments_link); |
|
2784 | - $comments_link = str_replace('#respond', '#reviews', $comments_link); |
|
2785 | - } |
|
2781 | + $all_postypes = geodir_get_posttypes(); |
|
2782 | + if (in_array($post_type, $all_postypes)) { |
|
2783 | + $comments_link = str_replace('#comments', '#reviews', $comments_link); |
|
2784 | + $comments_link = str_replace('#respond', '#reviews', $comments_link); |
|
2785 | + } |
|
2786 | 2786 | |
2787 | - return $comments_link; |
|
2787 | + return $comments_link; |
|
2788 | 2788 | } |
2789 | 2789 | |
2790 | 2790 | |
@@ -2802,11 +2802,11 @@ discard block |
||
2802 | 2802 | function geodir_add_nav_menu_class( $args ) |
2803 | 2803 | { |
2804 | 2804 | |
2805 | - if(isset($args['menu_class'])){ |
|
2806 | - $args['menu_class'] = $args['menu_class']." gd-menu-z"; |
|
2807 | - } |
|
2805 | + if(isset($args['menu_class'])){ |
|
2806 | + $args['menu_class'] = $args['menu_class']." gd-menu-z"; |
|
2807 | + } |
|
2808 | 2808 | |
2809 | - return $args; |
|
2809 | + return $args; |
|
2810 | 2810 | } |
2811 | 2811 | |
2812 | 2812 | add_filter( 'wp_nav_menu_args', 'geodir_add_nav_menu_class' ); |
@@ -2823,15 +2823,15 @@ discard block |
||
2823 | 2823 | * @return string Filtered locale ID. |
2824 | 2824 | */ |
2825 | 2825 | function geodir_wpml_filter_locale($locale) { |
2826 | - global $sitepress; |
|
2826 | + global $sitepress; |
|
2827 | 2827 | |
2828 | - $post_type = !empty($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (!empty($_REQUEST['post']) ? get_post_type($_REQUEST['post']) : ''); |
|
2828 | + $post_type = !empty($_REQUEST['post_type']) ? $_REQUEST['post_type'] : (!empty($_REQUEST['post']) ? get_post_type($_REQUEST['post']) : ''); |
|
2829 | 2829 | |
2830 | - if (!empty($sitepress) && $sitepress->is_post_edit_screen() && $post_type && in_array($post_type, geodir_get_posttypes()) && $current_lang = $sitepress->get_current_language()) { |
|
2831 | - $locale = $sitepress->get_locale($current_lang); |
|
2832 | - } |
|
2830 | + if (!empty($sitepress) && $sitepress->is_post_edit_screen() && $post_type && in_array($post_type, geodir_get_posttypes()) && $current_lang = $sitepress->get_current_language()) { |
|
2831 | + $locale = $sitepress->get_locale($current_lang); |
|
2832 | + } |
|
2833 | 2833 | |
2834 | - return $locale; |
|
2834 | + return $locale; |
|
2835 | 2835 | } |
2836 | 2836 | |
2837 | 2837 | /** |
@@ -2841,20 +2841,20 @@ discard block |
||
2841 | 2841 | * @package GeoDirectory |
2842 | 2842 | */ |
2843 | 2843 | function geodir_wpml_set_filter() { |
2844 | - if (geodir_is_wpml()) { |
|
2845 | - global $sitepress; |
|
2844 | + if (geodir_is_wpml()) { |
|
2845 | + global $sitepress; |
|
2846 | 2846 | |
2847 | - if ($sitepress->get_setting('sync_comments_on_duplicates')) { |
|
2848 | - add_action('comment_post', 'gepdir_wpml_sync_comment', 100, 1); |
|
2849 | - } |
|
2847 | + if ($sitepress->get_setting('sync_comments_on_duplicates')) { |
|
2848 | + add_action('comment_post', 'gepdir_wpml_sync_comment', 100, 1); |
|
2849 | + } |
|
2850 | 2850 | |
2851 | - add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2); |
|
2852 | - add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 ); |
|
2851 | + add_action('geodir_after_save_listing', 'geodir_wpml_duplicate_listing', 100, 2); |
|
2852 | + add_action( 'geodir_edit_post_link_html', 'geodir_wpml_frontend_duplicate_listing', 0, 1 ); |
|
2853 | 2853 | add_action( 'geodir_after_search_form', 'geodir_wpml_add_language_input_field' ); |
2854 | - if (is_admin()) { |
|
2855 | - add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 ); |
|
2856 | - } |
|
2857 | - } |
|
2854 | + if (is_admin()) { |
|
2855 | + add_filter( 'geodir_design_settings', 'geodir_wpml_duplicate_settings', 10, 1 ); |
|
2856 | + } |
|
2857 | + } |
|
2858 | 2858 | } |
2859 | 2859 | add_filter('plugins_loaded', 'geodir_wpml_set_filter'); |
2860 | 2860 | |
@@ -2867,38 +2867,38 @@ discard block |
||
2867 | 2867 | * @return array Filtered languages. |
2868 | 2868 | */ |
2869 | 2869 | function geodir_wpml_filter_ls_languages($languages) { |
2870 | - if (geodir_is_geodir_page()) { |
|
2871 | - $keep_vars = array(); |
|
2870 | + if (geodir_is_geodir_page()) { |
|
2871 | + $keep_vars = array(); |
|
2872 | 2872 | |
2873 | - if (geodir_is_page('add-listing')) { |
|
2874 | - $keep_vars = array('listing_type', 'package_id'); |
|
2875 | - } else if (geodir_is_page('search')) { |
|
2876 | - $keep_vars = array('geodir_search', 'stype', 'snear', 'set_location_type', 'set_location_val', 'sgeo_lat', 'sgeo_lon'); |
|
2877 | - } else if (geodir_is_page('author')) { |
|
2878 | - $keep_vars = array('geodir_dashbord', 'stype', 'list'); |
|
2879 | - } else if (geodir_is_page('login')) { |
|
2880 | - $keep_vars = array('forgot', 'signup'); |
|
2881 | - } |
|
2873 | + if (geodir_is_page('add-listing')) { |
|
2874 | + $keep_vars = array('listing_type', 'package_id'); |
|
2875 | + } else if (geodir_is_page('search')) { |
|
2876 | + $keep_vars = array('geodir_search', 'stype', 'snear', 'set_location_type', 'set_location_val', 'sgeo_lat', 'sgeo_lon'); |
|
2877 | + } else if (geodir_is_page('author')) { |
|
2878 | + $keep_vars = array('geodir_dashbord', 'stype', 'list'); |
|
2879 | + } else if (geodir_is_page('login')) { |
|
2880 | + $keep_vars = array('forgot', 'signup'); |
|
2881 | + } |
|
2882 | 2882 | |
2883 | - if (!empty($keep_vars)) { |
|
2884 | - foreach ( $languages as $code => $url) { |
|
2885 | - $filter_url = $url['url']; |
|
2883 | + if (!empty($keep_vars)) { |
|
2884 | + foreach ( $languages as $code => $url) { |
|
2885 | + $filter_url = $url['url']; |
|
2886 | 2886 | |
2887 | - foreach ($keep_vars as $var) { |
|
2888 | - if (isset($_GET[$var]) && !is_array($_GET[$var])) { |
|
2889 | - $filter_url = remove_query_arg(array($var), $filter_url); |
|
2890 | - $filter_url = add_query_arg(array($var => $_GET[$var]), $filter_url); |
|
2891 | - } |
|
2892 | - } |
|
2887 | + foreach ($keep_vars as $var) { |
|
2888 | + if (isset($_GET[$var]) && !is_array($_GET[$var])) { |
|
2889 | + $filter_url = remove_query_arg(array($var), $filter_url); |
|
2890 | + $filter_url = add_query_arg(array($var => $_GET[$var]), $filter_url); |
|
2891 | + } |
|
2892 | + } |
|
2893 | 2893 | |
2894 | - if ($filter_url != $url['url']) { |
|
2895 | - $languages[$code]['url'] = $filter_url; |
|
2896 | - } |
|
2897 | - } |
|
2898 | - } |
|
2899 | - } |
|
2894 | + if ($filter_url != $url['url']) { |
|
2895 | + $languages[$code]['url'] = $filter_url; |
|
2896 | + } |
|
2897 | + } |
|
2898 | + } |
|
2899 | + } |
|
2900 | 2900 | |
2901 | - return $languages; |
|
2901 | + return $languages; |
|
2902 | 2902 | } |
2903 | 2903 | add_filter( 'icl_ls_languages', 'geodir_wpml_filter_ls_languages', 11, 1 ); |
2904 | 2904 | |
@@ -2909,18 +2909,18 @@ discard block |
||
2909 | 2909 | * |
2910 | 2910 | */ |
2911 | 2911 | function geodir_remove_yoast_seo_metas(){ |
2912 | - if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) { |
|
2913 | - $wpseo = WPSEO_Frontend::get_instance(); |
|
2912 | + if ( class_exists( 'WPSEO_Frontend' ) && geodir_is_geodir_page() && geodir_disable_yoast_seo_metas() ) { |
|
2913 | + $wpseo = WPSEO_Frontend::get_instance(); |
|
2914 | 2914 | |
2915 | - remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 ); |
|
2916 | - remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 ); |
|
2917 | - remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 ); |
|
2918 | - remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 ); |
|
2919 | - remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 ); |
|
2920 | - remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 ); |
|
2915 | + remove_action( 'wp_head', array( $wpseo, 'metadesc' ), 6 ); |
|
2916 | + remove_action( 'wp_head', array( $wpseo, 'metakeywords' ), 11 ); |
|
2917 | + remove_filter( 'pre_get_document_title', array( $wpseo, 'title' ), 15 ); |
|
2918 | + remove_filter( 'wp_title', array( $wpseo, 'title' ), 15, 3 ); |
|
2919 | + remove_filter( 'thematic_doctitle', array( $wpseo, 'title' ), 15 ); |
|
2920 | + remove_filter( 'woo_title', array( $wpseo, 'fix_woo_title' ), 99 ); |
|
2921 | 2921 | |
2922 | - remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 ); |
|
2923 | - } |
|
2922 | + remove_action( 'template_redirect', 'wpseo_frontend_head_init', 999 ); |
|
2923 | + } |
|
2924 | 2924 | } |
2925 | 2925 | |
2926 | 2926 | /** |
@@ -2934,20 +2934,20 @@ discard block |
||
2934 | 2934 | * |
2935 | 2935 | */ |
2936 | 2936 | function geodir_wpml_ajax_set_guest_lang() { |
2937 | - if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) { |
|
2938 | - if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) { |
|
2939 | - global $sitepress; |
|
2937 | + if ( geodir_is_wpml() && wpml_is_ajax() && !is_user_logged_in() ) { |
|
2938 | + if ( empty( $_GET['lang'] ) && !( !empty( $_SERVER['REQUEST_URI'] ) && preg_match( '@\.(css|js|png|jpg|gif|jpeg|bmp)@i', basename( preg_replace( '@\?.*$@', '', $_SERVER['REQUEST_URI'] ) ) ) ) ) { |
|
2939 | + global $sitepress; |
|
2940 | 2940 | |
2941 | - $referer = wp_get_referer(); |
|
2941 | + $referer = wp_get_referer(); |
|
2942 | 2942 | |
2943 | - $current_lang = $sitepress->get_current_language(); |
|
2944 | - $referrer_lang = $sitepress->get_language_from_url( $referer ); |
|
2943 | + $current_lang = $sitepress->get_current_language(); |
|
2944 | + $referrer_lang = $sitepress->get_language_from_url( $referer ); |
|
2945 | 2945 | |
2946 | - if ( $referrer_lang && $current_lang != $referrer_lang ) { |
|
2947 | - $_GET['lang'] = $referrer_lang; |
|
2948 | - } |
|
2949 | - } |
|
2950 | - } |
|
2946 | + if ( $referrer_lang && $current_lang != $referrer_lang ) { |
|
2947 | + $_GET['lang'] = $referrer_lang; |
|
2948 | + } |
|
2949 | + } |
|
2950 | + } |
|
2951 | 2951 | } |
2952 | 2952 | add_action( 'plugins_loaded', 'geodir_wpml_ajax_set_guest_lang', -1 ); |
2953 | 2953 | |
@@ -2959,36 +2959,36 @@ discard block |
||
2959 | 2959 | * @param object $wp The WordPress object. |
2960 | 2960 | */ |
2961 | 2961 | function geodir_check_redirect($wp) { |
2962 | - if (is_404() || (!empty($wp->query_vars['error']) && $wp->query_vars['error'] == '404')) { |
|
2963 | - $current_url = geodir_curPageURL(); |
|
2964 | - $search = 'czech-republic'; |
|
2965 | - $replace = 'czechia'; |
|
2962 | + if (is_404() || (!empty($wp->query_vars['error']) && $wp->query_vars['error'] == '404')) { |
|
2963 | + $current_url = geodir_curPageURL(); |
|
2964 | + $search = 'czech-republic'; |
|
2965 | + $replace = 'czechia'; |
|
2966 | 2966 | |
2967 | - $has_slash = substr($current_url, -1); |
|
2968 | - if ($has_slash != "/") { |
|
2969 | - $current_url .= '/'; |
|
2970 | - } |
|
2967 | + $has_slash = substr($current_url, -1); |
|
2968 | + if ($has_slash != "/") { |
|
2969 | + $current_url .= '/'; |
|
2970 | + } |
|
2971 | 2971 | |
2972 | - $redirect = false; |
|
2973 | - if (strpos($current_url, '/' . $search . '/') !== false) { |
|
2974 | - $redirect = true; |
|
2975 | - $current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1); |
|
2976 | - } |
|
2972 | + $redirect = false; |
|
2973 | + if (strpos($current_url, '/' . $search . '/') !== false) { |
|
2974 | + $redirect = true; |
|
2975 | + $current_url = preg_replace('/\/' . $search . '\//', '/' . $replace . '/', $current_url, 1); |
|
2976 | + } |
|
2977 | 2977 | |
2978 | - if ($has_slash != "/") { |
|
2979 | - $current_url = trim($current_url, '/'); |
|
2980 | - } |
|
2978 | + if ($has_slash != "/") { |
|
2979 | + $current_url = trim($current_url, '/'); |
|
2980 | + } |
|
2981 | 2981 | |
2982 | - if (strpos($current_url, 'gd_country=' . $search) !== false) { |
|
2983 | - $redirect = true; |
|
2984 | - $current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url); |
|
2985 | - } |
|
2986 | - |
|
2987 | - if ($redirect) { |
|
2988 | - wp_redirect($current_url); |
|
2989 | - exit; |
|
2990 | - } |
|
2991 | - } |
|
2982 | + if (strpos($current_url, 'gd_country=' . $search) !== false) { |
|
2983 | + $redirect = true; |
|
2984 | + $current_url = str_replace('gd_country=' . $search, 'gd_country=' . $replace, $current_url); |
|
2985 | + } |
|
2986 | + |
|
2987 | + if ($redirect) { |
|
2988 | + wp_redirect($current_url); |
|
2989 | + exit; |
|
2990 | + } |
|
2991 | + } |
|
2992 | 2992 | } |
2993 | 2993 | add_action('parse_request', 'geodir_check_redirect', 101, 1); |
2994 | 2994 | |
@@ -3008,50 +3008,50 @@ discard block |
||
3008 | 3008 | * @param string $original_slug The original post slug. |
3009 | 3009 | */ |
3010 | 3010 | function geodir_check_post_to_term_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) { |
3011 | - global $wpdb, $sitepress; |
|
3011 | + global $wpdb, $sitepress; |
|
3012 | 3012 | |
3013 | - if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) { |
|
3014 | - $wpml_post_join = ""; |
|
3015 | - $wpml_post_where = ""; |
|
3016 | - $wpml_term_join = ""; |
|
3017 | - $wpml_term_where = ""; |
|
3013 | + if ( $post_type && strpos( $post_type, 'gd_' ) === 0 ) { |
|
3014 | + $wpml_post_join = ""; |
|
3015 | + $wpml_post_where = ""; |
|
3016 | + $wpml_term_join = ""; |
|
3017 | + $wpml_term_where = ""; |
|
3018 | 3018 | |
3019 | - if (geodir_wpml_is_post_type_translated($post_type)) { |
|
3020 | - $post_language = $post_ID ? $sitepress->post_translations()->get_element_lang_code($post_ID) : $sitepress->get_current_language(); |
|
3021 | - $post_language = $post_language ? $post_language : $sitepress->post_translations()->get_save_post_lang($post_ID, $sitepress); |
|
3022 | - if (!$post_language) { |
|
3023 | - $post_language = $sitepress->get_current_language(); |
|
3024 | - } |
|
3019 | + if (geodir_wpml_is_post_type_translated($post_type)) { |
|
3020 | + $post_language = $post_ID ? $sitepress->post_translations()->get_element_lang_code($post_ID) : $sitepress->get_current_language(); |
|
3021 | + $post_language = $post_language ? $post_language : $sitepress->post_translations()->get_save_post_lang($post_ID, $sitepress); |
|
3022 | + if (!$post_language) { |
|
3023 | + $post_language = $sitepress->get_current_language(); |
|
3024 | + } |
|
3025 | 3025 | |
3026 | - $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)"; |
|
3027 | - $wpml_post_where = " AND icl_t.language_code = '" . $post_language ."'"; |
|
3026 | + $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)"; |
|
3027 | + $wpml_post_where = " AND icl_t.language_code = '" . $post_language ."'"; |
|
3028 | 3028 | |
3029 | - $wpml_term_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type = CONCAT('tax_', tt.taxonomy)"; |
|
3030 | - $wpml_term_where = " AND icl_t.language_code = '" . $post_language ."'"; |
|
3031 | - } |
|
3029 | + $wpml_term_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type = CONCAT('tax_', tt.taxonomy)"; |
|
3030 | + $wpml_term_where = " AND icl_t.language_code = '" . $post_language ."'"; |
|
3031 | + } |
|
3032 | 3032 | |
3033 | - $term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $slug ) ); |
|
3033 | + $term_slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $slug ) ); |
|
3034 | 3034 | |
3035 | - if ( $term_slug_check ) { |
|
3036 | - $suffix = 1; |
|
3035 | + if ( $term_slug_check ) { |
|
3036 | + $suffix = 1; |
|
3037 | 3037 | |
3038 | - do { |
|
3039 | - $alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; |
|
3038 | + do { |
|
3039 | + $alt_slug = _truncate_post_slug( $original_slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; |
|
3040 | 3040 | |
3041 | - $term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug ) ); |
|
3041 | + $term_check = $wpdb->get_var( $wpdb->prepare( "SELECT t.slug FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id {$wpml_term_join} WHERE t.slug = '%s' AND ( tt.taxonomy = '" . $post_type . "category' OR tt.taxonomy = '" . $post_type . "_tags' ) {$wpml_term_where} LIMIT 1", $alt_slug ) ); |
|
3042 | 3042 | |
3043 | - $post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID ) ); |
|
3043 | + $post_check = !$term_check && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s AND p.ID != %d {$wpml_term_where} LIMIT 1", $alt_slug, $post_type, $post_ID ) ); |
|
3044 | 3044 | |
3045 | - $term_slug_check = $term_check || $post_check; |
|
3045 | + $term_slug_check = $term_check || $post_check; |
|
3046 | 3046 | |
3047 | - $suffix++; |
|
3048 | - } while ( $term_slug_check ); |
|
3047 | + $suffix++; |
|
3048 | + } while ( $term_slug_check ); |
|
3049 | 3049 | |
3050 | - $slug = $alt_slug; |
|
3051 | - } |
|
3052 | - } |
|
3050 | + $slug = $alt_slug; |
|
3051 | + } |
|
3052 | + } |
|
3053 | 3053 | |
3054 | - return $slug; |
|
3054 | + return $slug; |
|
3055 | 3055 | } |
3056 | 3056 | add_filter( 'wp_unique_post_slug', 'geodir_check_post_to_term_slug', 101, 6 ); |
3057 | 3057 | |
@@ -3071,48 +3071,48 @@ discard block |
||
3071 | 3071 | * @return bool true when exists. false when not exists. |
3072 | 3072 | */ |
3073 | 3073 | function geodir_check_term_to_post_slug( $slug_exists, $slug, $term_id ) { |
3074 | - global $wpdb, $gd_term_post_type, $gd_term_taxonomy, $sitepress; |
|
3074 | + global $wpdb, $gd_term_post_type, $gd_term_taxonomy, $sitepress; |
|
3075 | 3075 | |
3076 | - if ( $slug_exists ) { |
|
3077 | - return $slug_exists; |
|
3078 | - } |
|
3076 | + if ( $slug_exists ) { |
|
3077 | + return $slug_exists; |
|
3078 | + } |
|
3079 | 3079 | |
3080 | - if ( !empty( $gd_term_taxonomy ) && isset($gd_term_taxonomy[$term_id]) ) { |
|
3081 | - $taxonomy = $gd_term_taxonomy[$term_id]; |
|
3082 | - } else { |
|
3083 | - $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) ); |
|
3084 | - $gd_term_taxonomy[$term_id] = $taxonomy; |
|
3085 | - } |
|
3080 | + if ( !empty( $gd_term_taxonomy ) && isset($gd_term_taxonomy[$term_id]) ) { |
|
3081 | + $taxonomy = $gd_term_taxonomy[$term_id]; |
|
3082 | + } else { |
|
3083 | + $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id ) ); |
|
3084 | + $gd_term_taxonomy[$term_id] = $taxonomy; |
|
3085 | + } |
|
3086 | 3086 | |
3087 | - if ( empty($taxonomy) ) { |
|
3088 | - return $slug_exists; |
|
3089 | - } |
|
3087 | + if ( empty($taxonomy) ) { |
|
3088 | + return $slug_exists; |
|
3089 | + } |
|
3090 | 3090 | |
3091 | - if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) { |
|
3092 | - $post_type = $gd_term_post_type[$term_id]; |
|
3093 | - } else { |
|
3094 | - $taxonomy_obj = get_taxonomy( $taxonomy ); |
|
3095 | - $post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL; |
|
3096 | - } |
|
3091 | + if ( !empty( $gd_term_post_type ) && $gd_term_post_type[$term_id] ) { |
|
3092 | + $post_type = $gd_term_post_type[$term_id]; |
|
3093 | + } else { |
|
3094 | + $taxonomy_obj = get_taxonomy( $taxonomy ); |
|
3095 | + $post_type = !empty( $taxonomy_obj->object_type ) ? $taxonomy_obj->object_type[0] : NULL; |
|
3096 | + } |
|
3097 | 3097 | |
3098 | - $wpml_post_join = ""; |
|
3099 | - $wpml_post_where = ""; |
|
3098 | + $wpml_post_join = ""; |
|
3099 | + $wpml_post_where = ""; |
|
3100 | 3100 | |
3101 | - if (geodir_wpml_is_taxonomy_translated($taxonomy) || geodir_wpml_is_post_type_translated($post_type)) { |
|
3102 | - $term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_' . $taxonomy) : $sitepress->get_current_language(); |
|
3103 | - if (!$term_language) { |
|
3104 | - $term_language = $sitepress->get_current_language(); |
|
3105 | - } |
|
3101 | + if (geodir_wpml_is_taxonomy_translated($taxonomy) || geodir_wpml_is_post_type_translated($post_type)) { |
|
3102 | + $term_language = $term_id ? geodir_get_language_for_element($term_id, 'tax_' . $taxonomy) : $sitepress->get_current_language(); |
|
3103 | + if (!$term_language) { |
|
3104 | + $term_language = $sitepress->get_current_language(); |
|
3105 | + } |
|
3106 | 3106 | |
3107 | - $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)"; |
|
3108 | - $wpml_post_where = " AND icl_t.language_code = '" . $term_language ."'"; |
|
3109 | - } |
|
3107 | + $wpml_post_join = " JOIN {$wpdb->prefix}icl_translations AS icl_t ON p.ID = icl_t.element_id AND icl_t.element_type = CONCAT('post_', p.post_type)"; |
|
3108 | + $wpml_post_where = " AND icl_t.language_code = '" . $term_language ."'"; |
|
3109 | + } |
|
3110 | 3110 | |
3111 | - if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s {$wpml_post_where} LIMIT 1", $slug, $post_type ) ) ) { |
|
3112 | - $slug_exists = true; |
|
3113 | - } |
|
3111 | + if ( $post_type && $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p {$wpml_post_join} WHERE p.post_name = %s AND p.post_type = %s {$wpml_post_where} LIMIT 1", $slug, $post_type ) ) ) { |
|
3112 | + $slug_exists = true; |
|
3113 | + } |
|
3114 | 3114 | |
3115 | - return $slug_exists; |
|
3115 | + return $slug_exists; |
|
3116 | 3116 | } |
3117 | 3117 | add_filter( 'geodir_term_slug_is_exists', 'geodir_check_term_to_post_slug', 10, 3 ); |
3118 | 3118 |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | * @since 1.4.6 |
14 | 14 | * @return int|null Return the page ID if present or null if not. |
15 | 15 | */ |
16 | -function geodir_add_listing_page_id(){ |
|
16 | +function geodir_add_listing_page_id() { |
|
17 | 17 | $gd_page_id = get_option('geodir_add_listing_page'); |
18 | 18 | |
19 | 19 | if (geodir_is_wpml()) { |
20 | - $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
20 | + $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | return $gd_page_id; |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * @since 1.4.6 |
31 | 31 | * @return int|null Return the page ID if present or null if not. |
32 | 32 | */ |
33 | -function geodir_preview_page_id(){ |
|
33 | +function geodir_preview_page_id() { |
|
34 | 34 | $gd_page_id = get_option('geodir_preview_page'); |
35 | 35 | |
36 | 36 | if (geodir_is_wpml()) { |
37 | - $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
37 | + $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return $gd_page_id; |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @since 1.4.6 |
48 | 48 | * @return int|null Return the page ID if present or null if not. |
49 | 49 | */ |
50 | -function geodir_success_page_id(){ |
|
50 | +function geodir_success_page_id() { |
|
51 | 51 | $gd_page_id = get_option('geodir_success_page'); |
52 | 52 | |
53 | 53 | if (geodir_is_wpml()) { |
54 | - $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
54 | + $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return $gd_page_id; |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * @since 1.4.6 |
65 | 65 | * @return int|null Return the page ID if present or null if not. |
66 | 66 | */ |
67 | -function geodir_location_page_id(){ |
|
67 | +function geodir_location_page_id() { |
|
68 | 68 | $gd_page_id = get_option('geodir_location_page'); |
69 | 69 | |
70 | 70 | if (geodir_is_wpml()) { |
71 | - $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
71 | + $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return $gd_page_id; |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | * @since 1.5.4 |
82 | 82 | * @return int|null Return the page ID if present or null if not. |
83 | 83 | */ |
84 | -function geodir_home_page_id(){ |
|
84 | +function geodir_home_page_id() { |
|
85 | 85 | $gd_page_id = get_option('geodir_home_page'); |
86 | 86 | |
87 | 87 | if (geodir_is_wpml()) { |
88 | - $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
88 | + $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $gd_page_id; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * @since 1.5.3 |
99 | 99 | * @return int|null Return the page ID if present or null if not. |
100 | 100 | */ |
101 | -function geodir_info_page_id(){ |
|
101 | +function geodir_info_page_id() { |
|
102 | 102 | $gd_page_id = get_option('geodir_info_page'); |
103 | 103 | |
104 | 104 | if (geodir_is_wpml()) { |
105 | - $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
105 | + $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | return $gd_page_id; |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | * @since 1.5.3 |
116 | 116 | * @return int|null Return the page ID if present or null if not. |
117 | 117 | */ |
118 | -function geodir_login_page_id(){ |
|
118 | +function geodir_login_page_id() { |
|
119 | 119 | $gd_page_id = get_option('geodir_login_page'); |
120 | 120 | |
121 | 121 | if (geodir_is_wpml()) { |
122 | - $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
122 | + $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return $gd_page_id; |
@@ -133,20 +133,20 @@ discard block |
||
133 | 133 | * @since 1.5.3 |
134 | 134 | * @return int|null Return the page ID if present or null if not. |
135 | 135 | */ |
136 | -function geodir_login_url($args=array()){ |
|
136 | +function geodir_login_url($args = array()) { |
|
137 | 137 | $gd_page_id = get_option('geodir_login_page'); |
138 | 138 | |
139 | 139 | if (geodir_is_wpml()) { |
140 | - $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
140 | + $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | if (function_exists('geodir_location_geo_home_link')) { |
144 | 144 | remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
145 | 145 | } |
146 | 146 | |
147 | - if (geodir_is_wpml()){ |
|
147 | + if (geodir_is_wpml()) { |
|
148 | 148 | $home_url = icl_get_home_url(); |
149 | - }else{ |
|
149 | + } else { |
|
150 | 150 | $home_url = home_url(); |
151 | 151 | } |
152 | 152 | |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
155 | 155 | } |
156 | 156 | |
157 | - if($gd_page_id){ |
|
157 | + if ($gd_page_id) { |
|
158 | 158 | $post = get_post($gd_page_id); |
159 | 159 | $slug = $post->post_name; |
160 | 160 | //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
161 | 161 | $login_url = trailingslashit($home_url)."$slug/"; |
162 | - }else{ |
|
162 | + } else { |
|
163 | 163 | $login_url = trailingslashit($home_url)."?geodir_signup=true"; |
164 | 164 | } |
165 | 165 | |
166 | - if($args){ |
|
167 | - $login_url = add_query_arg($args,$login_url ); |
|
166 | + if ($args) { |
|
167 | + $login_url = add_query_arg($args, $login_url); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param array $args The array of query args used. |
179 | 179 | * @param int $gd_page_id The page id of the GD login page. |
180 | 180 | */ |
181 | - return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id); |
|
181 | + return apply_filters('geodir_login_url', $login_url, $args, $gd_page_id); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -189,20 +189,20 @@ discard block |
||
189 | 189 | * @since 1.5.16 Added WPML lang code to url. |
190 | 190 | * @return string Info page url. |
191 | 191 | */ |
192 | -function geodir_info_url($args=array()){ |
|
192 | +function geodir_info_url($args = array()) { |
|
193 | 193 | $gd_page_id = get_option('geodir_info_page'); |
194 | 194 | |
195 | 195 | if (geodir_is_wpml()) { |
196 | - $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
196 | + $gd_page_id = geodir_wpml_object_id($gd_page_id, 'page', true); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | if (function_exists('geodir_location_geo_home_link')) { |
200 | 200 | remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
201 | 201 | } |
202 | 202 | |
203 | - if (geodir_is_wpml()){ |
|
203 | + if (geodir_is_wpml()) { |
|
204 | 204 | $home_url = icl_get_home_url(); |
205 | - }else{ |
|
205 | + } else { |
|
206 | 206 | $home_url = home_url(); |
207 | 207 | } |
208 | 208 | |
@@ -210,17 +210,17 @@ discard block |
||
210 | 210 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
211 | 211 | } |
212 | 212 | |
213 | - if($gd_page_id){ |
|
213 | + if ($gd_page_id) { |
|
214 | 214 | $post = get_post($gd_page_id); |
215 | 215 | $slug = $post->post_name; |
216 | 216 | //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
217 | 217 | $info_url = trailingslashit($home_url)."$slug/"; |
218 | - }else{ |
|
218 | + } else { |
|
219 | 219 | $info_url = trailingslashit($home_url); |
220 | 220 | } |
221 | 221 | |
222 | - if($args){ |
|
223 | - $info_url = add_query_arg($args,$info_url ); |
|
222 | + if ($args) { |
|
223 | + $info_url = add_query_arg($args, $info_url); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | return $info_url; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param string $charset Character set to use for conversion. |
239 | 239 | * @return string Returns converted string. |
240 | 240 | */ |
241 | -function geodir_ucwords($string, $charset='UTF-8') { |
|
241 | +function geodir_ucwords($string, $charset = 'UTF-8') { |
|
242 | 242 | if (function_exists('mb_convert_case')) { |
243 | 243 | return mb_convert_case($string, MB_CASE_TITLE, $charset); |
244 | 244 | } else { |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param string $charset Character set to use for conversion. |
259 | 259 | * @return string Returns converted string. |
260 | 260 | */ |
261 | -function geodir_strtolower($string, $charset='UTF-8') { |
|
261 | +function geodir_strtolower($string, $charset = 'UTF-8') { |
|
262 | 262 | if (function_exists('mb_convert_case')) { |
263 | 263 | return mb_convert_case($string, MB_CASE_LOWER, $charset); |
264 | 264 | } else { |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param string $charset Character set to use for conversion. |
279 | 279 | * @return string Returns converted string. |
280 | 280 | */ |
281 | -function geodir_strtoupper($string, $charset='UTF-8') { |
|
281 | +function geodir_strtoupper($string, $charset = 'UTF-8') { |
|
282 | 282 | if (function_exists('mb_convert_case')) { |
283 | 283 | return mb_convert_case($string, MB_CASE_UPPER, $charset); |
284 | 284 | } else { |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | $url = trim($parts[0]); |
311 | 311 | if ($formatted && $url != '') { |
312 | - $url = str_replace( ' ', '%20', $url ); |
|
312 | + $url = str_replace(' ', '%20', $url); |
|
313 | 313 | $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url); |
314 | 314 | |
315 | 315 | if (0 !== stripos($url, 'mailto:')) { |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | |
320 | 320 | $url = str_replace(';//', '://', $url); |
321 | 321 | |
322 | - if (strpos($url, ':') === false && ! in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) { |
|
323 | - $url = 'http://' . $url; |
|
322 | + if (strpos($url, ':') === false && !in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) { |
|
323 | + $url = 'http://'.$url; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | $url = wp_kses_normalize_entities($url); |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * @package GeoDirectory |
463 | 463 | */ |
464 | 464 | function _gd_die_handler() { |
465 | - if ( defined( 'GD_TESTING_MODE' ) ) { |
|
465 | + if (defined('GD_TESTING_MODE')) { |
|
466 | 466 | return '_gd_die_handler'; |
467 | 467 | } else { |
468 | 468 | die(); |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | * @param string $title Optional. Error title. |
481 | 481 | * @param int $status Optional. Status code. |
482 | 482 | */ |
483 | -function gd_die( $message = '', $title = '', $status = 400 ) { |
|
484 | - add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 ); |
|
485 | - add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 ); |
|
486 | - wp_die( $message, $title, array( 'response' => $status )); |
|
483 | +function gd_die($message = '', $title = '', $status = 400) { |
|
484 | + add_filter('wp_die_ajax_handler', '_gd_die_handler', 10, 3); |
|
485 | + add_filter('wp_die_handler', '_gd_die_handler', 10, 3); |
|
486 | + wp_die($message, $title, array('response' => $status)); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /* |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | * @param string $php_format The PHP date format. |
494 | 494 | * @return string The jQuery format date string. |
495 | 495 | */ |
496 | -function geodir_date_format_php_to_jqueryui( $php_format ) { |
|
496 | +function geodir_date_format_php_to_jqueryui($php_format) { |
|
497 | 497 | $symbols = array( |
498 | 498 | // Day |
499 | 499 | 'd' => 'dd', |
@@ -533,27 +533,27 @@ discard block |
||
533 | 533 | $jqueryui_format = ""; |
534 | 534 | $escaping = false; |
535 | 535 | |
536 | - for ( $i = 0; $i < strlen( $php_format ); $i++ ) { |
|
536 | + for ($i = 0; $i < strlen($php_format); $i++) { |
|
537 | 537 | $char = $php_format[$i]; |
538 | 538 | |
539 | 539 | // PHP date format escaping character |
540 | - if ( $char === '\\' ) { |
|
540 | + if ($char === '\\') { |
|
541 | 541 | $i++; |
542 | 542 | |
543 | - if ( $escaping ) { |
|
543 | + if ($escaping) { |
|
544 | 544 | $jqueryui_format .= $php_format[$i]; |
545 | 545 | } else { |
546 | - $jqueryui_format .= '\'' . $php_format[$i]; |
|
546 | + $jqueryui_format .= '\''.$php_format[$i]; |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | $escaping = true; |
550 | 550 | } else { |
551 | - if ( $escaping ) { |
|
551 | + if ($escaping) { |
|
552 | 552 | $jqueryui_format .= "'"; |
553 | 553 | $escaping = false; |
554 | 554 | } |
555 | 555 | |
556 | - if ( isset( $symbols[$char] ) ) { |
|
556 | + if (isset($symbols[$char])) { |
|
557 | 557 | $jqueryui_format .= $symbols[$char]; |
558 | 558 | } else { |
559 | 559 | $jqueryui_format .= $char; |
@@ -574,79 +574,79 @@ discard block |
||
574 | 574 | * @since 1.6.22 Genitive month added. |
575 | 575 | * @since 1.6.26 Date translation issue in German language - FIXED. |
576 | 576 | */ |
577 | -function geodir_maybe_untranslate_date( $date ) { |
|
578 | - $date_formated = ' '. $date; |
|
577 | +function geodir_maybe_untranslate_date($date) { |
|
578 | + $date_formated = ' '.$date; |
|
579 | 579 | |
580 | 580 | $names = array( |
581 | 581 | // The Weekdays |
582 | - 'Sunday' => __( 'Sunday' ), |
|
583 | - 'Monday' => __( 'Monday' ), |
|
584 | - 'Tuesday' => __( 'Tuesday' ), |
|
585 | - 'Wednesday' => __( 'Wednesday' ), |
|
586 | - 'Thursday' => __( 'Thursday' ), |
|
587 | - 'Friday' => __( 'Friday' ), |
|
588 | - 'Saturday' => __( 'Saturday' ), |
|
582 | + 'Sunday' => __('Sunday'), |
|
583 | + 'Monday' => __('Monday'), |
|
584 | + 'Tuesday' => __('Tuesday'), |
|
585 | + 'Wednesday' => __('Wednesday'), |
|
586 | + 'Thursday' => __('Thursday'), |
|
587 | + 'Friday' => __('Friday'), |
|
588 | + 'Saturday' => __('Saturday'), |
|
589 | 589 | |
590 | 590 | // The Months |
591 | - 'January' => __( 'January' ), |
|
592 | - 'February' => __( 'February' ), |
|
593 | - 'March' => __( 'March' ), |
|
594 | - 'April' => __( 'April' ), |
|
595 | - 'May' => __( 'May' ), |
|
596 | - 'June' => __( 'June' ), |
|
597 | - 'July' => __( 'July' ), |
|
598 | - 'August' => __( 'August' ), |
|
599 | - 'September' => __( 'September' ), |
|
600 | - 'October' => __( 'October' ), |
|
601 | - 'November' => __( 'November' ), |
|
602 | - 'December' => __( 'December' ), |
|
591 | + 'January' => __('January'), |
|
592 | + 'February' => __('February'), |
|
593 | + 'March' => __('March'), |
|
594 | + 'April' => __('April'), |
|
595 | + 'May' => __('May'), |
|
596 | + 'June' => __('June'), |
|
597 | + 'July' => __('July'), |
|
598 | + 'August' => __('August'), |
|
599 | + 'September' => __('September'), |
|
600 | + 'October' => __('October'), |
|
601 | + 'November' => __('November'), |
|
602 | + 'December' => __('December'), |
|
603 | 603 | |
604 | 604 | // Abbreviations for each month. |
605 | - 'Jan' => _x( 'Jan', 'January abbreviation' ), |
|
606 | - 'Feb' => _x( 'Feb', 'February abbreviation' ), |
|
607 | - 'Mar' => _x( 'Mar', 'March abbreviation' ), |
|
608 | - 'Apr' => _x( 'Apr', 'April abbreviation' ), |
|
609 | - 'May' => _x( 'May', 'May abbreviation' ), |
|
610 | - 'Jun' => _x( 'Jun', 'June abbreviation' ), |
|
611 | - 'Jul' => _x( 'Jul', 'July abbreviation' ), |
|
612 | - 'Aug' => _x( 'Aug', 'August abbreviation' ), |
|
613 | - 'Sep' => _x( 'Sep', 'September abbreviation' ), |
|
614 | - 'Oct' => _x( 'Oct', 'October abbreviation' ), |
|
615 | - 'Nov' => _x( 'Nov', 'November abbreviation' ), |
|
616 | - 'Dec' => _x( 'Dec', 'December abbreviation' ), |
|
605 | + 'Jan' => _x('Jan', 'January abbreviation'), |
|
606 | + 'Feb' => _x('Feb', 'February abbreviation'), |
|
607 | + 'Mar' => _x('Mar', 'March abbreviation'), |
|
608 | + 'Apr' => _x('Apr', 'April abbreviation'), |
|
609 | + 'May' => _x('May', 'May abbreviation'), |
|
610 | + 'Jun' => _x('Jun', 'June abbreviation'), |
|
611 | + 'Jul' => _x('Jul', 'July abbreviation'), |
|
612 | + 'Aug' => _x('Aug', 'August abbreviation'), |
|
613 | + 'Sep' => _x('Sep', 'September abbreviation'), |
|
614 | + 'Oct' => _x('Oct', 'October abbreviation'), |
|
615 | + 'Nov' => _x('Nov', 'November abbreviation'), |
|
616 | + 'Dec' => _x('Dec', 'December abbreviation'), |
|
617 | 617 | |
618 | 618 | // Abbreviations for each day. |
619 | - 'Sun' => __( 'Sun' ), |
|
620 | - 'Mon' => __( 'Mon' ), |
|
621 | - 'Tue' => __( 'Tue' ), |
|
622 | - 'Wed' => __( 'Wed' ), |
|
623 | - 'Thu' => __( 'Thu' ), |
|
624 | - 'Fri' => __( 'Fri' ), |
|
625 | - 'Sat' => __( 'Sat' ), |
|
619 | + 'Sun' => __('Sun'), |
|
620 | + 'Mon' => __('Mon'), |
|
621 | + 'Tue' => __('Tue'), |
|
622 | + 'Wed' => __('Wed'), |
|
623 | + 'Thu' => __('Thu'), |
|
624 | + 'Fri' => __('Fri'), |
|
625 | + 'Sat' => __('Sat'), |
|
626 | 626 | |
627 | 627 | // The first letter of each day. |
628 | - 'S' => _x( 'S', 'Sunday initial' ), |
|
629 | - 'M' => _x( 'M', 'Monday initial' ), |
|
630 | - 'T' => _x( 'T', 'Tuesday initial' ), |
|
631 | - 'W' => _x( 'W', 'Wednesday initial' ), |
|
632 | - 'T' => _x( 'T', 'Thursday initial' ), |
|
633 | - 'F' => _x( 'F', 'Friday initial' ), |
|
634 | - 'S' => _x( 'S', 'Saturday initial' ), |
|
628 | + 'S' => _x('S', 'Sunday initial'), |
|
629 | + 'M' => _x('M', 'Monday initial'), |
|
630 | + 'T' => _x('T', 'Tuesday initial'), |
|
631 | + 'W' => _x('W', 'Wednesday initial'), |
|
632 | + 'T' => _x('T', 'Thursday initial'), |
|
633 | + 'F' => _x('F', 'Friday initial'), |
|
634 | + 'S' => _x('S', 'Saturday initial'), |
|
635 | 635 | |
636 | 636 | // The Meridiems |
637 | - 'am' => __( 'am' ), |
|
638 | - 'pm' => __( 'pm' ), |
|
639 | - 'AM' => __( 'AM' ), |
|
640 | - 'PM' => __( 'PM' ) |
|
637 | + 'am' => __('am'), |
|
638 | + 'pm' => __('pm'), |
|
639 | + 'AM' => __('AM'), |
|
640 | + 'PM' => __('PM') |
|
641 | 641 | ); |
642 | 642 | |
643 | - foreach ( $names as $name => $translation ) { |
|
644 | - $date_formated = preg_replace( "/([^\\\])" . $name . "/", "\\1" . backslashit( $name ), $date_formated ); |
|
645 | - $date_formated = preg_replace( "/([^\\\])" . $translation . "/", "\\1" . backslashit( $name ), $date_formated ); |
|
643 | + foreach ($names as $name => $translation) { |
|
644 | + $date_formated = preg_replace("/([^\\\])".$name."/", "\\1".backslashit($name), $date_formated); |
|
645 | + $date_formated = preg_replace("/([^\\\])".$translation."/", "\\1".backslashit($name), $date_formated); |
|
646 | 646 | } |
647 | 647 | |
648 | - $date_formated = substr( $date_formated, 1, strlen( $date_formated ) -1 ); |
|
649 | - $date = stripslashes( $date_formated ); |
|
648 | + $date_formated = substr($date_formated, 1, strlen($date_formated) - 1); |
|
649 | + $date = stripslashes($date_formated); |
|
650 | 650 | |
651 | 651 | return $date; |
652 | 652 | } |
@@ -663,30 +663,30 @@ discard block |
||
663 | 663 | * @param bool $locale True to retrieve the date in localized format. Default false. |
664 | 664 | * @return string The formatted date. |
665 | 665 | */ |
666 | -function geodir_date( $date_input, $date_to, $date_from = '', $locale = false ) { |
|
667 | - if ( empty( $date_input ) || empty( $date_to ) ) { |
|
666 | +function geodir_date($date_input, $date_to, $date_from = '', $locale = false) { |
|
667 | + if (empty($date_input) || empty($date_to)) { |
|
668 | 668 | return NULL; |
669 | 669 | } |
670 | 670 | |
671 | - $date_input = geodir_maybe_untranslate_date( $date_input ); |
|
671 | + $date_input = geodir_maybe_untranslate_date($date_input); |
|
672 | 672 | |
673 | 673 | $timestamp = 0; |
674 | - if (!empty( $date_from ) && function_exists( 'date_create_from_format' ) ) { |
|
675 | - $datetime = date_create_from_format( $date_from, $date_input ); |
|
676 | - if ( !empty( $datetime ) ) { |
|
674 | + if (!empty($date_from) && function_exists('date_create_from_format')) { |
|
675 | + $datetime = date_create_from_format($date_from, $date_input); |
|
676 | + if (!empty($datetime)) { |
|
677 | 677 | $timestamp = $datetime->getTimestamp(); |
678 | 678 | } |
679 | 679 | } |
680 | 680 | |
681 | - if ( empty( $timestamp ) ) { |
|
682 | - $date = strpos( $date_input, '/' ) !== false ? str_replace( '/', '-', $date_input ) : $date_input; |
|
683 | - $timestamp = strtotime( $date ); |
|
681 | + if (empty($timestamp)) { |
|
682 | + $date = strpos($date_input, '/') !== false ? str_replace('/', '-', $date_input) : $date_input; |
|
683 | + $timestamp = strtotime($date); |
|
684 | 684 | } |
685 | 685 | |
686 | - $date = date_i18n( $date_to, $timestamp ); |
|
686 | + $date = date_i18n($date_to, $timestamp); |
|
687 | 687 | |
688 | - if ( !$locale ) { |
|
689 | - $date = geodir_maybe_untranslate_date( $date ); |
|
688 | + if (!$locale) { |
|
689 | + $date = geodir_maybe_untranslate_date($date); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @param string $date_from The source date format. |
702 | 702 | * @param bool $locale True to retrieve the date in localized format. |
703 | 703 | */ |
704 | - return apply_filters( 'geodir_date', $date, $date_input, $date_to, $date_from, $locale ); |
|
704 | + return apply_filters('geodir_date', $date, $date_input, $date_to, $date_from, $locale); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | /** |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | * @return string Trimmed string. |
727 | 727 | */ |
728 | 728 | function geodir_excerpt($text, $length = 100, $options = array()) { |
729 | - if (!(int)$length > 0) { |
|
729 | + if (!(int) $length > 0) { |
|
730 | 730 | return $text; |
731 | 731 | } |
732 | 732 | $default = array( |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | $length = $truncateLength; |
789 | 789 | |
790 | 790 | foreach ($openTags as $tag) { |
791 | - $suffix .= '</' . $tag . '>'; |
|
791 | + $suffix .= '</'.$tag.'>'; |
|
792 | 792 | } |
793 | 793 | } else { |
794 | 794 | if (geodir_strlen($text, $options) <= $length) { |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | } |
811 | 811 | } |
812 | 812 | |
813 | - return $prefix . $result . $suffix; |
|
813 | + return $prefix.$result.$suffix; |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i'; |
848 | 848 | $replace = preg_replace_callback( |
849 | 849 | $pattern, |
850 | - function ($match) use ($strlen) { |
|
850 | + function($match) use ($strlen) { |
|
851 | 851 | $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8'); |
852 | 852 | |
853 | 853 | return str_repeat(' ', $strlen($utf8, 'UTF-8')); |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | } |
909 | 909 | |
910 | 910 | if (empty($options['html'])) { |
911 | - return (string)$substr($text, $start, $length); |
|
911 | + return (string) $substr($text, $start, $length); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | $totalOffset = 0; |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | |
934 | 934 | $len = geodir_strlen($part, $options); |
935 | 935 | if ($offset !== 0 || $totalLength + $len > $length) { |
936 | - if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8') ) { |
|
936 | + if (strpos($part, '&') === 0 && preg_match($pattern, $part) && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, 'UTF-8')) { |
|
937 | 937 | // Entities cannot be passed substr. |
938 | 938 | continue; |
939 | 939 | } |
@@ -979,39 +979,39 @@ discard block |
||
979 | 979 | return ''; |
980 | 980 | } |
981 | 981 | |
982 | -function geodir_tool_restore_cpt_from_taxonomies(){ |
|
982 | +function geodir_tool_restore_cpt_from_taxonomies() { |
|
983 | 983 | |
984 | 984 | $cpts = get_option('geodir_post_types'); |
985 | 985 | |
986 | - if(!empty($cpts)){return;} |
|
986 | + if (!empty($cpts)) {return; } |
|
987 | 987 | |
988 | 988 | $taxonomies = get_option('geodir_taxonomies'); |
989 | 989 | |
990 | - if(empty($taxonomies)){return;} |
|
990 | + if (empty($taxonomies)) {return; } |
|
991 | 991 | |
992 | 992 | $cpts = array(); |
993 | 993 | |
994 | - foreach($taxonomies as $key => $val){ |
|
994 | + foreach ($taxonomies as $key => $val) { |
|
995 | 995 | |
996 | - if(strpos($val['listing_slug'], '/') === false) { |
|
997 | - $cpts[$val['object_type']] = array('cpt'=>$val['object_type'],'slug'=>$val['listing_slug']); |
|
996 | + if (strpos($val['listing_slug'], '/') === false) { |
|
997 | + $cpts[$val['object_type']] = array('cpt'=>$val['object_type'], 'slug'=>$val['listing_slug']); |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | } |
1001 | 1001 | |
1002 | - if(empty($cpts)){return;} |
|
1002 | + if (empty($cpts)) {return; } |
|
1003 | 1003 | |
1004 | 1004 | |
1005 | 1005 | $cpts_restore = $cpts; |
1006 | 1006 | |
1007 | - foreach($cpts as $cpt){ |
|
1007 | + foreach ($cpts as $cpt) { |
|
1008 | 1008 | |
1009 | 1009 | |
1010 | - $is_custom = $cpt['cpt']=='gd_place' ? 0 : 1; |
|
1010 | + $is_custom = $cpt['cpt'] == 'gd_place' ? 0 : 1; |
|
1011 | 1011 | |
1012 | - $cpts_restore[$cpt['cpt']] = array ( |
|
1012 | + $cpts_restore[$cpt['cpt']] = array( |
|
1013 | 1013 | 'labels' => |
1014 | - array ( |
|
1014 | + array( |
|
1015 | 1015 | 'name' => $cpt['slug'], |
1016 | 1016 | 'singular_name' => $cpt['slug'], |
1017 | 1017 | 'add_new' => 'Add New', |
@@ -1039,14 +1039,14 @@ discard block |
||
1039 | 1039 | 'public' => true, |
1040 | 1040 | 'query_var' => true, |
1041 | 1041 | 'rewrite' => |
1042 | - array ( |
|
1042 | + array( |
|
1043 | 1043 | 'slug' => $cpt['slug'], |
1044 | 1044 | 'with_front' => false, |
1045 | 1045 | 'hierarchical' => true, |
1046 | 1046 | 'feeds' => true, |
1047 | 1047 | ), |
1048 | 1048 | 'supports' => |
1049 | - array ( |
|
1049 | + array( |
|
1050 | 1050 | 0 => 'title', |
1051 | 1051 | 1 => 'editor', |
1052 | 1052 | 2 => 'author', |
@@ -1056,14 +1056,14 @@ discard block |
||
1056 | 1056 | 6 => 'comments', |
1057 | 1057 | ), |
1058 | 1058 | 'taxonomies' => |
1059 | - array ( |
|
1059 | + array( |
|
1060 | 1060 | 0 => $cpt['cpt'].'category', |
1061 | 1061 | 1 => $cpt['cpt'].'_tags', |
1062 | 1062 | ), |
1063 | 1063 | 'is_custom' => $is_custom, |
1064 | 1064 | 'listing_order' => '1', |
1065 | 1065 | 'seo' => |
1066 | - array ( |
|
1066 | + array( |
|
1067 | 1067 | 'meta_keyword' => '', |
1068 | 1068 | 'meta_description' => '', |
1069 | 1069 | ), |
@@ -1075,7 +1075,7 @@ discard block |
||
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | |
1078 | - update_option('geodir_post_types',$cpts_restore); |
|
1078 | + update_option('geodir_post_types', $cpts_restore); |
|
1079 | 1079 | |
1080 | 1080 | } |
1081 | 1081 | |
@@ -1093,12 +1093,12 @@ discard block |
||
1093 | 1093 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
1094 | 1094 | * @return string |
1095 | 1095 | */ |
1096 | -function geodir_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
1097 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
1098 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
1096 | +function geodir_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
1097 | + if (function_exists('mb_strimwidth')) { |
|
1098 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | - return geodir_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
1101 | + return geodir_utf8_substr($str, $start, $width, $encoding).$trimmaker; |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | /** |
@@ -1111,12 +1111,12 @@ discard block |
||
1111 | 1111 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
1112 | 1112 | * @return int Returns the number of characters in string. |
1113 | 1113 | */ |
1114 | -function geodir_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
1115 | - if ( function_exists( 'mb_strlen' ) ) { |
|
1116 | - return mb_strlen( $str, $encoding ); |
|
1114 | +function geodir_utf8_strlen($str, $encoding = 'UTF-8') { |
|
1115 | + if (function_exists('mb_strlen')) { |
|
1116 | + return mb_strlen($str, $encoding); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | - return strlen( $str ); |
|
1119 | + return strlen($str); |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | /** |
@@ -1131,12 +1131,12 @@ discard block |
||
1131 | 1131 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
1132 | 1132 | * @return int Returns the position of the first occurrence of search in the string. |
1133 | 1133 | */ |
1134 | -function geodir_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
1135 | - if ( function_exists( 'mb_strpos' ) ) { |
|
1136 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
1134 | +function geodir_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
1135 | + if (function_exists('mb_strpos')) { |
|
1136 | + return mb_strpos($str, $find, $offset, $encoding); |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | - return strpos( $str, $find, $offset ); |
|
1139 | + return strpos($str, $find, $offset); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | /** |
@@ -1151,12 +1151,12 @@ discard block |
||
1151 | 1151 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
1152 | 1152 | * @return int Returns the position of the last occurrence of search. |
1153 | 1153 | */ |
1154 | -function geodir_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
1155 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
1156 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
1154 | +function geodir_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
1155 | + if (function_exists('mb_strrpos')) { |
|
1156 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | - return strrpos( $str, $find, $offset ); |
|
1159 | + return strrpos($str, $find, $offset); |
|
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | /** |
@@ -1172,16 +1172,16 @@ discard block |
||
1172 | 1172 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
1173 | 1173 | * @return string |
1174 | 1174 | */ |
1175 | -function geodir_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
1176 | - if ( function_exists( 'mb_substr' ) ) { |
|
1177 | - if ( $length === null ) { |
|
1178 | - return mb_substr( $str, $start, geodir_utf8_strlen( $str, $encoding ), $encoding ); |
|
1175 | +function geodir_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
1176 | + if (function_exists('mb_substr')) { |
|
1177 | + if ($length === null) { |
|
1178 | + return mb_substr($str, $start, geodir_utf8_strlen($str, $encoding), $encoding); |
|
1179 | 1179 | } else { |
1180 | - return mb_substr( $str, $start, $length, $encoding ); |
|
1180 | + return mb_substr($str, $start, $length, $encoding); |
|
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | |
1184 | - return substr( $str, $start, $length ); |
|
1184 | + return substr($str, $start, $length); |
|
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | /** |
@@ -1194,12 +1194,12 @@ discard block |
||
1194 | 1194 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
1195 | 1195 | * @return string The width of string. |
1196 | 1196 | */ |
1197 | -function geodir_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
1198 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
1199 | - return mb_strwidth( $str, $encoding ); |
|
1197 | +function geodir_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
1198 | + if (function_exists('mb_strwidth')) { |
|
1199 | + return mb_strwidth($str, $encoding); |
|
1200 | 1200 | } |
1201 | 1201 | |
1202 | - return geodir_utf8_strlen( $str, $encoding ); |
|
1202 | + return geodir_utf8_strlen($str, $encoding); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | /** |
@@ -1213,21 +1213,21 @@ discard block |
||
1213 | 1213 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
1214 | 1214 | * @return string The resulting string. |
1215 | 1215 | */ |
1216 | -function geodir_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
1217 | - if ( function_exists( 'mb_strlen' ) ) { |
|
1218 | - $first_letter = geodir_strtoupper( geodir_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
1216 | +function geodir_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
1217 | + if (function_exists('mb_strlen')) { |
|
1218 | + $first_letter = geodir_strtoupper(geodir_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
1219 | 1219 | $str_end = ""; |
1220 | 1220 | |
1221 | - if ( $lower_str_end ) { |
|
1222 | - $str_end = geodir_strtolower( geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
1221 | + if ($lower_str_end) { |
|
1222 | + $str_end = geodir_strtolower(geodir_utf8_substr($str, 1, geodir_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
1223 | 1223 | } else { |
1224 | - $str_end = geodir_utf8_substr( $str, 1, geodir_utf8_strlen( $str, $encoding ), $encoding ); |
|
1224 | + $str_end = geodir_utf8_substr($str, 1, geodir_utf8_strlen($str, $encoding), $encoding); |
|
1225 | 1225 | } |
1226 | 1226 | |
1227 | - return $first_letter . $str_end; |
|
1227 | + return $first_letter.$str_end; |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | - return ucfirst( $str ); |
|
1230 | + return ucfirst($str); |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | function geodir_total_listings_count($post_type = false) |
@@ -1237,13 +1237,13 @@ discard block |
||
1237 | 1237 | $count = 0; |
1238 | 1238 | |
1239 | 1239 | if ($post_type) { |
1240 | - $count = $count + $wpdb->get_var("select count(post_id) from " . $wpdb->prefix . "geodir_" . $post_type . "_detail"); |
|
1240 | + $count = $count + $wpdb->get_var("select count(post_id) from ".$wpdb->prefix."geodir_".$post_type."_detail"); |
|
1241 | 1241 | } else { |
1242 | 1242 | $all_postypes = geodir_get_posttypes(); |
1243 | 1243 | |
1244 | 1244 | if (!empty($all_postypes)) { |
1245 | 1245 | foreach ($all_postypes as $key) { |
1246 | - $count = $count + $wpdb->get_var("select count(post_id) from " . $wpdb->prefix . "geodir_" . $key . "_detail"); |
|
1246 | + $count = $count + $wpdb->get_var("select count(post_id) from ".$wpdb->prefix."geodir_".$key."_detail"); |
|
1247 | 1247 | } |
1248 | 1248 | } |
1249 | 1249 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | // If this file is called directly, abort. |
9 | 9 | if (!defined('WPINC')) { |
10 | - die; |
|
10 | + die; |
|
11 | 11 | } |
12 | 12 | require_once('geodirectory-functions/shortcode_functions.php'); |
13 | 13 | |
@@ -32,43 +32,43 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function geodir_sc_add_listing($atts) |
34 | 34 | { |
35 | - ob_start(); |
|
36 | - $defaults = array( |
|
37 | - 'pid' => '', |
|
38 | - 'listing_type' => 'gd_place', |
|
39 | - 'login_msg' => __('You must login to post.', 'geodirectory'), |
|
40 | - 'show_login' => false, |
|
41 | - ); |
|
42 | - $params = shortcode_atts($defaults, $atts); |
|
43 | - |
|
44 | - foreach ($params as $key => $value) { |
|
45 | - $_REQUEST[$key] = $value; |
|
46 | - } |
|
47 | - |
|
48 | - $user_id = get_current_user_id(); |
|
49 | - if (!$user_id) { |
|
50 | - echo $params['login_msg']; |
|
51 | - if ($params['show_login']) { |
|
52 | - echo "<br />"; |
|
53 | - $defaults = array( |
|
54 | - 'before_widget' => '', |
|
55 | - 'after_widget' => '', |
|
56 | - 'before_title' => '', |
|
57 | - 'after_title' => '', |
|
58 | - ); |
|
59 | - |
|
60 | - geodir_loginwidget_output($defaults, $defaults); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - } else { |
|
65 | - // Add listing page will be used if shortcode is detected in page content, no need to call it here |
|
66 | - } |
|
67 | - $output = ob_get_contents(); |
|
68 | - |
|
69 | - ob_end_clean(); |
|
70 | - |
|
71 | - return $output; |
|
35 | + ob_start(); |
|
36 | + $defaults = array( |
|
37 | + 'pid' => '', |
|
38 | + 'listing_type' => 'gd_place', |
|
39 | + 'login_msg' => __('You must login to post.', 'geodirectory'), |
|
40 | + 'show_login' => false, |
|
41 | + ); |
|
42 | + $params = shortcode_atts($defaults, $atts); |
|
43 | + |
|
44 | + foreach ($params as $key => $value) { |
|
45 | + $_REQUEST[$key] = $value; |
|
46 | + } |
|
47 | + |
|
48 | + $user_id = get_current_user_id(); |
|
49 | + if (!$user_id) { |
|
50 | + echo $params['login_msg']; |
|
51 | + if ($params['show_login']) { |
|
52 | + echo "<br />"; |
|
53 | + $defaults = array( |
|
54 | + 'before_widget' => '', |
|
55 | + 'after_widget' => '', |
|
56 | + 'before_title' => '', |
|
57 | + 'after_title' => '', |
|
58 | + ); |
|
59 | + |
|
60 | + geodir_loginwidget_output($defaults, $defaults); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + } else { |
|
65 | + // Add listing page will be used if shortcode is detected in page content, no need to call it here |
|
66 | + } |
|
67 | + $output = ob_get_contents(); |
|
68 | + |
|
69 | + ob_end_clean(); |
|
70 | + |
|
71 | + return $output; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -96,136 +96,136 @@ discard block |
||
96 | 96 | */ |
97 | 97 | function geodir_sc_home_map($atts) |
98 | 98 | { |
99 | - ob_start(); |
|
100 | - $defaults = array( |
|
101 | - 'width' => '960', |
|
102 | - 'height' => '425', |
|
103 | - 'maptype' => 'ROADMAP', |
|
104 | - 'zoom' => '13', |
|
105 | - 'autozoom' => '', |
|
106 | - 'child_collapse' => '0', |
|
107 | - 'scrollwheel' => '0', |
|
99 | + ob_start(); |
|
100 | + $defaults = array( |
|
101 | + 'width' => '960', |
|
102 | + 'height' => '425', |
|
103 | + 'maptype' => 'ROADMAP', |
|
104 | + 'zoom' => '13', |
|
105 | + 'autozoom' => '', |
|
106 | + 'child_collapse' => '0', |
|
107 | + 'scrollwheel' => '0', |
|
108 | 108 | 'marker_cluster' => false, |
109 | - 'latitude' => '', |
|
110 | - 'longitude' => '' |
|
111 | - ); |
|
112 | - |
|
113 | - $params = shortcode_atts($defaults, $atts); |
|
114 | - |
|
115 | - $params = gdsc_validate_map_args($params); |
|
116 | - |
|
117 | - $map_args = array( |
|
118 | - 'map_canvas_name' => 'gd_home_map', |
|
119 | - 'latitude' => $params['latitude'], |
|
120 | - 'longitude' => $params['longitude'], |
|
121 | - |
|
122 | - /** |
|
123 | - * Filter the widget width of the map on home/listings page. |
|
124 | - * |
|
125 | - * @since 1.0.0 |
|
126 | - * @param mixed(string|int|float) $params['width'] The map width. |
|
127 | - */ |
|
128 | - 'width' => apply_filters('widget_width', $params['width']), |
|
129 | - /** |
|
130 | - * Filter the widget height of the map on home/listings page. |
|
131 | - * |
|
132 | - * @since 1.0.0 |
|
133 | - * @param mixed(string|int|float) $params['height'] The map height. |
|
134 | - */ |
|
135 | - 'height' => apply_filters('widget_heigh', $params['height']), |
|
136 | - /** |
|
137 | - * Filter the widget maptype of the map on home/listings page. |
|
138 | - * |
|
139 | - * @since 1.0.0 |
|
109 | + 'latitude' => '', |
|
110 | + 'longitude' => '' |
|
111 | + ); |
|
112 | + |
|
113 | + $params = shortcode_atts($defaults, $atts); |
|
114 | + |
|
115 | + $params = gdsc_validate_map_args($params); |
|
116 | + |
|
117 | + $map_args = array( |
|
118 | + 'map_canvas_name' => 'gd_home_map', |
|
119 | + 'latitude' => $params['latitude'], |
|
120 | + 'longitude' => $params['longitude'], |
|
121 | + |
|
122 | + /** |
|
123 | + * Filter the widget width of the map on home/listings page. |
|
124 | + * |
|
125 | + * @since 1.0.0 |
|
126 | + * @param mixed(string|int|float) $params['width'] The map width. |
|
127 | + */ |
|
128 | + 'width' => apply_filters('widget_width', $params['width']), |
|
129 | + /** |
|
130 | + * Filter the widget height of the map on home/listings page. |
|
131 | + * |
|
132 | + * @since 1.0.0 |
|
133 | + * @param mixed(string|int|float) $params['height'] The map height. |
|
134 | + */ |
|
135 | + 'height' => apply_filters('widget_heigh', $params['height']), |
|
136 | + /** |
|
137 | + * Filter the widget maptype of the map on home/listings page. |
|
138 | + * |
|
139 | + * @since 1.0.0 |
|
140 | 140 | * @since 1.5.2 Added TERRAIN map type. |
141 | - * @param string $params['maptype'] The map type. Can be ROADMAP | SATELLITE | HYBRID | TERRAIN. |
|
142 | - */ |
|
143 | - 'maptype' => apply_filters('widget_maptype', $params['maptype']), |
|
144 | - /** |
|
145 | - * Filter the widget scrollwheel value of the map on home/listings page. |
|
146 | - * |
|
147 | - * Should the scrollwheel zoom the map or not. |
|
148 | - * |
|
149 | - * @since 1.0.0 |
|
150 | - * @param bool $params['scrollwheel'] True to allow scroll wheel to scroll map or false if not. |
|
151 | - */ |
|
152 | - 'scrollwheel' => apply_filters('widget_scrollwheel', $params['scrollwheel']), |
|
153 | - /** |
|
154 | - * Filter the widget zoom level of the map on home/listings page. |
|
155 | - * |
|
156 | - * @since 1.0.0 |
|
157 | - * @param int $params['zoom'] The zoom level of the map. Between 1-19. |
|
158 | - */ |
|
159 | - 'zoom' => apply_filters('widget_zoom', $params['zoom']), |
|
160 | - /** |
|
161 | - * Filter the widget auto zoom value of the map on home/listings page. |
|
162 | - * |
|
163 | - * If the map should autozoom to fit the markers shown. |
|
164 | - * |
|
165 | - * @since 1.0.0 |
|
166 | - * @param bool $params['autozoom'] True if the map should autozoom, false if not. |
|
167 | - */ |
|
168 | - 'autozoom' => apply_filters('widget_autozoom', $params['autozoom']), |
|
169 | - /** |
|
170 | - * Filter the widget child_collapse value of the map on home/listings page. |
|
171 | - * |
|
172 | - * If the map should auto collapse the child categories if the category bar is present. |
|
173 | - * |
|
174 | - * @since 1.0.0 |
|
175 | - * @param bool $params['child_collapse'] True if the map should collapse the categories, false if not. |
|
176 | - */ |
|
177 | - 'child_collapse' => apply_filters('widget_child_collapse', $params['child_collapse']), |
|
178 | - 'enable_cat_filters' => true, |
|
179 | - 'enable_text_search' => true, |
|
180 | - 'enable_post_type_filters' => true, |
|
181 | - /** |
|
182 | - * Filter the widget enable_location_filters value of the map on home/listings page. |
|
183 | - * |
|
184 | - * This is used when the location addon is used. |
|
185 | - * |
|
186 | - * @since 1.0.0 |
|
187 | - * @param bool $val True if location filters should be used, false if not. |
|
188 | - */ |
|
189 | - 'enable_location_filters' => apply_filters('geodir_home_map_enable_location_filters', false), |
|
190 | - 'enable_jason_on_load' => false, |
|
191 | - 'enable_marker_cluster' => false, |
|
192 | - 'enable_map_resize_button' => true, |
|
193 | - 'map_class_name' => 'geodir-map-home-page', |
|
194 | - 'is_geodir_home_map_widget' => true, |
|
195 | - ); |
|
141 | + * @param string $params['maptype'] The map type. Can be ROADMAP | SATELLITE | HYBRID | TERRAIN. |
|
142 | + */ |
|
143 | + 'maptype' => apply_filters('widget_maptype', $params['maptype']), |
|
144 | + /** |
|
145 | + * Filter the widget scrollwheel value of the map on home/listings page. |
|
146 | + * |
|
147 | + * Should the scrollwheel zoom the map or not. |
|
148 | + * |
|
149 | + * @since 1.0.0 |
|
150 | + * @param bool $params['scrollwheel'] True to allow scroll wheel to scroll map or false if not. |
|
151 | + */ |
|
152 | + 'scrollwheel' => apply_filters('widget_scrollwheel', $params['scrollwheel']), |
|
153 | + /** |
|
154 | + * Filter the widget zoom level of the map on home/listings page. |
|
155 | + * |
|
156 | + * @since 1.0.0 |
|
157 | + * @param int $params['zoom'] The zoom level of the map. Between 1-19. |
|
158 | + */ |
|
159 | + 'zoom' => apply_filters('widget_zoom', $params['zoom']), |
|
160 | + /** |
|
161 | + * Filter the widget auto zoom value of the map on home/listings page. |
|
162 | + * |
|
163 | + * If the map should autozoom to fit the markers shown. |
|
164 | + * |
|
165 | + * @since 1.0.0 |
|
166 | + * @param bool $params['autozoom'] True if the map should autozoom, false if not. |
|
167 | + */ |
|
168 | + 'autozoom' => apply_filters('widget_autozoom', $params['autozoom']), |
|
169 | + /** |
|
170 | + * Filter the widget child_collapse value of the map on home/listings page. |
|
171 | + * |
|
172 | + * If the map should auto collapse the child categories if the category bar is present. |
|
173 | + * |
|
174 | + * @since 1.0.0 |
|
175 | + * @param bool $params['child_collapse'] True if the map should collapse the categories, false if not. |
|
176 | + */ |
|
177 | + 'child_collapse' => apply_filters('widget_child_collapse', $params['child_collapse']), |
|
178 | + 'enable_cat_filters' => true, |
|
179 | + 'enable_text_search' => true, |
|
180 | + 'enable_post_type_filters' => true, |
|
181 | + /** |
|
182 | + * Filter the widget enable_location_filters value of the map on home/listings page. |
|
183 | + * |
|
184 | + * This is used when the location addon is used. |
|
185 | + * |
|
186 | + * @since 1.0.0 |
|
187 | + * @param bool $val True if location filters should be used, false if not. |
|
188 | + */ |
|
189 | + 'enable_location_filters' => apply_filters('geodir_home_map_enable_location_filters', false), |
|
190 | + 'enable_jason_on_load' => false, |
|
191 | + 'enable_marker_cluster' => false, |
|
192 | + 'enable_map_resize_button' => true, |
|
193 | + 'map_class_name' => 'geodir-map-home-page', |
|
194 | + 'is_geodir_home_map_widget' => true, |
|
195 | + ); |
|
196 | 196 | |
197 | 197 | // Add marker cluster |
198 | 198 | if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
199 | - $map_args['enable_marker_cluster'] = true; |
|
200 | - if(get_option('geodir_marker_cluster_type')) { |
|
201 | - if ($map_args['autozoom']) { |
|
202 | - $map_args['enable_marker_cluster_no_reposition'] = false; |
|
203 | - } else { |
|
204 | - $map_args['enable_marker_cluster_no_reposition'] = true; |
|
205 | - } |
|
199 | + $map_args['enable_marker_cluster'] = true; |
|
200 | + if(get_option('geodir_marker_cluster_type')) { |
|
201 | + if ($map_args['autozoom']) { |
|
202 | + $map_args['enable_marker_cluster_no_reposition'] = false; |
|
203 | + } else { |
|
204 | + $map_args['enable_marker_cluster_no_reposition'] = true; |
|
205 | + } |
|
206 | 206 | |
207 | - $map_args['enable_marker_cluster_server'] = true ; |
|
207 | + $map_args['enable_marker_cluster_server'] = true ; |
|
208 | 208 | |
209 | - } |
|
209 | + } |
|
210 | 210 | } else { |
211 | 211 | $map_args['enable_marker_cluster'] = false; |
212 | 212 | } |
213 | 213 | |
214 | - // if lat and long set in shortcode, hack it so the map is not repositioned |
|
215 | - if(!empty($params['latitude']) && !empty($params['longitude']) ){ |
|
216 | - $map_args['enable_marker_cluster_no_reposition'] = true; |
|
217 | - } |
|
214 | + // if lat and long set in shortcode, hack it so the map is not repositioned |
|
215 | + if(!empty($params['latitude']) && !empty($params['longitude']) ){ |
|
216 | + $map_args['enable_marker_cluster_no_reposition'] = true; |
|
217 | + } |
|
218 | 218 | |
219 | 219 | |
220 | - geodir_draw_map($map_args); |
|
220 | + geodir_draw_map($map_args); |
|
221 | 221 | |
222 | - add_action('wp_footer', 'geodir_home_map_add_script', 100); |
|
222 | + add_action('wp_footer', 'geodir_home_map_add_script', 100); |
|
223 | 223 | |
224 | - $output = ob_get_contents(); |
|
224 | + $output = ob_get_contents(); |
|
225 | 225 | |
226 | - ob_end_clean(); |
|
226 | + ob_end_clean(); |
|
227 | 227 | |
228 | - return $output; |
|
228 | + return $output; |
|
229 | 229 | } |
230 | 230 | add_shortcode('gd_homepage_map', 'geodir_sc_home_map'); |
231 | 231 | |
@@ -264,218 +264,218 @@ discard block |
||
264 | 264 | */ |
265 | 265 | function geodir_sc_listing_map($atts) { |
266 | 266 | |
267 | - // if some params are set then we need a new query, if not then we can use the main query |
|
268 | - if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) { |
|
269 | - |
|
270 | - global $add_post_in_marker_array, $gd_sc_map_params; |
|
271 | - $backup_globals = array(); |
|
272 | - $backup_globals['add_post_in_marker_array'] = $add_post_in_marker_array; |
|
273 | - $backup_globals['gd_sc_map_params'] = $gd_sc_map_params; |
|
274 | - |
|
275 | - $defaults = array( |
|
276 | - 'width' => '294', |
|
277 | - 'height' => '370', |
|
278 | - 'zoom' => '13', |
|
279 | - 'autozoom' => '', |
|
280 | - 'sticky' => '', |
|
281 | - 'showall' => '0', |
|
282 | - 'scrollwheel' => '0', |
|
283 | - 'maptype' => 'ROADMAP', |
|
284 | - 'child_collapse' => 0, |
|
285 | - 'marker_cluster' => false, |
|
286 | - 'post_type' => 'gd_place', |
|
287 | - 'category' => '0', |
|
288 | - 'event_type' => 'all' |
|
289 | - ); |
|
290 | - |
|
291 | - $params = shortcode_atts( $defaults, $atts ); |
|
292 | - |
|
293 | - if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) { |
|
294 | - $params['post_type'] = 'gd_place'; |
|
295 | - } |
|
296 | - |
|
297 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
298 | - $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
299 | - $categories = get_terms( $category_taxonomy, array( |
|
300 | - 'orderby' => 'count', |
|
301 | - 'order' => 'DESC', |
|
302 | - 'fields' => 'ids' |
|
303 | - ) ); |
|
304 | - |
|
305 | - // Make sure we have an array |
|
306 | - if ( ! ( is_array( $params['category'] ) ) ) { |
|
307 | - $params['category'] = explode( ',', $params['category'] ); |
|
308 | - } |
|
309 | - |
|
310 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
311 | - // Otherwise it becomes empty and later on that will mean "All" |
|
312 | - $params['category'] = array_intersect( $params['category'], $categories ); |
|
313 | - |
|
314 | - if ( $params['post_type'] == 'gd_event' ) { |
|
315 | - $params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] ); |
|
316 | - } |
|
317 | - |
|
318 | - $params = gdsc_validate_map_args( $params ); |
|
319 | - |
|
320 | - $gd_sc_map_params = $params; |
|
321 | - |
|
322 | - $query_args = array( |
|
323 | - 'posts_per_page' => 1000000, //@todo kiran why was this added? |
|
324 | - 'is_geodir_loop' => true, |
|
325 | - 'gd_location' => false, |
|
326 | - 'post_type' => $params['post_type'], |
|
327 | - ); |
|
328 | - |
|
329 | - if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) { |
|
330 | - $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
331 | - |
|
332 | - ######### WPML ######### |
|
333 | - if ( geodir_wpml_is_taxonomy_translated( $category_taxonomy[0] ) ) { |
|
334 | - $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
335 | - } |
|
336 | - ######### WPML ######### |
|
337 | - |
|
338 | - $tax_query = array( |
|
339 | - 'taxonomy' => $category_taxonomy[0], |
|
340 | - 'field' => 'id', |
|
341 | - 'terms' => $params['category'] |
|
342 | - ); |
|
343 | - |
|
344 | - $query_args['tax_query'] = array( $tax_query ); |
|
345 | - } |
|
346 | - |
|
347 | - $add_post_in_marker_array = true; |
|
348 | - |
|
349 | - if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) { |
|
350 | - global $geodir_event_widget_listview; |
|
351 | - $geodir_event_widget_listview = true; |
|
352 | - |
|
353 | - $query_args['geodir_event_type'] = $params['event_type']; |
|
354 | - |
|
355 | - $listings = geodir_event_get_widget_events( $query_args ); |
|
356 | - |
|
357 | - $geodir_event_widget_listview = false; |
|
358 | - } else { |
|
359 | - $listings = geodir_get_widget_listings( $query_args ); |
|
360 | - } |
|
361 | - |
|
362 | - if ( ! empty( $listings ) ) { |
|
363 | - foreach ( $listings as $listing ) { |
|
364 | - create_marker_jason_of_posts( $listing ); |
|
365 | - } |
|
366 | - } |
|
367 | - |
|
368 | - ob_start(); |
|
369 | - add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array |
|
370 | - |
|
371 | - add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array |
|
372 | - |
|
373 | - add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers |
|
374 | - |
|
375 | - $default_location = geodir_get_default_location(); |
|
376 | - |
|
377 | - $map_args = array( |
|
378 | - 'map_canvas_name' => 'gd_listing_map', |
|
379 | - 'width' => $params['width'], |
|
380 | - 'height' => $params['height'], |
|
381 | - 'zoom' => $params['zoom'], |
|
382 | - 'autozoom' => $params['autozoom'], |
|
383 | - 'sticky' => $params['sticky'], |
|
384 | - 'showall' => $params['showall'], |
|
385 | - 'scrollwheel' => $params['scrollwheel'], |
|
386 | - 'maptype' => $params['maptype'], |
|
387 | - 'child_collapse' => 0, |
|
388 | - 'enable_cat_filters' => false, |
|
389 | - 'enable_text_search' => false, |
|
390 | - 'enable_post_type_filters' => false, |
|
391 | - 'enable_location_filters' => false, |
|
392 | - 'enable_jason_on_load' => true, |
|
393 | - 'ajax_url' => geodir_get_ajax_url(), |
|
394 | - 'latitude' => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '', |
|
395 | - 'longitude' => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '', |
|
396 | - 'streetViewControl' => true, |
|
397 | - 'showPreview' => '0', |
|
398 | - 'maxZoom' => 21, |
|
399 | - 'bubble_size' => 'small', |
|
400 | - ); |
|
401 | - |
|
402 | - if ( is_single() ) { |
|
403 | - global $post; |
|
404 | - if ( isset( $post->post_latitude ) ) { |
|
405 | - $map_args['latitude'] = $post->post_latitude; |
|
406 | - $map_args['longitude'] = $post->post_longitude; |
|
407 | - } |
|
408 | - |
|
409 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
410 | - } else { |
|
411 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
412 | - } |
|
413 | - |
|
414 | - // Add marker cluster |
|
415 | - if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) { |
|
416 | - $map_args['enable_marker_cluster'] = true; |
|
417 | - } else { |
|
418 | - $map_args['enable_marker_cluster'] = false; |
|
419 | - } |
|
420 | - |
|
421 | - geodir_draw_map( $map_args ); |
|
422 | - |
|
423 | - $output = ob_get_contents(); |
|
424 | - |
|
425 | - ob_end_clean(); |
|
426 | - |
|
427 | - foreach ( $backup_globals as $global => $value ) { |
|
428 | - ${$global} = $value; |
|
429 | - } |
|
430 | - |
|
431 | - return $output; |
|
432 | - }else{ |
|
433 | - ob_start(); |
|
434 | - add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
435 | - add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
436 | - add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
437 | - $defaults = array( |
|
438 | - 'width' => '294', |
|
439 | - 'height' => '370', |
|
440 | - 'zoom' => '13', |
|
441 | - 'autozoom' => '', |
|
442 | - 'sticky' => '', |
|
443 | - 'showall' => '0', |
|
444 | - 'scrollwheel' => '0', |
|
445 | - 'maptype' => 'ROADMAP', |
|
446 | - 'child_collapse' => 0, |
|
447 | - 'marker_cluster' => false |
|
448 | - ); |
|
449 | - $params = shortcode_atts($defaults, $atts); |
|
450 | - $params = gdsc_validate_map_args($params); |
|
451 | - $map_args = array( |
|
452 | - 'map_canvas_name' => 'gd_listing_map', |
|
453 | - 'width' => $params['width'], |
|
454 | - 'height' => $params['height'], |
|
455 | - 'zoom' => $params['zoom'], |
|
456 | - 'autozoom' => $params['autozoom'], |
|
457 | - 'sticky' => $params['sticky'], |
|
458 | - 'showall' => $params['showall'], |
|
459 | - 'scrollwheel' => $params['scrollwheel'], |
|
460 | - 'child_collapse' => 0, |
|
461 | - 'enable_cat_filters' => false, |
|
462 | - 'enable_text_search' => false, |
|
463 | - 'enable_post_type_filters' => false, |
|
464 | - 'enable_location_filters' => false, |
|
465 | - 'enable_jason_on_load' => true, |
|
466 | - ); |
|
467 | - if (is_single()) { |
|
468 | - global $post; |
|
469 | - $map_default_lat = $address_latitude = $post->post_latitude; |
|
470 | - $map_default_lng = $address_longitude = $post->post_longitude; |
|
471 | - $mapview = $post->post_mapview; |
|
472 | - $map_args['zoom'] = $post->post_mapzoom; |
|
473 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
474 | - } else { |
|
475 | - $default_location = geodir_get_default_location(); |
|
476 | - $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
477 | - $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
478 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
267 | + // if some params are set then we need a new query, if not then we can use the main query |
|
268 | + if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) { |
|
269 | + |
|
270 | + global $add_post_in_marker_array, $gd_sc_map_params; |
|
271 | + $backup_globals = array(); |
|
272 | + $backup_globals['add_post_in_marker_array'] = $add_post_in_marker_array; |
|
273 | + $backup_globals['gd_sc_map_params'] = $gd_sc_map_params; |
|
274 | + |
|
275 | + $defaults = array( |
|
276 | + 'width' => '294', |
|
277 | + 'height' => '370', |
|
278 | + 'zoom' => '13', |
|
279 | + 'autozoom' => '', |
|
280 | + 'sticky' => '', |
|
281 | + 'showall' => '0', |
|
282 | + 'scrollwheel' => '0', |
|
283 | + 'maptype' => 'ROADMAP', |
|
284 | + 'child_collapse' => 0, |
|
285 | + 'marker_cluster' => false, |
|
286 | + 'post_type' => 'gd_place', |
|
287 | + 'category' => '0', |
|
288 | + 'event_type' => 'all' |
|
289 | + ); |
|
290 | + |
|
291 | + $params = shortcode_atts( $defaults, $atts ); |
|
292 | + |
|
293 | + if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) { |
|
294 | + $params['post_type'] = 'gd_place'; |
|
295 | + } |
|
296 | + |
|
297 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
298 | + $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
299 | + $categories = get_terms( $category_taxonomy, array( |
|
300 | + 'orderby' => 'count', |
|
301 | + 'order' => 'DESC', |
|
302 | + 'fields' => 'ids' |
|
303 | + ) ); |
|
304 | + |
|
305 | + // Make sure we have an array |
|
306 | + if ( ! ( is_array( $params['category'] ) ) ) { |
|
307 | + $params['category'] = explode( ',', $params['category'] ); |
|
308 | + } |
|
309 | + |
|
310 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
311 | + // Otherwise it becomes empty and later on that will mean "All" |
|
312 | + $params['category'] = array_intersect( $params['category'], $categories ); |
|
313 | + |
|
314 | + if ( $params['post_type'] == 'gd_event' ) { |
|
315 | + $params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] ); |
|
316 | + } |
|
317 | + |
|
318 | + $params = gdsc_validate_map_args( $params ); |
|
319 | + |
|
320 | + $gd_sc_map_params = $params; |
|
321 | + |
|
322 | + $query_args = array( |
|
323 | + 'posts_per_page' => 1000000, //@todo kiran why was this added? |
|
324 | + 'is_geodir_loop' => true, |
|
325 | + 'gd_location' => false, |
|
326 | + 'post_type' => $params['post_type'], |
|
327 | + ); |
|
328 | + |
|
329 | + if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) { |
|
330 | + $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
331 | + |
|
332 | + ######### WPML ######### |
|
333 | + if ( geodir_wpml_is_taxonomy_translated( $category_taxonomy[0] ) ) { |
|
334 | + $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
335 | + } |
|
336 | + ######### WPML ######### |
|
337 | + |
|
338 | + $tax_query = array( |
|
339 | + 'taxonomy' => $category_taxonomy[0], |
|
340 | + 'field' => 'id', |
|
341 | + 'terms' => $params['category'] |
|
342 | + ); |
|
343 | + |
|
344 | + $query_args['tax_query'] = array( $tax_query ); |
|
345 | + } |
|
346 | + |
|
347 | + $add_post_in_marker_array = true; |
|
348 | + |
|
349 | + if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) { |
|
350 | + global $geodir_event_widget_listview; |
|
351 | + $geodir_event_widget_listview = true; |
|
352 | + |
|
353 | + $query_args['geodir_event_type'] = $params['event_type']; |
|
354 | + |
|
355 | + $listings = geodir_event_get_widget_events( $query_args ); |
|
356 | + |
|
357 | + $geodir_event_widget_listview = false; |
|
358 | + } else { |
|
359 | + $listings = geodir_get_widget_listings( $query_args ); |
|
360 | + } |
|
361 | + |
|
362 | + if ( ! empty( $listings ) ) { |
|
363 | + foreach ( $listings as $listing ) { |
|
364 | + create_marker_jason_of_posts( $listing ); |
|
365 | + } |
|
366 | + } |
|
367 | + |
|
368 | + ob_start(); |
|
369 | + add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array |
|
370 | + |
|
371 | + add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array |
|
372 | + |
|
373 | + add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers |
|
374 | + |
|
375 | + $default_location = geodir_get_default_location(); |
|
376 | + |
|
377 | + $map_args = array( |
|
378 | + 'map_canvas_name' => 'gd_listing_map', |
|
379 | + 'width' => $params['width'], |
|
380 | + 'height' => $params['height'], |
|
381 | + 'zoom' => $params['zoom'], |
|
382 | + 'autozoom' => $params['autozoom'], |
|
383 | + 'sticky' => $params['sticky'], |
|
384 | + 'showall' => $params['showall'], |
|
385 | + 'scrollwheel' => $params['scrollwheel'], |
|
386 | + 'maptype' => $params['maptype'], |
|
387 | + 'child_collapse' => 0, |
|
388 | + 'enable_cat_filters' => false, |
|
389 | + 'enable_text_search' => false, |
|
390 | + 'enable_post_type_filters' => false, |
|
391 | + 'enable_location_filters' => false, |
|
392 | + 'enable_jason_on_load' => true, |
|
393 | + 'ajax_url' => geodir_get_ajax_url(), |
|
394 | + 'latitude' => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '', |
|
395 | + 'longitude' => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '', |
|
396 | + 'streetViewControl' => true, |
|
397 | + 'showPreview' => '0', |
|
398 | + 'maxZoom' => 21, |
|
399 | + 'bubble_size' => 'small', |
|
400 | + ); |
|
401 | + |
|
402 | + if ( is_single() ) { |
|
403 | + global $post; |
|
404 | + if ( isset( $post->post_latitude ) ) { |
|
405 | + $map_args['latitude'] = $post->post_latitude; |
|
406 | + $map_args['longitude'] = $post->post_longitude; |
|
407 | + } |
|
408 | + |
|
409 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
410 | + } else { |
|
411 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
412 | + } |
|
413 | + |
|
414 | + // Add marker cluster |
|
415 | + if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) { |
|
416 | + $map_args['enable_marker_cluster'] = true; |
|
417 | + } else { |
|
418 | + $map_args['enable_marker_cluster'] = false; |
|
419 | + } |
|
420 | + |
|
421 | + geodir_draw_map( $map_args ); |
|
422 | + |
|
423 | + $output = ob_get_contents(); |
|
424 | + |
|
425 | + ob_end_clean(); |
|
426 | + |
|
427 | + foreach ( $backup_globals as $global => $value ) { |
|
428 | + ${$global} = $value; |
|
429 | + } |
|
430 | + |
|
431 | + return $output; |
|
432 | + }else{ |
|
433 | + ob_start(); |
|
434 | + add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
435 | + add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
436 | + add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
437 | + $defaults = array( |
|
438 | + 'width' => '294', |
|
439 | + 'height' => '370', |
|
440 | + 'zoom' => '13', |
|
441 | + 'autozoom' => '', |
|
442 | + 'sticky' => '', |
|
443 | + 'showall' => '0', |
|
444 | + 'scrollwheel' => '0', |
|
445 | + 'maptype' => 'ROADMAP', |
|
446 | + 'child_collapse' => 0, |
|
447 | + 'marker_cluster' => false |
|
448 | + ); |
|
449 | + $params = shortcode_atts($defaults, $atts); |
|
450 | + $params = gdsc_validate_map_args($params); |
|
451 | + $map_args = array( |
|
452 | + 'map_canvas_name' => 'gd_listing_map', |
|
453 | + 'width' => $params['width'], |
|
454 | + 'height' => $params['height'], |
|
455 | + 'zoom' => $params['zoom'], |
|
456 | + 'autozoom' => $params['autozoom'], |
|
457 | + 'sticky' => $params['sticky'], |
|
458 | + 'showall' => $params['showall'], |
|
459 | + 'scrollwheel' => $params['scrollwheel'], |
|
460 | + 'child_collapse' => 0, |
|
461 | + 'enable_cat_filters' => false, |
|
462 | + 'enable_text_search' => false, |
|
463 | + 'enable_post_type_filters' => false, |
|
464 | + 'enable_location_filters' => false, |
|
465 | + 'enable_jason_on_load' => true, |
|
466 | + ); |
|
467 | + if (is_single()) { |
|
468 | + global $post; |
|
469 | + $map_default_lat = $address_latitude = $post->post_latitude; |
|
470 | + $map_default_lng = $address_longitude = $post->post_longitude; |
|
471 | + $mapview = $post->post_mapview; |
|
472 | + $map_args['zoom'] = $post->post_mapzoom; |
|
473 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
474 | + } else { |
|
475 | + $default_location = geodir_get_default_location(); |
|
476 | + $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
477 | + $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
478 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
479 | 479 | if ( geodir_is_page( 'search' ) ) { |
480 | 480 | $map_default_lat = ''; |
481 | 481 | $map_default_lng = ''; |
@@ -491,31 +491,31 @@ discard block |
||
491 | 491 | } |
492 | 492 | } |
493 | 493 | } |
494 | - } |
|
495 | - if (empty($mapview)) { |
|
496 | - $mapview = 'ROADMAP'; |
|
497 | - } |
|
498 | - // Set default map options |
|
499 | - $map_args['ajax_url'] = geodir_get_ajax_url(); |
|
500 | - $map_args['latitude'] = $map_default_lat; |
|
501 | - $map_args['longitude'] = $map_default_lng; |
|
502 | - $map_args['streetViewControl'] = true; |
|
503 | - $map_args['maptype'] = $mapview; |
|
504 | - $map_args['showPreview'] = '0'; |
|
505 | - $map_args['maxZoom'] = 21; |
|
506 | - $map_args['bubble_size'] = 'small'; |
|
507 | - |
|
508 | - // Add marker cluster |
|
509 | - if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
|
510 | - $map_args['enable_marker_cluster'] = true; |
|
511 | - } else { |
|
512 | - $map_args['enable_marker_cluster'] = false; |
|
513 | - } |
|
514 | - geodir_draw_map($map_args); |
|
515 | - $output = ob_get_contents(); |
|
516 | - ob_end_clean(); |
|
517 | - return $output; |
|
518 | - } |
|
494 | + } |
|
495 | + if (empty($mapview)) { |
|
496 | + $mapview = 'ROADMAP'; |
|
497 | + } |
|
498 | + // Set default map options |
|
499 | + $map_args['ajax_url'] = geodir_get_ajax_url(); |
|
500 | + $map_args['latitude'] = $map_default_lat; |
|
501 | + $map_args['longitude'] = $map_default_lng; |
|
502 | + $map_args['streetViewControl'] = true; |
|
503 | + $map_args['maptype'] = $mapview; |
|
504 | + $map_args['showPreview'] = '0'; |
|
505 | + $map_args['maxZoom'] = 21; |
|
506 | + $map_args['bubble_size'] = 'small'; |
|
507 | + |
|
508 | + // Add marker cluster |
|
509 | + if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
|
510 | + $map_args['enable_marker_cluster'] = true; |
|
511 | + } else { |
|
512 | + $map_args['enable_marker_cluster'] = false; |
|
513 | + } |
|
514 | + geodir_draw_map($map_args); |
|
515 | + $output = ob_get_contents(); |
|
516 | + ob_end_clean(); |
|
517 | + return $output; |
|
518 | + } |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | add_shortcode('gd_listing_slider', 'geodir_sc_listing_slider'); |
@@ -548,120 +548,120 @@ discard block |
||
548 | 548 | */ |
549 | 549 | function geodir_sc_listing_slider($atts) |
550 | 550 | { |
551 | - ob_start(); |
|
552 | - $defaults = array( |
|
553 | - 'post_type' => 'gd_place', |
|
554 | - 'category' => '0', |
|
555 | - 'post_number' => '5', |
|
556 | - 'slideshow' => '0', |
|
557 | - 'animation_loop' => 0, |
|
558 | - 'direction_nav' => 0, |
|
559 | - 'slideshow_speed' => 5000, |
|
560 | - 'animation_speed' => 600, |
|
561 | - 'animation' => 'slide', |
|
562 | - 'order_by' => 'latest', |
|
563 | - 'show_title' => '', |
|
564 | - 'show_featured_only' => '', |
|
565 | - 'title' => '', |
|
566 | - ); |
|
567 | - |
|
568 | - $params = shortcode_atts($defaults, $atts); |
|
569 | - |
|
570 | - |
|
571 | - /* |
|
551 | + ob_start(); |
|
552 | + $defaults = array( |
|
553 | + 'post_type' => 'gd_place', |
|
554 | + 'category' => '0', |
|
555 | + 'post_number' => '5', |
|
556 | + 'slideshow' => '0', |
|
557 | + 'animation_loop' => 0, |
|
558 | + 'direction_nav' => 0, |
|
559 | + 'slideshow_speed' => 5000, |
|
560 | + 'animation_speed' => 600, |
|
561 | + 'animation' => 'slide', |
|
562 | + 'order_by' => 'latest', |
|
563 | + 'show_title' => '', |
|
564 | + 'show_featured_only' => '', |
|
565 | + 'title' => '', |
|
566 | + ); |
|
567 | + |
|
568 | + $params = shortcode_atts($defaults, $atts); |
|
569 | + |
|
570 | + |
|
571 | + /* |
|
572 | 572 | * |
573 | 573 | * Now we begin the validation of the attributes. |
574 | 574 | */ |
575 | - // Check we have a valid post_type |
|
576 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
577 | - $params['post_type'] = 'gd_place'; |
|
578 | - } |
|
579 | - |
|
580 | - // Check we have a valid sort_order |
|
581 | - $params['order_by'] = gdsc_validate_sort_choice($params['order_by']); |
|
582 | - |
|
583 | - // Match the chosen animation to our options |
|
584 | - $animation_list = array('slide', 'fade'); |
|
585 | - if (!(in_array($params['animation'], $animation_list))) { |
|
586 | - $params['animation'] = 'slide'; |
|
587 | - } |
|
588 | - |
|
589 | - // Post_number needs to be a positive integer |
|
590 | - $params['post_number'] = absint($params['post_number']); |
|
591 | - if (0 == $params['post_number']) { |
|
592 | - $params['post_number'] = 1; |
|
593 | - } |
|
594 | - |
|
595 | - // Manage the entered categories |
|
596 | - if (0 != $params['category'] || '' != $params['category']) { |
|
597 | - $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']); |
|
598 | - } |
|
599 | - // Convert show_title to a bool |
|
600 | - $params['show_title'] = intval(gdsc_to_bool_val($params['show_title'])); |
|
601 | - |
|
602 | - // Convert show_featured_only to a bool |
|
603 | - $params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only'])); |
|
604 | - |
|
605 | - /* |
|
575 | + // Check we have a valid post_type |
|
576 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
577 | + $params['post_type'] = 'gd_place'; |
|
578 | + } |
|
579 | + |
|
580 | + // Check we have a valid sort_order |
|
581 | + $params['order_by'] = gdsc_validate_sort_choice($params['order_by']); |
|
582 | + |
|
583 | + // Match the chosen animation to our options |
|
584 | + $animation_list = array('slide', 'fade'); |
|
585 | + if (!(in_array($params['animation'], $animation_list))) { |
|
586 | + $params['animation'] = 'slide'; |
|
587 | + } |
|
588 | + |
|
589 | + // Post_number needs to be a positive integer |
|
590 | + $params['post_number'] = absint($params['post_number']); |
|
591 | + if (0 == $params['post_number']) { |
|
592 | + $params['post_number'] = 1; |
|
593 | + } |
|
594 | + |
|
595 | + // Manage the entered categories |
|
596 | + if (0 != $params['category'] || '' != $params['category']) { |
|
597 | + $params['category'] = gdsc_manage_category_choice($params['post_type'], $params['category']); |
|
598 | + } |
|
599 | + // Convert show_title to a bool |
|
600 | + $params['show_title'] = intval(gdsc_to_bool_val($params['show_title'])); |
|
601 | + |
|
602 | + // Convert show_featured_only to a bool |
|
603 | + $params['show_featured_only'] = intval(gdsc_to_bool_val($params['show_featured_only'])); |
|
604 | + |
|
605 | + /* |
|
606 | 606 | * Hopefully all attributes are now valid, and safe to pass forward |
607 | 607 | */ |
608 | 608 | |
609 | - // redeclare vars after validation |
|
610 | - |
|
611 | - if (isset($params['direction_nav'])) { |
|
612 | - $params['directionNav'] = $params['direction_nav']; |
|
613 | - } |
|
614 | - if (isset($params['animation_loop'])) { |
|
615 | - $params['animationLoop'] = $params['animation_loop']; |
|
616 | - } |
|
617 | - if (isset($params['slideshow_speed'])) { |
|
618 | - $params['slideshowSpeed'] = $params['slideshow_speed']; |
|
619 | - } |
|
620 | - if (isset($params['animation_speed'])) { |
|
621 | - $params['animationSpeed'] = $params['animation_speed']; |
|
622 | - } |
|
623 | - if (isset($params['order_by'])) { |
|
624 | - $params['list_sort'] = $params['order_by']; |
|
625 | - } |
|
626 | - |
|
627 | - $query_args = array( |
|
628 | - 'post_number' => $params['post_number'], |
|
629 | - 'is_geodir_loop' => true, |
|
630 | - 'post_type' => $params['post_type'], |
|
631 | - 'order_by' => $params['order_by'] |
|
632 | - ); |
|
633 | - |
|
634 | - if (1 == $params['show_featured_only']) { |
|
635 | - $query_args['show_featured_only'] = 1; |
|
636 | - } |
|
637 | - |
|
638 | - if (0 != $params['category'] && '' != $params['category']) { |
|
639 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
640 | - $tax_query = array( |
|
641 | - 'taxonomy' => $category_taxonomy[0], |
|
642 | - 'field' => 'id', |
|
643 | - 'terms' => $params['category'], |
|
644 | - ); |
|
645 | - |
|
646 | - $query_args['tax_query'] = array($tax_query); |
|
647 | - } |
|
648 | - |
|
649 | - $defaults = array( |
|
650 | - 'before_widget' => '', |
|
651 | - 'after_widget' => '', |
|
652 | - 'before_title' => '', |
|
653 | - 'after_title' => '', |
|
654 | - ); |
|
655 | - |
|
656 | - $query_args = array_merge($query_args, $params); |
|
657 | - |
|
658 | - geodir_listing_slider_widget_output($defaults, $query_args); |
|
659 | - |
|
660 | - $output = ob_get_contents(); |
|
661 | - |
|
662 | - ob_end_clean(); |
|
663 | - |
|
664 | - return $output; |
|
609 | + // redeclare vars after validation |
|
610 | + |
|
611 | + if (isset($params['direction_nav'])) { |
|
612 | + $params['directionNav'] = $params['direction_nav']; |
|
613 | + } |
|
614 | + if (isset($params['animation_loop'])) { |
|
615 | + $params['animationLoop'] = $params['animation_loop']; |
|
616 | + } |
|
617 | + if (isset($params['slideshow_speed'])) { |
|
618 | + $params['slideshowSpeed'] = $params['slideshow_speed']; |
|
619 | + } |
|
620 | + if (isset($params['animation_speed'])) { |
|
621 | + $params['animationSpeed'] = $params['animation_speed']; |
|
622 | + } |
|
623 | + if (isset($params['order_by'])) { |
|
624 | + $params['list_sort'] = $params['order_by']; |
|
625 | + } |
|
626 | + |
|
627 | + $query_args = array( |
|
628 | + 'post_number' => $params['post_number'], |
|
629 | + 'is_geodir_loop' => true, |
|
630 | + 'post_type' => $params['post_type'], |
|
631 | + 'order_by' => $params['order_by'] |
|
632 | + ); |
|
633 | + |
|
634 | + if (1 == $params['show_featured_only']) { |
|
635 | + $query_args['show_featured_only'] = 1; |
|
636 | + } |
|
637 | + |
|
638 | + if (0 != $params['category'] && '' != $params['category']) { |
|
639 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
640 | + $tax_query = array( |
|
641 | + 'taxonomy' => $category_taxonomy[0], |
|
642 | + 'field' => 'id', |
|
643 | + 'terms' => $params['category'], |
|
644 | + ); |
|
645 | + |
|
646 | + $query_args['tax_query'] = array($tax_query); |
|
647 | + } |
|
648 | + |
|
649 | + $defaults = array( |
|
650 | + 'before_widget' => '', |
|
651 | + 'after_widget' => '', |
|
652 | + 'before_title' => '', |
|
653 | + 'after_title' => '', |
|
654 | + ); |
|
655 | + |
|
656 | + $query_args = array_merge($query_args, $params); |
|
657 | + |
|
658 | + geodir_listing_slider_widget_output($defaults, $query_args); |
|
659 | + |
|
660 | + $output = ob_get_contents(); |
|
661 | + |
|
662 | + ob_end_clean(); |
|
663 | + |
|
664 | + return $output; |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | add_shortcode('gd_login_box', 'geodir_sc_login_box'); |
@@ -685,22 +685,22 @@ discard block |
||
685 | 685 | */ |
686 | 686 | function geodir_sc_login_box($atts) |
687 | 687 | { |
688 | - ob_start(); |
|
688 | + ob_start(); |
|
689 | 689 | |
690 | - $defaults = array( |
|
691 | - 'before_widget' => '', |
|
692 | - 'after_widget' => '', |
|
693 | - 'before_title' => '', |
|
694 | - 'after_title' => '', |
|
695 | - ); |
|
690 | + $defaults = array( |
|
691 | + 'before_widget' => '', |
|
692 | + 'after_widget' => '', |
|
693 | + 'before_title' => '', |
|
694 | + 'after_title' => '', |
|
695 | + ); |
|
696 | 696 | |
697 | - geodir_loginwidget_output($defaults, $defaults); |
|
697 | + geodir_loginwidget_output($defaults, $defaults); |
|
698 | 698 | |
699 | - $output = ob_get_contents(); |
|
699 | + $output = ob_get_contents(); |
|
700 | 700 | |
701 | - ob_end_clean(); |
|
701 | + ob_end_clean(); |
|
702 | 702 | |
703 | - return $output; |
|
703 | + return $output; |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | add_shortcode('gd_popular_post_category', 'geodir_sc_popular_post_category'); |
@@ -731,31 +731,31 @@ discard block |
||
731 | 731 | */ |
732 | 732 | function geodir_sc_popular_post_category($atts) |
733 | 733 | { |
734 | - ob_start(); |
|
735 | - global $geodir_post_category_str; |
|
736 | - $defaults = array( |
|
737 | - 'category_limit' => 15, |
|
738 | - 'category_restrict' => false, |
|
739 | - 'before_widget' => '', |
|
740 | - 'after_widget' => '', |
|
741 | - 'before_title' => '', |
|
742 | - 'after_title' => '', |
|
743 | - 'title' => '', |
|
744 | - 'default_post_type' => '', |
|
745 | - 'parent_only' => false, |
|
746 | - ); |
|
747 | - |
|
748 | - $params = shortcode_atts($defaults, $atts, 'popular_post_category'); |
|
749 | - $params['category_limit'] = absint($params['category_limit']); |
|
750 | - $params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : ''; |
|
751 | - $params['parent_only'] = gdsc_to_bool_val($params['parent_only']); |
|
752 | - geodir_popular_post_category_output($params, $params); |
|
753 | - |
|
754 | - $output = ob_get_contents(); |
|
755 | - |
|
756 | - ob_end_clean(); |
|
757 | - |
|
758 | - return $output; |
|
734 | + ob_start(); |
|
735 | + global $geodir_post_category_str; |
|
736 | + $defaults = array( |
|
737 | + 'category_limit' => 15, |
|
738 | + 'category_restrict' => false, |
|
739 | + 'before_widget' => '', |
|
740 | + 'after_widget' => '', |
|
741 | + 'before_title' => '', |
|
742 | + 'after_title' => '', |
|
743 | + 'title' => '', |
|
744 | + 'default_post_type' => '', |
|
745 | + 'parent_only' => false, |
|
746 | + ); |
|
747 | + |
|
748 | + $params = shortcode_atts($defaults, $atts, 'popular_post_category'); |
|
749 | + $params['category_limit'] = absint($params['category_limit']); |
|
750 | + $params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : ''; |
|
751 | + $params['parent_only'] = gdsc_to_bool_val($params['parent_only']); |
|
752 | + geodir_popular_post_category_output($params, $params); |
|
753 | + |
|
754 | + $output = ob_get_contents(); |
|
755 | + |
|
756 | + ob_end_clean(); |
|
757 | + |
|
758 | + return $output; |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | add_shortcode('gd_popular_post_view', 'geodir_sc_popular_post_view'); |
@@ -798,98 +798,98 @@ discard block |
||
798 | 798 | */ |
799 | 799 | function geodir_sc_popular_post_view($atts) |
800 | 800 | { |
801 | - ob_start(); |
|
802 | - $defaults = array( |
|
803 | - 'post_type' => 'gd_place', |
|
804 | - 'category' => '0', |
|
805 | - 'post_number' => '5', |
|
806 | - 'layout' => 'gridview_onehalf', |
|
807 | - 'add_location_filter' => '0', |
|
808 | - 'list_sort' => 'latest', |
|
809 | - 'use_viewing_post_type' => '1', |
|
810 | - 'character_count' => '20', |
|
811 | - 'listing_width' => '', |
|
812 | - 'show_featured_only' => '0', |
|
813 | - 'show_special_only' => '0', |
|
814 | - 'with_pics_only' => '0', |
|
815 | - 'with_videos_only' => '0', |
|
816 | - 'hide_if_empty' => '0', |
|
817 | - 'before_widget' => '', |
|
818 | - 'after_widget' => '', |
|
819 | - 'before_title' => '<h3 class="widget-title">', |
|
820 | - 'after_title' => '</h3>', |
|
821 | - 'title' => '', |
|
822 | - 'category_title' => '', |
|
823 | - ); |
|
824 | - |
|
825 | - $params = shortcode_atts($defaults, $atts); |
|
826 | - |
|
827 | - /** |
|
828 | - * Validate our incoming params |
|
829 | - */ |
|
801 | + ob_start(); |
|
802 | + $defaults = array( |
|
803 | + 'post_type' => 'gd_place', |
|
804 | + 'category' => '0', |
|
805 | + 'post_number' => '5', |
|
806 | + 'layout' => 'gridview_onehalf', |
|
807 | + 'add_location_filter' => '0', |
|
808 | + 'list_sort' => 'latest', |
|
809 | + 'use_viewing_post_type' => '1', |
|
810 | + 'character_count' => '20', |
|
811 | + 'listing_width' => '', |
|
812 | + 'show_featured_only' => '0', |
|
813 | + 'show_special_only' => '0', |
|
814 | + 'with_pics_only' => '0', |
|
815 | + 'with_videos_only' => '0', |
|
816 | + 'hide_if_empty' => '0', |
|
817 | + 'before_widget' => '', |
|
818 | + 'after_widget' => '', |
|
819 | + 'before_title' => '<h3 class="widget-title">', |
|
820 | + 'after_title' => '</h3>', |
|
821 | + 'title' => '', |
|
822 | + 'category_title' => '', |
|
823 | + ); |
|
830 | 824 | |
831 | - // Validate the selected post type, default to gd_place on fail |
|
832 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
833 | - $params['post_type'] = 'gd_place'; |
|
834 | - } |
|
835 | - |
|
836 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
837 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
838 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
839 | - |
|
840 | - // Make sure we have an array |
|
841 | - if (!(is_array($params['category']))) { |
|
842 | - $params['category'] = explode(',', $params['category']); |
|
843 | - } |
|
844 | - |
|
845 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
846 | - // Otherwise it becomes empty and later on that will mean "All" |
|
847 | - $params['category'] = array_intersect($params['category'], $categories); |
|
848 | - |
|
849 | - // Post_number needs to be a positive integer |
|
850 | - $params['post_number'] = absint($params['post_number']); |
|
851 | - if (0 == $params['post_number']) { |
|
852 | - $params['post_number'] = 1; |
|
853 | - } |
|
854 | - |
|
855 | - // Validate our layout choice |
|
856 | - // Outside of the norm, I added some more simple terms to match the existing |
|
857 | - // So now I just run the switch to set it properly. |
|
858 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
859 | - |
|
860 | - // Validate our sorting choice |
|
861 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']); |
|
862 | - |
|
863 | - // Validate character_count |
|
864 | - if ($params['character_count'] !== '') { |
|
865 | - $params['character_count'] = absint($params['character_count']); |
|
866 | - } |
|
867 | - |
|
868 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
869 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
870 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
871 | - |
|
872 | - // Validate the checkboxes used on the widget |
|
873 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
874 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
875 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
876 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
877 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
878 | - $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']); |
|
879 | - $params['hide_if_empty'] = gdsc_to_bool_val($params['hide_if_empty']); |
|
880 | - |
|
881 | - /** |
|
882 | - * End of validation |
|
883 | - */ |
|
825 | + $params = shortcode_atts($defaults, $atts); |
|
826 | + |
|
827 | + /** |
|
828 | + * Validate our incoming params |
|
829 | + */ |
|
830 | + |
|
831 | + // Validate the selected post type, default to gd_place on fail |
|
832 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
833 | + $params['post_type'] = 'gd_place'; |
|
834 | + } |
|
835 | + |
|
836 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
837 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
838 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids')); |
|
839 | + |
|
840 | + // Make sure we have an array |
|
841 | + if (!(is_array($params['category']))) { |
|
842 | + $params['category'] = explode(',', $params['category']); |
|
843 | + } |
|
844 | + |
|
845 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
846 | + // Otherwise it becomes empty and later on that will mean "All" |
|
847 | + $params['category'] = array_intersect($params['category'], $categories); |
|
884 | 848 | |
885 | - geodir_popular_postview_output($params, $params); |
|
849 | + // Post_number needs to be a positive integer |
|
850 | + $params['post_number'] = absint($params['post_number']); |
|
851 | + if (0 == $params['post_number']) { |
|
852 | + $params['post_number'] = 1; |
|
853 | + } |
|
854 | + |
|
855 | + // Validate our layout choice |
|
856 | + // Outside of the norm, I added some more simple terms to match the existing |
|
857 | + // So now I just run the switch to set it properly. |
|
858 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
859 | + |
|
860 | + // Validate our sorting choice |
|
861 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']); |
|
862 | + |
|
863 | + // Validate character_count |
|
864 | + if ($params['character_count'] !== '') { |
|
865 | + $params['character_count'] = absint($params['character_count']); |
|
866 | + } |
|
867 | + |
|
868 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
869 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
870 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
886 | 871 | |
872 | + // Validate the checkboxes used on the widget |
|
873 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
874 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
875 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
876 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
877 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
878 | + $params['use_viewing_post_type'] = gdsc_to_bool_val($params['use_viewing_post_type']); |
|
879 | + $params['hide_if_empty'] = gdsc_to_bool_val($params['hide_if_empty']); |
|
887 | 880 | |
888 | - $output = ob_get_contents(); |
|
881 | + /** |
|
882 | + * End of validation |
|
883 | + */ |
|
889 | 884 | |
890 | - ob_end_clean(); |
|
885 | + geodir_popular_postview_output($params, $params); |
|
891 | 886 | |
892 | - return $output; |
|
887 | + |
|
888 | + $output = ob_get_contents(); |
|
889 | + |
|
890 | + ob_end_clean(); |
|
891 | + |
|
892 | + return $output; |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | add_shortcode('gd_recent_reviews', 'geodir_sc_recent_reviews'); |
@@ -911,37 +911,37 @@ discard block |
||
911 | 911 | * @return string Recent reviews HTML. |
912 | 912 | */ |
913 | 913 | function geodir_sc_recent_reviews($atts) { |
914 | - ob_start(); |
|
915 | - $defaults = array( |
|
914 | + ob_start(); |
|
915 | + $defaults = array( |
|
916 | 916 | 'title' => '', |
917 | 917 | 'count' => 5, |
918 | - ); |
|
918 | + ); |
|
919 | 919 | |
920 | - $params = shortcode_atts($defaults, $atts); |
|
920 | + $params = shortcode_atts($defaults, $atts); |
|
921 | 921 | |
922 | - $count = absint($params['count']); |
|
923 | - if (0 == $count) { |
|
924 | - $count = 1; |
|
925 | - } |
|
922 | + $count = absint($params['count']); |
|
923 | + if (0 == $count) { |
|
924 | + $count = 1; |
|
925 | + } |
|
926 | 926 | |
927 | 927 | $title = !empty($params['title']) ? __($params['title'], 'geodirectory') : ''; |
928 | 928 | |
929 | - $comments_li = geodir_get_recent_reviews(30, $count, 100, false); |
|
929 | + $comments_li = geodir_get_recent_reviews(30, $count, 100, false); |
|
930 | 930 | |
931 | - if ($comments_li) { |
|
932 | - if ($title != '') { ?> |
|
931 | + if ($comments_li) { |
|
932 | + if ($title != '') { ?> |
|
933 | 933 | <h3 class="geodir-sc-recent-reviews-title widget-title"><?php echo $title; ?></h3> |
934 | 934 | <?php } ?> |
935 | 935 | <div class="geodir_sc_recent_reviews_section"> |
936 | 936 | <ul class="geodir_sc_recent_reviews"><?php echo $comments_li; ?></ul> |
937 | 937 | </div> |
938 | 938 | <?php |
939 | - } |
|
940 | - $output = ob_get_contents(); |
|
939 | + } |
|
940 | + $output = ob_get_contents(); |
|
941 | 941 | |
942 | - ob_end_clean(); |
|
942 | + ob_end_clean(); |
|
943 | 943 | |
944 | - return $output; |
|
944 | + return $output; |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | add_shortcode('gd_related_listings', 'geodir_sc_related_listings'); |
@@ -971,63 +971,63 @@ discard block |
||
971 | 971 | */ |
972 | 972 | function geodir_sc_related_listings($atts) |
973 | 973 | { |
974 | - ob_start(); |
|
975 | - $defaults = array( |
|
976 | - 'post_number' => 5, |
|
977 | - 'relate_to' => 'category', |
|
978 | - 'layout' => 'gridview_onehalf', |
|
979 | - 'add_location_filter' => 0, |
|
980 | - 'listing_width' => '', |
|
981 | - 'list_sort' => 'latest', |
|
982 | - 'character_count' => 20, |
|
983 | - 'is_widget' => 1, |
|
984 | - 'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>', |
|
985 | - ); |
|
986 | - // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet. |
|
987 | - |
|
988 | - $params = shortcode_atts($defaults, $atts); |
|
989 | - |
|
990 | - /** |
|
991 | - * Begin validating parameters |
|
992 | - */ |
|
974 | + ob_start(); |
|
975 | + $defaults = array( |
|
976 | + 'post_number' => 5, |
|
977 | + 'relate_to' => 'category', |
|
978 | + 'layout' => 'gridview_onehalf', |
|
979 | + 'add_location_filter' => 0, |
|
980 | + 'listing_width' => '', |
|
981 | + 'list_sort' => 'latest', |
|
982 | + 'character_count' => 20, |
|
983 | + 'is_widget' => 1, |
|
984 | + 'before_title' => '<style type="text/css">.geodir_category_list_view li{margin:0px!important}</style>', |
|
985 | + ); |
|
986 | + // The "before_title" code is an ugly & terrible hack. But it works for now. I should enqueue a new stylesheet. |
|
987 | + |
|
988 | + $params = shortcode_atts($defaults, $atts); |
|
989 | + |
|
990 | + /** |
|
991 | + * Begin validating parameters |
|
992 | + */ |
|
993 | 993 | |
994 | - // Validate that post_number is a number and is 1 or higher |
|
995 | - $params['post_number'] = absint($params['post_number']); |
|
996 | - if (0 === $params['post_number']) { |
|
997 | - $params['post_number'] = 1; |
|
998 | - } |
|
994 | + // Validate that post_number is a number and is 1 or higher |
|
995 | + $params['post_number'] = absint($params['post_number']); |
|
996 | + if (0 === $params['post_number']) { |
|
997 | + $params['post_number'] = 1; |
|
998 | + } |
|
999 | 999 | |
1000 | - // Validate relate_to - only category or tags |
|
1001 | - $params['relate_to'] = geodir_strtolower($params['relate_to']); |
|
1002 | - if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) { |
|
1003 | - $params['relate_to'] = 'category'; |
|
1004 | - } |
|
1000 | + // Validate relate_to - only category or tags |
|
1001 | + $params['relate_to'] = geodir_strtolower($params['relate_to']); |
|
1002 | + if ('category' != $params['relate_to'] && 'tags' != $params['relate_to']) { |
|
1003 | + $params['relate_to'] = 'category'; |
|
1004 | + } |
|
1005 | 1005 | |
1006 | - // Validate layout selection |
|
1007 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1006 | + // Validate layout selection |
|
1007 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1008 | 1008 | |
1009 | - // Validate sorting option |
|
1010 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
1009 | + // Validate sorting option |
|
1010 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort']); |
|
1011 | 1011 | |
1012 | - // Validate add_location_filter |
|
1013 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1012 | + // Validate add_location_filter |
|
1013 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1014 | 1014 | |
1015 | - // Validate listing_width |
|
1016 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1015 | + // Validate listing_width |
|
1016 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1017 | 1017 | |
1018 | - // Validate character_count |
|
1019 | - if ($params['character_count'] !== '') { |
|
1020 | - $params['character_count'] = absint($params['character_count']); |
|
1021 | - } |
|
1018 | + // Validate character_count |
|
1019 | + if ($params['character_count'] !== '') { |
|
1020 | + $params['character_count'] = absint($params['character_count']); |
|
1021 | + } |
|
1022 | 1022 | |
1023 | - if ($related_display = geodir_related_posts_display($params)) { |
|
1024 | - echo $related_display; |
|
1025 | - } |
|
1026 | - $output = ob_get_contents(); |
|
1023 | + if ($related_display = geodir_related_posts_display($params)) { |
|
1024 | + echo $related_display; |
|
1025 | + } |
|
1026 | + $output = ob_get_contents(); |
|
1027 | 1027 | |
1028 | - ob_end_clean(); |
|
1028 | + ob_end_clean(); |
|
1029 | 1029 | |
1030 | - return $output; |
|
1030 | + return $output; |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | /** |
@@ -1051,13 +1051,13 @@ discard block |
||
1051 | 1051 | * @return string Advanced search widget HTML. |
1052 | 1052 | */ |
1053 | 1053 | function geodir_sc_advanced_search($atts) { |
1054 | - $defaults = array( |
|
1054 | + $defaults = array( |
|
1055 | 1055 | 'title' => '', |
1056 | 1056 | 'before_widget' => '<section id="geodir_advanced_search-1" class="widget geodir-widget geodir_advance_search_widget">', |
1057 | - 'after_widget' => '</section>', |
|
1058 | - 'before_title' => '<h3 class="widget-title">', |
|
1059 | - 'after_title' => '</h3>', |
|
1060 | - 'show_adv_search' => 'default', |
|
1057 | + 'after_widget' => '</section>', |
|
1058 | + 'before_title' => '<h3 class="widget-title">', |
|
1059 | + 'after_title' => '</h3>', |
|
1060 | + 'show_adv_search' => 'default', |
|
1061 | 1061 | 'post_type' => '' |
1062 | 1062 | ); |
1063 | 1063 | |
@@ -1081,9 +1081,9 @@ discard block |
||
1081 | 1081 | the_widget('geodir_advance_search_widget', $params, $params ); |
1082 | 1082 | |
1083 | 1083 | $output = ob_get_contents(); |
1084 | - ob_end_clean(); |
|
1084 | + ob_end_clean(); |
|
1085 | 1085 | |
1086 | - return $output; |
|
1086 | + return $output; |
|
1087 | 1087 | } |
1088 | 1088 | add_shortcode('gd_advanced_search', 'geodir_sc_advanced_search'); |
1089 | 1089 | |
@@ -1129,48 +1129,48 @@ discard block |
||
1129 | 1129 | 'add_location_filter' => '1', |
1130 | 1130 | 'tab_layout' => 'bestof-tabs-on-top', |
1131 | 1131 | 'before_widget' => '<section id="bestof_widget-1" class="widget geodir-widget geodir_bestof_widget geodir_sc_bestof_widget">', |
1132 | - 'after_widget' => '</section>', |
|
1133 | - 'before_title' => '<h3 class="widget-title">', |
|
1134 | - 'after_title' => '</h3>', |
|
1132 | + 'after_widget' => '</section>', |
|
1133 | + 'before_title' => '<h3 class="widget-title">', |
|
1134 | + 'after_title' => '</h3>', |
|
1135 | 1135 | ); |
1136 | 1136 | $params = shortcode_atts($defaults, $atts); |
1137 | 1137 | |
1138 | - /** |
|
1139 | - * Validate our incoming params |
|
1140 | - */ |
|
1138 | + /** |
|
1139 | + * Validate our incoming params |
|
1140 | + */ |
|
1141 | 1141 | |
1142 | - // Validate the selected post type, default to gd_place on fail |
|
1143 | - if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
1144 | - $params['post_type'] = 'gd_place'; |
|
1145 | - } |
|
1142 | + // Validate the selected post type, default to gd_place on fail |
|
1143 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
1144 | + $params['post_type'] = 'gd_place'; |
|
1145 | + } |
|
1146 | 1146 | |
1147 | 1147 | // Post limit needs to be a positive integer |
1148 | - $params['post_limit'] = absint($params['post_limit']); |
|
1149 | - if (0 == $params['post_limit']) { |
|
1150 | - $params['post_limit'] = 5; |
|
1151 | - } |
|
1148 | + $params['post_limit'] = absint($params['post_limit']); |
|
1149 | + if (0 == $params['post_limit']) { |
|
1150 | + $params['post_limit'] = 5; |
|
1151 | + } |
|
1152 | 1152 | |
1153 | 1153 | // Category limit needs to be a positive integer |
1154 | - $params['categ_limit'] = absint($params['categ_limit']); |
|
1155 | - if (0 == $params['categ_limit']) { |
|
1156 | - $params['categ_limit'] = 3; |
|
1157 | - } |
|
1154 | + $params['categ_limit'] = absint($params['categ_limit']); |
|
1155 | + if (0 == $params['categ_limit']) { |
|
1156 | + $params['categ_limit'] = 3; |
|
1157 | + } |
|
1158 | 1158 | |
1159 | 1159 | // Tab layout validation |
1160 | - $params['tab_layout'] = $params['tab_layout']; |
|
1161 | - if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
1162 | - $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
1163 | - } |
|
1160 | + $params['tab_layout'] = $params['tab_layout']; |
|
1161 | + if (!in_array($params['tab_layout'], array('bestof-tabs-on-top', 'bestof-tabs-on-left', 'bestof-tabs-as-dropdown'))) { |
|
1162 | + $params['tab_layout'] = 'bestof-tabs-on-top'; |
|
1163 | + } |
|
1164 | 1164 | |
1165 | 1165 | // Validate character_count |
1166 | - $params['character_count'] = $params['character_count']; |
|
1166 | + $params['character_count'] = $params['character_count']; |
|
1167 | 1167 | |
1168 | 1168 | ob_start(); |
1169 | 1169 | the_widget('geodir_bestof_widget', $params, $params); |
1170 | - $output = ob_get_contents(); |
|
1171 | - ob_end_clean(); |
|
1170 | + $output = ob_get_contents(); |
|
1171 | + ob_end_clean(); |
|
1172 | 1172 | |
1173 | - return $output; |
|
1173 | + return $output; |
|
1174 | 1174 | } |
1175 | 1175 | add_shortcode('gd_bestof_widget', 'geodir_sc_bestof_widget'); |
1176 | 1176 | |
@@ -1223,162 +1223,162 @@ discard block |
||
1223 | 1223 | * @return string HTML content to display geodirectory listings. |
1224 | 1224 | */ |
1225 | 1225 | function geodir_sc_gd_listings($atts, $content = '') { |
1226 | - global $post; |
|
1227 | - $defaults = array( |
|
1228 | - 'title' => '', |
|
1229 | - 'post_type' => 'gd_place', |
|
1230 | - 'category' => 0, |
|
1231 | - 'list_sort' => 'latest', |
|
1232 | - 'event_type' => '', |
|
1233 | - 'post_number' => 10, |
|
1234 | - 'post_author' => '', |
|
1235 | - 'layout' => 'gridview_onehalf', |
|
1236 | - 'listing_width' => '', |
|
1237 | - 'character_count' => 20, |
|
1238 | - 'add_location_filter' => 1, |
|
1239 | - 'show_featured_only' => '', |
|
1240 | - 'show_special_only' => '', |
|
1241 | - 'with_pics_only' => '', |
|
1242 | - 'with_videos_only' => '', |
|
1243 | - 'with_pagination' => '1', |
|
1244 | - 'top_pagination' => '0', |
|
1245 | - 'bottom_pagination' => '1', |
|
1246 | - 'without_no_results' => 0, |
|
1247 | - 'tags' => '', |
|
1248 | - 'show_favorites_only' => '', |
|
1249 | - 'favorites_by_user' => '', |
|
1250 | - ); |
|
1251 | - $params = shortcode_atts($defaults, $atts); |
|
1252 | - |
|
1253 | - $params['title'] = wp_strip_all_tags($params['title']); |
|
1254 | - $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
1255 | - |
|
1256 | - // Validate the selected category/ies - Grab the current list based on post_type |
|
1257 | - $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
1258 | - $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids', 'hide_empty' => 0)); |
|
1259 | - |
|
1260 | - // Make sure we have an array |
|
1261 | - if (!(is_array($params['category']))) { |
|
1262 | - $params['category'] = explode(',', $params['category']); |
|
1263 | - } |
|
1264 | - |
|
1265 | - // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
1266 | - // Otherwise it becomes empty and later on that will mean "All" |
|
1267 | - $params['category'] = array_intersect($params['category'], $categories); |
|
1268 | - |
|
1269 | - // Post_number needs to be a positive integer |
|
1270 | - $params['post_number'] = absint($params['post_number']); |
|
1271 | - $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
1226 | + global $post; |
|
1227 | + $defaults = array( |
|
1228 | + 'title' => '', |
|
1229 | + 'post_type' => 'gd_place', |
|
1230 | + 'category' => 0, |
|
1231 | + 'list_sort' => 'latest', |
|
1232 | + 'event_type' => '', |
|
1233 | + 'post_number' => 10, |
|
1234 | + 'post_author' => '', |
|
1235 | + 'layout' => 'gridview_onehalf', |
|
1236 | + 'listing_width' => '', |
|
1237 | + 'character_count' => 20, |
|
1238 | + 'add_location_filter' => 1, |
|
1239 | + 'show_featured_only' => '', |
|
1240 | + 'show_special_only' => '', |
|
1241 | + 'with_pics_only' => '', |
|
1242 | + 'with_videos_only' => '', |
|
1243 | + 'with_pagination' => '1', |
|
1244 | + 'top_pagination' => '0', |
|
1245 | + 'bottom_pagination' => '1', |
|
1246 | + 'without_no_results' => 0, |
|
1247 | + 'tags' => '', |
|
1248 | + 'show_favorites_only' => '', |
|
1249 | + 'favorites_by_user' => '', |
|
1250 | + ); |
|
1251 | + $params = shortcode_atts($defaults, $atts); |
|
1252 | + |
|
1253 | + $params['title'] = wp_strip_all_tags($params['title']); |
|
1254 | + $params['post_type'] = gdsc_is_post_type_valid($params['post_type']) ? $params['post_type'] : 'gd_place'; |
|
1255 | + |
|
1256 | + // Validate the selected category/ies - Grab the current list based on post_type |
|
1257 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
1258 | + $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC', 'fields' => 'ids', 'hide_empty' => 0)); |
|
1259 | + |
|
1260 | + // Make sure we have an array |
|
1261 | + if (!(is_array($params['category']))) { |
|
1262 | + $params['category'] = explode(',', $params['category']); |
|
1263 | + } |
|
1264 | + |
|
1265 | + // Array_intersect returns only the items in $params['category'] that are also in our category list |
|
1266 | + // Otherwise it becomes empty and later on that will mean "All" |
|
1267 | + $params['category'] = array_intersect($params['category'], $categories); |
|
1268 | + |
|
1269 | + // Post_number needs to be a positive integer |
|
1270 | + $params['post_number'] = absint($params['post_number']); |
|
1271 | + $params['post_number'] = $params['post_number'] > 0 ? $params['post_number'] : 10; |
|
1272 | 1272 | |
1273 | - // Post_number needs to be a positive integer |
|
1274 | - if (!empty($params['post_author'])) { |
|
1275 | - // 'current' left for backwards compatibility |
|
1276 | - if ( $params['post_author'] == 'current' || $params['post_author'] == 'current_author') { |
|
1277 | - if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
|
1278 | - $params['post_author'] = $post->post_author; |
|
1279 | - } else { |
|
1280 | - $params['post_author'] = -1; // Don't show any listings. |
|
1281 | - } |
|
1282 | - } else if ($params['post_author'] == 'current_user' ) { |
|
1283 | - if ($current_user_id = get_current_user_id()) { |
|
1284 | - $params['post_author'] = $current_user_id; |
|
1285 | - } else { |
|
1286 | - $params['post_author'] = -1; // If not logged in then don't show any listings. |
|
1287 | - } |
|
1288 | - } else if (absint($params['post_author']) > 0) { |
|
1289 | - $params['post_author'] = absint($params['post_author']); |
|
1290 | - } else { |
|
1291 | - $params['post_author'] = -1; // Don't show any listings. |
|
1292 | - } |
|
1293 | - } else { |
|
1294 | - unset($params['post_author']); |
|
1295 | - } |
|
1296 | - |
|
1297 | - // Validate character_count |
|
1298 | - //todo: is this necessary? |
|
1299 | - $params['character_count'] = $params['character_count']; |
|
1300 | - |
|
1301 | - // Validate our layout choice |
|
1302 | - // Outside of the norm, I added some more simple terms to match the existing |
|
1303 | - // So now I just run the switch to set it properly. |
|
1304 | - $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1305 | - |
|
1306 | - // Validate our sorting choice |
|
1307 | - $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']); |
|
1308 | - |
|
1309 | - // Validate Listing width, used in the template widget-listing-listview.php |
|
1310 | - // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
1311 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1312 | - |
|
1313 | - // Validate the checkboxes used on the widget |
|
1314 | - $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1315 | - $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
1316 | - $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
1317 | - $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
1318 | - $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
1319 | - $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
1320 | - $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
1321 | - $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
1273 | + // Post_number needs to be a positive integer |
|
1274 | + if (!empty($params['post_author'])) { |
|
1275 | + // 'current' left for backwards compatibility |
|
1276 | + if ( $params['post_author'] == 'current' || $params['post_author'] == 'current_author') { |
|
1277 | + if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
|
1278 | + $params['post_author'] = $post->post_author; |
|
1279 | + } else { |
|
1280 | + $params['post_author'] = -1; // Don't show any listings. |
|
1281 | + } |
|
1282 | + } else if ($params['post_author'] == 'current_user' ) { |
|
1283 | + if ($current_user_id = get_current_user_id()) { |
|
1284 | + $params['post_author'] = $current_user_id; |
|
1285 | + } else { |
|
1286 | + $params['post_author'] = -1; // If not logged in then don't show any listings. |
|
1287 | + } |
|
1288 | + } else if (absint($params['post_author']) > 0) { |
|
1289 | + $params['post_author'] = absint($params['post_author']); |
|
1290 | + } else { |
|
1291 | + $params['post_author'] = -1; // Don't show any listings. |
|
1292 | + } |
|
1293 | + } else { |
|
1294 | + unset($params['post_author']); |
|
1295 | + } |
|
1296 | + |
|
1297 | + // Validate character_count |
|
1298 | + //todo: is this necessary? |
|
1299 | + $params['character_count'] = $params['character_count']; |
|
1300 | + |
|
1301 | + // Validate our layout choice |
|
1302 | + // Outside of the norm, I added some more simple terms to match the existing |
|
1303 | + // So now I just run the switch to set it properly. |
|
1304 | + $params['layout'] = gdsc_validate_layout_choice($params['layout']); |
|
1305 | + |
|
1306 | + // Validate our sorting choice |
|
1307 | + $params['list_sort'] = gdsc_validate_sort_choice($params['list_sort'], $params['post_type']); |
|
1308 | + |
|
1309 | + // Validate Listing width, used in the template widget-listing-listview.php |
|
1310 | + // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
|
1311 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1312 | + |
|
1313 | + // Validate the checkboxes used on the widget |
|
1314 | + $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
|
1315 | + $params['show_featured_only'] = gdsc_to_bool_val($params['show_featured_only']); |
|
1316 | + $params['show_special_only'] = gdsc_to_bool_val($params['show_special_only']); |
|
1317 | + $params['with_pics_only'] = gdsc_to_bool_val($params['with_pics_only']); |
|
1318 | + $params['with_videos_only'] = gdsc_to_bool_val($params['with_videos_only']); |
|
1319 | + $params['with_pagination'] = gdsc_to_bool_val($params['with_pagination']); |
|
1320 | + $params['top_pagination'] = gdsc_to_bool_val($params['top_pagination']); |
|
1321 | + $params['bottom_pagination'] = gdsc_to_bool_val($params['bottom_pagination']); |
|
1322 | 1322 | |
1323 | - // User favorites |
|
1324 | - $params['show_favorites_only'] = gdsc_to_bool_val($params['show_favorites_only']); |
|
1325 | - if (!empty($params['show_favorites_only'])) { |
|
1326 | - if ( $params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') { |
|
1327 | - if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
|
1328 | - $params['favorites_by_user'] = $post->post_author; |
|
1329 | - } else { |
|
1330 | - $params['favorites_by_user'] = 0; |
|
1331 | - } |
|
1332 | - } else if ($params['favorites_by_user'] == 'current_user' || empty($params['favorites_by_user'])) { |
|
1333 | - if ($current_user_id = get_current_user_id()) { |
|
1334 | - $params['favorites_by_user'] = $current_user_id; |
|
1335 | - } else { |
|
1336 | - $params['favorites_by_user'] = 0; |
|
1337 | - } |
|
1338 | - } else if (absint($params['favorites_by_user']) > 0) { |
|
1339 | - $params['favorites_by_user'] = absint($params['favorites_by_user']); |
|
1340 | - } else { |
|
1341 | - $params['favorites_by_user'] = 0; |
|
1342 | - } |
|
1343 | - } |
|
1344 | - |
|
1345 | - // Clean tags |
|
1346 | - if (!empty($params['tags'])) { |
|
1347 | - if (!is_array($params['tags'])) { |
|
1348 | - $comma = _x(',', 'tag delimiter'); |
|
1349 | - if ( ',' !== $comma ) { |
|
1350 | - $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
1351 | - } |
|
1352 | - $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
1353 | - $params['tags'] = array_map('trim', $params['tags']); |
|
1354 | - } |
|
1355 | - } else { |
|
1356 | - $params['tags'] = array(); |
|
1357 | - } |
|
1358 | - |
|
1359 | - /** |
|
1360 | - * End of validation |
|
1361 | - */ |
|
1362 | - if (isset($atts['geodir_ajax'])) { |
|
1363 | - $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
1364 | - unset($atts['geodir_ajax']); |
|
1365 | - } |
|
1366 | - if (isset($atts['pageno'])) { |
|
1367 | - $params['pageno'] = $atts['pageno']; |
|
1368 | - unset($atts['pageno']); |
|
1369 | - } |
|
1370 | - |
|
1371 | - if ( !empty($atts['shortcode_content']) ) { |
|
1372 | - $content = $atts['shortcode_content']; |
|
1373 | - } |
|
1374 | - $params['shortcode_content'] = trim($content); |
|
1375 | - $atts['shortcode_content'] = trim($content); |
|
1323 | + // User favorites |
|
1324 | + $params['show_favorites_only'] = gdsc_to_bool_val($params['show_favorites_only']); |
|
1325 | + if (!empty($params['show_favorites_only'])) { |
|
1326 | + if ( $params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') { |
|
1327 | + if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
|
1328 | + $params['favorites_by_user'] = $post->post_author; |
|
1329 | + } else { |
|
1330 | + $params['favorites_by_user'] = 0; |
|
1331 | + } |
|
1332 | + } else if ($params['favorites_by_user'] == 'current_user' || empty($params['favorites_by_user'])) { |
|
1333 | + if ($current_user_id = get_current_user_id()) { |
|
1334 | + $params['favorites_by_user'] = $current_user_id; |
|
1335 | + } else { |
|
1336 | + $params['favorites_by_user'] = 0; |
|
1337 | + } |
|
1338 | + } else if (absint($params['favorites_by_user']) > 0) { |
|
1339 | + $params['favorites_by_user'] = absint($params['favorites_by_user']); |
|
1340 | + } else { |
|
1341 | + $params['favorites_by_user'] = 0; |
|
1342 | + } |
|
1343 | + } |
|
1344 | + |
|
1345 | + // Clean tags |
|
1346 | + if (!empty($params['tags'])) { |
|
1347 | + if (!is_array($params['tags'])) { |
|
1348 | + $comma = _x(',', 'tag delimiter'); |
|
1349 | + if ( ',' !== $comma ) { |
|
1350 | + $params['tags'] = str_replace($comma, ',', $params['tags']); |
|
1351 | + } |
|
1352 | + $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
|
1353 | + $params['tags'] = array_map('trim', $params['tags']); |
|
1354 | + } |
|
1355 | + } else { |
|
1356 | + $params['tags'] = array(); |
|
1357 | + } |
|
1358 | + |
|
1359 | + /** |
|
1360 | + * End of validation |
|
1361 | + */ |
|
1362 | + if (isset($atts['geodir_ajax'])) { |
|
1363 | + $params['geodir_ajax'] = $atts['geodir_ajax']; |
|
1364 | + unset($atts['geodir_ajax']); |
|
1365 | + } |
|
1366 | + if (isset($atts['pageno'])) { |
|
1367 | + $params['pageno'] = $atts['pageno']; |
|
1368 | + unset($atts['pageno']); |
|
1369 | + } |
|
1370 | + |
|
1371 | + if ( !empty($atts['shortcode_content']) ) { |
|
1372 | + $content = $atts['shortcode_content']; |
|
1373 | + } |
|
1374 | + $params['shortcode_content'] = trim($content); |
|
1375 | + $atts['shortcode_content'] = trim($content); |
|
1376 | 1376 | |
1377 | - $params['shortcode_atts'] = $atts; |
|
1377 | + $params['shortcode_atts'] = $atts; |
|
1378 | 1378 | |
1379 | - $output = geodir_sc_gd_listings_output($params); |
|
1379 | + $output = geodir_sc_gd_listings_output($params); |
|
1380 | 1380 | |
1381 | - return $output; |
|
1381 | + return $output; |
|
1382 | 1382 | } |
1383 | 1383 | add_shortcode('gd_listings', 'geodir_sc_gd_listings'); |
1384 | 1384 | |
@@ -1418,56 +1418,56 @@ discard block |
||
1418 | 1418 | * @return string HTML content to display CPT categories. |
1419 | 1419 | */ |
1420 | 1420 | function geodir_sc_cpt_categories_widget($atts, $content = '') { |
1421 | - $defaults = array( |
|
1422 | - 'title' => '', |
|
1423 | - 'post_type' => '', // NULL for all |
|
1424 | - 'hide_empty' => '', |
|
1425 | - 'show_count' => '', |
|
1426 | - 'hide_icon' => '', |
|
1427 | - 'cpt_left' => '', |
|
1428 | - 'sort_by' => 'count', |
|
1429 | - 'max_count' => 'all', |
|
1430 | - 'max_level' => '1', |
|
1431 | - 'no_cpt_filter' => '', |
|
1432 | - 'no_cat_filter' => '', |
|
1433 | - 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
1434 | - 'after_widget' => '</section>', |
|
1435 | - 'before_title' => '<h3 class="widget-title">', |
|
1436 | - 'after_title' => '</h3>', |
|
1437 | - ); |
|
1438 | - $params = shortcode_atts($defaults, $atts); |
|
1439 | - |
|
1440 | - /** |
|
1441 | - * Validate our incoming params |
|
1442 | - */ |
|
1443 | - // Make sure we have an array |
|
1444 | - $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
1445 | - |
|
1446 | - // Validate the checkboxes used on the widget |
|
1447 | - $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
1448 | - $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
1449 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1450 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1421 | + $defaults = array( |
|
1422 | + 'title' => '', |
|
1423 | + 'post_type' => '', // NULL for all |
|
1424 | + 'hide_empty' => '', |
|
1425 | + 'show_count' => '', |
|
1426 | + 'hide_icon' => '', |
|
1427 | + 'cpt_left' => '', |
|
1428 | + 'sort_by' => 'count', |
|
1429 | + 'max_count' => 'all', |
|
1430 | + 'max_level' => '1', |
|
1431 | + 'no_cpt_filter' => '', |
|
1432 | + 'no_cat_filter' => '', |
|
1433 | + 'before_widget' => '<section id="geodir_cpt_categories_widget-1" class="widget geodir-widget geodir_cpt_categories_widget geodir_sc_cpt_categories_widget">', |
|
1434 | + 'after_widget' => '</section>', |
|
1435 | + 'before_title' => '<h3 class="widget-title">', |
|
1436 | + 'after_title' => '</h3>', |
|
1437 | + ); |
|
1438 | + $params = shortcode_atts($defaults, $atts); |
|
1451 | 1439 | |
1452 | - if ($params['max_count'] != 'all') { |
|
1453 | - $params['max_count'] = absint($params['max_count']); |
|
1454 | - } |
|
1440 | + /** |
|
1441 | + * Validate our incoming params |
|
1442 | + */ |
|
1443 | + // Make sure we have an array |
|
1444 | + $params['post_type'] = !is_array($params['post_type']) && trim($params['post_type']) != '' ? explode(',', trim($params['post_type'])) : array(); |
|
1445 | + |
|
1446 | + // Validate the checkboxes used on the widget |
|
1447 | + $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
|
1448 | + $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
|
1449 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1450 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1451 | + |
|
1452 | + if ($params['max_count'] != 'all') { |
|
1453 | + $params['max_count'] = absint($params['max_count']); |
|
1454 | + } |
|
1455 | 1455 | |
1456 | - if ($params['max_level'] != 'all') { |
|
1457 | - $params['max_level'] = absint($params['max_level']); |
|
1458 | - } |
|
1456 | + if ($params['max_level'] != 'all') { |
|
1457 | + $params['max_level'] = absint($params['max_level']); |
|
1458 | + } |
|
1459 | 1459 | |
1460 | - $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
1461 | - $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
1460 | + $params['no_cpt_filter'] = gdsc_to_bool_val($params['no_cpt_filter']); |
|
1461 | + $params['no_cat_filter'] = gdsc_to_bool_val($params['no_cat_filter']); |
|
1462 | 1462 | |
1463 | - $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
1463 | + $params['sort_by'] = $params['sort_by'] == 'az' ? 'az' : 'count'; |
|
1464 | 1464 | |
1465 | - ob_start(); |
|
1466 | - the_widget('geodir_cpt_categories_widget', $params, $params); |
|
1467 | - $output = ob_get_contents(); |
|
1468 | - ob_end_clean(); |
|
1465 | + ob_start(); |
|
1466 | + the_widget('geodir_cpt_categories_widget', $params, $params); |
|
1467 | + $output = ob_get_contents(); |
|
1468 | + ob_end_clean(); |
|
1469 | 1469 | |
1470 | - return $output; |
|
1470 | + return $output; |
|
1471 | 1471 | } |
1472 | 1472 | add_shortcode('gd_cpt_categories', 'geodir_sc_cpt_categories_widget'); |
1473 | 1473 | |
@@ -1482,6 +1482,6 @@ discard block |
||
1482 | 1482 | * @return string HTML code. |
1483 | 1483 | */ |
1484 | 1484 | function geodir_sc_responsive_videos($atts, $content) { |
1485 | - return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
1485 | + return '<div class="geodir-video-wrapper">'.$content.'</div>'; |
|
1486 | 1486 | } |
1487 | 1487 | add_shortcode('gd_video', 'geodir_sc_responsive_videos'); |
1488 | 1488 | \ No newline at end of file |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | // Add marker cluster |
198 | 198 | if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
199 | 199 | $map_args['enable_marker_cluster'] = true; |
200 | - if(get_option('geodir_marker_cluster_type')) { |
|
200 | + if (get_option('geodir_marker_cluster_type')) { |
|
201 | 201 | if ($map_args['autozoom']) { |
202 | 202 | $map_args['enable_marker_cluster_no_reposition'] = false; |
203 | 203 | } else { |
204 | 204 | $map_args['enable_marker_cluster_no_reposition'] = true; |
205 | 205 | } |
206 | 206 | |
207 | - $map_args['enable_marker_cluster_server'] = true ; |
|
207 | + $map_args['enable_marker_cluster_server'] = true; |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | } else { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | // if lat and long set in shortcode, hack it so the map is not repositioned |
215 | - if(!empty($params['latitude']) && !empty($params['longitude']) ){ |
|
215 | + if (!empty($params['latitude']) && !empty($params['longitude'])) { |
|
216 | 216 | $map_args['enable_marker_cluster_no_reposition'] = true; |
217 | 217 | } |
218 | 218 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | function geodir_sc_listing_map($atts) { |
266 | 266 | |
267 | 267 | // if some params are set then we need a new query, if not then we can use the main query |
268 | - if( isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type']) ) { |
|
268 | + if (isset($atts['post_type']) || isset($atts['category']) || isset($atts['event_type'])) { |
|
269 | 269 | |
270 | 270 | global $add_post_in_marker_array, $gd_sc_map_params; |
271 | 271 | $backup_globals = array(); |
@@ -288,34 +288,34 @@ discard block |
||
288 | 288 | 'event_type' => 'all' |
289 | 289 | ); |
290 | 290 | |
291 | - $params = shortcode_atts( $defaults, $atts ); |
|
291 | + $params = shortcode_atts($defaults, $atts); |
|
292 | 292 | |
293 | - if ( ! ( gdsc_is_post_type_valid( $params['post_type'] ) ) ) { |
|
293 | + if (!(gdsc_is_post_type_valid($params['post_type']))) { |
|
294 | 294 | $params['post_type'] = 'gd_place'; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Validate the selected category/ies - Grab the current list based on post_type |
298 | - $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
299 | - $categories = get_terms( $category_taxonomy, array( |
|
298 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
299 | + $categories = get_terms($category_taxonomy, array( |
|
300 | 300 | 'orderby' => 'count', |
301 | 301 | 'order' => 'DESC', |
302 | 302 | 'fields' => 'ids' |
303 | - ) ); |
|
303 | + )); |
|
304 | 304 | |
305 | 305 | // Make sure we have an array |
306 | - if ( ! ( is_array( $params['category'] ) ) ) { |
|
307 | - $params['category'] = explode( ',', $params['category'] ); |
|
306 | + if (!(is_array($params['category']))) { |
|
307 | + $params['category'] = explode(',', $params['category']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // Array_intersect returns only the items in $params['category'] that are also in our category list |
311 | 311 | // Otherwise it becomes empty and later on that will mean "All" |
312 | - $params['category'] = array_intersect( $params['category'], $categories ); |
|
312 | + $params['category'] = array_intersect($params['category'], $categories); |
|
313 | 313 | |
314 | - if ( $params['post_type'] == 'gd_event' ) { |
|
315 | - $params['event_type'] = gdsc_validate_list_filter_choice( $params['event_type'] ); |
|
314 | + if ($params['post_type'] == 'gd_event') { |
|
315 | + $params['event_type'] = gdsc_validate_list_filter_choice($params['event_type']); |
|
316 | 316 | } |
317 | 317 | |
318 | - $params = gdsc_validate_map_args( $params ); |
|
318 | + $params = gdsc_validate_map_args($params); |
|
319 | 319 | |
320 | 320 | $gd_sc_map_params = $params; |
321 | 321 | |
@@ -326,12 +326,12 @@ discard block |
||
326 | 326 | 'post_type' => $params['post_type'], |
327 | 327 | ); |
328 | 328 | |
329 | - if ( ! empty( $params['category'] ) && isset( $params['category'][0] ) && (int) $params['category'][0] != 0 ) { |
|
330 | - $category_taxonomy = geodir_get_taxonomies( $params['post_type'] ); |
|
329 | + if (!empty($params['category']) && isset($params['category'][0]) && (int) $params['category'][0] != 0) { |
|
330 | + $category_taxonomy = geodir_get_taxonomies($params['post_type']); |
|
331 | 331 | |
332 | 332 | ######### WPML ######### |
333 | - if ( geodir_wpml_is_taxonomy_translated( $category_taxonomy[0] ) ) { |
|
334 | - $category = gd_lang_object_ids( $params['category'], $category_taxonomy[0] ); |
|
333 | + if (geodir_wpml_is_taxonomy_translated($category_taxonomy[0])) { |
|
334 | + $category = gd_lang_object_ids($params['category'], $category_taxonomy[0]); |
|
335 | 335 | } |
336 | 336 | ######### WPML ######### |
337 | 337 | |
@@ -341,36 +341,36 @@ discard block |
||
341 | 341 | 'terms' => $params['category'] |
342 | 342 | ); |
343 | 343 | |
344 | - $query_args['tax_query'] = array( $tax_query ); |
|
344 | + $query_args['tax_query'] = array($tax_query); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | $add_post_in_marker_array = true; |
348 | 348 | |
349 | - if ( $params['post_type'] == 'gd_event' && function_exists( 'geodir_event_get_widget_events' ) ) { |
|
349 | + if ($params['post_type'] == 'gd_event' && function_exists('geodir_event_get_widget_events')) { |
|
350 | 350 | global $geodir_event_widget_listview; |
351 | 351 | $geodir_event_widget_listview = true; |
352 | 352 | |
353 | 353 | $query_args['geodir_event_type'] = $params['event_type']; |
354 | 354 | |
355 | - $listings = geodir_event_get_widget_events( $query_args ); |
|
355 | + $listings = geodir_event_get_widget_events($query_args); |
|
356 | 356 | |
357 | 357 | $geodir_event_widget_listview = false; |
358 | 358 | } else { |
359 | - $listings = geodir_get_widget_listings( $query_args ); |
|
359 | + $listings = geodir_get_widget_listings($query_args); |
|
360 | 360 | } |
361 | 361 | |
362 | - if ( ! empty( $listings ) ) { |
|
363 | - foreach ( $listings as $listing ) { |
|
364 | - create_marker_jason_of_posts( $listing ); |
|
362 | + if (!empty($listings)) { |
|
363 | + foreach ($listings as $listing) { |
|
364 | + create_marker_jason_of_posts($listing); |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
368 | 368 | ob_start(); |
369 | - add_action( 'wp_head', 'init_listing_map_script' ); // Initialize the map object and marker array |
|
369 | + add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
370 | 370 | |
371 | - add_action( 'the_post', 'create_list_jsondata' ); // Add marker in json array |
|
371 | + add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
372 | 372 | |
373 | - add_action( 'wp_footer', 'show_listing_widget_map' ); // Show map for listings with markers |
|
373 | + add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
374 | 374 | |
375 | 375 | $default_location = geodir_get_default_location(); |
376 | 376 | |
@@ -391,17 +391,17 @@ discard block |
||
391 | 391 | 'enable_location_filters' => false, |
392 | 392 | 'enable_jason_on_load' => true, |
393 | 393 | 'ajax_url' => geodir_get_ajax_url(), |
394 | - 'latitude' => isset( $default_location->city_latitude ) ? $default_location->city_latitude : '', |
|
395 | - 'longitude' => isset( $default_location->city_longitude ) ? $default_location->city_longitude : '', |
|
394 | + 'latitude' => isset($default_location->city_latitude) ? $default_location->city_latitude : '', |
|
395 | + 'longitude' => isset($default_location->city_longitude) ? $default_location->city_longitude : '', |
|
396 | 396 | 'streetViewControl' => true, |
397 | 397 | 'showPreview' => '0', |
398 | 398 | 'maxZoom' => 21, |
399 | 399 | 'bubble_size' => 'small', |
400 | 400 | ); |
401 | 401 | |
402 | - if ( is_single() ) { |
|
402 | + if (is_single()) { |
|
403 | 403 | global $post; |
404 | - if ( isset( $post->post_latitude ) ) { |
|
404 | + if (isset($post->post_latitude)) { |
|
405 | 405 | $map_args['latitude'] = $post->post_latitude; |
406 | 406 | $map_args['longitude'] = $post->post_longitude; |
407 | 407 | } |
@@ -412,24 +412,24 @@ discard block |
||
412 | 412 | } |
413 | 413 | |
414 | 414 | // Add marker cluster |
415 | - if ( isset( $params['marker_cluster'] ) && gdsc_to_bool_val( $params['marker_cluster'] ) && defined( 'GDCLUSTER_VERSION' ) ) { |
|
415 | + if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { |
|
416 | 416 | $map_args['enable_marker_cluster'] = true; |
417 | 417 | } else { |
418 | 418 | $map_args['enable_marker_cluster'] = false; |
419 | 419 | } |
420 | 420 | |
421 | - geodir_draw_map( $map_args ); |
|
421 | + geodir_draw_map($map_args); |
|
422 | 422 | |
423 | 423 | $output = ob_get_contents(); |
424 | 424 | |
425 | 425 | ob_end_clean(); |
426 | 426 | |
427 | - foreach ( $backup_globals as $global => $value ) { |
|
427 | + foreach ($backup_globals as $global => $value) { |
|
428 | 428 | ${$global} = $value; |
429 | 429 | } |
430 | 430 | |
431 | 431 | return $output; |
432 | - }else{ |
|
432 | + } else { |
|
433 | 433 | ob_start(); |
434 | 434 | add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
435 | 435 | add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
@@ -476,16 +476,16 @@ discard block |
||
476 | 476 | $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
477 | 477 | $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
478 | 478 | $map_args['map_class_name'] = 'geodir-map-listing-page'; |
479 | - if ( geodir_is_page( 'search' ) ) { |
|
479 | + if (geodir_is_page('search')) { |
|
480 | 480 | $map_default_lat = ''; |
481 | 481 | $map_default_lng = ''; |
482 | - if ( isset( $_REQUEST['sgeo_lat'] ) && isset( $_REQUEST['sgeo_lon'] ) ) { |
|
483 | - $map_default_lat = (float)sanitize_text_field( $_REQUEST['sgeo_lat'] ); |
|
484 | - $map_default_lng = (float)sanitize_text_field( $_REQUEST['sgeo_lon'] ); |
|
482 | + if (isset($_REQUEST['sgeo_lat']) && isset($_REQUEST['sgeo_lon'])) { |
|
483 | + $map_default_lat = (float) sanitize_text_field($_REQUEST['sgeo_lat']); |
|
484 | + $map_default_lng = (float) sanitize_text_field($_REQUEST['sgeo_lon']); |
|
485 | 485 | } |
486 | - if ( empty( $map_default_lat ) && empty( $map_default_lng ) && ! empty( $_REQUEST['set_location_type'] ) && ! empty( $_REQUEST['set_location_val'] ) && function_exists( 'geodir_get_location_by_id' ) ) { |
|
487 | - $location = geodir_get_location_by_id( '', (int)$_REQUEST['set_location_val'] ); |
|
488 | - if ( ! empty( $location ) ) { |
|
486 | + if (empty($map_default_lat) && empty($map_default_lng) && !empty($_REQUEST['set_location_type']) && !empty($_REQUEST['set_location_val']) && function_exists('geodir_get_location_by_id')) { |
|
487 | + $location = geodir_get_location_by_id('', (int) $_REQUEST['set_location_val']); |
|
488 | + if (!empty($location)) { |
|
489 | 489 | $map_default_lat = $location->city_latitude; |
490 | 490 | $map_default_lng = $location->city_longitude; |
491 | 491 | } |
@@ -1065,20 +1065,20 @@ discard block |
||
1065 | 1065 | |
1066 | 1066 | $show_adv_search = isset($params['show_adv_search']) && in_array($params['show_adv_search'], array('default', 'always', 'searched')) ? $params['show_adv_search'] : ''; |
1067 | 1067 | |
1068 | - if ($show_adv_search != '' ) { |
|
1069 | - $show_adv_class = 'geodir-advance-search-' . $show_adv_search . ' '; |
|
1068 | + if ($show_adv_search != '') { |
|
1069 | + $show_adv_class = 'geodir-advance-search-'.$show_adv_search.' '; |
|
1070 | 1070 | if ($show_adv_search == 'searched' && geodir_is_page('search')) { |
1071 | 1071 | $show_adv_search = 'search'; |
1072 | 1072 | } |
1073 | - $show_adv_attrs = 'data-show-adv="' . $show_adv_search . '"'; |
|
1073 | + $show_adv_attrs = 'data-show-adv="'.$show_adv_search.'"'; |
|
1074 | 1074 | |
1075 | - $params['before_widget'] = str_replace('class="', $show_adv_attrs . ' class="' . $show_adv_class, $params['before_widget']); |
|
1075 | + $params['before_widget'] = str_replace('class="', $show_adv_attrs.' class="'.$show_adv_class, $params['before_widget']); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | ob_start(); |
1079 | 1079 | |
1080 | 1080 | //geodir_get_template_part('listing', 'filter-form'); |
1081 | - the_widget('geodir_advance_search_widget', $params, $params ); |
|
1081 | + the_widget('geodir_advance_search_widget', $params, $params); |
|
1082 | 1082 | |
1083 | 1083 | $output = ob_get_contents(); |
1084 | 1084 | ob_end_clean(); |
@@ -1273,13 +1273,13 @@ discard block |
||
1273 | 1273 | // Post_number needs to be a positive integer |
1274 | 1274 | if (!empty($params['post_author'])) { |
1275 | 1275 | // 'current' left for backwards compatibility |
1276 | - if ( $params['post_author'] == 'current' || $params['post_author'] == 'current_author') { |
|
1276 | + if ($params['post_author'] == 'current' || $params['post_author'] == 'current_author') { |
|
1277 | 1277 | if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
1278 | 1278 | $params['post_author'] = $post->post_author; |
1279 | 1279 | } else { |
1280 | 1280 | $params['post_author'] = -1; // Don't show any listings. |
1281 | 1281 | } |
1282 | - } else if ($params['post_author'] == 'current_user' ) { |
|
1282 | + } else if ($params['post_author'] == 'current_user') { |
|
1283 | 1283 | if ($current_user_id = get_current_user_id()) { |
1284 | 1284 | $params['post_author'] = $current_user_id; |
1285 | 1285 | } else { |
@@ -1296,7 +1296,7 @@ discard block |
||
1296 | 1296 | |
1297 | 1297 | // Validate character_count |
1298 | 1298 | //todo: is this necessary? |
1299 | - $params['character_count'] = $params['character_count']; |
|
1299 | + $params['character_count'] = $params['character_count']; |
|
1300 | 1300 | |
1301 | 1301 | // Validate our layout choice |
1302 | 1302 | // Outside of the norm, I added some more simple terms to match the existing |
@@ -1308,7 +1308,7 @@ discard block |
||
1308 | 1308 | |
1309 | 1309 | // Validate Listing width, used in the template widget-listing-listview.php |
1310 | 1310 | // The context is in width=$listing_width% - So we need a positive number between 0 & 100 |
1311 | - $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1311 | + $params['listing_width'] = gdsc_validate_listing_width($params['listing_width']); |
|
1312 | 1312 | |
1313 | 1313 | // Validate the checkboxes used on the widget |
1314 | 1314 | $params['add_location_filter'] = gdsc_to_bool_val($params['add_location_filter']); |
@@ -1323,7 +1323,7 @@ discard block |
||
1323 | 1323 | // User favorites |
1324 | 1324 | $params['show_favorites_only'] = gdsc_to_bool_val($params['show_favorites_only']); |
1325 | 1325 | if (!empty($params['show_favorites_only'])) { |
1326 | - if ( $params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') { |
|
1326 | + if ($params['favorites_by_user'] == 'current' || $params['favorites_by_user'] == 'current_author') { |
|
1327 | 1327 | if (!empty($post) && $post->post_type != 'page' && isset($post->post_author)) { |
1328 | 1328 | $params['favorites_by_user'] = $post->post_author; |
1329 | 1329 | } else { |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | if (!empty($params['tags'])) { |
1347 | 1347 | if (!is_array($params['tags'])) { |
1348 | 1348 | $comma = _x(',', 'tag delimiter'); |
1349 | - if ( ',' !== $comma ) { |
|
1349 | + if (',' !== $comma) { |
|
1350 | 1350 | $params['tags'] = str_replace($comma, ',', $params['tags']); |
1351 | 1351 | } |
1352 | 1352 | $params['tags'] = explode(',', trim($params['tags'], " \n\t\r\0\x0B,")); |
@@ -1368,13 +1368,13 @@ discard block |
||
1368 | 1368 | unset($atts['pageno']); |
1369 | 1369 | } |
1370 | 1370 | |
1371 | - if ( !empty($atts['shortcode_content']) ) { |
|
1371 | + if (!empty($atts['shortcode_content'])) { |
|
1372 | 1372 | $content = $atts['shortcode_content']; |
1373 | 1373 | } |
1374 | 1374 | $params['shortcode_content'] = trim($content); |
1375 | 1375 | $atts['shortcode_content'] = trim($content); |
1376 | 1376 | |
1377 | - $params['shortcode_atts'] = $atts; |
|
1377 | + $params['shortcode_atts'] = $atts; |
|
1378 | 1378 | |
1379 | 1379 | $output = geodir_sc_gd_listings_output($params); |
1380 | 1380 | |
@@ -1446,8 +1446,8 @@ discard block |
||
1446 | 1446 | // Validate the checkboxes used on the widget |
1447 | 1447 | $params['hide_empty'] = gdsc_to_bool_val($params['hide_empty']); |
1448 | 1448 | $params['show_count'] = gdsc_to_bool_val($params['show_count']); |
1449 | - $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1450 | - $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1449 | + $params['hide_icon'] = gdsc_to_bool_val($params['hide_icon']); |
|
1450 | + $params['cpt_left'] = gdsc_to_bool_val($params['cpt_left']); |
|
1451 | 1451 | |
1452 | 1452 | if ($params['max_count'] != 'all') { |
1453 | 1453 | $params['max_count'] = absint($params['max_count']); |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | */ |
19 | 19 | function init_listing_map_script() |
20 | 20 | { |
21 | - global $list_map_json; |
|
21 | + global $list_map_json; |
|
22 | 22 | |
23 | - $list_map_json = array(); |
|
23 | + $list_map_json = array(); |
|
24 | 24 | |
25 | 25 | } |
26 | 26 | |
@@ -35,18 +35,18 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function create_list_jsondata($post) |
37 | 37 | { |
38 | - global $wpdb, $list_map_json, $add_post_in_marker_array; |
|
39 | - |
|
40 | - if ((is_main_query() || $add_post_in_marker_array) && isset($post->marker_json) && $post->marker_json != '') { |
|
41 | - /** |
|
42 | - * Filter the json data for search listing map. |
|
43 | - * |
|
44 | - * @since 1.5.7 |
|
45 | - * @param string $post->marker_json JSON representation of the post marker info. |
|
46 | - * @param object $post The post object. |
|
47 | - */ |
|
48 | - $list_map_json[] = apply_filters('geodir_create_list_jsondata',$post->marker_json,$post); |
|
49 | - } |
|
38 | + global $wpdb, $list_map_json, $add_post_in_marker_array; |
|
39 | + |
|
40 | + if ((is_main_query() || $add_post_in_marker_array) && isset($post->marker_json) && $post->marker_json != '') { |
|
41 | + /** |
|
42 | + * Filter the json data for search listing map. |
|
43 | + * |
|
44 | + * @since 1.5.7 |
|
45 | + * @param string $post->marker_json JSON representation of the post marker info. |
|
46 | + * @param object $post The post object. |
|
47 | + */ |
|
48 | + $list_map_json[] = apply_filters('geodir_create_list_jsondata',$post->marker_json,$post); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
@@ -59,29 +59,29 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function show_listing_widget_map() |
61 | 61 | { |
62 | - global $list_map_json; |
|
62 | + global $list_map_json; |
|
63 | 63 | |
64 | - if (!empty($list_map_json)) { |
|
65 | - $list_map_json = array_unique($list_map_json); |
|
66 | - $cat_content_info[] = implode(',', $list_map_json); |
|
67 | - } |
|
64 | + if (!empty($list_map_json)) { |
|
65 | + $list_map_json = array_unique($list_map_json); |
|
66 | + $cat_content_info[] = implode(',', $list_map_json); |
|
67 | + } |
|
68 | 68 | |
69 | - $totalcount = count(array_unique($list_map_json)); |
|
69 | + $totalcount = count(array_unique($list_map_json)); |
|
70 | 70 | |
71 | 71 | |
72 | - if (!empty($cat_content_info)) { |
|
73 | - $json_content = substr(implode(',', $cat_content_info), 1); |
|
74 | - $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016 |
|
75 | - $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
|
76 | - $list_json = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']'; |
|
77 | - } else { |
|
78 | - $list_json = '[{"totalcount":"0"}]'; |
|
79 | - } |
|
72 | + if (!empty($cat_content_info)) { |
|
73 | + $json_content = substr(implode(',', $cat_content_info), 1); |
|
74 | + $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016 |
|
75 | + $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
|
76 | + $list_json = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']'; |
|
77 | + } else { |
|
78 | + $list_json = '[{"totalcount":"0"}]'; |
|
79 | + } |
|
80 | 80 | |
81 | - $listing_map_args = array('list_json' => $list_json); |
|
81 | + $listing_map_args = array('list_json' => $list_json); |
|
82 | 82 | |
83 | - // Pass the json data in listing map script |
|
84 | - wp_localize_script('geodir-listing-map-widget', 'listing_map_args', $listing_map_args); |
|
83 | + // Pass the json data in listing map script |
|
84 | + wp_localize_script('geodir-listing-map-widget', 'listing_map_args', $listing_map_args); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -93,110 +93,110 @@ discard block |
||
93 | 93 | class geodir_map_listingpage extends WP_Widget |
94 | 94 | { |
95 | 95 | |
96 | - /** |
|
96 | + /** |
|
97 | 97 | * Register the listing page map widget. |
98 | 98 | * |
99 | 99 | * @since 1.0.0 |
100 | - * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
100 | + * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct. |
|
101 | 101 | */ |
102 | - public function __construct() { |
|
103 | - $widget_ops = array('classname' => 'widget geodir-map-listing-page', 'description' => __('Google Map for Listing page. It will show you google map V3 for Listing page.', 'geodirectory')); |
|
104 | - parent::__construct( |
|
105 | - 'geodir_map_v3_listing_map', // Base ID |
|
106 | - __('GD > GMap - Listing page', 'geodirectory'), // Name |
|
107 | - $widget_ops// Args |
|
108 | - ); |
|
102 | + public function __construct() { |
|
103 | + $widget_ops = array('classname' => 'widget geodir-map-listing-page', 'description' => __('Google Map for Listing page. It will show you google map V3 for Listing page.', 'geodirectory')); |
|
104 | + parent::__construct( |
|
105 | + 'geodir_map_v3_listing_map', // Base ID |
|
106 | + __('GD > GMap - Listing page', 'geodirectory'), // Name |
|
107 | + $widget_ops// Args |
|
108 | + ); |
|
109 | 109 | |
110 | - add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
110 | + add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array |
|
111 | 111 | |
112 | - add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
112 | + add_action('the_post', 'create_list_jsondata'); // Add marker in json array |
|
113 | 113 | |
114 | - add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
115 | - } |
|
114 | + add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers |
|
115 | + } |
|
116 | 116 | |
117 | 117 | /** |
118 | 118 | * Front-end display content for listing page map widget. |
119 | 119 | * |
120 | 120 | * @since 1.0.0 |
121 | - * @since 1.5.1 Declare function public. |
|
121 | + * @since 1.5.1 Declare function public. |
|
122 | + * |
|
123 | + * @global object $post The current post object. |
|
122 | 124 | * |
123 | - * @global object $post The current post object. |
|
124 | - * |
|
125 | 125 | * @param array $args Widget arguments. |
126 | 126 | * @param array $instance Saved values from database. |
127 | 127 | */ |
128 | - public function widget($args, $instance) |
|
129 | - { |
|
130 | - |
|
131 | - if (geodir_is_page('listing') || geodir_is_page('author') || geodir_is_page('search') |
|
132 | - || geodir_is_page('detail') |
|
133 | - ) : |
|
134 | - |
|
135 | - extract($args, EXTR_SKIP); |
|
136 | - /** This action is documented in geodirectory_shortcodes.php */ |
|
137 | - $width = empty($instance['width']) ? '294' : apply_filters('widget_width', $instance['width']); |
|
138 | - /** This action is documented in geodirectory_shortcodes.php */ |
|
139 | - $height = empty($instance['heigh']) ? '370' : apply_filters('widget_heigh', $instance['heigh']); |
|
140 | - /** This action is documented in geodirectory_shortcodes.php */ |
|
141 | - $maptype = empty($instance['maptype']) ? 'ROADMAP' : apply_filters('widget_maptype', $instance['maptype']); |
|
142 | - /** This action is documented in geodirectory_shortcodes.php */ |
|
143 | - $zoom = empty($instance['zoom']) ? '13' : apply_filters('widget_zoom', $instance['zoom']); |
|
144 | - /** This action is documented in geodirectory_shortcodes.php */ |
|
145 | - $autozoom = empty($instance['autozoom']) ? '' : apply_filters('widget_autozoom', $instance['autozoom']); |
|
146 | - /** |
|
147 | - * Filter the listing map value widget_sticky, to set if the map should be sticky or not (scroll with page). |
|
148 | - * |
|
149 | - * @since 1.0.0 |
|
150 | - * @param bool $sticky True if should be sticky, false if not |
|
151 | - */ |
|
152 | - $sticky = empty($instance['sticky']) ? '' : apply_filters('widget_sticky', $instance['sticky']); |
|
153 | - /** This action is documented in geodirectory_shortcodes.php */ |
|
154 | - $scrollwheel = empty($instance['scrollwheel']) ? '0' : apply_filters('widget_scrollwheel', $instance['scrollwheel']); |
|
155 | - $showall = empty($instance['showall']) ? '0' : apply_filters('widget_showall', $instance['showall']); |
|
128 | + public function widget($args, $instance) |
|
129 | + { |
|
130 | + |
|
131 | + if (geodir_is_page('listing') || geodir_is_page('author') || geodir_is_page('search') |
|
132 | + || geodir_is_page('detail') |
|
133 | + ) : |
|
134 | + |
|
135 | + extract($args, EXTR_SKIP); |
|
136 | + /** This action is documented in geodirectory_shortcodes.php */ |
|
137 | + $width = empty($instance['width']) ? '294' : apply_filters('widget_width', $instance['width']); |
|
138 | + /** This action is documented in geodirectory_shortcodes.php */ |
|
139 | + $height = empty($instance['heigh']) ? '370' : apply_filters('widget_heigh', $instance['heigh']); |
|
140 | + /** This action is documented in geodirectory_shortcodes.php */ |
|
141 | + $maptype = empty($instance['maptype']) ? 'ROADMAP' : apply_filters('widget_maptype', $instance['maptype']); |
|
142 | + /** This action is documented in geodirectory_shortcodes.php */ |
|
143 | + $zoom = empty($instance['zoom']) ? '13' : apply_filters('widget_zoom', $instance['zoom']); |
|
144 | + /** This action is documented in geodirectory_shortcodes.php */ |
|
145 | + $autozoom = empty($instance['autozoom']) ? '' : apply_filters('widget_autozoom', $instance['autozoom']); |
|
146 | + /** |
|
147 | + * Filter the listing map value widget_sticky, to set if the map should be sticky or not (scroll with page). |
|
148 | + * |
|
149 | + * @since 1.0.0 |
|
150 | + * @param bool $sticky True if should be sticky, false if not |
|
151 | + */ |
|
152 | + $sticky = empty($instance['sticky']) ? '' : apply_filters('widget_sticky', $instance['sticky']); |
|
153 | + /** This action is documented in geodirectory_shortcodes.php */ |
|
154 | + $scrollwheel = empty($instance['scrollwheel']) ? '0' : apply_filters('widget_scrollwheel', $instance['scrollwheel']); |
|
155 | + $showall = empty($instance['showall']) ? '0' : apply_filters('widget_showall', $instance['showall']); |
|
156 | 156 | |
157 | 157 | /** |
158 | - * Filter the listing map should to be displayed or not. |
|
159 | - * |
|
160 | - * @since 1.4.6 |
|
158 | + * Filter the listing map should to be displayed or not. |
|
161 | 159 | * |
162 | - * @param bool $display true if map should be displayed, false if not. |
|
163 | - */ |
|
160 | + * @since 1.4.6 |
|
161 | + * |
|
162 | + * @param bool $display true if map should be displayed, false if not. |
|
163 | + */ |
|
164 | 164 | $show_map = apply_filters( 'geodir_show_map_listing', $display = true ); |
165 | 165 | if ( !$show_map ) { |
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
169 | - $map_args = array(); |
|
170 | - $map_args['map_canvas_name'] = str_replace('-', '_', $args['widget_id']); |
|
171 | - $map_args['width'] = $width; |
|
172 | - $map_args['height'] = $height; |
|
173 | - |
|
174 | - $map_args['scrollwheel'] = $scrollwheel; |
|
175 | - $map_args['showall'] = $showall; |
|
176 | - $map_args['child_collapse'] = '0'; |
|
177 | - $map_args['sticky'] = $sticky; |
|
178 | - $map_args['enable_cat_filters'] = false; |
|
179 | - $map_args['enable_text_search'] = false; |
|
180 | - $map_args['enable_post_type_filters'] = false; |
|
181 | - $map_args['enable_location_filters'] = false; |
|
182 | - $map_args['enable_jason_on_load'] = true; |
|
169 | + $map_args = array(); |
|
170 | + $map_args['map_canvas_name'] = str_replace('-', '_', $args['widget_id']); |
|
171 | + $map_args['width'] = $width; |
|
172 | + $map_args['height'] = $height; |
|
173 | + |
|
174 | + $map_args['scrollwheel'] = $scrollwheel; |
|
175 | + $map_args['showall'] = $showall; |
|
176 | + $map_args['child_collapse'] = '0'; |
|
177 | + $map_args['sticky'] = $sticky; |
|
178 | + $map_args['enable_cat_filters'] = false; |
|
179 | + $map_args['enable_text_search'] = false; |
|
180 | + $map_args['enable_post_type_filters'] = false; |
|
181 | + $map_args['enable_location_filters'] = false; |
|
182 | + $map_args['enable_jason_on_load'] = true; |
|
183 | 183 | |
184 | - if (is_single()) { |
|
184 | + if (is_single()) { |
|
185 | 185 | |
186 | - global $post; |
|
187 | - $map_default_lat = $address_latitude = $post->post_latitude; |
|
188 | - $map_default_lng = $address_longitude = $post->post_longitude; |
|
189 | - $mapview = $post->post_mapview; |
|
190 | - $mapzoom = $post->post_mapzoom; |
|
191 | - $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
186 | + global $post; |
|
187 | + $map_default_lat = $address_latitude = $post->post_latitude; |
|
188 | + $map_default_lng = $address_longitude = $post->post_longitude; |
|
189 | + $mapview = $post->post_mapview; |
|
190 | + $mapzoom = $post->post_mapzoom; |
|
191 | + $map_args['map_class_name'] = 'geodir-map-listing-page-single'; |
|
192 | 192 | |
193 | - } else { |
|
194 | - $default_location = geodir_get_default_location(); |
|
193 | + } else { |
|
194 | + $default_location = geodir_get_default_location(); |
|
195 | 195 | |
196 | - $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
197 | - $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
198 | - $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
199 | - $mapview = $maptype; |
|
196 | + $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
197 | + $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
198 | + $map_args['map_class_name'] = 'geodir-map-listing-page'; |
|
199 | + $mapview = $maptype; |
|
200 | 200 | |
201 | 201 | if ( geodir_is_page( 'search' ) ) { |
202 | 202 | $map_default_lat = ''; |
@@ -213,83 +213,83 @@ discard block |
||
213 | 213 | } |
214 | 214 | } |
215 | 215 | } |
216 | - } |
|
217 | - |
|
218 | - if (empty($mapzoom)) $mapzoom = $zoom; |
|
219 | - |
|
220 | - // Set default map options |
|
221 | - $map_args['ajax_url'] = geodir_get_ajax_url(); |
|
222 | - $map_args['latitude'] = $map_default_lat; |
|
223 | - $map_args['longitude'] = $map_default_lng; |
|
224 | - $map_args['zoom'] = $zoom; |
|
225 | - //$map_args['scrollwheel'] = true; |
|
226 | - $map_args['scrollwheel'] = $scrollwheel; |
|
227 | - $map_args['showall'] = $showall; |
|
228 | - $map_args['streetViewControl'] = true; |
|
229 | - $map_args['maptype'] = $maptype; |
|
230 | - $map_args['showPreview'] = '0'; |
|
231 | - $map_args['maxZoom'] = 21; |
|
232 | - $map_args['autozoom'] = $autozoom; |
|
233 | - $map_args['bubble_size'] = 'small'; |
|
216 | + } |
|
217 | + |
|
218 | + if (empty($mapzoom)) $mapzoom = $zoom; |
|
219 | + |
|
220 | + // Set default map options |
|
221 | + $map_args['ajax_url'] = geodir_get_ajax_url(); |
|
222 | + $map_args['latitude'] = $map_default_lat; |
|
223 | + $map_args['longitude'] = $map_default_lng; |
|
224 | + $map_args['zoom'] = $zoom; |
|
225 | + //$map_args['scrollwheel'] = true; |
|
226 | + $map_args['scrollwheel'] = $scrollwheel; |
|
227 | + $map_args['showall'] = $showall; |
|
228 | + $map_args['streetViewControl'] = true; |
|
229 | + $map_args['maptype'] = $maptype; |
|
230 | + $map_args['showPreview'] = '0'; |
|
231 | + $map_args['maxZoom'] = 21; |
|
232 | + $map_args['autozoom'] = $autozoom; |
|
233 | + $map_args['bubble_size'] = 'small'; |
|
234 | 234 | |
235 | - $map_args['enable_marker_cluster'] = defined('GDCLUSTER_VERSION') && !empty($instance['marker_cluster']) ? true : false; |
|
235 | + $map_args['enable_marker_cluster'] = defined('GDCLUSTER_VERSION') && !empty($instance['marker_cluster']) ? true : false; |
|
236 | 236 | |
237 | - echo $before_widget; |
|
238 | - geodir_draw_map($map_args); |
|
239 | - echo $after_widget; |
|
237 | + echo $before_widget; |
|
238 | + geodir_draw_map($map_args); |
|
239 | + echo $after_widget; |
|
240 | 240 | |
241 | - endif; |
|
242 | - } |
|
241 | + endif; |
|
242 | + } |
|
243 | 243 | |
244 | 244 | /** |
245 | 245 | * Sanitize listing page map widget form values as they are saved. |
246 | 246 | * |
247 | 247 | * @since 1.0.0 |
248 | - * @since 1.5.1 Declare function public. |
|
248 | + * @since 1.5.1 Declare function public. |
|
249 | 249 | * |
250 | 250 | * @param array $new_instance Values just sent to be saved. |
251 | 251 | * @param array $old_instance Previously saved values from database. |
252 | 252 | * |
253 | 253 | * @return array Updated safe values to be saved. |
254 | 254 | */ |
255 | - public function update($new_instance, $old_instance) { |
|
256 | - //save the widget |
|
257 | - $instance = $old_instance; |
|
258 | - $instance['width'] = strip_tags($new_instance['width']); |
|
259 | - $instance['heigh'] = ($new_instance['heigh']); |
|
260 | - $instance['maptype'] = ($new_instance['maptype']); |
|
261 | - $instance['zoom'] = ($new_instance['zoom']); |
|
262 | - $instance['autozoom'] = isset($new_instance['autozoom']) ? $new_instance['autozoom'] : ''; |
|
263 | - $instance['sticky'] = isset($new_instance['sticky']) ? $new_instance['sticky'] : ''; |
|
264 | - $instance['scrollwheel'] = isset($new_instance['scrollwheel']) ? ($new_instance['scrollwheel']) : ''; |
|
265 | - $instance['showall'] = isset($new_instance['showall']) ? ($new_instance['showall']) : ''; |
|
266 | - $instance['marker_cluster'] = defined('GDCLUSTER_VERSION') && !empty($new_instance['marker_cluster']) ? 1 : ''; |
|
267 | - |
|
268 | - return $instance; |
|
269 | - } |
|
255 | + public function update($new_instance, $old_instance) { |
|
256 | + //save the widget |
|
257 | + $instance = $old_instance; |
|
258 | + $instance['width'] = strip_tags($new_instance['width']); |
|
259 | + $instance['heigh'] = ($new_instance['heigh']); |
|
260 | + $instance['maptype'] = ($new_instance['maptype']); |
|
261 | + $instance['zoom'] = ($new_instance['zoom']); |
|
262 | + $instance['autozoom'] = isset($new_instance['autozoom']) ? $new_instance['autozoom'] : ''; |
|
263 | + $instance['sticky'] = isset($new_instance['sticky']) ? $new_instance['sticky'] : ''; |
|
264 | + $instance['scrollwheel'] = isset($new_instance['scrollwheel']) ? ($new_instance['scrollwheel']) : ''; |
|
265 | + $instance['showall'] = isset($new_instance['showall']) ? ($new_instance['showall']) : ''; |
|
266 | + $instance['marker_cluster'] = defined('GDCLUSTER_VERSION') && !empty($new_instance['marker_cluster']) ? 1 : ''; |
|
267 | + |
|
268 | + return $instance; |
|
269 | + } |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Back-end listing page map widget settings form. |
273 | 273 | * |
274 | 274 | * @since 1.0.0 |
275 | - * @since 1.5.1 Declare function public. |
|
275 | + * @since 1.5.1 Declare function public. |
|
276 | 276 | * |
277 | 277 | * @param array $instance Previously saved values from database. |
278 | 278 | */ |
279 | - public function form($instance) { |
|
280 | - // widget form in backend |
|
281 | - $instance = wp_parse_args((array)$instance, array('width' => '', 'heigh' => '', 'maptype' => '', 'zoom' => '', 'autozoom' => '', 'sticky' => '', 'scrollwheel' => '0', 'showall' => '0', 'marker_cluster' => '0')); |
|
279 | + public function form($instance) { |
|
280 | + // widget form in backend |
|
281 | + $instance = wp_parse_args((array)$instance, array('width' => '', 'heigh' => '', 'maptype' => '', 'zoom' => '', 'autozoom' => '', 'sticky' => '', 'scrollwheel' => '0', 'showall' => '0', 'marker_cluster' => '0')); |
|
282 | 282 | |
283 | - $width = strip_tags($instance['width']); |
|
284 | - $heigh = strip_tags($instance['heigh']); |
|
285 | - $maptype = strip_tags($instance['maptype']); |
|
286 | - $zoom = strip_tags($instance['zoom']); |
|
287 | - $autozoom = strip_tags($instance['autozoom']); |
|
288 | - $sticky = strip_tags($instance['sticky']); |
|
289 | - $scrollwheel = strip_tags($instance['scrollwheel']); |
|
290 | - $showall = strip_tags($instance['showall']); |
|
291 | - $marker_cluster = (int)$instance['marker_cluster']; |
|
292 | - ?> |
|
283 | + $width = strip_tags($instance['width']); |
|
284 | + $heigh = strip_tags($instance['heigh']); |
|
285 | + $maptype = strip_tags($instance['maptype']); |
|
286 | + $zoom = strip_tags($instance['zoom']); |
|
287 | + $autozoom = strip_tags($instance['autozoom']); |
|
288 | + $sticky = strip_tags($instance['sticky']); |
|
289 | + $scrollwheel = strip_tags($instance['scrollwheel']); |
|
290 | + $showall = strip_tags($instance['showall']); |
|
291 | + $marker_cluster = (int)$instance['marker_cluster']; |
|
292 | + ?> |
|
293 | 293 | <p> |
294 | 294 | <label |
295 | 295 | for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Map Width <small>(Default is : 294) you can use px or % here</small>', 'geodirectory'); ?> |
@@ -318,14 +318,14 @@ discard block |
||
318 | 318 | name="<?php echo $this->get_field_name('maptype'); ?>"> |
319 | 319 | |
320 | 320 | <option <?php if (isset($maptype) && $maptype == 'ROADMAP') { |
321 | - echo 'selected="selected"'; |
|
322 | - } ?> value="ROADMAP"><?php _e('Road Map', 'geodirectory'); ?></option> |
|
321 | + echo 'selected="selected"'; |
|
322 | + } ?> value="ROADMAP"><?php _e('Road Map', 'geodirectory'); ?></option> |
|
323 | 323 | <option <?php if (isset($maptype) && $maptype == 'SATELLITE') { |
324 | - echo 'selected="selected"'; |
|
325 | - } ?> value="SATELLITE"><?php _e('Satellite Map', 'geodirectory'); ?></option> |
|
324 | + echo 'selected="selected"'; |
|
325 | + } ?> value="SATELLITE"><?php _e('Satellite Map', 'geodirectory'); ?></option> |
|
326 | 326 | <option <?php if (isset($maptype) && $maptype == 'HYBRID') { |
327 | - echo 'selected="selected"'; |
|
328 | - } ?> value="HYBRID"><?php _e('Hybrid Map', 'geodirectory'); ?></option> |
|
327 | + echo 'selected="selected"'; |
|
328 | + } ?> value="HYBRID"><?php _e('Hybrid Map', 'geodirectory'); ?></option> |
|
329 | 329 | <option <?php selected($maptype, 'TERRAIN');?> |
330 | 330 | value="TERRAIN"><?php _e('Terrain Map', 'geodirectory'); ?></option> |
331 | 331 | </select> |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | </p> |
334 | 334 | |
335 | 335 | <?php |
336 | - $map_zoom_level = geodir_map_zoom_level(); |
|
337 | - ?> |
|
336 | + $map_zoom_level = geodir_map_zoom_level(); |
|
337 | + ?> |
|
338 | 338 | |
339 | 339 | <p> |
340 | 340 | <label |
@@ -344,14 +344,14 @@ discard block |
||
344 | 344 | <select class="widefat" id="<?php echo $this->get_field_id('zoom'); ?>" |
345 | 345 | name="<?php echo $this->get_field_name('zoom'); ?>"> <?php |
346 | 346 | |
347 | - foreach ($map_zoom_level as $level) { |
|
348 | - $selected = ''; |
|
349 | - if ($level == $zoom) |
|
350 | - $selected = 'selected="selected"'; |
|
347 | + foreach ($map_zoom_level as $level) { |
|
348 | + $selected = ''; |
|
349 | + if ($level == $zoom) |
|
350 | + $selected = 'selected="selected"'; |
|
351 | 351 | |
352 | - echo '<option ' . $selected . ' value="' . $level . '">' . $level . '</option>'; |
|
352 | + echo '<option ' . $selected . ' value="' . $level . '">' . $level . '</option>'; |
|
353 | 353 | |
354 | - } ?> |
|
354 | + } ?> |
|
355 | 355 | |
356 | 356 | </select> |
357 | 357 | |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | for="<?php echo $this->get_field_id('autozoom'); ?>"> |
364 | 364 | <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('autozoom'); ?>" |
365 | 365 | name="<?php echo $this->get_field_name('autozoom'); ?>"<?php if ($autozoom) { |
366 | - echo 'checked="checked"'; |
|
367 | - } ?> /> <?php _e('Map Auto Zoom ?', 'geodirectory'); ?></label> |
|
366 | + echo 'checked="checked"'; |
|
367 | + } ?> /> <?php _e('Map Auto Zoom ?', 'geodirectory'); ?></label> |
|
368 | 368 | </p> |
369 | 369 | |
370 | 370 | <p> |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | for="<?php echo $this->get_field_id('sticky'); ?>"> |
373 | 373 | <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('sticky'); ?>" |
374 | 374 | name="<?php echo $this->get_field_name('sticky'); ?>"<?php if ($sticky) { |
375 | - echo 'checked="checked"'; |
|
376 | - } ?> /> <?php _e('Map Sticky(should stick to the right of screen) ?', 'geodirectory'); ?> |
|
375 | + echo 'checked="checked"'; |
|
376 | + } ?> /> <?php _e('Map Sticky(should stick to the right of screen) ?', 'geodirectory'); ?> |
|
377 | 377 | </label> |
378 | 378 | </p> |
379 | 379 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | </p> --> |
400 | 400 | |
401 | 401 | <?php |
402 | - } |
|
402 | + } |
|
403 | 403 | } // class geodir_map_listingpage |
404 | 404 | |
405 | 405 | register_widget('geodir_map_listingpage'); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string $post->marker_json JSON representation of the post marker info. |
46 | 46 | * @param object $post The post object. |
47 | 47 | */ |
48 | - $list_map_json[] = apply_filters('geodir_create_list_jsondata',$post->marker_json,$post); |
|
48 | + $list_map_json[] = apply_filters('geodir_create_list_jsondata', $post->marker_json, $post); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $json_content = substr(implode(',', $cat_content_info), 1); |
74 | 74 | $json_content = htmlentities($json_content, ENT_QUOTES, get_option('blog_charset')); // Quotes in csv title import break maps - FIXED by kiran on 2nd March, 2016 |
75 | 75 | $json_content = wp_specialchars_decode($json_content); // Fixed #post-320722 on 2016-12-08 |
76 | - $list_json = '[{"totalcount":"' . $totalcount . '",' . $json_content . ']'; |
|
76 | + $list_json = '[{"totalcount":"'.$totalcount.'",'.$json_content.']'; |
|
77 | 77 | } else { |
78 | 78 | $list_json = '[{"totalcount":"0"}]'; |
79 | 79 | } |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @param bool $display true if map should be displayed, false if not. |
163 | 163 | */ |
164 | - $show_map = apply_filters( 'geodir_show_map_listing', $display = true ); |
|
165 | - if ( !$show_map ) { |
|
164 | + $show_map = apply_filters('geodir_show_map_listing', $display = true); |
|
165 | + if (!$show_map) { |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
@@ -198,16 +198,16 @@ discard block |
||
198 | 198 | $map_args['map_class_name'] = 'geodir-map-listing-page'; |
199 | 199 | $mapview = $maptype; |
200 | 200 | |
201 | - if ( geodir_is_page( 'search' ) ) { |
|
201 | + if (geodir_is_page('search')) { |
|
202 | 202 | $map_default_lat = ''; |
203 | 203 | $map_default_lng = ''; |
204 | - if ( isset( $_REQUEST['sgeo_lat'] ) && isset( $_REQUEST['sgeo_lon'] ) ) { |
|
205 | - $map_default_lat = (float)sanitize_text_field( $_REQUEST['sgeo_lat'] ); |
|
206 | - $map_default_lng = (float)sanitize_text_field( $_REQUEST['sgeo_lon'] ); |
|
204 | + if (isset($_REQUEST['sgeo_lat']) && isset($_REQUEST['sgeo_lon'])) { |
|
205 | + $map_default_lat = (float) sanitize_text_field($_REQUEST['sgeo_lat']); |
|
206 | + $map_default_lng = (float) sanitize_text_field($_REQUEST['sgeo_lon']); |
|
207 | 207 | } |
208 | - if ( empty( $map_default_lat ) && empty( $map_default_lng ) && ! empty( $_REQUEST['set_location_type'] ) && ! empty( $_REQUEST['set_location_val'] ) && function_exists( 'geodir_get_location_by_id' ) ) { |
|
209 | - $location = geodir_get_location_by_id( '', (int)$_REQUEST['set_location_val'] ); |
|
210 | - if ( ! empty( $location ) ) { |
|
208 | + if (empty($map_default_lat) && empty($map_default_lng) && !empty($_REQUEST['set_location_type']) && !empty($_REQUEST['set_location_val']) && function_exists('geodir_get_location_by_id')) { |
|
209 | + $location = geodir_get_location_by_id('', (int) $_REQUEST['set_location_val']); |
|
210 | + if (!empty($location)) { |
|
211 | 211 | $map_default_lat = $location->city_latitude; |
212 | 212 | $map_default_lng = $location->city_longitude; |
213 | 213 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function form($instance) { |
280 | 280 | // widget form in backend |
281 | - $instance = wp_parse_args((array)$instance, array('width' => '', 'heigh' => '', 'maptype' => '', 'zoom' => '', 'autozoom' => '', 'sticky' => '', 'scrollwheel' => '0', 'showall' => '0', 'marker_cluster' => '0')); |
|
281 | + $instance = wp_parse_args((array) $instance, array('width' => '', 'heigh' => '', 'maptype' => '', 'zoom' => '', 'autozoom' => '', 'sticky' => '', 'scrollwheel' => '0', 'showall' => '0', 'marker_cluster' => '0')); |
|
282 | 282 | |
283 | 283 | $width = strip_tags($instance['width']); |
284 | 284 | $heigh = strip_tags($instance['heigh']); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $sticky = strip_tags($instance['sticky']); |
289 | 289 | $scrollwheel = strip_tags($instance['scrollwheel']); |
290 | 290 | $showall = strip_tags($instance['showall']); |
291 | - $marker_cluster = (int)$instance['marker_cluster']; |
|
291 | + $marker_cluster = (int) $instance['marker_cluster']; |
|
292 | 292 | ?> |
293 | 293 | <p> |
294 | 294 | <label |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | <option <?php if (isset($maptype) && $maptype == 'HYBRID') { |
327 | 327 | echo 'selected="selected"'; |
328 | 328 | } ?> value="HYBRID"><?php _e('Hybrid Map', 'geodirectory'); ?></option> |
329 | - <option <?php selected($maptype, 'TERRAIN');?> |
|
329 | + <option <?php selected($maptype, 'TERRAIN'); ?> |
|
330 | 330 | value="TERRAIN"><?php _e('Terrain Map', 'geodirectory'); ?></option> |
331 | 331 | </select> |
332 | 332 | </label> |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | if ($level == $zoom) |
350 | 350 | $selected = 'selected="selected"'; |
351 | 351 | |
352 | - echo '<option ' . $selected . ' value="' . $level . '">' . $level . '</option>'; |
|
352 | + echo '<option '.$selected.' value="'.$level.'">'.$level.'</option>'; |
|
353 | 353 | |
354 | 354 | } ?> |
355 | 355 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | for="<?php echo $this->get_field_id('scrollwheel'); ?>"> |
383 | 383 | <input id="<?php echo $this->get_field_id('scrollwheel'); ?>" |
384 | 384 | name="<?php echo $this->get_field_name('scrollwheel'); ?>" type="checkbox" value="1" |
385 | - <?php if ($scrollwheel){ ?>checked="checked" <?php } ?> /> <?php _e('Enable mouse scroll zoom ?', 'geodirectory'); ?> |
|
385 | + <?php if ($scrollwheel) { ?>checked="checked" <?php } ?> /> <?php _e('Enable mouse scroll zoom ?', 'geodirectory'); ?> |
|
386 | 386 | </label> |
387 | 387 | </p> |
388 | 388 | <?php if (defined('GDCLUSTER_VERSION')) { ?> |
@@ -215,7 +215,9 @@ discard block |
||
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if (empty($mapzoom)) $mapzoom = $zoom; |
|
218 | + if (empty($mapzoom)) { |
|
219 | + $mapzoom = $zoom; |
|
220 | + } |
|
219 | 221 | |
220 | 222 | // Set default map options |
221 | 223 | $map_args['ajax_url'] = geodir_get_ajax_url(); |
@@ -346,8 +348,9 @@ discard block |
||
346 | 348 | |
347 | 349 | foreach ($map_zoom_level as $level) { |
348 | 350 | $selected = ''; |
349 | - if ($level == $zoom) |
|
350 | - $selected = 'selected="selected"'; |
|
351 | + if ($level == $zoom) { |
|
352 | + $selected = 'selected="selected"'; |
|
353 | + } |
|
351 | 354 | |
352 | 355 | echo '<option ' . $selected . ' value="' . $level . '">' . $level . '</option>'; |
353 | 356 |
@@ -136,8 +136,8 @@ |
||
136 | 136 | |
137 | 137 | global $wp_version; |
138 | 138 | // If curent WP Version >= 4.9.6. |
139 | -if ( version_compare( $wp_version, '4.9.6', '>=' ) ) { |
|
140 | - include_once( 'geodirectory-functions/privacy/abstract-geodir-privacy.php' ); |
|
141 | - include_once( 'geodirectory-functions/privacy/class-geodir-privacy-background-process.php' ); |
|
142 | - include_once( 'geodirectory-functions/privacy/class-geodir-privacy.php' ); |
|
139 | +if (version_compare($wp_version, '4.9.6', '>=')) { |
|
140 | + include_once('geodirectory-functions/privacy/abstract-geodir-privacy.php'); |
|
141 | + include_once('geodirectory-functions/privacy/class-geodir-privacy-background-process.php'); |
|
142 | + include_once('geodirectory-functions/privacy/class-geodir-privacy.php'); |
|
143 | 143 | } |
144 | 144 | \ No newline at end of file |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @package WP-Background-Processing |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Abstract WP_Async_Request class. |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | * Initiate new async request |
55 | 55 | */ |
56 | 56 | public function __construct() { |
57 | - $this->identifier = $this->prefix . '_' . $this->action; |
|
57 | + $this->identifier = $this->prefix.'_'.$this->action; |
|
58 | 58 | |
59 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
60 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
59 | + add_action('wp_ajax_'.$this->identifier, array($this, 'maybe_handle')); |
|
60 | + add_action('wp_ajax_nopriv_'.$this->identifier, array($this, 'maybe_handle')); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return $this |
69 | 69 | */ |
70 | - public function data( $data ) { |
|
70 | + public function data($data) { |
|
71 | 71 | $this->data = $data; |
72 | 72 | |
73 | 73 | return $this; |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | * @return array|WP_Error |
80 | 80 | */ |
81 | 81 | public function dispatch() { |
82 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
82 | + $url = add_query_arg($this->get_query_args(), $this->get_query_url()); |
|
83 | 83 | $args = $this->get_post_args(); |
84 | 84 | |
85 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
85 | + return wp_remote_post(esc_url_raw($url), $args); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @return array |
92 | 92 | */ |
93 | 93 | protected function get_query_args() { |
94 | - if ( property_exists( $this, 'query_args' ) ) { |
|
94 | + if (property_exists($this, 'query_args')) { |
|
95 | 95 | return $this->query_args; |
96 | 96 | } |
97 | 97 | |
98 | 98 | return array( |
99 | 99 | 'action' => $this->identifier, |
100 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
100 | + 'nonce' => wp_create_nonce($this->identifier), |
|
101 | 101 | ); |
102 | 102 | } |
103 | 103 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | * @return string |
108 | 108 | */ |
109 | 109 | protected function get_query_url() { |
110 | - if ( property_exists( $this, 'query_url' ) ) { |
|
110 | + if (property_exists($this, 'query_url')) { |
|
111 | 111 | return $this->query_url; |
112 | 112 | } |
113 | 113 | |
114 | - return admin_url( 'admin-ajax.php' ); |
|
114 | + return admin_url('admin-ajax.php'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @return array |
121 | 121 | */ |
122 | 122 | protected function get_post_args() { |
123 | - if ( property_exists( $this, 'post_args' ) ) { |
|
123 | + if (property_exists($this, 'post_args')) { |
|
124 | 124 | return $this->post_args; |
125 | 125 | } |
126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | 'blocking' => false, |
130 | 130 | 'body' => $this->data, |
131 | 131 | 'cookies' => $_COOKIE, |
132 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
132 | + 'sslverify' => apply_filters('https_local_ssl_verify', false), |
|
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | // Don't lock up other requests while processing |
143 | 143 | session_write_close(); |
144 | 144 | |
145 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
145 | + check_ajax_referer($this->identifier, 'nonce'); |
|
146 | 146 | |
147 | 147 | $this->handle(); |
148 | 148 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @extends WP_Async_Request |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Abstract WP_Background_Process class. |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | public function __construct() { |
56 | 56 | parent::__construct(); |
57 | 57 | |
58 | - $this->cron_hook_identifier = $this->identifier . '_cron'; |
|
59 | - $this->cron_interval_identifier = $this->identifier . '_cron_interval'; |
|
58 | + $this->cron_hook_identifier = $this->identifier.'_cron'; |
|
59 | + $this->cron_interval_identifier = $this->identifier.'_cron_interval'; |
|
60 | 60 | |
61 | - add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) ); |
|
62 | - add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) ); |
|
61 | + add_action($this->cron_hook_identifier, array($this, 'handle_cron_healthcheck')); |
|
62 | + add_filter('cron_schedules', array($this, 'schedule_cron_healthcheck')); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return $this |
85 | 85 | */ |
86 | - public function push_to_queue( $data ) { |
|
86 | + public function push_to_queue($data) { |
|
87 | 87 | $this->data[] = $data; |
88 | 88 | |
89 | 89 | return $this; |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | public function save() { |
98 | 98 | $key = $this->generate_key(); |
99 | 99 | |
100 | - if ( ! empty( $this->data ) ) { |
|
101 | - update_site_option( $key, $this->data ); |
|
100 | + if (!empty($this->data)) { |
|
101 | + update_site_option($key, $this->data); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return $this; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return $this |
114 | 114 | */ |
115 | - public function update( $key, $data ) { |
|
116 | - if ( ! empty( $data ) ) { |
|
117 | - update_site_option( $key, $data ); |
|
115 | + public function update($key, $data) { |
|
116 | + if (!empty($data)) { |
|
117 | + update_site_option($key, $data); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return $this; |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return $this |
129 | 129 | */ |
130 | - public function delete( $key ) { |
|
131 | - delete_site_option( $key ); |
|
130 | + public function delete($key) { |
|
131 | + delete_site_option($key); |
|
132 | 132 | |
133 | 133 | return $this; |
134 | 134 | } |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string |
145 | 145 | */ |
146 | - protected function generate_key( $length = 64 ) { |
|
147 | - $unique = md5( microtime() . rand() ); |
|
148 | - $prepend = $this->identifier . '_batch_'; |
|
146 | + protected function generate_key($length = 64) { |
|
147 | + $unique = md5(microtime().rand()); |
|
148 | + $prepend = $this->identifier.'_batch_'; |
|
149 | 149 | |
150 | - return substr( $prepend . $unique, 0, $length ); |
|
150 | + return substr($prepend.$unique, 0, $length); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | // Don't lock up other requests while processing |
161 | 161 | session_write_close(); |
162 | 162 | |
163 | - if ( $this->is_process_running() ) { |
|
163 | + if ($this->is_process_running()) { |
|
164 | 164 | // Background process already running. |
165 | 165 | wp_die(); |
166 | 166 | } |
167 | 167 | |
168 | - if ( $this->is_queue_empty() ) { |
|
168 | + if ($this->is_queue_empty()) { |
|
169 | 169 | // No data to process. |
170 | 170 | wp_die(); |
171 | 171 | } |
172 | 172 | |
173 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
173 | + check_ajax_referer($this->identifier, 'nonce'); |
|
174 | 174 | |
175 | 175 | $this->handle(); |
176 | 176 | |
@@ -188,20 +188,20 @@ discard block |
||
188 | 188 | $table = $wpdb->options; |
189 | 189 | $column = 'option_name'; |
190 | 190 | |
191 | - if ( is_multisite() ) { |
|
191 | + if (is_multisite()) { |
|
192 | 192 | $table = $wpdb->sitemeta; |
193 | 193 | $column = 'meta_key'; |
194 | 194 | } |
195 | 195 | |
196 | - $key = $this->identifier . '_batch_%'; |
|
196 | + $key = $this->identifier.'_batch_%'; |
|
197 | 197 | |
198 | - $count = $wpdb->get_var( $wpdb->prepare( " |
|
198 | + $count = $wpdb->get_var($wpdb->prepare(" |
|
199 | 199 | SELECT COUNT(*) |
200 | 200 | FROM {$table} |
201 | 201 | WHERE {$column} LIKE %s |
202 | - ", $key ) ); |
|
202 | + ", $key)); |
|
203 | 203 | |
204 | - return ! ( $count > 0 ); |
|
204 | + return !($count > 0); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * in a background process. |
212 | 212 | */ |
213 | 213 | protected function is_process_running() { |
214 | - if ( get_site_transient( $this->identifier . '_process_lock' ) ) { |
|
214 | + if (get_site_transient($this->identifier.'_process_lock')) { |
|
215 | 215 | // Process already running. |
216 | 216 | return true; |
217 | 217 | } |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | protected function lock_process() { |
230 | 230 | $this->start_time = time(); // Set start time of current process. |
231 | 231 | |
232 | - $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute |
|
233 | - $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration ); |
|
232 | + $lock_duration = (property_exists($this, 'queue_lock_time')) ? $this->queue_lock_time : 60; // 1 minute |
|
233 | + $lock_duration = apply_filters($this->identifier.'_queue_lock_time', $lock_duration); |
|
234 | 234 | |
235 | - set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); |
|
235 | + set_site_transient($this->identifier.'_process_lock', microtime(), $lock_duration); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @return $this |
244 | 244 | */ |
245 | 245 | protected function unlock_process() { |
246 | - delete_site_transient( $this->identifier . '_process_lock' ); |
|
246 | + delete_site_transient($this->identifier.'_process_lock'); |
|
247 | 247 | |
248 | 248 | return $this; |
249 | 249 | } |
@@ -261,26 +261,26 @@ discard block |
||
261 | 261 | $key_column = 'option_id'; |
262 | 262 | $value_column = 'option_value'; |
263 | 263 | |
264 | - if ( is_multisite() ) { |
|
264 | + if (is_multisite()) { |
|
265 | 265 | $table = $wpdb->sitemeta; |
266 | 266 | $column = 'meta_key'; |
267 | 267 | $key_column = 'meta_id'; |
268 | 268 | $value_column = 'meta_value'; |
269 | 269 | } |
270 | 270 | |
271 | - $key = $this->identifier . '_batch_%'; |
|
271 | + $key = $this->identifier.'_batch_%'; |
|
272 | 272 | |
273 | - $query = $wpdb->get_row( $wpdb->prepare( " |
|
273 | + $query = $wpdb->get_row($wpdb->prepare(" |
|
274 | 274 | SELECT * |
275 | 275 | FROM {$table} |
276 | 276 | WHERE {$column} LIKE %s |
277 | 277 | ORDER BY {$key_column} ASC |
278 | 278 | LIMIT 1 |
279 | - ", $key ) ); |
|
279 | + ", $key)); |
|
280 | 280 | |
281 | 281 | $batch = new stdClass(); |
282 | 282 | $batch->key = $query->$column; |
283 | - $batch->data = maybe_unserialize( $query->$value_column ); |
|
283 | + $batch->data = maybe_unserialize($query->$value_column); |
|
284 | 284 | |
285 | 285 | return $batch; |
286 | 286 | } |
@@ -297,33 +297,33 @@ discard block |
||
297 | 297 | do { |
298 | 298 | $batch = $this->get_batch(); |
299 | 299 | |
300 | - foreach ( $batch->data as $key => $value ) { |
|
301 | - $task = $this->task( $value ); |
|
300 | + foreach ($batch->data as $key => $value) { |
|
301 | + $task = $this->task($value); |
|
302 | 302 | |
303 | - if ( false !== $task ) { |
|
304 | - $batch->data[ $key ] = $task; |
|
303 | + if (false !== $task) { |
|
304 | + $batch->data[$key] = $task; |
|
305 | 305 | } else { |
306 | - unset( $batch->data[ $key ] ); |
|
306 | + unset($batch->data[$key]); |
|
307 | 307 | } |
308 | 308 | |
309 | - if ( $this->time_exceeded() || $this->memory_exceeded() ) { |
|
309 | + if ($this->time_exceeded() || $this->memory_exceeded()) { |
|
310 | 310 | // Batch limits reached. |
311 | 311 | break; |
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | 315 | // Update or delete current batch. |
316 | - if ( ! empty( $batch->data ) ) { |
|
317 | - $this->update( $batch->key, $batch->data ); |
|
316 | + if (!empty($batch->data)) { |
|
317 | + $this->update($batch->key, $batch->data); |
|
318 | 318 | } else { |
319 | - $this->delete( $batch->key ); |
|
319 | + $this->delete($batch->key); |
|
320 | 320 | } |
321 | - } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); |
|
321 | + } while (!$this->time_exceeded() && !$this->memory_exceeded() && !$this->is_queue_empty()); |
|
322 | 322 | |
323 | 323 | $this->unlock_process(); |
324 | 324 | |
325 | 325 | // Start next batch or complete process. |
326 | - if ( ! $this->is_queue_empty() ) { |
|
326 | + if (!$this->is_queue_empty()) { |
|
327 | 327 | $this->dispatch(); |
328 | 328 | } else { |
329 | 329 | $this->complete(); |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | */ |
343 | 343 | protected function memory_exceeded() { |
344 | 344 | $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory |
345 | - $current_memory = memory_get_usage( true ); |
|
345 | + $current_memory = memory_get_usage(true); |
|
346 | 346 | $return = false; |
347 | 347 | |
348 | - if ( $current_memory >= $memory_limit ) { |
|
348 | + if ($current_memory >= $memory_limit) { |
|
349 | 349 | $return = true; |
350 | 350 | } |
351 | 351 | |
352 | - return apply_filters( $this->identifier . '_memory_exceeded', $return ); |
|
352 | + return apply_filters($this->identifier.'_memory_exceeded', $return); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -358,19 +358,19 @@ discard block |
||
358 | 358 | * @return int |
359 | 359 | */ |
360 | 360 | protected function get_memory_limit() { |
361 | - if ( function_exists( 'ini_get' ) ) { |
|
362 | - $memory_limit = ini_get( 'memory_limit' ); |
|
361 | + if (function_exists('ini_get')) { |
|
362 | + $memory_limit = ini_get('memory_limit'); |
|
363 | 363 | } else { |
364 | 364 | // Sensible default. |
365 | 365 | $memory_limit = '128M'; |
366 | 366 | } |
367 | 367 | |
368 | - if ( ! $memory_limit || -1 === $memory_limit ) { |
|
368 | + if (!$memory_limit || -1 === $memory_limit) { |
|
369 | 369 | // Unlimited, set to 32GB. |
370 | 370 | $memory_limit = '32000M'; |
371 | 371 | } |
372 | 372 | |
373 | - return intval( $memory_limit ) * 1024 * 1024; |
|
373 | + return intval($memory_limit) * 1024 * 1024; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -382,14 +382,14 @@ discard block |
||
382 | 382 | * @return bool |
383 | 383 | */ |
384 | 384 | protected function time_exceeded() { |
385 | - $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds |
|
385 | + $finish = $this->start_time + apply_filters($this->identifier.'_default_time_limit', 20); // 20 seconds |
|
386 | 386 | $return = false; |
387 | 387 | |
388 | - if ( time() >= $finish ) { |
|
388 | + if (time() >= $finish) { |
|
389 | 389 | $return = true; |
390 | 390 | } |
391 | 391 | |
392 | - return apply_filters( $this->identifier . '_time_exceeded', $return ); |
|
392 | + return apply_filters($this->identifier.'_time_exceeded', $return); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -410,17 +410,17 @@ discard block |
||
410 | 410 | * @param mixed $schedules Schedules. |
411 | 411 | * @return mixed |
412 | 412 | */ |
413 | - public function schedule_cron_healthcheck( $schedules ) { |
|
414 | - $interval = apply_filters( $this->identifier . '_cron_interval', 5 ); |
|
413 | + public function schedule_cron_healthcheck($schedules) { |
|
414 | + $interval = apply_filters($this->identifier.'_cron_interval', 5); |
|
415 | 415 | |
416 | - if ( property_exists( $this, 'cron_interval' ) ) { |
|
417 | - $interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval_identifier ); |
|
416 | + if (property_exists($this, 'cron_interval')) { |
|
417 | + $interval = apply_filters($this->identifier.'_cron_interval', $this->cron_interval_identifier); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | // Adds every 5 minutes to the existing schedules. |
421 | - $schedules[ $this->identifier . '_cron_interval' ] = array( |
|
421 | + $schedules[$this->identifier.'_cron_interval'] = array( |
|
422 | 422 | 'interval' => MINUTE_IN_SECONDS * $interval, |
423 | - 'display' => sprintf( __( 'Every %d Minutes' ), $interval ), |
|
423 | + 'display' => sprintf(__('Every %d Minutes'), $interval), |
|
424 | 424 | ); |
425 | 425 | |
426 | 426 | return $schedules; |
@@ -433,12 +433,12 @@ discard block |
||
433 | 433 | * and data exists in the queue. |
434 | 434 | */ |
435 | 435 | public function handle_cron_healthcheck() { |
436 | - if ( $this->is_process_running() ) { |
|
436 | + if ($this->is_process_running()) { |
|
437 | 437 | // Background process already running. |
438 | 438 | exit; |
439 | 439 | } |
440 | 440 | |
441 | - if ( $this->is_queue_empty() ) { |
|
441 | + if ($this->is_queue_empty()) { |
|
442 | 442 | // No data to process. |
443 | 443 | $this->clear_scheduled_event(); |
444 | 444 | exit; |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * Schedule event |
454 | 454 | */ |
455 | 455 | protected function schedule_event() { |
456 | - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { |
|
457 | - wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier ); |
|
456 | + if (!wp_next_scheduled($this->cron_hook_identifier)) { |
|
457 | + wp_schedule_event(time(), $this->cron_interval_identifier, $this->cron_hook_identifier); |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
@@ -462,10 +462,10 @@ discard block |
||
462 | 462 | * Clear scheduled event |
463 | 463 | */ |
464 | 464 | protected function clear_scheduled_event() { |
465 | - $timestamp = wp_next_scheduled( $this->cron_hook_identifier ); |
|
465 | + $timestamp = wp_next_scheduled($this->cron_hook_identifier); |
|
466 | 466 | |
467 | - if ( $timestamp ) { |
|
468 | - wp_unschedule_event( $timestamp, $this->cron_hook_identifier ); |
|
467 | + if ($timestamp) { |
|
468 | + wp_unschedule_event($timestamp, $this->cron_hook_identifier); |
|
469 | 469 | } |
470 | 470 | } |
471 | 471 | |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | * |
477 | 477 | */ |
478 | 478 | public function cancel_process() { |
479 | - if ( ! $this->is_queue_empty() ) { |
|
479 | + if (!$this->is_queue_empty()) { |
|
480 | 480 | $batch = $this->get_batch(); |
481 | 481 | |
482 | - $this->delete( $batch->key ); |
|
482 | + $this->delete($batch->key); |
|
483 | 483 | |
484 | - wp_clear_scheduled_hook( $this->cron_hook_identifier ); |
|
484 | + wp_clear_scheduled_hook($this->cron_hook_identifier); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | } |
@@ -498,6 +498,6 @@ discard block |
||
498 | 498 | * |
499 | 499 | * @return mixed |
500 | 500 | */ |
501 | - abstract protected function task( $item ); |
|
501 | + abstract protected function task($item); |
|
502 | 502 | |
503 | 503 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package GeoDirectory |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * GeoDir_Privacy_Erasers Class. |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | * @param int $page Page. |
23 | 23 | * @return array An array of personal data in name value pairs |
24 | 24 | */ |
25 | - public static function post_data_eraser( $email_address, $page ) { |
|
25 | + public static function post_data_eraser($email_address, $page) { |
|
26 | 26 | $page = (int) $page; |
27 | - $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data. |
|
27 | + $user = get_user_by('email', $email_address); // Check if user has an ID in the DB to load stored personal data. |
|
28 | 28 | |
29 | - $erasure_enabled = get_option( 'geodir_erasure_request_removes_post_data', false ); |
|
29 | + $erasure_enabled = get_option('geodir_erasure_request_removes_post_data', false); |
|
30 | 30 | |
31 | 31 | $response = array( |
32 | 32 | 'items_removed' => false, |
@@ -38,30 +38,30 @@ discard block |
||
38 | 38 | $post_query = array( |
39 | 39 | 'limit' => 10, |
40 | 40 | 'page' => $page, |
41 | - 'user' => array( $email_address ), |
|
41 | + 'user' => array($email_address), |
|
42 | 42 | ); |
43 | 43 | |
44 | - if ( $user instanceof WP_User ) { |
|
44 | + if ($user instanceof WP_User) { |
|
45 | 45 | $post_query['user'][] = (int) $user->ID; |
46 | 46 | } |
47 | 47 | |
48 | 48 | $posts = array(); |
49 | 49 | |
50 | - if ( 0 < count( $posts ) ) { |
|
51 | - foreach ( $posts as $post ) { |
|
52 | - if ( apply_filters( 'geodir_privacy_erase_post_personal_data', $erasure_enabled, $post ) ) { |
|
53 | - self::remove_post_personal_data( $post ); |
|
50 | + if (0 < count($posts)) { |
|
51 | + foreach ($posts as $post) { |
|
52 | + if (apply_filters('geodir_privacy_erase_post_personal_data', $erasure_enabled, $post)) { |
|
53 | + self::remove_post_personal_data($post); |
|
54 | 54 | |
55 | 55 | /* Translators: %s Post number. */ |
56 | - $response['messages'][] = sprintf( __( 'Removed personal data from post %s.', 'geodirectory' ), $post->ID ); |
|
56 | + $response['messages'][] = sprintf(__('Removed personal data from post %s.', 'geodirectory'), $post->ID); |
|
57 | 57 | $response['items_removed'] = true; |
58 | 58 | } else { |
59 | 59 | /* Translators: %s Post number. */ |
60 | - $response['messages'][] = sprintf( __( 'Personal data within post %s has been retained.', 'geodirectory' ), $post->ID ); |
|
60 | + $response['messages'][] = sprintf(__('Personal data within post %s has been retained.', 'geodirectory'), $post->ID); |
|
61 | 61 | $response['items_retained'] = true; |
62 | 62 | } |
63 | 63 | } |
64 | - $response['done'] = 10 > count( $posts ); |
|
64 | + $response['done'] = 10 > count($posts); |
|
65 | 65 | } else { |
66 | 66 | $response['done'] = true; |
67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @param WP_Post $post Post object. |
78 | 78 | */ |
79 | - public static function remove_post_personal_data( $post ) { |
|
79 | + public static function remove_post_personal_data($post) { |
|
80 | 80 | $anonymized_data = array(); |
81 | 81 | |
82 | 82 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @since 1.6.26 |
86 | 86 | * @param WP_Post $post A post object. |
87 | 87 | */ |
88 | - do_action( 'geodir_privacy_before_remove_post_personal_data', $post ); |
|
88 | + do_action('geodir_privacy_before_remove_post_personal_data', $post); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Expose props and data types we'll be anonymizing. |
@@ -94,23 +94,23 @@ discard block |
||
94 | 94 | * @param array $props Keys are the prop names, values are the data type we'll be passing to wp_privacy_anonymize_data(). |
95 | 95 | * @param WP_Post $post A post object. |
96 | 96 | */ |
97 | - $props_to_remove = apply_filters( 'geodir_privacy_remove_post_personal_data_props', array( |
|
97 | + $props_to_remove = apply_filters('geodir_privacy_remove_post_personal_data_props', array( |
|
98 | 98 | 'phone' => 'phone', |
99 | 99 | 'email' => 'email' |
100 | 100 | // TODO more fields |
101 | - ), $post ); |
|
101 | + ), $post); |
|
102 | 102 | |
103 | - if ( ! empty( $props_to_remove ) && is_array( $props_to_remove ) ) { |
|
104 | - foreach ( $props_to_remove as $prop => $data_type ) { |
|
103 | + if (!empty($props_to_remove) && is_array($props_to_remove)) { |
|
104 | + foreach ($props_to_remove as $prop => $data_type) { |
|
105 | 105 | // Get the current value in edit context. |
106 | - $value = isset( $post->{$prop} ) ? $post->{$prop} : ''; |
|
106 | + $value = isset($post->{$prop} ) ? $post->{$prop} : ''; |
|
107 | 107 | |
108 | 108 | // If the value is empty, it does not need to be anonymized. |
109 | - if ( empty( $value ) || empty( $data_type ) ) { |
|
109 | + if (empty($value) || empty($data_type)) { |
|
110 | 110 | continue; |
111 | 111 | } |
112 | 112 | |
113 | - $anon_value = wp_privacy_anonymize_data( $data_type, $value ); |
|
113 | + $anon_value = wp_privacy_anonymize_data($data_type, $value); |
|
114 | 114 | |
115 | 115 | /** |
116 | 116 | * Expose a way to control the anonymized value of a prop via 3rd party code. |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @param string $data_type Type of data. |
123 | 123 | * @param WP_Post $post The post object. |
124 | 124 | */ |
125 | - $anonymized_data[ $prop ] = apply_filters( 'geodir_privacy_remove_post_personal_data_prop_value', $anon_value, $prop, $value, $data_type, $post ); |
|
125 | + $anonymized_data[$prop] = apply_filters('geodir_privacy_remove_post_personal_data_prop_value', $anon_value, $prop, $value, $data_type, $post); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -137,6 +137,6 @@ discard block |
||
137 | 137 | * @since 1.6.26 |
138 | 138 | * @param WP_Post $post The post object. |
139 | 139 | */ |
140 | - do_action( 'geodir_privacy_remove_post_personal_data', $post ); |
|
140 | + do_action('geodir_privacy_remove_post_personal_data', $post); |
|
141 | 141 | } |
142 | 142 | } |