<?php
/**
 * @category    FishPig
 * @package     FishPig_WordPress
 * @author      Ben Tideswell <help@fishpig.co.uk>
 */
// phpcs:ignoreFile -- long lines (todo)
?>
<?php $archives = $block->getArchives() ?>
<?php if (count($archives) > 0): ?>
    <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">
            <ul id="wp-archive-list">
            <?php if ($block->getDropdown()): ?>
                <li class="item">
                    <select name="blog-archive-dropdown" onchange="window.location.href=this.value">
                            <option value="#"><?= $block->escapeHtml(__('Select Month')) ?></option>
                        <?php foreach ($archives as $archive): ?>
                            <option value="<?= $block->escapeUrl($archive->getUrl()) ?>"<?php if ($block->isCurrentArchive($archive)): ?> selected="selected"<?php endif; ?>>
                                <?= $block->escapeHtml($block->translateDate($archive->getName())) ?> <?php if ($block->getCount()): ?> (<?= $block->escapeHtml($archive->getPostCount()) ?>)<?php endif; ?>
                            </option>
                        <?php endforeach; ?>
                    </select>
                </li>
            <?php else: ?>
                <?php foreach ($archives as $archive): ?>
                    <li class="item<?php if ($block->isCurrentArchive($archive)): ?> active<?php endif; ?>">
                        <a href="<?= $block->escapeUrl($archive->getUrl()) ?>" title="<?= $block->escapeHtml($archive->getName()) ?>"><?= $block->escapeHtml($block->translateDate($archive->getName())) ?></a>
                        <?php if ($block->getCount()): ?> (<?= $block->escapeHtml($archive->getPostCount()) ?>)<?php endif; ?>
                    </li>
                <?php endforeach; ?>
            <?php endif; ?>
            </ul>
        </div>
    </div>
<?php endif; ?>