<?php
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*
* @package GridMini WordPress Theme
* @copyright Copyright (C) 2025 ThemesDNA
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
* @author ThemesDNA <themesdna@gmail.com>
*/

function gridmini_widgets_init() {

register_sidebar(array(
    'id' => 'gridmini-sidebar-one',
    'name' => esc_html__( 'Sidebar 1 Widgets', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located on the left-hand side of your web page.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-side-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-home-fullwidth-widgets',
    'name' => esc_html__( 'Top Full Width Widgets (Default HomePage)', 'gridmini' ),
    'description' => esc_html__( 'This full-width widget area is located after the header of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-fullwidth-widgets',
    'name' => esc_html__( 'Top Full Width Widgets (Everywhere)', 'gridmini' ),
    'description' => esc_html__( 'This full-width widget area is located after the header of your website. Widgets of this widget area are displayed on every page of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-home-top-widgets',
    'name' => esc_html__( 'Above Content Widgets (Default HomePage)', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located at the top of the main content (above posts) of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-top-widgets',
    'name' => esc_html__( 'Above Content Widgets (Everywhere)', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located at the top of the main content (above posts) of your website. Widgets of this widget area are displayed on every page of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-home-left-top-widgets',
    'name' => esc_html__( 'Top Left Widgets (Default HomePage)', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located at the left top of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-left-top-widgets',
    'name' => esc_html__( 'Top Left Widgets (Everywhere)', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located at the left top of your website. Widgets of this widget area are displayed on every page of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-home-right-top-widgets',
    'name' => esc_html__( 'Top Right Widgets (Default HomePage)', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located at the right top of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-right-top-widgets',
    'name' => esc_html__( 'Top Right Widgets (Everywhere)', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located at the right top of your website. Widgets of this widget area are displayed on every page of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-home-bottom-widgets',
    'name' => esc_html__( 'Below Content Widgets (Default HomePage)', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located at the bottom of the main content (below posts) of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-bottom-widgets',
    'name' => esc_html__( 'Below Content Widgets (Everywhere)', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located at the bottom of the main content (below posts) of your website. Widgets of this widget area are displayed on every page of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-home-fullwidth-bottom-widgets',
    'name' => esc_html__( 'Bottom Full Width Widgets (Default HomePage)', 'gridmini' ),
    'description' => esc_html__( 'This full-width widget area is located before the footer of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-fullwidth-bottom-widgets',
    'name' => esc_html__( 'Bottom Full Width Widgets (Everywhere)', 'gridmini' ),
    'description' => esc_html__( 'This full-width widget area is located before the footer of your website. Widgets of this widget area are displayed on every page of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-single-post-bottom-widgets',
    'name' => esc_html__( 'Single Post Bottom Widgets', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located at the bottom of single post of any post type (except attachments and pages).', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridmini-top-footer',
    'name' => esc_html__( 'Footer Top Widgets', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located on the top of the footer of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridmini-footer-1',
    'name' => esc_html__( 'Footer 1 Widgets', 'gridmini' ),
    'description' => esc_html__( 'This widget area is the column 1 of the footer of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridmini-footer-2',
    'name' => esc_html__( 'Footer 2 Widgets', 'gridmini' ),
    'description' => esc_html__( 'This widget area is the column 2 of the footer of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridmini-footer-3',
    'name' => esc_html__( 'Footer 3 Widgets', 'gridmini' ),
    'description' => esc_html__( 'This widget area is the column 3 of the footer of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridmini-footer-4',
    'name' => esc_html__( 'Footer 4 Widgets', 'gridmini' ),
    'description' => esc_html__( 'This widget area is the column 4 of the footer of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridmini-footer-5',
    'name' => esc_html__( 'Footer 5 Widgets', 'gridmini' ),
    'description' => esc_html__( 'This widget area is the column 5 of the footer of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridmini-bottom-footer',
    'name' => esc_html__( 'Footer Bottom Widgets', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located on the bottom of the footer of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridmini-404-widgets',
    'name' => esc_html__( '404 Page Widgets', 'gridmini' ),
    'description' => esc_html__( 'This widget area is located on the 404(not found) page of your website.', 'gridmini' ),
    'before_widget' => '<div id="%1$s" class="gridmini-main-widget widget gridmini-widget-box %2$s"><div class="gridmini-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridmini-widget-header"><h2 class="gridmini-widget-title"><span class="gridmini-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

}
add_action( 'widgets_init', 'gridmini_widgets_init' );


function gridmini_sidebar_one_widgets() {
    dynamic_sidebar( 'gridmini-sidebar-one' );
}

function gridmini_top_wide_widgets() { ?>

<?php if ( is_active_sidebar( 'gridmini-home-fullwidth-widgets' ) || is_active_sidebar( 'gridmini-fullwidth-widgets' ) ) : ?>
<div class="gridmini-outer-wrapper">
<div class="gridmini-top-wrapper-outer gridmini-clearfix">
<div class="gridmini-featured-posts-area gridmini-top-wrapper gridmini-clearfix">
<?php if ( is_front_page() && is_home() && !is_paged() ) { ?>
<?php dynamic_sidebar( 'gridmini-home-fullwidth-widgets' ); ?>
<?php } ?>

<?php dynamic_sidebar( 'gridmini-fullwidth-widgets' ); ?>
</div>
</div>
</div>
<?php endif; ?>

<?php }


function gridmini_top_widgets() { ?>

<?php if ( is_active_sidebar( 'gridmini-home-top-widgets' ) || is_active_sidebar( 'gridmini-top-widgets' ) ) : ?>
<div class="gridmini-featured-posts-area gridmini-featured-posts-area-top gridmini-clearfix">
<?php if ( is_front_page() && is_home() && !is_paged() ) { ?>
<?php dynamic_sidebar( 'gridmini-home-top-widgets' ); ?>
<?php } ?>

<?php dynamic_sidebar( 'gridmini-top-widgets' ); ?>
</div>
<?php endif; ?>

<?php }


function gridmini_top_left_right_widgets() { ?>

<div class="gridmini-left-right-wrapper gridmini-clearfix">

<?php if ( is_active_sidebar( 'gridmini-home-left-top-widgets' ) || is_active_sidebar( 'gridmini-left-top-widgets' ) ) : ?>
<div class="gridmini-left-top-wrapper">
<div class="gridmini-featured-posts-area gridmini-featured-posts-area-top gridmini-clearfix">
<?php if ( is_front_page() && is_home() && !is_paged() ) { ?>
<?php dynamic_sidebar( 'gridmini-home-left-top-widgets' ); ?>
<?php } ?>

<?php dynamic_sidebar( 'gridmini-left-top-widgets' ); ?>
</div>
</div>
<?php endif; ?>

<?php if ( is_active_sidebar( 'gridmini-home-right-top-widgets' ) || is_active_sidebar( 'gridmini-right-top-widgets' ) ) : ?>
<div class="gridmini-right-top-wrapper">
<div class="gridmini-featured-posts-area gridmini-featured-posts-area-top gridmini-clearfix">
<?php if ( is_front_page() && is_home() && !is_paged() ) { ?>
<?php dynamic_sidebar( 'gridmini-home-right-top-widgets' ); ?>
<?php } ?>

<?php dynamic_sidebar( 'gridmini-right-top-widgets' ); ?>
</div>
</div>
<?php endif; ?>

</div>

<?php }


function gridmini_bottom_widgets() { ?>

<?php if ( is_active_sidebar( 'gridmini-home-bottom-widgets' ) || is_active_sidebar( 'gridmini-bottom-widgets' ) ) : ?>
<div class='gridmini-featured-posts-area gridmini-featured-posts-area-bottom gridmini-clearfix'>
<?php if ( is_front_page() && is_home() && !is_paged() ) { ?>
<?php dynamic_sidebar( 'gridmini-home-bottom-widgets' ); ?>
<?php } ?>

<?php dynamic_sidebar( 'gridmini-bottom-widgets' ); ?>
</div>
<?php endif; ?>

<?php }


function gridmini_bottom_wide_widgets() { ?>

<?php if ( is_active_sidebar( 'gridmini-home-fullwidth-bottom-widgets' ) || is_active_sidebar( 'gridmini-fullwidth-bottom-widgets' ) ) : ?>
<div class="gridmini-outer-wrapper">
<div class="gridmini-bottom-wrapper-outer gridmini-clearfix">
<div class="gridmini-featured-posts-area gridmini-bottom-wrapper gridmini-clearfix">
<?php if ( is_front_page() && is_home() && !is_paged() ) { ?>
<?php dynamic_sidebar( 'gridmini-home-fullwidth-bottom-widgets' ); ?>
<?php } ?>

<?php dynamic_sidebar( 'gridmini-fullwidth-bottom-widgets' ); ?>
</div>
</div>
</div>
<?php endif; ?>

<?php }


function gridmini_404_widgets() { ?>

<?php if ( is_active_sidebar( 'gridmini-404-widgets' ) ) : ?>
<div class="gridmini-featured-posts-area gridmini-featured-posts-area-top gridmini-clearfix">
<?php dynamic_sidebar( 'gridmini-404-widgets' ); ?>
</div>
<?php endif; ?>

<?php }


function gridmini_post_bottom_widgets() {
    if ( is_singular() ) {
        global $post;
        if ( is_active_sidebar( 'gridmini-single-post-bottom-widgets' ) ) : ?>
            <div class="gridmini-featured-posts-area gridmini-clearfix">
            <?php dynamic_sidebar( 'gridmini-single-post-bottom-widgets' ); ?>
            </div>
        <?php endif;
    }
}