
<?php
/**
 * The sidebar containing the main widget area
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package computer-repair-solutions
 */
?>

<aside id="secondary" class="widget-area">
	<?php dynamic_sidebar( 'sidebar-1' ); ?>
</aside><!-- #secondary -->

<?php 
if ( ! is_active_sidebar( 'sidebar-1' ) ) { ?>
    
<aside id="secondary" class="widget-area">

    <!-- SEARCH -->
   <section id="Search" class="widget widget_block widget_archive bg-white rounded p-4 border shadow-sm mb-4 ">
        <h2 class="widget-title "><?php esc_html_e('Search', 'computer-repair-solutions'); ?></h2>
        <?php get_search_form(); ?>
    </section>

    <!-- RECENT POSTS -->
    <section id="recent-posts"
        class="widget bg-white rounded p-4 border shadow-sm mb-4"
        role="complementary">
        
        <h2 class="widget-title mb-3">
            <?php esc_html_e('Recent Posts', 'computer-repair-solutions'); ?>
        </h2>

        <ul class="list-unstyled mb-0">
            <?php
            $computer_repair_solutions_recent_posts = get_posts(
                array(
                    'numberposts' => 5,
                    'post_status' => 'publish',
                )
            );

            foreach ( $computer_repair_solutions_recent_posts as $computer_repair_solutions_post ) :
                setup_postdata( $computer_repair_solutions_post );
                ?>
                <li class="mb-2">
                    <a href="<?php echo esc_url( get_permalink( $computer_repair_solutions_post->ID ) ); ?>"
                       class="text-decoration-none text-dark">
                        <?php echo esc_html( get_the_title( $computer_repair_solutions_post->ID ) ); ?>
                    </a>
                </li>
            <?php endforeach; wp_reset_postdata(); ?>
        </ul>
    </section>

    <!-- ARCHIVES -->
    <section id="archives"
        class="widget widget_block widget_archive bg-white rounded p-4 border shadow-sm mb-4">
        
        <h2 class="widget-title mb-3">
            <?php esc_html_e('Archives', 'computer-repair-solutions'); ?>
        </h2>

        <ul class="list-unstyled mb-0">
            <?php
            wp_get_archives(array(
                'type'            => 'monthly',
                'show_post_count' => true,
            ));
            ?>
        </ul>
    </section>

    <!-- CATEGORIES -->
    <section id="categories"
        class="widget widget_categories bg-white rounded p-4 border shadow-sm"
        role="complementary">
        
        <h2 class="widget-title mb-3">
            <?php esc_html_e('Categories', 'computer-repair-solutions'); ?>
        </h2>

        <ul class="list-unstyled mb-0">
            <?php
            wp_list_categories(array(
                'orderby'    => 'name',
                'title_li'   => '',
                'show_count' => true,
            ));
            ?>
        </ul>
    </section>

</aside><!-- #secondary -->

<?php } ?>

