<?php
/**
 * MeetingBooking Shortcode
 *
 * Renders the meeting booking form container.
 * Usage: [rtrb_meeting_booking slug="my-meeting-type"]
 *
 * @package RadiusTheme\RadiusBooking\Shortcodes
 * @since   1.2.0
 */

namespace RadiusTheme\RadiusBooking\Shortcodes;

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

/**
 * Class MeetingBooking
 */
class MeetingBooking {

	/**
	 * Render the meeting booking 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_meeting_booking'
		);

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

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

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