Privacy for the * site admin to copy into their published policy. Does not claim any * specific legal compliance on the site owner's behalf. */ function ninetytwo_notify_add_privacy_policy_content() { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } $content = '
' . esc_html__( 'When a visitor subscribes to a product availability alert, we store the email address they provide, the product they are interested in, and the date of their subscription request, in order to send them a notification if that product (or a similar product, where enabled) becomes available. Subscribers can unsubscribe at any time using the link included in every notification email. We do not use this information for unrelated marketing without separate consent.', '92-notify-for-woocommerce' ) . '
'; wp_add_privacy_policy_content( __( '92 Notify', '92-notify-for-woocommerce' ), wp_kses_post( $content ) ); } add_action( 'admin_init', 'ninetytwo_notify_add_privacy_policy_content' ); /** * Registers the personal data exporter for the subscriber email table. * * @param array $exporters Registered exporters, keyed by identifier. * @return array */ function ninetytwo_notify_register_privacy_exporter( $exporters ) { $exporters['92-notify-for-woocommerce'] = array( 'exporter_friendly_name' => __( '92 Notify Subscriptions', '92-notify-for-woocommerce' ), 'callback' => 'ninetytwo_notify_privacy_export_subscriber_data', ); return $exporters; } add_filter( 'wp_privacy_personal_data_exporters', 'ninetytwo_notify_register_privacy_exporter' ); /** * Personal Data Exporter callback for one subscriber's email address. * * @param string $email_address The email address being exported. * @param int $page 1-indexed page of results. * @return array */ function ninetytwo_notify_privacy_export_subscriber_data( $email_address, $page = 1 ) { global $wpdb; $table_name = $wpdb->prefix . 'ninetytwo_notify_subscribers'; $per_page = 100; $rows = $wpdb->get_results( $wpdb->prepare( 'SELECT product_name, product_url, status, created_at, notified_at FROM %i WHERE email = %s ORDER BY id LIMIT %d OFFSET %d', $table_name, $email_address, $per_page, ( (int) $page - 1 ) * $per_page ), ARRAY_A ); $export_items = array(); foreach ( $rows as $index => $row ) { $export_items[] = array( 'group_id' => '92-notify-for-woocommerce', 'group_label' => __( '92 Notify Subscriptions', '92-notify-for-woocommerce' ), 'item_id' => 'ntn-subscriber-' . $page . '-' . $index, 'data' => array( array( 'name' => __( 'Product', '92-notify-for-woocommerce' ), 'value' => $row['product_name'], ), array( 'name' => __( 'Product URL', '92-notify-for-woocommerce' ), 'value' => $row['product_url'], ), array( 'name' => __( 'Status', '92-notify-for-woocommerce' ), 'value' => $row['status'] ? __( 'Active', '92-notify-for-woocommerce' ) : __( 'Unsubscribed', '92-notify-for-woocommerce' ), ), array( 'name' => __( 'Subscribed On', '92-notify-for-woocommerce' ), 'value' => $row['created_at'], ), array( 'name' => __( 'Last Notified', '92-notify-for-woocommerce' ), 'value' => $row['notified_at'] ? $row['notified_at'] : __( 'Never', '92-notify-for-woocommerce' ), ), ), ); } return array( 'data' => $export_items, 'done' => count( $rows ) < $per_page, ); } /** * Registers the personal data eraser for the subscriber email table. * * @param array $erasers Registered erasers, keyed by identifier. * @return array */ function ninetytwo_notify_register_privacy_eraser( $erasers ) { $erasers['92-notify-for-woocommerce'] = array( 'eraser_friendly_name' => __( '92 Notify Subscriptions', '92-notify-for-woocommerce' ), 'callback' => 'ninetytwo_notify_privacy_erase_subscriber_data', ); return $erasers; } add_filter( 'wp_privacy_personal_data_erasers', 'ninetytwo_notify_register_privacy_eraser' ); /** * Personal Data Eraser callback for one subscriber's email address. Deletes * every matching row in a single query, so pagination isn't needed here — * $page is still accepted because WordPress always calls erasers with it. * * @param string $email_address The email address being erased. * @param int $page Unused; required by the eraser callback signature. * @return array */ function ninetytwo_notify_privacy_erase_subscriber_data( $email_address, $page = 1 ) { global $wpdb; $table_name = $wpdb->prefix . 'ninetytwo_notify_subscribers'; $deleted = $wpdb->delete( $table_name, array( 'email' => $email_address ), array( '%s' ) ); return array( 'items_removed' => (bool) $deleted, 'items_retained' => false, 'messages' => array(), 'done' => true, ); }