<?php

if ( ! function_exists( 'calla_elated_set_header_centered_type_global_option' ) ) {
	/**
	 * This function set header type value for global header option map
	 */
	function calla_elated_set_header_centered_type_global_option( $header_types ) {
		$header_types['header-centered'] = array(
			'image' => ELATED_FRAMEWORK_HEADER_TYPES_ROOT . '/header-centered/assets/img/header-centered.png',
			'label' => esc_html__( 'Centered', 'calla' )
		);
		
		return $header_types;
	}
	
	add_filter( 'calla_elated_header_type_global_option', 'calla_elated_set_header_centered_type_global_option' );
}

if ( ! function_exists( 'calla_elated_set_header_centered_type_meta_boxes_option' ) ) {
	/**
	 * This function set header type value for header meta boxes map
	 */
	function calla_elated_set_header_centered_type_meta_boxes_option( $header_type_options ) {
		$header_type_options['header-centered'] = esc_html__( 'Centered', 'calla' );
		
		return $header_type_options;
	}
	
	add_filter( 'calla_elated_header_type_meta_boxes', 'calla_elated_set_header_centered_type_meta_boxes_option' );
}

if(!function_exists('calla_elated_set_default_menu_height_for_centered_header')) {
	/**
	 * This function set default menu area height for header types
	 */
	function calla_elated_set_default_menu_height_for_centered_header($menu_height) {
		$menu_height_meta = calla_elated_filter_px( calla_elated_options()->getOptionValue( 'menu_area_height' ) );
		$id = calla_elated_get_page_id();

		$header_type = calla_elated_get_meta_field_intersect( 'header_type', $id );

		if ($menu_height_meta !== '') {
			$menu_height = intval( $menu_height_meta );
		} else if ($header_type == 'header-centered') {
			$menu_height = 67;
		} else {
			$menu_height = 90;
		}

		return $menu_height;
	}
	add_filter('calla_elated_set_default_menu_height_value_for_header_types', 'calla_elated_set_default_menu_height_for_centered_header');
}

if ( ! function_exists( 'calla_elated_set_hide_dep_options_header_centered' ) ) {
	/**
	 * This function is used to hide all containers/panels for admin options when this header type is selected
	 */
	function calla_elated_set_hide_dep_options_header_centered( $hide_dep_options ) {
		$hide_dep_options[] = 'header-centered';
		
		return $hide_dep_options;
	}
	
	// header types panel options
	add_filter( 'calla_elated_full_screen_menu_hide_global_option', 'calla_elated_set_hide_dep_options_header_centered' );
	add_filter( 'calla_elated_header_standard_hide_global_option', 'calla_elated_set_hide_dep_options_header_centered' );
	add_filter( 'calla_elated_header_vertical_hide_global_option', 'calla_elated_set_hide_dep_options_header_centered' );
	add_filter( 'calla_elated_header_vertical_menu_hide_global_option', 'calla_elated_set_hide_dep_options_header_centered' );
	add_filter( 'calla_elated_header_vertical_closed_hide_global_option', 'calla_elated_set_hide_dep_options_header_centered' );
	add_filter( 'calla_elated_header_vertical_sliding_hide_global_option', 'calla_elated_set_hide_dep_options_header_centered' );
	
	// header types panel meta boxes
	add_filter( 'calla_elated_header_standard_hide_meta_boxes', 'calla_elated_set_hide_dep_options_header_centered' );
	add_filter( 'calla_elated_header_vertical_hide_meta_boxes', 'calla_elated_set_hide_dep_options_header_centered' );
	
	// header types panel - widgets area meta boxes
	add_filter( 'calla_elated_header_menu_area_widgets_hide_meta_boxes', 'calla_elated_set_hide_dep_options_header_centered' );
	add_filter( 'calla_elated_header_logo_area_widgets_hide_meta_boxes', 'calla_elated_set_hide_dep_options_header_centered' );
}