PluginProbe
Elementor Website Builder – more than just a page builder / 3.17.2
Elementor Website Builder – more than just a page builder v3.17.2
4.3.0-beta3 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 All 452 releases
← All changes | includes/widgets/image-carousel.php +43 -165 4.2.23.17.2 View file →
@@ -5,9 +5,8 @@
5 5 exit; // Exit if accessed directly.
6 6 }
7 7
8 8 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
9 -use Elementor\Modules\Promotions\Controls\Promotion_Control;
10 9
11 10 /**
12 11 * Elementor image carousel widget.
13 12 *
@@ -73,66 +72,9 @@
73 72 public function get_keywords() {
74 73 return [ 'image', 'photo', 'visual', 'carousel', 'slider' ];
75 74 }
76 75
77 - protected function is_dynamic_content(): bool {
78 - return false;
79 - }
80 -
81 76 /**
82 - * Get style dependencies.
83 - *
84 - * Retrieve the list of style dependencies the widget requires.
85 - *
86 - * @since 3.24.0
87 - * @access public
88 - *
89 - * @return array Widget style dependencies.
90 - */
91 - public function get_style_depends(): array {
92 - return [ 'e-swiper', 'widget-image-carousel' ];
93 - }
94 -
95 - /**
96 - * Get script dependencies.
97 - *
98 - * Retrieve the list of script dependencies the widget requires.
99 - *
100 - * @since 3.27.0
101 - * @access public
102 - *
103 - * @return array Widget script dependencies.
104 - */
105 - public function get_script_depends(): array {
106 - return [ 'swiper' ];
107 - }
108 -
109 - public function has_widget_inner_wrapper(): bool {
110 - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
111 - }
112 -
113 - /**
114 - * Get widget upsale data.
115 - *
116 - * Retrieve the widget promotion data.
117 - *
118 - * @since 3.18.0
119 - * @access protected
120 - *
121 - * @return array Widget promotion data.
122 - */
123 - protected function get_upsale_data() {
124 - return [
125 - 'condition' => ! Utils::has_pro(),
126 - 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ),
127 - 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ),
128 - 'description' => esc_html__( 'Gain complete freedom to design every slide with Elementor"s Pro Carousel.', 'elementor' ),
129 - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-image-carousel-widget/' ),
130 - 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ),
131 - ];
132 - }
133 -
134 - /**
135 77 * Register image carousel widget controls.
136 78 *
137 79 * Adds different input fields to allow the user to change and customize the widget settings.
138 80 *
@@ -147,17 +89,8 @@
147 89 ]
148 90 );
149 91
150 92 $this->add_control(
151 - 'carousel_name',
152 - [
153 - 'label' => esc_html__( 'Carousel Name', 'elementor' ),
154 - 'type' => Controls_Manager::TEXT,
155 - 'default' => esc_html__( 'Image Carousel', 'elementor' ),
156 - ]
157 - );
158 -
159 - $this->add_control(
160 93 'carousel',
161 94 [
162 95 'label' => esc_html__( 'Add Images', 'elementor' ),
163 96 'type' => Controls_Manager::GALLERY,
@@ -172,8 +105,9 @@
172 105 $this->add_group_control(
173 106 Group_Control_Image_Size::get_type(),
174 107 [
175 108 'name' => 'thumbnail', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `thumbnail_size` and `thumbnail_custom_dimension`.
109 + 'separator' => 'none',
176 110 ]
177 111 );
178 112
179 113 $slides_to_show = range( 1, 10 );
@@ -418,8 +352,17 @@
418 352 ],
419 353 ]
420 354 );
421 355
356 + $this->add_control(
357 + 'view',
358 + [
359 + 'label' => esc_html__( 'View', 'elementor' ),
360 + 'type' => Controls_Manager::HIDDEN,
361 + 'default' => 'traditional',
362 + ]
363 + );
364 +
422 365 $this->end_controls_section();
423 366
424 367 $this->start_controls_section(
425 368 'section_additional_options',
@@ -440,13 +383,14 @@
440 383 $this->add_control(
441 384 'autoplay',
442 385 [
443 386 'label' => esc_html__( 'Autoplay', 'elementor' ),
444 - 'type' => Controls_Manager::SWITCHER,
445 - 'label_on' => esc_html__( 'Yes', 'elementor' ),
446 - 'label_off' => esc_html__( 'No', 'elementor' ),
447 - 'return_value' => 'yes',
387 + 'type' => Controls_Manager::SELECT,
448 388 'default' => 'yes',
389 + 'options' => [
390 + 'yes' => esc_html__( 'Yes', 'elementor' ),
391 + 'no' => esc_html__( 'No', 'elementor' ),
392 + ],
449 393 'frontend_available' => true,
450 394 ]
451 395 );
452 396
@@ -453,13 +397,14 @@
453 397 $this->add_control(
454 398 'pause_on_hover',
455 399 [
456 400 'label' => esc_html__( 'Pause on Hover', 'elementor' ),
457 - 'type' => Controls_Manager::SWITCHER,
458 - 'label_on' => esc_html__( 'Yes', 'elementor' ),
459 - 'label_off' => esc_html__( 'No', 'elementor' ),
460 - 'return_value' => 'yes',
401 + 'type' => Controls_Manager::SELECT,
461 402 'default' => 'yes',
403 + 'options' => [
404 + 'yes' => esc_html__( 'Yes', 'elementor' ),
405 + 'no' => esc_html__( 'No', 'elementor' ),
406 + ],
462 407 'condition' => [
463 408 'autoplay' => 'yes',
464 409 ],
465 410 'render_type' => 'none',
@@ -470,13 +415,14 @@
470 415 $this->add_control(
471 416 'pause_on_interaction',
472 417 [
473 418 'label' => esc_html__( 'Pause on Interaction', 'elementor' ),
474 - 'type' => Controls_Manager::SWITCHER,
475 - 'label_on' => esc_html__( 'Yes', 'elementor' ),
476 - 'label_off' => esc_html__( 'No', 'elementor' ),
477 - 'return_value' => 'yes',
419 + 'type' => Controls_Manager::SELECT,
478 420 'default' => 'yes',
421 + 'options' => [
422 + 'yes' => esc_html__( 'Yes', 'elementor' ),
423 + 'no' => esc_html__( 'No', 'elementor' ),
424 + ],
479 425 'condition' => [
480 426 'autoplay' => 'yes',
481 427 ],
482 428 'frontend_available' => true,
@@ -501,13 +447,14 @@
501 447 $this->add_control(
502 448 'infinite',
503 449 [
504 450 'label' => esc_html__( 'Infinite Loop', 'elementor' ),
505 - 'type' => Controls_Manager::SWITCHER,
506 - 'label_on' => esc_html__( 'Yes', 'elementor' ),
507 - 'label_off' => esc_html__( 'No', 'elementor' ),
508 - 'return_value' => 'yes',
451 + 'type' => Controls_Manager::SELECT,
509 452 'default' => 'yes',
453 + 'options' => [
454 + 'yes' => esc_html__( 'Yes', 'elementor' ),
455 + 'no' => esc_html__( 'No', 'elementor' ),
456 + ],
510 457 'frontend_available' => true,
511 458 ]
512 459 );
513 460
@@ -593,17 +540,17 @@
593 540 ],
594 541 ]
595 542 );
596 543
597 - $this->add_responsive_control(
544 + $this->add_control(
598 545 'arrows_size',
599 546 [
600 547 'label' => esc_html__( 'Size', 'elementor' ),
601 548 'type' => Controls_Manager::SLIDER,
602 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
603 549 'range' => [
604 550 'px' => [
605 - 'max' => 100,
551 + 'min' => 20,
552 + 'max' => 60,
606 553 ],
607 554 ],
608 555 'selectors' => [
609 556 '{{WRAPPER}} .elementor-swiper-button.elementor-swiper-button-prev, {{WRAPPER}} .elementor-swiper-button.elementor-swiper-button-next' => 'font-size: {{SIZE}}{{UNIT}};',
@@ -657,37 +604,17 @@
657 604 ],
658 605 ]
659 606 );
660 607
661 - $this->add_responsive_control(
662 - 'dots_gap',
663 - [
664 - 'label' => esc_html__( 'Space Between Dots', 'elementor' ),
665 - 'type' => Controls_Manager::SLIDER,
666 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
667 - 'range' => [
668 - 'px' => [
669 - 'max' => 20,
670 - ],
671 - ],
672 - 'selectors' => [
673 - '{{WRAPPER}} .swiper-pagination-bullet' => '--swiper-pagination-bullet-horizontal-gap: {{SIZE}}{{UNIT}}; --swiper-pagination-bullet-vertical-gap: {{SIZE}}{{UNIT}};',
674 - ],
675 - 'condition' => [
676 - 'navigation' => [ 'dots', 'both' ],
677 - ],
678 - ]
679 - );
680 -
681 - $this->add_responsive_control(
608 + $this->add_control(
682 609 'dots_size',
683 610 [
684 611 'label' => esc_html__( 'Size', 'elementor' ),
685 612 'type' => Controls_Manager::SLIDER,
686 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
687 613 'range' => [
688 614 'px' => [
689 - 'max' => 20,
615 + 'min' => 5,
616 + 'max' => 10,
690 617 ],
691 618 ],
692 619 'selectors' => [
693 620 '{{WRAPPER}} .swiper-pagination-bullet' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
@@ -785,9 +712,8 @@
785 712 'image_spacing_custom',
786 713 [
787 714 'label' => esc_html__( 'Image Spacing', 'elementor' ),
788 715 'type' => Controls_Manager::SLIDER,
789 - 'size_units' => [ 'px' ],
790 716 'range' => [
791 717 'px' => [
792 718 'max' => 100,
793 719 ],
@@ -843,10 +769,10 @@
843 769 [
844 770 'label' => esc_html__( 'Alignment', 'elementor' ),
845 771 'type' => Controls_Manager::CHOOSE,
846 772 'options' => [
847 - 'start' => [
848 - 'title' => esc_html__( 'Start', 'elementor' ),
773 + 'left' => [
774 + 'title' => esc_html__( 'Left', 'elementor' ),
849 775 'icon' => 'eicon-text-align-left',
850 776 ],
851 777 'center' => [
852 778 'title' => esc_html__( 'Center', 'elementor' ),
@@ -851,10 +777,10 @@
851 777 'center' => [
852 778 'title' => esc_html__( 'Center', 'elementor' ),
853 779 'icon' => 'eicon-text-align-center',
854 780 ],
855 - 'end' => [
856 - 'title' => esc_html__( 'End', 'elementor' ),
781 + 'right' => [
782 + 'title' => esc_html__( 'Right', 'elementor' ),
857 783 'icon' => 'eicon-text-align-right',
858 784 ],
859 785 'justify' => [
860 786 'title' => esc_html__( 'Justified', 'elementor' ),
@@ -860,13 +786,8 @@
860 786 'title' => esc_html__( 'Justified', 'elementor' ),
861 787 'icon' => 'eicon-text-align-justify',
862 788 ],
863 789 ],
864 - 'classes' => 'elementor-control-start-end',
865 - 'selectors_dictionary' => [
866 - 'left' => is_rtl() ? 'end' : 'start',
867 - 'right' => is_rtl() ? 'start' : 'end',
868 - ],
869 790 'default' => 'center',
870 791 'selectors' => [
871 792 '{{WRAPPER}} .elementor-image-carousel-caption' => 'text-align: {{VALUE}};',
872 793 ],
@@ -903,20 +824,8 @@
903 824 'selector' => '{{WRAPPER}} .elementor-image-carousel-caption',
904 825 ]
905 826 );
906 827
907 - $this->add_responsive_control(
908 - 'caption_space',
909 - [
910 - 'label' => esc_html__( 'Spacing', 'elementor' ),
911 - 'type' => Controls_Manager::SLIDER,
912 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
913 - 'selectors' => [
914 - '{{WRAPPER}} .elementor-image-carousel-caption' => 'margin-block-start: {{SIZE}}{{UNIT}};',
915 - ],
916 - ]
917 - );
918 -
919 828 $this->end_controls_section();
920 829 }
921 830
922 831 /**
@@ -1013,9 +922,9 @@
1013 922 if ( empty( $slides ) ) {
1014 923 return;
1015 924 }
1016 925
1017 - $swiper_class = 'swiper';
926 + $swiper_class = Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ) ? 'swiper' : 'swiper-container';
1018 927 $has_autoplay_enabled = 'yes' === $this->get_settings_for_display( 'autoplay' );
1019 928
1020 929 $this->add_render_attribute( [
1021 930 'carousel' => [
@@ -1023,11 +932,8 @@
1023 932 'aria-live' => $has_autoplay_enabled ? 'off' : 'polite',
1024 933 ],
1025 934 'carousel-wrapper' => [
1026 935 'class' => 'elementor-image-carousel-wrapper ' . $swiper_class,
1027 - 'role' => 'region',
1028 - 'aria-roledescription' => 'carousel',
1029 - 'aria-label' => $settings['carousel_name'],
1030 936 'dir' => $settings['direction'],
1031 937 ],
1032 938 ] );
1033 939
@@ -1041,9 +947,9 @@
1041 947 $slides_count = count( $settings['carousel'] );
1042 948 ?>
1043 949 <div <?php $this->print_render_attribute_string( 'carousel-wrapper' ); ?>>
1044 950 <div <?php $this->print_render_attribute_string( 'carousel' ); ?>>
1045 - <?php // PHPCS - $slides contains the slides content, all the relevant content is escaped above. ?>
951 + <?php // PHPCS - $slides contains the slides content, all the relevent content is escaped above. ?>
1046 952 <?php echo implode( '', $slides ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1047 953 </div>
1048 954 <?php if ( 1 < $slides_count ) : ?>
1049 955 <?php if ( $show_arrows ) : ?>
@@ -1068,9 +974,9 @@
1068 974 *
1069 975 * @since 1.0.0
1070 976 * @access private
1071 977 *
1072 - * @param array $attachment
978 + * @param array $attachment
1073 979 * @param object $instance
1074 980 *
1075 981 * @return array|string|false An array/string containing the attachment URL, or false if no link.
1076 982 */
@@ -1110,12 +1016,8 @@
1110 1016 }
1111 1017
1112 1018 $attachment_post = get_post( $attachment['id'] );
1113 1019
1114 - if ( Utils::has_invalid_post_permissions( $attachment_post ) ) {
1115 - return '';
1116 - }
1117 -
1118 1020 if ( 'caption' === $caption_type ) {
1119 1021 return $attachment_post->post_excerpt;
1120 1022 }
1121 1023
@@ -1122,12 +1024,8 @@
1122 1024 if ( 'title' === $caption_type ) {
1123 1025 return $attachment_post->post_title;
1124 1026 }
1125 1027
1126 - if ( empty( $attachment_post->post_content ) ) {
1127 - return '';
1128 - }
1129 -
1130 1028 return $attachment_post->post_content;
1131 1029 }
1132 1030
1133 1031 private function render_swiper_button( $type ) {
@@ -1141,26 +1039,6 @@
1141 1039 ];
1142 1040 }
1143 1041
1144 1042 Icons_Manager::render_icon( $icon_settings, [ 'aria-hidden' => 'true' ] );
1145 - }
1146 -
1147 - public function render_markdown(): string {
1148 - $settings = $this->get_settings_for_display();
1149 - if ( empty( $settings['carousel'] ) ) {
1150 - return '';
1151 - }
1152 - $images = [];
1153 - foreach ( $settings['carousel'] as $item ) {
1154 - $url = $item['url'] ?? '';
1155 - if ( empty( $url ) ) {
1156 - continue;
1157 - }
1158 - $alt = '';
1159 - if ( ! empty( $item['id'] ) ) {
1160 - $alt = get_post_meta( $item['id'], '_wp_attachment_image_alt', true );
1161 - }
1162 - $images[] = '![' . $alt . '](' . esc_url( $url ) . ')';
1163 - }
1164 - return implode( "\n\n", $images );
1165 1043 }
1166 1044 }