<?php
/**
 * Footer main area fields in Footer Settings panel.
 * 
 * @package Blogbuster
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

add_action( 'customize_register', 'blogbuster_register_footer_main_options' );

if ( ! function_exists( 'blogbuster_register_footer_main_options' ) ) :

    /**
     * Register theme options for Main Area section.
     * 
     * @param WP_Customize_Manager $wp_customize Object that holds the customizer data.
     * @since 1.0.0
     */
    function blogbuster_register_footer_main_options( $wp_customize ) {

        /*
         * Failsafe is safe
         */
        if ( ! isset( $wp_customize ) ) {
            return;
        }

        /**
         * Main Area Section
         * 
         * Footer Settings > Main Area
         * 
         * @uses $wp_customize->add_section() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_section/
         * @since 1.0.0
         */
        $wp_customize->add_section( new Blogbuster_Customize_Section (
            $wp_customize, 'blogbuster_section_footer_main',
                array(
                    'priority'  => 10,
                    'panel'     => 'blogbuster_panel_footer',
                    'title'     => __( 'Main Area', 'blogbuster' ),
                )
            )
        );

        /**
         * Toggle option for footer main area
         *
         * Footer Settings > Main Area
         *
         * @since 1.0.0
         */
        $wp_customize->add_setting( 'blogbuster_footer_main_enable',
            array(
                'default'           => blogbuster_get_customizer_default( 'blogbuster_footer_main_enable' ),
                'sanitize_callback' => 'blogbuster_sanitize_checkbox'
            )
        );
        $wp_customize->add_control( new Blogbuster_Control_Toggle(
            $wp_customize, 'blogbuster_footer_main_enable',
                array(
                    'priority'          => 15,
                    'section'           => 'blogbuster_section_footer_main',
                    'settings'          => 'blogbuster_footer_main_enable',
                    'label'             => __( 'Enable footer main area.', 'blogbuster' )
                )
            )
        );

        /**
         * Radio image field for footer widget area layout
         *
         * Footer Settings > Main Area
         *
         * @since 1.0.0
         */
        $wp_customize->add_setting( 'blogbuster_footer_widget_area_layout',
            array(
                'default'           => blogbuster_get_customizer_default( 'blogbuster_footer_widget_area_layout' ),
                'sanitize_callback' => 'blogbuster_sanitize_select',
            )
        );
        $wp_customize->add_control( new Blogbuster_Control_Radio_Image(
            $wp_customize, 'blogbuster_footer_widget_area_layout',
                array(
                    'priority'          => 20,
                    'section'           => 'blogbuster_section_footer_main',
                    'settings'          => 'blogbuster_footer_widget_area_layout',
                    'label'             => __( 'Widget Area Layout', 'blogbuster' ),
                    'choices'           => blogbuster_footer_widget_area_layout_choices(),
                    // Required Dependency
                    'required'          => array(
                        array(
                            'control'  => 'blogbuster_footer_main_enable',
                            'value'    => true,
                            'operator' => '==',
                        ),
                    ),
                )
            )
        );

    }

endif;