<?php
/**
 * EventRegistration Shortcode
 *
 * Renders the event registration form container.
 * Usage: [rtrb_event_registration slug="my-event"]
 *
 * @package RadiusTheme\RadiusBooking\Shortcodes
 * @since   1.2.0
 */

namespace RadiusTheme\RadiusBooking\Shortcodes;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class EventRegistration
 */
class EventRegistration {

	/**
	 * Render the event registration shortcode output.
	 *
	 * @param array $atts Shortcode attributes.
	 *
	 * @return string HTML output.
	 */
	public static function output( $atts = array() ): string {
		$atts = shortcode_atts(
			array(
				'slug' => '',
			),
			$atts,
			'rtrb_event_registration'
		);

		$slug = sanitize_text_field( $atts['slug'] );

		if ( empty( $slug ) && isset( $_GET['event'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
			$slug = sanitize_text_field( wp_unslash( $_GET['event'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		}

		return sprintf(
			'<div class="rtrb-event-registration" data-slug="%s"></div>',
			esc_attr( $slug )
		);
	}
}
