<?php
/**
 * Footer bottom area fields in Footer Settings panel.
 * 
 * @package Purenote
 */

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

add_action( 'customize_register', 'purenote_register_footer_bottom_options' );

if ( ! function_exists( 'purenote_register_footer_bottom_options' ) ) :

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

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

        /**
         * Bottom Area Section
         * 
         * Footer Settings > Bottom 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 Purenote_Customize_Section (
            $wp_customize, 'purenote_section_footer_bottom',
                array(
                    'priority'  => 20,
                    'panel'     => 'purenote_panel_footer',
                    'title'     => __( 'Bottom Area', 'purenote' ),
                )
            )
        );

        /**
         * Toggle option for footer bottom area
         *
         * Footer Settings > Bottom Area
         *
         * @since 1.0.0
         */
        $wp_customize->add_setting( 'purenote_footer_bottom_enable',
            array(
                'default'           => purenote_get_customizer_default( 'purenote_footer_bottom_enable' ),
                'sanitize_callback' => 'purenote_sanitize_checkbox'
            )
        );
        $wp_customize->add_control( new Purenote_Control_Toggle(
            $wp_customize, 'purenote_footer_bottom_enable',
                array(
                    'priority'          => 15,
                    'section'           => 'purenote_section_footer_bottom',
                    'settings'          => 'purenote_footer_bottom_enable',
                    'label'             => __( 'Enable footer bottom area.', 'purenote' )
                )
            )
        );

        /**
         * Textarea field for copyright content
         *
         * Footer Settings > Bottom Area
         *
         * @since 1.0.0
         */
        $wp_customize->add_setting( 'purenote_footer_copyright_info',
            array(
                'default'           => purenote_get_customizer_default( 'purenote_footer_copyright_info' ),
                'transport'         => 'refresh',
                'sanitize_callback' => 'wp_kses_post'
            )
        );
        $wp_customize->add_control( new Purenote_Customize_Control (
            $wp_customize, 'purenote_footer_copyright_info',
                array(
                    'priority'          => 25,
                    'section'           => 'purenote_section_footer_bottom',
                    'settings'          => 'purenote_footer_copyright_info',
                    'label'             => __( 'Copyright Content', 'purenote' ),
                    'type'              => 'textarea',
                    // Required Dependency
                    'required'          => array(
                        array(
                            'control'  => 'purenote_footer_bottom_enable',
                            'value'    => true,
                            'operator' => '==',
                        ),
                    ),
                )
            )
        );
        
    }

endif;