<?php

defined( 'ABSPATH' ) || exit;
/**
 * Listing Form template part.
 *
 * Expected variables (via extract in getTemplatePart):
 * @var string $form_id  Form config ID (e.g. 'inquiry').
 * @var int    $post_id  Listing post ID.
 * @var string $title    Optional form title.
 *
 * @package ThemeREX\AutoDealer
 */

use ThemeREX\AutoDealer\Forms\FormRenderer;

$form_id = $form_id ?? 'inquiry';
$post_id = $post_id ?? (int) get_the_ID();
$title   = $title ?? '';

$html = FormRenderer::render( $form_id, $post_id );

if ( '' === $html ) {
	return;
}

if ( '' !== $title ) {
	echo '<h2 class="trx-ad-form-title">' . esc_html( $title ) . '</h2>';
}

echo wp_kses( $html, \ThemeREX\AutoDealer\allowedHtml() );
