PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.2.1
Easy Elements for Elementor – Addons & Website Templates v1.2.1
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
← All changes | widgets/offcanvas/offcanvas.php +466 -454 1.3.91.2.1 View file →
@@ -1,454 +1,466 @@
1 -<?php
2 -namespace Easyel\EasyElements\Widgets;
3 -use Elementor\Controls_Manager;
4 -use Elementor\Widget_Base;
5 -use Elementor\Group_Control_Typography;
6 -use Elementor\Group_Control_Background;
7 -
8 -if ( ! defined( 'ABSPATH' ) ) {
9 - exit;
10 -}
11 -
12 -class Easyel_Offcanvas_Widget extends Widget_Base {
13 -
14 - public function get_name() {
15 - return 'eel-offcanvas';
16 - }
17 -
18 - public function get_title() {
19 - return __( 'Offcanvas', 'easy-elements' );
20 - }
21 -
22 - public function get_icon() {
23 - return 'easyicon easyelIcon-canvas';
24 - }
25 -
26 - public function get_categories() {
27 - return [ 'easyelements_category' ];
28 - }
29 -
30 - public function get_keywords() {
31 - return [ 'offcanvas', 'text', 'link', 'image' ];
32 - }
33 -
34 - public function get_style_depends() {
35 - return [
36 - 'eel-offcanvas',
37 - ];
38 - }
39 -
40 - public function get_script_depends() {
41 - return [
42 - 'eel-offcanvas',
43 - ];
44 - }
45 -
46 - protected function register_controls() {
47 - $this->start_controls_section(
48 - 'section_offcanvas',
49 - [
50 - 'label' => __( 'Offcanvas Settings', 'easy-elements' ),
51 - ]
52 - );
53 -
54 - $this->add_control(
55 - 'offcanvas_layout',
56 - [
57 - 'label' => __( 'Offcanvas Layout', 'easy-elements' ),
58 - 'type' => Controls_Manager::SELECT,
59 - 'default' => 'classic',
60 - 'options' => [
61 - 'classic' => __( 'Classic', 'easy-elements' ),
62 - 'modern' => __( 'Modern', 'easy-elements' ),
63 - ],
64 - ]
65 - );
66 -
67 - $this->add_control(
68 - 'menu_text',
69 - [
70 - 'label' => __( 'Canvas Menu', 'easy-elements' ),
71 - 'type' => Controls_Manager::TEXT,
72 - 'default' => __( 'Menu', 'easy-elements' ),
73 - ]
74 - );
75 -
76 - $this->add_control(
77 - 'btn_icon',
78 - [
79 - 'label' => esc_html__('Menu Icon', 'easy-elements'),
80 - 'type' => Controls_Manager::ICONS,
81 - 'default' => [
82 - 'value' => '',
83 - 'library' => '',
84 - ],
85 - ]
86 - );
87 -
88 - $this->add_control(
89 - 'position_offcanvas',
90 - [
91 - 'label' => __( 'Open Position', 'easy-elements' ),
92 - 'type' => Controls_Manager::SELECT,
93 - 'default' => 'eel-offcanvas-right',
94 - 'options' => [
95 - 'eel-offcanvas-left' => __( 'Left', 'easy-elements' ),
96 - 'eel-offcanvas-right' => __( 'Right', 'easy-elements' ),
97 - ],
98 - 'condition' => [
99 - 'offcanvas_layout' => 'classic',
100 - ],
101 - ]
102 - );
103 -
104 - $this->add_responsive_control(
105 - 'offcanvas_width',
106 - [
107 - 'label' => __( 'Canvas Width', 'easy-elements' ),
108 - 'type' => \Elementor\Controls_Manager::SLIDER,
109 - 'size_units' => [ 'px', '%' ],
110 - 'range' => [
111 - 'px' => [
112 - 'min' => 200,
113 - 'max' => 800,
114 - ],
115 - '%' => [
116 - 'min' => 20,
117 - 'max' => 100,
118 - ],
119 - ],
120 - 'default' => [
121 - 'unit' => 'px',
122 - 'size' => 380,
123 - ],
124 - 'selectors' => [
125 - '.eel-offcanvas' => 'width: {{SIZE}}{{UNIT}} !important;',
126 - ],
127 - 'condition' => [
128 - 'offcanvas_layout' => ['classic', 'modern'],
129 - ],
130 - ]
131 - );
132 -
133 - $this->add_control(
134 - 'content_template',
135 - [
136 - 'label' => esc_html__( 'Select Template', 'easy-elements' ),
137 - 'type' => \Elementor\Controls_Manager::SELECT,
138 - 'options' => $this->get_eligible_canvas_templates(),
139 - ]
140 - );
141 -
142 - $this->add_control(
143 - 'edit_template_button',
144 - [
145 - 'type' => \Elementor\Controls_Manager::RAW_HTML,
146 - 'raw' => sprintf(
147 - '<a href="%s" class="elementor-button elementor-button-primary" target="_blank">%s</a>
148 - <p style="margin-top:5px; font-size:13px; color:#555;">%s</p>',
149 - admin_url( 'edit.php?post_type=easy-offcanvas' ),
150 - esc_html__( 'Edit Offcanvas Templates', 'easy-elements' ),
151 - esc_html__( 'All your offcanvas content can be managed here in the Easy Offcanvas post type.', 'easy-elements' )
152 - ),
153 - 'separator' => 'before',
154 - ]
155 - );
156 -
157 - $this->add_control(
158 - 'close_icon',
159 - [
160 - 'label' => esc_html__('Close Icon', 'easy-elements'),
161 - 'type' => Controls_Manager::ICONS,
162 - 'default' => [
163 - 'value' => '',
164 - 'library' => '',
165 - ],
166 - ]
167 - );
168 -
169 - $this->add_control(
170 - 'need_blur_effect',
171 - [
172 - 'label' => esc_html__( 'Enable Blur', 'easy-elements' ),
173 - 'type' => \Elementor\Controls_Manager::SWITCHER,
174 - 'label_on' => esc_html__( 'Yes', 'easy-elements' ),
175 - 'label_off' => esc_html__( 'No', 'easy-elements' ),
176 - 'return_value' => 'yes',
177 - 'default' => 'no',
178 - ]
179 - );
180 - $this->end_controls_section();
181 -
182 - // Style
183 - $this->start_controls_section(
184 - 'style_section',
185 - [
186 - 'label' => esc_html__( 'Style', 'easy-elements' ),
187 - 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
188 - ]
189 - );
190 - $this->add_control(
191 - 'open_icon_options',
192 - [
193 - 'label' => esc_html__( 'Opener Icon', 'easy-elements' ),
194 - 'type' => \Elementor\Controls_Manager::HEADING,
195 - 'separator' => 'after',
196 - ]
197 - );
198 - $this->add_control(
199 - 'offcanvas_opener_text_color',
200 - [
201 - 'label' => esc_html__( 'Text Color', 'easy-elements' ),
202 - 'type' => \Elementor\Controls_Manager::COLOR,
203 - 'selectors' => [
204 - '{{WRAPPER}} .eel-offcanvas-toggle-text .eel-icon-text' => 'color: {{VALUE}};',
205 - ],
206 - 'condition' => [
207 - 'menu_text!' => '',
208 - ],
209 - ]
210 - );
211 - $this->add_group_control(
212 - \Elementor\Group_Control_Typography::get_type(),
213 - [
214 - 'name' => 'offcanvas_opener_text_typography',
215 - 'label' => esc_html__('Typography', 'easy-elements' ),
216 - 'selector' => '{{WRAPPER}} .eel-offcanvas-toggle-text .eel-icon-text',
217 - 'separator' => 'after',
218 - 'condition' => [
219 - 'menu_text!' => '',
220 - ],
221 - ]
222 - );
223 - $this->add_control(
224 - 'offcanvas_opener_icon_color',
225 - [
226 - 'label' => esc_html__( 'Hamburger Color', 'easy-elements' ),
227 - 'type' => \Elementor\Controls_Manager::COLOR,
228 - 'selectors' => [
229 - '{{WRAPPER}} .eel-offcanvas-toggle-text svg' => 'fill: {{VALUE}};',
230 - '{{WRAPPER}} .eel-offcanvas-toggle-text i' => 'color: {{VALUE}};',
231 - '{{WRAPPER}} .eel-icon-menu' => 'border-bottom-color: {{VALUE}};',
232 - ],
233 - 'condition' => [
234 - 'offcanvas_layout' => 'classic',
235 - ],
236 - ]
237 - );
238 - $this->add_control(
239 - 'offcanvas_opener_icon_humburger_color',
240 - [
241 - 'label' => esc_html__( 'Hamburger Color', 'easy-elements' ),
242 - 'type' => \Elementor\Controls_Manager::COLOR,
243 - 'selectors' => [
244 - '.modern.eel-offcanvas-wrapper label span' => 'background: {{VALUE}} !important;',
245 -
246 - ],
247 - 'condition' => [
248 - 'offcanvas_layout' => 'modern',
249 - ],
250 - ]
251 - );
252 - $this->add_responsive_control(
253 - 'offcanvas_opener_icon_size',
254 - [
255 - 'label' => __( 'Hamburger Size', 'easy-elements' ),
256 - 'type' => \Elementor\Controls_Manager::SLIDER,
257 - 'size_units' => [ 'px', '%' ],
258 - 'selectors' => [
259 - '{{WRAPPER}} .eel-offcanvas-toggle-text svg' => 'width: {{SIZE}}{{UNIT}} !important; height: {{SIZE}}{{UNIT}} !important;',
260 - '{{WRAPPER}} .eel-offcanvas-toggle-text i' => 'font-size: {{SIZE}}{{UNIT}} !important;',
261 - ],
262 - 'condition' => [
263 - 'offcanvas_layout' => 'classic',
264 - ],
265 - ]
266 - );
267 - $this->add_responsive_control(
268 - 'offcanvas_opener_icon_size_morden',
269 - [
270 - 'label' => __( 'Hamburger Size', 'easy-elements' ),
271 - 'type' => \Elementor\Controls_Manager::SLIDER,
272 - 'size_units' => [ 'px', '%' ],
273 - 'selectors' => [
274 - '{{WRAPPER}} .modern.eel-offcanvas-wrapper label' => 'width: {{SIZE}}{{UNIT}};',
275 - ],
276 - 'condition' => [
277 - 'offcanvas_layout' => 'modern',
278 - ],
279 - ]
280 - );
281 - $this->add_control(
282 - 'closing_icon_options',
283 - [
284 - 'label' => esc_html__( 'Closing Icon', 'easy-elements' ),
285 - 'type' => \Elementor\Controls_Manager::HEADING,
286 - 'separator' => 'after',
287 - ]
288 - );
289 -
290 - $this->add_control(
291 - 'offcanvas_closing_icon_color',
292 - [
293 - 'label' => esc_html__( 'Icon Color', 'easy-elements' ),
294 - 'type' => \Elementor\Controls_Manager::COLOR,
295 - 'selectors' => [
296 - '.eel-offcanvas-close' => 'color: {{VALUE}} !important;',
297 - ],
298 - 'condition' => [
299 - 'offcanvas_layout' => 'classic',
300 - ],
301 - ]
302 - );
303 -
304 - $this->add_control(
305 - 'offcanvas_closing_icon_morden_color',
306 - [
307 - 'label' => esc_html__( 'Icon Color', 'easy-elements' ),
308 - 'type' => \Elementor\Controls_Manager::COLOR,
309 - 'selectors' => [
310 - '.eel-modern-close-toggle span, .modern.eel-offcanvas-wrapper label.eel-modern-close-toggle span' => 'background: {{VALUE}} !important;',
311 - ],
312 - 'condition' => [
313 - 'offcanvas_layout' => 'modern',
314 - ],
315 - ]
316 - );
317 -
318 - $this->add_responsive_control(
319 - 'offcanvas_closing_icon_size',
320 - [
321 - 'label' => __( 'Icon Size', 'easy-elements' ),
322 - 'type' => \Elementor\Controls_Manager::SLIDER,
323 - 'size_units' => [ 'px', '%' ],
324 - 'selectors' => [
325 - '.eel-offcanvas-close' => 'font-size: {{SIZE}}{{UNIT}} !important;',
326 - ],
327 - 'condition' => [
328 - 'offcanvas_layout' => 'classic',
329 - ],
330 - ]
331 - );
332 - $this->add_control(
333 - 'offcanvas_item',
334 - [
335 - 'label' => esc_html__( 'OffCanvas Item', 'easy-elements' ),
336 - 'type' => \Elementor\Controls_Manager::HEADING,
337 - 'separator' => 'after',
338 - ]
339 - );
340 - $this->add_control(
341 - 'offcanvas_bg',
342 - [
343 - 'label' => esc_html__( 'OffCanvas Background', 'easy-elements' ),
344 - 'type' => \Elementor\Controls_Manager::COLOR,
345 - 'selectors' => [
346 - 'body .eel-offcanvas' => 'background: {{VALUE}} !important;',
347 - ],
348 - ]
349 - );
350 - $this->add_responsive_control(
351 - 'offcanvas_padding',
352 - [
353 - 'label' => esc_html__('OffCanvas Padding', 'easy-elements'),
354 - 'type' => \Elementor\Controls_Manager::DIMENSIONS,
355 - 'size_units' => [ 'px', 'em', '%' ],
356 - 'selectors' => [
357 - 'body .eel-offcanvas' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
358 - ],
359 - ]
360 - );
361 - $this->end_controls_section();
362 - }
363 -
364 - private function get_eligible_canvas_templates() {
365 - $templates = [];
366 -
367 - $posts = get_posts([
368 - 'post_type' => 'easy-offcanvas',
369 - 'posts_per_page' => -1,
370 - 'post_status' => 'publish',
371 - ]);
372 -
373 - foreach ( $posts as $post ) {
374 - $templates[ $post->ID ] = $post->post_title;
375 - }
376 -
377 - return $templates;
378 - }
379 -
380 - protected function render() {
381 - $settings = $this->get_settings_for_display();
382 - $position = $settings['position_offcanvas'];
383 - $btn_text = ! empty( $settings['menu_text'] ) ? $settings['menu_text'] : '';
384 - $content_template = ! empty( $settings['content_template'] ) ? $settings['content_template'] : '';
385 - $blur = ( isset( $settings['need_blur_effect'] ) && $settings['need_blur_effect'] === 'yes' ) ? 'eel-blur-effect' : '';
386 - $unique_id = 'eel-offcanvas-' . $this->get_id();
387 - ?>
388 -
389 - <div class="eel-offcanvas-wrapper <?php echo esc_attr($settings['offcanvas_layout']); ?>">
390 - <div class="eel-offcanvas-toggle" data-target="#<?php echo esc_attr($unique_id); ?>">
391 - <span class="eel-offcanvas-toggle-text">
392 - <?php if (!empty($btn_text)) : ?>
393 - <em class="eel-icon-text"><?php echo esc_html($btn_text); ?></em>
394 - <?php endif; ?>
395 -
396 - <?php if ($settings['offcanvas_layout'] === 'classic') : ?>
397 - <?php
398 - if (!empty($settings['btn_icon']['value'])) {
399 - \Elementor\Icons_Manager::render_icon($settings['btn_icon'], ['aria-hidden' => 'true']);
400 - } else { ?>
401 - <div class="eel-icon-menu-wrap">
402 - <em class="eel-icon-menu"></em>
403 - <em class="eel-icon-menu"></em>
404 - </div>
405 - <?php } ?>
406 - <?php else : ?>
407 - <label>
408 - <span></span><span></span><span></span>
409 - </label>
410 - <?php endif; ?>
411 - </span>
412 - </div>
413 -
414 - <?php
415 - if (!\Elementor\Plugin::$instance->editor->is_edit_mode()) {
416 - add_action('wp_footer', function() use ($settings, $unique_id, $blur) { ?>
417 - <div id="<?php echo esc_attr($unique_id); ?>" class="eel-offcanvas <?php echo esc_attr($blur . ' ' . $settings['position_offcanvas'] . ' ' . $settings['offcanvas_layout']); ?>">
418 - <div class="eel-offcanvas-overlay"></div>
419 - <div class="eel-offcanvas-panel">
420 - <?php if ($settings['offcanvas_layout'] === 'classic') { ?>
421 - <span class="eel-offcanvas-close eel-offcanvas-toggle" data-target="#<?php echo esc_attr($unique_id); ?>">
422 - <?php
423 - if (!empty($settings['close_icon']['value'])) {
424 - \Elementor\Icons_Manager::render_icon($settings['close_icon'], ['aria-hidden' => 'true']);
425 - } else {
426 - echo '<i class="unicon-close"></i>';
427 - }
428 - ?>
429 - </span>
430 - <?php } else { ?>
431 - <span class="eel-offcanvas-close eel-offcanvas-toggle eel-modern-close" data-target="#<?php echo esc_attr($unique_id); ?>">
432 - <label class="eel-modern-close-toggle">
433 - <span></span><span></span><span></span>
434 - </label>
435 - </span>
436 - <?php } ?>
437 -
438 - <div class="eel-offcanvas-content">
439 - <?php
440 - if (!empty($settings['content_template'])) {
441 - // phpcs:ignore WordPress.Security.EscapeOutput
442 - echo \Elementor\Plugin::$instance->frontend->get_builder_content_for_display($settings['content_template']);
443 - }
444 - ?>
445 - </div>
446 - </div>
447 - </div>
448 - <?php });
449 - }
450 - ?>
451 - </div>
452 - <?php
453 - }
454 -}
1 +<?php
2 +use Elementor\Controls_Manager;
3 +use Elementor\Widget_Base;
4 +use Elementor\Group_Control_Typography;
5 +use Elementor\Group_Control_Background;
6 +
7 +if ( ! defined( 'ABSPATH' ) ) {
8 + exit;
9 +}
10 +
11 +class Easyel_Offcanvas_Widget extends Widget_Base {
12 +
13 + public function get_style_depends() {
14 + $handle = 'eel-offcanvas-style';
15 + $css_path = plugin_dir_path( __FILE__ ) . 'css/offcanvas.min.css';
16 +
17 + if ( ! wp_style_is( $handle, 'registered' ) && file_exists( $css_path ) ) {
18 + wp_register_style(
19 + $handle,
20 + plugins_url( 'css/offcanvas.min.css', __FILE__ ),
21 + [],
22 + defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $css_path ) : EASYELEMENTS_VER
23 + );
24 + }
25 + return [ $handle ];
26 + }
27 +
28 + public function get_script_depends() {
29 + $handle = 'eel-offcanvas-script';
30 + $js_path = plugin_dir_path( __FILE__ ) . 'js/offcanvas.js';
31 +
32 + if ( ! wp_script_is( $handle, 'registered' ) && file_exists( $js_path ) ) {
33 + wp_register_script( $handle, plugins_url( 'js/offcanvas.js', __FILE__ ), [ 'jquery' ], filemtime( $js_path ), true );
34 + }
35 +
36 + return [ $handle ];
37 + }
38 + public function get_name() {
39 + return 'eel-offcanvas';
40 + }
41 +
42 + public function get_title() {
43 + return __( 'Offcanvas', 'easy-elements' );
44 + }
45 +
46 + public function get_icon() {
47 + return 'easyicon easyelIcon-canvas';
48 + }
49 +
50 + public function get_categories() {
51 + return [ 'easyelements_category' ];
52 + }
53 +
54 + public function get_keywords() {
55 + return [ 'offcanvas', 'text', 'link', 'image' ];
56 + }
57 + protected function register_controls() {
58 + $this->start_controls_section(
59 + 'section_offcanvas',
60 + [
61 + 'label' => __( 'Offcanvas Settings', 'easy-elements' ),
62 + ]
63 + );
64 +
65 + $this->add_control(
66 + 'offcanvas_layout',
67 + [
68 + 'label' => __( 'Offcanvas Layout', 'easy-elements' ),
69 + 'type' => Controls_Manager::SELECT,
70 + 'default' => 'classic',
71 + 'options' => [
72 + 'classic' => __( 'Classic', 'easy-elements' ),
73 + 'modern' => __( 'Modern', 'easy-elements' ),
74 + ],
75 + ]
76 + );
77 +
78 + $this->add_control(
79 + 'menu_text',
80 + [
81 + 'label' => __( 'Canvas Menu', 'easy-elements' ),
82 + 'type' => Controls_Manager::TEXT,
83 + 'default' => __( 'Menu', 'easy-elements' ),
84 + ]
85 + );
86 +
87 + $this->add_control(
88 + 'btn_icon',
89 + [
90 + 'label' => esc_html__('Menu Icon', 'easy-elements'),
91 + 'type' => Controls_Manager::ICONS,
92 + 'default' => [
93 + 'value' => '',
94 + 'library' => '',
95 + ],
96 + ]
97 + );
98 +
99 + $this->add_control(
100 + 'position_offcanvas',
101 + [
102 + 'label' => __( 'Open Position', 'easy-elements' ),
103 + 'type' => Controls_Manager::SELECT,
104 + 'default' => 'eel-offcanvas-right',
105 + 'options' => [
106 + 'eel-offcanvas-left' => __( 'Left', 'easy-elements' ),
107 + 'eel-offcanvas-right' => __( 'Right', 'easy-elements' ),
108 + ],
109 + 'condition' => [
110 + 'offcanvas_layout' => 'classic',
111 + ],
112 + ]
113 + );
114 +
115 + $this->add_responsive_control(
116 + 'offcanvas_width',
117 + [
118 + 'label' => __( 'Canvas Width', 'easy-elements' ),
119 + 'type' => \Elementor\Controls_Manager::SLIDER,
120 + 'size_units' => [ 'px', '%' ],
121 + 'range' => [
122 + 'px' => [
123 + 'min' => 200,
124 + 'max' => 800,
125 + ],
126 + '%' => [
127 + 'min' => 20,
128 + 'max' => 100,
129 + ],
130 + ],
131 + 'default' => [
132 + 'unit' => 'px',
133 + 'size' => 380,
134 + ],
135 + 'selectors' => [
136 + '.eel-offcanvas' => 'width: {{SIZE}}{{UNIT}} !important;',
137 + ],
138 + 'condition' => [
139 + 'offcanvas_layout' => ['classic', 'modern'],
140 + ],
141 + ]
142 + );
143 +
144 + $this->add_control(
145 + 'content_template',
146 + [
147 + 'label' => esc_html__( 'Select Template', 'easy-elements' ),
148 + 'type' => \Elementor\Controls_Manager::SELECT,
149 + 'options' => $this->get_eligible_canvas_templates(),
150 + ]
151 + );
152 +
153 + $this->add_control(
154 + 'edit_template_button',
155 + [
156 + 'type' => \Elementor\Controls_Manager::RAW_HTML,
157 + 'raw' => sprintf(
158 + '<a href="%s" class="elementor-button elementor-button-primary" target="_blank">%s</a>
159 + <p style="margin-top:5px; font-size:13px; color:#555;">%s</p>',
160 + admin_url( 'edit.php?post_type=easy-offcanvas' ),
161 + esc_html__( 'Edit Offcanvas Templates', 'easy-elements' ),
162 + esc_html__( 'All your offcanvas content can be managed here in the Easy Offcanvas post type.', 'easy-elements' )
163 + ),
164 + 'separator' => 'before',
165 + ]
166 + );
167 +
168 + $this->add_control(
169 + 'close_icon',
170 + [
171 + 'label' => esc_html__('Close Icon', 'easy-elements'),
172 + 'type' => Controls_Manager::ICONS,
173 + 'default' => [
174 + 'value' => '',
175 + 'library' => '',
176 + ],
177 + ]
178 + );
179 +
180 + $this->add_control(
181 + 'need_blur_effect',
182 + [
183 + 'label' => esc_html__( 'Enable Blur', 'easy-elements' ),
184 + 'type' => \Elementor\Controls_Manager::SWITCHER,
185 + 'label_on' => esc_html__( 'Yes', 'easy-elements' ),
186 + 'label_off' => esc_html__( 'No', 'easy-elements' ),
187 + 'return_value' => 'yes',
188 + 'default' => 'no',
189 + ]
190 + );
191 + $this->end_controls_section();
192 +
193 + // Style
194 + $this->start_controls_section(
195 + 'style_section',
196 + [
197 + 'label' => esc_html__( 'Style', 'easy-elements' ),
198 + 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
199 + ]
200 + );
201 + $this->add_control(
202 + 'open_icon_options',
203 + [
204 + 'label' => esc_html__( 'Opener Icon', 'easy-elements' ),
205 + 'type' => \Elementor\Controls_Manager::HEADING,
206 + 'separator' => 'after',
207 + ]
208 + );
209 + $this->add_control(
210 + 'offcanvas_opener_text_color',
211 + [
212 + 'label' => esc_html__( 'Text Color', 'easy-elements' ),
213 + 'type' => \Elementor\Controls_Manager::COLOR,
214 + 'selectors' => [
215 + '{{WRAPPER}} .eel-offcanvas-toggle-text .eel-icon-text' => 'color: {{VALUE}};',
216 + ],
217 + 'condition' => [
218 + 'menu_text!' => '',
219 + ],
220 + ]
221 + );
222 + $this->add_group_control(
223 + \Elementor\Group_Control_Typography::get_type(),
224 + [
225 + 'name' => 'offcanvas_opener_text_typography',
226 + 'label' => esc_html__('Typography', 'easy-elements' ),
227 + 'selector' => '{{WRAPPER}} .eel-offcanvas-toggle-text .eel-icon-text',
228 + 'separator' => 'after',
229 + 'condition' => [
230 + 'menu_text!' => '',
231 + ],
232 + ]
233 + );
234 + $this->add_control(
235 + 'offcanvas_opener_icon_color',
236 + [
237 + 'label' => esc_html__( 'Hamburger Color', 'easy-elements' ),
238 + 'type' => \Elementor\Controls_Manager::COLOR,
239 + 'selectors' => [
240 + '{{WRAPPER}} .eel-offcanvas-toggle-text svg' => 'fill: {{VALUE}};',
241 + '{{WRAPPER}} .eel-offcanvas-toggle-text i' => 'color: {{VALUE}};',
242 + '{{WRAPPER}} .eel-icon-menu' => 'border-bottom-color: {{VALUE}};',
243 + ],
244 + 'condition' => [
245 + 'offcanvas_layout' => 'classic',
246 + ],
247 + ]
248 + );
249 + $this->add_control(
250 + 'offcanvas_opener_icon_humburger_color',
251 + [
252 + 'label' => esc_html__( 'Hamburger Color', 'easy-elements' ),
253 + 'type' => \Elementor\Controls_Manager::COLOR,
254 + 'selectors' => [
255 + '.modern.eel-offcanvas-wrapper label span' => 'background: {{VALUE}} !important;',
256 +
257 + ],
258 + 'condition' => [
259 + 'offcanvas_layout' => 'modern',
260 + ],
261 + ]
262 + );
263 + $this->add_responsive_control(
264 + 'offcanvas_opener_icon_size',
265 + [
266 + 'label' => __( 'Hamburger Size', 'easy-elements' ),
267 + 'type' => \Elementor\Controls_Manager::SLIDER,
268 + 'size_units' => [ 'px', '%' ],
269 + 'selectors' => [
270 + '{{WRAPPER}} .eel-offcanvas-toggle-text svg' => 'width: {{SIZE}}{{UNIT}} !important; height: {{SIZE}}{{UNIT}} !important;',
271 + '{{WRAPPER}} .eel-offcanvas-toggle-text i' => 'font-size: {{SIZE}}{{UNIT}} !important;',
272 + ],
273 + 'condition' => [
274 + 'offcanvas_layout' => 'classic',
275 + ],
276 + ]
277 + );
278 + $this->add_responsive_control(
279 + 'offcanvas_opener_icon_size_morden',
280 + [
281 + 'label' => __( 'Hamburger Size', 'easy-elements' ),
282 + 'type' => \Elementor\Controls_Manager::SLIDER,
283 + 'size_units' => [ 'px', '%' ],
284 + 'selectors' => [
285 + '{{WRAPPER}} .modern.eel-offcanvas-wrapper label' => 'width: {{SIZE}}{{UNIT}};',
286 + ],
287 + 'condition' => [
288 + 'offcanvas_layout' => 'modern',
289 + ],
290 + ]
291 + );
292 + $this->add_control(
293 + 'closing_icon_options',
294 + [
295 + 'label' => esc_html__( 'Closing Icon', 'easy-elements' ),
296 + 'type' => \Elementor\Controls_Manager::HEADING,
297 + 'separator' => 'after',
298 + ]
299 + );
300 +
301 + $this->add_control(
302 + 'offcanvas_closing_icon_color',
303 + [
304 + 'label' => esc_html__( 'Icon Color', 'easy-elements' ),
305 + 'type' => \Elementor\Controls_Manager::COLOR,
306 + 'selectors' => [
307 + '.eel-offcanvas-close' => 'color: {{VALUE}} !important;',
308 + ],
309 + 'condition' => [
310 + 'offcanvas_layout' => 'classic',
311 + ],
312 + ]
313 + );
314 +
315 + $this->add_control(
316 + 'offcanvas_closing_icon_morden_color',
317 + [
318 + 'label' => esc_html__( 'Icon Color', 'easy-elements' ),
319 + 'type' => \Elementor\Controls_Manager::COLOR,
320 + 'selectors' => [
321 + '.eel-modern-close-toggle span, .modern.eel-offcanvas-wrapper label.eel-modern-close-toggle span' => 'background: {{VALUE}} !important;',
322 + ],
323 + 'condition' => [
324 + 'offcanvas_layout' => 'modern',
325 + ],
326 + ]
327 + );
328 +
329 + $this->add_responsive_control(
330 + 'offcanvas_closing_icon_size',
331 + [
332 + 'label' => __( 'Icon Size', 'easy-elements' ),
333 + 'type' => \Elementor\Controls_Manager::SLIDER,
334 + 'size_units' => [ 'px', '%' ],
335 + 'selectors' => [
336 + '.eel-offcanvas-close' => 'font-size: {{SIZE}}{{UNIT}} !important;',
337 + ],
338 + 'condition' => [
339 + 'offcanvas_layout' => 'classic',
340 + ],
341 + ]
342 + );
343 + $this->add_control(
344 + 'offcanvas_item',
345 + [
346 + 'label' => esc_html__( 'OffCanvas Item', 'easy-elements' ),
347 + 'type' => \Elementor\Controls_Manager::HEADING,
348 + 'separator' => 'after',
349 + ]
350 + );
351 + $this->add_control(
352 + 'offcanvas_bg',
353 + [
354 + 'label' => esc_html__( 'OffCanvas Background', 'easy-elements' ),
355 + 'type' => \Elementor\Controls_Manager::COLOR,
356 + 'selectors' => [
357 + 'body .eel-offcanvas' => 'background: {{VALUE}} !important;',
358 + ],
359 + ]
360 + );
361 + $this->add_responsive_control(
362 + 'offcanvas_padding',
363 + [
364 + 'label' => esc_html__('OffCanvas Padding', 'easy-elements'),
365 + 'type' => \Elementor\Controls_Manager::DIMENSIONS,
366 + 'size_units' => [ 'px', 'em', '%' ],
367 + 'selectors' => [
368 + 'body .eel-offcanvas' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
369 + ],
370 + ]
371 + );
372 + $this->end_controls_section();
373 + }
374 +
375 + private function get_eligible_canvas_templates() {
376 + $templates = [];
377 +
378 + $posts = get_posts([
379 + 'post_type' => 'easy-offcanvas',
380 + 'posts_per_page' => -1,
381 + 'post_status' => 'publish',
382 + ]);
383 +
384 + foreach ( $posts as $post ) {
385 + $templates[ $post->ID ] = $post->post_title;
386 + }
387 +
388 + return $templates;
389 + }
390 +
391 + protected function render() {
392 + $settings = $this->get_settings_for_display();
393 + $position = $settings['position_offcanvas'];
394 + $btn_text = ! empty( $settings['menu_text'] ) ? $settings['menu_text'] : '';
395 + $content_template = ! empty( $settings['content_template'] ) ? $settings['content_template'] : '';
396 + $blur = ( isset( $settings['need_blur_effect'] ) && $settings['need_blur_effect'] === 'yes' ) ? 'eel-blur-effect' : '';
397 + $unique_id = 'eel-offcanvas-' . $this->get_id();
398 + ?>
399 +
400 + <div class="eel-offcanvas-wrapper <?php echo esc_attr($settings['offcanvas_layout']); ?>">
401 + <div class="eel-offcanvas-toggle" data-target="#<?php echo esc_attr($unique_id); ?>">
402 + <span class="eel-offcanvas-toggle-text">
403 + <?php if (!empty($btn_text)) : ?>
404 + <em class="eel-icon-text"><?php echo esc_html($btn_text); ?></em>
405 + <?php endif; ?>
406 +
407 + <?php if ($settings['offcanvas_layout'] === 'classic') : ?>
408 + <?php
409 + if (!empty($settings['btn_icon']['value'])) {
410 + \Elementor\Icons_Manager::render_icon($settings['btn_icon'], ['aria-hidden' => 'true']);
411 + } else { ?>
412 + <div class="eel-icon-menu-wrap">
413 + <em class="eel-icon-menu"></em>
414 + <em class="eel-icon-menu"></em>
415 + </div>
416 + <?php } ?>
417 + <?php else : ?>
418 + <label>
419 + <span></span><span></span><span></span>
420 + </label>
421 + <?php endif; ?>
422 + </span>
423 + </div>
424 +
425 + <?php
426 + if (!\Elementor\Plugin::$instance->editor->is_edit_mode()) {
427 + add_action('wp_footer', function() use ($settings, $unique_id, $blur) { ?>
428 + <div id="<?php echo esc_attr($unique_id); ?>" class="eel-offcanvas <?php echo esc_attr($blur . ' ' . $settings['position_offcanvas'] . ' ' . $settings['offcanvas_layout']); ?>">
429 + <div class="eel-offcanvas-overlay"></div>
430 + <div class="eel-offcanvas-panel">
431 + <?php if ($settings['offcanvas_layout'] === 'classic') { ?>
432 + <span class="eel-offcanvas-close eel-offcanvas-toggle" data-target="#<?php echo esc_attr($unique_id); ?>">
433 + <?php
434 + if (!empty($settings['close_icon']['value'])) {
435 + \Elementor\Icons_Manager::render_icon($settings['close_icon'], ['aria-hidden' => 'true']);
436 + } else {
437 + echo '<i class="unicon-close"></i>';
438 + }
439 + ?>
440 + </span>
441 + <?php } else { ?>
442 + <span class="eel-offcanvas-close eel-offcanvas-toggle eel-modern-close" data-target="#<?php echo esc_attr($unique_id); ?>">
443 + <label class="eel-modern-close-toggle">
444 + <span></span><span></span><span></span>
445 + </label>
446 + </span>
447 + <?php } ?>
448 +
449 + <div class="eel-offcanvas-content">
450 + <?php
451 + if (!empty($settings['content_template'])) {
452 + // phpcs:ignore WordPress.Security.EscapeOutput
453 + echo \Elementor\Plugin::$instance->frontend->get_builder_content_for_display($settings['content_template']);
454 + }
455 + ?>
456 + </div>
457 + </div>
458 + </div>
459 + <?php });
460 + }
461 + ?>
462 + </div>
463 + <?php
464 + }
465 +}
466 +?>