<?php
/**
 * @category    FishPig
 * @package     FishPig_WordPress
 * @author      Ben Tideswell <help@fishpig.co.uk>
 */
// phpcs:ignoreFile -- long lines (todo)
?>
<?php $items = $block->getDateItems() ?>
<?php if ($items): ?>
    <div class="block block-blog block-blog-archives">
        <?php if ($title = $block->getTitle()): ?>
            <div class="block-title">
                <strong><?= $block->escapeHtml(__($title)) ?></strong>
            </div>
        <?php endif; ?>
        <div class="block-content">
            <div id="calendar_wrap">
                <table id="wp-calendar">
                    <thead>
                        <tr>
                            <th scope="col"><?= $block->escapeHtml(__('M')) ?></th>
                            <th scope="col"><?= $block->escapeHtml(__('T')) ?></th>
                            <th scope="col"><?= $block->escapeHtml(__('W')) ?></th>
                            <th scope="col"><?= $block->escapeHtml(__('T')) ?></th>
                            <th scope="col"><?= $block->escapeHtml(__('F')) ?></th>
                            <th scope="col"><?= $block->escapeHtml(__('S')) ?></th>
                            <th scope="col"><?= $block->escapeHtml(__('S')) ?></th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr>
                            <?php if ($block->hasPreviousUrl()): ?>
                                <td colspan="3" class="a-left">
                                    <a href="<?= $block->escapeUrl($block->getPreviousUrl()) ?>">&laquo; <?= $block->escapeHtml($block->getPreviousText()) ?></a>
                                </td>
                            <?php else: ?>
                                <td colspan="3" class="pad">&nbsp;</td>
                            <?php endif; ?>
                            <td class="pad">&nbsp;</td>
                            <?php if ($block->hasNextUrl()): ?>
                                <td colspan="3" class="a-right">
                                    <a href="<?= $block->escapeUrl($block->getNextUrl()) ?>"><?= $block->escapeHtml($block->getNextText()) ?> &raquo;</a>
                                </td>
                            <?php else: ?>
                                <td colspan="3" class="pad">&nbsp;</td>
                            <?php endif; ?>
                        </tr>
                    </tfoot>
                    <tbody>
                        <?php foreach ($items as $it => $row): ?>
                            <tr>
                                <?php foreach ($row as $html): ?>
                                    <?php if ($html === null): ?>
                                        <td class="pad">&nbsp;</td>
                                    <?php else: ?>
                                        <td><?= /* @noEscape */ $html ?></td>
                                    <?php endif; ?>
                                <?php endforeach; ?>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<?php endif; ?>