<?php 

/**
 * Register theme sidebars
 * @package Influential Lite 
 */

 
function influential_lite_widgets_init() {

	register_sidebar( array(
		'name' => esc_html__( 'Blog Right Sidebar', 'influential-lite' ),
		'id' => 'blogright',
		'description' => esc_html__( 'Right sidebar for the blog', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );
	register_sidebar( array(
		'name' => esc_html__( 'Blog Left Sidebar', 'influential-lite' ),
		'id' => 'blogleft',
		'description' => esc_html__( 'Left sidebar for the blog', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );	
	register_sidebar( array(
		'name' => esc_html__( 'Page Right Sidebar', 'influential-lite' ),
		'id' => 'pageright',
		'description' => esc_html__( 'Right sidebar for pages', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );	
	register_sidebar( array(
		'name' => esc_html__( 'Page Left Sidebar', 'influential-lite' ),
		'id' => 'pageleft',
		'description' => esc_html__( 'Left sidebar for pages', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );	

	register_sidebar( array(
		'name' => esc_html__( 'Banner', 'influential-lite' ),
		'id' => 'banner',
		'description' => esc_html__( 'For Images and Sliders.', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h1 class="widget-title">',
		'after_title' => '</h1>',
	) );
	
	register_sidebar( array(
		'name' => esc_html__( 'Content Top 1', 'influential-lite' ),
		'id' => 'ctop1',
		'description' => esc_html__( 'Content Top 1 position', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );
	register_sidebar( array(
		'name' => esc_html__( 'Content Top 2', 'influential-lite' ),
		'id' => 'ctop2',
		'description' => esc_html__( 'Content Top 2 position', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );
	register_sidebar( array(
		'name' => esc_html__( 'Content Top 3', 'influential-lite' ),
		'id' => 'ctop3',
		'description' => esc_html__( 'Content Top 3 position', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );
	register_sidebar( array(
		'name' => esc_html__( 'Content Top 4', 'influential-lite' ),
		'id' => 'ctop4',
		'description' => esc_html__( 'Content Top 4 position', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );		
			
	register_sidebar( array(
		'name' => esc_html__( 'Content Bottom 1', 'influential-lite' ),
		'id' => 'cbottom1',
		'description' => esc_html__( 'Content Bottom 1 position', 'influential-lite' ),
		'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__( 'Content Bottom 2', 'influential-lite' ),
		'id' => 'cbottom2',
		'description' => esc_html__( 'Content Bottom 2 position', 'influential-lite' ),
		'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__( 'Content Bottom 3', 'influential-lite' ),
		'id' => 'cbottom3',
		'description' => esc_html__( 'Content Bottom 3 position', 'influential-lite' ),
		'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__( 'Content Bottom 4', 'influential-lite' ),
		'id' => 'cbottom4',
		'description' => esc_html__( 'Content Bottom 4 position', 'influential-lite' ),
		'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__( 'Bottom 1', 'influential-lite' ),
		'id' => 'bottom1',
		'description' => esc_html__( 'Bottom 1 position', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h4 class="widget-title">',
		'after_title' => '</h4>',
	) );
	register_sidebar( array(
		'name' => esc_html__( 'Bottom 2', 'influential-lite' ),
		'id' => 'bottom2',
		'description' => esc_html__( 'Bottom 2 position', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h4 class="widget-title">',
		'after_title' => '</h4>',
	) );
	register_sidebar( array(
		'name' => esc_html__( 'Bottom 3', 'influential-lite' ),
		'id' => 'bottom3',
		'description' => esc_html__( 'Bottom 3 position', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h4 class="widget-title">',
		'after_title' => '</h4>',
	) );
	register_sidebar( array(
		'name' => esc_html__( 'Bottom 4', 'influential-lite' ),
		'id' => 'bottom4',
		'description' => esc_html__( 'Bottom 4 position', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h4 class="widget-title">',
		'after_title' => '</h4>',
	) );		
	register_sidebar( array(
		'name' => esc_html__( 'Header', 'influential-lite' ),
		'id' => 'header',
		'description' => esc_html__( 'Located in the top header area but limited to header styles 1 and 4', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<div class="widget-title">',
		'after_title' => '</div>',
	) );
	register_sidebar( array(
		'name' => esc_html__( 'Call to Action', 'influential-lite' ),
		'id' => 'cta',
		'description' => esc_html__( 'For adding a Call to Action just below the banner sidebar.', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<div class="widget-title">',
		'after_title' => '</div>',
	) );	
	register_sidebar( array(
		'name' => esc_html__( 'Announcement', 'influential-lite' ),
		'id' => 'announcement',
		'description' => esc_html__( 'This is Announcement position but can be used for other things', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<div class="widget-title">',
		'after_title' => '</div>',
	) );	
	register_sidebar( array(
		'name' => esc_html__( 'Breadcrumbs', 'influential-lite' ),
		'id' => 'breadcrumbs',
		'description' => esc_html__( 'For adding breadcrumb navigation if using a plugin, or you can add content here.', 'influential-lite' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<div class="widget-title">',
		'after_title' => '</div>',
	) );	
	
	// enable landing page section 1 sidebars
	if( esc_attr(get_theme_mod( 'enable_section1_sidebars', 0 ) ) ) :
	
		register_sidebar( array(
			'name' => esc_html__( 'Section 1a', 'influential-lite' ),
			'id' => 'section1-a',
			'description' => esc_html__( 'Section 1 sidebar position 1', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );	
		register_sidebar( array(
			'name' => esc_html__( 'Section 1b', 'influential-lite' ),
			'id' => 'section1-b',
			'description' => esc_html__( 'Section 1 sidebar position 2', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );
		register_sidebar( array(
			'name' => esc_html__( 'Section 1c', 'influential-lite' ),
			'id' => 'section1-c',
			'description' => esc_html__( 'Section 1 sidebar position 3', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );
		register_sidebar( array(
			'name' => esc_html__( 'Section 1d', 'influential-lite' ),
			'id' => 'section1-d',
			'description' => esc_html__( 'Section 1 sidebar position 4', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );		
	endif;	
	
	// enable landing page section 2 sidebars
	if( esc_attr(get_theme_mod( 'enable_section2_sidebars', 0 ) ) ) :	
		register_sidebar( array(
			'name' => esc_html__( 'Section 2a', 'influential-lite' ),
			'id' => 'section2-a',
			'description' => esc_html__( 'Section 2 sidebar position 1', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );	
		register_sidebar( array(
			'name' => esc_html__( 'Section 2b', 'influential-lite' ),
			'id' => 'section2-b',
			'description' => esc_html__( 'Section 2 sidebar position 2', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );
		register_sidebar( array(
			'name' => esc_html__( 'Section 2c', 'influential-lite' ),
			'id' => 'section2-c',
			'description' => esc_html__( 'Section 2 sidebar position 3', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );
		register_sidebar( array(
			'name' => esc_html__( 'Section 2d', 'influential-lite' ),
			'id' => 'section2-d',
			'description' => esc_html__( 'Section 2 sidebar position 4', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );		
	endif;	
		
	// enable landing page section 5 sidebars
	if( esc_attr(get_theme_mod( 'enable_section5_sidebars', 0 ) ) ) :	
		register_sidebar( array(
			'name' => esc_html__( 'Section 5a', 'influential-lite' ),
			'id' => 'section5-a',
			'description' => esc_html__( 'Section 5 sidebar position 1', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );	
		register_sidebar( array(
			'name' => esc_html__( 'Section 5b', 'influential-lite' ),
			'id' => 'section5-b',
			'description' => esc_html__( 'Section 5 sidebar position 2', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );
		register_sidebar( array(
			'name' => esc_html__( 'Section 5c', 'influential-lite' ),
			'id' => 'section5-c',
			'description' => esc_html__( 'Section 5 sidebar position 3', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );
		register_sidebar( array(
			'name' => esc_html__( 'Section 5d', 'influential-lite' ),
			'id' => 'section5-d',
			'description' => esc_html__( 'Section 5 sidebar position 4', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );		
	endif;	
	
	// enable landing page section 6 sidebars
	if( esc_attr(get_theme_mod( 'enable_section6_sidebars', 0 ) ) ) :	
		register_sidebar( array(
			'name' => esc_html__( 'Section 6a', 'influential-lite' ),
			'id' => 'section6-a',
			'description' => esc_html__( 'Section 6 sidebar position 1', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );	
		register_sidebar( array(
			'name' => esc_html__( 'Section 6b', 'influential-lite' ),
			'id' => 'section6-b',
			'description' => esc_html__( 'Section 6 sidebar position 2', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );
		register_sidebar( array(
			'name' => esc_html__( 'Section 6c', 'influential-lite' ),
			'id' => 'section6-c',
			'description' => esc_html__( 'Section 6 sidebar position 3', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );
		register_sidebar( array(
			'name' => esc_html__( 'Section 6d', 'influential-lite' ),
			'id' => 'section6-d',
			'description' => esc_html__( 'Section 6 sidebar position 4', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );		
	endif;		
	
	// enable or disable woocommerce sidebars
	if( esc_attr(get_theme_mod( 'add_woocommerce', 0 ) ) ) :
		register_sidebar( array(
			'name' =>  esc_html__( 'WooCommerce Left Sidebar', 'influential-lite' ),
			'id' => 'shop-left',
			'description' => esc_html__( 'A special left sidebar if you have WooCommerce setup', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );	
		register_sidebar( array(
			'name' =>  esc_html__( 'WooCommerce Right Sidebar', 'influential-lite' ),
			'id' => 'shop-right',
			'description' => esc_html__( 'A special right sidebar if you have WooCommerce setup', 'influential-lite' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<h3 class="widget-title">',
			'after_title' => '</h3>',
		) );	
	endif;
	
}
add_action( 'widgets_init', 'influential_lite_widgets_init' );


/**
 * Count the number of widgets to enable resizable widgets
 * in the content top group.
 */

function influential_lite_ctop() {
	$count = 0;
	if ( is_active_sidebar( 'ctop1' ) )
		$count++;
	if ( is_active_sidebar( 'ctop2' ) )
		$count++;
	if ( is_active_sidebar( 'ctop3' ) )
		$count++;		
	if ( is_active_sidebar( 'ctop4' ) )
		$count++;
	$class = '';
	switch ( $count ) {
		case '1':
			$class = 'col-lg-12';
			break;
		case '2':
			$class = 'col-md-6';
			break;
		case '3':
			$class = 'col-md-4';
			break;
		case '4':
			$class = 'col-md-3';
			break;
	}
	if ( $class )
		echo 'class="' . $class . '"';
}

/**
 * Count the number of widgets to enable resizable widgets
 * in the content bottom group.
 */

function influential_lite_cbottom() {
	$count = 0;
	if ( is_active_sidebar( 'cbottom1' ) )
		$count++;
	if ( is_active_sidebar( 'cbottom2' ) )
		$count++;
	if ( is_active_sidebar( 'cbottom3' ) )
		$count++;		
	if ( is_active_sidebar( 'cbottom4' ) )
		$count++;
	$class = '';
	switch ( $count ) {
		case '1':
			$class = 'col-lg-12';
			break;
		case '2':
			$class = 'col-md-6';
			break;
		case '3':
			$class = 'col-md-4';
			break;
		case '4':
			$class = 'col-md-3';
			break;
	}
	if ( $class )
		echo 'class="' . $class . '"';
}
/**
 * Count the number of widgets to enable resizable widgets
 * in the bottom group.
 */

function influential_lite_bottom() {
	$count = 0;
	if ( is_active_sidebar( 'bottom1' ) )
		$count++;
	if ( is_active_sidebar( 'bottom2' ) )
		$count++;
	if ( is_active_sidebar( 'bottom3' ) )
		$count++;		
	if ( is_active_sidebar( 'bottom4' ) )
		$count++;
	$class = '';
	switch ( $count ) {
		case '1':
			$class = 'col-lg-12';
			break;
		case '2':
			$class = 'col-lg-6';
			break;
		case '3':
			$class = 'col-lg-4';
			break;
		case '4':
			$class = 'col-lg-3';
			break;
	}
	if ( $class )
		echo 'class="' . $class . '"';
}


/**
 * Count the number of widgets to enable resizable widgets section 1
 */

function influential_lite_section1() {
	$count = 0;
	if ( is_active_sidebar( 'section1-a' ) )
		$count++;
	if ( is_active_sidebar( 'section1-b' ) )
		$count++;
	if ( is_active_sidebar( 'section1-c' ) )
		$count++;		
	if ( is_active_sidebar( 'section1-d' ) )
		$count++;
	$class = '';
	switch ( $count ) {
		case '1':
			$class = 'col-lg-12';
			break;
		case '2':
			$class = 'col-md-6';
			break;
		case '3':
			$class = 'col-md-4';
			break;
		case '4':
			$class = 'col-md-3';
			break;
	}
	if ( $class )
		echo 'class="' . $class . '"';
}


/**
 * Count the number of widgets to enable resizable widgets section 2
 */

function influential_lite_section2() {
	$count = 0;
	if ( is_active_sidebar( 'section2-a' ) )
		$count++;
	if ( is_active_sidebar( 'section2-b' ) )
		$count++;
	if ( is_active_sidebar( 'section2-c' ) )
		$count++;		
	if ( is_active_sidebar( 'section2-d' ) )
		$count++;
	$class = '';
	switch ( $count ) {
		case '1':
			$class = 'col-lg-12';
			break;
		case '2':
			$class = 'col-md-6';
			break;
		case '3':
			$class = 'col-md-4';
			break;
		case '4':
			$class = 'col-md-3';
			break;
	}
	if ( $class )
		echo 'class="' . $class . '"';
}

/**
 * Count the number of widgets to enable resizable widgets section 5
 */

function influential_lite_section5() {
	$count = 0;
	if ( is_active_sidebar( 'section5-a' ) )
		$count++;
	if ( is_active_sidebar( 'section5-b' ) )
		$count++;
	if ( is_active_sidebar( 'section5-c' ) )
		$count++;		
	if ( is_active_sidebar( 'section5-d' ) )
		$count++;
	$class = '';
	switch ( $count ) {
		case '1':
			$class = 'col-lg-12';
			break;
		case '2':
			$class = 'col-md-6';
			break;
		case '3':
			$class = 'col-md-4';
			break;
		case '4':
			$class = 'col-md-3';
			break;
	}
	if ( $class )
		echo 'class="' . $class . '"';
}

/**
 * Count the number of widgets to enable resizable widgets section 6
 */

function influential_lite_section6() {
	$count = 0;
	if ( is_active_sidebar( 'section6-a' ) )
		$count++;
	if ( is_active_sidebar( 'section6-b' ) )
		$count++;
	if ( is_active_sidebar( 'section6-c' ) )
		$count++;		
	if ( is_active_sidebar( 'section6-d' ) )
		$count++;
	$class = '';
	switch ( $count ) {
		case '1':
			$class = 'col-lg-12';
			break;
		case '2':
			$class = 'col-md-6';
			break;
		case '3':
			$class = 'col-md-4';
			break;
		case '4':
			$class = 'col-md-3';
			break;
	}
	if ( $class )
		echo 'class="' . $class . '"';
}
