__( 'Fitzaro virtual try-ons', 'fitzaro' ), 'callback' => array( self::class, 'export' ), ); } return $exporters; } /** * Registers the eraser. * * @param mixed $erasers Erasers. * @return mixed */ public static function add_eraser( $erasers ) { if ( is_array( $erasers ) ) { $erasers[ self::ID ] = array( 'eraser_friendly_name' => __( 'Fitzaro virtual try-ons', 'fitzaro' ), 'callback' => array( self::class, 'erase' ), ); } return $erasers; } /** * Exporter callback. * * @param string $email Email address. * @return array{data: list>, done: bool} */ public static function export( $email ): array { $user = get_user_by( 'email', (string) $email ); if ( ! $user instanceof \WP_User ) { return array( 'data' => array(), 'done' => true, ); } $labels = array( 'product' => __( 'Product', 'fitzaro' ), 'status' => __( 'Status', 'fitzaro' ), 'date' => __( 'Date (UTC)', 'fitzaro' ), ); $data = array(); foreach ( PersonalData::export( Jobs::requests(), (int) $user->ID, array( self::class, 'product_name' ) ) as $item ) { $fields = array(); foreach ( $item['data'] as $key => $value ) { $fields[] = array( 'name' => $labels[ $key ], 'value' => $value, ); } $data[] = array( 'group_id' => 'fitzaro-tryons', 'group_label' => __( 'Virtual try-ons', 'fitzaro' ), 'item_id' => $item['id'], 'data' => $fields, ); } return array( 'data' => $data, 'done' => true, ); } /** * Eraser callback. * * @param string $email Email address. * @return array{items_removed: bool, items_retained: bool, messages: list, done: bool} */ public static function erase( $email ): array { $user = get_user_by( 'email', (string) $email ); $files = Storage::store(); $count = $user instanceof \WP_User && null !== $files ? PersonalData::erase( Jobs::requests(), $files, (int) $user->ID ) : 0; return array( 'items_removed' => $count > 0, 'items_retained' => false, 'messages' => array(), 'done' => true, ); } /** * Name of a product for the export. * * @param int $product_id Product ID. */ public static function product_name( int $product_id ): string { $product = wc_get_product( $product_id ); /* translators: %d: product ID. */ return $product instanceof \WC_Product ? $product->get_name() : sprintf( __( 'Product #%d (deleted)', 'fitzaro' ), $product_id ); } /** * Suggested privacy policy text (Settings → Privacy → Policy guide). */ public static function add_policy_text(): void { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } $paragraphs = array( __( 'When you use the virtual try-on on a product page, the photo you upload is re-encoded without its metadata and stored privately on this site. It is sent, together with the product image, to OpenAI, which creates the preview image. OpenAI\'s privacy policy: https://openai.com/policies/privacy-policy', 'fitzaro' ), __( 'Your photo is deleted within 24 hours and the preview within 7 days. You can delete both sooner in the try-on window. A record of the try-on without any image (product, date, status, a hashed browser identifier and a hashed IP address) is kept for up to 90 days for usage limits and cost tracking.', 'fitzaro' ), __( 'A functional cookie, fitzaro_visitor, is set when you upload a photo so that only your browser can see your photo and preview. It expires when you close the browser.', 'fitzaro' ), __( 'If you were logged in, your try-ons are included when you ask for an export or erasure of your personal data.', 'fitzaro' ), ); wp_add_privacy_policy_content( 'Fitzaro', '

' . esc_html__( 'Suggested text:', 'fitzaro' ) . '

' . implode( '

', array_map( 'esc_html', $paragraphs ) ) . '

' ); } }