<?php
/**
 * @package MatrixAddons
 * @subpackage trainifyframework
 * @since trainifyframework 1.0.0
 * @version 1.0.0
 * @description this file for tab group field
 */
$current_widget_slug = $trainifyframeworkwidget->id_base.'_'.$trainifyframeworkwidget->number.'_';
?>
<div class="tff-widget-field-tab-wraper <?php echo esc_attr($trainify_framework_widget_field_wraper); ?>">
	<h5 class="tff-widget-tab-list nav-tab-wrapper">
		<?php 
		foreach($trainify_framework_widget_field_options as $tab_key=>$tab_details){
			$current_tab_id = $current_widget_slug.$tab_key;
			?>
			<label for="field_<?php echo esc_attr($current_tab_id); ?>" data-id="#content_<?php echo esc_attr($current_tab_id); ?>" class="nav-tab <?php echo ($tab_key == $trainify_framework_widget_field_value) ? 'nav-tab-active' : ''; ?>"><?php echo esc_html($tab_details['trainify_framework_widget_field_title']); ?><input id="field_<?php echo esc_attr($current_tab_id); ?>" type="radio" name="<?php echo esc_attr($trainifyframeworkwidget->get_field_name($trainify_framework_widget_field_name) ); ?>" value="<?php echo esc_attr($tab_key); ?>" <?php checked($trainify_framework_widget_field_value, $tab_key); ?> class="tff-hidden"/></label>
		<?php } ?>
	</h5>
	<div class="tff-tab-content-wraper">
		<?php
		foreach($trainify_framework_widget_field_options as $tab_key=>$tab_details){ 
			$current_tab_id = $current_widget_slug.$tab_key;
			?>
			<div id="content_<?php echo esc_attr($current_tab_id); ?>" class="trainify-framework-tab-contents <?php echo ($trainify_framework_widget_field_value==$tab_key
			) ? 'trainify-framework-tab-active' : ''; ?>" >
				<?php
					$all_values = get_option('widget_' . $trainifyframeworkwidget->id_base);
					$this_widget_instance = isset($all_values[$trainifyframeworkwidget->number]) ? $all_values[$trainifyframeworkwidget->number] : array();
					$widget_fields = isset($tab_details['trainify_framework_widget_field_options']) ? $tab_details['trainify_framework_widget_field_options'] : array();
					// Loop through fields
					if(count($widget_fields)):
			            foreach ( $widget_fields as $widget_field ) {
			                // Make array elements available as variables
			                extract( $widget_field );
			                $trainify_framework_widget_field_default = isset($widget_field['trainify_framework_widget_field_default']) ? $widget_field['trainify_framework_widget_field_default'] : '';
			                $trainify_framework_widgets_field_value = isset( $this_widget_instance[ $trainify_framework_widget_field_name ] ) ? $this_widget_instance[ $trainify_framework_widget_field_name ] : $trainify_framework_widget_field_default;
			                trainify_framework_widgets_show_widget_field( $trainifyframeworkwidget, $widget_field, $trainify_framework_widgets_field_value );
			            }
			        else:
			        	?><p><?php echo esc_html__('No fields are added on ', 'trainify').esc_attr($tab_details['trainify_framework_widget_field_name']).esc_html__(' tab', 'trainify'); ?></p><?php
			        endif;
				?>
			</div>
		<?php } ?>
	</div>
</div>