| 1 |
<?php |
| 2 |
namespace Easyel\EasyElements\Widgets; |
| 3 |
use Elementor\Controls_Manager; |
| 4 |
use Elementor\Widget_Base; |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; |
| 8 |
} |
| 9 |
|
| 10 |
class Easyel_Scroll_To_Top_Widget extends \Elementor\Widget_Base { |
| 11 |
|
| 12 |
|
| 13 |
public function get_name() { |
| 14 |
return 'eel-scroll-to-top'; |
| 15 |
} |
| 16 |
|
| 17 |
public function get_title() { |
| 18 |
return __( 'Scroll Top', 'easy-elements' ); |
| 19 |
} |
| 20 |
|
| 21 |
public function get_icon() { |
| 22 |
return 'easyicon easyelIcon-scroll-top'; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_categories() { |
| 26 |
return [ 'easyelements_category' ]; |
| 27 |
} |
| 28 |
|
| 29 |
public function get_keywords() { |
| 30 |
return [ 'scroll', 'top', 'back', 'to', 'text' ]; |
| 31 |
} |
| 32 |
|
| 33 |
public function get_style_depends() { |
| 34 |
return [ |
| 35 |
'eel-scroll-to-top', |
| 36 |
]; |
| 37 |
} |
| 38 |
|
| 39 |
public function get_script_depends() { |
| 40 |
return [ |
| 41 |
'eel-scroll-to-top', |
| 42 |
]; |
| 43 |
} |
| 44 |
|
| 45 |
protected function register_controls() { |
| 46 |
// Example: Style section for button |
| 47 |
$this->start_controls_section( |
| 48 |
'section_scroll_setting', |
| 49 |
[ |
| 50 |
'label' => __( 'Scroll Button', 'easy-elements' ), |
| 51 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 52 |
] |
| 53 |
); |
| 54 |
|
| 55 |
$this->add_control( |
| 56 |
'scroll_btn_icon', |
| 57 |
[ |
| 58 |
'label' => __( 'Icon', 'easy-elements' ), |
| 59 |
'type' => Controls_Manager::ICONS, |
| 60 |
] |
| 61 |
); |
| 62 |
$this->end_controls_section(); |
| 63 |
|
| 64 |
$this->start_controls_section( |
| 65 |
'section_scroll_style', |
| 66 |
[ |
| 67 |
'label' => __( 'Scroll Button', 'easy-elements' ), |
| 68 |
'tab' => Controls_Manager::TAB_STYLE, |
| 69 |
] |
| 70 |
); |
| 71 |
|
| 72 |
$this->add_control( |
| 73 |
'scroll_btn_color', |
| 74 |
[ |
| 75 |
'label' => __( 'Color', 'easy-elements' ), |
| 76 |
'type' => Controls_Manager::COLOR, |
| 77 |
'selectors' => [ |
| 78 |
'{{WRAPPER}} #easyel-top-to-bottom i' => 'color: {{VALUE}};', |
| 79 |
'{{WRAPPER}} #easyel-top-to-bottom svg, {{WRAPPER}} #easyel-top-to-bottom svg path' => 'fill: {{VALUE}};', |
| 80 |
], |
| 81 |
] |
| 82 |
); |
| 83 |
|
| 84 |
$this->add_control( |
| 85 |
'scroll_btn_bg', |
| 86 |
[ |
| 87 |
'label' => __( 'Background Color', 'easy-elements' ), |
| 88 |
'type' => Controls_Manager::COLOR, |
| 89 |
'selectors' => [ |
| 90 |
'{{WRAPPER}} #easyel-top-to-bottom' => 'background-color: {{VALUE}};', |
| 91 |
], |
| 92 |
] |
| 93 |
); |
| 94 |
|
| 95 |
$this->end_controls_section(); |
| 96 |
} |
| 97 |
|
| 98 |
protected function render() { |
| 99 |
$settings = $this->get_settings_for_display(); |
| 100 |
?> |
| 101 |
<div id="easyel-top-to-bottom"> |
| 102 |
<?php |
| 103 |
if ( ! empty( $settings['scroll_btn_icon']['value'] ) ) { |
| 104 |
\Elementor\Icons_Manager::render_icon( |
| 105 |
$settings['scroll_btn_icon'], |
| 106 |
[ 'aria-hidden' => 'true' ] |
| 107 |
); |
| 108 |
} else { |
| 109 |
?> |
| 110 |
<i class="unicon-arrow-up"></i> |
| 111 |
<?php |
| 112 |
} |
| 113 |
?> |
| 114 |
</div> |
| 115 |
<?php |
| 116 |
} |
| 117 |
} |