PluginProbe
Elementor Website Builder – more than just a page builder / 3.20.0-dev3
Elementor Website Builder – more than just a page builder v3.20.0-dev3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | includes/widgets/image-box.php +49 -243 4.1.13.20.0-dev3 View file →
@@ -72,31 +72,9 @@
72 72 public function get_keywords() {
73 73 return [ 'image', 'photo', 'visual', 'box' ];
74 74 }
75 75
76 - protected function is_dynamic_content(): bool {
77 - return false;
78 - }
79 -
80 76 /**
81 - * Get style dependencies.
82 - *
83 - * Retrieve the list of style dependencies the widget requires.
84 - *
85 - * @since 3.24.0
86 - * @access public
87 - *
88 - * @return array Widget style dependencies.
89 - */
90 - public function get_style_depends(): array {
91 - return [ 'widget-image-box' ];
92 - }
93 -
94 - public function has_widget_inner_wrapper(): bool {
95 - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
96 - }
97 -
98 - /**
99 77 * Register image box widget controls.
100 78 *
101 79 * Adds different input fields to allow the user to change and customize the widget settings.
102 80 *
@@ -267,10 +245,10 @@
267 245 [
268 246 'label' => esc_html__( 'Alignment', 'elementor' ),
269 247 'type' => Controls_Manager::CHOOSE,
270 248 'options' => [
271 - 'start' => [
272 - 'title' => esc_html__( 'Start', 'elementor' ),
249 + 'left' => [
250 + 'title' => esc_html__( 'Left', 'elementor' ),
273 251 'icon' => 'eicon-text-align-left',
274 252 ],
275 253 'center' => [
276 254 'title' => esc_html__( 'Center', 'elementor' ),
@@ -275,10 +253,10 @@
275 253 'center' => [
276 254 'title' => esc_html__( 'Center', 'elementor' ),
277 255 'icon' => 'eicon-text-align-center',
278 256 ],
279 - 'end' => [
280 - 'title' => esc_html__( 'End', 'elementor' ),
257 + 'right' => [
258 + 'title' => esc_html__( 'Right', 'elementor' ),
281 259 'icon' => 'eicon-text-align-right',
282 260 ],
283 261 'justify' => [
284 262 'title' => esc_html__( 'Justified', 'elementor' ),
@@ -284,13 +262,8 @@
284 262 'title' => esc_html__( 'Justified', 'elementor' ),
285 263 'icon' => 'eicon-text-align-justify',
286 264 ],
287 265 ],
288 - 'classes' => 'elementor-control-start-end',
289 - 'selectors_dictionary' => [
290 - 'left' => is_rtl() ? 'end' : 'start',
291 - 'right' => is_rtl() ? 'start' : 'end',
292 - ],
293 266 'selectors' => [
294 267 '{{WRAPPER}} .elementor-image-box-wrapper' => 'text-align: {{VALUE}};',
295 268 ],
296 269 'separator' => 'after',
@@ -388,68 +361,8 @@
388 361 ],
389 362 ]
390 363 );
391 364
392 - $this->add_responsive_control(
393 - 'image_height',
394 - [
395 - 'label' => esc_html__( 'Height', 'elementor' ),
396 - 'type' => Controls_Manager::SLIDER,
397 - 'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ],
398 - 'selectors' => [
399 - '{{WRAPPER}} .elementor-image-box-img img' => 'height: {{SIZE}}{{UNIT}};',
400 - ],
401 - ]
402 - );
403 -
404 - $this->add_responsive_control(
405 - 'image_object_fit',
406 - [
407 - 'label' => esc_html__( 'Object Fit', 'elementor' ),
408 - 'type' => Controls_Manager::SELECT,
409 - 'options' => [
410 - '' => esc_html__( 'Default', 'elementor' ),
411 - 'fill' => esc_html__( 'Fill', 'elementor' ),
412 - 'cover' => esc_html__( 'Cover', 'elementor' ),
413 - 'contain' => esc_html__( 'Contain', 'elementor' ),
414 - 'scale-down' => esc_html__( 'Scale Down', 'elementor' ),
415 - ],
416 - 'condition' => [
417 - 'image_height[size]!' => '',
418 - ],
419 - 'selectors' => [
420 - '{{WRAPPER}} .elementor-image-box-img img' => 'object-fit: {{VALUE}};',
421 - ],
422 - ]
423 - );
424 -
425 - $this->add_responsive_control(
426 - 'image_object_position',
427 - [
428 - 'label' => esc_html__( 'Object Position', 'elementor' ),
429 - 'type' => Controls_Manager::SELECT,
430 - 'options' => [
431 - 'center center' => esc_html__( 'Center Center', 'elementor' ),
432 - 'center left' => esc_html__( 'Center Left', 'elementor' ),
433 - 'center right' => esc_html__( 'Center Right', 'elementor' ),
434 - 'top center' => esc_html__( 'Top Center', 'elementor' ),
435 - 'top left' => esc_html__( 'Top Left', 'elementor' ),
436 - 'top right' => esc_html__( 'Top Right', 'elementor' ),
437 - 'bottom center' => esc_html__( 'Bottom Center', 'elementor' ),
438 - 'bottom left' => esc_html__( 'Bottom Left', 'elementor' ),
439 - 'bottom right' => esc_html__( 'Bottom Right', 'elementor' ),
440 - ],
441 - 'default' => 'center center',
442 - 'selectors' => [
443 - '{{WRAPPER}} .elementor-image-box-img img' => 'object-position: {{VALUE}};',
444 - ],
445 - 'condition' => [
446 - 'image_height[size]!' => '',
447 - 'image_object_fit' => [ 'cover', 'contain', 'scale-down' ],
448 - ],
449 - ]
450 - );
451 -
452 365 $this->add_group_control(
453 366 Group_Control_Border::get_type(),
454 367 [
455 368 'name' => 'image_border',
@@ -463,8 +376,9 @@
463 376 [
464 377 'label' => esc_html__( 'Border Radius', 'elementor' ),
465 378 'type' => Controls_Manager::SLIDER,
466 379 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
380 + 'separator' => 'after',
467 381 'selectors' => [
468 382 '{{WRAPPER}} .elementor-image-box-img img' => 'border-radius: {{SIZE}}{{UNIT}};',
469 383 ],
470 384 ]
@@ -469,24 +383,8 @@
469 383 ],
470 384 ]
471 385 );
472 386
473 - $this->add_group_control(
474 - Group_Control_Box_Shadow::get_type(),
475 - [
476 - 'name' => 'image_box_shadow',
477 - 'selector' => '{{WRAPPER}} .elementor-image-box-img img',
478 - ]
479 - );
480 -
481 - $this->add_control(
482 - 'separator_panel_style',
483 - [
484 - 'type' => Controls_Manager::DIVIDER,
485 - 'style' => 'thick',
486 - ]
487 - );
488 -
489 387 $this->start_controls_tabs( 'image_effects' );
490 388
491 389 $this->start_controls_tab(
492 390 'normal',
@@ -607,8 +505,23 @@
607 505 'separator' => 'before',
608 506 ]
609 507 );
610 508
509 + $this->add_control(
510 + 'title_color',
511 + [
512 + 'label' => esc_html__( 'Color', 'elementor' ),
513 + 'type' => Controls_Manager::COLOR,
514 + 'default' => '',
515 + 'selectors' => [
516 + '{{WRAPPER}} .elementor-image-box-title' => 'color: {{VALUE}};',
517 + ],
518 + 'global' => [
519 + 'default' => Global_Colors::COLOR_PRIMARY,
520 + ],
521 + ]
522 + );
523 +
611 524 $this->add_group_control(
612 525 Group_Control_Typography::get_type(),
613 526 [
614 527 'name' => 'title_typography',
@@ -634,85 +547,32 @@
634 547 'selector' => '{{WRAPPER}} .elementor-image-box-title',
635 548 ]
636 549 );
637 550
638 - $this->start_controls_tabs( 'image_box_title_colors' );
639 -
640 - $this->start_controls_tab(
641 - 'image_box_title_colors_normal',
642 - [
643 - 'label' => esc_html__( 'Normal', 'elementor' ),
644 - ]
645 - );
646 -
647 551 $this->add_control(
648 - 'title_color',
552 + 'heading_description',
649 553 [
650 - 'label' => esc_html__( 'Color', 'elementor' ),
651 - 'type' => Controls_Manager::COLOR,
652 - 'default' => '',
653 - 'selectors' => [
654 - '{{WRAPPER}} .elementor-image-box-title' => 'color: {{VALUE}};',
655 - ],
656 - 'global' => [
657 - 'default' => Global_Colors::COLOR_PRIMARY,
658 - ],
554 + 'label' => esc_html__( 'Description', 'elementor' ),
555 + 'type' => Controls_Manager::HEADING,
556 + 'separator' => 'before',
659 557 ]
660 558 );
661 559
662 - $this->end_controls_tab();
663 -
664 - $this->start_controls_tab(
665 - 'image_box_title_colors_hover',
666 - [
667 - 'label' => esc_html__( 'Hover', 'elementor' ),
668 - ]
669 - );
670 -
671 560 $this->add_control(
672 - 'hover_title_color',
561 + 'description_color',
673 562 [
674 563 'label' => esc_html__( 'Color', 'elementor' ),
675 564 'type' => Controls_Manager::COLOR,
676 565 'default' => '',
677 566 'selectors' => [
678 - '{{WRAPPER}}:has(:hover) .elementor-image-box-title,
679 - {{WRAPPER}}:has(:focus) .elementor-image-box-title' => 'color: {{VALUE}};',
567 + '{{WRAPPER}} .elementor-image-box-description' => 'color: {{VALUE}};',
680 568 ],
681 569 'global' => [
682 - 'default' => Global_Colors::COLOR_PRIMARY,
570 + 'default' => Global_Colors::COLOR_TEXT,
683 571 ],
684 572 ]
685 573 );
686 574
687 - $this->add_control(
688 - 'hover_title_color_transition_duration',
689 - [
690 - 'label' => esc_html__( 'Transition Duration', 'elementor' ),
691 - 'type' => Controls_Manager::SLIDER,
692 - 'size_units' => [ 's', 'ms', 'custom' ],
693 - 'default' => [
694 - 'unit' => 's',
695 - ],
696 - 'selectors' => [
697 - '{{WRAPPER}} .elementor-image-box-title' => 'transition-duration: {{SIZE}}{{UNIT}};',
698 - ],
699 - ]
700 - );
701 -
702 - $this->end_controls_tab();
703 -
704 - $this->end_controls_tabs();
705 -
706 - $this->add_control(
707 - 'heading_description',
708 - [
709 - 'label' => esc_html__( 'Description', 'elementor' ),
710 - 'type' => Controls_Manager::HEADING,
711 - 'separator' => 'before',
712 - ]
713 - );
714 -
715 575 $this->add_group_control(
716 576 Group_Control_Typography::get_type(),
717 577 [
718 578 'name' => 'description_typography',
@@ -730,23 +590,8 @@
730 590 'selector' => '{{WRAPPER}} .elementor-image-box-description',
731 591 ]
732 592 );
733 593
734 - $this->add_control(
735 - 'description_color',
736 - [
737 - 'label' => esc_html__( 'Color', 'elementor' ),
738 - 'type' => Controls_Manager::COLOR,
739 - 'default' => '',
740 - 'selectors' => [
741 - '{{WRAPPER}} .elementor-image-box-description' => 'color: {{VALUE}};',
742 - ],
743 - 'global' => [
744 - 'default' => Global_Colors::COLOR_TEXT,
745 - ],
746 - ]
747 - );
748 -
749 594 $this->end_controls_section();
750 595 }
751 596
752 597 /**
@@ -759,18 +604,10 @@
759 604 */
760 605 protected function render() {
761 606 $settings = $this->get_settings_for_display();
762 607
763 - $description_text = wp_kses_post( $settings['description_text'] );
764 - $title_text = wp_kses_post( $settings['title_text'] );
608 + $has_content = ! Utils::is_empty( $settings['title_text'] ) || ! Utils::is_empty( $settings['description_text'] );
765 609
766 - $has_image = ! empty( $settings['image']['url'] );
767 - $has_content = ! Utils::is_empty( $title_text ) || ! Utils::is_empty( $description_text );
768 -
769 - if ( ! $has_image && ! $has_content ) {
770 - return;
771 - }
772 -
773 610 $html = '<div class="elementor-image-box-wrapper">';
774 611
775 612 if ( ! empty( $settings['link']['url'] ) ) {
776 613 $this->add_link_attributes( 'link', $settings['link'] );
@@ -775,9 +612,9 @@
775 612 if ( ! empty( $settings['link']['url'] ) ) {
776 613 $this->add_link_attributes( 'link', $settings['link'] );
777 614 }
778 615
779 - if ( $has_image ) {
616 + if ( ! empty( $settings['image']['url'] ) ) {
780 617
781 618 $image_html = wp_kses_post( Group_Control_Image_Size::get_attachment_image_html( $settings, 'thumbnail', 'image' ) );
782 619
783 620 if ( ! empty( $settings['link']['url'] ) ) {
@@ -789,27 +626,28 @@
789 626
790 627 if ( $has_content ) {
791 628 $html .= '<div class="elementor-image-box-content">';
792 629
793 - if ( ! Utils::is_empty( $title_text ) ) {
794 - $title_html = $title_text;
630 + if ( ! Utils::is_empty( $settings['title_text'] ) ) {
795 631 $this->add_render_attribute( 'title_text', 'class', 'elementor-image-box-title' );
796 632
797 633 $this->add_inline_editing_attributes( 'title_text', 'none' );
798 634
635 + $title_html = $settings['title_text'];
636 +
799 637 if ( ! empty( $settings['link']['url'] ) ) {
800 - $title_html = '<a ' . $this->get_render_attribute_string( 'link' ) . '>' . $title_text . '</a>';
638 + $title_html = '<a ' . $this->get_render_attribute_string( 'link' ) . '>' . $title_html . '</a>';
801 639 }
802 640
803 641 $html .= sprintf( '<%1$s %2$s>%3$s</%1$s>', Utils::validate_html_tag( $settings['title_size'] ), $this->get_render_attribute_string( 'title_text' ), $title_html );
804 642 }
805 643
806 - if ( ! Utils::is_empty( $description_text ) ) {
644 + if ( ! Utils::is_empty( $settings['description_text'] ) ) {
807 645 $this->add_render_attribute( 'description_text', 'class', 'elementor-image-box-description' );
808 646
809 647 $this->add_inline_editing_attributes( 'description_text' );
810 648
811 - $html .= sprintf( '<p %1$s>%2$s</p>', $this->get_render_attribute_string( 'description_text' ), $description_text );
649 + $html .= sprintf( '<p %1$s>%2$s</p>', $this->get_render_attribute_string( 'description_text' ), $settings['description_text'] );
812 650 }
813 651
814 652 $html .= '</div>';
815 653 }
@@ -829,21 +667,11 @@
829 667 */
830 668 protected function content_template() {
831 669 ?>
832 670 <#
833 - const titleText = elementor.helpers.sanitize( settings.title_text, { ALLOW_DATA_ATTR: false } )
834 - const descriptionText = elementor.helpers.sanitize( settings.description_text, { ALLOW_DATA_ATTR: false } )
835 -
836 - var hasImage = !! settings.image.url;
837 - var hasContent = !! ( titleText || descriptionText );
838 -
839 - if ( ! hasImage && ! hasContent ) {
840 - return;
841 - }
842 -
843 671 var html = '<div class="elementor-image-box-wrapper">';
844 672
845 - if ( hasImage ) {
673 + if ( settings.image.url ) {
846 674 var image = {
847 675 id: settings.image.id,
848 676 url: settings.image.url,
849 677 size: settings.thumbnail_size,
@@ -852,25 +680,28 @@
852 680 };
853 681
854 682 var image_url = elementor.imagesManager.getImageUrl( image );
855 683
856 - var imageHtml = '<img src="' + _.escape( image_url ) + '" class="elementor-animation-' + _.escape( settings.hover_animation ) + '" />';
684 + var imageHtml = '<img src="' + _.escape( image_url ) + '" class="elementor-animation-' + settings.hover_animation + '" />';
857 685
858 - if ( settings.link?.url ) {
859 - imageHtml = '<a href="' + elementor.helpers.sanitizeUrl( settings.link?.url ) + '" tabindex="-1">' + imageHtml + '</a>';
686 + if ( settings.link.url ) {
687 + imageHtml = '<a href="' + _.escape( settings.link.url ) + '" tabindex="-1">' + imageHtml + '</a>';
860 688 }
861 689
862 690 html += '<figure class="elementor-image-box-img">' + imageHtml + '</figure>';
863 691 }
864 692
693 + var hasContent = !! ( settings.title_text || settings.description_text );
694 +
865 695 if ( hasContent ) {
866 696 html += '<div class="elementor-image-box-content">';
867 697
868 - if ( titleText ) {
869 - var titleSizeTag = elementor.helpers.validateHTMLTag( settings.title_size );
698 + if ( settings.title_text ) {
699 + var title_html = settings.title_text,
700 + titleSizeTag = elementor.helpers.validateHTMLTag( settings.title_size );
870 701
871 - if ( settings.link?.url ) {
872 - title_html = '<a href="' + elementor.helpers.sanitizeUrl( settings.link?.url ) + '">' + titleText + '</a>';
702 + if ( settings.link.url ) {
703 + title_html = '<a href="' + _.escape( settings.link.url ) + '">' + title_html + '</a>';
873 704 }
874 705
875 706 view.addRenderAttribute( 'title_text', 'class', 'elementor-image-box-title' );
876 707
@@ -875,17 +706,17 @@
875 706 view.addRenderAttribute( 'title_text', 'class', 'elementor-image-box-title' );
876 707
877 708 view.addInlineEditingAttributes( 'title_text', 'none' );
878 709
879 - html += '<' + titleSizeTag + ' ' + view.getRenderAttributeString( 'title_text' ) + '>' + titleText + '</' + titleSizeTag + '>';
710 + html += '<' + titleSizeTag + ' ' + view.getRenderAttributeString( 'title_text' ) + '>' + title_html + '</' + titleSizeTag + '>';
880 711 }
881 712
882 - if ( descriptionText ) {
713 + if ( settings.description_text ) {
883 714 view.addRenderAttribute( 'description_text', 'class', 'elementor-image-box-description' );
884 715
885 716 view.addInlineEditingAttributes( 'description_text' );
886 717
887 - html += '<p ' + view.getRenderAttributeString( 'description_text' ) + '>' + descriptionText + '</p>';
718 + html += '<p ' + view.getRenderAttributeString( 'description_text' ) + '>' + settings.description_text + '</p>';
888 719 }
889 720
890 721 html += '</div>';
891 722 }
@@ -894,31 +725,6 @@
894 725
895 726 print( html );
896 727 #>
897 728 <?php
898 - }
899 -
900 - public function render_markdown(): string {
901 - $settings = $this->get_settings_for_display();
902 - $title = Utils::html_to_plain_text( $settings['title_text'] ?? '' );
903 - $description = Utils::html_to_plain_text( $settings['description_text'] ?? '' );
904 - $image_url = $settings['image']['url'] ?? '';
905 - if ( empty( $title ) && empty( $description ) && empty( $image_url ) ) {
906 - return '';
907 - }
908 - $parts = [];
909 - if ( ! empty( $image_url ) ) {
910 - $parts[] = '![' . $title . '](' . esc_url( $image_url ) . ')';
911 - }
912 - if ( ! empty( $title ) ) {
913 - if ( ! empty( $settings['link']['url'] ) ) {
914 - $parts[] = '### [' . $title . '](' . esc_url( $settings['link']['url'] ) . ')';
915 - } else {
916 - $parts[] = '### ' . $title;
917 - }
918 - }
919 - if ( ! empty( $description ) ) {
920 - $parts[] = $description;
921 - }
922 - return implode( "\n\n", $parts );
923 729 }
924 730 }