<?php
namespace EcafeAddons\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Utils;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Border;
use Elementor\Core\Schemes\Typography;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Box_Shadow;

use EcafeAddons\EcafeElementLoad;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

class Ecafe_Social_Icons extends Widget_Base {

	public function get_name() {
		return 'ecafe-social-icons';
	}

	public function get_title() {
		return esc_html__( 'Social Icons', 'essential-classy-addons-for-elementor' );
	}

	public function get_icon() {
		return 'ecafe-ele-back-icon ecafe-social-icon';
	}

	public function get_categories() {
		return array( 'essential' );
	}

	public function get_keywords() {
		return array( 'social', 'icons', 'social icons' );
	}

	public function get_custom_help_url() {
		return 'https://store.kapasias.com/helpdesk/';
	}

	public function has_widget_inner_wrapper(): bool {
		return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
	}

	protected function register_controls() {

		$this->start_controls_section(
			'contentSection',
			array(
				'label' => esc_html__( 'Social Icons', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$repeater = new \Elementor\Repeater();
		$repeater->add_control(
			'socIconLabel',
			array(
				'label'       => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'default'     => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Label', 'essential-classy-addons-for-elementor' ),
			)
		);
		$repeater->add_control(
			'socIconType',
			array(
				'label'   => esc_html__( 'Type', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'default',
				'options' => array(
					'default' => esc_html__( 'Default', 'essential-classy-addons-for-elementor' ),
					'tel'     => esc_html__( 'Tel', 'essential-classy-addons-for-elementor' ),
					'mail'    => esc_html__( 'Mail', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$repeater->add_control(
			'socIconIcon',
			array(
				'label'       => esc_html__( 'Icon', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::ICONS,
				'default'     => array(
					'value'   => 'fab fa-wordpress',
					'library' => 'fa-brands',
				),
				'recommended' => array(
					'fa-brands' => array(
						'android',
						'apple',
						'behance',
						'bitbucket',
						'codepen',
						'delicious',
						'deviantart',
						'digg',
						'dribbble',
						'elementor',
						'facebook',
						'flickr',
						'foursquare',
						'free-code-camp',
						'github',
						'gitlab',
						'globe',
						'houzz',
						'instagram',
						'jsfiddle',
						'linkedin',
						'medium',
						'meetup',
						'mix',
						'mixcloud',
						'odnoklassniki',
						'pinterest',
						'product-hunt',
						'reddit',
						'shopping-cart',
						'skype',
						'slideshare',
						'snapchat',
						'soundcloud',
						'spotify',
						'stack-overflow',
						'steam',
						'telegram',
						'thumb-tack',
						'tripadvisor',
						'tumblr',
						'twitch',
						'twitter',
						'viber',
						'vimeo',
						'vk',
						'weibo',
						'weixin',
						'whatsapp',
						'wordpress',
						'xing',
						'yelp',
						'youtube',
						'500px',
					),
				),
			)
		);
		$repeater->add_control(
			'socIconLink',
			array(
				'label'         => esc_html__( 'Link', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => esc_html__( 'https://your-link.com', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'default'       => array( 'url' => '' ),
				'dynamic'       => array( 'active' => true ),
				'condition'     => array(
					'socIconType' => 'default',
				),
			)
		);
		$repeater->add_control(
			'socIconTel',
			array(
				'label'     => __( 'Tel', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::TEXT,
				'condition' => array(
					'socIconType' => 'tel',
				),
			)
		);
		$repeater->add_control(
			'socIconEmail',
			array(
				'label'       => esc_html__( 'Email', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'placeholder' => esc_html__( 'Enter Email', 'essential-classy-addons-for-elementor' ),
				'condition'   => array(
					'socIconType' => 'mail',
				),
			)
		);
		$repeater->add_control(
			'optionView',
			array(
				'label'   => esc_html__( 'View', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'default',
				'options' => array(
					'default' => esc_html__( 'Default', 'essential-classy-addons-for-elementor' ),
					'custom'  => esc_html__( 'Custom', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$repeater->start_controls_tabs( 'tabsSocIcon' );
		$repeater->start_controls_tab(
			'tabSocIconN',
			array(
				'label'     => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
				'condition' => array(
					'optionView' => 'custom',
				),
			)
		);
		$repeater->add_control(
			'socIconNormColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li {{CURRENT_ITEM}}' => 'color: {{VALUE}};',
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li {{CURRENT_ITEM}} svg' => 'fill: {{VALUE}};',
				),
				'condition' => array(
					'optionView' => 'custom',
				),
			)
		);
		$repeater->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'      => 'socIconNormBg',
				'types'     => array( 'classic', 'gradient' ),
				'selector'  => '{{WRAPPER}} .eca-social-icons .eca-social-lists li {{CURRENT_ITEM}}',
				'condition' => array(
					'optionView' => 'custom',
				),
			)
		);
		$repeater->end_controls_tab();
		$repeater->start_controls_tab(
			'tabSocIconHover',
			array(
				'label'     => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
				'condition' => array(
					'optionView' => 'custom',
				),
			)
		);
		$repeater->add_control(
			'socIconColorHover',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li {{CURRENT_ITEM}}:hover' => 'color: {{VALUE}};',
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li {{CURRENT_ITEM}}:hover svg' => 'fill: {{VALUE}};',
				),
				'condition' => array(
					'optionView' => 'custom',
				),
			)
		);
		$repeater->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'      => 'socIconBgHover',
				'types'     => array( 'classic', 'gradient' ),
				'selector'  => '{{WRAPPER}} .eca-social-icons .eca-social-lists li {{CURRENT_ITEM}}:hover',
				'condition' => array(
					'optionView' => 'custom',
				),
			)
		);
		$repeater->end_controls_tab();
		$repeater->end_controls_tabs();
		$this->add_control(
			'socIconList',
			array(
				'label'       => esc_html__( 'List', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::REPEATER,
				'fields'      => $repeater->get_controls(),
				'default'     => array(
					array(
						'socIconIcon'  => array(
							'value'   => 'fab fa-facebook',
							'library' => 'fa-brands',
						),
						'socIconLabel' => 'Facebook',
					),
					array(
						'socIconIcon'  => array(
							'value'   => 'fab fa-twitter',
							'library' => 'fa-brands',
						),
						'socIconLabel' => 'Twitter',
					),
					array(
						'socIconIcon'  => array(
							'value'   => 'fab fa-linkedin',
							'library' => 'fa-brands',
						),
						'socIconLabel' => 'Linkedin',
					),
				),
				'title_field' => '{{{ socIconLabel }}}',
			)
		);
		$this->add_responsive_control(
			'contentAlign',
			array(
				'label'     => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start'    => array(
						'title' => esc_html__( 'Left', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center'        => array(
						'title' => esc_html__( 'Center', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-center',
					),
					'flex-end'      => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
					'space-around'  => array(
						'title' => esc_html__( 'Space Around', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-h-align-stretch',
					),
					'space-between' => array(
						'title' => esc_html__( 'Space Between', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-h-align-stretch',
					),
				),
				'separator' => 'before',
				'default'   => 'flex-start',
				'selectors' => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists' => 'justify-content:{{VALUE}};',
				),
			)
		);
		$this->end_controls_section();

		/*Tilt Effect Options*/
		include ECAFE_PATH . 'element/widgets/ecafe-tilt-options.php';

		/*Notice panel*/
		$ecwidgetdemolink = esc_url( 'https://ecaddons.com/elements/social-icons/' );
		$ecwidgetdoclink  = esc_url( 'https://ecaddons.com/docs/social-icons-widget-tutorial/' );
		include ECAFE_PATH . 'element/widgets/ecafe-widgetpanel-help.php';

		/*style start*/
		$this->start_controls_section(
			'sectionStyling',
			array(
				'label' => esc_html__( 'Social Icons', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_responsive_control(
			'socialPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'socialMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'sIconSize',
			array(
				'label'      => esc_html__( 'Icon Size', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 200,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a i:before' => 'font-size :{{SIZE}}px;',
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a svg' => 'width:{{SIZE}}px;height:{{SIZE}}px;',
				),
			)
		);
			$this->add_responsive_control(
				'sIconBoxMinWidthSize',
				array(
					'label'      => esc_html__( 'Item Min. Width', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px' ),
					'range'      => array(
						'px' => array(
							'min' => 1,
							'max' => 200,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 50,
					),
					'selectors'  => array(
						'{{WRAPPER}} .eca-social-icons .eca-social-lists li a' => 'min-width:{{SIZE}}px;',
					),
				)
			);
		$this->start_controls_tabs( 'tabsSocialtyle' );
		$this->start_controls_tab(
			'tabSocialN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'socialColorN',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a' => 'color: {{VALUE}};',
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'      => 'socialBackgroundN',
				'types'     => array( 'classic', 'gradient' ),
				'selector'  => '{{WRAPPER}} .eca-social-icons .eca-social-lists li a',
				'condition' => array(
					'buttonHoverEffectH!' => 'yes',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'socialBorderN',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-social-icons .eca-social-lists li a',
			)
		);
		$this->add_responsive_control(
			'socialBrN',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'socialShadowN',
				'selector' => '{{WRAPPER}} .eca-social-icons .eca-social-lists li a',
			)
		);
		$this->add_control(
			'socialTransitionN',
			array(
				'label'       => esc_html__( 'Transition css', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'all .3s linear', 'essential-classy-addons-for-elementor' ),
				'selectors'   => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a' => 'transition:{{VALUE}};',
				),
			)
		);
		$this->add_control(
			'socialTransformN',
			array(
				'label'       => esc_html__( 'Transform css', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'skew(-20deg)', 'essential-classy-addons-for-elementor' ),
				'selectors'   => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a' => 'transform: {{VALUE}};-ms-transform: {{VALUE}};-moz-transform: {{VALUE}};-webkit-transform: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabSocialH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'buttonHoverEffectH',
			array(
				'label'     => esc_html__( 'Hover Effect', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'no',
			)
		);
		$this->add_control(
			'buttonEffectPosH',
			array(
				'label'     => esc_html__( 'Position', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => '',
				'options'   => array(
					''                              => esc_html__( 'Bottom', 'essential-classy-addons-for-elementor' ),
					'eca-button-hover-effect-top'   => esc_html__( 'Top', 'essential-classy-addons-for-elementor' ),
					'eca-button-hover-effect-left'  => esc_html__( 'Left', 'essential-classy-addons-for-elementor' ),
					'eca-button-hover-effect-right' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'buttonHoverEffectH' => 'yes',
				),
			)
		);
		$this->add_control(
			'socialColorh',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a:hover' => 'color: {{VALUE}};',
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a:hover svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'      => 'socialBackgroundH',
				'types'     => array( 'classic', 'gradient' ),
				'selector'  => '{{WRAPPER}} .eca-social-icons .eca-social-lists li a:hover',
				'condition' => array(
					'buttonHoverEffectH!' => 'yes',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'      => 'bBgEffectHover',
				'types'     => array( 'classic', 'gradient' ),
				'selector'  => '{{WRAPPER}} .eca-button-hover-effect:hover:after',
				'condition' => array(
					'buttonHoverEffectH' => 'yes',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'socialBorderH',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-social-icons .eca-social-lists li a:hover',
			)
		);
		$this->add_responsive_control(
			'socialBrH',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'socialShadowH',
				'selector' => '{{WRAPPER}} .eca-social-icons .eca-social-lists li a:hover',
			)
		);
		$this->add_control(
			'socialTransitionH',
			array(
				'label'       => esc_html__( 'Transition css', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'all .3s linear', 'essential-classy-addons-for-elementor' ),
				'selectors'   => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a:hover' => 'transition:{{VALUE}};',
				),
			)
		);
		$this->add_control(
			'socialTransformH',
			array(
				'label'       => esc_html__( 'Transform css', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'skew(-20deg)', 'essential-classy-addons-for-elementor' ),
				'selectors'   => array(
					'{{WRAPPER}} .eca-social-icons .eca-social-lists li a:hover' => 'transform: {{VALUE}};-ms-transform: {{VALUE}};-moz-transform: {{VALUE}};-webkit-transform: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
	}

	protected function render() {

		$settings = $this->get_settings_for_display();

		$socIconIcon = $socialIconClass = '';

		$output             = '<div class="eca-social-icons">';
			$output        .= '<ul class="eca-social-lists">';
				$tiltclass  = '';
				$tiltrender = '';
		if ( isset( $settings['tiltEffect'] ) && $settings['tiltEffect'] === 'yes' ) {
			/*Tilt Effect Render*/
			include ECAFE_PATH . 'element/widgets/ecafe-tilt-render.php';
		}
		foreach ( $settings['socIconList'] as $item ) {
			if ( ! empty( $item['socIconIcon'] ) ) {
						ob_start();
						\Elementor\Icons_Manager::render_icon( $item['socIconIcon'], array( 'aria-hidden' => 'true' ) );
						$socIconIcon = ob_get_contents();
						ob_end_clean();

						$socialIconClass = explode( ' ', $item['socIconIcon']['value'], 2 );
						$socialIconClass = str_replace( 'fa-', '', $socialIconClass[1] );
			}

					$socIconType  = ! empty( $item['socIconType'] ) ? $item['socIconType'] : 'default';
					$socIconLink  = ! empty( $item['socIconLink']['url'] ) ? $item['socIconLink']['url'] : '';
					$socIconTel   = ! empty( $item['socIconTel'] ) ? $item['socIconTel'] : '';
					$socIconEmail = ! empty( $item['socIconEmail'] ) ? $item['socIconEmail'] : '';

					$socIconSrc = $socIconLinkTarget = $socIconLinkNoFollow = '';
			if ( $socIconType == 'default' && ! empty( $socIconLink ) ) {
				$socIconLinkTarget   = $item['socIconLink']['is_external'] ? ' target="_blank"' : '';
				$socIconLinkNoFollow = $item['socIconLink']['nofollow'] ? ' rel="nofollow"' : '';
				$socIconSrc          = $socIconLink;
			} elseif ( $socIconType == 'tel' && ! empty( $socIconTel ) ) {
						$socIconSrc = 'tel:' . $socIconTel;
			} elseif ( $socIconType == 'mail' && ! empty( $socIconEmail ) ) {
								$socIconSrc = 'mailto:' . $socIconEmail;
			}

								$output            .= '<li class="eca-social-list ' . esc_attr( $tiltclass ) . '" ' . $tiltrender . '>';
								$buttonHoverEffectH = ( isset( $settings['buttonHoverEffectH'] ) && $settings['buttonHoverEffectH'] == 'yes' ) ? 'eca-button-hover-effect ' . esc_attr( $settings['buttonEffectPosH'] ) : '';
								$output            .= '<a class="elementor-repeater-item-' . esc_attr( $item['_id'] ) . ' eca-si-' . esc_attr( $socialIconClass ) . ' ' . esc_attr( $buttonHoverEffectH ) . '"
								href="' . esc_url( $socIconSrc ) . '" ' . esc_attr( $socIconLinkTarget ) . esc_attr( $socIconLinkNoFollow ) . '>
								' . $socIconIcon . '
								</a>';
								$output            .= '</li>';
		}
			$output .= '</ul>';
			$output .= '</div>';

			echo wp_kses_normalize_entities( $output );
	}
}
