<?php

if ( ! function_exists( 'calla_elated_sidebar_options_map' ) ) {
	function calla_elated_sidebar_options_map() {
		
		calla_elated_add_admin_page(
			array(
				'slug'  => '_sidebar_page',
				'title' => esc_html__( 'Sidebar Area', 'calla' ),
				'icon'  => 'fa fa-indent'
			)
		);
		
		$sidebar_panel = calla_elated_add_admin_panel(
			array(
				'title' => esc_html__( 'Sidebar Area', 'calla' ),
				'name'  => 'sidebar',
				'page'  => '_sidebar_page'
			)
		);
		
		calla_elated_add_admin_field( array(
			'name'          => 'sidebar_layout',
			'type'          => 'select',
			'label'         => esc_html__( 'Sidebar Layout', 'calla' ),
			'description'   => esc_html__( 'Choose a sidebar layout for pages', 'calla' ),
			'parent'        => $sidebar_panel,
			'default_value' => 'no-sidebar',
            'options'       => calla_elated_get_custom_sidebars_options()
		) );
		
		$calla_custom_sidebars = calla_elated_get_custom_sidebars();
		if ( count( $calla_custom_sidebars ) > 0 ) {
			calla_elated_add_admin_field( array(
				'name'        => 'custom_sidebar_area',
				'type'        => 'selectblank',
				'label'       => esc_html__( 'Sidebar to Display', 'calla' ),
				'description' => esc_html__( 'Choose a sidebar to display on pages. Default sidebar is "Sidebar"', 'calla' ),
				'parent'      => $sidebar_panel,
				'options'     => $calla_custom_sidebars,
				'args'        => array(
					'select2' => true
				)
			) );
		}
	}
	
	add_action( 'calla_elated_options_map', 'calla_elated_sidebar_options_map', 6 );
}