templates
2 years ago
Accordion.php
2 years ago
Alerts_Box.php
2 years ago
Animated_Heading.php
2 years ago
Before_after.php
2 years ago
Blog_Grid.php
2 years ago
Buttons.php
2 years ago
Cheat_sheet.php
2 years ago
Counter.php
2 years ago
Fullscreen_Slider.php
2 years ago
Icon_box.php
2 years ago
Instagram.php
2 years ago
Integrations.php
2 years ago
List_Item.php
2 years ago
Marquee_Slides.php
2 years ago
Pricing_Table_Switcher.php
2 years ago
Pricing_Table_Tabs.php
2 years ago
Skill_Showcase.php
2 years ago
Tabs.php
2 years ago
Team_Carousel.php
2 years ago
Testimonial.php
2 years ago
Timeline.php
2 years ago
Video_Playlist.php
2 years ago
Video_Popup.php
2 years ago
Before_after.php
225 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Use namespace to avoid conflict |
| 4 | */ |
| 5 | |
| 6 | namespace SPEL\Widgets; |
| 7 | |
| 8 | use Elementor\Widget_Base; |
| 9 | use Elementor\Controls_Manager; |
| 10 | use Elementor\Group_Control_Typography; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; // Exit if accessed directly. |
| 14 | } |
| 15 | |
| 16 | |
| 17 | /** |
| 18 | * Class Before_after |
| 19 | * @package spider\Widgets |
| 20 | */ |
| 21 | class Before_After extends Widget_Base { |
| 22 | |
| 23 | public function get_name() { |
| 24 | return 'spe_after_before_widget'; // ID of the widget (Don't change this name) |
| 25 | } |
| 26 | |
| 27 | public function get_title() { |
| 28 | return __( 'Before After', 'spider-elements' ); |
| 29 | } |
| 30 | |
| 31 | public function get_icon() { |
| 32 | return 'eicon-thumbnails-half spel-icon'; |
| 33 | } |
| 34 | |
| 35 | public function get_keywords() { |
| 36 | return [ 'after', 'before' ]; |
| 37 | } |
| 38 | |
| 39 | public function get_categories() { |
| 40 | return [ 'spider-elements' ]; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Name: get_style_depends() |
| 45 | * Desc: Register the required CSS dependencies for the frontend. |
| 46 | */ |
| 47 | public function get_style_depends() { |
| 48 | return [ 'elegant-icon', 'spel-main' ]; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Name: get_script_depends() |
| 53 | * Desc: Register the required JS dependencies for the frontend. |
| 54 | */ |
| 55 | public function get_script_depends() { |
| 56 | return [ 'beforeafter', 'spel-el-widgets' ]; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | /** |
| 61 | * Name: register_controls() |
| 62 | * Desc: Register controls for these widgets |
| 63 | * Params: no params |
| 64 | * Return: @void |
| 65 | * Since: @1.0.0 |
| 66 | * Package: @spider-elements |
| 67 | * Author: spider-themes |
| 68 | */ |
| 69 | protected function register_controls() { |
| 70 | $this->elementor_content_control(); |
| 71 | $this->elementor_style_control(); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | /** |
| 76 | * Name: elementor_content_control() |
| 77 | * Desc: Register the Content Tab output on the Elementor editor. |
| 78 | * Params: no params |
| 79 | * Return: @void |
| 80 | * Since: @1.0.0 |
| 81 | * Package: @spider-elements |
| 82 | * Author: spider-themes |
| 83 | */ |
| 84 | protected function elementor_content_control() { |
| 85 | |
| 86 | //================= Before-After Images=====================// |
| 87 | $this->start_controls_section( |
| 88 | 'before_after_images', |
| 89 | [ |
| 90 | 'label' => __( 'Images', 'spider-elements' ), |
| 91 | ] |
| 92 | ); |
| 93 | |
| 94 | $this->add_control( |
| 95 | 'before_image', |
| 96 | [ |
| 97 | 'label' => __( 'Before Image', 'spider-elements' ), |
| 98 | 'type' => Controls_Manager::MEDIA, |
| 99 | ] |
| 100 | ); |
| 101 | |
| 102 | $this->add_control( |
| 103 | 'after_image', |
| 104 | [ |
| 105 | 'label' => __( 'After Image', 'spider-elements' ), |
| 106 | 'type' => Controls_Manager::MEDIA, |
| 107 | ] |
| 108 | ); |
| 109 | |
| 110 | $this->add_control( |
| 111 | 'before_text', |
| 112 | [ |
| 113 | 'label' => esc_html__( 'Before Button Text', 'spider-elements' ), |
| 114 | 'type' => Controls_Manager::TEXT, |
| 115 | 'default' => esc_html__( 'Before', 'spider-elements' ), |
| 116 | ] |
| 117 | ); |
| 118 | |
| 119 | $this->add_control( |
| 120 | 'after_text', |
| 121 | [ |
| 122 | 'label' => esc_html__( 'After Button Text', 'spider-elements' ), |
| 123 | 'type' => Controls_Manager::TEXT, |
| 124 | 'default' => esc_html__( 'After', 'spider-elements' ), |
| 125 | ] |
| 126 | ); |
| 127 | |
| 128 | $this->end_controls_section(); |
| 129 | |
| 130 | } //End Before-After Images |
| 131 | |
| 132 | |
| 133 | /** |
| 134 | * Name: elementor_style_control() |
| 135 | * Desc: Register the Style Tab output on the Elementor editor. |
| 136 | * Params: no params |
| 137 | * Return: @void |
| 138 | * Since: @1.0.0 |
| 139 | * Package: @spider-elements |
| 140 | * Author: spider-themes |
| 141 | */ |
| 142 | public function elementor_style_control() { |
| 143 | |
| 144 | //===================== beforeAfter Text style ==========================// |
| 145 | $this->start_controls_section( |
| 146 | 'sec_before_after_style', |
| 147 | [ |
| 148 | 'label' => __( 'Button Style', 'spider-elements' ), |
| 149 | 'tab' => Controls_Manager::TAB_STYLE, |
| 150 | ] |
| 151 | ); |
| 152 | |
| 153 | $this->add_control( |
| 154 | 'beforeAfter_text_color', |
| 155 | [ |
| 156 | 'label' => esc_html__( 'Text Color', 'spider-elements' ), |
| 157 | 'type' => Controls_Manager::COLOR, |
| 158 | 'selectors' => [ |
| 159 | '{{WRAPPER}} .before-after-banner .indicator' => 'color: {{VALUE}};', |
| 160 | ], |
| 161 | ] |
| 162 | ); |
| 163 | |
| 164 | $this->add_group_control( |
| 165 | Group_Control_Typography::get_type(), [ |
| 166 | 'name' => 'before_after_text_typography', |
| 167 | 'selector' => '{{WRAPPER}} .before-after-banner .indicator', |
| 168 | ] |
| 169 | ); |
| 170 | |
| 171 | $this->add_control( |
| 172 | 'beforeAfter_text_bg_color', |
| 173 | [ |
| 174 | 'label' => esc_html__( 'Button Background Color', 'spider-elements' ), |
| 175 | 'type' => Controls_Manager::COLOR, |
| 176 | 'selectors' => [ |
| 177 | '{{WRAPPER}} .before-after-banner .indicator' => 'background-color: {{VALUE}};', |
| 178 | ], |
| 179 | ] |
| 180 | ); |
| 181 | |
| 182 | $this->end_controls_section(); // end beforeAfter Text style |
| 183 | |
| 184 | } |
| 185 | |
| 186 | |
| 187 | /** |
| 188 | * Name: elementor_render() |
| 189 | * Desc: Render the widget output on the frontend. |
| 190 | * Params: no params |
| 191 | * Return: @void |
| 192 | * Since: @1.0.0 |
| 193 | * Package: @spider-elements |
| 194 | * Author: spider-themes |
| 195 | */ |
| 196 | protected function render() { |
| 197 | $settings = $this->get_settings_for_display(); |
| 198 | ?> |
| 199 | <section class="before-after-banner"> |
| 200 | <div class="beforeAfter"> |
| 201 | <?php |
| 202 | if ( ! empty( $settings['before_image']['id'] ) ) { |
| 203 | ?> |
| 204 | <div> |
| 205 | <?php spel_dynamic_image( $settings['before_image']) ?> |
| 206 | <div class="indicator before"><?php echo esc_html( $settings['before_text'] ); ?></div> |
| 207 | </div> |
| 208 | <?php |
| 209 | } |
| 210 | if ( ! empty( $settings['after_image']['id'] ) ) { |
| 211 | ?> |
| 212 | <div> |
| 213 | <?php spel_dynamic_image( $settings['after_image'] ) ?> |
| 214 | <div class="indicator after"><?php echo esc_html( $settings['after_text'] ); ?></div> |
| 215 | </div> |
| 216 | <?php |
| 217 | } |
| 218 | ?> |
| 219 | </div> |
| 220 | </section> |
| 221 | <?php |
| 222 | } |
| 223 | |
| 224 | } |
| 225 |