<ul class="tabnav el">
    <?php
    $class = '';
    if ($_SERVER['SCRIPT_NAME']=='/shop/admin/categories/manage.categories.php'
        || ($_SERVER['SCRIPT_NAME']=='/shop/admin/categories/edit.category.php' && !empty($_REQUEST['id']))
    ) {
        $class = 'selected';
    }
    $manage_url = !empty($_REQUEST['id']) ?
        '/shop/admin/categories/edit.category.php?id=' . $_REQUEST['id'] :
        '/shop/admin/categories/manage.categories.php';
    ?>
    <li class="<?= $class ?>">
        <a href="<?=$manage_url; ?>">
            Manage
        </a>
    </li>
    <?php
    $class = '';
    if ($_SERVER['SCRIPT_NAME']=='/shop/admin/categories/edit.category.php' && empty($_REQUEST['id'])) {
        $class = 'selected';
    }
    $sub_id_param = !empty($_REQUEST['sub_id']) ? 'sub_id=' . $_REQUEST['sub_id'] : '';
    ?>
    <li class="<?= $class ?>">
        <a href="/shop/admin/categories/edit.category.php?<?= $sub_id_param ?>">
            Add
        </a>
    </li>
    <?php
    if (!empty($_REQUEST['id'])) {
        if (is_dir($_SERVER['DOCUMENT_ROOT'] . '/modules/BlockRegistry')) {
            $class = strpos($_SERVER['REQUEST_URI'], '/modules/BlockRegistry/admin/categories/blocks.php') !== false ? 'selected' : '';
            ?>
            <li class="<?= $class ?>">
                <a href="/modules/BlockRegistry/admin/categories/blocks.php?id=<?= (int) $_REQUEST['id']; ?>">
                    Blocks
                </a>
            </li>
            <?php
        }
    }
    ?>
</ul>
