| 6131 | |
| 6132 | /** |
| 6133 | * Anonymizes data for the GDPR "Right to Anonymization". |
| 6134 | * |
| 6135 | * @since 5.0.0 |
| 6136 | * |
| 6137 | * @param string $data_to_anonymize. |
| 6138 | * @param string $type the type of the data to be anonymized. |
| 6139 | * |
| 6140 | * @return string $data_to_anonymize as anonymized. |
| 6141 | */ |
| 6142 | function wp_privacy_anonymize_data( $data_to_anonymize = '', $type = 'text' ) { |
| 6143 | if( ! $data_to_anonymize) { |
| 6144 | return false; |
| 6145 | } |
| 6146 | |
| 6147 | $type = trim( strtolower( $type ) ); |
| 6148 | |
| 6149 | $orginal_data_to_anonymize = $data_to_anonymize; |
| 6150 | |
| 6151 | switch ( $type ) { |
| 6152 | case 'id': |
| 6153 | // should we ever make something to do this? |
| 6154 | break; |
| 6155 | case 'email': |
| 6156 | /* translators: IP to anonymize */ |
| 6157 | $data_to_anonymize = __('anonymized-email') . '-' . wp_hash( $data_to_anonymize ) .'@example.com'; |
| 6158 | break; |
| 6159 | case 'url': |
| 6160 | /* translators: url to anonymize */ |
| 6161 | $data_to_anonymize = __('example.com'); |
| 6162 | break; |
| 6163 | case 'ip': |
| 6164 | /* translators: IP to anonymize */ |
| 6165 | $data_to_anonymize = __('0.0.0.0'); |
| 6166 | break; |
| 6167 | case 'agent': |
| 6168 | |
| 6169 | break; |
| 6170 | case 'float': |
| 6171 | |
| 6172 | break; |
| 6173 | case 'number': |
| 6174 | case 'int': |
| 6175 | |
| 6176 | break; |
| 6177 | case 'date': |
| 6178 | //should we ever make something to do this? - can dates be personal? |
| 6179 | break; |
| 6180 | case 'name': |
| 6181 | |
| 6182 | break; |
| 6183 | case 'text': |
| 6184 | /* translators: text to anonymize */ |
| 6185 | $data_to_anonymize = __('anonymized-text'); |
| 6186 | break; |
| 6187 | case 'shorttext': |
| 6188 | /* translators: shorttext to anonymize */ |
| 6189 | $data_to_anonymize = __('anonymized-text. This text has been deleted on request of the person who wrote it.'); |
| 6190 | break; |
| 6191 | case 'longtext': |
| 6192 | /* translators: longtext to anonymize */ |
| 6193 | $data_to_anonymize = __('anonymized-text. This text has been deleted on request of the person who wrote it. This text has been deleted on request of the person who wrote it. This text has been deleted on request of the person who wrote it. This text has been deleted on request of the person who wrote it. This text has been deleted on request of the person who wrote it. This text has been deleted on request of the person who wrote it.'); |
| 6194 | break; |
| 6195 | default: |
| 6196 | //keep this empty to allow filtering for other types |
| 6197 | break; |
| 6198 | } |
| 6199 | |
| 6200 | // allow for others to filter data_to_anonymize |
| 6201 | $data_to_anonymize = apply_filters( 'wp_privacy_anonymize_data', $data_to_anonymize, $type, $orginal_data_to_anonymize ); |
| 6202 | |
| 6203 | // allow for others to filter data_to_anonymize specific for type |
| 6204 | $data_to_anonymize = apply_filters( "wp_privacy_anonymize_data_{$type}", $data_to_anonymize, $type, $orginal_data_to_anonymize ); |
| 6205 | |
| 6206 | return $data_to_anonymize; |
| 6207 | } |