<?php

/**
 * Elementor counter Widget.
 *
 * Elementor widget that inserts an embbedable content into the page, from any given URL.
 *
 * @since 1.0.0
 */
class Daltech_Footer_Menu extends \Elementor\Widget_Base
{

    /**
     * Get widget name.
     *
     * Retrieve counter widget name.
     *
     * @since 1.0.0
     * @access public
     *
     * @return string Widget name.
     */
    public function get_name()
    {
        return 'daltech_footer_menu';
    }

    /**
     * Get widget title.
     *
     * Retrieve counter widget title.
     *
     * @since 1.0.0
     * @access public 
     *
     * @return string Widget title.
     */
    public function get_title()
    {
        return esc_html__('Footer Menu', 'daltech-core');
    }

    /**
     * Get widget icon.
     *
     * Retrieve counter widget icon.
     *
     * @since 1.0.0
     * @access public
     *
     * @return string Widget icon.
     */
    public function get_icon()
    {
        return 'eicon-code';
    }

    /**
     * Get widget categories.
     *
     * Retrieve the list of categories the counter widget belongs to.
     *
     * @since 1.0.0
     * @access public
     *
     * @return array Widget categories.
     */
    public function get_categories()
    {
        return ['daltech'];
    }

    public function get_script_depends()
    {
        return array('main');
    }

    // Add The Input For User
    protected function register_controls()
    {


        $this->start_controls_section(
            'counter_content',
            [
                'label'        => esc_html__('Set counter Content', 'daltech-core'),
                'tab'        => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'style',
            [
                'label'     => esc_html__('Style', 'daltech-core'),
                'type'         => \Elementor\Controls_Manager::SELECT,
                'default'     => '1',
                'options'     => [
                    '1'      => esc_html__('Style One', 'daltech-core'),
                ],
            ]
        );

        $this->add_control(
            'section_title',
            [
                'label'         => esc_html__('Section Title', 'daltech-core'),
                'type'             => \Elementor\Controls_Manager::TEXTAREA,
                'placeholder'     => esc_html__('section title', 'daltech-core'),
                'default'         => esc_html__('Default Section Title', 'daltech-core'),
                'condition' => [
                    'style' => ['1']
                ]
            ]
        );

        $nav_menus = new \Elementor\Repeater();

        $nav_menus->add_control(
            'nav_menu',
            [
                'label' => __('Select Nav Menu', 'ogency-addon'),
                'type' => \Elementor\Controls_Manager::SELECT2,
                'options' => daltech_get_nav_menu(),
                'label_block' => true,
            ]
        );

        $this->add_control(
            'nav_menus',
            [
                'label' => __('Nav Menus', 'ogency-addon'),
                'type' => \Elementor\Controls_Manager::REPEATER,
                'prevent_empty' => false,
                'fields' => $nav_menus->get_controls(),
            ]
        );

        $this->end_controls_section();

        include DALTECH_PLUGIN_WIDGET_STYLE_PATH . 'footer-menu-style.php';
    }

    // Output For User
    protected function render()
    {
        $settings = $this->get_settings_for_display();
        if ($settings['style'] == '1') : ?>

            <!-- Start Our Footer Menu  One -->
            <div class="wow fadeInUp" data-wow-delay=".4s">
                <div class="single-footer-widget">
                    <div class="widget-head">
                        <h5> <?php echo wp_kses_post($settings['section_title'], 'daltech_kses_allowed_html'); ?></h5>
                    </div>
                    <?php foreach ($settings['nav_menus'] as $nav_menu) : ?>
                        <?php wp_nav_menu(array(
                            'menu' => $nav_menu['nav_menu'],
                            'container'  => '',
                            'menu_class' => 'list-items'
                        )); ?>
                    <?php endforeach; ?>
                </div>
            </div>
            <!-- End Our Footer Menu One -->
<?php
        endif;
    }
}
