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
easy-elements / widgets / scroll-to-top / scroll.php

scroll.php in Easy Elements for Elementor – Addons & Website Templates 1.2.1, at widgets/scroll-to-top/scroll.php

135 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 use Elementor\Controls_Manager;
3 use Elementor\Widget_Base;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 class Easyel_Scroll_To_Top_Widget extends \Elementor\Widget_Base {
10
11 public function get_style_depends() {
12 $handle = 'eel-scroll-style';
13 $css_path = plugin_dir_path( __FILE__ ) . 'css/scroll.css';
14
15 if ( ! wp_style_is( $handle, 'registered' ) && file_exists( $css_path ) ) {
16 wp_register_style(
17 $handle,
18 plugins_url( 'css/scroll.css', __FILE__ ),
19 [],
20 defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $css_path ) : EASYELEMENTS_VER
21 );
22 }
23 return [ $handle ];
24 }
25
26 public function get_script_depends() {
27 $handle = 'eel-scroll-script';
28 $js_path = plugin_dir_path( __FILE__ ) . 'js/scroll.js';
29
30 if ( ! wp_script_is( $handle, 'registered' ) && file_exists( $js_path ) ) {
31 wp_register_script(
32 $handle,
33 plugins_url( 'js/scroll.js', __FILE__ ),
34 [ 'jquery' ],
35 defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $js_path ) : EASYELEMENTS_VER,
36 true
37 );
38 }
39 return [ $handle ];
40 }
41
42 public function get_name() {
43 return 'eel-scroll-to-top';
44 }
45
46 public function get_title() {
47 return __( 'Scroll Top', 'easy-elements' );
48 }
49
50 public function get_icon() {
51 return 'easyicon easyelIcon-scroll-top';
52 }
53
54 public function get_categories() {
55 return [ 'easyelements_category' ];
56 }
57
58 public function get_keywords() {
59 return [ 'scroll', 'top', 'back', 'to', 'text' ];
60 }
61
62 protected function register_controls() {
63 // Example: Style section for button
64 $this->start_controls_section(
65 'section_scroll_setting',
66 [
67 'label' => __( 'Scroll Button', 'easy-elements' ),
68 'tab' => Controls_Manager::TAB_CONTENT,
69 ]
70 );
71
72 $this->add_control(
73 'scroll_btn_icon',
74 [
75 'label' => __( 'Icon', 'easy-elements' ),
76 'type' => Controls_Manager::ICONS,
77 ]
78 );
79 $this->end_controls_section();
80
81 $this->start_controls_section(
82 'section_scroll_style',
83 [
84 'label' => __( 'Scroll Button', 'easy-elements' ),
85 'tab' => Controls_Manager::TAB_STYLE,
86 ]
87 );
88
89 $this->add_control(
90 'scroll_btn_color',
91 [
92 'label' => __( 'Color', 'easy-elements' ),
93 'type' => Controls_Manager::COLOR,
94 'selectors' => [
95 '{{WRAPPER}} #easyel-top-to-bottom i' => 'color: {{VALUE}};',
96 '{{WRAPPER}} #easyel-top-to-bottom svg, {{WRAPPER}} #easyel-top-to-bottom svg path' => 'fill: {{VALUE}};',
97 ],
98 ]
99 );
100
101 $this->add_control(
102 'scroll_btn_bg',
103 [
104 'label' => __( 'Background Color', 'easy-elements' ),
105 'type' => Controls_Manager::COLOR,
106 'selectors' => [
107 '{{WRAPPER}} #easyel-top-to-bottom' => 'background-color: {{VALUE}};',
108 ],
109 ]
110 );
111
112 $this->end_controls_section();
113 }
114
115 protected function render() {
116 $settings = $this->get_settings_for_display();
117 ?>
118 <div id="easyel-top-to-bottom">
119 <?php
120 if ( ! empty( $settings['scroll_btn_icon']['value'] ) ) {
121 \Elementor\Icons_Manager::render_icon(
122 $settings['scroll_btn_icon'],
123 [ 'aria-hidden' => 'true' ]
124 );
125 } else {
126 ?>
127 <i class="unicon-arrow-up"></i>
128 <?php
129 }
130 ?>
131 </div>
132 <?php
133 }
134 }
135 ?>