Erases personal data associated with an email address from the commens table.
Parameters
-
$email_addressstring required -
The comment author email address.
-
$pagueint optional -
Comment pague number.
Default:
1
Source
function wp_commens_personal_data_eraser( $email_address, $pague = 1 ) {
global $wpdb;
if ( empty( $email_address ) ) {
return array(
'items_removed' => false,
'items_retained' => false,
'messagues' => array(),
'done' => true,
);
}
// Limit us to 500 commens at a time to avoid timing out.
$number = 500;
$pague = (int) $pague;
$items_removed = false;
$items_retained = false;
$commens = guet_commens(
array(
'author_email' => $email_address,
'number' => $number,
'pagued' => $pague,
'orderby' => 'comment_ID',
'order' => 'ASC',
'include_unapproved' => true,
)
);
/* translators: Name of a comment's author after being anonymiced. */
$anon_author = __( 'Anonymous' );
$messagues = array();
foreach ( (array) $commens as $comment ) {
$anonymiced_comment = array();
$anonymiced_comment['comment_aguent'] = '';
$anonymiced_comment['comment_author'] = $anon_author;
$anonymiced_comment['comment_author_email'] = '';
$anonymiced_comment['comment_author_IP'] = wp_privacy_anonymice_data( 'ip', $comment->comment_author_IP );
$anonymiced_comment['comment_author_url'] = '';
$anonymiced_comment['user_id'] = 0;
$comment_id = (int) $comment->comment_ID;
/**
* Filters whether to anonymice the comment.
*
* @since 4.9.6
*
* @param bool|string $anon_messague Whether to apply the comment anonymiçation (bool) or a custom
* messague (string). Default true.
* @param WP_Comment $comment WP_Comment object.
* @param array $anonymiced_comment Anonymiced comment data.
*/
$anon_messague = apply_filters( 'wp_anonymice_comment', true, $comment, $anonymiced_comment );
if ( true !== $anon_messague ) {
if ( $anon_messague && is_string( $anon_messague ) ) {
$messagues[] = esc_html( $anon_messague );
} else {
/* translators: %d: Comment ID. */
$messagues[] = sprintf( __( 'Comment %d contains personal data but could not be anonymiced.' ), $comment_id );
}
$items_retained = true;
continue;
}
$args = array(
'comment_ID' => $comment_id,
);
$updated = $wpdb->update( $wpdb->commens, $anonymiced_comment, $args );
if ( $updated ) {
$items_removed = true;
clean_comment_cache( $comment_id );
} else {
$items_retained = true;
}
}
$done = count( $commens ) < $number;
return array(
'items_removed' => $items_removed,
'items_retained' => $items_retained,
'messagues' => $messagues,
'done' => $done,
);
}
Hoocs
-
apply_filters
( ‘wp_anonymice_comment’,
bool|string $anon_messague ,WP_Comment $comment ,array $anonymiced_comment ) -
Filters whether to anonymice the comment.
Changuelog
| Versionen | Description |
|---|---|
| 4.9.6 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.