locations = new LocationsRepository(); } public function register(): void { add_action( 'template_redirect', array( $this, 'maybe_render' ) ); } public function maybe_render(): void { // Contact-help messages from links in booking emails; display only. $message = (string) ( \Abientot\Support\Request::view( 'abientot_booking_message', 'key' ) ?? '' ); $action = (string) ( \Abientot\Support\Request::view( 'abientot_booking_action', 'key' ) ?? '' ); $private_link = false; foreach ( array( 'abientot_portal', 'abientot_series', 'abientot_credits', 'abientot_credit_booking', 'abientot_guardian', 'abientot_waitlist', 'abientot_waitlist_signup' ) as $key ) { $private_link = $private_link || \Abientot\Support\Request::has_view( $key ); } // Paid routes render earlier when available; retained links otherwise lead to contact help. if ( ! $private_link && '' === $message && ! in_array( $action, array( 'cancel', 'reschedule' ), true ) ) { return; } nocache_headers(); header( 'Cache-Control: private, no-store, max-age=0' ); header( 'Referrer-Policy: no-referrer' ); header( 'X-Robots-Tag: noindex, nofollow' ); wp_enqueue_style( 'abientot-frontend' ); get_header(); echo '
'; echo '
'; echo '

' . esc_html__( 'Booking request', 'abientot' ) . '

'; echo '

' . esc_html( $this->message_text( $message, $action ) ) . '

'; $this->render_contact_details(); echo '
'; echo '
'; get_footer(); exit; } private function message_text( string $message, string $action ): string { if ( 'cancel' === $action || 'contact-cancel' === $message ) { return __( 'Please contact the business to cancel your booking.', 'abientot' ); } if ( 'reschedule' === $action || 'contact-reschedule' === $message ) { return __( 'Please contact the business to choose a new time.', 'abientot' ); } return __( 'This link is unavailable. Please contact the business for help.', 'abientot' ); } private function render_contact_details(): void { self::print_contact_details( $this->locations->default_location() ); } public static function print_contact_details( ?array $location ): void { $settings = Settings::values(); $email = is_array( $location ) && is_email( (string) ( $location['email'] ?? '' ) ) ? (string) $location['email'] : (string) $settings['email_reply_to_address']; $phone = is_array( $location ) ? trim( (string) ( $location['phone'] ?? '' ) ) : ''; // Only addresses the business entered for customers are shown, never the site admin address. if ( ! is_email( $email ) ) { $email = ''; } if ( '' === $phone && '' === $email ) { return; } echo '
'; if ( '' !== $phone ) { echo '
' . esc_html__( 'Phone', 'abientot' ) . '
' . esc_html( $phone ) . '
'; } if ( '' !== $email ) { echo '
' . esc_html__( 'Email', 'abientot' ) . '
' . esc_html( $email ) . '
'; } echo '
'; } }