| 1 |
<?php |
| 2 |
namespace Easyel\EasyElements\Widgets; |
| 3 |
use Elementor\Utils; |
| 4 |
use Elementor\Controls_Manager; |
| 5 |
use Elementor\Responsive_Control; |
| 6 |
use Elementor\Group_Control_Image_Size; |
| 7 |
|
| 8 |
defined( 'ABSPATH' ) || die(); |
| 9 |
class Easyel_Contact_Box__Widget extends \Elementor\Widget_Base { |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
public function get_name() { |
| 14 |
return 'eel-contact-box'; |
| 15 |
} |
| 16 |
|
| 17 |
public function get_title() { |
| 18 |
return esc_html__( 'Contact Box', 'easy-elements' ); |
| 19 |
} |
| 20 |
|
| 21 |
public function get_icon() { |
| 22 |
return 'easyicon easyelIcon-contact-box'; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_categories() { |
| 26 |
return [ 'easyelements_category' ]; |
| 27 |
} |
| 28 |
|
| 29 |
public function get_keywords() { |
| 30 |
return [ 'contact', 'text', 'info', 'address' ]; |
| 31 |
} |
| 32 |
|
| 33 |
public function get_style_depends() { |
| 34 |
return [ |
| 35 |
'eel-contact-box', |
| 36 |
]; |
| 37 |
} |
| 38 |
|
| 39 |
protected function register_controls() { |
| 40 |
$this->start_controls_section( |
| 41 |
'_section_logo', |
| 42 |
[ |
| 43 |
'label' => esc_html__( 'Contact Box Settings', 'easy-elements' ), |
| 44 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 45 |
] |
| 46 |
); |
| 47 |
|
| 48 |
|
| 49 |
$this->add_control( |
| 50 |
'info_type', |
| 51 |
[ |
| 52 |
'label' => esc_html__('Select Info Type', 'easy-elements'), |
| 53 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 54 |
'default' => 'address', |
| 55 |
'options' => [ |
| 56 |
'address' => esc_html__('Address', 'easy-elements'), |
| 57 |
'phone' => esc_html__('Phone', 'easy-elements'), |
| 58 |
'email' => esc_html__('Email', 'easy-elements'), |
| 59 |
'hours' => esc_html__('Hours', 'easy-elements'), |
| 60 |
'website' => esc_html__('Website', 'easy-elements'), |
| 61 |
], |
| 62 |
] |
| 63 |
); |
| 64 |
|
| 65 |
|
| 66 |
$this->add_control( |
| 67 |
'icon_box_off', |
| 68 |
[ |
| 69 |
'label' => esc_html__('Icon Box Disable', 'easy-elements'), |
| 70 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 71 |
'label_on' => esc_html__('Yes', 'easy-elements'), |
| 72 |
'label_off' => esc_html__('No', 'easy-elements'), |
| 73 |
'return_value' => 'yes', |
| 74 |
'default' => 'yes', |
| 75 |
] |
| 76 |
); |
| 77 |
|
| 78 |
$this->add_control( |
| 79 |
'icon', |
| 80 |
[ |
| 81 |
'label' => esc_html__( 'Icon', 'easy-elements' ), |
| 82 |
'type' => \Elementor\Controls_Manager::ICONS, |
| 83 |
'label_block' => true, |
| 84 |
'default' => [ |
| 85 |
'value' => 'fas fa-star', |
| 86 |
'library' => 'fa-solid', |
| 87 |
], |
| 88 |
'condition' => [ |
| 89 |
'icon_box_off' => 'yes', |
| 90 |
], |
| 91 |
] |
| 92 |
); |
| 93 |
|
| 94 |
$this->add_control( |
| 95 |
'eel_title', |
| 96 |
[ |
| 97 |
'label' => esc_html__( 'Label', 'easy-elements' ), |
| 98 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 99 |
'default' => esc_html__( 'Headquarters', 'easy-elements' ), |
| 100 |
'label_block' => true, |
| 101 |
] |
| 102 |
); |
| 103 |
|
| 104 |
$this->add_control( |
| 105 |
'title_position', |
| 106 |
[ |
| 107 |
'label' => esc_html__('Label Position', 'easy-elements'), |
| 108 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 109 |
'default' => 'top', |
| 110 |
'options' => [ |
| 111 |
'top' => esc_html__('Top', 'easy-elements'), |
| 112 |
'bottom' => esc_html__('Bottom', 'easy-elements'), |
| 113 |
], |
| 114 |
] |
| 115 |
); |
| 116 |
|
| 117 |
$this->add_control( |
| 118 |
'address', |
| 119 |
[ |
| 120 |
'label' => esc_html__( 'Information', 'easy-elements' ), |
| 121 |
'type' => \Elementor\Controls_Manager::TEXTAREA, |
| 122 |
'default' => esc_html__( 'Apt 1010 Business Avenue, Toronto, Canada', 'easy-elements' ), |
| 123 |
'condition' => [ |
| 124 |
'info_type' => 'address', |
| 125 |
], |
| 126 |
] |
| 127 |
); |
| 128 |
|
| 129 |
$this->add_control( |
| 130 |
'hours', |
| 131 |
[ |
| 132 |
'label' => esc_html__( 'Hours', 'easy-elements' ), |
| 133 |
'type' => \Elementor\Controls_Manager::TEXTAREA, |
| 134 |
'default' => esc_html__( 'Monday-Friday:8:30 AM - 5:30 PM', 'easy-elements' ), |
| 135 |
'condition' => [ |
| 136 |
'info_type' => 'hours', |
| 137 |
], |
| 138 |
] |
| 139 |
); |
| 140 |
|
| 141 |
$this->add_control( |
| 142 |
'_phone', |
| 143 |
[ |
| 144 |
'label' => esc_html__( 'Phone Number 01', 'easy-elements' ), |
| 145 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 146 |
'default' => esc_html__( '+99 254 36587', 'easy-elements' ), |
| 147 |
'condition' => [ |
| 148 |
'info_type' => 'phone', |
| 149 |
], |
| 150 |
] |
| 151 |
); |
| 152 |
|
| 153 |
$this->add_control( |
| 154 |
'phone2', |
| 155 |
[ |
| 156 |
'label' => esc_html__( 'Phone Number 02', 'easy-elements' ), |
| 157 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 158 |
'default' => esc_html__( '+99 254 36587', 'easy-elements' ), |
| 159 |
'condition' => [ |
| 160 |
'info_type' => 'phone', |
| 161 |
], |
| 162 |
] |
| 163 |
); |
| 164 |
|
| 165 |
$this->add_control( |
| 166 |
'email', |
| 167 |
[ |
| 168 |
'label' => esc_html__( 'Email 01', 'easy-elements' ), |
| 169 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 170 |
'default' => esc_html__( 'example@gmail.com', 'easy-elements' ), |
| 171 |
'condition' => [ |
| 172 |
'info_type' => 'email', |
| 173 |
], |
| 174 |
] |
| 175 |
); |
| 176 |
|
| 177 |
$this->add_control( |
| 178 |
'email2', |
| 179 |
[ |
| 180 |
'label' => esc_html__( 'Email 02', 'easy-elements' ), |
| 181 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 182 |
'default' => esc_html__( 'example2@gmail.com', 'easy-elements' ), |
| 183 |
'condition' => [ |
| 184 |
'info_type' => 'email', |
| 185 |
], |
| 186 |
] |
| 187 |
); |
| 188 |
|
| 189 |
$this->add_control( |
| 190 |
'website', |
| 191 |
[ |
| 192 |
'label' => esc_html__( 'Website', 'easy-elements' ), |
| 193 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 194 |
'default' => esc_html__( 'https://example.com', 'easy-elements' ), |
| 195 |
'condition' => [ |
| 196 |
'info_type' => 'website', |
| 197 |
], |
| 198 |
] |
| 199 |
); |
| 200 |
|
| 201 |
$this->add_control( |
| 202 |
'website_link', |
| 203 |
[ |
| 204 |
'label' => esc_html__('Website URL', 'easy-elements'), |
| 205 |
'type' => \Elementor\Controls_Manager::URL, |
| 206 |
'placeholder' => 'https://example.com', |
| 207 |
'show_external' => true, |
| 208 |
'condition' => [ |
| 209 |
'info_type' => 'website', |
| 210 |
], |
| 211 |
] |
| 212 |
); |
| 213 |
|
| 214 |
$this->add_control( |
| 215 |
'full_box_link', |
| 216 |
[ |
| 217 |
'label' => esc_html__('Make Full Box Clickable', 'easy-elements'), |
| 218 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 219 |
'label_on' => esc_html__('Yes', 'easy-elements'), |
| 220 |
'label_off' => esc_html__('No', 'easy-elements'), |
| 221 |
'return_value' => 'yes', |
| 222 |
'default' => 'no', |
| 223 |
'description' => esc_html__('This option will not work if you use a second phone or second email field.', 'easy-elements'), |
| 224 |
] |
| 225 |
); |
| 226 |
|
| 227 |
$this->add_control( |
| 228 |
'link', |
| 229 |
[ |
| 230 |
'label' => esc_html__('Custom Link', 'easy-elements'), |
| 231 |
'type' => Controls_Manager::URL, |
| 232 |
'placeholder' => 'https://example.com', |
| 233 |
'description' => esc_html__('Custom link to be used for full box or manual overrides.', 'easy-elements'), |
| 234 |
'condition' => [ |
| 235 |
'full_box_link' => 'yes', |
| 236 |
'info_type' => ['address', 'hours'], |
| 237 |
], |
| 238 |
] |
| 239 |
); |
| 240 |
|
| 241 |
$this->add_control( |
| 242 |
'icon_direction', |
| 243 |
[ |
| 244 |
'label' => esc_html__( 'Direction', 'easy-elements' ), |
| 245 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 246 |
'default' => 'top', |
| 247 |
'options' => [ |
| 248 |
'left' => [ |
| 249 |
'title' => esc_html__( 'Left', 'easy-elements' ), |
| 250 |
'icon' => 'eicon-h-align-left', |
| 251 |
], |
| 252 |
'top' => [ |
| 253 |
'title' => esc_html__( 'Top', 'easy-elements' ), |
| 254 |
'icon' => 'eicon-v-align-top', |
| 255 |
], |
| 256 |
'right' => [ |
| 257 |
'title' => esc_html__( 'Right', 'easy-elements' ), |
| 258 |
'icon' => 'eicon-h-align-right', |
| 259 |
], |
| 260 |
], |
| 261 |
'toggle' => false, |
| 262 |
'condition' => [ |
| 263 |
'icon_box_off' => 'yes', |
| 264 |
], |
| 265 |
] |
| 266 |
); |
| 267 |
|
| 268 |
|
| 269 |
$this->add_responsive_control( |
| 270 |
'_text_align', |
| 271 |
[ |
| 272 |
'label' => esc_html__( 'Alignment', 'easy-elements' ), |
| 273 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 274 |
'options' => [ |
| 275 |
'left' => [ |
| 276 |
'title' => esc_html__( 'Left', 'easy-elements' ), |
| 277 |
'icon' => 'eicon-text-align-left', |
| 278 |
], |
| 279 |
'center' => [ |
| 280 |
'title' => esc_html__( 'Center', 'easy-elements' ), |
| 281 |
'icon' => 'eicon-text-align-center', |
| 282 |
], |
| 283 |
'right' => [ |
| 284 |
'title' => esc_html__( 'Right', 'easy-elements' ), |
| 285 |
'icon' => 'eicon-text-align-right', |
| 286 |
], |
| 287 |
], |
| 288 |
'default' => 'center', |
| 289 |
'selectors' => [ |
| 290 |
'{{WRAPPER}} .ee--contact-box' => 'text-align: {{VALUE}};', |
| 291 |
], |
| 292 |
] |
| 293 |
); |
| 294 |
|
| 295 |
$this->add_control( |
| 296 |
'title_tag', |
| 297 |
[ |
| 298 |
'label' => esc_html__( 'Title HTML Tag', 'easy-elements' ), |
| 299 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 300 |
'default' => 'h3', |
| 301 |
'options' => [ |
| 302 |
'h1' => 'H1', |
| 303 |
'h2' => 'H2', |
| 304 |
'h3' => 'H3', |
| 305 |
'h4' => 'H4', |
| 306 |
'h5' => 'H5', |
| 307 |
'h6' => 'H6', |
| 308 |
'div' => 'div', |
| 309 |
'span' => 'span', |
| 310 |
'p' => 'p', |
| 311 |
], |
| 312 |
] |
| 313 |
); |
| 314 |
|
| 315 |
$this->end_controls_section(); |
| 316 |
|
| 317 |
$this->start_controls_section( |
| 318 |
'section_style_box', |
| 319 |
[ |
| 320 |
'label' => esc_html__( 'Box', 'easy-elements' ), |
| 321 |
'tab' => Controls_Manager::TAB_STYLE, |
| 322 |
] |
| 323 |
); |
| 324 |
|
| 325 |
$this->add_group_control( |
| 326 |
\Elementor\Group_Control_Background::get_type(), |
| 327 |
[ |
| 328 |
'name' => 'box_background', |
| 329 |
'types' => [ 'classic', 'gradient' ], |
| 330 |
'selector' => '{{WRAPPER}} .ee--contact-box', |
| 331 |
] |
| 332 |
); |
| 333 |
|
| 334 |
$this->add_group_control( |
| 335 |
\Elementor\Group_Control_Border::get_type(), |
| 336 |
[ |
| 337 |
'name' => 'box_border', |
| 338 |
'selector' => '{{WRAPPER}} .ee--contact-box', |
| 339 |
] |
| 340 |
); |
| 341 |
|
| 342 |
$this->add_responsive_control( |
| 343 |
'box_border_radius', |
| 344 |
[ |
| 345 |
'label' => esc_html__( 'Border Radius', 'easy-elements' ), |
| 346 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 347 |
'size_units' => [ 'px', '%' ], |
| 348 |
'selectors' => [ |
| 349 |
'{{WRAPPER}} .ee--contact-box' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 350 |
], |
| 351 |
] |
| 352 |
); |
| 353 |
|
| 354 |
$this->add_group_control( |
| 355 |
\Elementor\Group_Control_Box_Shadow::get_type(), |
| 356 |
[ |
| 357 |
'name' => 'box_shadow', |
| 358 |
'selector' => '{{WRAPPER}} .ee--contact-box', |
| 359 |
] |
| 360 |
); |
| 361 |
|
| 362 |
$this->add_responsive_control( |
| 363 |
'box_padding', |
| 364 |
[ |
| 365 |
'label' => esc_html__( 'Padding', 'easy-elements' ), |
| 366 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 367 |
'size_units' => [ 'px', '%', 'em', 'rem' ], |
| 368 |
'selectors' => [ |
| 369 |
'{{WRAPPER}} .ee--contact-box' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 370 |
], |
| 371 |
] |
| 372 |
); |
| 373 |
|
| 374 |
$this->add_responsive_control( |
| 375 |
'box_margin', |
| 376 |
[ |
| 377 |
'label' => esc_html__( 'Margin', 'easy-elements' ), |
| 378 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 379 |
'size_units' => [ 'px', '%', 'em', 'rem' ], |
| 380 |
'selectors' => [ |
| 381 |
'{{WRAPPER}} .ee--contact-box' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 382 |
], |
| 383 |
] |
| 384 |
); |
| 385 |
|
| 386 |
$this->end_controls_section(); |
| 387 |
|
| 388 |
$this->start_controls_section( |
| 389 |
'section_style_icon', |
| 390 |
[ |
| 391 |
'label' => esc_html__( 'Icon', 'easy-elements' ), |
| 392 |
'tab' => Controls_Manager::TAB_STYLE, |
| 393 |
] |
| 394 |
); |
| 395 |
|
| 396 |
$this->start_controls_tabs( 'icon_color_tabs' ); |
| 397 |
|
| 398 |
$this->start_controls_tab( |
| 399 |
'icon_color_tab_normal', |
| 400 |
[ |
| 401 |
'label' => esc_html__( 'Normal', 'easy-elements' ), |
| 402 |
] |
| 403 |
); |
| 404 |
|
| 405 |
$this->add_control( |
| 406 |
'icon_color', |
| 407 |
[ |
| 408 |
'label' => esc_html__( 'Color', 'easy-elements' ), |
| 409 |
'type' => Controls_Manager::COLOR, |
| 410 |
'selectors' => [ |
| 411 |
'{{WRAPPER}} .ee--contact-box .eel-icon' => 'color: {{VALUE}};', |
| 412 |
'{{WRAPPER}} .ee--contact-box .eel-icon svg' => 'fill: {{VALUE}};', |
| 413 |
'{{WRAPPER}} .ee--contact-box .eel-icon svg path' => 'fill: {{VALUE}};', |
| 414 |
], |
| 415 |
] |
| 416 |
); |
| 417 |
|
| 418 |
$this->add_control( |
| 419 |
'icon_bg_color', |
| 420 |
[ |
| 421 |
'label' => esc_html__( 'Background', 'easy-elements' ), |
| 422 |
'type' => Controls_Manager::COLOR, |
| 423 |
'selectors' => [ |
| 424 |
'{{WRAPPER}} .ee--contact-box .eel-icon' => 'background-color: {{VALUE}};', |
| 425 |
], |
| 426 |
] |
| 427 |
); |
| 428 |
|
| 429 |
$this->add_group_control( |
| 430 |
\Elementor\Group_Control_Background::get_type(), |
| 431 |
[ |
| 432 |
'name' => 'icon_bg_color_group', |
| 433 |
'label' => esc_html__( 'Background', 'easy-elements' ), |
| 434 |
'types' => [ 'classic', 'gradient' ], |
| 435 |
'selector' => '{{WRAPPER}} .ee--contact-box .eel-icon', |
| 436 |
] |
| 437 |
); |
| 438 |
|
| 439 |
$this->end_controls_tab(); |
| 440 |
|
| 441 |
$this->start_controls_tab( |
| 442 |
'icon_color_tab_hover', |
| 443 |
[ |
| 444 |
'label' => esc_html__( 'Hover', 'easy-elements' ), |
| 445 |
] |
| 446 |
); |
| 447 |
|
| 448 |
$this->add_control( |
| 449 |
'icon_hover_color', |
| 450 |
[ |
| 451 |
'label' => esc_html__( 'Color', 'easy-elements' ), |
| 452 |
'type' => Controls_Manager::COLOR, |
| 453 |
'selectors' => [ |
| 454 |
'{{WRAPPER}} .ee--contact-box:hover .eel-icon' => 'color: {{VALUE}};', |
| 455 |
'{{WRAPPER}} .ee--contact-box:hover .eel-icon svg' => 'fill: {{VALUE}};', |
| 456 |
'{{WRAPPER}} .ee--contact-box:hover .eel-icon svg path' => 'fill: {{VALUE}};', |
| 457 |
], |
| 458 |
] |
| 459 |
); |
| 460 |
|
| 461 |
$this->add_group_control( |
| 462 |
\Elementor\Group_Control_Background::get_type(), |
| 463 |
[ |
| 464 |
'name' => 'icon_hover_background', |
| 465 |
'label' => esc_html__( 'Background', 'easy-elements' ), |
| 466 |
'types' => [ 'classic', 'gradient' ], |
| 467 |
'selector' => '{{WRAPPER}} .ee--contact-box:hover .eel-icon', |
| 468 |
] |
| 469 |
); |
| 470 |
|
| 471 |
$this->end_controls_tab(); |
| 472 |
|
| 473 |
$this->end_controls_tabs(); |
| 474 |
|
| 475 |
$this->add_group_control( |
| 476 |
\Elementor\Group_Control_Typography::get_type(), |
| 477 |
[ |
| 478 |
'name' => 'icon_typography', |
| 479 |
'label' => esc_html__( 'Icon Typography', 'easy-elements' ), |
| 480 |
'selector' => '{{WRAPPER}} .ee--contact-box .eel-icon', |
| 481 |
] |
| 482 |
); |
| 483 |
|
| 484 |
$this->add_group_control( |
| 485 |
\Elementor\Group_Control_Border::get_type(), |
| 486 |
[ |
| 487 |
'name' => 'icon_border', |
| 488 |
'selector' => '{{WRAPPER}} .ee--contact-box .eel-icon', |
| 489 |
] |
| 490 |
); |
| 491 |
|
| 492 |
$this->add_control( |
| 493 |
'icon__border_radius', |
| 494 |
[ |
| 495 |
'label' => esc_html__( 'Border Radius', 'easy-elements' ), |
| 496 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 497 |
'size_units' => [ 'px', '%' ], |
| 498 |
'selectors' => [ |
| 499 |
'{{WRAPPER}} .ee--contact-box .eel-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 500 |
], |
| 501 |
] |
| 502 |
); |
| 503 |
|
| 504 |
$this->add_responsive_control( |
| 505 |
'icon_margin', |
| 506 |
[ |
| 507 |
'label' => esc_html__( 'Margin', 'easy-elements' ), |
| 508 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 509 |
'size_units' => [ 'px', '%', 'em', 'rem' ], |
| 510 |
'selectors' => [ |
| 511 |
'{{WRAPPER}} .ee--contact-box .eel-icon' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 512 |
], |
| 513 |
] |
| 514 |
); |
| 515 |
$this->add_responsive_control( |
| 516 |
'icon_width', |
| 517 |
[ |
| 518 |
'label' => esc_html__('Icon Area Width', 'easy-elements'), |
| 519 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 520 |
'size_units' => [ 'px', '%', 'em', 'rem' ], |
| 521 |
'selectors' => [ |
| 522 |
'{{WRAPPER}} .ee--contact-box .eel-icon' => 'min-width: {{SIZE}}{{UNIT}};', |
| 523 |
], |
| 524 |
] |
| 525 |
); |
| 526 |
$this->add_responsive_control( |
| 527 |
'icon_height', |
| 528 |
[ |
| 529 |
'label' => esc_html__('Icon Area Height', 'easy-elements'), |
| 530 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 531 |
'size_units' => [ 'px', '%', 'em', 'rem' ], |
| 532 |
'selectors' => [ |
| 533 |
'{{WRAPPER}} .ee--contact-box .eel-icon' => 'height: {{SIZE}}{{UNIT}};', |
| 534 |
], |
| 535 |
] |
| 536 |
); |
| 537 |
|
| 538 |
$this->add_responsive_control( |
| 539 |
'icon_content_gap', |
| 540 |
[ |
| 541 |
'label' => esc_html__('Gap', 'easy-elements'), |
| 542 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 543 |
'size_units' => [ 'px', '%', 'em', 'rem' ], |
| 544 |
'range' => [ |
| 545 |
'px' => [ 'min' => 0, 'max' => 200 ], |
| 546 |
'em' => [ 'min' => 0, 'max' => 20 ], |
| 547 |
'rem' => [ 'min' => 0, 'max' => 20 ], |
| 548 |
], |
| 549 |
'default' => [ |
| 550 |
'size' => 20, |
| 551 |
'unit' => 'px', |
| 552 |
], |
| 553 |
'description' => esc_html__('Space between the icon and the content (applies to Left/Right direction).', 'easy-elements'), |
| 554 |
'selectors' => [ |
| 555 |
'{{WRAPPER}} .ee--contact-box.left, {{WRAPPER}} .ee--contact-box.right' => 'gap: {{SIZE}}{{UNIT}};', |
| 556 |
], |
| 557 |
'condition' => [ |
| 558 |
'icon_direction' => [ 'left', 'right' ], |
| 559 |
], |
| 560 |
] |
| 561 |
); |
| 562 |
|
| 563 |
$this->end_controls_section(); |
| 564 |
|
| 565 |
$this->start_controls_section( |
| 566 |
'section_style_title', |
| 567 |
[ |
| 568 |
'label' => esc_html__( 'Label', 'easy-elements' ), |
| 569 |
'tab' => Controls_Manager::TAB_STYLE, |
| 570 |
] |
| 571 |
); |
| 572 |
|
| 573 |
$this->add_control( |
| 574 |
'title_color', |
| 575 |
[ |
| 576 |
'label' => esc_html__( 'Color', 'easy-elements' ), |
| 577 |
'type' => Controls_Manager::COLOR, |
| 578 |
'selectors' => [ |
| 579 |
'{{WRAPPER}} .contact-box-title' => 'color: {{VALUE}};', |
| 580 |
], |
| 581 |
] |
| 582 |
); |
| 583 |
|
| 584 |
$this->add_group_control( |
| 585 |
\Elementor\Group_Control_Typography::get_type(), |
| 586 |
[ |
| 587 |
'name' => '_title_typography', |
| 588 |
'label' => esc_html__( 'Typography', 'easy-elements' ), |
| 589 |
'selector' => '{{WRAPPER}} .contact-box-title', |
| 590 |
] |
| 591 |
); |
| 592 |
|
| 593 |
$this->add_responsive_control( |
| 594 |
'title_margin', |
| 595 |
[ |
| 596 |
'label' => esc_html__( 'Margin', 'easy-elements' ), |
| 597 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 598 |
'size_units' => [ 'px', '%', 'em', 'rem' ], |
| 599 |
'selectors' => [ |
| 600 |
'{{WRAPPER}} .ee--contact-box .contact-box-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 601 |
], |
| 602 |
] |
| 603 |
); |
| 604 |
|
| 605 |
$this->end_controls_section(); |
| 606 |
|
| 607 |
$this->start_controls_section( |
| 608 |
'section_style_description', |
| 609 |
[ |
| 610 |
'label' => esc_html__( 'Information', 'easy-elements' ), |
| 611 |
'tab' => Controls_Manager::TAB_STYLE, |
| 612 |
] |
| 613 |
); |
| 614 |
|
| 615 |
$this->start_controls_tabs( 'desc_color_tabs' ); |
| 616 |
|
| 617 |
$this->start_controls_tab( |
| 618 |
'desc_color_tab_normal', |
| 619 |
[ |
| 620 |
'label' => esc_html__( 'Normal', 'easy-elements' ), |
| 621 |
] |
| 622 |
); |
| 623 |
|
| 624 |
$this->add_control( |
| 625 |
'desc_color', |
| 626 |
[ |
| 627 |
'label' => esc_html__( 'Color', 'easy-elements' ), |
| 628 |
'type' => Controls_Manager::COLOR, |
| 629 |
'selectors' => [ |
| 630 |
'{{WRAPPER}} .contact-box-description' => 'color: {{VALUE}};', |
| 631 |
], |
| 632 |
] |
| 633 |
); |
| 634 |
|
| 635 |
$this->end_controls_tab(); |
| 636 |
|
| 637 |
$this->start_controls_tab( |
| 638 |
'desc_color_tab_hover', |
| 639 |
[ |
| 640 |
'label' => esc_html__( 'Hover', 'easy-elements' ), |
| 641 |
] |
| 642 |
); |
| 643 |
|
| 644 |
$this->add_control( |
| 645 |
'desc_hover_color', |
| 646 |
[ |
| 647 |
'label' => esc_html__( 'Color', 'easy-elements' ), |
| 648 |
'type' => Controls_Manager::COLOR, |
| 649 |
'selectors' => [ |
| 650 |
'{{WRAPPER}} .contact-box-description a:hover' => 'color: {{VALUE}};', |
| 651 |
], |
| 652 |
] |
| 653 |
); |
| 654 |
|
| 655 |
$this->end_controls_tab(); |
| 656 |
|
| 657 |
$this->end_controls_tabs(); |
| 658 |
|
| 659 |
$this->add_group_control( |
| 660 |
\Elementor\Group_Control_Typography::get_type(), |
| 661 |
[ |
| 662 |
'name' => 'box_desc_typography', |
| 663 |
'label' => esc_html__( 'Typography', 'easy-elements' ), |
| 664 |
'selector' => '{{WRAPPER}} .contact-box-description', |
| 665 |
] |
| 666 |
); |
| 667 |
|
| 668 |
|
| 669 |
$this->end_controls_section(); |
| 670 |
} |
| 671 |
|
| 672 |
protected function render() { |
| 673 |
$settings = $this->get_settings_for_display(); |
| 674 |
|
| 675 |
$icon_direction = $settings['icon_direction'] ?? ''; |
| 676 |
$full_box_link = $settings['full_box_link'] ?? 'no'; |
| 677 |
$type = $settings['info_type'] ?? ''; |
| 678 |
|
| 679 |
$type_map = [ |
| 680 |
'phone' => ['_phone', 'phone2'], |
| 681 |
'email' => ['email', 'email2'], |
| 682 |
'website' => ['website'], |
| 683 |
'hours' => ['hours'], |
| 684 |
'address' => ['address'], |
| 685 |
]; |
| 686 |
|
| 687 |
$value = $second_value = ''; |
| 688 |
if (isset($type_map[$type])) { |
| 689 |
$keys = $type_map[$type]; |
| 690 |
$value = $settings[$keys[0]] ?? ''; |
| 691 |
$second_value = isset($keys[1]) ? ($settings[$keys[1]] ?? '') : ''; |
| 692 |
} |
| 693 |
|
| 694 |
$link = ''; |
| 695 |
$target = $nofollow = ''; |
| 696 |
|
| 697 |
if (in_array($type, ['phone', 'email', 'website']) && !empty($value)) { |
| 698 |
if ($type === 'phone') { |
| 699 |
$link = 'tel:' . $value; |
| 700 |
} elseif ($type === 'email') { |
| 701 |
$link = 'mailto:' . $value; |
| 702 |
} elseif ($type === 'website' && !empty($settings['website_link']['url'])) { |
| 703 |
$link = $settings['website_link']['url']; |
| 704 |
$target = !empty($settings['website_link']['is_external']) ? ' target="_blank"' : ''; |
| 705 |
$nofollow = ' rel="noopener noreferrer"'; |
| 706 |
} |
| 707 |
} |
| 708 |
|
| 709 |
if (empty($link) && !empty($settings['link']['url'])) { |
| 710 |
$link = $settings['link']['url']; |
| 711 |
$target = !empty($settings['link']['is_external']) ? ' target="_blank"' : ''; |
| 712 |
$nofollow = !empty($settings['link']['nofollow']) ? ' rel="nofollow"' : ''; |
| 713 |
} |
| 714 |
|
| 715 |
$title_tag = $settings['title_tag'] ?? 'h3'; |
| 716 |
$title_position = $settings['title_position'] ?? 'top'; |
| 717 |
|
| 718 |
if ($full_box_link === 'yes' && !empty($link)) : |
| 719 |
echo wp_kses_post( '<a href="' . esc_url($link) . '"' . $target . $nofollow . ' class="eel-full-link-wrap">'); |
| 720 |
endif; |
| 721 |
?> |
| 722 |
|
| 723 |
<div class="ee--contact-box <?php echo esc_attr($icon_direction); ?>"> |
| 724 |
|
| 725 |
<?php if (!empty($settings['icon']) && ($settings['icon_box_off'] ?? '') === 'yes') : ?> |
| 726 |
<span class="eel-icon"> |
| 727 |
<?php \Elementor\Icons_Manager::render_icon($settings['icon'], ['aria-hidden' => 'true']); ?> |
| 728 |
</span> |
| 729 |
<?php endif; ?> |
| 730 |
|
| 731 |
<?php if ($icon_direction === 'left' || $icon_direction === 'right') : ?> |
| 732 |
<div class="eel-title-content-wrap"> |
| 733 |
<?php endif; ?> |
| 734 |
|
| 735 |
<?php |
| 736 |
if ($title_position === 'top') { |
| 737 |
$this->render_title($settings['eel_title'] ?? '', $title_tag); |
| 738 |
} |
| 739 |
?> |
| 740 |
|
| 741 |
<?php if (!empty($value)) : ?> |
| 742 |
<div class="contact-box-description"> |
| 743 |
<?php $this->render_contact_description($value, $second_value, $full_box_link, $type, $settings, $target, $nofollow); ?> |
| 744 |
</div> |
| 745 |
<?php endif; ?> |
| 746 |
|
| 747 |
<?php |
| 748 |
if ($title_position === 'bottom') { |
| 749 |
$this->render_title($settings['eel_title'] ?? '', $title_tag); |
| 750 |
} |
| 751 |
?> |
| 752 |
|
| 753 |
<?php if ($icon_direction === 'left' || $icon_direction === 'right') : ?> |
| 754 |
</div> |
| 755 |
<?php endif; ?> |
| 756 |
|
| 757 |
</div> |
| 758 |
|
| 759 |
<?php |
| 760 |
if ($full_box_link === 'yes' && !empty($link)) : |
| 761 |
echo '</a>'; |
| 762 |
endif; |
| 763 |
} |
| 764 |
|
| 765 |
protected function render_contact_description($value, $second_value, $full_box_link, $type, $settings, $target = '', $nofollow = '') { |
| 766 |
if ($full_box_link === 'yes') { |
| 767 |
echo esc_html($value); |
| 768 |
if (!empty($second_value)) { |
| 769 |
echo '<br>' . esc_html($second_value); |
| 770 |
} |
| 771 |
return; |
| 772 |
} |
| 773 |
|
| 774 |
switch ( $type ) { |
| 775 |
case 'phone': |
| 776 |
$this->render_phone_with_text( $value ); |
| 777 |
if ( ! empty( $second_value ) ) { |
| 778 |
echo '<br>'; |
| 779 |
$this->render_phone_with_text( $second_value ); |
| 780 |
} |
| 781 |
break; |
| 782 |
|
| 783 |
case 'email': |
| 784 |
if ( is_email( $value ) ) { |
| 785 |
$email1 = sprintf( |
| 786 |
'<a href="mailto:%1$s">%2$s</a>', |
| 787 |
antispambot( esc_attr( $value ) ), |
| 788 |
esc_html( antispambot( $value ) ) |
| 789 |
); |
| 790 |
echo wp_kses( |
| 791 |
$email1, |
| 792 |
[ |
| 793 |
'a' => [ 'href' => [] ], |
| 794 |
] |
| 795 |
); |
| 796 |
} |
| 797 |
|
| 798 |
if ( ! empty( $second_value ) && is_email( $second_value ) ) { |
| 799 |
$email2 = sprintf( |
| 800 |
'<br><a href="mailto:%1$s">%2$s</a>', |
| 801 |
antispambot( esc_attr( $second_value ) ), |
| 802 |
esc_html( antispambot( $second_value ) ) |
| 803 |
); |
| 804 |
echo wp_kses( |
| 805 |
$email2, |
| 806 |
[ |
| 807 |
'br' => [], |
| 808 |
'a' => [ 'href' => [] ], |
| 809 |
] |
| 810 |
); |
| 811 |
} |
| 812 |
break; |
| 813 |
|
| 814 |
case 'website': |
| 815 |
if ( ! empty( $settings['website_link']['url'] ) ) { |
| 816 |
$href = esc_url( $settings['website_link']['url'] ); |
| 817 |
$target = ! empty( $settings['website_link']['is_external'] ) ? ' target="_blank"' : ''; |
| 818 |
$rel_attr = ' rel="' . esc_attr( |
| 819 |
! empty( $settings['website_link']['nofollow'] ) ? 'nofollow noopener noreferrer' : 'noopener noreferrer' |
| 820 |
) . '"'; |
| 821 |
|
| 822 |
$link_html = sprintf( |
| 823 |
'<a href="%1$s"%2$s%3$s>%4$s</a>', |
| 824 |
$href, |
| 825 |
$target, |
| 826 |
$rel_attr, |
| 827 |
esc_html( $value ) |
| 828 |
); |
| 829 |
|
| 830 |
echo wp_kses( |
| 831 |
$link_html, |
| 832 |
[ |
| 833 |
'a' => [ |
| 834 |
'href' => [], |
| 835 |
'target' => [], |
| 836 |
'rel' => [], |
| 837 |
], |
| 838 |
] |
| 839 |
); |
| 840 |
} else { |
| 841 |
echo esc_html( $value ); |
| 842 |
} |
| 843 |
break; |
| 844 |
|
| 845 |
default: |
| 846 |
echo wp_kses_post( $value ); |
| 847 |
break; |
| 848 |
} |
| 849 |
} |
| 850 |
|
| 851 |
protected function render_phone_with_text($value) { |
| 852 |
if (preg_match('/([+]?\d[\d\s\-().]{6,})/', $value, $matches, PREG_OFFSET_CAPTURE)) { |
| 853 |
$number = trim($matches[1][0]); |
| 854 |
$start = $matches[1][1]; |
| 855 |
$end = $start + strlen($number); |
| 856 |
$before = substr($value, 0, $start); |
| 857 |
$after = substr($value, $end); |
| 858 |
// Preserve a leading "+" (international prefix) while stripping spaces, dashes, etc. |
| 859 |
$has_plus = strpos(trim($number), '+') === 0; |
| 860 |
$tel = ($has_plus ? '+' : '') . preg_replace('/\D+/', '', $number); |
| 861 |
echo esc_html($before); |
| 862 |
echo '<a href="tel:' . esc_attr($tel) . '">' . esc_html($number) . '</a>'; |
| 863 |
echo esc_html($after); |
| 864 |
} else { |
| 865 |
echo esc_html($value); |
| 866 |
} |
| 867 |
} |
| 868 |
|
| 869 |
protected function render_title($title, $tag) { |
| 870 |
if (!empty($title)) { |
| 871 |
printf('<%1$s class="contact-box-title">%2$s</%1$s>', esc_attr($tag), esc_html($title)); |
| 872 |
} |
| 873 |
} |
| 874 |
|
| 875 |
} |