'alai_pdf_lead', 'post_status' => array_values(get_post_stati()), 'posts_per_page' => 50, 'paged' => max(1, (int) $page), // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters -- Privacy requests must include records from every language. 'orderby' => 'ID', 'order' => 'ASC', 'suppress_filters' => true, 'meta_key' => '_alai_email', 'meta_value' => $email, ]); } function lwek_privacy_export($email, $page = 1) { $records = lwek_privacy_records($email, $page); $data = []; $fields = [ 'name' => __('Name', 'fucuo-elements'), 'email' => __('Email', 'fucuo-elements'), 'company' => __('Company', 'fucuo-elements'), 'phone' => __('Phone', 'fucuo-elements'), 'book_title' => __('Publication', 'fucuo-elements'), 'consent' => __('Consent text', 'fucuo-elements'), 'consent_version' => __('Consent version', 'fucuo-elements'), 'downloaded' => __('Download started', 'fucuo-elements'), ]; foreach ($records as $record) { $values = []; foreach ($fields as $key => $label) { $values[] = ['name' => $label, 'value' => (string) get_post_meta($record->ID, '_alai_' . $key, true)]; } $values[] = ['name' => __('Submitted (site time)', 'fucuo-elements'), 'value' => $record->post_date]; $data[] = ['group_id' => 'fucuo-pdf-requests', 'group_label' => __('PDF download requests', 'fucuo-elements'), 'item_id' => 'fucuo-lead-' . $record->ID, 'data' => $values]; } return ['data' => $data, 'done' => count($records) < 50]; } function lwek_privacy_erase($email, $page = 1) { // Always take the first remaining batch: successful deletions shift the result set. $records = lwek_privacy_records($email, 1); $removed = false; $retained = false; foreach ($records as $record) { if (wp_delete_post($record->ID, true)) { $removed = true; } else { $retained = true; } } return [ 'items_removed' => $removed, 'items_retained' => $retained, 'messages' => $retained ? [__('Some PDF download records could not be deleted. Please contact the site administrator.', 'fucuo-elements')] : [], 'done' => $retained || count($records) < 50, ]; } add_filter('wp_privacy_personal_data_exporters', function ($exporters) { $exporters['fucuo-elements'] = ['exporter_friendly_name' => 'FUCUO Elements', 'callback' => 'lwek_privacy_export']; return $exporters; }); add_filter('wp_privacy_personal_data_erasers', function ($erasers) { $erasers['fucuo-elements'] = ['eraser_friendly_name' => 'FUCUO Elements', 'callback' => 'lwek_privacy_erase']; return $erasers; }); add_action('admin_init', function () { if (function_exists('wp_add_privacy_policy_content')) { wp_add_privacy_policy_content('FUCUO Elements', wpautop(esc_html__( 'When visitors request a PDF download, this site stores their name, email, optional company and phone, requested publication, consent text and submission/download time. Records are stored in this site database until an administrator removes them; set and disclose an appropriate retention period. No contact details are sent to the plugin developer. A hashed IP identifier is cached for ten minutes to limit submissions, and a random download token is cached for fifteen minutes. These cache entries may remain until cache cleanup. Administrators can export or erase contact records using the WordPress privacy tools. Public media-library PDFs are not protected by this form. Review and adapt this suggested text to your site practices.', 'fucuo-elements' ))); } });