templates
1 year ago
Accordion.php
1 year ago
Alerts_Box.php
1 year ago
Animated_Heading.php
1 year ago
Before_after.php
1 year ago
Blog_Grid.php
1 year ago
Buttons.php
1 year ago
Cheat_sheet.php
1 year ago
Counter.php
1 year ago
Fullscreen_Slider.php
1 year ago
Icon_box.php
1 year ago
Instagram.php
1 year ago
Integrations.php
1 year ago
List_Item.php
1 year ago
Pricing_Table_Switcher.php
1 year ago
Pricing_Table_Tabs.php
1 year ago
Tabs.php
1 year ago
Team_Carousel.php
1 year ago
Testimonial.php
1 year ago
Timeline.php
1 year ago
Video_Playlist.php
1 year ago
Video_Popup.php
1 year ago
Before_after.php
238 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 esc_html__( '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' => esc_html__( 'Images', 'spider-elements' ), |
| 91 | ] |
| 92 | ); |
| 93 | |
| 94 | $this->add_control( |
| 95 | 'before_image', |
| 96 | [ |
| 97 | 'label' => esc_html__( 'Before Image', 'spider-elements' ), |
| 98 | 'type' => Controls_Manager::MEDIA, |
| 99 | ] |
| 100 | ); |
| 101 | |
| 102 | $this->add_control( |
| 103 | 'after_image', |
| 104 | [ |
| 105 | 'label' => esc_html__( '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' => esc_html__( 'Buttons', 'spider-elements' ), |
| 149 | 'tab' => Controls_Manager::TAB_STYLE, |
| 150 | ] |
| 151 | ); |
| 152 | |
| 153 | $this->add_group_control( |
| 154 | Group_Control_Typography::get_type(), [ |
| 155 | 'name' => 'before_after_text_typography', |
| 156 | 'selector' => '{{WRAPPER}} .indicator', |
| 157 | ] |
| 158 | ); |
| 159 | |
| 160 | $this->add_control( |
| 161 | 'beforeAfter_text_color', |
| 162 | [ |
| 163 | 'label' => esc_html__( 'Text Color', 'spider-elements' ), |
| 164 | 'type' => Controls_Manager::COLOR, |
| 165 | 'selectors' => [ |
| 166 | '{{WRAPPER}} .indicator' => 'color: {{VALUE}};', |
| 167 | ], |
| 168 | ] |
| 169 | ); |
| 170 | |
| 171 | $this->add_group_control( |
| 172 | \Elementor\Group_Control_Background::get_type(), |
| 173 | [ |
| 174 | 'name' => 'background', |
| 175 | 'types' => [ 'classic', 'gradient'], |
| 176 | 'exclude' => [ |
| 177 | 'image' |
| 178 | ], |
| 179 | 'selector' => '{{WRAPPER}} .before-after-banner .indicator', |
| 180 | ] |
| 181 | ); |
| 182 | |
| 183 | $this->add_control( |
| 184 | 'button_padding', |
| 185 | [ |
| 186 | 'label' => esc_html__( 'Padding', 'spider-elements' ), |
| 187 | 'type' => Controls_Manager::DIMENSIONS, |
| 188 | 'size_units' => [ 'px', 'em', '%' ], |
| 189 | 'selectors' => [ |
| 190 | '{{WRAPPER}} .indicator' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 191 | ], |
| 192 | ] |
| 193 | ); |
| 194 | |
| 195 | $this->end_controls_section(); // end beforeAfter Text style |
| 196 | |
| 197 | } |
| 198 | |
| 199 | |
| 200 | /** |
| 201 | * Name: elementor_render() |
| 202 | * Desc: Render the widget output on the frontend. |
| 203 | * Params: no params |
| 204 | * Return: @void |
| 205 | * Since: @1.0.0 |
| 206 | * Package: @spider-elements |
| 207 | * Author: spider-themes |
| 208 | */ |
| 209 | protected function render() { |
| 210 | $settings = $this->get_settings_for_display(); |
| 211 | ?> |
| 212 | <section class="before-after-banner"> |
| 213 | <div class="beforeAfter"> |
| 214 | <?php |
| 215 | if ( ! empty( $settings['before_image']['id'] ) ) { |
| 216 | ?> |
| 217 | <div> |
| 218 | <?php spel_dynamic_image( $settings['before_image']) ?> |
| 219 | <div class="indicator before"><?php echo esc_html( $settings['before_text'] ); ?></div> |
| 220 | </div> |
| 221 | <?php |
| 222 | } |
| 223 | if ( ! empty( $settings['after_image']['id'] ) ) { |
| 224 | ?> |
| 225 | <div> |
| 226 | <?php spel_dynamic_image( $settings['after_image'] ) ?> |
| 227 | <div class="indicator after"><?php echo esc_html( $settings['after_text'] ); ?></div> |
| 228 | </div> |
| 229 | <?php |
| 230 | } |
| 231 | ?> |
| 232 | </div> |
| 233 | </section> |
| 234 | <?php |
| 235 | } |
| 236 | |
| 237 | } |
| 238 |