@@ -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,189 +91,189 @@ 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 | - if ( ! empty( $gd_post->post_modified ) && $gd_post->post_modified != '0000-00-00 00:00:00' ) { |
|
| 109 | + if (!empty($gd_post->post_modified) && $gd_post->post_modified != '0000-00-00 00:00:00') { |
|
| 110 | 110 | $personal_data[] = array( |
| 111 | - 'name' => __( 'Post Modified Date', 'geodirectory' ), |
|
| 111 | + 'name' => __('Post Modified Date', 'geodirectory'), |
|
| 112 | 112 | 'value' => $gd_post->post_modified, |
| 113 | 113 | ); |
| 114 | 114 | } |
| 115 | 115 | $personal_data[] = array( |
| 116 | - 'name' => __( 'Post Status', 'geodirectory' ), |
|
| 116 | + 'name' => __('Post Status', 'geodirectory'), |
|
| 117 | 117 | 'value' => $gd_post->post_status, |
| 118 | 118 | ); |
| 119 | - if ( ! empty( $gd_post->submit_ip ) ) { |
|
| 119 | + if (!empty($gd_post->submit_ip)) { |
|
| 120 | 120 | $personal_data[] = array( |
| 121 | - 'name' => __( 'Submit IP', 'geodirectory' ), |
|
| 121 | + 'name' => __('Submit IP', 'geodirectory'), |
|
| 122 | 122 | 'value' => $gd_post->submit_ip, |
| 123 | 123 | ); |
| 124 | 124 | } |
| 125 | 125 | $personal_data[] = array( |
| 126 | - 'name' => __( 'Post Categories', 'geodirectory' ), |
|
| 127 | - 'value' => ( ! empty( $post_categories ) ? implode( ', ', $post_categories ) : '' ), |
|
| 126 | + 'name' => __('Post Categories', 'geodirectory'), |
|
| 127 | + 'value' => (!empty($post_categories) ? implode(', ', $post_categories) : ''), |
|
| 128 | 128 | ); |
| 129 | - if ( $default_category ) { |
|
| 129 | + if ($default_category) { |
|
| 130 | 130 | $personal_data[] = array( |
| 131 | - 'name' => __( 'Default Category', 'geodirectory' ), |
|
| 131 | + 'name' => __('Default Category', 'geodirectory'), |
|
| 132 | 132 | 'value' => $default_category, |
| 133 | 133 | ); |
| 134 | 134 | } |
| 135 | - if ( ! empty( $post_tags ) ) { |
|
| 135 | + if (!empty($post_tags)) { |
|
| 136 | 136 | $personal_data[] = array( |
| 137 | - 'name' => __( 'Post Tags', 'geodirectory' ), |
|
| 138 | - 'value' => implode( ', ', $post_tags ), |
|
| 137 | + 'name' => __('Post Tags', 'geodirectory'), |
|
| 138 | + 'value' => implode(', ', $post_tags), |
|
| 139 | 139 | ); |
| 140 | 140 | } |
| 141 | 141 | $personal_data[] = array( |
| 142 | - 'name' => __( 'Post URL', 'geodirectory' ), |
|
| 143 | - 'value' => get_permalink( $gd_post->ID ), |
|
| 142 | + 'name' => __('Post URL', 'geodirectory'), |
|
| 143 | + 'value' => get_permalink($gd_post->ID), |
|
| 144 | 144 | ); |
| 145 | 145 | |
| 146 | 146 | // Post Images |
| 147 | - $post_images = geodir_get_images( $gd_post->ID ); |
|
| 148 | - if ( ! empty( $post_images ) ) { |
|
| 147 | + $post_images = geodir_get_images($gd_post->ID); |
|
| 148 | + if (!empty($post_images)) { |
|
| 149 | 149 | $images = array(); |
| 150 | - foreach ( $post_images as $key => $post_image ) { |
|
| 151 | - if ( ! empty( $post_image->src ) ) { |
|
| 150 | + foreach ($post_images as $key => $post_image) { |
|
| 151 | + if (!empty($post_image->src)) { |
|
| 152 | 152 | $images[] = $post_image->src; |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if ( ! empty( $images ) ) { |
|
| 156 | + if (!empty($images)) { |
|
| 157 | 157 | $personal_data[] = array( |
| 158 | - 'name' => __( 'Post Images', 'geodirectory' ), |
|
| 159 | - 'value' => self::parse_files_value( $images ), |
|
| 158 | + 'name' => __('Post Images', 'geodirectory'), |
|
| 159 | + 'value' => self::parse_files_value($images), |
|
| 160 | 160 | ); |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // Post Rating |
| 165 | - $post_rating = geodir_get_post_rating( $gd_post->ID ); |
|
| 166 | - if ( $post_rating > 0 ) { |
|
| 167 | - $post_rating = ( is_float( $post_rating) || ( strpos( $post_rating, ".", 1 ) == 1 && strlen( $post_rating ) > 3 ) ) ? number_format( $post_rating, 1, '.', '' ) : $post_rating; |
|
| 165 | + $post_rating = geodir_get_post_rating($gd_post->ID); |
|
| 166 | + if ($post_rating > 0) { |
|
| 167 | + $post_rating = (is_float($post_rating) || (strpos($post_rating, ".", 1) == 1 && strlen($post_rating) > 3)) ? number_format($post_rating, 1, '.', '') : $post_rating; |
|
| 168 | 168 | $personal_data[] = array( |
| 169 | - 'name' => __( 'Post Rating', 'geodirectory' ), |
|
| 170 | - 'value' => $post_rating . ' / 5', |
|
| 169 | + 'name' => __('Post Rating', 'geodirectory'), |
|
| 170 | + 'value' => $post_rating.' / 5', |
|
| 171 | 171 | ); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Post Reviews |
| 175 | - $post_reviews = geodir_get_review_count_total( $gd_post->ID ); |
|
| 176 | - if ( $post_reviews > 0 ) { |
|
| 175 | + $post_reviews = geodir_get_review_count_total($gd_post->ID); |
|
| 176 | + if ($post_reviews > 0) { |
|
| 177 | 177 | $personal_data[] = array( |
| 178 | - 'name' => __( 'Post Reviews', 'geodirectory' ), |
|
| 178 | + 'name' => __('Post Reviews', 'geodirectory'), |
|
| 179 | 179 | 'value' => $post_reviews, |
| 180 | 180 | ); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( ! empty( $gd_post->is_featured ) ) { |
|
| 183 | + if (!empty($gd_post->is_featured)) { |
|
| 184 | 184 | $personal_data[] = array( |
| 185 | - 'name' => __( 'Post Featured', 'geodirectory' ), |
|
| 186 | - 'value' => __( 'Yes', 'geodirectory' ), |
|
| 185 | + 'name' => __('Post Featured', 'geodirectory'), |
|
| 186 | + 'value' => __('Yes', 'geodirectory'), |
|
| 187 | 187 | ); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $custom_fields = geodir_post_custom_fields( $gd_post->package_id, 'all', $gd_post->post_type ); |
|
| 191 | - $post_fields = array_keys( (array) $gd_post ); |
|
| 190 | + $custom_fields = geodir_post_custom_fields($gd_post->package_id, 'all', $gd_post->post_type); |
|
| 191 | + $post_fields = array_keys((array) $gd_post); |
|
| 192 | 192 | |
| 193 | - foreach ( $custom_fields as $key => $field ) { |
|
| 194 | - $field_name = ! empty( $field['htmlvar_name'] ) ? $field['htmlvar_name'] : ''; |
|
| 195 | - if ( empty( $field_name ) ) { |
|
| 193 | + foreach ($custom_fields as $key => $field) { |
|
| 194 | + $field_name = !empty($field['htmlvar_name']) ? $field['htmlvar_name'] : ''; |
|
| 195 | + if (empty($field_name)) { |
|
| 196 | 196 | continue; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - $field = stripslashes_deep( $field ); |
|
| 199 | + $field = stripslashes_deep($field); |
|
| 200 | 200 | |
| 201 | - $extra_fields = ! empty( $field['extra_fields'] ) ? $field['extra_fields'] : array(); |
|
| 201 | + $extra_fields = !empty($field['extra_fields']) ? $field['extra_fields'] : array(); |
|
| 202 | 202 | $data_type = $field['data_type']; |
| 203 | 203 | $field_type = $field['field_type']; |
| 204 | - $field_title = $field['site_title']; |
|
| 205 | - if ( $field_name == 'post' ) { |
|
| 204 | + $field_title = $field['site_title']; |
|
| 205 | + if ($field_name == 'post') { |
|
| 206 | 206 | $field_name = 'post_address'; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if ( ! in_array( $field_name, $post_fields ) ) { |
|
| 209 | + if (!in_array($field_name, $post_fields)) { |
|
| 210 | 210 | continue; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | $name = $field_title; |
| 214 | 214 | $value = ''; |
| 215 | - switch ( $field_type ) { |
|
| 215 | + switch ($field_type) { |
|
| 216 | 216 | case 'address': |
| 217 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $gd_post->post_type ) ? false : true; |
|
| 218 | - if ( $location_allowed && ! empty( $gd_post->post_country ) && ! empty( $gd_post->post_region ) && ! empty( $gd_post->post_city ) ) { |
|
| 217 | + $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($gd_post->post_type) ? false : true; |
|
| 218 | + if ($location_allowed && !empty($gd_post->post_country) && !empty($gd_post->post_region) && !empty($gd_post->post_city)) { |
|
| 219 | 219 | $personal_data[] = array( |
| 220 | - 'name' => __( 'Post Address', 'geodirectory' ), |
|
| 220 | + 'name' => __('Post Address', 'geodirectory'), |
|
| 221 | 221 | 'value' => $gd_post->post_address, |
| 222 | 222 | ); |
| 223 | 223 | $personal_data[] = array( |
| 224 | - 'name' => __( 'Post City', 'geodirectory' ), |
|
| 224 | + 'name' => __('Post City', 'geodirectory'), |
|
| 225 | 225 | 'value' => $gd_post->post_city, |
| 226 | 226 | ); |
| 227 | 227 | $personal_data[] = array( |
| 228 | - 'name' => __( 'Post Region', 'geodirectory' ), |
|
| 228 | + 'name' => __('Post Region', 'geodirectory'), |
|
| 229 | 229 | 'value' => $gd_post->post_region, |
| 230 | 230 | ); |
| 231 | 231 | $personal_data[] = array( |
| 232 | - 'name' => __( 'Post Country', 'geodirectory' ), |
|
| 232 | + 'name' => __('Post Country', 'geodirectory'), |
|
| 233 | 233 | 'value' => $gd_post->post_country, |
| 234 | 234 | ); |
| 235 | 235 | $personal_data[] = array( |
| 236 | - 'name' => __( 'Post Zip', 'geodirectory' ), |
|
| 236 | + 'name' => __('Post Zip', 'geodirectory'), |
|
| 237 | 237 | 'value' => $gd_post->post_zip, |
| 238 | 238 | ); |
| 239 | 239 | $personal_data[] = array( |
| 240 | - 'name' => __( 'Post Latitude', 'geodirectory' ), |
|
| 240 | + 'name' => __('Post Latitude', 'geodirectory'), |
|
| 241 | 241 | 'value' => $gd_post->post_latitude, |
| 242 | 242 | ); |
| 243 | 243 | $personal_data[] = array( |
| 244 | - 'name' => __( 'Post Longitude', 'geodirectory' ), |
|
| 244 | + 'name' => __('Post Longitude', 'geodirectory'), |
|
| 245 | 245 | 'value' => $gd_post->post_longitude, |
| 246 | 246 | ); |
| 247 | - if ( ! empty( $gd_post->post_neighbourhood ) ) { |
|
| 247 | + if (!empty($gd_post->post_neighbourhood)) { |
|
| 248 | 248 | $personal_data[] = array( |
| 249 | - 'name' => __( 'Post Neighbourhood', 'geodirectory' ), |
|
| 249 | + 'name' => __('Post Neighbourhood', 'geodirectory'), |
|
| 250 | 250 | 'value' => $gd_post->post_neighbourhood, |
| 251 | 251 | ); |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | break; |
| 255 | 255 | case 'checkbox': |
| 256 | - if ( ! empty( $gd_post->{$field_name} ) ) { |
|
| 257 | - $value = __( 'Yes', 'geodirectory' ); |
|
| 256 | + if (!empty($gd_post->{$field_name} )) { |
|
| 257 | + $value = __('Yes', 'geodirectory'); |
|
| 258 | 258 | } else { |
| 259 | - $value = __( 'No', 'geodirectory' ); |
|
| 259 | + $value = __('No', 'geodirectory'); |
|
| 260 | 260 | } |
| 261 | 261 | break; |
| 262 | 262 | case 'datepicker': |
| 263 | 263 | $value = $gd_post->{$field_name} != '0000-00-00' ? $gd_post->{$field_name} : ''; |
| 264 | 264 | break; |
| 265 | 265 | case 'radio': |
| 266 | - if ( $gd_post->{$field_name} !== '' ) { |
|
| 267 | - if ( $gd_post->{$field_name} == 'f' || $gd_post->{$field_name} == '0') { |
|
| 268 | - $value = __( 'No', 'geodirectory' ); |
|
| 269 | - } else if ( $gd_post->{$field_name} == 't' || $gd_post->{$field_name} == '1') { |
|
| 270 | - $value = __( 'Yes', 'geodirectory' ); |
|
| 266 | + if ($gd_post->{$field_name} !== '') { |
|
| 267 | + if ($gd_post->{$field_name} == 'f' || $gd_post->{$field_name} == '0') { |
|
| 268 | + $value = __('No', 'geodirectory'); |
|
| 269 | + } else if ($gd_post->{$field_name} == 't' || $gd_post->{$field_name} == '1') { |
|
| 270 | + $value = __('Yes', 'geodirectory'); |
|
| 271 | 271 | } else { |
| 272 | - if ( !empty( $field['option_values'] ) ) { |
|
| 273 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep( $field['option_values'] ), true ); |
|
| 274 | - if ( ! empty( $cf_option_values ) ) { |
|
| 275 | - foreach ( $cf_option_values as $cf_option_value ) { |
|
| 276 | - if ( isset( $cf_option_value['value'] ) && $cf_option_value['value'] == $gd_post->{$field_name} ) { |
|
| 272 | + if (!empty($field['option_values'])) { |
|
| 273 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($field['option_values']), true); |
|
| 274 | + if (!empty($cf_option_values)) { |
|
| 275 | + foreach ($cf_option_values as $cf_option_value) { |
|
| 276 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $gd_post->{$field_name} ) { |
|
| 277 | 277 | $value = $cf_option_value['label']; |
| 278 | 278 | } |
| 279 | 279 | } |
@@ -283,12 +283,12 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | break; |
| 285 | 285 | case 'select': |
| 286 | - $value = __( $gd_post->{$field_name}, 'geodirectory'); |
|
| 287 | - if ( !empty( $field['option_values'] ) ) { |
|
| 288 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep( $field['option_values'] ), true ); |
|
| 289 | - if ( ! empty( $cf_option_values ) ) { |
|
| 290 | - foreach ( $cf_option_values as $cf_option_value ) { |
|
| 291 | - if ( isset( $cf_option_value['value'] ) && $cf_option_value['value'] == $gd_post->{$field_name} ) { |
|
| 286 | + $value = __($gd_post->{$field_name}, 'geodirectory'); |
|
| 287 | + if (!empty($field['option_values'])) { |
|
| 288 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($field['option_values']), true); |
|
| 289 | + if (!empty($cf_option_values)) { |
|
| 290 | + foreach ($cf_option_values as $cf_option_value) { |
|
| 291 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $gd_post->{$field_name} ) { |
|
| 292 | 292 | $value = $cf_option_value['label']; |
| 293 | 293 | } |
| 294 | 294 | } |
@@ -296,23 +296,23 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | break; |
| 298 | 298 | case 'multiselect': |
| 299 | - $field_values = explode( ',', trim( $gd_post->{$field_name}, "," ) ); |
|
| 300 | - if ( is_array( $field_values ) ) { |
|
| 301 | - $field_values = array_map( 'trim', $field_values ); |
|
| 299 | + $field_values = explode(',', trim($gd_post->{$field_name}, ",")); |
|
| 300 | + if (is_array($field_values)) { |
|
| 301 | + $field_values = array_map('trim', $field_values); |
|
| 302 | 302 | } |
| 303 | 303 | $values = array(); |
| 304 | - if ( ! empty( $field['option_values'] ) ) { |
|
| 305 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep( $field['option_values'] ), true ); |
|
| 304 | + if (!empty($field['option_values'])) { |
|
| 305 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($field['option_values']), true); |
|
| 306 | 306 | |
| 307 | - if ( ! empty( $cf_option_values ) ) { |
|
| 308 | - foreach ( $cf_option_values as $cf_option_value ) { |
|
| 309 | - if ( isset( $cf_option_value['value'] ) && in_array( $cf_option_value['value'], $field_values ) ) { |
|
| 307 | + if (!empty($cf_option_values)) { |
|
| 308 | + foreach ($cf_option_values as $cf_option_value) { |
|
| 309 | + if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) { |
|
| 310 | 310 | $values[] = $cf_option_value['label']; |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | - $value = ! empty( $values ) ? implode( ', ', $values ) : ''; |
|
| 315 | + $value = !empty($values) ? implode(', ', $values) : ''; |
|
| 316 | 316 | break; |
| 317 | 317 | case 'time': |
| 318 | 318 | $value = $gd_post->{$field_name} != '00:00:00' ? $gd_post->{$field_name} : ''; |
@@ -326,70 +326,70 @@ discard block |
||
| 326 | 326 | $value = $gd_post->{$field_name} ? $gd_post->{$field_name} : ''; |
| 327 | 327 | break; |
| 328 | 328 | case 'file': |
| 329 | - $files = explode( ",", $gd_post->{$field_name} ); |
|
| 330 | - if ( ! empty( $files ) ) { |
|
| 331 | - $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'] : ''; |
|
| 329 | + $files = explode(",", $gd_post->{$field_name} ); |
|
| 330 | + if (!empty($files)) { |
|
| 331 | + $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'] : ''; |
|
| 332 | 332 | |
| 333 | 333 | $file_urls = array(); |
| 334 | - foreach ( $files as $file ) { |
|
| 335 | - if ( ! empty( $file ) ) { |
|
| 336 | - $image_name_arr = explode( '/', $file ); |
|
| 337 | - $curr_img_dir = $image_name_arr[ count( $image_name_arr ) - 2]; |
|
| 334 | + foreach ($files as $file) { |
|
| 335 | + if (!empty($file)) { |
|
| 336 | + $image_name_arr = explode('/', $file); |
|
| 337 | + $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
|
| 338 | 338 | $filename = end($image_name_arr); |
| 339 | 339 | $img_name_arr = explode('.', $filename); |
| 340 | 340 | |
| 341 | - $arr_file_type = wp_check_filetype( $filename ); |
|
| 342 | - if ( empty( $arr_file_type['ext'] ) || empty( $arr_file_type['type'] ) ) { |
|
| 341 | + $arr_file_type = wp_check_filetype($filename); |
|
| 342 | + if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) { |
|
| 343 | 343 | continue; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | $uploaded_file_type = $arr_file_type['type']; |
| 347 | 347 | $uploaded_file_ext = $arr_file_type['ext']; |
| 348 | 348 | |
| 349 | - if ( ! empty( $allowed_file_types ) && !in_array( $uploaded_file_ext, $allowed_file_types ) ) { |
|
| 349 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) { |
|
| 350 | 350 | continue; // Invalid file type. |
| 351 | 351 | } |
| 352 | - $image_file_types = array( 'image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon' ); |
|
| 353 | - $audio_file_types = array( 'audio/mpeg', 'audio/ogg', 'audio/mp4', 'audio/vnd.wav', 'audio/basic', 'audio/mid' ); |
|
| 352 | + $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon'); |
|
| 353 | + $audio_file_types = array('audio/mpeg', 'audio/ogg', 'audio/mp4', 'audio/vnd.wav', 'audio/basic', 'audio/mid'); |
|
| 354 | 354 | |
| 355 | 355 | // If the uploaded file is image |
| 356 | - if ( in_array( $uploaded_file_type, $image_file_types ) ) { |
|
| 356 | + if (in_array($uploaded_file_type, $image_file_types)) { |
|
| 357 | 357 | $file_urls[] = $file; |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | - $value = ! empty( $file_urls ) ? self::parse_files_value( $file_urls ) : ''; |
|
| 361 | + $value = !empty($file_urls) ? self::parse_files_value($file_urls) : ''; |
|
| 362 | 362 | } |
| 363 | 363 | break; |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if ( ! empty( $name ) && $value !== '' ) { |
|
| 366 | + if (!empty($name) && $value !== '') { |
|
| 367 | 367 | $personal_data[] = array( |
| 368 | - 'name' => __( $name, 'geodirectory' ), |
|
| 368 | + 'name' => __($name, 'geodirectory'), |
|
| 369 | 369 | 'value' => $value, |
| 370 | 370 | ); |
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if ( ! empty( $gd_post->geodir_link_business ) && ( $post_type = get_post_type( (int)$gd_post->geodir_link_business ) ) ) { |
|
| 374 | + if (!empty($gd_post->geodir_link_business) && ($post_type = get_post_type((int) $gd_post->geodir_link_business))) { |
|
| 375 | 375 | $personal_data[] = array( |
| 376 | - 'name' => __( 'Link Business Title', 'geodirectory' ), |
|
| 377 | - 'value' => get_the_title( (int)$gd_post->geodir_link_business ), |
|
| 376 | + 'name' => __('Link Business Title', 'geodirectory'), |
|
| 377 | + 'value' => get_the_title((int) $gd_post->geodir_link_business), |
|
| 378 | 378 | ); |
| 379 | 379 | $personal_data[] = array( |
| 380 | - 'name' => __( 'Link Business URL', 'geodirectory' ), |
|
| 381 | - 'value' => get_permalink( (int)$gd_post->geodir_link_business ), |
|
| 380 | + 'name' => __('Link Business URL', 'geodirectory'), |
|
| 381 | + 'value' => get_permalink((int) $gd_post->geodir_link_business), |
|
| 382 | 382 | ); |
| 383 | 383 | } |
| 384 | - if ( defined( 'GEODIR_FRANCHISE_VERSION' ) ) { |
|
| 385 | - if ( ! empty( $gd_post->franchise ) && ( $post_type = get_post_type( (int)$gd_post->franchise ) ) ) { |
|
| 384 | + if (defined('GEODIR_FRANCHISE_VERSION')) { |
|
| 385 | + if (!empty($gd_post->franchise) && ($post_type = get_post_type((int) $gd_post->franchise))) { |
|
| 386 | 386 | $personal_data[] = array( |
| 387 | - 'name' => __( 'Main Listing Title', 'geodirectory' ), |
|
| 388 | - 'value' => get_the_title( (int)$gd_post->franchise ), |
|
| 387 | + 'name' => __('Main Listing Title', 'geodirectory'), |
|
| 388 | + 'value' => get_the_title((int) $gd_post->franchise), |
|
| 389 | 389 | ); |
| 390 | 390 | $personal_data[] = array( |
| 391 | - 'name' => __( 'Main Listing URL', 'geodirectory' ), |
|
| 392 | - 'value' => get_permalink( (int)$gd_post->franchise ), |
|
| 391 | + 'name' => __('Main Listing URL', 'geodirectory'), |
|
| 392 | + 'value' => get_permalink((int) $gd_post->franchise), |
|
| 393 | 393 | ); |
| 394 | 394 | } |
| 395 | 395 | } |
@@ -401,28 +401,28 @@ discard block |
||
| 401 | 401 | * @param array $personal_data Array of name value pairs to expose in the export. |
| 402 | 402 | * @param WP_Post $gd_post The post object. |
| 403 | 403 | */ |
| 404 | - $personal_data = apply_filters( 'geodir_privacy_export_post_personal_data', $personal_data, $gd_post ); |
|
| 404 | + $personal_data = apply_filters('geodir_privacy_export_post_personal_data', $personal_data, $gd_post); |
|
| 405 | 405 | |
| 406 | 406 | return $personal_data; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - public static function posts_by_author( $email_address, $post_type, $page ) { |
|
| 410 | - if ( empty( $email_address ) || empty( $post_type ) || empty( $page ) ) { |
|
| 409 | + public static function posts_by_author($email_address, $post_type, $page) { |
|
| 410 | + if (empty($email_address) || empty($post_type) || empty($page)) { |
|
| 411 | 411 | return array(); |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - $user = get_user_by( 'email', $email_address ); |
|
| 415 | - if ( empty( $user ) ) { |
|
| 414 | + $user = get_user_by('email', $email_address); |
|
| 415 | + if (empty($user)) { |
|
| 416 | 416 | return array(); |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - $statuses = array_keys( get_post_statuses() ); |
|
| 419 | + $statuses = array_keys(get_post_statuses()); |
|
| 420 | 420 | $skip_statuses = geodir_imex_export_skip_statuses(); |
| 421 | - if ( ! empty( $skip_statuses ) ) { |
|
| 422 | - $statuses = array_diff( $statuses, $skip_statuses ); |
|
| 421 | + if (!empty($skip_statuses)) { |
|
| 422 | + $statuses = array_diff($statuses, $skip_statuses); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - $query_args = array( |
|
| 425 | + $query_args = array( |
|
| 426 | 426 | 'post_type' => $post_type, |
| 427 | 427 | 'post_status' => $statuses, |
| 428 | 428 | 'fields' => 'ids', |
@@ -433,66 +433,66 @@ discard block |
||
| 433 | 433 | 'order' => 'ASC' |
| 434 | 434 | ); |
| 435 | 435 | |
| 436 | - $query_args = apply_filters( 'geodir_privacy_post_data_exporter_post_query', $query_args, $post_type, $email_address, $page ); |
|
| 436 | + $query_args = apply_filters('geodir_privacy_post_data_exporter_post_query', $query_args, $post_type, $email_address, $page); |
|
| 437 | 437 | |
| 438 | - $posts = get_posts( $query_args ); |
|
| 438 | + $posts = get_posts($query_args); |
|
| 439 | 439 | |
| 440 | - return apply_filters( 'geodir_privacy_post_data_exporter_posts', $posts, $query_args, $post_type, $email_address, $page ); |
|
| 440 | + return apply_filters('geodir_privacy_post_data_exporter_posts', $posts, $query_args, $post_type, $email_address, $page); |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - public static function review_data_exporter( $response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key ) { |
|
| 443 | + public static function review_data_exporter($response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key) { |
|
| 444 | 444 | global $wpdb; |
| 445 | 445 | |
| 446 | 446 | $exporter_key = GeoDir_Privacy::personal_data_exporter_key(); |
| 447 | 447 | |
| 448 | - if ( $exporter_key == 'wordpress-comments' && ! empty( $response['data'] ) ) { |
|
| 449 | - foreach ( $response['data'] as $key => $item ) { |
|
| 450 | - $comment_id = str_replace( 'comment-', '', $item['item_id'] ); |
|
| 448 | + if ($exporter_key == 'wordpress-comments' && !empty($response['data'])) { |
|
| 449 | + foreach ($response['data'] as $key => $item) { |
|
| 450 | + $comment_id = str_replace('comment-', '', $item['item_id']); |
|
| 451 | 451 | $data = $item['data']; |
| 452 | 452 | |
| 453 | - $review = geodir_get_review( $comment_id ); |
|
| 454 | - if ( ! empty( $review ) ) { |
|
| 455 | - if ( ! empty( $review->overall_rating ) ) { |
|
| 453 | + $review = geodir_get_review($comment_id); |
|
| 454 | + if (!empty($review)) { |
|
| 455 | + if (!empty($review->overall_rating)) { |
|
| 456 | 456 | $data[] = array( |
| 457 | - 'name' => __( 'Rating (Overall)', 'geodirectory' ), |
|
| 458 | - 'value' => (float)$review->overall_rating . ' / 5', |
|
| 457 | + 'name' => __('Rating (Overall)', 'geodirectory'), |
|
| 458 | + 'value' => (float) $review->overall_rating.' / 5', |
|
| 459 | 459 | ); |
| 460 | 460 | } |
| 461 | - if ( ! empty( $review->post_city ) ) { |
|
| 461 | + if (!empty($review->post_city)) { |
|
| 462 | 462 | $data[] = array( |
| 463 | - 'name' => __( 'Review City', 'geodirectory' ), |
|
| 463 | + 'name' => __('Review City', 'geodirectory'), |
|
| 464 | 464 | 'value' => $review->post_city, |
| 465 | 465 | ); |
| 466 | 466 | } |
| 467 | - if ( ! empty( $review->post_region ) ) { |
|
| 467 | + if (!empty($review->post_region)) { |
|
| 468 | 468 | $data[] = array( |
| 469 | - 'name' => __( 'Review Region', 'geodirectory' ), |
|
| 469 | + 'name' => __('Review Region', 'geodirectory'), |
|
| 470 | 470 | 'value' => $review->post_region, |
| 471 | 471 | ); |
| 472 | 472 | } |
| 473 | - if ( ! empty( $review->post_country ) ) { |
|
| 473 | + if (!empty($review->post_country)) { |
|
| 474 | 474 | $data[] = array( |
| 475 | - 'name' => __( 'Review Country', 'geodirectory' ), |
|
| 475 | + 'name' => __('Review Country', 'geodirectory'), |
|
| 476 | 476 | 'value' => $review->post_country, |
| 477 | 477 | ); |
| 478 | 478 | } |
| 479 | - if ( ! empty( $review->post_latitude ) ) { |
|
| 479 | + if (!empty($review->post_latitude)) { |
|
| 480 | 480 | $data[] = array( |
| 481 | - 'name' => __( 'Review Latitude', 'geodirectory' ), |
|
| 481 | + 'name' => __('Review Latitude', 'geodirectory'), |
|
| 482 | 482 | 'value' => $review->post_latitude, |
| 483 | 483 | ); |
| 484 | 484 | } |
| 485 | - if ( ! empty( $review->post_longitude ) ) { |
|
| 485 | + if (!empty($review->post_longitude)) { |
|
| 486 | 486 | $data[] = array( |
| 487 | - 'name' => __( 'Review Longitude', 'geodirectory' ), |
|
| 487 | + 'name' => __('Review Longitude', 'geodirectory'), |
|
| 488 | 488 | 'value' => $review->post_longitude, |
| 489 | 489 | ); |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - $data = apply_filters( 'geodir_privacy_export_review_data', $data, $review, $email_address ); |
|
| 492 | + $data = apply_filters('geodir_privacy_export_review_data', $data, $review, $email_address); |
|
| 493 | 493 | |
| 494 | - if ( ! empty( $data ) ) { |
|
| 495 | - $response['data'][ $key ]['data'] = $data; |
|
| 494 | + if (!empty($data)) { |
|
| 495 | + $response['data'][$key]['data'] = $data; |
|
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | } |
@@ -508,36 +508,36 @@ discard block |
||
| 508 | 508 | * @param int $page Page. |
| 509 | 509 | * @return array An array of personal data in name value pairs |
| 510 | 510 | */ |
| 511 | - public static function favorites_data_exporter( $email_address, $page ) { |
|
| 511 | + public static function favorites_data_exporter($email_address, $page) { |
|
| 512 | 512 | $done = true; |
| 513 | 513 | $page = (int) $page; |
| 514 | 514 | $data_to_export = array(); |
| 515 | 515 | |
| 516 | - $items = GeoDir_Privacy::favorites_by_user( $email_address, $page ); |
|
| 516 | + $items = GeoDir_Privacy::favorites_by_user($email_address, $page); |
|
| 517 | 517 | |
| 518 | - if ( 0 < count( $items ) ) { |
|
| 519 | - foreach ( $items as $item ) { |
|
| 520 | - $gd_post = geodir_get_post_info( $item ); |
|
| 521 | - if ( empty( $gd_post ) ) { |
|
| 518 | + if (0 < count($items)) { |
|
| 519 | + foreach ($items as $item) { |
|
| 520 | + $gd_post = geodir_get_post_info($item); |
|
| 521 | + if (empty($gd_post)) { |
|
| 522 | 522 | continue; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | $data_to_export[] = array( |
| 526 | 526 | 'group_id' => 'geodirectory-post-favorites', |
| 527 | - 'group_label' => __( 'GeoDirectory Favorite Listings', 'geodirectory' ), |
|
| 528 | - 'item_id' => 'gd-favorite-' . $gd_post->ID, |
|
| 527 | + 'group_label' => __('GeoDirectory Favorite Listings', 'geodirectory'), |
|
| 528 | + 'item_id' => 'gd-favorite-'.$gd_post->ID, |
|
| 529 | 529 | 'data' => array( |
| 530 | 530 | array( |
| 531 | - 'name' => __( 'Post ID', 'geodirectory' ), |
|
| 531 | + 'name' => __('Post ID', 'geodirectory'), |
|
| 532 | 532 | 'value' => $gd_post->ID, |
| 533 | 533 | ), |
| 534 | 534 | array( |
| 535 | - 'name' => __( 'Post Title', 'geodirectory' ), |
|
| 535 | + 'name' => __('Post Title', 'geodirectory'), |
|
| 536 | 536 | 'value' => $gd_post->post_title, |
| 537 | 537 | ), |
| 538 | 538 | array( |
| 539 | - 'name' => __( 'Post URL', 'geodirectory' ), |
|
| 540 | - 'value' => get_permalink( $gd_post->ID ), |
|
| 539 | + 'name' => __('Post URL', 'geodirectory'), |
|
| 540 | + 'value' => get_permalink($gd_post->ID), |
|
| 541 | 541 | ) |
| 542 | 542 | ), |
| 543 | 543 | ); |
@@ -550,27 +550,27 @@ discard block |
||
| 550 | 550 | ); |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - public static function parse_files_value( $files ) { |
|
| 554 | - if ( empty( $files ) ) { |
|
| 553 | + public static function parse_files_value($files) { |
|
| 554 | + if (empty($files)) { |
|
| 555 | 555 | return ''; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | - if ( ! is_array( $files ) ) { |
|
| 558 | + if (!is_array($files)) { |
|
| 559 | 559 | return $files; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - if ( count( $files ) == 1 ) { |
|
| 562 | + if (count($files) == 1) { |
|
| 563 | 563 | return $files[0]; |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | $links = array(); |
| 567 | - foreach ( $files as $file ) { |
|
| 568 | - if ( false === strpos( $file, ' ' ) && ( 0 === strpos( $file, 'http://' ) || 0 === strpos( $file, 'https://' ) ) ) { |
|
| 569 | - $file = '<a href="' . esc_url( $file ) . '">' . esc_html( $file ) . '</a>'; |
|
| 567 | + foreach ($files as $file) { |
|
| 568 | + if (false === strpos($file, ' ') && (0 === strpos($file, 'http://') || 0 === strpos($file, 'https://'))) { |
|
| 569 | + $file = '<a href="'.esc_url($file).'">'.esc_html($file).'</a>'; |
|
| 570 | 570 | } |
| 571 | 571 | $links[] = $file; |
| 572 | 572 | } |
| 573 | - $links = ! empty( $links ) ? implode( ' <br> ', $links ) : ''; |
|
| 573 | + $links = !empty($links) ? implode(' <br> ', $links) : ''; |
|
| 574 | 574 | |
| 575 | 575 | return $links; |
| 576 | 576 | } |