| 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_Button_Widget extends \Elementor\Widget_Base { |
| 11 |
public function get_name() { |
| 12 |
return 'eel-button'; |
| 13 |
} |
| 14 |
|
| 15 |
public function get_title() { |
| 16 |
return __( 'Button', 'easy-elements' ); |
| 17 |
} |
| 18 |
|
| 19 |
public function get_icon() { |
| 20 |
return 'easyicon easyelIcon-button'; |
| 21 |
} |
| 22 |
|
| 23 |
public function get_categories() { |
| 24 |
return [ 'easyelements_category' ]; |
| 25 |
} |
| 26 |
|
| 27 |
public function get_keywords() { |
| 28 |
return [ 'button', 'link', 'click', 'text' ]; |
| 29 |
} |
| 30 |
|
| 31 |
public function get_style_depends() { |
| 32 |
return [ |
| 33 |
'eel-button', |
| 34 |
]; |
| 35 |
} |
| 36 |
|
| 37 |
protected function register_controls() { |
| 38 |
|
| 39 |
$this->start_controls_section( |
| 40 |
'content_section', |
| 41 |
[ |
| 42 |
'label' => esc_html__('Button Settings', 'easy-elements'), |
| 43 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 44 |
] |
| 45 |
); |
| 46 |
|
| 47 |
$this->add_control( |
| 48 |
'button_text', |
| 49 |
[ |
| 50 |
'label' => esc_html__('Button Text', 'easy-elements'), |
| 51 |
'type' => Controls_Manager::TEXTAREA, |
| 52 |
'label_block' => true, |
| 53 |
'default' => esc_html__('Click Here', 'easy-elements'), |
| 54 |
'placeholder' => esc_html__('Enter button text', 'easy-elements'), |
| 55 |
'dynamic' => [ |
| 56 |
'active' => true, |
| 57 |
], |
| 58 |
] |
| 59 |
); |
| 60 |
|
| 61 |
$this->add_control( |
| 62 |
'button_url', |
| 63 |
[ |
| 64 |
'label' => esc_html__('Button URL', 'easy-elements'), |
| 65 |
'type' => Controls_Manager::URL, |
| 66 |
'default' => [ |
| 67 |
'url' => '#', |
| 68 |
'is_external' => false, |
| 69 |
'nofollow' => false, |
| 70 |
], |
| 71 |
'dynamic' => [ |
| 72 |
'active' => true, |
| 73 |
], |
| 74 |
] |
| 75 |
); |
| 76 |
|
| 77 |
$this->add_control( |
| 78 |
'button_type', |
| 79 |
[ |
| 80 |
'label' => esc_html__('Button Type', 'easy-elements'), |
| 81 |
'type' => Controls_Manager::SELECT, |
| 82 |
'default' => 'primary', |
| 83 |
'options' => [ |
| 84 |
'primary' => esc_html__('Primary', 'easy-elements'), |
| 85 |
'outline' => esc_html__('Outline', 'easy-elements'), |
| 86 |
'icon_btn' => esc_html__('Icon', 'easy-elements'), |
| 87 |
], |
| 88 |
] |
| 89 |
); |
| 90 |
|
| 91 |
$this->add_control( |
| 92 |
'button_icon', |
| 93 |
[ |
| 94 |
'label' => esc_html__('Icon', 'easy-elements'), |
| 95 |
'type' => Controls_Manager::ICONS, |
| 96 |
'default' => [ |
| 97 |
'value' => '', |
| 98 |
'library' => '', |
| 99 |
], |
| 100 |
] |
| 101 |
); |
| 102 |
|
| 103 |
$this->add_control( |
| 104 |
'icon_position', |
| 105 |
[ |
| 106 |
'label' => esc_html__('Icon Position', 'easy-elements'), |
| 107 |
'type' => Controls_Manager::SELECT, |
| 108 |
'default' => 'after', |
| 109 |
'options' => [ |
| 110 |
'before' => esc_html__('Before Text', 'easy-elements'), |
| 111 |
'after' => esc_html__('After Text', 'easy-elements'), |
| 112 |
], |
| 113 |
'condition' => [ |
| 114 |
'button_icon[value]!' => '', |
| 115 |
], |
| 116 |
] |
| 117 |
); |
| 118 |
$this->add_responsive_control( |
| 119 |
'icon_spacing', |
| 120 |
[ |
| 121 |
'label' => esc_html__('Icon Spacing', 'easy-elements'), |
| 122 |
'type' => Controls_Manager::SLIDER, |
| 123 |
'size_units' => ['px'], |
| 124 |
'range' => [ |
| 125 |
'px' => [ |
| 126 |
'min' => 0, |
| 127 |
'max' => 50, |
| 128 |
], |
| 129 |
'em' => [ |
| 130 |
'min' => 0, |
| 131 |
'max' => 5, |
| 132 |
], |
| 133 |
], |
| 134 |
'default' => [ |
| 135 |
'unit' => 'px', |
| 136 |
'size' => 8, |
| 137 |
], |
| 138 |
'selectors' => [ |
| 139 |
'{{WRAPPER}} .eel-button .eel-button-icon-before' => 'margin-right: {{SIZE}}{{UNIT}};', |
| 140 |
'{{WRAPPER}} .eel-button .eel-button-icon-after' => 'margin-left: {{SIZE}}{{UNIT}}; margin-right: 0;', |
| 141 |
'{{WRAPPER}} .eel-button i.eel-button-icon-before' => 'margin-right: {{SIZE}}{{UNIT}};', |
| 142 |
'{{WRAPPER}} .eel-button i.eel-button-icon-after' => 'margin-left: {{SIZE}}{{UNIT}}; margin-right: 0;', |
| 143 |
'{{WRAPPER}} .eel-button svg.eel-button-icon-before' => 'margin-right: {{SIZE}}{{UNIT}};', |
| 144 |
'{{WRAPPER}} .eel-button svg.eel-button-icon-after' => 'margin-left: {{SIZE}}{{UNIT}}; margin-right: 0;', |
| 145 |
], |
| 146 |
] |
| 147 |
); |
| 148 |
|
| 149 |
$this->add_responsive_control( |
| 150 |
'button_min_width', |
| 151 |
[ |
| 152 |
'label' => esc_html__('Minimum Width', 'easy-elements'), |
| 153 |
'type' => Controls_Manager::SLIDER, |
| 154 |
'size_units' => ['px'], |
| 155 |
'range' => [ |
| 156 |
'px' => [ |
| 157 |
'min' => 100, |
| 158 |
'max' => 1000, |
| 159 |
], |
| 160 |
], |
| 161 |
'default' => [ |
| 162 |
'unit' => 'px', |
| 163 |
'size' => 150, |
| 164 |
], |
| 165 |
'selectors' => [ |
| 166 |
'{{WRAPPER}} .eel-button' => 'min-width: {{SIZE}}{{UNIT}};', |
| 167 |
], |
| 168 |
] |
| 169 |
); |
| 170 |
|
| 171 |
$this->add_responsive_control( |
| 172 |
'button_alignment', |
| 173 |
[ |
| 174 |
'label' => esc_html__( 'Content Alignment', 'easy-elements' ), |
| 175 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 176 |
'options' => [ |
| 177 |
'flex-start' => [ |
| 178 |
'title' => esc_html__( 'Left', 'easy-elements' ), |
| 179 |
'icon' => 'eicon-text-align-left', |
| 180 |
], |
| 181 |
'center' => [ |
| 182 |
'title' => esc_html__( 'Center', 'easy-elements' ), |
| 183 |
'icon' => 'eicon-text-align-center', |
| 184 |
], |
| 185 |
'flex-end' => [ |
| 186 |
'title' => esc_html__( 'Right', 'easy-elements' ), |
| 187 |
'icon' => 'eicon-text-align-right', |
| 188 |
], |
| 189 |
], |
| 190 |
'toggle' => true, |
| 191 |
'selectors' => [ |
| 192 |
'{{WRAPPER}} .eel-button' => 'justify-content: {{VALUE}};', |
| 193 |
], |
| 194 |
] |
| 195 |
); |
| 196 |
|
| 197 |
$this->add_control( |
| 198 |
'show_gradient', |
| 199 |
[ |
| 200 |
'label' => esc_html__( 'Gradient Button', 'easy-elements' ), |
| 201 |
'type' => Controls_Manager::SWITCHER, |
| 202 |
'label_on' => esc_html__( 'Yes', 'easy-elements' ), |
| 203 |
'label_off' => esc_html__( 'No', 'easy-elements' ), |
| 204 |
'default' => '', |
| 205 |
] |
| 206 |
); |
| 207 |
|
| 208 |
// First color |
| 209 |
$this->add_control( |
| 210 |
'easy_gradient_color_1', |
| 211 |
[ |
| 212 |
'label' => esc_html__( 'Gradient 1', 'easy-elements' ), |
| 213 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 214 |
'default' => '#4750CC', |
| 215 |
'condition' => [ |
| 216 |
'show_gradient' => 'yes', |
| 217 |
], |
| 218 |
'selectors' => [ |
| 219 |
'{{WRAPPER}} .eel-button-gradient' => '--eel-gradient-1: {{VALUE}};', |
| 220 |
], |
| 221 |
] |
| 222 |
); |
| 223 |
|
| 224 |
// Second color |
| 225 |
$this->add_control( |
| 226 |
'easy_gradient_color_2', |
| 227 |
[ |
| 228 |
'label' => esc_html__( 'Gradient 2', 'easy-elements' ), |
| 229 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 230 |
'default' => '#EF5CE8', |
| 231 |
'condition' => [ |
| 232 |
'show_gradient' => 'yes', |
| 233 |
], |
| 234 |
'selectors' => [ |
| 235 |
'{{WRAPPER}} .eel-button-gradient' => '--eel-gradient-2: {{VALUE}};', |
| 236 |
], |
| 237 |
] |
| 238 |
); |
| 239 |
|
| 240 |
// Third color |
| 241 |
$this->add_control( |
| 242 |
'easy_gradient_color_3', |
| 243 |
[ |
| 244 |
'label' => esc_html__( 'Gradient 3', 'easy-elements' ), |
| 245 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 246 |
'default' => '#EFC7AE', |
| 247 |
'condition' => [ |
| 248 |
'show_gradient' => 'yes', |
| 249 |
], |
| 250 |
'selectors' => [ |
| 251 |
'{{WRAPPER}} .eel-button-gradient' => '--eel-gradient-3: {{VALUE}};', |
| 252 |
], |
| 253 |
] |
| 254 |
); |
| 255 |
|
| 256 |
$this->add_control( |
| 257 |
'border_gradient_button', |
| 258 |
[ |
| 259 |
'label' => esc_html__( 'Border Gradient Button', 'easy-elements' ), |
| 260 |
'type' => Controls_Manager::SWITCHER, |
| 261 |
'label_on' => esc_html__( 'Yes', 'easy-elements' ), |
| 262 |
'label_off' => esc_html__( 'No', 'easy-elements' ), |
| 263 |
'default' => '', |
| 264 |
] |
| 265 |
); |
| 266 |
|
| 267 |
$this->add_group_control( |
| 268 |
\Elementor\Group_Control_Background::get_type(), |
| 269 |
[ |
| 270 |
'name' => 'border_gradient_color', |
| 271 |
'fields_options' => [ |
| 272 |
'gradient_angle' => [ |
| 273 |
'default' => [ |
| 274 |
'unit' => 'deg', |
| 275 |
'size' => 180, |
| 276 |
], |
| 277 |
], |
| 278 |
], |
| 279 |
'selector' => '{{WRAPPER}} .eel-button-border-gradient::before', |
| 280 |
'condition' => [ |
| 281 |
'border_gradient_button' => 'yes', |
| 282 |
], |
| 283 |
] |
| 284 |
); |
| 285 |
|
| 286 |
|
| 287 |
$this->end_controls_section(); |
| 288 |
|
| 289 |
// Style Tab - Button |
| 290 |
$this->start_controls_section( |
| 291 |
'style_section', |
| 292 |
[ |
| 293 |
'label' => esc_html__('Button Style', 'easy-elements'), |
| 294 |
'tab' => Controls_Manager::TAB_STYLE, |
| 295 |
] |
| 296 |
); |
| 297 |
|
| 298 |
$this->add_group_control( |
| 299 |
\Elementor\Group_Control_Typography::get_type(), |
| 300 |
[ |
| 301 |
'name' => 'button_typography', |
| 302 |
'selector' => '{{WRAPPER}} .eel-button', |
| 303 |
] |
| 304 |
); |
| 305 |
|
| 306 |
$this->start_controls_tabs('button_styles'); |
| 307 |
|
| 308 |
$this->start_controls_tab( |
| 309 |
'button_normal', |
| 310 |
[ |
| 311 |
'label' => esc_html__('Normal', 'easy-elements'), |
| 312 |
] |
| 313 |
); |
| 314 |
|
| 315 |
$this->add_control( |
| 316 |
'button_text_color', |
| 317 |
[ |
| 318 |
'label' => esc_html__('Text Color', 'easy-elements'), |
| 319 |
'type' => Controls_Manager::COLOR, |
| 320 |
'default' => '', |
| 321 |
'selectors' => [ |
| 322 |
'{{WRAPPER}} .eel-button' => 'color: {{VALUE}};', |
| 323 |
], |
| 324 |
] |
| 325 |
); |
| 326 |
|
| 327 |
$this->add_control( |
| 328 |
'button_background_color', |
| 329 |
[ |
| 330 |
'label' => esc_html__('Background Color', 'easy-elements'), |
| 331 |
'type' => Controls_Manager::COLOR, |
| 332 |
'selectors' => [ |
| 333 |
'{{WRAPPER}} .eel-button' => 'background-color: {{VALUE}};', |
| 334 |
], |
| 335 |
] |
| 336 |
); |
| 337 |
|
| 338 |
$this->add_group_control( |
| 339 |
\Elementor\Group_Control_Background::get_type(), |
| 340 |
[ |
| 341 |
'name' => 'button_background_gradient', |
| 342 |
'label' => esc_html__('Background', 'easy-elements'), |
| 343 |
'types' => ['classic', 'gradient'], |
| 344 |
'selector' => '{{WRAPPER}} .eel-button', |
| 345 |
] |
| 346 |
); |
| 347 |
|
| 348 |
|
| 349 |
$this->add_group_control( |
| 350 |
\Elementor\Group_Control_Border::get_type(), |
| 351 |
[ |
| 352 |
'name' => 'button_border', |
| 353 |
'selector' => '{{WRAPPER}} .eel-button', |
| 354 |
] |
| 355 |
); |
| 356 |
|
| 357 |
$this->add_control( |
| 358 |
'button_border_radius', |
| 359 |
[ |
| 360 |
'label' => esc_html__('Border Radius', 'easy-elements'), |
| 361 |
'type' => Controls_Manager::DIMENSIONS, |
| 362 |
'size_units' => ['px'], |
| 363 |
'selectors' => [ |
| 364 |
'{{WRAPPER}} .eel-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 365 |
'{{WRAPPER}} .eel-button.eel-button-border-gradient::before' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 366 |
], |
| 367 |
] |
| 368 |
); |
| 369 |
|
| 370 |
$this->add_group_control( |
| 371 |
\Elementor\Group_Control_Box_Shadow::get_type(), |
| 372 |
[ |
| 373 |
'name' => 'button_box_shadow', |
| 374 |
'selector' => '{{WRAPPER}} .eel-button', |
| 375 |
] |
| 376 |
); |
| 377 |
|
| 378 |
$this->add_responsive_control( |
| 379 |
'button_padding', |
| 380 |
[ |
| 381 |
'label' => esc_html__('Padding', 'easy-elements'), |
| 382 |
'type' => Controls_Manager::DIMENSIONS, |
| 383 |
'size_units' => ['px'], |
| 384 |
'selectors' => [ |
| 385 |
'{{WRAPPER}} .eel-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 386 |
], |
| 387 |
] |
| 388 |
); |
| 389 |
|
| 390 |
$this->add_responsive_control( |
| 391 |
'button_margin', |
| 392 |
[ |
| 393 |
'label' => esc_html__('Margin', 'easy-elements'), |
| 394 |
'type' => Controls_Manager::DIMENSIONS, |
| 395 |
'size_units' => ['px'], |
| 396 |
'selectors' => [ |
| 397 |
'{{WRAPPER}} .eel-button' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 398 |
], |
| 399 |
] |
| 400 |
); |
| 401 |
|
| 402 |
$this->end_controls_tab(); |
| 403 |
|
| 404 |
$this->start_controls_tab( |
| 405 |
'button_hover', |
| 406 |
[ |
| 407 |
'label' => esc_html__('Hover', 'easy-elements'), |
| 408 |
] |
| 409 |
); |
| 410 |
|
| 411 |
$this->add_control( |
| 412 |
'button_hover_text_color', |
| 413 |
[ |
| 414 |
'label' => esc_html__('Text Color', 'easy-elements'), |
| 415 |
'type' => Controls_Manager::COLOR, |
| 416 |
'default' => '', |
| 417 |
'selectors' => [ |
| 418 |
'{{WRAPPER}} .eel-button:hover' => 'color: {{VALUE}};', |
| 419 |
], |
| 420 |
] |
| 421 |
); |
| 422 |
|
| 423 |
$this->add_control( |
| 424 |
'button_hover_background_color', |
| 425 |
[ |
| 426 |
'label' => esc_html__('Background Color', 'easy-elements'), |
| 427 |
'type' => Controls_Manager::COLOR, |
| 428 |
'default' => '', |
| 429 |
'selectors' => [ |
| 430 |
'{{WRAPPER}} .eel-button:hover' => 'background-color: {{VALUE}};', |
| 431 |
], |
| 432 |
] |
| 433 |
); |
| 434 |
|
| 435 |
$this->add_group_control( |
| 436 |
\Elementor\Group_Control_Background::get_type(), |
| 437 |
[ |
| 438 |
'name' => 'button_hover_background_gradient', |
| 439 |
'label' => esc_html__('Hover Background', 'easy-elements'), |
| 440 |
'types' => ['classic', 'gradient'], |
| 441 |
'selector' => '{{WRAPPER}} .eel-button:hover', |
| 442 |
] |
| 443 |
); |
| 444 |
|
| 445 |
|
| 446 |
$this->add_group_control( |
| 447 |
\Elementor\Group_Control_Border::get_type(), |
| 448 |
[ |
| 449 |
'name' => 'button_hover_border', |
| 450 |
'selector' => '{{WRAPPER}} .eel-button:hover', |
| 451 |
] |
| 452 |
); |
| 453 |
$this->end_controls_tab(); |
| 454 |
$this->end_controls_tabs(); |
| 455 |
|
| 456 |
$this->end_controls_section(); |
| 457 |
|
| 458 |
// Icon Style Section |
| 459 |
$this->start_controls_section( |
| 460 |
'icon_style_section', |
| 461 |
[ |
| 462 |
'label' => esc_html__('Icon Style', 'easy-elements'), |
| 463 |
'tab' => Controls_Manager::TAB_STYLE, |
| 464 |
'condition' => [ |
| 465 |
'button_icon[value]!' => '', |
| 466 |
], |
| 467 |
] |
| 468 |
); |
| 469 |
$this->start_controls_tabs('button_icon_styles'); |
| 470 |
$this->start_controls_tab( |
| 471 |
'button_icon_normal', |
| 472 |
[ |
| 473 |
'label' => esc_html__('Normal', 'easy-elements'), |
| 474 |
] |
| 475 |
); |
| 476 |
$this->add_control( |
| 477 |
'icon_color', |
| 478 |
[ |
| 479 |
'label' => esc_html__('Color', 'easy-elements'), |
| 480 |
'type' => Controls_Manager::COLOR, |
| 481 |
'default' => '', |
| 482 |
'selectors' => [ |
| 483 |
'{{WRAPPER}} .eel-button i' => 'color: {{VALUE}};', |
| 484 |
'{{WRAPPER}} .eel-button svg' => 'fill: {{VALUE}};', |
| 485 |
'{{WRAPPER}} .eel-button svg path' => 'stroke: {{VALUE}};', |
| 486 |
'{{WRAPPER}} .eel-button .elementor-icon' => 'color: {{VALUE}};', |
| 487 |
'{{WRAPPER}} .eel-button .elementor-icon svg' => 'fill: {{VALUE}};', |
| 488 |
'{{WRAPPER}} .eel-button .elementor-icon i' => 'color: {{VALUE}};', |
| 489 |
'{{WRAPPER}} .eel-button .eel-button-icon-before' => 'color: {{VALUE}};', |
| 490 |
'{{WRAPPER}} .eel-button .eel-button-icon-after' => 'color: {{VALUE}};', |
| 491 |
'{{WRAPPER}} .eel-button .eel-button-icon-before svg' => 'fill: {{VALUE}};', |
| 492 |
'{{WRAPPER}} .eel-button .eel-button-icon-after svg' => 'fill: {{VALUE}};', |
| 493 |
'{{WRAPPER}} .eel-button .eel-button-icon-before i' => 'color: {{VALUE}};', |
| 494 |
'{{WRAPPER}} .eel-button .eel-button-icon-after i' => 'color: {{VALUE}};', |
| 495 |
'{{WRAPPER}} .eel-button .elementor-icon-wrapper' => 'color: {{VALUE}};', |
| 496 |
'{{WRAPPER}} .eel-button .elementor-icon-wrapper svg' => 'fill: {{VALUE}};', |
| 497 |
], |
| 498 |
] |
| 499 |
); |
| 500 |
|
| 501 |
$this->add_control( |
| 502 |
'icon_bg', |
| 503 |
[ |
| 504 |
'label' => esc_html__('Background', 'easy-elements'), |
| 505 |
'type' => Controls_Manager::COLOR, |
| 506 |
'default' => '', |
| 507 |
'selectors' => [ |
| 508 |
'{{WRAPPER}} .eel-button .eel-button-icon-before, {{WRAPPER}} .eel-button .eel-button-icon-after' => 'background-color: {{VALUE}};', |
| 509 |
], |
| 510 |
] |
| 511 |
); |
| 512 |
|
| 513 |
$this->add_group_control( |
| 514 |
\Elementor\Group_Control_Background::get_type(), |
| 515 |
[ |
| 516 |
'name' => 'icon_background', |
| 517 |
'label' => esc_html__('Icon Background', 'easy-elements'), |
| 518 |
'types' => ['classic', 'gradient'], |
| 519 |
'selector' => '{{WRAPPER}} .eel-button .eel-button-icon-before, {{WRAPPER}} .eel-button .eel-button-icon-after', |
| 520 |
] |
| 521 |
); |
| 522 |
|
| 523 |
$this->add_responsive_control( |
| 524 |
'icon_size', |
| 525 |
[ |
| 526 |
'label' => esc_html__('Size', 'easy-elements'), |
| 527 |
'type' => Controls_Manager::SLIDER, |
| 528 |
'size_units' => ['px'], |
| 529 |
'range' => [ |
| 530 |
'px' => [ |
| 531 |
'min' => 6, |
| 532 |
'max' => 50, |
| 533 |
], |
| 534 |
'em' => [ |
| 535 |
'min' => 0.5, |
| 536 |
'max' => 5, |
| 537 |
], |
| 538 |
], |
| 539 |
'default' => [ |
| 540 |
'unit' => 'px', |
| 541 |
'size' => 16, |
| 542 |
], |
| 543 |
'selectors' => [ |
| 544 |
'{{WRAPPER}} .eel-button i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 545 |
'{{WRAPPER}} .eel-button svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 546 |
'{{WRAPPER}} .eel-button .elementor-icon' => 'font-size: {{SIZE}}{{UNIT}};', |
| 547 |
'{{WRAPPER}} .eel-button .eel-button-icon-before' => 'font-size: {{SIZE}}{{UNIT}};', |
| 548 |
'{{WRAPPER}} .eel-button .eel-button-icon-after' => 'font-size: {{SIZE}}{{UNIT}};', |
| 549 |
'{{WRAPPER}} .eel-button .eel-button-icon-before svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 550 |
'{{WRAPPER}} .eel-button .eel-button-icon-after svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 551 |
'{{WRAPPER}} .eel-button .eel-button-icon-before i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 552 |
'{{WRAPPER}} .eel-button .eel-button-icon-after i' => 'font-size: {{SIZE}}{{UNIT}};', |
| 553 |
'{{WRAPPER}} .eel-button img' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', |
| 554 |
], |
| 555 |
] |
| 556 |
); |
| 557 |
|
| 558 |
$this->add_responsive_control( |
| 559 |
'icon_box_width', |
| 560 |
[ |
| 561 |
'label' => esc_html__('Width', 'easy-elements'), |
| 562 |
'type' => Controls_Manager::SLIDER, |
| 563 |
'selectors' => [ |
| 564 |
'{{WRAPPER}} .eel-button .eel-button-icon-before, {{WRAPPER}} .eel-button .eel-button-icon-after' => 'width: {{SIZE}}{{UNIT}};', |
| 565 |
], |
| 566 |
] |
| 567 |
); |
| 568 |
$this->add_responsive_control( |
| 569 |
'icon_box_height', |
| 570 |
[ |
| 571 |
'label' => esc_html__('Height', 'easy-elements'), |
| 572 |
'type' => Controls_Manager::SLIDER, |
| 573 |
'selectors' => [ |
| 574 |
'{{WRAPPER}} .eel-button .eel-button-icon-before, {{WRAPPER}} .eel-button .eel-button-icon-after' => 'height: {{SIZE}}{{UNIT}};', |
| 575 |
], |
| 576 |
] |
| 577 |
); |
| 578 |
$this->add_responsive_control( |
| 579 |
'icon_box_border_radius', |
| 580 |
[ |
| 581 |
'label' => esc_html__('Border Radius', 'easy-elements'), |
| 582 |
'type' => Controls_Manager::DIMENSIONS, |
| 583 |
'size_units' => ['px','%'], |
| 584 |
'selectors' => [ |
| 585 |
'{{WRAPPER}} .eel-button .eel-button-icon-before, |
| 586 |
{{WRAPPER}} .eel-button .eel-button-icon-after' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 587 |
], |
| 588 |
] |
| 589 |
); |
| 590 |
$this->add_responsive_control( |
| 591 |
'icon_rotation', |
| 592 |
[ |
| 593 |
'label' => esc_html__('Default Icon Rotation', 'easy-elements'), |
| 594 |
'type' => Controls_Manager::SLIDER, |
| 595 |
'size_units' => ['deg'], |
| 596 |
'range' => [ |
| 597 |
'deg' => [ |
| 598 |
'min' => -360, |
| 599 |
'max' => 360, |
| 600 |
], |
| 601 |
], |
| 602 |
'default' => [ |
| 603 |
'unit' => 'deg', |
| 604 |
'size' => 0, |
| 605 |
], |
| 606 |
'selectors' => [ |
| 607 |
'{{WRAPPER}} .eel-button i' => 'transition: all 0.3s ease-in; transform: rotate({{SIZE}}{{UNIT}});', |
| 608 |
'{{WRAPPER}} .eel-button svg' => 'transition: all 0.3s ease-in; transform: rotate({{SIZE}}{{UNIT}});', |
| 609 |
], |
| 610 |
] |
| 611 |
); |
| 612 |
$this->end_controls_tab(); |
| 613 |
|
| 614 |
// Button Icon HOver Style |
| 615 |
$this->start_controls_tab( |
| 616 |
'button_icon_hover', |
| 617 |
[ |
| 618 |
'label' => esc_html__('Hover', 'easy-elements'), |
| 619 |
] |
| 620 |
); |
| 621 |
$this->add_control( |
| 622 |
'icon_hover_color', |
| 623 |
[ |
| 624 |
'label' => esc_html__('Color', 'easy-elements'), |
| 625 |
'type' => Controls_Manager::COLOR, |
| 626 |
'default' => '', |
| 627 |
'selectors' => [ |
| 628 |
'{{WRAPPER}} .eel-button:hover i' => 'color: {{VALUE}};', |
| 629 |
'{{WRAPPER}} .eel-button:hover svg' => 'fill: {{VALUE}};', |
| 630 |
'{{WRAPPER}} .eel-button:hover svg path' => 'stroke: {{VALUE}};', |
| 631 |
'{{WRAPPER}} .eel-button:hover .elementor-icon' => 'color: {{VALUE}};', |
| 632 |
'{{WRAPPER}} .eel-button:hover .elementor-icon svg' => 'fill: {{VALUE}};', |
| 633 |
'{{WRAPPER}} .eel-button:hover .elementor-icon i' => 'color: {{VALUE}};', |
| 634 |
'{{WRAPPER}} .eel-button:hover .eel-button-icon-before' => 'color: {{VALUE}};', |
| 635 |
'{{WRAPPER}} .eel-button:hover .eel-button-icon-after' => 'color: {{VALUE}};', |
| 636 |
'{{WRAPPER}} .eel-button:hover .eel-button-icon-before svg' => 'fill: {{VALUE}};', |
| 637 |
'{{WRAPPER}} .eel-button:hover .eel-button-icon-after svg' => 'fill: {{VALUE}};', |
| 638 |
'{{WRAPPER}} .eel-button .eel-button-icon-before i' => 'color: {{VALUE}};', |
| 639 |
'{{WRAPPER}} .eel-button .eel-button-icon-after i' => 'color: {{VALUE}};', |
| 640 |
'{{WRAPPER}} .eel-button .elementor-icon-wrapper' => 'color: {{VALUE}};', |
| 641 |
'{{WRAPPER}} .eel-button .elementor-icon-wrapper svg' => 'fill: {{VALUE}};', |
| 642 |
], |
| 643 |
] |
| 644 |
); |
| 645 |
|
| 646 |
$this->add_control( |
| 647 |
'icon_hover_bg', |
| 648 |
[ |
| 649 |
'label' => esc_html__('Background', 'easy-elements'), |
| 650 |
'type' => Controls_Manager::COLOR, |
| 651 |
'default' => '', |
| 652 |
'selectors' => [ |
| 653 |
'{{WRAPPER}} .eel-button:hover .eel-button-icon-before, {{WRAPPER}} .eel-button:hover .eel-button-icon-after' => 'background-color: {{VALUE}};', |
| 654 |
], |
| 655 |
] |
| 656 |
); |
| 657 |
|
| 658 |
$this->add_group_control( |
| 659 |
\Elementor\Group_Control_Background::get_type(), |
| 660 |
[ |
| 661 |
'name' => 'icon_hover_background', |
| 662 |
'label' => esc_html__('Icon Hover Background', 'easy-elements'), |
| 663 |
'types' => ['classic', 'gradient'], |
| 664 |
'selector' => '{{WRAPPER}} .eel-button:hover .eel-button-icon-before, {{WRAPPER}} .eel-button:hover .eel-button-icon-after', |
| 665 |
] |
| 666 |
); |
| 667 |
|
| 668 |
$this->add_responsive_control( |
| 669 |
'hover_icon_rotation', |
| 670 |
[ |
| 671 |
'label' => esc_html__('Rotation', 'easy-elements'), |
| 672 |
'type' => Controls_Manager::SLIDER, |
| 673 |
'size_units' => ['deg'], |
| 674 |
'range' => [ |
| 675 |
'deg' => [ |
| 676 |
'min' => -360, |
| 677 |
'max' => 360, |
| 678 |
], |
| 679 |
], |
| 680 |
'default' => [ |
| 681 |
'unit' => 'deg', |
| 682 |
'size' => 0, |
| 683 |
], |
| 684 |
'selectors' => [ |
| 685 |
'{{WRAPPER}} .eel-button:hover i' => 'transform: rotate({{SIZE}}{{UNIT}});', |
| 686 |
'{{WRAPPER}} .eel-button:hover svg' => 'transform: rotate({{SIZE}}{{UNIT}});', |
| 687 |
], |
| 688 |
] |
| 689 |
); |
| 690 |
$this->end_controls_tab(); |
| 691 |
|
| 692 |
$this->end_controls_tabs(); |
| 693 |
|
| 694 |
$this->end_controls_section(); |
| 695 |
} |
| 696 |
|
| 697 |
protected function render() { |
| 698 |
$settings = $this->get_settings_for_display(); |
| 699 |
|
| 700 |
// Get button URL |
| 701 |
$button_url = $settings['button_url']['url'] ?? '#'; |
| 702 |
$is_external = $settings['button_url']['is_external'] ?? false; |
| 703 |
$nofollow = $settings['button_url']['nofollow'] ?? false; |
| 704 |
|
| 705 |
// Build target attribute |
| 706 |
$target = $is_external ? '_blank' : '_self'; |
| 707 |
|
| 708 |
// Build rel attribute |
| 709 |
$rel = []; |
| 710 |
if ($is_external) { |
| 711 |
$rel[] = 'noopener'; |
| 712 |
} |
| 713 |
if ($nofollow) { |
| 714 |
$rel[] = 'nofollow'; |
| 715 |
} |
| 716 |
|
| 717 |
$rel_attr = !empty($rel) ? implode(' ', array_map('sanitize_html_class', $rel)) : ''; |
| 718 |
|
| 719 |
|
| 720 |
// Get button classes |
| 721 |
$button_classes = ['eel-button']; |
| 722 |
if (!empty($settings['button_type'])) { |
| 723 |
$button_classes[] = 'eel-button-' . $settings['button_type']; |
| 724 |
} |
| 725 |
|
| 726 |
if (!empty( $settings['show_gradient']) && 'yes' === $settings['show_gradient'] ) { |
| 727 |
$button_classes[] = 'eel-button-gradient'; |
| 728 |
} |
| 729 |
|
| 730 |
if(!empty($settings['border_gradient_button']) && 'yes' === $settings['border_gradient_button']) { |
| 731 |
$button_classes[] = 'eel-button-border-gradient'; |
| 732 |
} |
| 733 |
|
| 734 |
?> |
| 735 |
<a href="<?php echo esc_url( $button_url ); ?>" |
| 736 |
class="<?php echo esc_attr( implode(' ', $button_classes ) ); ?>" |
| 737 |
target="<?php echo esc_attr( $target ); ?>" |
| 738 |
<?php if ( $rel_attr ) : ?> rel="<?php echo esc_attr( $rel_attr ); ?> <?php endif; ?>"> |
| 739 |
<?php if (!empty($settings['button_icon']['value']) && $settings['icon_position'] === 'before'): ?> |
| 740 |
<span class="eel-button-icon-before"> |
| 741 |
<?php \Elementor\Icons_Manager::render_icon( $settings['button_icon'], [ 'aria-hidden' => 'true' ] ); ?> |
| 742 |
</span> |
| 743 |
<?php endif; ?> |
| 744 |
|
| 745 |
<span class="eel-button-text"><?php echo esc_html( $settings['button_text'] ); ?></span> |
| 746 |
|
| 747 |
<?php if (!empty( $settings['button_icon']['value'] ) && $settings['icon_position'] === 'after'): ?> |
| 748 |
<span class="eel-button-icon-after"> |
| 749 |
<?php \Elementor\Icons_Manager::render_icon( $settings['button_icon'], [ 'aria-hidden' => 'true' ] ); ?> |
| 750 |
</span> |
| 751 |
<?php endif; ?> |
| 752 |
</a> |
| 753 |
<?php |
| 754 |
} |
| 755 |
} |
| 756 |
|