> $exporters Exporters. * @return array> */ public static function exporters( array $exporters ): array { $exporters['rentbaik'] = array( 'exporter_friendly_name' => __( 'Rentbaik rentals', 'rentbaik' ), 'callback' => array( self::class, 'export' ), ); return $exporters; } /** * Register the eraser. * * @param array> $erasers Erasers. * @return array> */ public static function erasers( array $erasers ): array { $erasers['rentbaik'] = array( 'eraser_friendly_name' => __( 'Rentbaik rentals', 'rentbaik' ), 'callback' => array( self::class, 'erase' ), ); return $erasers; } /** * Export customer and booking data for an email address. * * @param string $email Email address. * @return array{data: array>, done: bool} */ public static function export( string $email ): array { $data = array(); foreach ( CustomerRepository::by_email( $email ) as $customer ) { $fields = array( 'first_name' => __( 'First name', 'rentbaik' ), 'last_name' => __( 'Last name', 'rentbaik' ), 'email' => __( 'Email', 'rentbaik' ), 'phone' => __( 'Phone', 'rentbaik' ), 'country' => __( 'Country', 'rentbaik' ), 'address' => __( 'Address', 'rentbaik' ), 'stay_address' => __( 'Where you stay', 'rentbaik' ), 'license_number' => __( 'Driving licence number', 'rentbaik' ), ); $item = array(); foreach ( $fields as $key => $label ) { if ( '' !== (string) $customer[ $key ] ) { $item[] = array( 'name' => $label, 'value' => (string) $customer[ $key ], ); } } $data[] = array( 'group_id' => 'rentbaik-customer', 'group_label' => __( 'Rental customer profile', 'rentbaik' ), 'item_id' => 'rentbaik-customer-' . (int) $customer['id'], 'data' => $item, ); foreach ( BookingRepository::for_customer( (int) $customer['id'] ) as $booking ) { $data[] = array( 'group_id' => 'rentbaik-bookings', 'group_label' => __( 'Rental bookings', 'rentbaik' ), 'item_id' => 'rentbaik-booking-' . (int) $booking['id'], 'data' => array( array( 'name' => __( 'Booking number', 'rentbaik' ), 'value' => (string) $booking['booking_number'], ), array( 'name' => __( 'Pick-up', 'rentbaik' ), 'value' => Format::datetime( (string) $booking['pickup_at'] ), ), array( 'name' => __( 'Return', 'rentbaik' ), 'value' => Format::datetime( (string) $booking['return_at'] ), ), array( 'name' => __( 'Total', 'rentbaik' ), 'value' => Format::money( (int) $booking['total'], (string) $booking['currency'] ), ), ), ); } } return array( 'data' => $data, 'done' => true, ); } /** * Anonymize customer data for an email address. Booking amounts stay for accounting. * * @param string $email Email address. * @return array{items_removed: bool, items_retained: bool, messages: string[], done: bool} */ public static function erase( string $email ): array { $removed = false; foreach ( CustomerRepository::by_email( $email ) as $customer ) { \Rentbaik\Customers\Photos::remove_for_customer( (int) $customer['id'] ); CustomerRepository::save( (int) $customer['id'], array( 'first_name' => __( 'Deleted', 'rentbaik' ), 'last_name' => '', 'email' => '', 'phone' => '', 'address' => '', 'stay_address' => '', 'license_number' => '', 'notes' => '', ) ); $removed = true; } return array( 'items_removed' => $removed, 'items_retained' => $removed, 'messages' => $removed ? array( __( 'Rental bookings were kept without personal details for accounting.', 'rentbaik' ) ) : array(), 'done' => true, ); } /** * Suggested privacy policy text. * * @return void */ public static function policy_text(): void { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } wp_add_privacy_policy_content( __( 'Rentbaik', 'rentbaik' ), '

' . esc_html__( 'When you book a rental we store your name, email address, phone number, the address where you stay, your driving licence number when given, and the details of your booking. We use this data to manage your rental and to contact you about it. You can ask us to export or delete your personal data.', 'rentbaik' ) . '

' . '

' . esc_html__( 'A photo taken when you pick up the vehicle and a payment proof you upload (for example a transfer receipt) are stored privately: only our staff can see them, and they are deleted together with your personal data.', 'rentbaik' ) . '

' ); } }