<?php

if ( ! function_exists( 'calla_elated_header_types_meta_boxes' ) ) {
	function calla_elated_header_types_meta_boxes() {
		$header_type_options = apply_filters( 'calla_elated_header_type_meta_boxes', $header_type_options = array( '' => esc_html__( 'Default', 'calla' ) ) );
		
		return $header_type_options;
	}
}

if ( ! function_exists( 'calla_elated_get_hide_dep_for_header_behavior_meta_boxes' ) ) {
	function calla_elated_get_hide_dep_for_header_behavior_meta_boxes() {
		$hide_dep_options = apply_filters( 'calla_elated_header_behavior_hide_meta_boxes', $hide_dep_options = array() );
		
		return $hide_dep_options;
	}
}

foreach ( glob( ELATED_FRAMEWORK_HEADER_ROOT_DIR . '/admin/meta-boxes/*/*.php' ) as $meta_box_load ) {
	include_once $meta_box_load;
}

foreach ( glob( ELATED_FRAMEWORK_HEADER_TYPES_ROOT_DIR . '/*/admin/meta-boxes/*.php' ) as $meta_box_load ) {
	include_once $meta_box_load;
}

if ( ! function_exists( 'calla_elated_map_header_meta' ) ) {
	function calla_elated_map_header_meta() {
		$header_type_meta_boxes              = calla_elated_header_types_meta_boxes();
		$header_behavior_meta_boxes_hide_dep = calla_elated_get_hide_dep_for_header_behavior_meta_boxes();
		
		$header_meta_box = calla_elated_create_meta_box(
			array(
				'scope' => apply_filters( 'calla_elated_set_scope_for_meta_boxes', array( 'page', 'post' ), 'header_meta' ),
				'title' => esc_html__( 'Header', 'calla' ),
				'name'  => 'header_meta'
			)
		);
		
		calla_elated_create_meta_box_field(
			array(
				'name'          => 'eltdf_header_type_meta',
				'type'          => 'select',
				'default_value' => '',
				'label'         => esc_html__( 'Choose Header Type', 'calla' ),
				'description'   => esc_html__( 'Select header type layout', 'calla' ),
				'parent'        => $header_meta_box,
				'options'       => $header_type_meta_boxes
			)
		);
		
		calla_elated_create_meta_box_field(
			array(
				'name'          => 'eltdf_header_style_meta',
				'type'          => 'select',
				'default_value' => '',
				'label'         => esc_html__( 'Header Skin', 'calla' ),
				'description'   => esc_html__( 'Choose a header style to make header elements (logo, main menu, side menu button) in that predefined style', 'calla' ),
				'parent'        => $header_meta_box,
				'options'       => array(
					''             => esc_html__( 'Default', 'calla' ),
					'light-header' => esc_html__( 'Light', 'calla' ),
					'dark-header'  => esc_html__( 'Dark', 'calla' )
				)
			)
		);
		
		calla_elated_create_meta_box_field(
			array(
				'parent'          => $header_meta_box,
				'type'            => 'select',
				'name'            => 'eltdf_header_behaviour_meta',
				'default_value'   => '',
				'label'           => esc_html__( 'Choose Header Behaviour', 'calla' ),
				'description'     => esc_html__( 'Select the behaviour of header when you scroll down to page', 'calla' ),
				'options'         => array(
					''                                => esc_html__( 'Default', 'calla' ),
					'fixed-on-scroll'                 => esc_html__( 'Fixed on scroll', 'calla' ),
					'no-behavior'                     => esc_html__( 'No Behavior', 'calla' ),
					'sticky-header-on-scroll-up'      => esc_html__( 'Sticky on scroll up', 'calla' ),
					'sticky-header-on-scroll-down-up' => esc_html__( 'Sticky on scroll up/down', 'calla' )
				),
				'dependency' => array(
					'hide' => array(
						'eltdf_header_type_meta'  => $header_behavior_meta_boxes_hide_dep
					)
				)
			)
		);
		
		//additional area
		do_action( 'calla_elated_additional_header_area_meta_boxes_map', $header_meta_box );
		
		//top area
		do_action( 'calla_elated_header_top_area_meta_boxes_map', $header_meta_box );
		
		//logo area
		do_action( 'calla_elated_header_logo_area_meta_boxes_map', $header_meta_box );
		
		//menu area
		do_action( 'calla_elated_header_menu_area_meta_boxes_map', $header_meta_box );
	}
	
	add_action( 'calla_elated_meta_boxes_map', 'calla_elated_map_header_meta', 50 );
}