PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev3
Elementor Website Builder – more than just a page builder v3.23.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 +45 -225 4.2.13.23.0-dev3 View file →
@@ -77,26 +77,8 @@
77 77 return false;
78 78 }
79 79
80 80 /**
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 81 * Register image box widget controls.
100 82 *
101 83 * Adds different input fields to allow the user to change and customize the widget settings.
102 84 *
@@ -267,10 +249,10 @@
267 249 [
268 250 'label' => esc_html__( 'Alignment', 'elementor' ),
269 251 'type' => Controls_Manager::CHOOSE,
270 252 'options' => [
271 - 'start' => [
272 - 'title' => esc_html__( 'Start', 'elementor' ),
253 + 'left' => [
254 + 'title' => esc_html__( 'Left', 'elementor' ),
273 255 'icon' => 'eicon-text-align-left',
274 256 ],
275 257 'center' => [
276 258 'title' => esc_html__( 'Center', 'elementor' ),
@@ -275,10 +257,10 @@
275 257 'center' => [
276 258 'title' => esc_html__( 'Center', 'elementor' ),
277 259 'icon' => 'eicon-text-align-center',
278 260 ],
279 - 'end' => [
280 - 'title' => esc_html__( 'End', 'elementor' ),
261 + 'right' => [
262 + 'title' => esc_html__( 'Right', 'elementor' ),
281 263 'icon' => 'eicon-text-align-right',
282 264 ],
283 265 'justify' => [
284 266 'title' => esc_html__( 'Justified', 'elementor' ),
@@ -284,13 +266,8 @@
284 266 'title' => esc_html__( 'Justified', 'elementor' ),
285 267 'icon' => 'eicon-text-align-justify',
286 268 ],
287 269 ],
288 - 'classes' => 'elementor-control-start-end',
289 - 'selectors_dictionary' => [
290 - 'left' => is_rtl() ? 'end' : 'start',
291 - 'right' => is_rtl() ? 'start' : 'end',
292 - ],
293 270 'selectors' => [
294 271 '{{WRAPPER}} .elementor-image-box-wrapper' => 'text-align: {{VALUE}};',
295 272 ],
296 273 'separator' => 'after',
@@ -388,68 +365,8 @@
388 365 ],
389 366 ]
390 367 );
391 368
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 369 $this->add_group_control(
453 370 Group_Control_Border::get_type(),
454 371 [
455 372 'name' => 'image_border',
@@ -463,8 +380,9 @@
463 380 [
464 381 'label' => esc_html__( 'Border Radius', 'elementor' ),
465 382 'type' => Controls_Manager::SLIDER,
466 383 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
384 + 'separator' => 'after',
467 385 'selectors' => [
468 386 '{{WRAPPER}} .elementor-image-box-img img' => 'border-radius: {{SIZE}}{{UNIT}};',
469 387 ],
470 388 ]
@@ -469,24 +387,8 @@
469 387 ],
470 388 ]
471 389 );
472 390
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 391 $this->start_controls_tabs( 'image_effects' );
490 392
491 393 $this->start_controls_tab(
492 394 'normal',
@@ -607,8 +509,23 @@
607 509 'separator' => 'before',
608 510 ]
609 511 );
610 512
513 + $this->add_control(
514 + 'title_color',
515 + [
516 + 'label' => esc_html__( 'Color', 'elementor' ),
517 + 'type' => Controls_Manager::COLOR,
518 + 'default' => '',
519 + 'selectors' => [
520 + '{{WRAPPER}} .elementor-image-box-title' => 'color: {{VALUE}};',
521 + ],
522 + 'global' => [
523 + 'default' => Global_Colors::COLOR_PRIMARY,
524 + ],
525 + ]
526 + );
527 +
611 528 $this->add_group_control(
612 529 Group_Control_Typography::get_type(),
613 530 [
614 531 'name' => 'title_typography',
@@ -634,85 +551,32 @@
634 551 'selector' => '{{WRAPPER}} .elementor-image-box-title',
635 552 ]
636 553 );
637 554
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 555 $this->add_control(
648 - 'title_color',
556 + 'heading_description',
649 557 [
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 - ],
558 + 'label' => esc_html__( 'Description', 'elementor' ),
559 + 'type' => Controls_Manager::HEADING,
560 + 'separator' => 'before',
659 561 ]
660 562 );
661 563
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 564 $this->add_control(
672 - 'hover_title_color',
565 + 'description_color',
673 566 [
674 567 'label' => esc_html__( 'Color', 'elementor' ),
675 568 'type' => Controls_Manager::COLOR,
676 569 'default' => '',
677 570 'selectors' => [
678 - '{{WRAPPER}}:has(:hover) .elementor-image-box-title,
679 - {{WRAPPER}}:has(:focus) .elementor-image-box-title' => 'color: {{VALUE}};',
571 + '{{WRAPPER}} .elementor-image-box-description' => 'color: {{VALUE}};',
680 572 ],
681 573 'global' => [
682 - 'default' => Global_Colors::COLOR_PRIMARY,
574 + 'default' => Global_Colors::COLOR_TEXT,
683 575 ],
684 576 ]
685 577 );
686 578
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 579 $this->add_group_control(
716 580 Group_Control_Typography::get_type(),
717 581 [
718 582 'name' => 'description_typography',
@@ -730,23 +594,8 @@
730 594 'selector' => '{{WRAPPER}} .elementor-image-box-description',
731 595 ]
732 596 );
733 597
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 598 $this->end_controls_section();
750 599 }
751 600
752 601 /**
@@ -759,13 +608,10 @@
759 608 */
760 609 protected function render() {
761 610 $settings = $this->get_settings_for_display();
762 611
763 - $description_text = wp_kses_post( $settings['description_text'] );
764 - $title_text = wp_kses_post( $settings['title_text'] );
765 -
766 612 $has_image = ! empty( $settings['image']['url'] );
767 - $has_content = ! Utils::is_empty( $title_text ) || ! Utils::is_empty( $description_text );
613 + $has_content = ! Utils::is_empty( $settings['title_text'] ) || ! Utils::is_empty( $settings['description_text'] );
768 614
769 615 if ( ! $has_image && ! $has_content ) {
770 616 return;
771 617 }
@@ -789,27 +635,28 @@
789 635
790 636 if ( $has_content ) {
791 637 $html .= '<div class="elementor-image-box-content">';
792 638
793 - if ( ! Utils::is_empty( $title_text ) ) {
794 - $title_html = $title_text;
639 + if ( ! Utils::is_empty( $settings['title_text'] ) ) {
795 640 $this->add_render_attribute( 'title_text', 'class', 'elementor-image-box-title' );
796 641
797 642 $this->add_inline_editing_attributes( 'title_text', 'none' );
798 643
644 + $title_html = $settings['title_text'];
645 +
799 646 if ( ! empty( $settings['link']['url'] ) ) {
800 - $title_html = '<a ' . $this->get_render_attribute_string( 'link' ) . '>' . $title_text . '</a>';
647 + $title_html = '<a ' . $this->get_render_attribute_string( 'link' ) . '>' . $title_html . '</a>';
801 648 }
802 649
803 650 $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 651 }
805 652
806 - if ( ! Utils::is_empty( $description_text ) ) {
653 + if ( ! Utils::is_empty( $settings['description_text'] ) ) {
807 654 $this->add_render_attribute( 'description_text', 'class', 'elementor-image-box-description' );
808 655
809 656 $this->add_inline_editing_attributes( 'description_text' );
810 657
811 - $html .= sprintf( '<p %1$s>%2$s</p>', $this->get_render_attribute_string( 'description_text' ), $description_text );
658 + $html .= sprintf( '<p %1$s>%2$s</p>', $this->get_render_attribute_string( 'description_text' ), $settings['description_text'] );
812 659 }
813 660
814 661 $html .= '</div>';
815 662 }
@@ -829,13 +676,10 @@
829 676 */
830 677 protected function content_template() {
831 678 ?>
832 679 <#
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 680 var hasImage = !! settings.image.url;
837 - var hasContent = !! ( titleText || descriptionText );
681 + var hasContent = !! ( settings.title_text || settings.description_text );
838 682
839 683 if ( ! hasImage && ! hasContent ) {
840 684 return;
841 685 }
@@ -854,10 +698,10 @@
854 698 var image_url = elementor.imagesManager.getImageUrl( image );
855 699
856 700 var imageHtml = '<img src="' + _.escape( image_url ) + '" class="elementor-animation-' + _.escape( settings.hover_animation ) + '" />';
857 701
858 - if ( settings.link?.url ) {
859 - imageHtml = '<a href="' + elementor.helpers.sanitizeUrl( settings.link?.url ) + '" tabindex="-1">' + imageHtml + '</a>';
702 + if ( settings.link.url ) {
703 + imageHtml = '<a href="' + _.escape( settings.link.url ) + '" tabindex="-1">' + imageHtml + '</a>';
860 704 }
861 705
862 706 html += '<figure class="elementor-image-box-img">' + imageHtml + '</figure>';
863 707 }
@@ -864,13 +708,14 @@
864 708
865 709 if ( hasContent ) {
866 710 html += '<div class="elementor-image-box-content">';
867 711
868 - if ( titleText ) {
869 - var titleSizeTag = elementor.helpers.validateHTMLTag( settings.title_size );
712 + if ( settings.title_text ) {
713 + var title_html = elementor.helpers.sanitize( settings.title_text ),
714 + titleSizeTag = elementor.helpers.validateHTMLTag( settings.title_size );
870 715
871 - if ( settings.link?.url ) {
872 - title_html = '<a href="' + elementor.helpers.sanitizeUrl( settings.link?.url ) + '">' + titleText + '</a>';
716 + if ( settings.link.url ) {
717 + title_html = '<a href="' + _.escape( settings.link.url ) + '">' + title_html + '</a>';
873 718 }
874 719
875 720 view.addRenderAttribute( 'title_text', 'class', 'elementor-image-box-title' );
876 721
@@ -875,17 +720,17 @@
875 720 view.addRenderAttribute( 'title_text', 'class', 'elementor-image-box-title' );
876 721
877 722 view.addInlineEditingAttributes( 'title_text', 'none' );
878 723
879 - html += '<' + titleSizeTag + ' ' + view.getRenderAttributeString( 'title_text' ) + '>' + titleText + '</' + titleSizeTag + '>';
724 + html += '<' + titleSizeTag + ' ' + view.getRenderAttributeString( 'title_text' ) + '>' + title_html + '</' + titleSizeTag + '>';
880 725 }
881 726
882 - if ( descriptionText ) {
727 + if ( settings.description_text ) {
883 728 view.addRenderAttribute( 'description_text', 'class', 'elementor-image-box-description' );
884 729
885 730 view.addInlineEditingAttributes( 'description_text' );
886 731
887 - html += '<p ' + view.getRenderAttributeString( 'description_text' ) + '>' + descriptionText + '</p>';
732 + html += '<p ' + view.getRenderAttributeString( 'description_text' ) + '>' + settings.description_text + '</p>';
888 733 }
889 734
890 735 html += '</div>';
891 736 }
@@ -894,31 +739,6 @@
894 739
895 740 print( html );
896 741 #>
897 742 <?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 743 }
924 744 }