<?php
Kirki::add_section( 'footer_section', array(
    'title'          => esc_html__( 'Footer Section', 'author-portfolio' ),
    'panel'          => 'author_portfolio_global_panel',
    'capability'     => 'edit_theme_options',
) );

Kirki::add_field( 'author_portfolio_config', array(
    'type'        => 'custom',
    'settings'    => 'separator_before_footer_top_section',
    'label'       => '',
    'section'     => 'footer_section',
    'default'     => '<div class="settings-separator">'.esc_html__('Footer Top Section', 'author-portfolio').'</div>',
) );

Kirki::add_field( 'author_portfolio_config', [
	'type'        => 'toggle',
	'settings'    => 'show_footer_top_section',
	'label'       => esc_html__( 'Show Footer Top Section', 'author-portfolio' ),
	'section'     => 'footer_section',
	'default'    => '1',
] );

Kirki::add_field( 'author_portfolio_config', [
	'type'        => 'select',
	'settings'    => 'footer_column',
	'label'       => esc_html__( 'Footer Column', 'author-portfolio' ),
	'section'     => 'footer_section',
	'active_callback' => function(){
		$showFooterTop = get_theme_mod('show_footer_top_section', true);
		if (true == $showFooterTop) {
			return true;
		}
		return false;
	},
	'default'    => '4/4/4',
	'choices'     => array(
            '4/4/4' => __( '4/4/4', 'author-portfolio' ),
            '3/3/3/3' => __( '3/3/3/3', 'author-portfolio' ),
            '3/6/3' => __( '3/6/3', 'author-portfolio' ),
        ),
] );

Kirki::add_field( 'author_portfolio_config', array(
    'type'        => 'custom',
    'settings'    => 'separator_before_footer_bottom_section',
    'label'       => '',
    'section'     => 'footer_section',
    'default'     => '<div class="settings-separator">'.esc_html__('Footer Bottom Section', 'author-portfolio').'</div>',
) );

Kirki::add_field( 'author_portfolio_config', [
	'type'        => 'toggle',
	'settings'    => 'show_footer_bottom_section',
	'label'       => esc_html__( 'Show Footer Bottom Section', 'author-portfolio' ),
	'section'     => 'footer_section',
	'default'    => '1',
] );

Kirki::add_field( 'author_portfolio_config', [
	'type'        => 'toggle',
	'settings'    => 'show_footer_logo',
	'label'       => esc_html__( 'Show Footer Logo', 'author-portfolio' ),
	'section'     => 'footer_section',
	'default'    => '1',
	'active_callback'	=> function(){
		$showFooterBottom = get_theme_mod('show_footer_bottom_section', true);
		if (true == $showFooterBottom) {
			return true;
		}
		return false;
	}
] );

Kirki::add_field( 'author_portfolio_config', [
	'type'        => 'image',
	'settings'    => 'footer_logo',
	'label'       => __( 'Upload Footer Logo', 'author-portfolio' ),
	'section'     => 'footer_section',
	'default'     => '',
	'transport'   => 'refresh',
	'choices'     => [
		'save_as' => 'id',
	],
    'active_callback'	=> function(){
		$showFooterBottom = get_theme_mod('show_footer_bottom_section', true);
		$showFooterLogo = get_theme_mod('show_footer_logo', true);
		if (true == $showFooterBottom && true == $showFooterLogo) {
			return true;
		}
		return false;
	}
] );

Kirki::add_field( 'author_portfolio_config', [
	'type'        => 'toggle',
	'settings'    => 'show_footer_menu',
	'label'       => esc_html__( 'Show Footer Menu', 'author-portfolio' ),
	'section'     => 'footer_section',
	'default'    => '1',
	'active_callback'	=> function(){
		$showFooterBottom = get_theme_mod('show_footer_bottom_section', true);
		if (true == $showFooterBottom) {
			return true;
		}
		return false;
	}
] );

Kirki::add_field( 'author_portfolio_config', [
	'type'        => 'toggle',
	'settings'    => 'show_footer_social_links',
	'label'       => esc_html__( 'Show Footer Social Links', 'author-portfolio' ),
	'section'     => 'footer_section',
	'default'    => '1',
	'active_callback'	=> function(){
		$showFooterBottom = get_theme_mod('show_footer_bottom_section', true);
		if (true == $showFooterBottom) {
			return true;
		}
		return false;
	}
] );

Kirki::add_field( 'author_portfolio_config', [
    'type'        => 'background',
    'settings'    => 'footer_bottom_bg',
    'label'       => esc_html__( 'Footer Bottom Background', 'author-portfolio' ),
    'section'     => 'footer_section',
    'default'     => [
        'background-color'      => '#f4f4ec',
        'background-image'      => '',
        'background-repeat'     => 'repeat',
        'background-position'   => 'center center',
        'background-size'       => 'cover',
        'background-attachment' => 'scroll',
    ],
    'output'      => [
        [
            'element' => '.footer-content.footer-bottom-area',
        ],
    ],
    'transport'   => 'postMessage',
    'active_callback' => function() {
        return get_theme_mod( 'show_footer_bottom_section', true );
    },
] );
