PluginProbe
Elementor Website Builder – more than just a page builder / 3.19.2
Elementor Website Builder – more than just a page builder v3.19.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 +30 -141 4.2.23.19.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,62 +72,12 @@
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 - /**
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 76 protected function get_upsale_data() {
124 77 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 78 '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' ),
79 + 'upgrade_url' => 'https://go.elementor.com/go-pro-image-carousel-widget/',
131 80 ];
132 81 }
133 82
134 83 /**
@@ -147,17 +96,8 @@
147 96 ]
148 97 );
149 98
150 99 $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 100 'carousel',
161 101 [
162 102 'label' => esc_html__( 'Add Images', 'elementor' ),
163 103 'type' => Controls_Manager::GALLERY,
@@ -172,8 +112,9 @@
172 112 $this->add_group_control(
173 113 Group_Control_Image_Size::get_type(),
174 114 [
175 115 'name' => 'thumbnail', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `thumbnail_size` and `thumbnail_custom_dimension`.
116 + 'separator' => 'none',
176 117 ]
177 118 );
178 119
179 120 $slides_to_show = range( 1, 10 );
@@ -440,13 +381,14 @@
440 381 $this->add_control(
441 382 'autoplay',
442 383 [
443 384 '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',
385 + 'type' => Controls_Manager::SELECT,
448 386 'default' => 'yes',
387 + 'options' => [
388 + 'yes' => esc_html__( 'Yes', 'elementor' ),
389 + 'no' => esc_html__( 'No', 'elementor' ),
390 + ],
449 391 'frontend_available' => true,
450 392 ]
451 393 );
452 394
@@ -453,13 +395,14 @@
453 395 $this->add_control(
454 396 'pause_on_hover',
455 397 [
456 398 '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',
399 + 'type' => Controls_Manager::SELECT,
461 400 'default' => 'yes',
401 + 'options' => [
402 + 'yes' => esc_html__( 'Yes', 'elementor' ),
403 + 'no' => esc_html__( 'No', 'elementor' ),
404 + ],
462 405 'condition' => [
463 406 'autoplay' => 'yes',
464 407 ],
465 408 'render_type' => 'none',
@@ -470,13 +413,14 @@
470 413 $this->add_control(
471 414 'pause_on_interaction',
472 415 [
473 416 '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',
417 + 'type' => Controls_Manager::SELECT,
478 418 'default' => 'yes',
419 + 'options' => [
420 + 'yes' => esc_html__( 'Yes', 'elementor' ),
421 + 'no' => esc_html__( 'No', 'elementor' ),
422 + ],
479 423 'condition' => [
480 424 'autoplay' => 'yes',
481 425 ],
482 426 'frontend_available' => true,
@@ -501,13 +445,14 @@
501 445 $this->add_control(
502 446 'infinite',
503 447 [
504 448 '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',
449 + 'type' => Controls_Manager::SELECT,
509 450 'default' => 'yes',
451 + 'options' => [
452 + 'yes' => esc_html__( 'Yes', 'elementor' ),
453 + 'no' => esc_html__( 'No', 'elementor' ),
454 + ],
510 455 'frontend_available' => true,
511 456 ]
512 457 );
513 458
@@ -658,28 +603,8 @@
658 603 ]
659 604 );
660 605
661 606 $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(
682 607 'dots_size',
683 608 [
684 609 'label' => esc_html__( 'Size', 'elementor' ),
685 610 'type' => Controls_Manager::SLIDER,
@@ -785,9 +710,9 @@
785 710 'image_spacing_custom',
786 711 [
787 712 'label' => esc_html__( 'Image Spacing', 'elementor' ),
788 713 'type' => Controls_Manager::SLIDER,
789 - 'size_units' => [ 'px' ],
714 + 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
790 715 'range' => [
791 716 'px' => [
792 717 'max' => 100,
793 718 ],
@@ -843,10 +768,10 @@
843 768 [
844 769 'label' => esc_html__( 'Alignment', 'elementor' ),
845 770 'type' => Controls_Manager::CHOOSE,
846 771 'options' => [
847 - 'start' => [
848 - 'title' => esc_html__( 'Start', 'elementor' ),
772 + 'left' => [
773 + 'title' => esc_html__( 'Left', 'elementor' ),
849 774 'icon' => 'eicon-text-align-left',
850 775 ],
851 776 'center' => [
852 777 'title' => esc_html__( 'Center', 'elementor' ),
@@ -851,10 +776,10 @@
851 776 'center' => [
852 777 'title' => esc_html__( 'Center', 'elementor' ),
853 778 'icon' => 'eicon-text-align-center',
854 779 ],
855 - 'end' => [
856 - 'title' => esc_html__( 'End', 'elementor' ),
780 + 'right' => [
781 + 'title' => esc_html__( 'Right', 'elementor' ),
857 782 'icon' => 'eicon-text-align-right',
858 783 ],
859 784 'justify' => [
860 785 'title' => esc_html__( 'Justified', 'elementor' ),
@@ -860,13 +785,8 @@
860 785 'title' => esc_html__( 'Justified', 'elementor' ),
861 786 'icon' => 'eicon-text-align-justify',
862 787 ],
863 788 ],
864 - 'classes' => 'elementor-control-start-end',
865 - 'selectors_dictionary' => [
866 - 'left' => is_rtl() ? 'end' : 'start',
867 - 'right' => is_rtl() ? 'start' : 'end',
868 - ],
869 789 'default' => 'center',
870 790 'selectors' => [
871 791 '{{WRAPPER}} .elementor-image-carousel-caption' => 'text-align: {{VALUE}};',
872 792 ],
@@ -1013,9 +933,9 @@
1013 933 if ( empty( $slides ) ) {
1014 934 return;
1015 935 }
1016 936
1017 - $swiper_class = 'swiper';
937 + $swiper_class = Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ) ? 'swiper' : 'swiper-container';
1018 938 $has_autoplay_enabled = 'yes' === $this->get_settings_for_display( 'autoplay' );
1019 939
1020 940 $this->add_render_attribute( [
1021 941 'carousel' => [
@@ -1023,11 +943,8 @@
1023 943 'aria-live' => $has_autoplay_enabled ? 'off' : 'polite',
1024 944 ],
1025 945 'carousel-wrapper' => [
1026 946 'class' => 'elementor-image-carousel-wrapper ' . $swiper_class,
1027 - 'role' => 'region',
1028 - 'aria-roledescription' => 'carousel',
1029 - 'aria-label' => $settings['carousel_name'],
1030 947 'dir' => $settings['direction'],
1031 948 ],
1032 949 ] );
1033 950
@@ -1041,9 +958,9 @@
1041 958 $slides_count = count( $settings['carousel'] );
1042 959 ?>
1043 960 <div <?php $this->print_render_attribute_string( 'carousel-wrapper' ); ?>>
1044 961 <div <?php $this->print_render_attribute_string( 'carousel' ); ?>>
1045 - <?php // PHPCS - $slides contains the slides content, all the relevant content is escaped above. ?>
962 + <?php // PHPCS - $slides contains the slides content, all the relevent content is escaped above. ?>
1046 963 <?php echo implode( '', $slides ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1047 964 </div>
1048 965 <?php if ( 1 < $slides_count ) : ?>
1049 966 <?php if ( $show_arrows ) : ?>
@@ -1068,9 +985,9 @@
1068 985 *
1069 986 * @since 1.0.0
1070 987 * @access private
1071 988 *
1072 - * @param array $attachment
989 + * @param array $attachment
1073 990 * @param object $instance
1074 991 *
1075 992 * @return array|string|false An array/string containing the attachment URL, or false if no link.
1076 993 */
@@ -1110,12 +1027,8 @@
1110 1027 }
1111 1028
1112 1029 $attachment_post = get_post( $attachment['id'] );
1113 1030
1114 - if ( Utils::has_invalid_post_permissions( $attachment_post ) ) {
1115 - return '';
1116 - }
1117 -
1118 1031 if ( 'caption' === $caption_type ) {
1119 1032 return $attachment_post->post_excerpt;
1120 1033 }
1121 1034
@@ -1122,12 +1035,8 @@
1122 1035 if ( 'title' === $caption_type ) {
1123 1036 return $attachment_post->post_title;
1124 1037 }
1125 1038
1126 - if ( empty( $attachment_post->post_content ) ) {
1127 - return '';
1128 - }
1129 -
1130 1039 return $attachment_post->post_content;
1131 1040 }
1132 1041
1133 1042 private function render_swiper_button( $type ) {
@@ -1141,26 +1050,6 @@
1141 1050 ];
1142 1051 }
1143 1052
1144 1053 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 1054 }
1166 1055 }