<?php

if ( ! function_exists( 'calla_elated_map_sidebar_meta' ) ) {
	function calla_elated_map_sidebar_meta() {
		$eltdf_sidebar_meta_box = calla_elated_create_meta_box(
			array(
				'scope' => apply_filters( 'calla_elated_set_scope_for_meta_boxes', array( 'page' ), 'sidebar_meta' ),
				'title' => esc_html__( 'Sidebar', 'calla' ),
				'name'  => 'sidebar_meta'
			)
		);
		
		calla_elated_create_meta_box_field(
			array(
				'name'        => 'eltdf_sidebar_layout_meta',
				'type'        => 'select',
				'label'       => esc_html__( 'Sidebar Layout', 'calla' ),
				'description' => esc_html__( 'Choose the sidebar layout', 'calla' ),
				'parent'      => $eltdf_sidebar_meta_box,
                'options'       => calla_elated_get_custom_sidebars_options( true )
			)
		);
		
		$eltdf_custom_sidebars = calla_elated_get_custom_sidebars();
		if ( count( $eltdf_custom_sidebars ) > 0 ) {
			calla_elated_create_meta_box_field(
				array(
					'name'        => 'eltdf_custom_sidebar_area_meta',
					'type'        => 'selectblank',
					'label'       => esc_html__( 'Choose Widget Area in Sidebar', 'calla' ),
					'description' => esc_html__( 'Choose Custom Widget area to display in Sidebar"', 'calla' ),
					'parent'      => $eltdf_sidebar_meta_box,
					'options'     => $eltdf_custom_sidebars,
					'args'        => array(
						'select2' => true
					)
				)
			);
		}
	}
	
	add_action( 'calla_elated_meta_boxes_map', 'calla_elated_map_sidebar_meta', 31 );
}