<?php
/**
 * Archive page and its field inside InnerPage Settings
 * 
 * @package PureNote
 */

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

add_action( 'customize_register', 'purenote_register_archive_options' );

if ( !function_exists( 'purenote_register_archive_options' ) ):

	/**
	 * Register theme options for archive section
	 * 
	 * @param WP_Customize_Manager $wp_customize Object that holds the customizer data.
	 * @since 1.0.0
	 */

	function purenote_register_archive_options( $wp_customize ) {

		/*
		*Failsafe is safe
		*/

		if ( ! isset ( $wp_customize)){
			return;
		}

		
		/**
		 * Archive Section
		 * 
		 * InnerPage Settings > Archive Pages
		 * 
		 * @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_page_archive',
				array(
					'priority'	=> 5,
					'panel'		=> 'purenote_panel_inner_page',
					'title'		=> __( 'Archive Pages', 'purenote' ),
				)
			)
		);

		/**
         * Radio image field for site layout
         *
         * General Settings > Site Style
         *
         * @since 1.0.0
         */
        $wp_customize->add_setting( 'purenote_archive_page_style',
            array(
                'default'           => purenote_get_customizer_default( 'purenote_archive_page_style' ),
                'sanitize_callback' => 'purenote_sanitize_select',
            )
        );
        $wp_customize->add_control( new Purenote_Control_Radio_Image(
            $wp_customize, 'purenote_archive_page_style',
                array(
                    'priortiy'	=> 10,
					'section'	=> 'purenote_section_page_archive',
					'settings'	=> 'purenote_archive_page_style',
					'label'		=> __('Archive Page Style', 'purenote'),
					'choices'	=>purenote_archive_page_style_choices()
                )
            )
        );
		
		/**
		 * Toggle option for archive title prefix.
		 * 
		 * Innerpage Settings > Archive Pages
		 * 
		 * @since 1.0.0
		 */
		$wp_customize->add_setting( 'purenote_archive_title_prefix_enable',
		 	array(
		 		'default'	=> purenote_get_customizer_default( 'purenote_archive_title_prefix_enable'),
		 		'sanitize_callback'	=> 'purenote_sanitize_checkbox'
		 	)
		);
		$wp_customize->add_control( new Purenote_Control_Toggle(
			$wp_customize, 'purenote_archive_title_prefix_enable',
		 		array(
			 		'priority'	=> 15,
			 		'section'	=> 'purenote_section_page_archive',
			 		'settings'	=> 'purenote_archive_title_prefix_enable',
			 		'label'		=> __('Enable archive page title prefix.', 'purenote')
			 	)
			)
		);

	}

endif;