<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

if ( ! function_exists( 'nevo_customizer_footer_top_config' ) ) {

	function nevo_customizer_footer_top_config($configs = array()) {
		$section  = 'nevo_footer_top';
		$name     = 'footer_top';
		$selector = '.top-footer';
		$config = array(
			array(
				'name'  => $section,
				'type'  => 'section',
				'panel' => 'nevo_footer',
				'priority' => 50,
				'title' => __( 'Top Row', 'nevo' ),
			),
			
			array(
				'name'            => $section . '_layout',
				'type'            => 'radio_group',
				'section'         => $section,
				'title'           => __( 'Layout', 'nevo' ),
				'selector'        => '.top-footer .nevo-container',
				'css_format'      => 'html_class',
				'default'         => 'normal',
				'choices'         => array(
					'normal'      => __( 'Contained', 'nevo' ),
					'cv-mw-100'   => __( 'Full Width', 'nevo' ),
				),
			),
			
			array(
				'name'            => $name . '_padding',
				'type'            => 'css_ruler',
				'section'         => $section,
				'title'           => __( 'Padding', 'nevo' ),
				'device_settings' => true,
				'fields_disabled' => array(
					'left'  => 'nevo',
					'right' => 'nevo',
				),
				'css_format'      => array(
					'top'    => 'padding-top: {{value}};',
					'bottom' => 'padding-bottom: {{value}};',
				),
				'selector'        => '.top-footer .inside-footer',
			),
			
			array(
				'name'            => $name . '_margin',
				'type'            => 'css_ruler',
				'section'         => $section,
				'title'           => __( 'Margin', 'nevo' ),
				'device_settings' => true,
				'css_format'      => array(
					'top'    => 'margin-top: {{value}};',
					'right'  => 'margin-right: {{value}};',
					'bottom' => 'margin-bottom: {{value}};',
					'left'   => 'margin-left: {{value}};',
				),
				'selector'        => '.top-footer',
			),
			
			array(
				'name'    => $name . '_hr',
				'type'    => 'hr',
				'section' => $section,
			),
			
			array(
				'name'       => $name . '_styling',
				'type'       => 'styling',
				'section'    => $section,
				'title'      => __( 'Styling', 'nevo' ),
				'selector'   => array(
					'normal' => '.top-footer',
					'normal_text_color' => '.top-footer, .top-footer .entry-meta',
					'normal_link_color' => '.top-footer a, .top-footer .nevo-nav-menu li.menu-item > a, .top-footer .entry-meta a',
					'hover' => '.top-footer a:hover, .top-footer li.menu-item > a .nevo-item-title:hover, .top-footer .entry-meta a:hover',
				),
				'default'   => array(
					'normal' => array(
						//'text_color' => '#ffffff',
						//'link_color' => '#ffffff',
					),
					'hover' => array(
						//'link_color' => '#ffffff',
					),
				),
				'css_format' => 'styling',
				'fields'     => array(
					'normal_fields' => array(
						'primary'	=> false,
						'secondary' => false,
						'success'	=> false,
						'info'	=> false,
						'warning'	=> false,
						'type_heading'	=> false,
						'link'	=> false,
						'link_hover'	=> false,
						'base'	=> false,
						'title'	=> false,
						'meta'	=> false,
						'heading'	=> false,
						'margin'     => false,
						'padding'    => false,
						'paddinga'   => false,
						'box_shadow' => false,
					),
					'hover_fields'  => array(
						'text_color'  => false,
						'margin'      => false,
						'padding'     => false,
						'bg_heading'  => false,
						'bg_color'    => false,
						'bg_image'    => false,
						'border_heading' => false,
						'border_style'   => false,
						'border_radius'  => false,
						'box_shadow'	 => false,
					),
				),
			),
			
			array(
				'name'       => $name . '_widgets_title',
				'type'       => 'styling',
				'section'    => $section,
				'title'      => __( 'Footer Widgets Title', 'nevo' ),
				'selector'   => array(
					'normal' => "{$selector} .heading-title",
					'normal_text_color' => "{$selector} .widget-title",
					'normal_padding' => "{$selector} .widget-title",
					'normal_margin' => "{$selector} .heading-title",
					'normal_bg_color' => "{$selector} .widget-title",
				),
				'default'   => array(
					'normal' => array(
					),
				),
				'css_format' => 'styling',
				'fields'     => array(
					'normal_fields' => array(
						'primary'	=> false,
						'secondary' => false,
						'success'	=> false,
						'info'	=> false,
						'warning'	=> false,
						'type_heading'	=> false,
						'link'	=> false,
						'link_hover'	=> false,
						'base'	=> false,
						'title'	=> false,
						'meta'	=> false,
						'heading'	=> false,
						'link_color'  => false,
						'margin'      => false,
						'paddinga'    => false,
						'box_shadow'  => false,
					),
					'hover_fields'  => false,
				),
			),
		);

		return array_merge( $configs, $config );
	}
	
}
add_filter( 'nevo/customizer/config', 'nevo_customizer_footer_top_config', 50 );

function nevo_change_footer_widgets_location( $wp_customize ) {
	for ( $i = 1; $i <= 6; $i ++ ) {
		if ( $wp_customize->get_section( 'sidebar-widgets-footer-' . $i ) ) {
			$wp_customize->get_section( 'sidebar-widgets-footer-' . $i )->panel = 'nevo_footer';
		}
	}
}

add_action( 'customize_register', 'nevo_change_footer_widgets_location', 999 );