inactive(); if ( null !== $inactive ) { return $inactive; } $email = strtolower( trim( (string) $email ) ); if ( ! is_email( $email ) ) { return [ 'ok' => false, 'error' => 'That email does not look right. Ask the visitor to type it again.', ]; } if ( ! $this->gateway->supports_manage_links() ) { return [ 'ok' => false, 'error' => 'Online changes are not set up on this site. Tell the visitor exactly this: use the Reschedule or Cancel link in your booking confirmation email. Do not replace it with the contact message.', ]; } $intent = in_array( (string) $intent, self::INTENTS, true ) ? (string) $intent : 'view'; $button = __( 'Send link', 'aisentic' ); $this->set_card( 'manage_links', [ 'plugin' => 'timetics', 'email' => $email, 'intent' => $intent, 'hint' => [ 'service' => mb_substr( sanitize_text_field( (string) $hint_service ), 0, 100 ), 'date' => 1 === preg_match( '/^\d{4}-\d{2}-\d{2}$/', (string) $hint_date ) ? (string) $hint_date : '', ], 'button_label' => $button, 'change_label' => __( 'Change email', 'aisentic' ), // The send endpoint accepts only an email the AI made this card for. 'token' => Manage_Links_Service::token( $email ), ] ); return [ 'ok' => true, 'button_label' => $button, // Without this the model called the tool again after a success, and // the visitor got three identical cards. 'shown' => 'The card with the Send link button is on screen now. Do not call timetics-manage-links again for this email. Tell the visitor to tap the button.', ]; } }