HEX
Server: Apache/2.4.37 (CentOS Stream) OpenSSL/1.1.1k
System: Linux ysnet.com.tw 4.18.0-553.5.1.el8.x86_64 #1 SMP Tue May 21 05:46:01 UTC 2024 x86_64
User: test (521)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /var/www/test/wp-content/plugins/wp-statistics/includes/class-wp-statistics-privacy-erasers.php
<?php

namespace WP_STATISTICS;

class PrivacyErasers
{
    /**
     * Finds and erases visitors' data by email address.
     *
     * @param string $emailAddress The user email address.
     * @param int $page Page.
     *
     * @return array An array of personal data in name value pairs
     *
     * @since 13.2.5
     */
    public static function visitorsDataEraser($emailAddress, $page = 1)
    {
        $response = array(
            'items_removed'  => false,
            'items_retained' => false,
            'messages'       => array(),
            'done'           => true,
        );

        global $wpdb;

        $visitor_table = DB::table('visitor');
        $user          = get_user_by('email', $emailAddress);

        if (!$user) {
            return $response;
        }

        $visitors = $wpdb->query($wpdb->prepare("DELETE FROM {$visitor_table} WHERE `user_id` = %s", $user->ID));

        if ($visitors) {
            /* translators: %s: string value */
            $response['messages']      = array(sprintf(__('Visitor data deleted for %s.', 'wp-statistics'), $emailAddress));
            $response['items_removed'] = true;
        }

        return $response;
    }
}