<?php global $syrus; ?>
<div class="main-sidebar">
    <?php if(is_active_sidebar('primary-sidebar')){ ?>
        <?php dynamic_sidebar('primary-sidebar') ?>
    <?php }else{ ?>
        <div class="widget widget-1">
            <img src="<?php echo $syrus->get_img_dir('logo-syrus.png') ;?>" alt="Syrus" width="120" height="100%">
        </div>
        
        <div class="widget widget-3">
            <p class="widget-title"><?php _e('Categorie', 'syrus') ?></p>
            <div class="widget-content widget-categorie">
                <?php foreach($syrus->get_categories_for_sidebar() as $i => $cat){ ?>
                    <li class="cat-item cat-item-<?php echo $cat->term_id; ?>">
                        <a href="<?php echo esc_url(home_url()); ?>/category/<?php echo $cat->slug; ?>" title="<?php echo $cat->name ;?>"><?php echo $cat->name; ?></a>
                    </li>
                    <?php 
                        if(count($syrus->get_categories_for_sidebar())-1!=$i){
                            echo "<hr class='m-0'>";
                        }
                    ?>
                <?php } ?>
            </div>
        </div>

        <?php if(strpos(home_url(),'syrus') !== false && $syrus->has_nav_menu('syrus-theme-directories-menu')){ $directories = $syrus->get_directories_for_sidebar(); ?>

            <div class="widget widget-4">
                <p class="widget-title"><?php _e('Directories', 'syrus') ?></p>
                <div class="widget-content widget-directories">
                    <?php foreach($directories as $index => $menu_item){ ?>
                        <li class="dir-item <?php echo $menu_item->menu_item_parent == 0 ? '' : 'sub-item' ?>">
                            <a href="<?php echo esc_url($menu_item->url) ?>" title="<?php echo $menu_item->title ?>"><?php echo $menu_item->title ?></a>
                        </li>
                        <?php 
                            if(count($directories) - 1 != $index){
                                echo "<hr class='m-0'>";
                            }
                        ?>
                    <?php } ?>
                </div>
            </div>
            
        <?php } ?>

    <?php } ?>

</div>

