PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 7.9.8
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v7.9.8
8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 All 46 releases
gamipress / includes / privacy / erasers / logs.php

logs.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 7.9.8, at includes/privacy/erasers/logs.php

86 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Logs Erasers
4 *
5 * @package GamiPress\Privacy\Erasers\Logs
6 * @author GamiPress <[email protected]>, Ruben Garcia <[email protected]>
7 * @since 1.5.0
8 */
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Register eraser for user logs.
14 *
15 * @since 1.5.0
16 *
17 * @param array $erasers
18 *
19 * @return array
20 */
21 function gamipress_privacy_register_logs_erasers( $erasers ) {
22
23 $erasers[] = array(
24 'eraser_friendly_name' => __( 'Activity Logs', 'gamipress' ),
25 'callback' => 'gamipress_privacy_logs_eraser',
26 );
27
28 return $erasers;
29
30 }
31 add_filter( 'wp_privacy_personal_data_erasers', 'gamipress_privacy_register_logs_erasers' );
32
33 /**
34 * Eraser for user logs.
35 *
36 * @since 1.5.0
37 *
38 * @param string $email_address
39 * @param int $page
40 *
41 * @return array
42 */
43 function gamipress_privacy_logs_eraser( $email_address, $page = 1 ) {
44
45 global $wpdb;
46
47 // Setup query vars
48 $logs = GamiPress()->db->logs;
49
50 // Important: %d is user ID
51 $query = "DELETE FROM {$logs} WHERE user_id = %d";
52 $count_query = str_replace( "DELETE", "SELECT COUNT(*)", $query );
53
54 // Setup vars
55 $response = array(
56 'items_removed' => true,
57 'items_retained' => false,
58 'messages' => array(),
59 'done' => true
60 );
61
62 $user = get_user_by( 'email', $email_address );
63
64 if ( $user && $user->ID ) {
65
66 // Erase user logs
67 $erased = $wpdb->query( $wpdb->prepare( $query, $user->ID ) );
68
69 if( $erased ) {
70
71 $messages[] = sprintf( __( 'Removed %d logs.', 'gamipress' ), $erased );
72
73 }
74
75 // Check remaining items
76 $items_count = absint( $wpdb->get_var( $wpdb->prepare( $count_query, $user->ID ) ) );
77
78 // Process done!
79 $response['done'] = (bool) ( $items_count === 0 );
80
81 }
82
83 // Return our erased items
84 return $response;
85
86 }