<?php
if ( ! defined( 'ABSPATH' ) ) exit;

use PaymentPage\PaymentForm as PP_PaymentForm;

get_header();

$post_id = get_the_ID();
?>

<div class="payment-page-single-form-wrap" style="max-width: 960px; margin: 40px auto; padding: 0 20px;">
<?php
$post_status = get_post_status( $post_id );

if ( 'draft' === $post_status ) {
	if ( ! current_user_can( PAYMENT_PAGE_ADMIN_CAP ) ) {
		echo '<p>' . esc_html__( 'This payment form is not currently available.', 'payment-page' ) . '</p>';
		echo '</div>';
		get_footer();
		return;
	}

	echo '<p data-payment-page-notification="warning">' . esc_html__( 'This form is currently in draft mode, and cannot be viewed by non-admin users', 'payment-page' ) . '</p>';
}

payment_page_register_universal_interface();

// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is generated by PaymentForm::get_from_payment_form_id which handles its own escaping
echo PP_PaymentForm::instance()->get_from_payment_form_id( $post_id );
?>
</div>

<?php get_footer(); ?>
