<?php
/**
 * @package MatrixAddons
 * @subpackage trainifyframework
 * @since trainifyframework 1.0.0
 * @version 1.0.0
 * @description this file for term list field
 */
?>
<p class="tff-widget-field-wrapper <?php echo esc_attr($trainify_framework_widget_field_wraper); ?>">
	<label for="<?php echo esc_attr( $trainifyframeworkwidget->get_field_id( $trainify_framework_widget_field_name ) ); ?>">
		<?php echo esc_html( $trainify_framework_widget_field_title ); ?>: 
	</label>
	<?php
	/* see more here https://codex.wordpress.org/Function_Reference/wp_dropdown_pages*/
	if( taxonomy_exists( $trainify_framework_widget_taxonomy_type ) ){
		$args = array(
			'show_option_all'	=> esc_html__('Show All', 'trainify'),
			'show_option_none'   => false,
			'orderby'            => 'name',
			'order'              => 'asc',
			'show_count'         => 1,
			'hide_empty'         => 0,
			'echo'               => 1,
			'selected'           => $trainify_framework_widget_field_value,
			'hierarchical'       => 1,
			'name'               => esc_attr( $trainifyframeworkwidget->get_field_name( $trainify_framework_widget_field_name ) ),
			'id'                 => esc_attr( $trainifyframeworkwidget->get_field_id( $trainify_framework_widget_field_name ) ),
			'class'              => 'widefat',
			'taxonomy'           => $trainify_framework_widget_taxonomy_type,
			'hide_if_empty'      => false,
		);
		wp_dropdown_categories( $args );	
	}else{
		?><select id="<?php echo esc_attr( $trainifyframeworkwidget->get_field_id( $trainify_framework_widget_field_name ) ); ?>" name="<?php echo esc_attr( $trainifyframeworkwidget->get_field_name( $trainify_framework_widget_field_name ) ); ?>" class="widefat">
			<option value=""><?php esc_html_e( 'No terms found in this taxonomy', 'trainify' ); ?></option>
		</select><?php
	}	

	if ( isset( $trainify_framework_widget_field_description ) ) { 
		?>
		<br/>
		<small><?php echo esc_html( $trainify_framework_widget_field_description ); ?></small>
		<?php 
	} 
	?>

</p>