<?php 
/*
 * List template
 */
?>
<ul id="<?php echo esc_attr( $id ); ?>" class="pls-menu-element pls-megamenu-list">
	<li class="menu-item">
		<?php $link_attributes = isset($link) ? pls_core_elementor_get_url_attribute($link) : '';
		$title_class = ( isset( $make_title ) && $make_title == 'yes' ) ? ' pls-menu-heading':'';
		if( ! empty( $title ) ){
			if( !empty( $link_attributes ) ){ ?>
				<a class="nav-link<?php echo esc_attr($title_class);?>" <?php echo $link_attributes;?>>
					<?php echo esc_html( $title ); ?>
					<?php if( !empty( $label_text ) ){ ?>
					<span class="pls-menu-badge"><?php echo esc_html($label_text);?></span>
					<?php } ?>
				</a>
			<?php } else { ?>
				<span class="<?php echo esc_attr($title_class);?>">
					<?php echo esc_html( $title ); ?>
					<?php if( !empty( $label_text ) ){ ?>
					<span class="pls-menu-badge"><?php echo esc_html($label_text);?></span>
					<?php } ?>
				</span>
			<?php } 
		} ?>	
		<?php if( !empty( $menu_items ) ){ 
			$view_more_link_attributes = '';
			if( isset( $view_more_menu_item ) && $view_more_menu_item === 'yes' && !empty($view_more_text ) ) {
				$view_more_link_attributes = isset($view_more_link) ? pls_core_elementor_get_url_attribute($view_more_link) : '';
			}
		?>
			<ul class="pls-sub-megamenu">
				<?php foreach ( $menu_items as $item ): ?>
					<li class="menu-item">
						<?php $link_attributes = isset($item['link']) ? pls_core_elementor_get_url_attribute($item['link']) : '';
						if( !empty( $link_attributes ) ){ ?>
							<a class="nav-link" <?php echo $link_attributes;?>>
								<span class="pls-menu-text"><?php echo esc_html( $item['title'] ); ?></span>
								<?php if( ! empty( $item['label_text'] ) ){?>
									<span class="pls-menu-badge elementor-repeater-item-<?php echo esc_attr($item['_id']);?>"><?php echo esc_html($item['label_text']);?></span>
								<?php } ?>
							</a>
						<?php } ?>
					</li>
				<?php endforeach;
				if( !empty( $view_more_link_attributes ) ){
				?>
				<li class="menu-item pls-view-all-link">
					<a class="nav-link" <?php echo $view_more_link_attributes;?>>				
						<span class="pls-menu-text"><?php echo esc_html( $view_more_text ); ?></span>
					</a>
				</li>
				<?php } ?>
			</ul>
		<?php } ?>
	</li>
</ul>