PluginProbe
Elementor Website Builder – more than just a page builder / 3.6.4
Elementor Website Builder – more than just a page builder v3.6.4
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/embed.php +15 -28 4.1.33.6.4 View file →
@@ -9,9 +9,9 @@
9 9 * Elementor embed.
10 10 *
11 11 * Elementor embed handler class is responsible for Elementor embed functionality.
12 12 * The class holds the supported providers with their embed patters, and handles
13 - * their custom properties to create custom HTML with the embedded content.
13 + * their custom properties to create custom HTML with the embeded content.
14 14 *
15 15 * @since 1.5.0
16 16 */
17 17 class Embed {
@@ -27,15 +27,11 @@
27 27 *
28 28 * @var array Provider URL structure regex.
29 29 */
30 30 private static $provider_match_masks = [
31 - 'youtube' => '/^.*(?:youtu\.be\/|youtube(?:-nocookie)?\.com\/(?:(?:watch)?\?(?:.*&)?vi?=|(?:embed|v|vi|user|shorts)\/))([^\?&\"\'>]+)/',
31 + 'youtube' => '/^.*(?:youtu\.be\/|youtube(?:-nocookie)?\.com\/(?:(?:watch)?\?(?:.*&)?vi?=|(?:embed|v|vi|user)\/))([^\?&\"\'>]+)/',
32 32 'vimeo' => '/^.*vimeo\.com\/(?:[a-z]*\/)*([‌​0-9]{6,11})[?]?.*/',
33 33 'dailymotion' => '/^.*dailymotion.com\/(?:video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/',
34 - 'videopress' => [
35 - '/^(?:http(?:s)?:\/\/)?videos\.files\.wordpress\.com\/([a-zA-Z\d]{8,})\//i',
36 - '/^(?:http(?:s)?:\/\/)?(?:www\.)?video(?:\.word)?press\.com\/(?:v|embed)\/([a-zA-Z\d]{8,})(.+)?/i',
37 - ],
38 34 ];
39 35
40 36 /**
41 37 * Embed patterns.
@@ -51,9 +47,8 @@
51 47 private static $embed_patterns = [
52 48 'youtube' => 'https://www.youtube{NO_COOKIE}.com/embed/{VIDEO_ID}?feature=oembed',
53 49 'vimeo' => 'https://player.vimeo.com/video/{VIDEO_ID}#t={TIME}',
54 50 'dailymotion' => 'https://dailymotion.com/embed/video/{VIDEO_ID}',
55 - 'videopress' => 'https://videopress.com/embed/{VIDEO_ID}',
56 51 ];
57 52
58 53 /**
59 54 * Get video properties.
@@ -69,19 +64,15 @@
69 64 * @return null|array The video properties, or null.
70 65 */
71 66 public static function get_video_properties( $video_url ) {
72 67 foreach ( self::$provider_match_masks as $provider => $match_mask ) {
73 - if ( ! is_array( $match_mask ) ) {
74 - $match_mask = [ $match_mask ];
75 - }
68 + preg_match( $match_mask, $video_url, $matches );
76 69
77 - foreach ( $match_mask as $mask ) {
78 - if ( preg_match( $mask, $video_url, $matches ) ) {
79 - return [
80 - 'provider' => $provider,
81 - 'video_id' => $matches[1],
82 - ];
83 - }
70 + if ( $matches ) {
71 + return [
72 + 'provider' => $provider,
73 + 'video_id' => $matches[1],
74 + ];
84 75 }
85 76 }
86 77
87 78 return null;
@@ -178,9 +169,8 @@
178 169
179 170 $default_frame_attributes = [
180 171 'class' => 'elementor-video-iframe',
181 172 'allowfullscreen',
182 - 'allow' => 'clipboard-write',
183 173 'title' => sprintf(
184 174 /* translators: %s: Video provider */
185 175 __( '%s Video Player', 'elementor' ),
186 176 $video_properties['provider']
@@ -190,18 +180,14 @@
190 180 $video_embed_url = self::get_embed_url( $video_url, $embed_url_params, $options );
191 181 if ( ! $video_embed_url ) {
192 182 return null;
193 183 }
194 - if ( ! isset( $options['lazy_load'] ) || ! $options['lazy_load'] ) {
184 + if ( ! $options['lazy_load'] ) {
195 185 $default_frame_attributes['src'] = $video_embed_url;
196 186 } else {
197 187 $default_frame_attributes['data-lazy-load'] = $video_embed_url;
198 188 }
199 189
200 - if ( isset( $embed_url_params['autoplay'] ) ) {
201 - $default_frame_attributes['allow'] = 'autoplay';
202 - }
203 -
204 190 $frame_attributes = array_merge( $default_frame_attributes, $frame_attributes );
205 191
206 192 $attributes_for_print = [];
207 193
@@ -226,10 +212,10 @@
226 212 /**
227 213 * Get oembed data from the cache.
228 214 * if not exists in the cache it will fetch from provider and then save to the cache.
229 215 *
230 - * @param string $oembed_url
231 - * @param string $cached_post_id
216 + * @param $oembed_url
217 + * @param $cached_post_id
232 218 *
233 219 * @return array|null
234 220 */
235 221 public static function get_oembed_data( $oembed_url, $cached_post_id ) {
@@ -257,9 +243,10 @@
257 243
258 244 /**
259 245 * Fetch oembed data from oembed provider.
260 246 *
261 - * @param string $oembed_url
247 + * @param $oembed_url
248 + *
262 249 * @return array|null
263 250 */
264 251 public static function fetch_oembed_data( $oembed_url ) {
265 252 $oembed_data = _wp_oembed_get_object()->get_data( $oembed_url );
@@ -274,9 +261,9 @@
274 261 ];
275 262 }
276 263
277 264 /**
278 - * @param string $oembed_url
265 + * @param $oembed_url
279 266 * @param null|string|int $cached_post_id
280 267 *
281 268 * @return string|null
282 269 */
@@ -286,7 +273,7 @@
286 273 if ( ! $oembed_data ) {
287 274 return null;
288 275 }
289 276
290 - return '<div class="elementor-image">' . sprintf( '<img src="%1$s" alt="%2$s" title="%2$s" width="%3$s" loading="lazy" />', $oembed_data['thumbnail_url'], esc_attr( $oembed_data['title'] ), '100%' ) . '</div>';
277 + return '<div class="elementor-image">' . sprintf( '<img src="%1$s" alt="%2$s" title="%2$s" width="%3$s" />', $oembed_data['thumbnail_url'], esc_attr( $oembed_data['title'] ), '100%' ) . '</div>';
291 278 }
292 279 }