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

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

add_action( 'customize_register', 'purenote_register_site_style_options' );

if ( ! function_exists( 'purenote_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 purenote_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 Purenote_Customize_Section (
            $wp_customize, 'purenote_section_site_style',
                array(
                    'priority'  => 10,
                    'panel'     => 'purenote_panel_general',
                    'title'     => __( 'Site Style', 'purenote' ),
                )
            )
        );

        /**
         * Radio image field for site layout
         *
         * General Settings > Site Style
         *
         * @since 1.0.0
         */
        $wp_customize->add_setting( 'purenote_site_container_layout',
            array(
                'default'           => purenote_get_customizer_default( 'purenote_site_container_layout' ),
                'sanitize_callback' => 'purenote_sanitize_select',
            )
        );
        $wp_customize->add_control( new Purenote_Control_Radio_Image(
            $wp_customize, 'purenote_site_container_layout',
                array(
                    'priority'      => 10,
                    'section'       => 'purenote_section_site_style',
                    'settings'      => 'purenote_site_container_layout',
                    'label'         => __( 'Container Layout', 'purenote' ),
                    'choices'       => purenote_site_container_layout_choices(),
                )
            )
        );

    }

endif;