PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 4.5.4
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v4.5.4
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / EmbedPress / Includes / Classes / Elementor_Enhancer.php
embedpress / EmbedPress / Includes / Classes Last commit date
Analytics 2 months ago Database 1 month ago DynamicFieldResolver.php 1 month ago Elementor_Enhancer.php 6 months ago EmbedPress_Core_Installer.php 6 years ago EmbedPress_Notice.php 3 months ago EmbedPress_Plugin_Usage_Tracker.php 2 months ago Extend_CustomPlayer_Controls.php 1 month ago Extend_Elementor_Controls.php 1 year ago FeatureNoticeManager.php 8 months ago FeatureNotices.php 8 months ago Feature_Enhancer.php 1 month ago Helper.php 1 month ago Pdf_Thumbnail_Handler.php 2 months ago PermalinkHelper.php 10 months ago README_FEATURE_NOTICES.md 8 months ago
Elementor_Enhancer.php
501 lines
1 <?php
2
3 namespace EmbedPress\Includes\Classes;
4
5 use Elementor\Group_Control_Image_Size;
6 use Elementor\Utils;
7 use SplMinHeap;
8 use EmbedPress\Includes\Classes\Helper;
9
10 class Elementor_Enhancer {
11
12 public static function youtube( $embed, $setting ) {
13 if ( isset( $setting['embedpress_pro_embeded_source'] ) && 'youtube' === $setting['embedpress_pro_embeded_source'] && isset( $embed->embed ) && preg_match( '/src=\"(.+?)\"/', $embed->embed, $match ) ) {
14
15 $url_full = $match[1];
16 $query = parse_url($url_full, PHP_URL_QUERY);
17 if (!empty($query)) {
18 parse_str($query, $params);
19 } else {
20 $params = [];
21 }
22
23 $params['controls'] = $setting['embedpress_pro_youtube_display_controls'];
24 $params['iv_load_policy'] = $setting['embedpress_pro_youtube_display_video_annotations'];
25 $params['fs'] = ( $setting['embedpress_pro_youtube_enable_fullscreen_button'] === 'yes' ) ? 1 : 0;
26 $params['rel'] = ( $setting['embedpress_pro_youtube_display_related_videos'] === 'yes' ) ? 1 : 0;
27 $params['end'] = $setting['embedpress_pro_youtube_end_time'];
28 $params['playsinline'] = 1;
29 if ( $setting['embedpress_pro_youtube_auto_play'] === 'yes' ) {
30 $params['autoplay'] = 1;
31 }
32 if (isset($setting['embedpress_pro_youtube_mute']) && $setting['embedpress_pro_youtube_mute'] === 'yes' ) {
33 $params['mute'] = 1;
34 }
35 $params['start'] = $setting['embedpress_pro_video_start_time'];
36
37 $params['color'] = $setting['embedpress_pro_youtube_progress_bar_color'];
38
39 $params = apply_filters('embedpress/elementor_enhancer_youtube', $params, $setting);
40
41 preg_match( '/(.+)?\?/', $url_full, $url );
42 if ( empty( $url) ) {
43 return $embed;
44 }
45 $url = $url[1];
46
47 // Reassemble the url with the new variables.
48 $url_modified = $url . '?';
49 foreach ( $params as $paramName => $paramValue ) {
50 $url_modified .= $paramName . '=' . $paramValue . '&';
51 }
52 // Replaces the old url with the new one.
53 $embed->embed = str_replace( $url_full, rtrim( $url_modified, '&' ), $embed->embed );
54
55 $embed = apply_filters('embedpress/elementor_enhancer_youtube_cta', $embed, $setting);
56
57 }
58
59 return $embed;
60 }
61
62 public static function apply_cta_markup( $embed, $settings, $provider_name = '' ) {
63
64 if ( empty( $settings["embedpress_pro_{$provider_name}_logo"] ) || empty( $settings["embedpress_pro_{$provider_name}_logo"]['url'] ) ) {
65 return $embed;
66 }
67 $img = Group_Control_Image_Size::get_attachment_image_html( $settings, "embedpress_pro_{$provider_name}_logo" );
68 if ( empty( $img ) ) {
69 return $embed;
70 }
71
72 $cta = '';
73 $url = '';
74 $target = '';
75 $x = ! empty( $settings["embedpress_pro_{$provider_name}_logo_xpos"] ) && ! empty( $settings["embedpress_pro_{$provider_name}_logo_xpos"]['unit'] ) ? $settings["embedpress_pro_{$provider_name}_logo_xpos"]['size'] . $settings["embedpress_pro_{$provider_name}_logo_xpos"]['unit'] : '10%';
76
77 $y = ! empty( $settings["embedpress_pro_{$provider_name}_logo_ypos"] ) && ! empty( $settings["embedpress_pro_{$provider_name}_logo_ypos"]['unit'] ) ? $settings["embedpress_pro_{$provider_name}_logo_ypos"]['size'] . $settings["embedpress_pro_{$provider_name}_logo_ypos"]['unit'] : '10%';
78 $cssClass = isset( $embed->url ) ? '.ose-uid-' . md5( $embed->url ) : ".ose-{$provider_name}";
79 ob_start();
80 ?>
81 <style type="text/css">
82 .ep-embed-content-wraper .watermark {
83 text-align: left;
84 position: relative;
85 }
86 .ep-embed-content-wraper .watermark {
87 border: 0;
88 position: absolute;
89 bottom: 10%;
90 right: 5%;
91 max-width: 150px;
92 max-height: 75px;
93 opacity: 0.35!important;
94 z-index: 5;
95 -o-transition: opacity 0.5s ease-in-out;
96 -moz-transition: opacity 0.5s ease-in-out;
97 -webkit-transition: opacity 0.5s ease-in-out;
98 transition: opacity 0.5s ease-in-out;
99 }
100
101 <?php echo esc_html($cssClass); ?> .watermark {
102 bottom: <?php echo esc_html($y); ?>;
103 right: <?php echo esc_html($x); ?>;
104 }
105
106 .ep-embed-content-wraper .watermark:hover {
107 opacity: 1!important;
108 }
109 </style>
110 <?php
111 $style = ob_get_clean();
112
113 if ( ! class_exists( '\simple_html_dom' ) ) {
114 include_once EMBEDPRESS_PATH_CORE . 'simple_html_dom.php';
115 }
116
117 if ( ! empty( $settings["embedpress_pro_{$provider_name}_cta"] ) && ! empty( $settings["embedpress_pro_{$provider_name}_cta"]['url'] ) ) {
118 $url = $settings["embedpress_pro_{$provider_name}_cta"]['url'];
119 }
120
121 if ( $url ) {
122 $atts = self::get_link_attributes( $settings["embedpress_pro_{$provider_name}_cta"] );
123 $attributes = '';
124 foreach ( $atts as $att => $value ) {
125 $attributes .= $att . '="' . esc_attr( $value ) . '" ';
126 }
127 $cta .= sprintf( '<a %s>', trim( $attributes ) );
128 }
129
130
131 $imgDom = str_get_html( $img );
132 $imgDom = $imgDom->find( 'img', 0 );
133 $imgDom->setAttribute( 'class', 'watermark' );
134 $imgDom->removeAttribute( 'style' );
135 $imgDom->setAttribute( 'width', 'auto' );
136 $imgDom->setAttribute( 'height', 'auto' );
137 ob_start();
138 echo $imgDom;
139 $cta .= ob_get_clean();
140 $imgDom->clear();
141 unset( $img, $imgDom );
142
143 if ( $url ) {
144 $cta .= '</a>';
145 }
146 $dom = str_get_html( $embed->embed );
147 $wrapDiv = $dom->find( "div.ose-{$provider_name}", 0 );
148 if ( ! empty( $wrapDiv ) && is_object( $wrapDiv ) ) {
149 $wrapDiv->innertext .= $cta;
150 }
151
152 ob_start();
153 echo $wrapDiv;
154 $markup = ob_get_clean();
155 $dom->clear();
156 unset( $dom, $wrapDiv );
157
158 $embed->embed = $style . $markup;
159
160 return $embed;
161 }
162
163 public static function get_link_attributes( $url_control ) {
164 $attributes = [];
165
166 if ( ! empty( $url_control['url'] ) ) {
167 $allowed_protocols = array_merge( wp_allowed_protocols(), [
168 'skype',
169 'viber',
170 ] );
171
172 $attributes['href'] = esc_url( $url_control['url'], $allowed_protocols );
173 }
174
175 if ( ! empty( $url_control['is_external'] ) ) {
176 $attributes['target'] = '_blank';
177 }
178
179 if ( ! empty( $url_control['nofollow'] ) ) {
180 $attributes['rel'] = 'nofollow';
181 }
182
183 if ( ! empty( $url_control['custom_attributes'] ) ) {
184 // Custom URL attributes should come as a string of comma-delimited key|value pairs
185 $attributes = array_merge( $attributes, Utils::parse_custom_attributes( $url_control['custom_attributes'] ) );
186 }
187
188 return $attributes;
189 }
190
191 public static function vimeo( $embed, $setting ) {
192
193 if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'VIMEO' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'vimeo' ) {
194 return $embed;
195 }
196 preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
197 $url_full = $match[1];
198 $params = [
199 'color' => str_replace('#', '', isset($setting['embedpress_pro_vimeo_color']) ? $setting['embedpress_pro_vimeo_color'] : ''),
200 'title' => $setting['embedpress_pro_vimeo_display_title'] === 'yes' ? 1 : 0,
201 'byline' => $setting['embedpress_pro_vimeo_display_author'] === 'yes' ? 1 : 0,
202 'portrait' => $setting['embedpress_pro_vimeo_avatar'] === 'yes' ? 1 : 0,
203 'autopause' => 0,
204 ];
205 if ( $setting['embedpress_pro_vimeo_auto_play'] === 'yes' ) {
206 $params['autoplay'] = 1;
207 }
208
209 $params = apply_filters('embedpress/elementor_enhancer_vimeo', $params, $setting);
210
211
212 $url_modified = str_replace("dnt=1&", "", $url_full);
213
214 foreach ( $params as $param => $value ) {
215 $url_modified = add_query_arg( $param, $value, $url_modified );
216 }
217
218
219 $url_modified .= '#t=' . $setting['embedpress_pro_video_start_time'];
220 // Replaces the old url with the new one.
221 $embed->embed = str_replace( $url_full, $url_modified, $embed->embed );
222
223 $embed = apply_filters('embedpress/elementor_enhancer_vimeo_cta', $embed, $setting);
224
225 return $embed;
226 }
227
228 public static function wistia( $embed, $setting ) {
229
230 // echo '<pre>';
231 // print_r($setting);
232 // die;
233
234 if ( ! isset( $embed->provider_name ) || (strtoupper( $embed->provider_name ) !== 'WISTIA, INC.' && strtoupper( $embed->provider_name ) !== 'WISTIA') || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'wistia' ) {
235
236 return $embed;
237 }
238 preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
239
240 $url_full = $match[1];
241
242 // Parse the url to retrieve all its info like variables etc.
243 $query = parse_url( $embed->url, PHP_URL_QUERY );
244 $url = str_replace( '?' . $query, '', $url_full );
245
246 if ($query !== null) {
247 parse_str($query, $params);
248 }
249
250 // Set the class in the attributes
251 $embed->attributes->class = str_replace( '{provider_alias}', 'wistia', $embed->attributes->class );
252 $embed->embed = str_replace( 'ose-wistia, inc.', 'ose-wistia', $embed->embed );
253
254 // Embed Options
255 $embedOptions = new \stdClass;
256 $embedOptions->videoFoam = false;
257 $embedOptions->fullscreenButton = ( $setting['embedpress_pro_wistia_fullscreen_button'] === 'yes' );
258 $embedOptions->smallPlayButton = ( $setting['embedpress_pro_wistia_small_play_button'] === 'yes' );
259 $embedOptions->autoPlay = ( $setting['embedpress_pro_wistia_auto_play'] === 'yes' );
260 $embedOptions->playerColor = $setting['embedpress_pro_wistia_color'];
261 $embedOptions->playbar = ( $setting['embedpress_pro_wistia_playbar'] === 'yes' );
262 if($setting['embedpress_pro_video_start_time']){
263 $embedOptions->time = $setting['embedpress_pro_video_start_time'];
264 }
265
266 if (is_embedpress_pro_active()) {
267 $embedOptions = apply_filters('embedpress/elementor_enhancer_wistia', $embedOptions, $setting);
268 }
269
270
271 // Plugins
272 $pluginsBaseURL = plugins_url( '../assets/js/wistia/min', dirname( __DIR__ ) . '/embedpress-Wistia.php' );
273
274 $pluginList = [];
275
276
277 if (is_embedpress_pro_active()) {
278 $embedOptions = apply_filters('embedpress/elementor_enhancer_wistia_captions', $embedOptions, $setting, $pluginList);
279 $pluginList = apply_filters('embedpress/elementor_enhancer_wistia_pluginlist', $embedOptions, $setting, $pluginList);
280 }
281
282
283 $embedOptions->plugin = $pluginList;
284 $embedOptions = json_encode( $embedOptions );
285
286 // Get the video ID
287 $videoId = self::get_wistia_video_from_url( $embed->url );
288 $shortVideoId = substr( $videoId, 0, 3 );
289
290 // Responsive?
291
292 $class = [
293 'wistia_embed',
294 'wistia_async_' . $videoId,
295 ];
296
297 $attribs = [
298 sprintf( 'id="wistia_%s"', $videoId ),
299 sprintf( 'class="%s"', join( ' ', $class ) ),
300 sprintf( 'style="width:%spx; height:%spx;"', $embed->attributes->{'data-width'}, $embed->attributes->{'data-height'} ),
301 ];
302
303 $labels = [
304 'watch_from_beginning' => __( 'Watch from the beginning', 'embedpress-pro' ),
305 'skip_to_where_you_left_off' => __( 'Skip to where you left off', 'embedpress-pro' ),
306 'you_have_watched_it_before' => __( 'It looks like you\'ve watched<br />part of this video before!', 'embedpress-pro' ),
307 ];
308 $labels = json_encode( $labels );
309
310 preg_match( '/ose-uid-([a-z0-9]*)/', $embed->embed, $matches );
311 $uid = $matches[1];
312
313 $html = "<div class=\"embedpress-wrapper ose-wistia ose-uid-{$uid} responsive\">";
314 $html .= '<script src="https://fast.wistia.com/assets/external/E-v1.js" async></script>';
315 $html .= "<script>window.pp_embed_wistia_labels = {$labels};</script>\n";
316 $html .= "<script>window._wq = window._wq || []; _wq.push({\"{$shortVideoId}\": {$embedOptions}});</script>\n";
317 $html .= '<div ' . join( ' ', $attribs ) . "></div>\n";
318 $html .= '</div>';
319 $embed->embed = $html;
320
321 if (is_embedpress_pro_active()) {
322 $embed = apply_filters('embedpress/elementor_enhancer_wistia_cta', $embed, $setting);
323 }
324
325
326 return $embed;
327 }
328
329 /**
330 * Get the Video ID from the URL
331 *
332 * @param string $url
333 *
334 * @return string
335 */
336 public static function get_wistia_video_from_url( $url ) {
337 // https://fast.wistia.com/embed/medias/xf1edjzn92.jsonp
338 // https://ostraining-1.wistia.com/medias/xf1edjzn92
339 preg_match( '#\/medias\\\?\/([a-z0-9]+)\.?#i', $url, $matches );
340
341 $id = false;
342 if ( isset( $matches[1] ) ) {
343 $id = $matches[1];
344 }
345
346 return $id;
347 }
348
349 public static function soundcloud( $embed, $setting ) {
350
351 if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'SOUNDCLOUD' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'soundcloud' ) {
352 return $embed;
353 }
354 preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
355 $url_full = $match[1];
356 $params = [
357 'color' => str_replace( '#', '', $setting['embedpress_pro_soundcloud_color'] ),
358 'visual' => $setting['embedpress_pro_soundcloud_visual'] === 'yes' ? 'true' : 'false',
359 'auto_play' => $setting['embedpress_pro_soundcloud_autoplay'] === 'yes' ? 'true' : 'false',
360 'sharing' => $setting['embedpress_pro_soundcloud_share_button'] === 'yes' ? 'true' : 'false',
361 'show_comments' => $setting['embedpress_pro_soundcloud_comments'] === 'yes' ? 'true' : 'false',
362 'show_artwork' => $setting['embedpress_pro_soundcloud_artwork'] === 'yes' ? 'true' : 'false',
363 'show_playcount' => $setting['embedpress_pro_soundcloud_play_count'] === 'yes' ? 'true' : 'false',
364 'show_user' => $setting['embedpress_pro_soundcloud_user_name'] === 'yes' ? 'true' : 'false',
365 'buying' => 'false',
366 'download' => 'false',
367 ];
368
369 $params = apply_filters('embedpress/elementor_enhancer_soundcloud', $params, $setting);
370
371 $url_modified = $url_full;
372 foreach ( $params as $param => $value ) {
373 $url_modified = add_query_arg( $param, $value, $url_modified );
374 }
375
376 // Replaces the old url with the new one.
377 $embed->embed = str_replace( $url_full, $url_modified, $embed->embed );
378 if ( 'false' === $params['visual'] ) {
379 $embed->embed = str_replace( 'height="400"', 'height="200 !important"', $embed->embed );
380 }
381
382 return $embed;
383 }
384
385 public static function dailymotion( $embed, $setting ) {
386 if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'DAILYMOTION' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'dailymotion' ) {
387 return $embed;
388 }
389
390 preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
391
392 if (isset($match[1])) {
393 $url_full = $match[1];
394 } else {
395 $url_full = null;
396 }
397
398 $params = [
399 'ui-highlight' => str_replace( '#', '', $setting['embedpress_pro_dailymotion_control_color'] ),
400 'start' => isset( $setting['embedpress_pro_video_start_time'] ) ? (int) $setting['embedpress_pro_video_start_time'] : 0,
401 'mute' => $setting['embedpress_pro_dailymotion_mute'] === 'yes' ? 1 : 0,
402 'autoplay' => $setting['embedpress_pro_dailymotion_autoplay'] === 'yes' ? 1 : 0,
403 'controls' => $setting['embedpress_pro_dailymotion_player_control'] === 'yes' ? 1 : 0,
404 'ui-start-screen-info' => $setting['embedpress_pro_dailymotion_video_info'] === 'yes' ? 1 : 0,
405 'endscreen-enable' => 0,
406 ];
407
408 if ( $setting['embedpress_pro_dailymotion_play_on_mobile'] === 'yes' ) {
409 $params['playsinline'] = 1;
410 }
411
412 $params = apply_filters('embedpress/elementor_enhancer_dailymotion', $params, $setting);
413
414 $url_modified = $url_full;
415 foreach ( $params as $param => $value ) {
416 $url_modified = add_query_arg( $param, $value, $url_modified );
417 }
418 $embed->embed = str_replace( $url_full, $url_modified, $embed->embed );
419
420 $embed = apply_filters('embedpress/elementor_enhancer_dailymotion_cta', $embed, $setting);
421
422 return $embed;
423 }
424
425 public static function twitch( $embed_content, $settings ) {
426 if ( ! isset( $embed_content->embed ) || $settings['embedpress_pro_embeded_source'] !== 'twitch' ) {
427 return $embed_content;
428 }
429 if (is_object($embed_content)) {
430 $embed_content_array = (array) $embed_content;
431 $e = current($embed_content_array);
432 } else {
433 $e = current($embed_content); // Assuming it's already an array
434 }
435
436 if ( ! isset( $e['provider_name'] ) || strtoupper( $e['provider_name'] ) !== 'TWITCH' ) {
437 return $embed_content;
438 }
439 $time = '0h0m0s';
440 $type = isset( $e['type'] ) ? $e['type'] : '';
441 $content_id = isset( $e['content_id'] ) ? $e['content_id'] : '';
442 $channel = 'channel' === $type ? $content_id : '';
443 $video = 'video' === $type ? $content_id : '';
444 $full_screen = ( 'yes' === $settings['embedpress_pro_fs'] ) ? 'true' : 'false';
445 $autoplay = ( 'yes' === $settings['embedpress_pro_twitch_autoplay'] ) ? 'true' : 'false';
446 $layout = 'video';
447 $width = isset($settings['width']['size']) ? (int) $settings['width']['size'] : 600; // Default to 0 if not set
448 $height = isset($settings['height']['size']) ? (int) $settings['height']['size'] : 340; // Default to 0
449
450 if ( ! empty( $settings['embedpress_pro_video_start_time'] ) ) {
451 $ta = explode( ':', gmdate( "G:i:s", $settings['embedpress_pro_video_start_time'] ) );
452 $h = $ta[0] . 'h';
453 $m = ( $ta[1] * 1 ) . 'm';
454 $s = ( $ta[2] * 1 ) . 's';
455 $time = $h . $m . $s;
456 }
457 $muted = ( 'yes' === $settings['embedpress_pro_twitch_mute'] ) ? 'true' : 'false';
458 $theme = !empty($settings['embedpress_pro_twitch_theme']) ? esc_attr($settings['embedpress_pro_twitch_theme']) : 'dark';
459
460
461 $layout = apply_filters('embedpress/elementor_enhancer_twitch', 'video', $settings);
462
463
464 $url = "https://embed.twitch.tv?autoplay={$autoplay}&channel={$channel}&height={$height}&layout={$layout}&migration=true&muted={$muted}&theme={$theme}&time={$time}&video={$video}&width={$width}&allowfullscreen={$full_screen}";
465
466 $pars_url = wp_parse_url( get_site_url() );
467 $url = ! empty( $pars_url['host'] ) ? $url . '&parent=' . $pars_url['host'] : $url;
468
469 preg_match( '/src=\"(.+?)\"/', $embed_content->embed, $match );
470 $url_full = $match[1];
471 $embed_content->embed = str_replace( $url_full, $url, $embed_content->embed );
472
473 $embed_content = apply_filters('embedpress/elementor_enhancer_twitch_cta', $embed_content, $settings);
474
475
476 return $embed_content;
477 }
478
479 public static function spotify( $embed, $setting ) {
480 if ( ! isset( $embed->provider_name ) || strtolower( $embed->provider_name ) !== 'spotify' || ! isset( $embed->embed ) ) {
481 return $embed;
482 }
483 preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
484 $url_full = $match[1];
485 $modified_url = str_replace( 'playlist-v2', 'playlist', $url_full );
486 if ( $setting['embedpress_pro_embeded_source'] == 'spotify' ) {
487 // apply elementor related mod
488 if ( isset( $setting['spotify_theme'] ) ) {
489 if ( strpos( $modified_url, '?' ) !== false ) {
490 $modified_url .= '&theme=' . sanitize_text_field( $setting['spotify_theme'] );
491 } else {
492 $modified_url .= '?theme=' . sanitize_text_field( $setting['spotify_theme'] );
493 }
494 }
495 }
496
497 $embed->embed = str_replace( $url_full, $modified_url, $embed->embed );
498
499 return $embed;
500 }
501 }