start_controls_section( 'section_single_nav', [ 'label' => esc_html__( 'Single Navigation', 'easy-elements' ), ] ); $repeater = new \Elementor\Repeater(); $repeater->add_control( 'nav_text', [ 'label' => esc_html__( 'Enter Menu Text Here', 'easy-elements' ), 'type' => Controls_Manager::TEXT, 'default' => esc_html__( 'Menu Item', 'easy-elements' ), 'label_block' => true, ] ); $repeater->add_control( 'nav_link', [ 'label' => esc_html__( 'Enter Menu Link Here', 'easy-elements' ), 'type' => Controls_Manager::URL, 'placeholder' => 'https://your-link.com', 'options' => [ 'url', 'is_external', 'nofollow' ], 'default' => [ 'url' => '#', ], ] ); $this->add_control( 'nav_items', [ 'label' => esc_html__( 'Single Page Navigation Items Here', 'easy-elements' ), 'type' => Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), 'default' => [ [ 'nav_text' => 'Home', ], [ 'nav_text' => 'About Us', ], [ 'nav_text' => 'Services', ], [ 'nav_text' => 'Contact Us', ], ], 'title_field' => '{{{ nav_text }}}', ] ); $this->add_control( 'enable_sticky_header', [ 'label' => __( 'Enable Sticky Header', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'easy-elements' ), 'label_off' => __( 'No', 'easy-elements' ), 'frontend_available' => true, 'default' => 'no', 'prefix_class' => 'eel-sticky-header-', ] ); $this->add_control( 'fixed_top_sticky', [ 'label' => __( 'Fixed Top Sticky', 'easy-elements' ), 'type' => Controls_Manager::SWITCHER, 'label_on' => __( 'Yes', 'easy-elements' ), 'label_off' => __( 'No', 'easy-elements' ), 'frontend_available' => true, 'default' => 'yes', 'condition' => [ 'enable_sticky_header' => 'yes', ], ] ); $this->start_controls_tabs( 'nav_sticky_color_tabs', [ 'condition' => [ 'enable_sticky_header' => 'yes', ], ] ); $this->start_controls_tab( 'nav_sticky_color_normal', [ 'label' => esc_html__( 'Normal', 'easy-elements' ), 'condition' => [ 'enable_sticky_header' => 'yes', ], ] ); $this->add_control( 'bg_color_sticky_normal', [ 'label' => __( 'Background Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ '.eel-single-nav-sticky-enabled' => 'background-color: {{VALUE}}', ], 'condition' => [ 'enable_sticky_header' => 'yes', ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'nav_sticky_color_sticky', [ 'label' => esc_html__( 'Sticky', 'easy-elements' ), 'condition' => [ 'enable_sticky_header' => 'yes', ], ] ); $this->add_control( 'bg_color_sticky', [ 'label' => __( 'Background Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ 'header.eel-sticky-header-on.eel-up-scroll .eel-single-nav-sticky-enabled, header.eel-sticky-header-on.eel--fixed-top-sticky .eel-single-nav-sticky-enabled, header.eel-sticky-header-on.eel-up-scroll .eel-nav-menu__layout-horizontal .eel-nav-menu .sub-menu:not(.easyel--elementor-template-mega-menu)' => 'background-color: {{VALUE}} !important', ], 'condition' => [ 'enable_sticky_header' => 'yes', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_control( 'text_color_sticky', [ 'label' => __( 'Text Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'default' => '', 'selectors' => [ 'header.eel-sticky-header-on.eel-up-scroll .eel-single-nav-list li a, header.eel-sticky-header-on.eel-up-scroll .eel-single-nav-list li a, .header.eel-sticky-header-on.eel-up-scroll *, header.eel-sticky-header-on.eel--fixed-top-sticky .eel-single-nav-list li a, header.eel-sticky-header-on.eel--fixed-top-sticky *' => 'color: {{VALUE}} !important', 'header.eel-sticky-header-on.eel-up-scroll .eel-icon-menu, header.eel-sticky-header-on.eel--fixed-top-sticky .eel-icon-menu' => 'border-bottom-color: {{VALUE}} !important; transition: none !important;', ], 'condition' => [ 'enable_sticky_header' => 'yes', ], ] ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [ 'name' => 'box_shadow', 'selector' => 'body header.eel-sticky-header-on.eel-up-scroll, body header.eel-sticky-header-on.eel--fixed-top-sticky', 'condition' => [ 'enable_sticky_header' => 'yes', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_nav_style', [ 'label' => esc_html__( 'Navigation Style', 'easy-elements' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->start_controls_tabs( 'nav_color_tabs' ); $this->start_controls_tab( 'nav_color_normal', [ 'label' => esc_html__( 'Normal', 'easy-elements' ), ] ); $this->add_control( 'nav_text_color', [ 'label' => esc_html__( 'Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-single-nav-list .eel-nav-item a' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'nav_bg_color', [ 'label' => esc_html__( 'Background Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-single-nav-list .eel-nav-item a' => 'background-color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'nav_typography', 'label' => esc_html__( 'Typography', 'easy-elements' ), 'selector' => '{{WRAPPER}} .eel-single-nav-list .eel-nav-item a', ] ); $this->add_responsive_control( 'nav_padding', [ 'label' => esc_html__( 'Padding', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .eel-single-nav-list .eel-nav-item a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'nav_margin', [ 'label' => esc_html__( 'Margin', 'easy-elements' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => [ 'px', 'em', '%' ], 'selectors' => [ '{{WRAPPER}} .eel-single-nav-list .eel-nav-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'nav_color_hover', [ 'label' => esc_html__( 'Hover', 'easy-elements' ), ] ); $this->add_control( 'nav_hover_color', [ 'label' => esc_html__( 'Hover Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-single-nav-list .eel-nav-item a:hover' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'nav_bg_color_hover', [ 'label' => esc_html__( 'Background Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-single-nav-list .eel-nav-item:hover a' => 'background-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); /* Active */ $this->start_controls_tab( 'nav_color_active', [ 'label' => esc_html__( 'Active', 'easy-elements' ), ] ); $this->add_control( 'nav_active_color', [ 'label' => esc_html__( 'Active Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-single-nav-list .eel-nav-item.active a' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'nav_bg_color_active', [ 'label' => esc_html__( 'Background Color', 'easy-elements' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .eel-single-nav-list .eel-nav-item.active a' => 'background-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); if ( empty( $settings['nav_items'] ) ) { return; } if ( isset( $settings['enable_sticky_header'] ) && 'yes' === $settings['enable_sticky_header'] ) { wp_enqueue_script( 'eel-sticky-header', plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'widgets/single-nav/js/eel-sticky-header.js', [ 'jquery' ], EASYELEMENTS_VER, true ); } if ( 'yes' === $settings['fixed_top_sticky'] ) { $this->add_render_attribute( 'eel-main-menu', 'class', 'eel-fixed-top-sticky' ); $inline_js = " document.addEventListener('DOMContentLoaded', function() { var header = document.querySelector('header.easy-site-header'); if (header) { header.classList.add('eel-fixed-top-sticky'); } }); "; wp_add_inline_script( 'eel-sticky-header', $inline_js ); } ?>