<?php

if ( ! function_exists( 'peggi_select_map_post_audio_meta' ) ) {
	function peggi_select_map_post_audio_meta() {
		$audio_post_format_meta_box = peggi_select_create_meta_box(
			array(
				'scope' => array( 'post' ),
				'title' => esc_html__( 'Audio Post Format', 'peggi' ),
				'name'  => 'post_format_audio_meta'
			)
		);
		
		peggi_select_create_meta_box_field(
			array(
				'name'          => 'qodef_audio_type_meta',
				'type'          => 'select',
				'label'         => esc_html__( 'Audio Type', 'peggi' ),
				'description'   => esc_html__( 'Choose audio type', 'peggi' ),
				'parent'        => $audio_post_format_meta_box,
				'default_value' => 'social_networks',
				'options'       => array(
					'social_networks' => esc_html__( 'Audio Service', 'peggi' ),
					'self'            => esc_html__( 'Self Hosted', 'peggi' )
				)
			)
		);
		
		$qodef_audio_embedded_container = peggi_select_add_admin_container(
			array(
				'parent' => $audio_post_format_meta_box,
				'name'   => 'qodef_audio_embedded_container'
			)
		);
		
		peggi_select_create_meta_box_field(
			array(
				'name'        => 'qodef_post_audio_link_meta',
				'type'        => 'text',
				'label'       => esc_html__( 'Audio URL', 'peggi' ),
				'description' => esc_html__( 'Enter audio URL', 'peggi' ),
				'parent'      => $qodef_audio_embedded_container,
				'dependency' => array(
					'show' => array(
						'qodef_audio_type_meta' => 'social_networks'
					)
				)
			)
		);
		
		peggi_select_create_meta_box_field(
			array(
				'name'        => 'qodef_post_audio_custom_meta',
				'type'        => 'text',
				'label'       => esc_html__( 'Audio Link', 'peggi' ),
				'description' => esc_html__( 'Enter audio link', 'peggi' ),
				'parent'      => $qodef_audio_embedded_container,
				'dependency' => array(
					'show' => array(
						'qodef_audio_type_meta' => 'self'
					)
				)
			)
		);
	}
	
	add_action( 'peggi_select_action_meta_boxes_map', 'peggi_select_map_post_audio_meta', 23 );
}