@@ -285,6 +285,10 @@ |
||
285 | 285 | return apply_filters( 'geodir_privacy_allow_erase_favorites_data', $allow ); |
286 | 286 | } |
287 | 287 | |
288 | + /** |
|
289 | + * @param string $email_address |
|
290 | + * @param integer $page |
|
291 | + */ |
|
288 | 292 | public static function favorites_by_user( $email_address, $page ) { |
289 | 293 | if ( empty( $email_address ) ) { |
290 | 294 | return array(); |
@@ -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 Class. |
@@ -17,44 +17,44 @@ discard block |
||
17 | 17 | * Init - hook into events. |
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | - parent::__construct( __( 'GeoDirectory', 'geodirectory' ) ); |
|
20 | + parent::__construct(__('GeoDirectory', 'geodirectory')); |
|
21 | 21 | |
22 | 22 | // Include supporting classes. |
23 | - include_once( 'class-geodir-privacy-erasers.php' ); |
|
24 | - include_once( 'class-geodir-privacy-exporters.php' ); |
|
23 | + include_once('class-geodir-privacy-erasers.php'); |
|
24 | + include_once('class-geodir-privacy-exporters.php'); |
|
25 | 25 | |
26 | - $gd_post_types = geodir_get_posttypes( 'object' ); |
|
26 | + $gd_post_types = geodir_get_posttypes('object'); |
|
27 | 27 | |
28 | - if ( ! empty( $gd_post_types ) ) { |
|
29 | - foreach ( $gd_post_types as $post_type => $info ) { |
|
28 | + if (!empty($gd_post_types)) { |
|
29 | + foreach ($gd_post_types as $post_type => $info) { |
|
30 | 30 | $name = $info->labels->name; |
31 | 31 | |
32 | - if ( self::allow_export_post_type_data( $post_type ) ) { |
|
32 | + if (self::allow_export_post_type_data($post_type)) { |
|
33 | 33 | // This hook registers GeoDirectory data exporters. |
34 | - $this->add_exporter( 'geodirectory-post-' . $post_type, wp_sprintf( __( 'User %s', 'geodirectory' ), $name ), array( 'GeoDir_Privacy_Exporters', 'post_data_exporter' ) ); |
|
34 | + $this->add_exporter('geodirectory-post-'.$post_type, wp_sprintf(__('User %s', 'geodirectory'), $name), array('GeoDir_Privacy_Exporters', 'post_data_exporter')); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | // Handles custom anonomization types not included in core. |
40 | - add_filter( 'wp_privacy_anonymize_data', array( $this, 'anonymize_custom_data_types' ), 10, 3 ); |
|
40 | + add_filter('wp_privacy_anonymize_data', array($this, 'anonymize_custom_data_types'), 10, 3); |
|
41 | 41 | |
42 | - if ( self::allow_export_reviews_data() ) { |
|
42 | + if (self::allow_export_reviews_data()) { |
|
43 | 43 | // Review data export |
44 | - add_filter( 'wp_privacy_personal_data_export_page', array( 'GeoDir_Privacy_Exporters', 'review_data_exporter' ), 10, 7 ); |
|
44 | + add_filter('wp_privacy_personal_data_export_page', array('GeoDir_Privacy_Exporters', 'review_data_exporter'), 10, 7); |
|
45 | 45 | } |
46 | 46 | |
47 | - if ( self::allow_erase_reviews_data() ) { |
|
47 | + if (self::allow_erase_reviews_data()) { |
|
48 | 48 | // Review data erase |
49 | - $this->add_eraser( 'geodirectory-post-reviews', __( 'User Listing Reviews', 'geodirectory' ), array( 'GeoDir_Privacy_Erasers', 'review_data_eraser' ) ); |
|
49 | + $this->add_eraser('geodirectory-post-reviews', __('User Listing Reviews', 'geodirectory'), array('GeoDir_Privacy_Erasers', 'review_data_eraser')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // Post favorites |
53 | - if ( self::allow_export_favorites_data() ) { |
|
54 | - $this->add_exporter( 'geodirectory-post-favorites', __( 'GeoDirectory Favorite Listings', 'geodirectory' ), array( 'GeoDir_Privacy_Exporters', 'favorites_data_exporter' ) ); |
|
53 | + if (self::allow_export_favorites_data()) { |
|
54 | + $this->add_exporter('geodirectory-post-favorites', __('GeoDirectory Favorite Listings', 'geodirectory'), array('GeoDir_Privacy_Exporters', 'favorites_data_exporter')); |
|
55 | 55 | } |
56 | - if ( self::allow_erase_favorites_data() ) { |
|
57 | - $this->add_eraser( 'geodirectory-post-favorites', __( 'GeoDirectory Favorite Listings', 'geodirectory' ), array( 'GeoDir_Privacy_Erasers', 'favorites_data_eraser' ) ); |
|
56 | + if (self::allow_erase_favorites_data()) { |
|
57 | + $this->add_eraser('geodirectory-post-favorites', __('GeoDirectory Favorite Listings', 'geodirectory'), array('GeoDir_Privacy_Erasers', 'favorites_data_eraser')); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -67,35 +67,35 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function get_privacy_message() { |
69 | 69 | |
70 | - $content = '<h2>' . __( 'Listings', 'geodirectory' ) . '</h2>' . |
|
71 | - '<p>' . __( 'We collect information about you during the add listing process on our site. This information may include, but is not limited to, your name, email address, phone number, address, locations details including GPS co-ordinates and any other details that might be requested from you for the purpose of adding your business/personal listings.', 'geodirectory' ) . '</p>' . |
|
72 | - '<p>' . __( 'Handling this data also allows us to:', 'geodirectory' ) . '</p>' . |
|
73 | - '<ul>' . |
|
74 | - '<li>' . __( '- Display this information in a public facing manner (such as a web page or API request) and allow website users to search and view submitted listing information.', 'geodirectory' ) . '</li>' . |
|
75 | - '<li>' . __( '- Send you important account/order/service information.', 'geodirectory' ) . '</li>' . |
|
76 | - '<li>' . __( '- Provide a way for users to contact your listing via the provided contact information.', 'geodirectory' ) . '</li>' . |
|
77 | - '<li>' . __( '- Notify you of user interactions such as but not limited to review and contact notifications.', 'geodirectory' ) . '</li>' . |
|
78 | - '<li>' . __( '- Respond to your queries or complaints.', 'geodirectory' ) . '</li>' . |
|
79 | - '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'geodirectory' ) . '</li>' . |
|
80 | - '</ul>' . |
|
81 | - '<h2>' . __( 'Reviews', 'geodirectory' ) . '</h2>' . |
|
82 | - '<p>' . __( 'We collect information about you during the leave a review process on our site. This information may include, but is not limited to, your name, email address, IP address, website url, image(s), review ratings and review texts.', 'geodirectory' ) . '</p>' . |
|
83 | - '<p>' . __( 'Handling this data also allows us to:', 'geodirectory' ) . '</p>' . |
|
84 | - '<ul>' . |
|
85 | - '<li>' . __( '- Display this information in a public facing manner (such as a web page or API request).', 'geodirectory' ) . '</li>' . |
|
86 | - '<li>' . __( '- Notify you of interactions such as approval or rejection of your review.', 'geodirectory' ) . '</li>' . |
|
87 | - '<li>' . __( '- Notify you of user interactions such as reply notifications.', 'geodirectory' ) . '</li>' . |
|
88 | - '</ul>' . |
|
89 | - '<h2>' . __( 'Listing contact forms', 'geodirectory' ) . '</h2>' . |
|
90 | - '<p>' . __( 'We may collect information about you when you submit a contact form to a listing. This information may include, but is not limited to, your name, email address, IP address and contact texts.', 'geodirectory' ) . '</p>' . |
|
91 | - '<p>' . __( 'Handling this data also allows us to:', 'geodirectory' ) . '</p>' . |
|
92 | - '<ul>' . |
|
93 | - '<li>' . __( '- Send your contact message and details to the listings contact email.', 'geodirectory' ) . '</li>' . |
|
94 | - '<li>' . __( '- Monitor the contact system for spam and abuse.', 'geodirectory' ) . '</li>' . |
|
70 | + $content = '<h2>'.__('Listings', 'geodirectory').'</h2>'. |
|
71 | + '<p>'.__('We collect information about you during the add listing process on our site. This information may include, but is not limited to, your name, email address, phone number, address, locations details including GPS co-ordinates and any other details that might be requested from you for the purpose of adding your business/personal listings.', 'geodirectory').'</p>'. |
|
72 | + '<p>'.__('Handling this data also allows us to:', 'geodirectory').'</p>'. |
|
73 | + '<ul>'. |
|
74 | + '<li>'.__('- Display this information in a public facing manner (such as a web page or API request) and allow website users to search and view submitted listing information.', 'geodirectory').'</li>'. |
|
75 | + '<li>'.__('- Send you important account/order/service information.', 'geodirectory').'</li>'. |
|
76 | + '<li>'.__('- Provide a way for users to contact your listing via the provided contact information.', 'geodirectory').'</li>'. |
|
77 | + '<li>'.__('- Notify you of user interactions such as but not limited to review and contact notifications.', 'geodirectory').'</li>'. |
|
78 | + '<li>'.__('- Respond to your queries or complaints.', 'geodirectory').'</li>'. |
|
79 | + '<li>'.__('- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'geodirectory').'</li>'. |
|
80 | + '</ul>'. |
|
81 | + '<h2>'.__('Reviews', 'geodirectory').'</h2>'. |
|
82 | + '<p>'.__('We collect information about you during the leave a review process on our site. This information may include, but is not limited to, your name, email address, IP address, website url, image(s), review ratings and review texts.', 'geodirectory').'</p>'. |
|
83 | + '<p>'.__('Handling this data also allows us to:', 'geodirectory').'</p>'. |
|
84 | + '<ul>'. |
|
85 | + '<li>'.__('- Display this information in a public facing manner (such as a web page or API request).', 'geodirectory').'</li>'. |
|
86 | + '<li>'.__('- Notify you of interactions such as approval or rejection of your review.', 'geodirectory').'</li>'. |
|
87 | + '<li>'.__('- Notify you of user interactions such as reply notifications.', 'geodirectory').'</li>'. |
|
88 | + '</ul>'. |
|
89 | + '<h2>'.__('Listing contact forms', 'geodirectory').'</h2>'. |
|
90 | + '<p>'.__('We may collect information about you when you submit a contact form to a listing. This information may include, but is not limited to, your name, email address, IP address and contact texts.', 'geodirectory').'</p>'. |
|
91 | + '<p>'.__('Handling this data also allows us to:', 'geodirectory').'</p>'. |
|
92 | + '<ul>'. |
|
93 | + '<li>'.__('- Send your contact message and details to the listings contact email.', 'geodirectory').'</li>'. |
|
94 | + '<li>'.__('- Monitor the contact system for spam and abuse.', 'geodirectory').'</li>'. |
|
95 | 95 | '</ul>'; |
96 | 96 | |
97 | 97 | |
98 | - return apply_filters( 'geodir_privacy_policy_content', $content) ; |
|
98 | + return apply_filters('geodir_privacy_policy_content', $content); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * @param string $data The data being anonymized. |
107 | 107 | * @return string Anonymized string. |
108 | 108 | */ |
109 | - public function anonymize_custom_data_types( $anonymous, $type, $data ) { |
|
110 | - switch ( $type ) { |
|
109 | + public function anonymize_custom_data_types($anonymous, $type, $data) { |
|
110 | + switch ($type) { |
|
111 | 111 | case 'phone': |
112 | - $anonymous = preg_replace( '/\d/u', '0', $data ); |
|
112 | + $anonymous = preg_replace('/\d/u', '0', $data); |
|
113 | 113 | break; |
114 | 114 | case 'numeric_id': |
115 | 115 | $anonymous = 0; |
@@ -122,46 +122,46 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | public static function personal_data_exporter_key() { |
125 | - if ( ! wp_doing_ajax() ) { |
|
125 | + if (!wp_doing_ajax()) { |
|
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | |
129 | - if ( empty( $_POST['id'] ) ) { |
|
129 | + if (empty($_POST['id'])) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | $request_id = (int) $_POST['id']; |
133 | 133 | |
134 | - if ( $request_id < 1 ) { |
|
134 | + if ($request_id < 1) { |
|
135 | 135 | return false; |
136 | 136 | } |
137 | 137 | |
138 | - if ( ! current_user_can( 'export_others_personal_data' ) ) { |
|
138 | + if (!current_user_can('export_others_personal_data')) { |
|
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | |
142 | 142 | // Get the request data. |
143 | - $request = wp_get_user_request_data( $request_id ); |
|
143 | + $request = wp_get_user_request_data($request_id); |
|
144 | 144 | |
145 | - if ( ! $request || 'export_personal_data' !== $request->action_name ) { |
|
145 | + if (!$request || 'export_personal_data' !== $request->action_name) { |
|
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | |
149 | 149 | $email_address = $request->email; |
150 | - if ( ! is_email( $email_address ) ) { |
|
150 | + if (!is_email($email_address)) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - if ( ! isset( $_POST['exporter'] ) ) { |
|
154 | + if (!isset($_POST['exporter'])) { |
|
155 | 155 | return false; |
156 | 156 | } |
157 | 157 | $exporter_index = (int) $_POST['exporter']; |
158 | 158 | |
159 | - if ( ! isset( $_POST['page'] ) ) { |
|
159 | + if (!isset($_POST['page'])) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | $page = (int) $_POST['page']; |
163 | 163 | |
164 | - $send_as_email = isset( $_POST['sendAsEmail'] ) ? ( 'true' === $_POST['sendAsEmail'] ) : false; |
|
164 | + $send_as_email = isset($_POST['sendAsEmail']) ? ('true' === $_POST['sendAsEmail']) : false; |
|
165 | 165 | |
166 | 166 | /** |
167 | 167 | * Filters the array of exporter callbacks. |
@@ -182,37 +182,37 @@ discard block |
||
182 | 182 | * } |
183 | 183 | * } |
184 | 184 | */ |
185 | - $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); |
|
185 | + $exporters = apply_filters('wp_privacy_personal_data_exporters', array()); |
|
186 | 186 | |
187 | - if ( ! is_array( $exporters ) ) { |
|
187 | + if (!is_array($exporters)) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
191 | 191 | // Do we have any registered exporters? |
192 | - if ( 0 < count( $exporters ) ) { |
|
193 | - if ( $exporter_index < 1 ) { |
|
192 | + if (0 < count($exporters)) { |
|
193 | + if ($exporter_index < 1) { |
|
194 | 194 | return false; |
195 | 195 | } |
196 | 196 | |
197 | - if ( $exporter_index > count( $exporters ) ) { |
|
197 | + if ($exporter_index > count($exporters)) { |
|
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | |
201 | - if ( $page < 1 ) { |
|
201 | + if ($page < 1) { |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | |
205 | - $exporter_keys = array_keys( $exporters ); |
|
206 | - $exporter_key = $exporter_keys[ $exporter_index - 1 ]; |
|
207 | - $exporter = $exporters[ $exporter_key ]; |
|
205 | + $exporter_keys = array_keys($exporters); |
|
206 | + $exporter_key = $exporter_keys[$exporter_index - 1]; |
|
207 | + $exporter = $exporters[$exporter_key]; |
|
208 | 208 | |
209 | - if ( ! is_array( $exporter ) || empty( $exporter_key ) ) { |
|
209 | + if (!is_array($exporter) || empty($exporter_key)) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | - if ( ! array_key_exists( 'exporter_friendly_name', $exporter ) ) { |
|
212 | + if (!array_key_exists('exporter_friendly_name', $exporter)) { |
|
213 | 213 | return false; |
214 | 214 | } |
215 | - if ( ! array_key_exists( 'callback', $exporter ) ) { |
|
215 | + if (!array_key_exists('callback', $exporter)) { |
|
216 | 216 | return false; |
217 | 217 | } |
218 | 218 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @param int $request_id The privacy request post ID associated with this request. |
231 | 231 | * @param bool $send_as_email Whether the final results of the export should be emailed to the user. |
232 | 232 | */ |
233 | - $exporter_key = apply_filters( 'geodir_privacy_personal_data_exporter', $exporter_key, $exporter, $exporter_index, $email_address, $page, $request_id, $send_as_email ); |
|
233 | + $exporter_key = apply_filters('geodir_privacy_personal_data_exporter', $exporter_key, $exporter, $exporter_index, $email_address, $page, $request_id, $send_as_email); |
|
234 | 234 | |
235 | 235 | return $exporter_key; |
236 | 236 | } |
@@ -238,66 +238,66 @@ discard block |
||
238 | 238 | public static function exporter_post_type() { |
239 | 239 | $exporter_key = self::personal_data_exporter_key(); |
240 | 240 | |
241 | - if ( empty( $exporter_key ) ) { |
|
241 | + if (empty($exporter_key)) { |
|
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | |
245 | - if ( strpos( $exporter_key, 'geodirectory-post-' ) !== 0 ) { |
|
245 | + if (strpos($exporter_key, 'geodirectory-post-') !== 0) { |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | |
249 | - $post_type = str_replace( 'geodirectory-post-', '', $exporter_key ); |
|
249 | + $post_type = str_replace('geodirectory-post-', '', $exporter_key); |
|
250 | 250 | |
251 | - if ( $post_type != '' && in_array( $post_type, geodir_get_posttypes() ) ) { |
|
251 | + if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) { |
|
252 | 252 | return $post_type; |
253 | 253 | } |
254 | 254 | |
255 | 255 | return false; |
256 | 256 | } |
257 | 257 | |
258 | - public static function allow_export_post_type_data( $post_type ) { |
|
258 | + public static function allow_export_post_type_data($post_type) { |
|
259 | 259 | $allow = true; |
260 | 260 | |
261 | - return apply_filters( 'geodir_privacy_allow_export_post_type_data', $allow, $post_type ); |
|
261 | + return apply_filters('geodir_privacy_allow_export_post_type_data', $allow, $post_type); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | public static function allow_export_reviews_data() { |
265 | 265 | $allow = true; |
266 | 266 | |
267 | - return apply_filters( 'geodir_privacy_allow_export_reviews_data', $allow ); |
|
267 | + return apply_filters('geodir_privacy_allow_export_reviews_data', $allow); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | public static function allow_erase_reviews_data() { |
271 | 271 | $allow = true; |
272 | 272 | |
273 | - return apply_filters( 'geodir_privacy_allow_erase_reviews_data', $allow ); |
|
273 | + return apply_filters('geodir_privacy_allow_erase_reviews_data', $allow); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | public static function allow_export_favorites_data() { |
277 | 277 | $allow = true; |
278 | 278 | |
279 | - return apply_filters( 'geodir_privacy_allow_export_favorites_data', $allow ); |
|
279 | + return apply_filters('geodir_privacy_allow_export_favorites_data', $allow); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | public static function allow_erase_favorites_data() { |
283 | 283 | $allow = true; |
284 | 284 | |
285 | - return apply_filters( 'geodir_privacy_allow_erase_favorites_data', $allow ); |
|
285 | + return apply_filters('geodir_privacy_allow_erase_favorites_data', $allow); |
|
286 | 286 | } |
287 | 287 | |
288 | - public static function favorites_by_user( $email_address, $page ) { |
|
289 | - if ( empty( $email_address ) ) { |
|
288 | + public static function favorites_by_user($email_address, $page) { |
|
289 | + if (empty($email_address)) { |
|
290 | 290 | return array(); |
291 | 291 | } |
292 | 292 | |
293 | - $user = get_user_by( 'email', $email_address ); |
|
294 | - if ( empty( $user ) ) { |
|
293 | + $user = get_user_by('email', $email_address); |
|
294 | + if (empty($user)) { |
|
295 | 295 | return array(); |
296 | 296 | } |
297 | 297 | |
298 | - $favourites = geodir_get_user_favourites( $user->ID ); |
|
298 | + $favourites = geodir_get_user_favourites($user->ID); |
|
299 | 299 | |
300 | - return ( ! empty( $favourites ) && is_array( $favourites ) ? $favourites : array() ); |
|
300 | + return (!empty($favourites) && is_array($favourites) ? $favourites : array()); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 |
@@ -159,12 +159,12 @@ |
||
159 | 159 | $messages = array(); |
160 | 160 | |
161 | 161 | $site_id = ''; |
162 | - if ( is_multisite() ) { |
|
163 | - $blog_id = get_current_blog_id(); |
|
164 | - if ( $blog_id && $blog_id != '1' ) { |
|
162 | + if ( is_multisite() ) { |
|
163 | + $blog_id = get_current_blog_id(); |
|
164 | + if ( $blog_id && $blog_id != '1' ) { |
|
165 | 165 | $site_id = '_' . $blog_id; |
166 | 166 | } |
167 | - } |
|
167 | + } |
|
168 | 168 | |
169 | 169 | if ( delete_user_meta( $user->ID, 'gd_user_favourite_post' . $site_id ) ) { |
170 | 170 | $messages[] = __( 'Removed "Favorite Listings" data from user.', 'geodirectory' ); |
@@ -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,7 +22,7 @@ discard block |
||
22 | 22 | * @param int $page Review page. |
23 | 23 | * @return array |
24 | 24 | */ |
25 | - public static function review_data_eraser( $email_address, $page ) { |
|
25 | + public static function review_data_eraser($email_address, $page) { |
|
26 | 26 | global $wpdb; |
27 | 27 | |
28 | 28 | $response = array( |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | 'done' => true, |
33 | 33 | ); |
34 | 34 | |
35 | - if ( empty( $email_address ) ) { |
|
35 | + if (empty($email_address)) { |
|
36 | 36 | return $response; |
37 | 37 | } |
38 | 38 | |
@@ -40,18 +40,18 @@ discard block |
||
40 | 40 | $items_removed = false; |
41 | 41 | $items_retained = false; |
42 | 42 | |
43 | - $reviews = self::reviews_by_author( $email_address, $page ); |
|
43 | + $reviews = self::reviews_by_author($email_address, $page); |
|
44 | 44 | |
45 | - if ( empty( $reviews ) ) { |
|
45 | + if (empty($reviews)) { |
|
46 | 46 | return $response; |
47 | 47 | } |
48 | 48 | |
49 | - $messages = array(); |
|
49 | + $messages = array(); |
|
50 | 50 | |
51 | - foreach ( $reviews as $review ) { |
|
51 | + foreach ($reviews as $review) { |
|
52 | 52 | $anonymized_review = array(); |
53 | 53 | $anonymized_review['user_id'] = 0; |
54 | - $anonymized_review['rating_ip'] = wp_privacy_anonymize_data( 'ip', $review->rating_ip ); |
|
54 | + $anonymized_review['rating_ip'] = wp_privacy_anonymize_data('ip', $review->rating_ip); |
|
55 | 55 | |
56 | 56 | $review_id = (int) $review->id; |
57 | 57 | |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * @param object $review Review object. |
66 | 66 | * @param array $anonymized_review Anonymized review data. |
67 | 67 | */ |
68 | - $anon_message = apply_filters( 'geodir_anonymize_post_review', true, $review, $anonymized_review ); |
|
68 | + $anon_message = apply_filters('geodir_anonymize_post_review', true, $review, $anonymized_review); |
|
69 | 69 | |
70 | - if ( true !== $anon_message ) { |
|
71 | - if ( $anon_message && is_string( $anon_message ) ) { |
|
72 | - $messages[] = esc_html( $anon_message ); |
|
70 | + if (true !== $anon_message) { |
|
71 | + if ($anon_message && is_string($anon_message)) { |
|
72 | + $messages[] = esc_html($anon_message); |
|
73 | 73 | } else { |
74 | 74 | /* translators: %d: Review ID */ |
75 | - $messages[] = sprintf( __( 'Review %d contains personal data but could not be anonymized.', 'geodirectory' ), $review_id ); |
|
75 | + $messages[] = sprintf(__('Review %d contains personal data but could not be anonymized.', 'geodirectory'), $review_id); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $items_retained = true; |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | 'id' => $review_id, |
85 | 85 | ); |
86 | 86 | |
87 | - $updated = $wpdb->update( GEODIR_REVIEW_TABLE, $anonymized_review, $args ); |
|
87 | + $updated = $wpdb->update(GEODIR_REVIEW_TABLE, $anonymized_review, $args); |
|
88 | 88 | |
89 | - if ( $updated ) { |
|
89 | + if ($updated) { |
|
90 | 90 | $items_removed = true; |
91 | 91 | } else { |
92 | 92 | $items_retained = true; |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | - $done = count( $reviews ) < $number; |
|
96 | + $done = count($reviews) < $number; |
|
97 | 97 | |
98 | 98 | return array( |
99 | 99 | 'items_removed' => $items_removed, |
@@ -103,29 +103,29 @@ discard block |
||
103 | 103 | ); |
104 | 104 | } |
105 | 105 | |
106 | - public static function reviews_by_author( $email_address, $page, $posts_per_page = 10 ) { |
|
106 | + public static function reviews_by_author($email_address, $page, $posts_per_page = 10) { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | - if ( empty( $email_address ) || empty( $page ) ) { |
|
109 | + if (empty($email_address) || empty($page)) { |
|
110 | 110 | return array(); |
111 | 111 | } |
112 | 112 | |
113 | - $user = get_user_by( 'email', $email_address ); |
|
114 | - if ( empty( $user ) ) { |
|
113 | + $user = get_user_by('email', $email_address); |
|
114 | + if (empty($user)) { |
|
115 | 115 | return array(); |
116 | 116 | } |
117 | 117 | |
118 | - if ( absint( $page ) < 1 ) { |
|
118 | + if (absint($page) < 1) { |
|
119 | 119 | $page = 1; |
120 | 120 | } |
121 | 121 | |
122 | - $limit = absint( ( $page - 1 ) * $posts_per_page ) . ", " . $posts_per_page; |
|
122 | + $limit = absint(($page - 1) * $posts_per_page).", ".$posts_per_page; |
|
123 | 123 | |
124 | - $query = $wpdb->prepare( "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d ORDER BY comment_id ASC LIMIT " . $limit, array( $user->ID ) ); |
|
124 | + $query = $wpdb->prepare("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE user_id = %d ORDER BY comment_id ASC LIMIT ".$limit, array($user->ID)); |
|
125 | 125 | |
126 | - $reviews = $wpdb->get_results( $query ); |
|
126 | + $reviews = $wpdb->get_results($query); |
|
127 | 127 | |
128 | - return apply_filters( 'geodir_privacy_review_data_eraser_reviews', $reviews, $email_address, $user, $page ); |
|
128 | + return apply_filters('geodir_privacy_review_data_eraser_reviews', $reviews, $email_address, $user, $page); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param int $page Page number. |
138 | 138 | * @return array |
139 | 139 | */ |
140 | - public static function favorites_data_eraser( $email_address, $page ) { |
|
140 | + public static function favorites_data_eraser($email_address, $page) { |
|
141 | 141 | $response = array( |
142 | 142 | 'items_removed' => false, |
143 | 143 | 'items_retained' => false, |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | 'done' => true, |
146 | 146 | ); |
147 | 147 | |
148 | - if ( empty( $email_address ) ) { |
|
148 | + if (empty($email_address)) { |
|
149 | 149 | return $response; |
150 | 150 | } |
151 | 151 | |
152 | - $user = get_user_by( 'email', $email_address ); |
|
153 | - if ( empty( $user ) ) { |
|
152 | + $user = get_user_by('email', $email_address); |
|
153 | + if (empty($user)) { |
|
154 | 154 | return $response; |
155 | 155 | } |
156 | 156 | |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | $messages = array(); |
160 | 160 | |
161 | 161 | $site_id = ''; |
162 | - if ( is_multisite() ) { |
|
162 | + if (is_multisite()) { |
|
163 | 163 | $blog_id = get_current_blog_id(); |
164 | - if ( $blog_id && $blog_id != '1' ) { |
|
165 | - $site_id = '_' . $blog_id; |
|
164 | + if ($blog_id && $blog_id != '1') { |
|
165 | + $site_id = '_'.$blog_id; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | - if ( delete_user_meta( $user->ID, 'gd_user_favourite_post' . $site_id ) ) { |
|
170 | - $messages[] = __( 'Removed "Favorite Listings" data from user.', 'geodirectory' ); |
|
169 | + if (delete_user_meta($user->ID, 'gd_user_favourite_post'.$site_id)) { |
|
170 | + $messages[] = __('Removed "Favorite Listings" data from user.', 'geodirectory'); |
|
171 | 171 | $items_removed = true; |
172 | 172 | } |
173 | 173 |
@@ -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_Exporters Class. |
@@ -23,32 +23,32 @@ discard block |
||
23 | 23 | * @param int $page Page. |
24 | 24 | * @return array An array of personal data in name value pairs |
25 | 25 | */ |
26 | - public static function post_data_exporter( $email_address, $page ) { |
|
27 | - $post_type = GeoDir_Privacy::exporter_post_type(); |
|
26 | + public static function post_data_exporter($email_address, $page) { |
|
27 | + $post_type = GeoDir_Privacy::exporter_post_type(); |
|
28 | 28 | |
29 | 29 | $done = false; |
30 | 30 | $page = (int) $page; |
31 | 31 | $data_to_export = array(); |
32 | 32 | |
33 | - $posts = self::posts_by_author( $email_address, $post_type, $page ); |
|
33 | + $posts = self::posts_by_author($email_address, $post_type, $page); |
|
34 | 34 | |
35 | - if ( 0 < count( $posts ) ) { |
|
36 | - $obj_post_type = get_post_type_object( $post_type ); |
|
35 | + if (0 < count($posts)) { |
|
36 | + $obj_post_type = get_post_type_object($post_type); |
|
37 | 37 | |
38 | - foreach ( $posts as $post_ID ) { |
|
39 | - $gd_post = geodir_get_post_info( $post_ID ); |
|
40 | - if ( empty( $gd_post ) ) { |
|
38 | + foreach ($posts as $post_ID) { |
|
39 | + $gd_post = geodir_get_post_info($post_ID); |
|
40 | + if (empty($gd_post)) { |
|
41 | 41 | continue; |
42 | 42 | } |
43 | 43 | |
44 | 44 | $data_to_export[] = array( |
45 | - 'group_id' => 'geodirectory-post-' . $post_type, |
|
46 | - 'group_label' => __( $obj_post_type->labels->name, 'geodirectory' ), |
|
47 | - 'item_id' => 'post-' . $post_ID, |
|
48 | - 'data' => self::get_post_personal_data( $gd_post ), |
|
45 | + 'group_id' => 'geodirectory-post-'.$post_type, |
|
46 | + 'group_label' => __($obj_post_type->labels->name, 'geodirectory'), |
|
47 | + 'item_id' => 'post-'.$post_ID, |
|
48 | + 'data' => self::get_post_personal_data($gd_post), |
|
49 | 49 | ); |
50 | 50 | } |
51 | - $done = 10 > count( $posts ); |
|
51 | + $done = 10 > count($posts); |
|
52 | 52 | } else { |
53 | 53 | $done = true; |
54 | 54 | } |
@@ -66,24 +66,24 @@ discard block |
||
66 | 66 | * @param WP_Post $gd_post The post object. |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - protected static function get_post_personal_data( $gd_post ) { |
|
69 | + protected static function get_post_personal_data($gd_post) { |
|
70 | 70 | $post_categories = array(); |
71 | 71 | $post_tags = array(); |
72 | 72 | $default_category = ''; |
73 | 73 | |
74 | - $cat_taxonomy = $gd_post->post_type . 'category'; |
|
75 | - $tag_taxonomy = $gd_post->post_type . '_tags'; |
|
74 | + $cat_taxonomy = $gd_post->post_type.'category'; |
|
75 | + $tag_taxonomy = $gd_post->post_type.'_tags'; |
|
76 | 76 | |
77 | - $post_terms = wp_get_post_terms( $gd_post->ID, array( $cat_taxonomy, $tag_taxonomy ) ); |
|
78 | - if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ) { |
|
79 | - foreach ( $post_terms as $term ) { |
|
80 | - if ( $term->taxonomy == $cat_taxonomy ) { |
|
77 | + $post_terms = wp_get_post_terms($gd_post->ID, array($cat_taxonomy, $tag_taxonomy)); |
|
78 | + if (!empty($post_terms) && !is_wp_error($post_terms)) { |
|
79 | + foreach ($post_terms as $term) { |
|
80 | + if ($term->taxonomy == $cat_taxonomy) { |
|
81 | 81 | $post_categories[] = $term->name; |
82 | 82 | } else { |
83 | 83 | $post_tags[] = $term->name; |
84 | 84 | } |
85 | 85 | |
86 | - if ( $gd_post->default_category == $term->term_id ) { |
|
86 | + if ($gd_post->default_category == $term->term_id) { |
|
87 | 87 | $default_category = $term->name; |
88 | 88 | } |
89 | 89 | } |
@@ -91,177 +91,177 @@ discard block |
||
91 | 91 | |
92 | 92 | $personal_data = array(); |
93 | 93 | $personal_data[] = array( |
94 | - 'name' => __( 'Post ID', 'geodirectory' ), |
|
94 | + 'name' => __('Post ID', 'geodirectory'), |
|
95 | 95 | 'value' => $gd_post->ID, |
96 | 96 | ); |
97 | 97 | $personal_data[] = array( |
98 | - 'name' => __( 'Post Title', 'geodirectory' ), |
|
98 | + 'name' => __('Post Title', 'geodirectory'), |
|
99 | 99 | 'value' => $gd_post->post_title, |
100 | 100 | ); |
101 | 101 | $personal_data[] = array( |
102 | - 'name' => __( 'Post Description', 'geodirectory' ), |
|
102 | + 'name' => __('Post Description', 'geodirectory'), |
|
103 | 103 | 'value' => $gd_post->post_content, |
104 | 104 | ); |
105 | 105 | $personal_data[] = array( |
106 | - 'name' => __( 'Post Date', 'geodirectory' ), |
|
106 | + 'name' => __('Post Date', 'geodirectory'), |
|
107 | 107 | 'value' => $gd_post->post_date, |
108 | 108 | ); |
109 | 109 | $personal_data[] = array( |
110 | - 'name' => __( 'Post Status', 'geodirectory' ), |
|
110 | + 'name' => __('Post Status', 'geodirectory'), |
|
111 | 111 | 'value' => $gd_post->post_status, |
112 | 112 | ); |
113 | 113 | $personal_data[] = array( |
114 | - 'name' => __( 'Post Categories', 'geodirectory' ), |
|
115 | - 'value' => ( ! empty( $post_categories ) ? implode( ', ', $post_categories ) : '' ), |
|
114 | + 'name' => __('Post Categories', 'geodirectory'), |
|
115 | + 'value' => (!empty($post_categories) ? implode(', ', $post_categories) : ''), |
|
116 | 116 | ); |
117 | - if ( $default_category ) { |
|
117 | + if ($default_category) { |
|
118 | 118 | $personal_data[] = array( |
119 | - 'name' => __( 'Default Category', 'geodirectory' ), |
|
119 | + 'name' => __('Default Category', 'geodirectory'), |
|
120 | 120 | 'value' => $default_category, |
121 | 121 | ); |
122 | 122 | } |
123 | - if ( ! empty( $post_tags ) ) { |
|
123 | + if (!empty($post_tags)) { |
|
124 | 124 | $personal_data[] = array( |
125 | - 'name' => __( 'Post Tags', 'geodirectory' ), |
|
126 | - 'value' => implode( ', ', $post_tags ), |
|
125 | + 'name' => __('Post Tags', 'geodirectory'), |
|
126 | + 'value' => implode(', ', $post_tags), |
|
127 | 127 | ); |
128 | 128 | } |
129 | 129 | $personal_data[] = array( |
130 | - 'name' => __( 'Post URL', 'geodirectory' ), |
|
131 | - 'value' => get_permalink( $gd_post->ID ), |
|
130 | + 'name' => __('Post URL', 'geodirectory'), |
|
131 | + 'value' => get_permalink($gd_post->ID), |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | // Post Images |
135 | - $post_images = geodir_get_images( $gd_post->ID ); |
|
136 | - if ( ! empty( $post_images ) ) { |
|
135 | + $post_images = geodir_get_images($gd_post->ID); |
|
136 | + if (!empty($post_images)) { |
|
137 | 137 | $images = array(); |
138 | - foreach ( $post_images as $key => $post_image ) { |
|
139 | - if ( ! empty( $post_image->src ) ) { |
|
138 | + foreach ($post_images as $key => $post_image) { |
|
139 | + if (!empty($post_image->src)) { |
|
140 | 140 | $images[] = $post_image->src; |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | - if ( ! empty( $images ) ) { |
|
144 | + if (!empty($images)) { |
|
145 | 145 | $personal_data[] = array( |
146 | - 'name' => __( 'Post Images', 'geodirectory' ), |
|
147 | - 'value' => self::parse_files_value( $images ), |
|
146 | + 'name' => __('Post Images', 'geodirectory'), |
|
147 | + 'value' => self::parse_files_value($images), |
|
148 | 148 | ); |
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | 152 | // Post Rating |
153 | - $post_rating = geodir_get_post_rating( $gd_post->ID ); |
|
154 | - if ( $post_rating > 0 ) { |
|
155 | - $post_rating = ( is_float( $post_rating) || ( strpos( $post_rating, ".", 1 ) == 1 && strlen( $post_rating ) > 3 ) ) ? number_format( $post_rating, 1, '.', '' ) : $post_rating; |
|
153 | + $post_rating = geodir_get_post_rating($gd_post->ID); |
|
154 | + if ($post_rating > 0) { |
|
155 | + $post_rating = (is_float($post_rating) || (strpos($post_rating, ".", 1) == 1 && strlen($post_rating) > 3)) ? number_format($post_rating, 1, '.', '') : $post_rating; |
|
156 | 156 | $personal_data[] = array( |
157 | - 'name' => __( 'Post Rating', 'geodirectory' ), |
|
158 | - 'value' => $post_rating . ' / 5', |
|
157 | + 'name' => __('Post Rating', 'geodirectory'), |
|
158 | + 'value' => $post_rating.' / 5', |
|
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
162 | 162 | // Post Reviews |
163 | - $post_reviews = geodir_get_review_count_total( $gd_post->ID ); |
|
164 | - if ( $post_reviews > 0 ) { |
|
163 | + $post_reviews = geodir_get_review_count_total($gd_post->ID); |
|
164 | + if ($post_reviews > 0) { |
|
165 | 165 | $personal_data[] = array( |
166 | - 'name' => __( 'Post Reviews', 'geodirectory' ), |
|
166 | + 'name' => __('Post Reviews', 'geodirectory'), |
|
167 | 167 | 'value' => $post_reviews, |
168 | 168 | ); |
169 | 169 | } |
170 | 170 | |
171 | - if ( ! empty( $gd_post->is_featured ) ) { |
|
171 | + if (!empty($gd_post->is_featured)) { |
|
172 | 172 | $personal_data[] = array( |
173 | - 'name' => __( 'Post Featured', 'geodirectory' ), |
|
174 | - 'value' => __( 'Yes', 'geodirectory' ), |
|
173 | + 'name' => __('Post Featured', 'geodirectory'), |
|
174 | + 'value' => __('Yes', 'geodirectory'), |
|
175 | 175 | ); |
176 | 176 | } |
177 | 177 | |
178 | - $custom_fields = geodir_post_custom_fields( $gd_post->package_id, 'all', $gd_post->post_type ); |
|
179 | - $post_fields = array_keys( (array) $gd_post ); |
|
178 | + $custom_fields = geodir_post_custom_fields($gd_post->package_id, 'all', $gd_post->post_type); |
|
179 | + $post_fields = array_keys((array) $gd_post); |
|
180 | 180 | |
181 | - foreach ( $custom_fields as $key => $field ) { |
|
182 | - $field_name = ! empty( $field['htmlvar_name'] ) ? $field['htmlvar_name'] : ''; |
|
183 | - if ( empty( $field_name ) ) { |
|
181 | + foreach ($custom_fields as $key => $field) { |
|
182 | + $field_name = !empty($field['htmlvar_name']) ? $field['htmlvar_name'] : ''; |
|
183 | + if (empty($field_name)) { |
|
184 | 184 | continue; |
185 | 185 | } |
186 | 186 | |
187 | - $field = stripslashes_deep( $field ); |
|
187 | + $field = stripslashes_deep($field); |
|
188 | 188 | |
189 | - $extra_fields = ! empty( $field['extra_fields'] ) ? $field['extra_fields'] : array(); |
|
189 | + $extra_fields = !empty($field['extra_fields']) ? $field['extra_fields'] : array(); |
|
190 | 190 | $data_type = $field['data_type']; |
191 | 191 | $field_type = $field['field_type']; |
192 | - $field_title = $field['site_title']; |
|
193 | - if ( $field_name == 'post' ) { |
|
192 | + $field_title = $field['site_title']; |
|
193 | + if ($field_name == 'post') { |
|
194 | 194 | $field_name = 'post_address'; |
195 | 195 | } |
196 | 196 | |
197 | - if ( ! in_array( $field_name, $post_fields ) ) { |
|
197 | + if (!in_array($field_name, $post_fields)) { |
|
198 | 198 | continue; |
199 | 199 | } |
200 | 200 | |
201 | 201 | $name = $field_title; |
202 | 202 | $value = ''; |
203 | - switch ( $field_type ) { |
|
203 | + switch ($field_type) { |
|
204 | 204 | case 'address': |
205 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $gd_post->post_type ) ? false : true; |
|
206 | - if ( $location_allowed && ! empty( $gd_post->post_country ) && ! empty( $gd_post->post_region ) && ! empty( $gd_post->post_city ) ) { |
|
205 | + $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($gd_post->post_type) ? false : true; |
|
206 | + if ($location_allowed && !empty($gd_post->post_country) && !empty($gd_post->post_region) && !empty($gd_post->post_city)) { |
|
207 | 207 | $personal_data[] = array( |
208 | - 'name' => __( 'Post Address', 'geodirectory' ), |
|
208 | + 'name' => __('Post Address', 'geodirectory'), |
|
209 | 209 | 'value' => $gd_post->post_address, |
210 | 210 | ); |
211 | 211 | $personal_data[] = array( |
212 | - 'name' => __( 'Post City', 'geodirectory' ), |
|
212 | + 'name' => __('Post City', 'geodirectory'), |
|
213 | 213 | 'value' => $gd_post->post_city, |
214 | 214 | ); |
215 | 215 | $personal_data[] = array( |
216 | - 'name' => __( 'Post Region', 'geodirectory' ), |
|
216 | + 'name' => __('Post Region', 'geodirectory'), |
|
217 | 217 | 'value' => $gd_post->post_region, |
218 | 218 | ); |
219 | 219 | $personal_data[] = array( |
220 | - 'name' => __( 'Post Country', 'geodirectory' ), |
|
220 | + 'name' => __('Post Country', 'geodirectory'), |
|
221 | 221 | 'value' => $gd_post->post_country, |
222 | 222 | ); |
223 | 223 | $personal_data[] = array( |
224 | - 'name' => __( 'Post Zip', 'geodirectory' ), |
|
224 | + 'name' => __('Post Zip', 'geodirectory'), |
|
225 | 225 | 'value' => $gd_post->post_zip, |
226 | 226 | ); |
227 | 227 | $personal_data[] = array( |
228 | - 'name' => __( 'Post Latitude', 'geodirectory' ), |
|
228 | + 'name' => __('Post Latitude', 'geodirectory'), |
|
229 | 229 | 'value' => $gd_post->post_latitude, |
230 | 230 | ); |
231 | 231 | $personal_data[] = array( |
232 | - 'name' => __( 'Post Longitude', 'geodirectory' ), |
|
232 | + 'name' => __('Post Longitude', 'geodirectory'), |
|
233 | 233 | 'value' => $gd_post->post_longitude, |
234 | 234 | ); |
235 | - if ( ! empty( $gd_post->post_neighbourhood ) ) { |
|
235 | + if (!empty($gd_post->post_neighbourhood)) { |
|
236 | 236 | $personal_data[] = array( |
237 | - 'name' => __( 'Post Neighbourhood', 'geodirectory' ), |
|
237 | + 'name' => __('Post Neighbourhood', 'geodirectory'), |
|
238 | 238 | 'value' => $gd_post->post_neighbourhood, |
239 | 239 | ); |
240 | 240 | } |
241 | 241 | } |
242 | 242 | break; |
243 | 243 | case 'checkbox': |
244 | - if ( ! empty( $gd_post->{$field_name} ) ) { |
|
245 | - $value = __( 'Yes', 'geodirectory' ); |
|
244 | + if (!empty($gd_post->{$field_name} )) { |
|
245 | + $value = __('Yes', 'geodirectory'); |
|
246 | 246 | } else { |
247 | - $value = __( 'No', 'geodirectory' ); |
|
247 | + $value = __('No', 'geodirectory'); |
|
248 | 248 | } |
249 | 249 | break; |
250 | 250 | case 'datepicker': |
251 | 251 | $value = $gd_post->{$field_name} != '0000-00-00' ? $gd_post->{$field_name} : ''; |
252 | 252 | break; |
253 | 253 | case 'radio': |
254 | - if ( $gd_post->{$field_name} !== '' ) { |
|
255 | - if ( $gd_post->{$field_name} == 'f' || $gd_post->{$field_name} == '0') { |
|
256 | - $value = __( 'No', 'geodirectory' ); |
|
257 | - } else if ( $gd_post->{$field_name} == 't' || $gd_post->{$field_name} == '1') { |
|
258 | - $value = __( 'Yes', 'geodirectory' ); |
|
254 | + if ($gd_post->{$field_name} !== '') { |
|
255 | + if ($gd_post->{$field_name} == 'f' || $gd_post->{$field_name} == '0') { |
|
256 | + $value = __('No', 'geodirectory'); |
|
257 | + } else if ($gd_post->{$field_name} == 't' || $gd_post->{$field_name} == '1') { |
|
258 | + $value = __('Yes', 'geodirectory'); |
|
259 | 259 | } else { |
260 | - if ( !empty( $field['option_values'] ) ) { |
|
261 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep( $field['option_values'] ), true ); |
|
262 | - if ( ! empty( $cf_option_values ) ) { |
|
263 | - foreach ( $cf_option_values as $cf_option_value ) { |
|
264 | - if ( isset( $cf_option_value['value'] ) && $cf_option_value['value'] == $gd_post->{$field_name} ) { |
|
260 | + if (!empty($field['option_values'])) { |
|
261 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($field['option_values']), true); |
|
262 | + if (!empty($cf_option_values)) { |
|
263 | + foreach ($cf_option_values as $cf_option_value) { |
|
264 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $gd_post->{$field_name} ) { |
|
265 | 265 | $value = $cf_option_value['label']; |
266 | 266 | } |
267 | 267 | } |
@@ -271,12 +271,12 @@ discard block |
||
271 | 271 | } |
272 | 272 | break; |
273 | 273 | case 'select': |
274 | - $value = __( $gd_post->{$field_name}, 'geodirectory'); |
|
275 | - if ( !empty( $field['option_values'] ) ) { |
|
276 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep( $field['option_values'] ), true ); |
|
277 | - if ( ! empty( $cf_option_values ) ) { |
|
278 | - foreach ( $cf_option_values as $cf_option_value ) { |
|
279 | - if ( isset( $cf_option_value['value'] ) && $cf_option_value['value'] == $gd_post->{$field_name} ) { |
|
274 | + $value = __($gd_post->{$field_name}, 'geodirectory'); |
|
275 | + if (!empty($field['option_values'])) { |
|
276 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($field['option_values']), true); |
|
277 | + if (!empty($cf_option_values)) { |
|
278 | + foreach ($cf_option_values as $cf_option_value) { |
|
279 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $gd_post->{$field_name} ) { |
|
280 | 280 | $value = $cf_option_value['label']; |
281 | 281 | } |
282 | 282 | } |
@@ -284,23 +284,23 @@ discard block |
||
284 | 284 | } |
285 | 285 | break; |
286 | 286 | case 'multiselect': |
287 | - $field_values = explode( ',', trim( $gd_post->{$field_name}, "," ) ); |
|
288 | - if ( is_array( $field_values ) ) { |
|
289 | - $field_values = array_map( 'trim', $field_values ); |
|
287 | + $field_values = explode(',', trim($gd_post->{$field_name}, ",")); |
|
288 | + if (is_array($field_values)) { |
|
289 | + $field_values = array_map('trim', $field_values); |
|
290 | 290 | } |
291 | 291 | $values = array(); |
292 | - if ( ! empty( $field['option_values'] ) ) { |
|
293 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep( $field['option_values'] ), true ); |
|
292 | + if (!empty($field['option_values'])) { |
|
293 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($field['option_values']), true); |
|
294 | 294 | |
295 | - if ( ! empty( $cf_option_values ) ) { |
|
296 | - foreach ( $cf_option_values as $cf_option_value ) { |
|
297 | - if ( isset( $cf_option_value['value'] ) && in_array( $cf_option_value['value'], $field_values ) ) { |
|
295 | + if (!empty($cf_option_values)) { |
|
296 | + foreach ($cf_option_values as $cf_option_value) { |
|
297 | + if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) { |
|
298 | 298 | $values[] = $cf_option_value['label']; |
299 | 299 | } |
300 | 300 | } |
301 | 301 | } |
302 | 302 | } |
303 | - $value = ! empty( $values ) ? implode( ', ', $values ) : ''; |
|
303 | + $value = !empty($values) ? implode(', ', $values) : ''; |
|
304 | 304 | break; |
305 | 305 | case 'time': |
306 | 306 | $value = $gd_post->{$field_name} != '00:00:00' ? $gd_post->{$field_name} : ''; |
@@ -314,70 +314,70 @@ discard block |
||
314 | 314 | $value = $gd_post->{$field_name} ? $gd_post->{$field_name} : ''; |
315 | 315 | break; |
316 | 316 | case 'file': |
317 | - $files = explode( ",", $gd_post->{$field_name} ); |
|
318 | - if ( ! empty( $files ) ) { |
|
319 | - $allowed_file_types = !empty( $extra_fields['gd_file_types'] ) && is_array( $extra_fields['gd_file_types'] ) && !in_array( "*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : ''; |
|
317 | + $files = explode(",", $gd_post->{$field_name} ); |
|
318 | + if (!empty($files)) { |
|
319 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : ''; |
|
320 | 320 | |
321 | 321 | $file_urls = array(); |
322 | - foreach ( $files as $file ) { |
|
323 | - if ( ! empty( $file ) ) { |
|
324 | - $image_name_arr = explode( '/', $file ); |
|
325 | - $curr_img_dir = $image_name_arr[ count( $image_name_arr ) - 2]; |
|
322 | + foreach ($files as $file) { |
|
323 | + if (!empty($file)) { |
|
324 | + $image_name_arr = explode('/', $file); |
|
325 | + $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
326 | 326 | $filename = end($image_name_arr); |
327 | 327 | $img_name_arr = explode('.', $filename); |
328 | 328 | |
329 | - $arr_file_type = wp_check_filetype( $filename ); |
|
330 | - if ( empty( $arr_file_type['ext'] ) || empty( $arr_file_type['type'] ) ) { |
|
329 | + $arr_file_type = wp_check_filetype($filename); |
|
330 | + if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { |
|
331 | 331 | continue; |
332 | 332 | } |
333 | 333 | |
334 | 334 | $uploaded_file_type = $arr_file_type['type']; |
335 | 335 | $uploaded_file_ext = $arr_file_type['ext']; |
336 | 336 | |
337 | - if ( ! empty( $allowed_file_types ) && !in_array( $uploaded_file_ext, $allowed_file_types ) ) { |
|
337 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { |
|
338 | 338 | continue; // Invalid file type. |
339 | 339 | } |
340 | - $image_file_types = array( 'image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon' ); |
|
341 | - $audio_file_types = array( 'audio/mpeg', 'audio/ogg', 'audio/mp4', 'audio/vnd.wav', 'audio/basic', 'audio/mid' ); |
|
340 | + $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon'); |
|
341 | + $audio_file_types = array('audio/mpeg', 'audio/ogg', 'audio/mp4', 'audio/vnd.wav', 'audio/basic', 'audio/mid'); |
|
342 | 342 | |
343 | 343 | // If the uploaded file is image |
344 | - if ( in_array( $uploaded_file_type, $image_file_types ) ) { |
|
344 | + if (in_array($uploaded_file_type, $image_file_types)) { |
|
345 | 345 | $file_urls[] = $file; |
346 | 346 | } |
347 | 347 | } |
348 | 348 | } |
349 | - $value = ! empty( $file_urls ) ? self::parse_files_value( $file_urls ) : ''; |
|
349 | + $value = !empty($file_urls) ? self::parse_files_value($file_urls) : ''; |
|
350 | 350 | } |
351 | 351 | break; |
352 | 352 | } |
353 | 353 | |
354 | - if ( ! empty( $name ) && $value !== '' ) { |
|
354 | + if (!empty($name) && $value !== '') { |
|
355 | 355 | $personal_data[] = array( |
356 | - 'name' => __( $name, 'geodirectory' ), |
|
356 | + 'name' => __($name, 'geodirectory'), |
|
357 | 357 | 'value' => $value, |
358 | 358 | ); |
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
362 | - if ( ! empty( $gd_post->geodir_link_business ) && ( $post_type = get_post_type( (int)$gd_post->geodir_link_business ) ) ) { |
|
362 | + if (!empty($gd_post->geodir_link_business) && ($post_type = get_post_type((int) $gd_post->geodir_link_business))) { |
|
363 | 363 | $personal_data[] = array( |
364 | - 'name' => __( 'Link Business Title', 'geodirectory' ), |
|
365 | - 'value' => get_the_title( (int)$gd_post->geodir_link_business ), |
|
364 | + 'name' => __('Link Business Title', 'geodirectory'), |
|
365 | + 'value' => get_the_title((int) $gd_post->geodir_link_business), |
|
366 | 366 | ); |
367 | 367 | $personal_data[] = array( |
368 | - 'name' => __( 'Link Business URL', 'geodirectory' ), |
|
369 | - 'value' => get_permalink( (int)$gd_post->geodir_link_business ), |
|
368 | + 'name' => __('Link Business URL', 'geodirectory'), |
|
369 | + 'value' => get_permalink((int) $gd_post->geodir_link_business), |
|
370 | 370 | ); |
371 | 371 | } |
372 | - if ( defined( 'GEODIR_FRANCHISE_VERSION' ) ) { |
|
373 | - if ( ! empty( $gd_post->franchise ) && ( $post_type = get_post_type( (int)$gd_post->franchise ) ) ) { |
|
372 | + if (defined('GEODIR_FRANCHISE_VERSION')) { |
|
373 | + if (!empty($gd_post->franchise) && ($post_type = get_post_type((int) $gd_post->franchise))) { |
|
374 | 374 | $personal_data[] = array( |
375 | - 'name' => __( 'Main Listing Title', 'geodirectory' ), |
|
376 | - 'value' => get_the_title( (int)$gd_post->franchise ), |
|
375 | + 'name' => __('Main Listing Title', 'geodirectory'), |
|
376 | + 'value' => get_the_title((int) $gd_post->franchise), |
|
377 | 377 | ); |
378 | 378 | $personal_data[] = array( |
379 | - 'name' => __( 'Main Listing URL', 'geodirectory' ), |
|
380 | - 'value' => get_permalink( (int)$gd_post->franchise ), |
|
379 | + 'name' => __('Main Listing URL', 'geodirectory'), |
|
380 | + 'value' => get_permalink((int) $gd_post->franchise), |
|
381 | 381 | ); |
382 | 382 | } |
383 | 383 | } |
@@ -389,28 +389,28 @@ discard block |
||
389 | 389 | * @param array $personal_data Array of name value pairs to expose in the export. |
390 | 390 | * @param WP_Post $gd_post The post object. |
391 | 391 | */ |
392 | - $personal_data = apply_filters( 'geodir_privacy_export_post_personal_data', $personal_data, $gd_post ); |
|
392 | + $personal_data = apply_filters('geodir_privacy_export_post_personal_data', $personal_data, $gd_post); |
|
393 | 393 | |
394 | 394 | return $personal_data; |
395 | 395 | } |
396 | 396 | |
397 | - public static function posts_by_author( $email_address, $post_type, $page ) { |
|
398 | - if ( empty( $email_address ) || empty( $post_type ) || empty( $page ) ) { |
|
397 | + public static function posts_by_author($email_address, $post_type, $page) { |
|
398 | + if (empty($email_address) || empty($post_type) || empty($page)) { |
|
399 | 399 | return array(); |
400 | 400 | } |
401 | 401 | |
402 | - $user = get_user_by( 'email', $email_address ); |
|
403 | - if ( empty( $user ) ) { |
|
402 | + $user = get_user_by('email', $email_address); |
|
403 | + if (empty($user)) { |
|
404 | 404 | return array(); |
405 | 405 | } |
406 | 406 | |
407 | - $statuses = array_keys( get_post_statuses() ); |
|
407 | + $statuses = array_keys(get_post_statuses()); |
|
408 | 408 | $skip_statuses = geodir_imex_export_skip_statuses(); |
409 | - if ( ! empty( $skip_statuses ) ) { |
|
410 | - $statuses = array_diff( $statuses, $skip_statuses ); |
|
409 | + if (!empty($skip_statuses)) { |
|
410 | + $statuses = array_diff($statuses, $skip_statuses); |
|
411 | 411 | } |
412 | 412 | |
413 | - $query_args = array( |
|
413 | + $query_args = array( |
|
414 | 414 | 'post_type' => $post_type, |
415 | 415 | 'post_status' => $statuses, |
416 | 416 | 'fields' => 'ids', |
@@ -421,66 +421,66 @@ discard block |
||
421 | 421 | 'order' => 'ASC' |
422 | 422 | ); |
423 | 423 | |
424 | - $query_args = apply_filters( 'geodir_privacy_post_data_exporter_post_query', $query_args, $post_type, $email_address, $page ); |
|
424 | + $query_args = apply_filters('geodir_privacy_post_data_exporter_post_query', $query_args, $post_type, $email_address, $page); |
|
425 | 425 | |
426 | - $posts = get_posts( $query_args ); |
|
426 | + $posts = get_posts($query_args); |
|
427 | 427 | |
428 | - return apply_filters( 'geodir_privacy_post_data_exporter_posts', $posts, $query_args, $post_type, $email_address, $page ); |
|
428 | + return apply_filters('geodir_privacy_post_data_exporter_posts', $posts, $query_args, $post_type, $email_address, $page); |
|
429 | 429 | } |
430 | 430 | |
431 | - public static function review_data_exporter( $response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key ) { |
|
431 | + public static function review_data_exporter($response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key) { |
|
432 | 432 | global $wpdb; |
433 | 433 | |
434 | 434 | $exporter_key = GeoDir_Privacy::personal_data_exporter_key(); |
435 | 435 | |
436 | - if ( $exporter_key == 'wordpress-comments' && ! empty( $response['data'] ) ) { |
|
437 | - foreach ( $response['data'] as $key => $item ) { |
|
438 | - $comment_id = str_replace( 'comment-', '', $item['item_id'] ); |
|
436 | + if ($exporter_key == 'wordpress-comments' && !empty($response['data'])) { |
|
437 | + foreach ($response['data'] as $key => $item) { |
|
438 | + $comment_id = str_replace('comment-', '', $item['item_id']); |
|
439 | 439 | $data = $item['data']; |
440 | 440 | |
441 | - $review = geodir_get_review( $comment_id ); |
|
442 | - if ( ! empty( $review ) ) { |
|
443 | - if ( ! empty( $review->overall_rating ) ) { |
|
441 | + $review = geodir_get_review($comment_id); |
|
442 | + if (!empty($review)) { |
|
443 | + if (!empty($review->overall_rating)) { |
|
444 | 444 | $data[] = array( |
445 | - 'name' => __( 'Rating (Overall)', 'geodirectory' ), |
|
446 | - 'value' => (float)$review->overall_rating . ' / 5', |
|
445 | + 'name' => __('Rating (Overall)', 'geodirectory'), |
|
446 | + 'value' => (float) $review->overall_rating.' / 5', |
|
447 | 447 | ); |
448 | 448 | } |
449 | - if ( ! empty( $review->post_city ) ) { |
|
449 | + if (!empty($review->post_city)) { |
|
450 | 450 | $data[] = array( |
451 | - 'name' => __( 'Review City', 'geodirectory' ), |
|
451 | + 'name' => __('Review City', 'geodirectory'), |
|
452 | 452 | 'value' => $review->post_city, |
453 | 453 | ); |
454 | 454 | } |
455 | - if ( ! empty( $review->post_region ) ) { |
|
455 | + if (!empty($review->post_region)) { |
|
456 | 456 | $data[] = array( |
457 | - 'name' => __( 'Review Region', 'geodirectory' ), |
|
457 | + 'name' => __('Review Region', 'geodirectory'), |
|
458 | 458 | 'value' => $review->post_region, |
459 | 459 | ); |
460 | 460 | } |
461 | - if ( ! empty( $review->post_country ) ) { |
|
461 | + if (!empty($review->post_country)) { |
|
462 | 462 | $data[] = array( |
463 | - 'name' => __( 'Review Country', 'geodirectory' ), |
|
463 | + 'name' => __('Review Country', 'geodirectory'), |
|
464 | 464 | 'value' => $review->post_country, |
465 | 465 | ); |
466 | 466 | } |
467 | - if ( ! empty( $review->post_latitude ) ) { |
|
467 | + if (!empty($review->post_latitude)) { |
|
468 | 468 | $data[] = array( |
469 | - 'name' => __( 'Review Latitude', 'geodirectory' ), |
|
469 | + 'name' => __('Review Latitude', 'geodirectory'), |
|
470 | 470 | 'value' => $review->post_latitude, |
471 | 471 | ); |
472 | 472 | } |
473 | - if ( ! empty( $review->post_longitude ) ) { |
|
473 | + if (!empty($review->post_longitude)) { |
|
474 | 474 | $data[] = array( |
475 | - 'name' => __( 'Review Longitude', 'geodirectory' ), |
|
475 | + 'name' => __('Review Longitude', 'geodirectory'), |
|
476 | 476 | 'value' => $review->post_longitude, |
477 | 477 | ); |
478 | 478 | } |
479 | 479 | |
480 | - $data = apply_filters( 'geodir_privacy_export_review_data', $data, $review, $email_address ); |
|
480 | + $data = apply_filters('geodir_privacy_export_review_data', $data, $review, $email_address); |
|
481 | 481 | |
482 | - if ( ! empty( $data ) ) { |
|
483 | - $response['data'][ $key ]['data'] = $data; |
|
482 | + if (!empty($data)) { |
|
483 | + $response['data'][$key]['data'] = $data; |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | } |
@@ -496,36 +496,36 @@ discard block |
||
496 | 496 | * @param int $page Page. |
497 | 497 | * @return array An array of personal data in name value pairs |
498 | 498 | */ |
499 | - public static function favorites_data_exporter( $email_address, $page ) { |
|
499 | + public static function favorites_data_exporter($email_address, $page) { |
|
500 | 500 | $done = true; |
501 | 501 | $page = (int) $page; |
502 | 502 | $data_to_export = array(); |
503 | 503 | |
504 | - $items = GeoDir_Privacy::favorites_by_user( $email_address, $page ); |
|
504 | + $items = GeoDir_Privacy::favorites_by_user($email_address, $page); |
|
505 | 505 | |
506 | - if ( 0 < count( $items ) ) { |
|
507 | - foreach ( $items as $item ) { |
|
508 | - $gd_post = geodir_get_post_info( $item ); |
|
509 | - if ( empty( $gd_post ) ) { |
|
506 | + if (0 < count($items)) { |
|
507 | + foreach ($items as $item) { |
|
508 | + $gd_post = geodir_get_post_info($item); |
|
509 | + if (empty($gd_post)) { |
|
510 | 510 | continue; |
511 | 511 | } |
512 | 512 | |
513 | 513 | $data_to_export[] = array( |
514 | 514 | 'group_id' => 'geodirectory-post-favorites', |
515 | - 'group_label' => __( 'GeoDirectory Favorite Listings', 'geodirectory' ), |
|
516 | - 'item_id' => 'gd-favorite-' . $gd_post->ID, |
|
515 | + 'group_label' => __('GeoDirectory Favorite Listings', 'geodirectory'), |
|
516 | + 'item_id' => 'gd-favorite-'.$gd_post->ID, |
|
517 | 517 | 'data' => array( |
518 | 518 | array( |
519 | - 'name' => __( 'Post ID', 'geodirectory' ), |
|
519 | + 'name' => __('Post ID', 'geodirectory'), |
|
520 | 520 | 'value' => $gd_post->ID, |
521 | 521 | ), |
522 | 522 | array( |
523 | - 'name' => __( 'Post Title', 'geodirectory' ), |
|
523 | + 'name' => __('Post Title', 'geodirectory'), |
|
524 | 524 | 'value' => $gd_post->post_title, |
525 | 525 | ), |
526 | 526 | array( |
527 | - 'name' => __( 'Post URL', 'geodirectory' ), |
|
528 | - 'value' => get_permalink( $gd_post->ID ), |
|
527 | + 'name' => __('Post URL', 'geodirectory'), |
|
528 | + 'value' => get_permalink($gd_post->ID), |
|
529 | 529 | ) |
530 | 530 | ), |
531 | 531 | ); |
@@ -538,27 +538,27 @@ discard block |
||
538 | 538 | ); |
539 | 539 | } |
540 | 540 | |
541 | - public static function parse_files_value( $files ) { |
|
542 | - if ( empty( $files ) ) { |
|
541 | + public static function parse_files_value($files) { |
|
542 | + if (empty($files)) { |
|
543 | 543 | return ''; |
544 | 544 | } |
545 | 545 | |
546 | - if ( ! is_array( $files ) ) { |
|
546 | + if (!is_array($files)) { |
|
547 | 547 | return $files; |
548 | 548 | } |
549 | 549 | |
550 | - if ( count( $files ) == 1 ) { |
|
550 | + if (count($files) == 1) { |
|
551 | 551 | return $files[0]; |
552 | 552 | } |
553 | 553 | |
554 | 554 | $links = array(); |
555 | - foreach ( $files as $file ) { |
|
556 | - if ( false === strpos( $file, ' ' ) && ( 0 === strpos( $file, 'http://' ) || 0 === strpos( $file, 'https://' ) ) ) { |
|
557 | - $file = '<a href="' . esc_url( $file ) . '">' . esc_html( $file ) . '</a>'; |
|
555 | + foreach ($files as $file) { |
|
556 | + if (false === strpos($file, ' ') && (0 === strpos($file, 'http://') || 0 === strpos($file, 'https://'))) { |
|
557 | + $file = '<a href="'.esc_url($file).'">'.esc_html($file).'</a>'; |
|
558 | 558 | } |
559 | 559 | $links[] = $file; |
560 | 560 | } |
561 | - $links = ! empty( $links ) ? implode( ' <br> ', $links ) : ''; |
|
561 | + $links = !empty($links) ? implode(' <br> ', $links) : ''; |
|
562 | 562 | |
563 | 563 | return $links; |
564 | 564 | } |