<?php

if ( ! function_exists( 'calla_elated_map_post_audio_meta' ) ) {
	function calla_elated_map_post_audio_meta() {
		$audio_post_format_meta_box = calla_elated_create_meta_box(
			array(
				'scope' => array( 'post' ),
				'title' => esc_html__( 'Audio Post Format', 'calla' ),
				'name'  => 'post_format_audio_meta'
			)
		);
		
		calla_elated_create_meta_box_field(
			array(
				'name'          => 'eltdf_audio_type_meta',
				'type'          => 'select',
				'label'         => esc_html__( 'Audio Type', 'calla' ),
				'description'   => esc_html__( 'Choose audio type', 'calla' ),
				'parent'        => $audio_post_format_meta_box,
				'default_value' => 'social_networks',
				'options'       => array(
					'social_networks' => esc_html__( 'Audio Service', 'calla' ),
					'self'            => esc_html__( 'Self Hosted', 'calla' )
				)
			)
		);
		
		$eltdf_audio_embedded_container = calla_elated_add_admin_container(
			array(
				'parent' => $audio_post_format_meta_box,
				'name'   => 'eltdf_audio_embedded_container'
			)
		);
		
		calla_elated_create_meta_box_field(
			array(
				'name'        => 'eltdf_post_audio_link_meta',
				'type'        => 'text',
				'label'       => esc_html__( 'Audio URL', 'calla' ),
				'description' => esc_html__( 'Enter audio URL', 'calla' ),
				'parent'      => $eltdf_audio_embedded_container,
				'dependency' => array(
					'show' => array(
						'eltdf_audio_type_meta' => 'social_networks'
					)
				)
			)
		);
		
		calla_elated_create_meta_box_field(
			array(
				'name'        => 'eltdf_post_audio_custom_meta',
				'type'        => 'text',
				'label'       => esc_html__( 'Audio Link', 'calla' ),
				'description' => esc_html__( 'Enter audio link', 'calla' ),
				'parent'      => $eltdf_audio_embedded_container,
				'dependency' => array(
					'show' => array(
						'eltdf_audio_type_meta' => 'self'
					)
				)
			)
		);
	}
	
	add_action( 'calla_elated_meta_boxes_map', 'calla_elated_map_post_audio_meta', 23 );
}