__( 'LaunchList signups waiting to be sent', 'launchlist' ), 'callback' => array( __CLASS__, 'export' ), ); return $exporters; } /** * Register the eraser. * * @param array $erasers Erasers. * @return array */ public static function register_eraser( $erasers ) { $erasers = is_array( $erasers ) ? $erasers : array(); $erasers[ self::KEY ] = array( 'eraser_friendly_name' => __( 'LaunchList signups waiting to be sent', 'launchlist' ), 'callback' => array( __CLASS__, 'erase' ), ); return $erasers; } /** * Export the waiting submissions that hold an email address. The queue is capped, so one page * holds them all. * * @param string $email The email address. * @param int $page Page (always one). * @return array{data: array, done: bool} */ public static function export( $email, $page = 1 ) { $items = array(); foreach ( self::rows_for( $email ) as $row ) { $payload = $row['payload']; $fields = array(); foreach ( $payload['data'] as $key => $value ) { $fields[] = $key . ': ' . $value; } $items[] = array( 'group_id' => 'launchlist-queue', 'group_label' => __( 'LaunchList signups waiting to be sent', 'launchlist' ), 'item_id' => 'launchlist-queue-' . $row['id'], 'data' => array( array( 'name' => __( 'Submitted', 'launchlist' ), 'value' => $row['created_at'] . ' UTC', ), array( 'name' => __( 'Form', 'launchlist' ), 'value' => isset( $payload['source_form'] ) ? (string) $payload['source_form'] : '', ), array( 'name' => __( 'LaunchList form', 'launchlist' ), 'value' => isset( $payload['form'] ) ? (string) $payload['form'] : '', ), array( 'name' => __( 'What was entered', 'launchlist' ), 'value' => implode( "\n", $fields ), ), array( 'name' => __( 'Status', 'launchlist' ), 'value' => Queue::FAILED === $row['status'] ? __( 'Could not be sent', 'launchlist' ) : __( 'Waiting to be sent', 'launchlist' ), ), ), ); } return array( 'data' => $items, 'done' => true, ); } /** * Delete the waiting submissions that hold an email address. * * @param string $email The email address. * @param int $page Page (always one). * @return array{items_removed: bool, items_retained: bool, messages: array, done: bool} */ public static function erase( $email, $page = 1 ) { $ids = array(); foreach ( self::rows_for( $email ) as $row ) { $ids[] = $row['id']; } if ( $ids ) { Queue::delete_rows( $ids ); } return array( 'items_removed' => ! empty( $ids ), 'items_retained' => false, 'messages' => array(), 'done' => true, ); } /** * Waiting submissions with a value equal to an email address (ignoring case). * * @param string $email The email address. * @return array */ public static function rows_for( $email ) { $email = strtolower( trim( (string) $email ) ); if ( '' === $email ) { return array(); } $rows = array(); foreach ( Queue::rows_containing( $email ) as $row ) { $payload = json_decode( (string) $row['payload'], true ); if ( ! is_array( $payload ) || ! isset( $payload['data'] ) || ! is_array( $payload['data'] ) ) { continue; } foreach ( $payload['data'] as $value ) { if ( is_string( $value ) && strtolower( trim( $value ) ) === $email ) { $rows[] = array( 'id' => (string) $row['id'], 'status' => (string) $row['status'], 'created_at' => (string) $row['created_at'], 'payload' => $payload, ); break; } } } return $rows; } /** * Suggest text for the site's privacy policy (Settings, then Privacy). * * @return void */ public static function add_policy_content() { if ( function_exists( 'wp_add_privacy_policy_content' ) ) { wp_add_privacy_policy_content( 'LaunchList', wp_kses_post( wpautop( self::policy_text(), false ) ) ); } } /** * The privacy policy suggestion. * * @return string */ public static function policy_text() { return implode( "\n\n", array( __( 'This site uses LaunchList (getlaunchlist.com) for its waitlist.', 'launchlist' ), __( 'Pages with a LaunchList form, popup, widget or updates load the LaunchList script from LaunchList\'s servers, and so may every page of this site. Loading it sends LaunchList your IP address and your browser\'s details (its user agent and the address of the page), as loading anything from another site does.', 'launchlist' ), __( 'When you sign up through a LaunchList form on this site, what you enter is sent to LaunchList, which keeps it for this site\'s owner. When you submit one of this site\'s own forms that its owner sends to LaunchList, what you entered in that form is sent to LaunchList from this site\'s server, with the address of the page you submitted it from.', 'launchlist' ), __( 'The LaunchList script remembers the referral link and campaign details (UTM parameters) you arrived with, and the site that sent you here, for up to 90 days: in your browser\'s storage and, when this site sends its own forms to LaunchList, in a cookie on this site named launchlist_attribution. They are sent with your signup so the person who referred you gets credit. They do not include your name or email address.', 'launchlist' ), __( 'If LaunchList cannot take a submission right away, this site keeps it in its database and tries again for up to 24 hours. It is deleted as soon as LaunchList has it, and deleted 7 days after the last try if it could never be sent.', 'launchlist' ), sprintf( /* translators: %s: URL of LaunchList's privacy policy. */ __( 'LaunchList\'s privacy policy: %s', 'launchlist' ), 'https://getlaunchlist.com/legal/privacy' ), ) ); } }