' . esc_html__( 'What this plugin stores on your site', '007aj-backup-restore-verifier' ) . ''; $parts[] = esc_html__( 'Backup archives: zip files in the uploads directory, in uploads/brverify-working/. An archive contains a copy of the site database (including user accounts, e-mail addresses, comments and any other personal data the site holds) and, depending on the components chosen for the backup, plugin, theme and upload files. By default the newest 3 backups are kept and older ones are deleted automatically (Settings, Retention; pre-update backups have their own cap).', '007aj-backup-restore-verifier' ); $parts[] = esc_html__( 'Job history and logs: the plugin tables record the job type, status, progress, timestamps, file names and error messages. They are not intended to hold personal data.', '007aj-backup-restore-verifier' ); $parts[] = esc_html__( 'Settings: schedule, retention, destinations and an optional notification e-mail address.', '007aj-backup-restore-verifier' ); $notice = file_exists( BRVERIFY_PATH . 'includes/Admin/class-extras-note.php' ); if ( $notice ) { $parts[] = esc_html__( 'External services: this edition does not contact any external service, sets no cookies and collects no usage statistics. The "Upgrade to Pro" links open 007aj.com in your browser only when you click it.', '007aj-backup-restore-verifier' ); } $text = implode( "\n\n", $parts ); /** * Lets an edition add statements about the services it contacts (HTML paragraphs separated by blank lines). * * @param string $more Additional policy text. */ $more = (string) apply_filters( 'brverify_privacy_policy_services', '' ); $tail = array(); $tail[] = '' . esc_html__( 'E-mail', '007aj-backup-restore-verifier' ) . ''; $tail[] = esc_html__( 'When a backup or restore job fails, one e-mail with the site name, the site URL, the job type and an error summary is sent with wp_mail() to the notification address in the settings, or to the site administrator e-mail if that field is empty. The administrator e-mail is read from WordPress and is not copied into the plugin settings.', '007aj-backup-restore-verifier' ); $tail[] = '' . esc_html__( 'Deleting the plugin', '007aj-backup-restore-verifier' ) . ''; $tail[] = esc_html__( 'Deleting the plugin always removes its scheduled events and temporary data. Settings, tables and backup archives are kept unless "Delete all data when the plugin is deleted" is ticked under Settings; with that option on, all plugin options, tables, user-meta and the backup folder are removed.', '007aj-backup-restore-verifier' ); $tail[] = '' . esc_html__( 'Personal data requests', '007aj-backup-restore-verifier' ) . ''; $tail[] = esc_html__( 'The WordPress export and erase tools cover the notification e-mail address, the per-user notice flag (where that notice exists) and any log row that contains the e-mail address. Existing backup archives are not rewritten: they keep a copy of the site as it was when each backup was made until the retention setting removes them or you delete them.', '007aj-backup-restore-verifier' ); return $text . ( '' !== $more ? "\n\n" . $more : '' ) . "\n\n" . implode( "\n\n", $tail ); } /** * Add the exporter. * * @param array $exporters Registered exporters. * @return array */ public function register_exporter( $exporters ) { $exporters = is_array( $exporters ) ? $exporters : array(); $exporters['007aj-backup-restore-verifier'] = array( 'exporter_friendly_name' => __( '007AJ Backup Restore Verifier', '007aj-backup-restore-verifier' ), 'callback' => array( $this, 'export' ), ); return $exporters; } /** * Add the eraser. * * @param array $erasers Registered erasers. * @return array */ public function register_eraser( $erasers ) { $erasers = is_array( $erasers ) ? $erasers : array(); $erasers['007aj-backup-restore-verifier'] = array( 'eraser_friendly_name' => __( '007AJ Backup Restore Verifier', '007aj-backup-restore-verifier' ), 'callback' => array( $this, 'erase' ), ); return $erasers; } /** * Exporter callback. * * @param string $email_address Requested e-mail address. * @param int $page Page (everything is returned on page 1). * @return array{data:array>,done:bool} */ public function export( $email_address, $page = 1 ): array { $email = self::norm( (string) $email_address ); $data = array(); if ( '' === $email ) { return array( 'data' => $data, 'done' => true, ); } if ( self::stored_alert_email() === $email ) { $data[] = array( 'group_id' => 'brverify-settings', 'group_label' => __( '007AJ Backup Restore Verifier settings', '007aj-backup-restore-verifier' ), 'item_id' => 'brverify-alert-email', 'data' => array( array( 'name' => __( 'Notification e-mail address', '007aj-backup-restore-verifier' ), 'value' => $email, ), ), ); } $user = get_user_by( 'email', $email ); if ( $user && '' !== (string) get_user_meta( (int) $user->ID, self::USERMETA, true ) ) { $data[] = array( 'group_id' => 'brverify-settings', 'group_label' => __( '007AJ Backup Restore Verifier settings', '007aj-backup-restore-verifier' ), 'item_id' => 'brverify-notice-flag', 'data' => array( array( 'name' => __( 'Plugin notice dismissed', '007aj-backup-restore-verifier' ), 'value' => __( 'Yes', '007aj-backup-restore-verifier' ), ), ), ); } foreach ( self::log_rows( $email ) as $row ) { $data[] = array( 'group_id' => 'brverify-logs', 'group_label' => __( '007AJ Backup Restore Verifier log entries', '007aj-backup-restore-verifier' ), 'item_id' => 'brverify-log-' . (int) $row['id'], 'data' => array( array( 'name' => __( 'Date', '007aj-backup-restore-verifier' ), 'value' => (string) $row['created_at'], ), array( 'name' => __( 'Message', '007aj-backup-restore-verifier' ), 'value' => (string) $row['message'], ), ), ); } return array( 'data' => $data, 'done' => true, ); } /** * Eraser callback. * * @param string $email_address Requested e-mail address. * @param int $page Page (everything is handled on page 1). * @return array{items_removed:bool,items_retained:bool,messages:array,done:bool} */ public function erase( $email_address, $page = 1 ): array { global $wpdb; $email = self::norm( (string) $email_address ); $removed = false; $msgs = array(); if ( '' === $email ) { return array( 'items_removed' => false, 'items_retained' => false, 'messages' => $msgs, 'done' => true, ); } // 1. Notification address stored in the settings (compared by value; no user lookup needed). if ( self::stored_alert_email() === $email ) { $settings = get_option( Settings::OPTION, array() ); if ( is_array( $settings ) ) { $settings['alert_email'] = ''; update_option( Settings::OPTION, $settings, false ); $removed = true; } } // 2. Per-user flag, when a user with that address still exists. $user = get_user_by( 'email', $email ); if ( $user && '' !== (string) get_user_meta( (int) $user->ID, self::USERMETA, true ) ) { delete_user_meta( (int) $user->ID, self::USERMETA ); $removed = true; } // 3. Log rows that contain the address (prepared, bounded). $table = $wpdb->prefix . 'brverify_logs'; $like = '%' . $wpdb->esc_like( $email ) . '%'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared $deleted = $wpdb->query( $wpdb->prepare( 'DELETE FROM %i WHERE message LIKE %s OR context_json LIKE %s', $table, $like, $like ) ); if ( is_int( $deleted ) && $deleted > 0 ) { $removed = true; } // 4. Backup archives are copies of the site; they are not rewritten. $retained = false; if ( self::has_backups() ) { $retained = true; $msgs[] = __( '007AJ Backup Restore Verifier: existing backup archives are not modified. They hold a copy of the site as it was when each backup was made and are removed by the retention setting or when you delete them.', '007aj-backup-restore-verifier' ); } return array( 'items_removed' => $removed, 'items_retained' => $retained, 'messages' => $msgs, 'done' => true, ); } /** * Lower-cased, sanitised address. * * @param string $email Raw. */ private static function norm( string $email ): string { $email = strtolower( trim( (string) sanitize_email( $email ) ) ); return is_email( $email ) ? $email : ''; } /** * The notification address saved in the settings, normalised ('' when none). */ private static function stored_alert_email(): string { $settings = get_option( Settings::OPTION, array() ); if ( ! is_array( $settings ) || empty( $settings['alert_email'] ) ) { return ''; } return strtolower( trim( (string) $settings['alert_email'] ) ); } /** * Log rows whose message or context contain the address. * * @param string $email Normalised address. * @return array> */ private static function log_rows( string $email ): array { global $wpdb; $table = $wpdb->prefix . 'brverify_logs'; $like = '%' . $wpdb->esc_like( $email ) . '%'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared $rows = $wpdb->get_results( $wpdb->prepare( 'SELECT id, message, created_at FROM %i WHERE message LIKE %s OR context_json LIKE %s ORDER BY id ASC LIMIT 500', $table, $like, $like ), ARRAY_A ); return is_array( $rows ) ? $rows : array(); } /** * Whether any backup record exists. */ private static function has_backups(): bool { global $wpdb; $table = $wpdb->prefix . 'brverify_artifacts'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared return (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i', $table ) ) > 0; } }