PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.3.0
Easy Elements for Elementor – Addons & Website Templates v1.3.0
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / widgets / single-nav / single-nav.php

single-nav.php in Easy Elements for Elementor – Addons & Website Templates 1.3.0, at widgets/single-nav/single-nav.php

444 lines 14.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Easyel\EasyElements\Widgets;
3 use Elementor\Controls_Manager;
4 use Elementor\Group_Control_Box_Shadow;
5 use Elementor\Group_Control_Typography;
6 use Elementor\Group_Control_Border;
7 use Elementor\Group_Control_Background;
8
9 defined( 'ABSPATH' ) || die();
10
11 class Easyel_Single_Nav_Widget extends \Elementor\Widget_Base {
12
13 public function get_name() {
14 return 'eel-single-nav';
15 }
16
17 /**
18 * Get widget title.
19 *
20 * Retrieve counter widget title.
21 *
22 * @since 1.0.0
23 * @access public
24 *
25 * @return string Widget title.
26 */
27 public function get_title() {
28 return esc_html__( 'Single Navigation', 'easy-elements' );
29 }
30
31 /**
32 * Get widget icon.
33 *
34 * Retrieve counter widget icon.
35 *
36 * @since 1.0.0
37 * @access public
38 *
39 * @return string Widget icon.
40 */
41 public function get_icon() {
42 return 'easyicon easyelIcon-navigation';
43 }
44
45 /**
46 * Retrieve the list of scripts the counter widget depended on.
47 *
48 * Used to set scripts dependencies required to run the widget.
49 *
50 * @since 1.3.0
51 * @access public
52 *
53 * @return array Widget scripts dependencies.
54 */
55 public function get_categories() {
56 return [ 'easyelements_header_footer_category' ];
57 }
58
59 /**
60 * Get widget keywords.
61 *
62 * Retrieve the list of keywords the widget belongs to.
63 *
64 * @since 2.1.0
65 * @access public
66 *
67 * @return array Widget keywords.
68 */
69 public function get_keywords() {
70 return [ 'navigation', 'menu', 'nav', 'text' ];
71 }
72
73 public function get_style_depends() {
74 return [
75 'eel-single-nav',
76 ];
77 }
78
79
80 protected function register_controls() {
81 $this->start_controls_section(
82 'section_single_nav',
83 [
84 'label' => esc_html__( 'Single Navigation', 'easy-elements' ),
85 ]
86 );
87
88 $repeater = new \Elementor\Repeater();
89
90 $repeater->add_control(
91 'nav_text',
92 [
93 'label' => esc_html__( 'Enter Menu Text Here', 'easy-elements' ),
94 'type' => Controls_Manager::TEXT,
95 'default' => esc_html__( 'Menu Item', 'easy-elements' ),
96 'label_block' => true,
97 ]
98 );
99
100 $repeater->add_control(
101 'nav_link',
102 [
103 'label' => esc_html__( 'Enter Menu Link Here', 'easy-elements' ),
104 'type' => Controls_Manager::URL,
105 'placeholder' => 'https://your-link.com',
106 'options' => [ 'url', 'is_external', 'nofollow' ],
107 'default' => [
108 'url' => '#',
109 ],
110 ]
111 );
112
113 $this->add_control(
114 'nav_items',
115 [
116 'label' => esc_html__( 'Single Page Navigation Items Here', 'easy-elements' ),
117 'type' => Controls_Manager::REPEATER,
118 'fields' => $repeater->get_controls(),
119 'default' => [
120 [
121 'nav_text' => 'Home',
122 ],
123 [
124 'nav_text' => 'About Us',
125 ],
126 [
127 'nav_text' => 'Services',
128 ],
129 [
130 'nav_text' => 'Contact Us',
131 ],
132 ],
133 'title_field' => '{{{ nav_text }}}',
134 ]
135 );
136
137 $this->add_control(
138 'enable_sticky_header',
139 [
140 'label' => __( 'Enable Sticky Header', 'easy-elements' ),
141 'type' => Controls_Manager::SWITCHER,
142 'label_on' => __( 'Yes', 'easy-elements' ),
143 'label_off' => __( 'No', 'easy-elements' ),
144 'frontend_available' => true,
145 'default' => 'no',
146 'prefix_class' => 'eel-sticky-header-',
147 ]
148 );
149
150 $this->add_control(
151 'fixed_top_sticky',
152 [
153 'label' => __( 'Fixed Top Sticky', 'easy-elements' ),
154 'type' => Controls_Manager::SWITCHER,
155 'label_on' => __( 'Yes', 'easy-elements' ),
156 'label_off' => __( 'No', 'easy-elements' ),
157 'frontend_available' => true,
158 'default' => 'yes',
159 'condition' => [
160 'enable_sticky_header' => 'yes',
161 ],
162 ]
163 );
164
165
166 $this->start_controls_tabs(
167 'nav_sticky_color_tabs',
168 [
169 'condition' => [
170 'enable_sticky_header' => 'yes',
171 ],
172 ]
173 );
174
175 $this->start_controls_tab(
176 'nav_sticky_color_normal',
177 [
178 'label' => esc_html__( 'Normal', 'easy-elements' ),
179 'condition' => [
180 'enable_sticky_header' => 'yes',
181 ],
182 ]
183 );
184
185 $this->add_control(
186 'bg_color_sticky_normal',
187 [
188 'label' => __( 'Background Color', 'easy-elements' ),
189 'type' => Controls_Manager::COLOR,
190 'default' => '',
191 'selectors' => [
192 '.eel-single-nav-sticky-enabled' => 'background-color: {{VALUE}}',
193 ],
194 'condition' => [
195 'enable_sticky_header' => 'yes',
196 ],
197 ]
198 );
199 $this->end_controls_tab();
200
201 $this->start_controls_tab(
202 'nav_sticky_color_sticky',
203 [
204 'label' => esc_html__( 'Sticky', 'easy-elements' ),
205 'condition' => [
206 'enable_sticky_header' => 'yes',
207 ],
208 ]
209 );
210 $this->add_control(
211 'bg_color_sticky',
212 [
213 'label' => __( 'Background Color', 'easy-elements' ),
214 'type' => Controls_Manager::COLOR,
215 'default' => '',
216 'selectors' => [
217 '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',
218 ],
219 'condition' => [
220 'enable_sticky_header' => 'yes',
221 ],
222 ]
223 );
224 $this->end_controls_tab();
225 $this->end_controls_tabs();
226
227 $this->add_control(
228 'text_color_sticky',
229 [
230 'label' => __( 'Text Color', 'easy-elements' ),
231 'type' => Controls_Manager::COLOR,
232 'default' => '',
233 'selectors' => [
234 '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',
235 '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;',
236 ],
237 'condition' => [
238 'enable_sticky_header' => 'yes',
239 ],
240 ]
241 );
242 $this->add_group_control(
243 \Elementor\Group_Control_Box_Shadow::get_type(),
244 [
245 'name' => 'box_shadow',
246 'selector' => 'body header.eel-sticky-header-on.eel-up-scroll, body header.eel-sticky-header-on.eel--fixed-top-sticky',
247 'condition' => [
248 'enable_sticky_header' => 'yes',
249 ],
250 ]
251 );
252 $this->end_controls_section();
253
254
255 $this->start_controls_section(
256 'section_nav_style',
257 [
258 'label' => esc_html__( 'Navigation Style', 'easy-elements' ),
259 'tab' => Controls_Manager::TAB_STYLE,
260 ]
261 );
262
263 $this->start_controls_tabs( 'nav_color_tabs' );
264
265 $this->start_controls_tab(
266 'nav_color_normal',
267 [
268 'label' => esc_html__( 'Normal', 'easy-elements' ),
269 ]
270 );
271
272 $this->add_control(
273 'nav_text_color',
274 [
275 'label' => esc_html__( 'Color', 'easy-elements' ),
276 'type' => Controls_Manager::COLOR,
277 'selectors' => [
278 '{{WRAPPER}} .eel-single-nav-list .eel-nav-item a' => 'color: {{VALUE}};',
279 ],
280 ]
281 );
282 $this->add_control(
283 'nav_bg_color',
284 [
285 'label' => esc_html__( 'Background Color', 'easy-elements' ),
286 'type' => Controls_Manager::COLOR,
287 'selectors' => [
288 '{{WRAPPER}} .eel-single-nav-list .eel-nav-item a' => 'background-color: {{VALUE}};',
289 ],
290 ]
291 );
292 $this->add_group_control(
293 Group_Control_Typography::get_type(),
294 [
295 'name' => 'nav_typography',
296 'label' => esc_html__( 'Typography', 'easy-elements' ),
297 'selector' => '{{WRAPPER}} .eel-single-nav-list .eel-nav-item a',
298 ]
299 );
300
301 $this->add_responsive_control(
302 'nav_padding',
303 [
304 'label' => esc_html__( 'Padding', 'easy-elements' ),
305 'type' => Controls_Manager::DIMENSIONS,
306 'size_units' => [ 'px', 'em', '%' ],
307 'selectors' => [
308 '{{WRAPPER}} .eel-single-nav-list .eel-nav-item a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
309 ],
310 ]
311 );
312
313 $this->add_responsive_control(
314 'nav_margin',
315 [
316 'label' => esc_html__( 'Margin', 'easy-elements' ),
317 'type' => Controls_Manager::DIMENSIONS,
318 'size_units' => [ 'px', 'em', '%' ],
319 'selectors' => [
320 '{{WRAPPER}} .eel-single-nav-list .eel-nav-item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
321 ],
322 ]
323 );
324
325 $this->end_controls_tab();
326
327 $this->start_controls_tab(
328 'nav_color_hover',
329 [
330 'label' => esc_html__( 'Hover', 'easy-elements' ),
331 ]
332 );
333
334 $this->add_control(
335 'nav_hover_color',
336 [
337 'label' => esc_html__( 'Hover Color', 'easy-elements' ),
338 'type' => Controls_Manager::COLOR,
339 'selectors' => [
340 '{{WRAPPER}} .eel-single-nav-list .eel-nav-item a:hover' => 'color: {{VALUE}};',
341 ],
342 ]
343 );
344 $this->add_control(
345 'nav_bg_color_hover',
346 [
347 'label' => esc_html__( 'Background Color', 'easy-elements' ),
348 'type' => Controls_Manager::COLOR,
349 'selectors' => [
350 '{{WRAPPER}} .eel-single-nav-list .eel-nav-item:hover a' => 'background-color: {{VALUE}};',
351 ],
352 ]
353 );
354
355 $this->end_controls_tab();
356
357 /* Active */
358 $this->start_controls_tab(
359 'nav_color_active',
360 [
361 'label' => esc_html__( 'Active', 'easy-elements' ),
362 ]
363 );
364
365 $this->add_control(
366 'nav_active_color',
367 [
368 'label' => esc_html__( 'Active Color', 'easy-elements' ),
369 'type' => Controls_Manager::COLOR,
370 'selectors' => [
371 '{{WRAPPER}} .eel-single-nav-list .eel-nav-item.active a' => 'color: {{VALUE}};',
372 ],
373 ]
374 );
375 $this->add_control(
376 'nav_bg_color_active',
377 [
378 'label' => esc_html__( 'Background Color', 'easy-elements' ),
379 'type' => Controls_Manager::COLOR,
380 'selectors' => [
381 '{{WRAPPER}} .eel-single-nav-list .eel-nav-item.active a' => 'background-color: {{VALUE}};',
382 ],
383 ]
384 );
385 $this->end_controls_tab();
386 $this->end_controls_tabs();
387 $this->end_controls_section();
388 }
389 protected function render() {
390 $settings = $this->get_settings_for_display();
391 if ( empty( $settings['nav_items'] ) ) {
392 return;
393 }
394 if ( isset( $settings['enable_sticky_header'] ) && 'yes' === $settings['enable_sticky_header'] ) {
395 wp_enqueue_script(
396 'eel-sticky-header',
397 plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'widgets/single-nav/js/eel-sticky-header.js',
398 [ 'jquery' ],
399 EASYELEMENTS_VER,
400 true
401 );
402 }
403 if ( 'yes' === $settings['fixed_top_sticky'] ) {
404 $this->add_render_attribute( 'eel-main-menu', 'class', 'eel-fixed-top-sticky' );
405
406 $inline_js = "
407 document.addEventListener('DOMContentLoaded', function() {
408 var header = document.querySelector('header.easy-site-header');
409 if (header) {
410 header.classList.add('eel-fixed-top-sticky');
411 }
412 });
413 ";
414
415 wp_add_inline_script( 'eel-sticky-header', $inline_js );
416 }
417
418 ?>
419 <nav class="eel-single-nav">
420 <ul class="eel-single-nav-list">
421 <?php $i = 0; foreach ( $settings['nav_items'] as $item ) :
422 $active_class = ( $i === 0 ) ? 'active' : '';
423 $target = ! empty( $item['nav_link']['is_external'] ) ? '_blank' : '';
424 $nofollow = ! empty( $item['nav_link']['nofollow'] ) ? 'nofollow' : '';
425 ?>
426 <li class="eel-nav-item <?php echo esc_attr( $active_class ); ?>">
427 <a
428 href="<?php echo esc_url( $item['nav_link']['url'] ); ?>"
429 <?php if ( $target ) : ?>
430 target="<?php echo esc_attr( $target ); ?>"
431 <?php endif; ?>
432 <?php if ( $nofollow ) : ?>
433 rel="<?php echo esc_attr( $nofollow ); ?>"
434 <?php endif; ?>
435 >
436 <?php echo esc_html( $item['nav_text'] ); ?>
437 </a>
438 </li>
439 <?php $i++; endforeach; ?>
440 </ul>
441 </nav>
442 <?php
443 }
444 }