<?php
/**
* Widget Functions.
*
* @package Business Classified Ads
*/

function business_classified_ads_widgets_init(){

	register_sidebar(array(
	    'name' => esc_html__('Main Sidebar', 'business-classified-ads'),
	    'id' => 'sidebar-1',
	    'description' => esc_html__('Add widgets here.', 'business-classified-ads'),
	    'before_widget' => '<div id="%1$s" class="widget %2$s">',
	    'after_widget' => '</div>',
	    'before_title' => '<h3 class="widget-title"><span>',
	    'after_title' => '</span></h3>',
	));

	register_sidebar( array(
		'name'          => esc_html__( 'Topbar weather', 'business-classified-ads' ),
		'id'            => 'topbar-widget',
		'description'   => esc_html__( 'Appears on topbar', 'business-classified-ads' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h3 class="widget-title"><span>',
		'after_title'   => '</span></h3>',
	) );

    $business_classified_ads_default = business_classified_ads_get_default_theme_options();
    $business_classified_ads_footer_column_layout = absint( get_theme_mod( 'business_classified_ads_footer_column_layout',$business_classified_ads_default['business_classified_ads_footer_column_layout'] ) );

    for( $i = 0; $i < $business_classified_ads_footer_column_layout; $i++ ){
    	
    	if( $i == 0 ){ $count = esc_html__('One','business-classified-ads'); }
    	if( $i == 1 ){ $count = esc_html__('Two','business-classified-ads'); }
    	if( $i == 2 ){ $count = esc_html__('Three','business-classified-ads'); }

	    register_sidebar( array(
	        'name' => esc_html__('Footer Widget ', 'business-classified-ads').$count,
	        'id' => 'business-classified-ads-footer-widget-'.$i,
	        'description' => esc_html__('Add widgets here.', 'business-classified-ads'),
	        'before_widget' => '<div id="%1$s" class="widget %2$s">',
	        'after_widget' => '</div>',
	        'before_title' => '<h2 class="widget-title">',
	        'after_title' => '</h2>',
	    ));
	}

}

add_action('widgets_init', 'business_classified_ads_widgets_init');