<?php
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*
* @package GridFeel 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 gridfeel_widgets_init() {

register_sidebar(array(
    'id' => 'gridfeel-header-ad',
    'name' => esc_html__( 'Header Right Widgets', 'gridfeel' ),
    'description' => esc_html__( 'This widget area is located on the right side of the header of your web page. You can drag and drop a "Custom HTML" widget into this widget area and add your 728x90 banner ad code into that widget. You need to select "Header Layout" as "Logo + Header Banner" from theme options to display this widget area.', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-header-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridfeel-widget-title">',
    'after_title' => '</h2>'));

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

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

register_sidebar(array(
    'id' => 'gridfeel-home-fullwidth-widgets',
    'name' => esc_html__( 'Top Full Width Widgets (Default HomePage)', 'gridfeel' ),
    '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).', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-fullwidth-widgets',
    'name' => esc_html__( 'Top Full Width Widgets (Everywhere)', 'gridfeel' ),
    '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.', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-home-top-widgets',
    'name' => esc_html__( 'Above Content Widgets (Default HomePage)', 'gridfeel' ),
    '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).', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-top-widgets',
    'name' => esc_html__( 'Above Content Widgets (Everywhere)', 'gridfeel' ),
    '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.', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-home-left-top-widgets',
    'name' => esc_html__( 'Top Left Widgets (Default HomePage)', 'gridfeel' ),
    '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).', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-left-top-widgets',
    'name' => esc_html__( 'Top Left Widgets (Everywhere)', 'gridfeel' ),
    '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.', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-home-right-top-widgets',
    'name' => esc_html__( 'Top Right Widgets (Default HomePage)', 'gridfeel' ),
    '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).', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-right-top-widgets',
    'name' => esc_html__( 'Top Right Widgets (Everywhere)', 'gridfeel' ),
    '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.', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-home-bottom-widgets',
    'name' => esc_html__( 'Below Content Widgets (Default HomePage)', 'gridfeel' ),
    '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).', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-bottom-widgets',
    'name' => esc_html__( 'Below Content Widgets (Everywhere)', 'gridfeel' ),
    '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.', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-home-fullwidth-bottom-widgets',
    'name' => esc_html__( 'Bottom Full Width Widgets (Default HomePage)', 'gridfeel' ),
    '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).', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

register_sidebar(array(
    'id' => 'gridfeel-fullwidth-bottom-widgets',
    'name' => esc_html__( 'Bottom Full Width Widgets (Everywhere)', 'gridfeel' ),
    '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.', 'gridfeel' ),
    'before_widget' => '<div id="%1$s" class="gridfeel-main-widget widget gridfeel-widget-box %2$s"><div class="gridfeel-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridfeel-widget-header"><h2 class="gridfeel-widget-title"><span class="gridfeel-widget-title-inside">',
    'after_title' => '</span></h2></div>'));

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

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

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

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

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

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

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

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

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


function gridfeel_sidebar_one_widgets() {
    dynamic_sidebar( 'gridfeel-sidebar-one' );
}

function gridfeel_sidebar_two_widgets() {
    dynamic_sidebar( 'gridfeel-sidebar-two' );
}

function gridfeel_top_wide_widgets() { ?>

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

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

<?php }


function gridfeel_top_widgets() { ?>

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

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

<?php }


function gridfeel_top_left_right_widgets() { ?>

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

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

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

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

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

</div>

<?php }


function gridfeel_bottom_widgets() { ?>

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

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

<?php }


function gridfeel_bottom_wide_widgets() { ?>

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

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

<?php }


function gridfeel_404_widgets() { ?>

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

<?php }


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