<?php
/**
 * Adds the Site Style section and its fields within the General Settings panel.
 * 
 * @package Blogbuster
 */

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

add_action( 'customize_register', 'blogbuster_register_site_style_options' );

if ( ! function_exists( 'blogbuster_register_site_style_options' ) ) :

    /**
     * Register theme options for Site Style section.
     * 
     * @param WP_Customize_Manager $wp_customize Object that holds the settings.
     * @since 1.0.0
     */
    function blogbuster_register_site_style_options( $wp_customize ) {

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

        /**
         * Add Site Style Section
         * 
         * General Settings > Site Style
         * 
         * @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_site_style',
                array(
                    'priority'  => 10,
                    'panel'     => 'blogbuster_panel_general',
                    'title'     => __( 'Site Style', 'blogbuster' ),
                )
            )
        );

        /**
         * Radio image field for site layout
         *
         * General Settings > Site Style
         *
         * @since 1.0.0
         */
        $wp_customize->add_setting( 'blogbuster_site_container_layout',
            array(
                'default'           => blogbuster_get_customizer_default( 'blogbuster_site_container_layout' ),
                'sanitize_callback' => 'blogbuster_sanitize_select',
            )
        );
        $wp_customize->add_control( new Blogbuster_Control_Radio_Image(
            $wp_customize, 'blogbuster_site_container_layout',
                array(
                    'priority'      => 10,
                    'section'       => 'blogbuster_section_site_style',
                    'settings'      => 'blogbuster_site_container_layout',
                    'label'         => __( 'Container Layout', 'blogbuster' ),
                    'choices'       => blogbuster_site_container_layout_choices(),
                )
            )
        );

        /**
         * Radio buttonset field for site mode
         *
         * Header Settings > Main Area
         *
         * @since 1.0.0
         */
        $wp_customize->add_setting( 'blogbuster_site_mode',
            array(
                'default'           => blogbuster_get_customizer_default( 'blogbuster_site_mode' ),
                'sanitize_callback' => 'blogbuster_sanitize_select',
            )
        );
        $wp_customize->add_control( new Blogbuster_Control_Buttonset(
            $wp_customize, 'blogbuster_site_mode',
                array(
                    'priority'      => 20,
                    'section'       => 'blogbuster_section_site_style',
                    'settings'      => 'blogbuster_site_mode',
                    'label'         => __( 'Site Mode', 'blogbuster' ),
                    'choices'       => blogbuster_site_mode_choices()
                )
            )
        );

        /**
         * Toggle option for background animation.
         *
         * General Settings > Site Style
         *
         * @since 1.0.0
         */
        $wp_customize->add_setting( 'blogbuster_background_animation_enable',
            array(
                'default'           => blogbuster_get_customizer_default ( 'blogbuster_background_animation_enable' ),
                'sanitize_callback' => 'blogbuster_sanitize_checkbox'
            )
        );
        $wp_customize->add_control( new Blogbuster_Control_Toggle(
            $wp_customize, 'blogbuster_background_animation_enable',
                array(
                    'priority'  => 100,
                    'section'   => 'blogbuster_section_site_style',
                    'settings'  => 'blogbuster_background_animation_enable',
                    'label'     => __( 'Enable Background Animation', 'blogbuster' )
                )
            )
        );

    }

endif;