PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.0
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.0
4.0.3 4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / widgets / back-to-top / back-to-top.php
elementskit-lite / widgets / back-to-top Last commit date
back-to-top-handler.php 3 years ago back-to-top.php 3 weeks ago
back-to-top.php
505 lines
1 <?php
2 namespace Elementor;
3
4 use \Elementor\ElementsKit_Widget_Back_To_Top_Handler as Handler;
5 use \ElementsKit_Lite\Modules\Controls\Controls_Manager as ElementsKit_Controls_Manager;
6
7 if (! defined( 'ABSPATH' ) ) exit;
8
9 class ElementsKit_Widget_Back_To_Top extends Widget_Base {
10 use \ElementsKit_Lite\Widgets\Widget_Notice;
11
12 public $base;
13
14 public function get_name() {
15 return Handler::get_name();
16 }
17
18 public function get_title() {
19 return Handler::get_title();
20 }
21
22 public function get_icon() {
23 return Handler::get_icon();
24 }
25
26 public function get_categories() {
27 return Handler::get_categories();
28 }
29
30 public function get_keywords() {
31 return Handler::get_keywords();
32 }
33
34 public function get_help_url() {
35 return 'https://wpmet.com/doc/back-to-top/';
36 }
37
38 public function get_script_depends() {
39 return ['ekit-back-to-top', 'animate-circle'];
40 }
41
42 public function get_style_depends() {
43 return ['ekit-back-to-top'];
44 }
45
46 protected function is_dynamic_content(): bool {
47 return false;
48 }
49
50 public function has_widget_inner_wrapper(): bool {
51 return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
52 }
53
54 protected function register_controls() {
55 /*
56 Content Tab section
57 ---------------------
58 -> Select appearane of back to top button
59 -> Icon control
60 -> Text control
61 -> Aligment
62 */
63
64 $this->start_controls_section(
65 'ekit_back_to_top_content_section',
66 [
67 'label' => esc_html__( 'Layout and Content', 'elementskit-lite' )
68 ]
69 );
70
71 $this->add_control(
72 'ekit_button_appearance',
73 [
74 'label' => esc_html__( 'Appearance', 'elementskit-lite' ),
75 'type' => Controls_Manager::SELECT,
76 'default' => 'icon_only',
77 'options' => [
78 'icon_only' => esc_html__( 'Icon Only', 'elementskit-lite' ),
79 'text_only' => esc_html__( 'Text Only', 'elementskit-lite' ),
80 'progress_indicator' => esc_html__( 'Progress Indicator', 'elementskit-lite' ),
81 ],
82 ]
83 );
84
85 // back to top icon show when user select icon only appearance
86 $this->add_control(
87 'ekit_btn_icons',
88 [
89 'label' => esc_html__( 'Icon', 'elementskit-lite' ),
90 'type' => Controls_Manager::ICONS,
91 'default' => [
92 'value' => 'fas fa-arrow-up',
93 'library' => 'fa-solid',
94 ],
95 'condition' => [
96 'ekit_button_appearance' => ['icon_only', 'progress_indicator']
97 ]
98 ]
99 );
100
101 // back to top text input control when user select text only appearance
102 $this->add_control(
103 'ekit_btn_text',
104 [
105 'label' => esc_html__( 'Button Text', 'elementskit-lite' ),
106 'type' => Controls_Manager::TEXT,
107 'dynamic' => [
108 'active' => true,
109 ],
110 'default' => esc_html__( 'Top', 'elementskit-lite' ),
111 'placeholder' => esc_html__( 'Type button label here', 'elementskit-lite' ),
112 'condition' => [
113 'ekit_button_appearance' => 'text_only'
114 ]
115 ]
116 );
117
118
119 $this->add_responsive_control(
120 'ekit_button_alignment',
121 [
122 'label' => esc_html__('Alignment', 'elementskit-lite'),
123 'type' => Controls_Manager::CHOOSE,
124 'default' => 'left',
125 'options' => [
126 'left' => [
127 'description' => esc_html__('Left', 'elementskit-lite'),
128 'icon' => 'eicon-text-align-left',
129 ],
130 'center' => [
131 'description' => esc_html__('Center', 'elementskit-lite'),
132 'icon' => 'eicon-text-align-center',
133 ],
134 'right' => [
135 'description' => esc_html__('Right', 'elementskit-lite'),
136 'icon' => 'eicon-text-align-right',
137 ],
138 ],
139 'selectors' => [
140 '{{WRAPPER}} .ekit-btt' => 'text-align: {{VALUE}};',
141 ]
142 ]
143 );
144
145
146 $this->end_controls_section(); // end of content tab section
147
148 /* ---------------------
149 Settings Tab
150 -> Scroll Top Offset
151 ------------------------*/
152 $this->start_controls_section(
153 'ekit_back_to_top_setting_section',
154 [
155 'label' => esc_html__( 'Setting', 'elementskit-lite' )
156 ]
157 );
158
159 $this->add_control(
160 'ekit_offset_top',
161 [
162 'label' => esc_html__( 'Offset Top (px)', 'elementskit-lite' ),
163 'type' => Controls_Manager::NUMBER,
164 'min' => 0,
165 'step' => 1,
166 'default' => 0,
167 ]
168 );
169
170 $this->add_control(
171 'ekit_show_button_after_switch',
172 [
173 'label' => esc_html__( 'Show button on scroll', 'elementskit-lite' ),
174 'type' => Controls_Manager::SWITCHER,
175 'label_on' => esc_html__( 'Yes', 'elementskit-lite' ),
176 'label_off' => esc_html__( 'No', 'elementskit-lite' ),
177 'default' => 'no',
178 ]
179 );
180
181 $this->add_control(
182 'ekit_show_button_after',
183 [
184 'label' => esc_html__( 'Enter scrolled value (px)', 'elementskit-lite' ),
185 'type' => Controls_Manager::NUMBER,
186 'min' => 0,
187 'step' => 1,
188 'default' => 400,
189 'condition' => [
190 'ekit_show_button_after_switch' => 'yes'
191 ]
192 ]
193 );
194
195 $this->end_controls_section(); // end of content tab section
196
197 /* -------------------------
198 back to top style tab
199 -> Typogaphy
200 -> Width
201 -> Height
202 -> Border radius
203 -> Border control
204 -> Stroke foreground and backgorund color
205 -> Size of button (width and height together)
206 ----------------------------*/
207 $this->start_controls_section(
208 'ekit_back_to_top_style_section',
209 [
210 'label' => esc_html__( 'Button Style', 'elementskit-lite' ),
211 'tab' => Controls_Manager::TAB_STYLE,
212 ]
213 );
214
215 $this->add_group_control(
216 Group_Control_Typography::get_type(),
217 array(
218 'name' => 'ekit_btn_typography',
219 'label' => esc_html__('Typography', 'elementskit-lite'),
220 'selector' => '{{WRAPPER}} .ekit-btt__button',
221 'exclude' => ['letter_spacing', 'font_style', 'text_decoration', 'line_height'], // PHPCS:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude
222 'fields_options' => [
223 'typography' => [
224 'default' => 'custom',
225 ],
226 'font_weight' => [
227 'default' => '400',
228 ],
229 'font_size' => [
230 'default' => [
231 'size' => '16',
232 'unit' => 'px'
233 ],
234 'size_units' => ['px']
235 ],
236 'text_transform' => [
237 'default' => 'uppercase',
238 ],
239 ],
240 )
241 );
242
243 $this->add_control(
244 'ekit_button_size',
245 [
246 'label' => esc_html__('Button Size (px)', 'elementskit-lite'),
247 'type' => Controls_Manager::SLIDER,
248 'size_units' => ['px'],
249 'range' => [
250 'px' => [
251 'min' => 0,
252 'max' => 200,
253 'step' => 1,
254 ],
255 ],
256 'default' => [
257 'unit' => 'px',
258 'size' => 50,
259 ],
260 'selectors' => [
261 '{{WRAPPER}} .ekit-btt__button' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
262 ],
263 'condition' => [
264 'ekit_button_appearance' => 'progress_indicator'
265 ]
266 ]
267 );
268
269 $this->add_control(
270 'ekit_button_width',
271 [
272 'label' => esc_html__('Width (px)', 'elementskit-lite'),
273 'type' => Controls_Manager::SLIDER,
274 'size_units' => ['px'],
275 'range' => [
276 'px' => [
277 'min' => 0,
278 'max' => 200,
279 'step' => 1,
280 ],
281 ],
282 'default' => [
283 'unit' => 'px',
284 'size' => 50,
285 ],
286 'selectors' => [
287 '{{WRAPPER}} .ekit-btt__button' => 'width: {{SIZE}}{{UNIT}};',
288 ],
289 'condition' => [
290 'ekit_button_appearance!' => 'progress_indicator'
291 ]
292 ]
293 );
294
295
296
297 $this->add_control(
298 'ekit_button_height',
299 [
300 'label' => esc_html__('Height (px)', 'elementskit-lite'),
301 'type' => Controls_Manager::SLIDER,
302 'size_units' => ['px'],
303 'range' => [
304 'px' => [
305 'min' => 0,
306 'max' => 200,
307 'step' => 1,
308 ],
309 ],
310 'default' => [
311 'unit' => 'px',
312 'size' => 50,
313 ],
314 'selectors' => [
315 '{{WRAPPER}} .ekit-btt__button' => 'height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
316 ],
317 'condition' => [
318 'ekit_button_appearance!' => 'progress_indicator'
319 ]
320 ]
321 );
322
323 $this->add_group_control(
324 Group_Control_Border::get_type(),
325 [
326 'name' => 'ekit_button_border',
327 'label' => esc_html__( 'Border', 'elementskit-lite' ),
328 'selector' => '{{WRAPPER}} .ekit-btt__button',
329 'exclude' => ['border_color'], // PHPCS:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude
330 'condition' => [
331 'ekit_button_appearance!' => 'progress_indicator'
332 ]
333 ]
334 );
335
336 $this->add_responsive_control(
337 'ekit_button_radius',
338 [
339 'label' => esc_html__('Border Radius', 'elementskit-lite'),
340 'type' => Controls_Manager::DIMENSIONS,
341 'size_units' => ['px'],
342 'default' => [
343 'unit' => 'px',
344 'top' => 50,
345 'right' => 50,
346 'bottom' => 50,
347 'left' => 50,
348 'isLinked' => true
349 ],
350 'selectors' => [
351 '{{WRAPPER}} :is( .ekit-btt__button, #canvas )' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
352 ],
353 'condition' => [
354 'ekit_button_appearance!' => 'progress_indicator'
355 ]
356 ]
357 );
358
359 $this->add_control(
360 'ekit_button_prgoress_foreground',
361 [
362 'label' => esc_html__('Line Foreground color', 'elementskit-lite'),
363 'type' => Controls_Manager::COLOR,
364 'alpha' => false,
365 'default' => '#FF5050',
366 'condition' => [
367 'ekit_button_appearance' => 'progress_indicator'
368 ]
369 ]
370 );
371
372 $this->add_control(
373 'ekit_button_prgoress_background',
374 [
375 'label' => esc_html__('Line Background Color', 'elementskit-lite'),
376 'type' => Controls_Manager::COLOR,
377 'alpha' => false,
378 'default' => '#eee',
379 'condition' => [
380 'ekit_button_appearance' => 'progress_indicator'
381 ]
382 ]
383 );
384
385 $this->start_controls_tabs('ekit_button_tabs');
386
387 $this->start_controls_tab(
388 'ekit_button_normal',
389 [
390 'label' => esc_html__('Normal', 'elementskit-lite'),
391 ]
392 );
393
394 $this->add_control(
395 'ekit_button_normal_color',
396 [
397 'label' => esc_html__('Color', 'elementskit-lite'),
398 'type' => Controls_Manager::COLOR,
399 'alpha' => false,
400 'selectors' => [
401 '{{WRAPPER}} .ekit-btt__button' => 'color: {{VALUE}}; fill: {{VALUE}}; border-color: {{VALUE}}'
402 ],
403 ]
404 );
405
406 $this->add_control(
407 'ekit_button_normal_bg_color',
408 [
409 'label' => esc_html__('Background', 'elementskit-lite'),
410 'type' => Controls_Manager::COLOR,
411 'selectors' => [
412 '{{WRAPPER}} .ekit-btt__button' => 'background: {{VALUE}};'
413 ],
414 ]
415 );
416
417 $this->end_controls_tab();
418
419 $this->start_controls_tab(
420 'ekit_button_hover',
421 [
422 'label' => esc_html__('Hover', 'elementskit-lite'),
423 ]
424 );
425
426 $this->add_control(
427 'ekit_button_hover_clr',
428 [
429 'label' => esc_html__('Color', 'elementskit-lite'),
430 'type' => Controls_Manager::COLOR,
431 'alpha' => false,
432 'selectors' => [
433 '{{WRAPPER}} .ekit-btt__button:hover' => 'color: {{VALUE}}; fill: {{VALUE}}; border-color: {{VALUE}}',
434 '{{WRAPPER}} .ekit-btt__button:focus' => 'color: {{VALUE}}; fill: {{VALUE}}; border-color: {{VALUE}}'
435 ],
436 ]
437 );
438
439 $this->add_control(
440 'ekit_button_hover_bg_clr',
441 [
442 'label' => esc_html__('Background', 'elementskit-lite'),
443 'type' => Controls_Manager::COLOR,
444 'selectors' => [
445 '{{WRAPPER}} .ekit-btt__button:hover' => 'background: {{VALUE}}',
446 '{{WRAPPER}} .ekit-btt__button:focus' => 'background: {{VALUE}}'
447 ],
448 ]
449 );
450
451
452 $this->end_controls_tab();
453 $this->end_controls_tabs();
454
455 $this->end_controls_section(); // end of back to style tab
456 }
457
458 protected function render( ) {
459 echo '<div class="ekit-wid-con" >';
460 $this->render_raw();
461 echo '</div>';
462 }
463
464 protected function render_raw() {
465 $settings = $this->get_settings_for_display();
466 $appearance = $settings['ekit_button_appearance'];
467 $is_scroll = $settings['ekit_show_button_after_switch'] === 'yes' ? 'yes' : '';
468
469 $args = [
470 'offset_top' => $settings['ekit_offset_top'],
471 'show_after' => $settings['ekit_show_button_after'],
472 'show_scroll' => $is_scroll,
473 'style' => $appearance,
474 'foreground' => $settings['ekit_button_prgoress_foreground'],
475 'background' => $settings['ekit_button_prgoress_background']
476 ];
477 ?>
478 <div class="ekit-back-to-top-container ekit-btt <?php echo esc_attr( $appearance ) ?>" data-settings="<?php echo esc_attr( wp_json_encode($args) ) ?>">
479 <button type="button" class="ekit-btt__button <?php echo esc_attr( $is_scroll ) ?>"<?php if ( 'text_only' !== $appearance ) : ?> aria-label="<?php echo esc_attr__( 'Back to top', 'elementskit-lite' ); ?>"<?php endif; ?>>
480 <?php // start container
481 switch( $appearance ) {
482 // show icon style by default
483 case 'icon_only':
484 Icons_Manager::render_icon($settings['ekit_btn_icons'], [ 'aria-hidden' => 'true' ]);
485 break;
486
487 // show text only style
488 case 'text_only':
489 echo esc_html($settings['ekit_btn_text']);
490 break;
491
492 // show progress indicator style (pro feature)
493 case 'progress_indicator': ?>
494 <div class="progress_indicator" >
495 <canvas id="canvas-<?php echo esc_attr( $this->get_id()); ?>" class="canvas" data-canvas="<?php echo esc_attr( $this->get_id()); ?>"></canvas>
496 <span><?php Icons_Manager::render_icon($settings['ekit_btn_icons'], [ 'aria-hidden' => 'true' ]); ?></span>
497 </div>
498 <?php break;
499 } ?>
500 </button>
501 </div>
502 <?php // end container
503 }
504 }
505