email_service = new EmailService(); } public function register(): void { add_action( 'admin_post_abientot_send_test_email', array( $this, 'send_test_email' ) ); } /** * Renders template helper, preview, and test email controls. */ public function render_tools(): void { $template_key = (string) ( Request::view( 'template', 'key' ) ?? 'customer_confirmation' ); if ( ! isset( EmailService::template_labels()[ $template_key ] ) ) { $template_key = 'customer_confirmation'; } $booking_id = (int) Request::view( 'booking_id', 'int' ); $preview = $this->email_service->preview( $template_key, $booking_id ); $this->notice(); ?>

{business_name} {booking_id} {customer_name} {customer_email} {customer_phone} {service_name} {staff_name} {location_name} {status} {start} {end} {price} {payment_status} {customer_note} {site_url} {cancellation_contact} {rescheduling_contact}

email_service->send_test( $template_key, $recipient, $booking_id, $subject, $body ); $notice = is_wp_error( $result ) ? 'email-test-failed' : 'email-test-sent'; wp_safe_redirect( RedirectNotice::url( add_query_arg( array( 'page' => 'abientot-settings', 'tab' => 'communication', 'template' => $template_key, 'booking_id' => $booking_id, ), admin_url( 'admin.php' ) ), array( 'abientot_notice' => $notice ) ) ); exit; } private function notice(): void { $notice = RedirectNotice::get( 'abientot_notice' ); if ( '' === $notice ) { return; } $map = array( 'email-test-sent' => array( 'success', __( 'Test email sent.', 'abientot' ) ), 'email-test-failed' => array( 'error', __( 'The test email could not be sent.', 'abientot' ) ), ); if ( isset( $map[ $notice ] ) ) { echo '

' . esc_html( $map[ $notice ][1] ) . '

'; } } }