<?php
/**
 * @category    FishPig
 * @package     FishPig_WordPress
 * @author      Ben Tideswell <help@fishpig.co.uk>
 */
// phpcs:ignoreFile -- long lines
?>
<form id="respond" method="post" action="<?= $block->escapeUrl($block->getCommentFormAction()) ?>">
    <input type="hidden" name="comment_post_ID" value="<?= (int)$block->getPostId() ?>"/>
    <input type="hidden" name="comment_parent" id="comment_parent" value="<?= (int)$block->getRequest()->getParam('replytocom', 0) ?>"/>
    <input type="hidden" name="redirect_to" value="<?= $block->escapeUrl($block->getRedirectToUrl()) ?>"/>
    <fieldset class="fieldset">
        <legend class="legend"><?= $block->escapeHtml(__('Leave a Reply')) ?></legend>
        <?php if ($block->customerMustLogin()): ?>    
            <div class="field note no-label"><?= $block->escapeHtml(__('Sorry, you must be logged in to post a comment.')) ?></div>
            <div class="field note no-label"><button class="button btn-login" type="button" onclick="window.location.href=encodeURI('<?= $block->escapeUrl($block->getLoginLink()) ?>')"><span><span><?= $block->escapeHtml(__('Login')) ?></span></span></button></div>
        <?php else: ?>
                <?php if (!$block->isCustomerLoggedIn()): ?>
                    <div class="field required">
                        <label class="label"><?= $block->escapeHtml(__('Name')) ?></label>
                        <div class="control">
                            <input type="text" id="author" name="author" class="input-text required-entry" value=""/>
                        </div>
                    </div>
                    <div class="field required">
                        <label for="email" class="label"><?= $block->escapeHtml(__('Email')) ?></label>
                        <div class="control">
                            <input type="text" id="email" name="email" class="input-text required-entry validate-email" value=""/>
                        </div>
                    </div>
                <?php else: ?>
                    <input type="hidden" id="author" name="author" value="<?= $block->escapeHtml($block->getCustomerName()) ?>"/>
                    <input type="hidden" id="email" name="email" value="<?= $block->escapeHtml($block->getCustomerEmail()) ?>"/>
                <?php endif; ?>
                <div class="field">
                    <label for="url" class="label"><?= $block->escapeHtml(__('Website')) ?></label>
                    <div class="control">
                        <input type="text" id="url" name="url" class="input-text" value=""/>
                    </div>
                </div>
                <div class="field required">
                    <label for="comment" class="label"><?= $block->escapeHtml(__('Comment')) ?></label>
                    <div class="control">
                        <textarea id="comment" name="comment" rows="8" cols="45" class="required-entry"></textarea>
                    </div>
                </div>
                <?= $block->getChildHtml('before_form_end') ?>
        <?php endif; ?>
    </fieldset>
    <?php if (!$block->customerMustLogin()): ?>    
    <div class="actions-toolbar">
        <div class="primary">
        <button type="submit" name="submit"  class="action submit primary" value="Post your comment" id="post-the-comment">
            <span><?= $block->escapeHtml(__('Leave a comment')) ?></span>
        </button>
        </div>
        <span class="please-wait" id="respond-please-wait" style="display:none;">
            <img src="<?= $block->escapeUrl($block->getSkinUrl('images/opc-ajax-loader.gif')) ?>" alt="<?= $block->escapeHtml(__('Loading next step...')) ?>" title="<?= $block->escapeHtml(__('Please wait...')) ?>" class="v-middle" /> <?= $block->escapeHtml(__('Please wait...')) ?>
        </span>
    </div>
    <?php endif; ?>
</form>
<script type="text/x-magento-init">{"#respond":{"validation":{}}}</script>