PluginProbe
Elementor Website Builder – more than just a page builder / 3.13.2
Elementor Website Builder – more than just a page builder v3.13.2
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/video.php +68 -213 4.1.33.13.2 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 4 use Elementor\Modules\DynamicTags\Module as TagsModule;
5 -use Elementor\Modules\Promotions\Controls\Promotion_Control;
6 5
7 6 if ( ! defined( 'ABSPATH' ) ) {
8 7 exit; // Exit if accessed directly.
9 8 }
@@ -85,60 +84,16 @@
85 84 *
86 85 * @return array Widget keywords.
87 86 */
88 87 public function get_keywords() {
89 - return [ 'video', 'player', 'embed', 'youtube', 'vimeo', 'dailymotion', 'videopress' ];
88 + return [ 'video', 'player', 'embed', 'youtube', 'vimeo', 'dailymotion' ];
90 89 }
91 90
92 - protected function is_dynamic_content(): bool {
93 - return false;
94 - }
95 -
96 91 /**
97 - * Get style dependencies.
98 - *
99 - * Retrieve the list of style dependencies the widget requires.
100 - *
101 - * @since 3.24.0
102 - * @access public
103 - *
104 - * @return array Widget style dependencies.
105 - */
106 - public function get_style_depends(): array {
107 - return [ 'widget-video' ];
108 - }
109 -
110 - public function has_widget_inner_wrapper(): bool {
111 - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
112 - }
113 -
114 - /**
115 92 * Register video widget controls.
116 93 *
117 94 * Adds different input fields to allow the user to change and customize the widget settings.
118 95 *
119 - * @since 3.19.0
120 - * @access protected
121 - *
122 - * @return array Widget promotion data.
123 - */
124 - protected function get_upsale_data() {
125 - return [
126 - 'condition' => ! Utils::has_pro(),
127 - 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ),
128 - 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ),
129 - 'title' => esc_html__( "Grab your visitors' attention", 'elementor' ),
130 - 'description' => esc_html__( 'Get the Video Playlist widget and grow your toolbox with Elementor Pro.', 'elementor' ),
131 - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-video-widget/' ),
132 - 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ),
133 - ];
134 - }
135 -
136 - /**
137 - * Register video widget controls.
138 - *
139 - * Adds different input fields to allow the user to change and customize the widget settings.
140 - *
141 96 * @since 3.1.0
142 97 * @access protected
143 98 */
144 99 protected function register_controls() {
@@ -158,9 +113,8 @@
158 113 'options' => [
159 114 'youtube' => esc_html__( 'YouTube', 'elementor' ),
160 115 'vimeo' => esc_html__( 'Vimeo', 'elementor' ),
161 116 'dailymotion' => esc_html__( 'Dailymotion', 'elementor' ),
162 - 'videopress' => esc_html__( 'VideoPress', 'elementor' ),
163 117 'hosted' => esc_html__( 'Self Hosted', 'elementor' ),
164 118 ],
165 119 'frontend_available' => true,
166 120 ]
@@ -244,10 +198,13 @@
244 198 [
245 199 'label' => esc_html__( 'External URL', 'elementor' ),
246 200 'type' => Controls_Manager::SWITCHER,
247 201 'condition' => [
248 - 'video_type' => [ 'hosted', 'videopress' ],
202 + 'video_type' => 'hosted',
249 203 ],
204 + 'ai' => [
205 + 'active' => false,
206 + ],
250 207 ]
251 208 );
252 209
253 210 $this->add_control(
@@ -252,9 +209,9 @@
252 209
253 210 $this->add_control(
254 211 'hosted_url',
255 212 [
256 - 'label' => esc_html__( 'Choose Video File', 'elementor' ),
213 + 'label' => esc_html__( 'Choose File', 'elementor' ),
257 214 'type' => Controls_Manager::MEDIA,
258 215 'dynamic' => [
259 216 'active' => true,
260 217 'categories' => [
@@ -260,15 +217,16 @@
260 217 'categories' => [
261 218 TagsModule::MEDIA_CATEGORY,
262 219 ],
263 220 ],
264 - 'media_types' => [
265 - 'video',
266 - ],
221 + 'media_type' => 'video',
267 222 'condition' => [
268 - 'video_type' => [ 'hosted', 'videopress' ],
223 + 'video_type' => 'hosted',
269 224 'insert_url' => '',
270 225 ],
226 + 'ai' => [
227 + 'active' => false,
228 + ],
271 229 ]
272 230 );
273 231
274 232 $this->add_control(
@@ -286,40 +244,17 @@
286 244 TagsModule::POST_META_CATEGORY,
287 245 TagsModule::URL_CATEGORY,
288 246 ],
289 247 ],
248 + 'media_type' => 'video',
290 249 'placeholder' => esc_html__( 'Enter your URL', 'elementor' ),
291 250 'condition' => [
292 251 'video_type' => 'hosted',
293 252 'insert_url' => 'yes',
294 253 ],
295 - ]
296 - );
297 -
298 - $this->add_control(
299 - 'videopress_url',
300 - [
301 - 'label' => esc_html__( 'URL', 'elementor' ),
302 - 'type' => Controls_Manager::TEXT,
303 - 'label_block' => true,
304 - 'show_label' => false,
305 - 'default' => 'https://videopress.com/v/ZCAOzTNk',
306 - 'dynamic' => [
307 - 'active' => true,
308 - 'categories' => [
309 - TagsModule::POST_META_CATEGORY,
310 - TagsModule::URL_CATEGORY,
311 - ],
312 - ],
313 - 'placeholder' => esc_html__( 'VideoPress URL', 'elementor' ),
314 254 'ai' => [
315 255 'active' => false,
316 256 ],
317 - 'condition' => [
318 - 'video_type' => 'videopress',
319 - 'insert_url' => 'yes',
320 - ],
321 -
322 257 ]
323 258 );
324 259
325 260 $this->add_control(
@@ -328,9 +263,8 @@
328 263 'label' => esc_html__( 'Start Time', 'elementor' ),
329 264 'type' => Controls_Manager::NUMBER,
330 265 'description' => esc_html__( 'Specify a start time (in seconds)', 'elementor' ),
331 266 'frontend_available' => true,
332 - 'separator' => 'before',
333 267 ]
334 268 );
335 269
336 270 $this->add_control(
@@ -358,16 +292,23 @@
358 292 $this->add_control(
359 293 'autoplay',
360 294 [
361 295 'label' => esc_html__( 'Autoplay', 'elementor' ),
362 - 'description' => sprintf(
363 - /* translators: 1: `<a>` opening tag, 2: `</a>` closing tag. */
364 - esc_html__( 'Note: Autoplay is affected by %1$s Google’s Autoplay policy %2$s on Chrome browsers.', 'elementor' ),
365 - '<a href="https://developers.google.com/web/updates/2017/09/autoplay-policy-changes" target="_blank">',
366 - '</a>'
367 - ),
368 296 'type' => Controls_Manager::SWITCHER,
369 297 'frontend_available' => true,
298 + 'conditions' => [
299 + 'relation' => 'or',
300 + 'terms' => [
301 + [
302 + 'name' => 'show_image_overlay',
303 + 'value' => '',
304 + ],
305 + [
306 + 'name' => 'image_overlay[url]',
307 + 'value' => '',
308 + ],
309 + ],
310 + ],
370 311 ]
371 312 );
372 313
373 314 $this->add_control(
@@ -432,11 +373,11 @@
432 373 ]
433 374 );
434 375
435 376 $this->add_control(
436 - 'cc_load_policy',
377 + 'modestbranding',
437 378 [
438 - 'label' => esc_html__( 'Captions', 'elementor' ),
379 + 'label' => esc_html__( 'Modest Branding', 'elementor' ),
439 380 'type' => Controls_Manager::SWITCHER,
440 381 'condition' => [
441 382 'video_type' => [ 'youtube' ],
442 383 'controls' => 'yes',
@@ -600,11 +541,11 @@
600 541 'auto' => esc_html__( 'Auto', 'elementor' ),
601 542 'none' => esc_html__( 'None', 'elementor' ),
602 543 ],
603 544 'description' => sprintf(
604 - '%1$s <a target="_blank" href="https://go.elementor.com/preload-video/">%2$s</a>',
605 - esc_html__( 'Preload attribute lets you specify how the video should be loaded when the page loads.', 'elementor' ),
606 - esc_html__( 'Learn more', 'elementor' ),
545 + esc_html__( 'Preload attribute lets you specify how the video should be loaded when the page loads. %1$sLearn More%2$s', 'elementor' ),
546 + '<a target="_blank" href="https://go.elementor.com/preload-video/">',
547 + '</a>'
607 548 ),
608 549 'default' => 'metadata',
609 550 'condition' => [
610 551 'video_type' => 'hosted',
@@ -626,8 +567,17 @@
626 567 ],
627 568 ]
628 569 );
629 570
571 + $this->add_control(
572 + 'view',
573 + [
574 + 'label' => esc_html__( 'View', 'elementor' ),
575 + 'type' => Controls_Manager::HIDDEN,
576 + 'default' => 'youtube',
577 + ]
578 + );
579 +
630 580 $this->end_controls_section();
631 581
632 582 $this->start_controls_section(
633 583 'section_image_overlay',
@@ -669,8 +619,9 @@
669 619 Group_Control_Image_Size::get_type(),
670 620 [
671 621 'name' => 'image_overlay', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `image_overlay_size` and `image_overlay_custom_dimension`.
672 622 'default' => 'full',
623 + 'separator' => 'none',
673 624 'condition' => [
674 625 'show_image_overlay' => 'yes',
675 626 ],
676 627 ]
@@ -681,11 +632,8 @@
681 632 [
682 633 'label' => esc_html__( 'Play Icon', 'elementor' ),
683 634 'type' => Controls_Manager::SWITCHER,
684 635 'default' => 'yes',
685 - 'label_off' => esc_html__( 'Hide', 'elementor' ),
686 - 'label_on' => esc_html__( 'Show', 'elementor' ),
687 - 'separator' => 'before',
688 636 'condition' => [
689 637 'show_image_overlay' => 'yes',
690 638 'image_overlay[url]!' => '',
691 639 ],
@@ -788,22 +736,8 @@
788 736 'selector' => '{{WRAPPER}} .elementor-wrapper',
789 737 ]
790 738 );
791 739
792 - $this->end_controls_section();
793 -
794 - $this->start_controls_section(
795 - 'section_image_overlay_style',
796 - [
797 - 'label' => esc_html__( 'Image Overlay', 'elementor' ),
798 - 'tab' => Controls_Manager::TAB_STYLE,
799 - 'condition' => [
800 - 'show_image_overlay' => 'yes',
801 - 'show_play_icon' => 'yes',
802 - ],
803 - ]
804 - );
805 -
806 740 $this->add_control(
807 741 'play_icon_title',
808 742 [
809 743 'label' => esc_html__( 'Play Icon', 'elementor' ),
@@ -811,8 +745,9 @@
811 745 'condition' => [
812 746 'show_image_overlay' => 'yes',
813 747 'show_play_icon' => 'yes',
814 748 ],
749 + 'separator' => 'before',
815 750 ]
816 751 );
817 752
818 753 $this->add_control(
@@ -835,9 +770,8 @@
835 770 'play_icon_size',
836 771 [
837 772 'label' => esc_html__( 'Size', 'elementor' ),
838 773 'type' => Controls_Manager::SLIDER,
839 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
840 774 'range' => [
841 775 'px' => [
842 776 'min' => 10,
843 777 'max' => 300,
@@ -861,9 +795,9 @@
861 795 'name' => 'play_icon_text_shadow',
862 796 'selector' => '{{WRAPPER}} .elementor-custom-embed-play i',
863 797 'fields_options' => [
864 798 'text_shadow_type' => [
865 - 'label' => esc_html__( 'Shadow', 'elementor' ),
799 + 'label' => esc_html_x( 'Shadow', 'Text Shadow Control', 'elementor' ),
866 800 ],
867 801 ],
868 802 'condition' => [
869 803 'show_image_overlay' => 'yes',
@@ -919,56 +853,31 @@
919 853 'selectors' => [
920 854 '#elementor-lightbox-{{ID}} .dialog-lightbox-close-button:hover' => 'color: {{VALUE}}',
921 855 '#elementor-lightbox-{{ID}} .dialog-lightbox-close-button:hover svg' => 'fill: {{VALUE}}',
922 856 ],
857 + 'separator' => 'after',
923 858 ]
924 859 );
925 860
926 - $this->add_responsive_control(
927 - 'lightbox_content_animation',
928 - [
929 - 'label' => esc_html__( 'Entrance Animation', 'elementor' ),
930 - 'type' => Controls_Manager::ANIMATION,
931 - 'frontend_available' => true,
932 - 'separator' => 'before',
933 - ]
934 - );
935 -
936 861 $this->add_control(
937 - 'deprecation_warning',
938 - [
939 - 'type' => Controls_Manager::ALERT,
940 - 'alert_type' => 'danger',
941 - 'content' => esc_html__( 'Note: These controls have been deprecated and are only visible if they were previously in use. The video’s width and position are now set based on its aspect ratio.', 'elementor' ),
942 - 'separator' => 'before',
943 - 'condition' => [
944 - 'lightbox_video_width!' => '',
945 - 'lightbox_content_position!' => '',
946 - ],
947 - ]
948 - );
949 -
950 - // Deprecated control. Visible only if it was previously in use.
951 - $this->add_control(
952 862 'lightbox_video_width',
953 863 [
954 864 'label' => esc_html__( 'Content Width', 'elementor' ),
955 865 'type' => Controls_Manager::SLIDER,
956 - 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
957 866 'default' => [
958 867 'unit' => '%',
959 868 ],
960 - // 'selectors' => [
961 - // '(desktop+)#elementor-lightbox-{{ID}} .elementor-video-container' => 'width: {{SIZE}}{{UNIT}};',
962 - // ],
963 - 'condition' => [
964 - 'lightbox_video_width!' => '',
965 - 'lightbox_content_position!' => '',
869 + 'range' => [
870 + '%' => [
871 + 'min' => 30,
872 + ],
966 873 ],
874 + 'selectors' => [
875 + '(desktop+)#elementor-lightbox-{{ID}} .elementor-video-container' => 'width: {{SIZE}}{{UNIT}};',
876 + ],
967 877 ]
968 878 );
969 879
970 - // Deprecated control. Visible only if it was previously in use.
971 880 $this->add_control(
972 881 'lightbox_content_position',
973 882 [
974 883 'label' => esc_html__( 'Content Position', 'elementor' ),
@@ -977,21 +886,26 @@
977 886 'options' => [
978 887 '' => esc_html__( 'Center', 'elementor' ),
979 888 'top' => esc_html__( 'Top', 'elementor' ),
980 889 ],
981 - // 'selectors' => [
982 - // '#elementor-lightbox-{{ID}} .elementor-video-container' => '{{VALUE}}; transform: translateX(-50%);',
983 - // ],
890 + 'selectors' => [
891 + '#elementor-lightbox-{{ID}} .elementor-video-container' => '{{VALUE}}; transform: translateX(-50%);',
892 + ],
984 893 'selectors_dictionary' => [
985 894 'top' => 'top: 60px',
986 895 ],
987 - 'condition' => [
988 - 'lightbox_video_width!' => '',
989 - 'lightbox_content_position!' => '',
990 - ],
991 896 ]
992 897 );
993 898
899 + $this->add_responsive_control(
900 + 'lightbox_content_animation',
901 + [
902 + 'label' => esc_html__( 'Entrance Animation', 'elementor' ),
903 + 'type' => Controls_Manager::ANIMATION,
904 + 'frontend_available' => true,
905 + ]
906 + );
907 +
994 908 $this->end_controls_section();
995 909 }
996 910
997 911 public function print_a11y_text( $image_overlay ) {
@@ -1017,12 +931,8 @@
1017 931
1018 932 if ( 'hosted' === $settings['video_type'] ) {
1019 933 $video_url = $this->get_hosted_video_url();
1020 934 } else {
1021 - if ( 'videopress' === $settings['video_type'] ) {
1022 - $video_url = $this->get_videopress_video_url();
1023 - }
1024 -
1025 935 $embed_params = $this->get_embed_params();
1026 936 $embed_options = $this->get_embed_options();
1027 937 }
1028 938
@@ -1048,9 +958,9 @@
1048 958
1049 959 if ( $is_static_render_mode ) {
1050 960 $video_html = Embed::get_embed_thumbnail_html( $video_url, $post_id );
1051 961 // YouTube API requires a different markup which was set above.
1052 - } elseif ( 'youtube' !== $settings['video_type'] ) {
962 + } else if ( 'youtube' !== $settings['video_type'] ) {
1053 963 $video_html = Embed::get_embed_html( $video_url, $embed_params, $embed_options );
1054 964 }
1055 965 }
1056 966
@@ -1083,15 +993,14 @@
1083 993 $lightbox_options = [
1084 994 'type' => 'video',
1085 995 'videoType' => $settings['video_type'],
1086 996 'url' => $lightbox_url,
1087 - 'autoplay' => $settings['autoplay'],
1088 997 'modalOptions' => [
1089 998 'id' => 'elementor-lightbox-' . $this->get_id(),
1090 999 'entranceAnimation' => $settings['lightbox_content_animation'],
1091 1000 'entranceAnimation_tablet' => $settings['lightbox_content_animation_tablet'],
1092 1001 'entranceAnimation_mobile' => $settings['lightbox_content_animation_mobile'],
1093 - 'videoAspectRatio' => $settings['aspect_ratio'] ?? '169',
1002 + 'videoAspectRatio' => $settings['aspect_ratio'],
1094 1003 ],
1095 1004 ];
1096 1005
1097 1006 if ( 'hosted' === $settings['video_type'] ) {
@@ -1134,8 +1043,9 @@
1134 1043 ];
1135 1044 }
1136 1045 Icons_Manager::render_icon( $settings['play_icon'], [ 'aria-hidden' => 'true' ] );
1137 1046 ?>
1047 + <span class="elementor-screen-only"><?php $this->print_a11y_text( $settings['image_overlay'] ); ?></span>
1138 1048 </div>
1139 1049 <?php endif; ?>
1140 1050 </div>
1141 1051 <?php } ?>
@@ -1145,9 +1055,9 @@
1145 1055
1146 1056 /**
1147 1057 * Render video widget as plain content.
1148 1058 *
1149 - * Override the default behavior, by printing the video URL instead of rendering it.
1059 + * Override the default behavior, by printing the video URL insted of rendering it.
1150 1060 *
1151 1061 * @since 1.4.5
1152 1062 * @access public
1153 1063 */
@@ -1193,9 +1103,9 @@
1193 1103 'loop',
1194 1104 'controls',
1195 1105 'mute',
1196 1106 'rel',
1197 - 'cc_load_policy',
1107 + 'modestbranding',
1198 1108 ];
1199 1109
1200 1110 if ( $settings['loop'] ) {
1201 1111 $video_properties = Embed::get_video_properties( $settings['youtube_url'] );
@@ -1236,12 +1146,8 @@
1236 1146
1237 1147 $params['start'] = $settings['start'];
1238 1148
1239 1149 $params['endscreen-enable'] = '0';
1240 - } elseif ( 'videopress' === $settings['video_type'] ) {
1241 - $params_dictionary = $this->get_params_dictionary_for_videopress();
1242 -
1243 - $params['at'] = $settings['start'];
1244 1150 }
1245 1151
1246 1152 foreach ( $params_dictionary as $key => $param_name ) {
1247 1153 $setting_name = $param_name;
@@ -1332,8 +1238,9 @@
1332 1238 return $video_params;
1333 1239 }
1334 1240
1335 1241 /**
1242 + * @param bool $from_media
1336 1243 *
1337 1244 * @return string
1338 1245 * @since 2.1.0
1339 1246 * @access private
@@ -1366,39 +1273,9 @@
1366 1273 return $video_url;
1367 1274 }
1368 1275
1369 1276 /**
1370 - * Get the VideoPress video URL from the current selected settings.
1371 1277 *
1372 - * @return string
1373 - */
1374 - private function get_videopress_video_url() {
1375 - $settings = $this->get_settings_for_display();
1376 -
1377 - if ( ! empty( $settings['insert_url'] ) ) {
1378 - return $settings['videopress_url'];
1379 - }
1380 -
1381 - return $settings['hosted_url']['url'];
1382 - }
1383 -
1384 - /**
1385 - * Get the params dictionary for VideoPress videos.
1386 - *
1387 - * @return array
1388 - */
1389 - private function get_params_dictionary_for_videopress() {
1390 - return [
1391 - 'controls',
1392 - 'autoplay' => 'autoPlay',
1393 - 'mute' => 'muted',
1394 - 'loop',
1395 - 'play_on_mobile' => 'playsinline',
1396 - ];
1397 - }
1398 -
1399 - /**
1400 - *
1401 1278 * @since 2.1.0
1402 1279 * @access private
1403 1280 */
1404 1281 private function render_hosted_video() {
@@ -1411,28 +1288,6 @@
1411 1288 /* Sometimes the video url is base64, therefore we use `esc_attr` in `src`. */
1412 1289 ?>
1413 1290 <video class="elementor-video" src="<?php echo esc_attr( $video_url ); ?>" <?php Utils::print_html_attributes( $video_params ); ?>></video>
1414 1291 <?php
1415 - }
1416 -
1417 - public function render_markdown(): string {
1418 - $settings = $this->get_settings_for_display();
1419 - $video_type = $settings['video_type'] ?? 'youtube';
1420 - $url = '';
1421 -
1422 - if ( 'hosted' === $video_type ) {
1423 - if ( ! empty( $settings['insert_url'] ) ) {
1424 - $url = $settings['external_url']['url'] ?? '';
1425 - } else {
1426 - $url = $settings['hosted_url']['url'] ?? '';
1427 - }
1428 - } else {
1429 - $url = $settings[ $video_type . '_url' ] ?? '';
1430 - }
1431 -
1432 - if ( empty( $url ) ) {
1433 - return '';
1434 - }
1435 -
1436 - return '[Video](' . esc_url( $url ) . ')';
1437 1292 }
1438 1293 }