Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/embedpre.../EmbedPre.../Includes/Classes
File: Elementor_Enhancer.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace EmbedPress\Includes\Classes;
[2] Fix | Delete
[3] Fix | Delete
use Elementor\Group_Control_Image_Size;
[4] Fix | Delete
use Elementor\Utils;
[5] Fix | Delete
use SplMinHeap;
[6] Fix | Delete
use EmbedPress\Includes\Classes\Helper;
[7] Fix | Delete
[8] Fix | Delete
class Elementor_Enhancer {
[9] Fix | Delete
[10] Fix | Delete
public static function youtube( $embed, $setting ) {
[11] Fix | Delete
if ( isset( $setting['embedpress_pro_embeded_source'] ) && 'youtube' === $setting['embedpress_pro_embeded_source'] && isset( $embed->embed ) && preg_match( '/src=\"(.+?)\"/', $embed->embed, $match ) ) {
[12] Fix | Delete
[13] Fix | Delete
$url_full = $match[1];
[14] Fix | Delete
$query = parse_url( $url_full, PHP_URL_QUERY );
[15] Fix | Delete
parse_str( $query, $params );
[16] Fix | Delete
$params['controls'] = $setting['embedpress_pro_youtube_display_controls'];
[17] Fix | Delete
$params['iv_load_policy'] = $setting['embedpress_pro_youtube_display_video_annotations'];
[18] Fix | Delete
$params['fs'] = ( $setting['embedpress_pro_youtube_enable_fullscreen_button'] === 'yes' ) ? 1 : 0;
[19] Fix | Delete
$params['rel'] = ( $setting['embedpress_pro_youtube_display_related_videos'] === 'yes' ) ? 1 : 0;
[20] Fix | Delete
$params['end'] = $setting['embedpress_pro_youtube_end_time'];
[21] Fix | Delete
if ( $setting['embedpress_pro_youtube_auto_play'] === 'yes' ) {
[22] Fix | Delete
$params['autoplay'] = 1;
[23] Fix | Delete
}
[24] Fix | Delete
$params['start'] = $setting['embedpress_pro_video_start_time'];
[25] Fix | Delete
[26] Fix | Delete
$params['color'] = $setting['embedpress_pro_youtube_progress_bar_color'];
[27] Fix | Delete
[28] Fix | Delete
if ( is_embedpress_pro_active() ) {
[29] Fix | Delete
$params['modestbranding'] = $setting['embedpress_pro_youtube_modest_branding'];
[30] Fix | Delete
if ( $setting['embedpress_pro_youtube_force_closed_captions'] === 'yes' ) {
[31] Fix | Delete
$params['cc_load_policy'] = 1;
[32] Fix | Delete
}
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
[36] Fix | Delete
preg_match( '/(.+)?\?/', $url_full, $url );
[37] Fix | Delete
if ( empty( $url) ) {
[38] Fix | Delete
return $embed;
[39] Fix | Delete
}
[40] Fix | Delete
$url = $url[1];
[41] Fix | Delete
[42] Fix | Delete
// Reassemble the url with the new variables.
[43] Fix | Delete
$url_modified = $url . '?';
[44] Fix | Delete
foreach ( $params as $paramName => $paramValue ) {
[45] Fix | Delete
$url_modified .= $paramName . '=' . $paramValue . '&';
[46] Fix | Delete
}
[47] Fix | Delete
// Replaces the old url with the new one.
[48] Fix | Delete
$embed->embed = str_replace( $url_full, rtrim( $url_modified, '&' ), $embed->embed );
[49] Fix | Delete
if ( is_embedpress_pro_active() ) {
[50] Fix | Delete
$embed = self::apply_cta_markup( $embed, $setting, 'youtube' );
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
return $embed;
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
public static function apply_cta_markup( $embed, $settings, $provider_name = '' ) {
[59] Fix | Delete
[60] Fix | Delete
if ( empty( $settings["embedpress_pro_{$provider_name}_logo"] ) || empty( $settings["embedpress_pro_{$provider_name}_logo"]['url'] ) ) {
[61] Fix | Delete
return $embed;
[62] Fix | Delete
}
[63] Fix | Delete
$img = Group_Control_Image_Size::get_attachment_image_html( $settings, "embedpress_pro_{$provider_name}_logo" );
[64] Fix | Delete
if ( empty( $img ) ) {
[65] Fix | Delete
return $embed;
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
$cta = '';
[69] Fix | Delete
$url = '';
[70] Fix | Delete
$target = '';
[71] Fix | Delete
$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%';
[72] Fix | Delete
[73] Fix | Delete
$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%';
[74] Fix | Delete
$cssClass = isset( $embed->url ) ? '.ose-uid-' . md5( $embed->url ) : ".ose-{$provider_name}";
[75] Fix | Delete
ob_start();
[76] Fix | Delete
?>
[77] Fix | Delete
<style type="text/css">
[78] Fix | Delete
.ep-embed-content-wraper .watermark {
[79] Fix | Delete
text-align: left;
[80] Fix | Delete
position: relative;
[81] Fix | Delete
}
[82] Fix | Delete
.ep-embed-content-wraper .watermark {
[83] Fix | Delete
border: 0;
[84] Fix | Delete
position: absolute;
[85] Fix | Delete
bottom: 10%;
[86] Fix | Delete
right: 5%;
[87] Fix | Delete
max-width: 150px;
[88] Fix | Delete
max-height: 75px;
[89] Fix | Delete
opacity: 0.35!important;
[90] Fix | Delete
z-index: 5;
[91] Fix | Delete
-o-transition: opacity 0.5s ease-in-out;
[92] Fix | Delete
-moz-transition: opacity 0.5s ease-in-out;
[93] Fix | Delete
-webkit-transition: opacity 0.5s ease-in-out;
[94] Fix | Delete
transition: opacity 0.5s ease-in-out;
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
<?php echo esc_html($cssClass); ?> .watermark {
[98] Fix | Delete
bottom: <?php echo esc_html($y); ?>;
[99] Fix | Delete
right: <?php echo esc_html($x); ?>;
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
.ep-embed-content-wraper .watermark:hover {
[103] Fix | Delete
opacity: 1!important;
[104] Fix | Delete
}
[105] Fix | Delete
</style>
[106] Fix | Delete
<?php
[107] Fix | Delete
$style = ob_get_clean();
[108] Fix | Delete
[109] Fix | Delete
if ( ! class_exists( '\simple_html_dom' ) ) {
[110] Fix | Delete
include_once EMBEDPRESS_PATH_CORE . 'simple_html_dom.php';
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
if ( ! empty( $settings["embedpress_pro_{$provider_name}_cta"] ) && ! empty( $settings["embedpress_pro_{$provider_name}_cta"]['url'] ) ) {
[114] Fix | Delete
$url = $settings["embedpress_pro_{$provider_name}_cta"]['url'];
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
if ( $url ) {
[118] Fix | Delete
$atts = self::get_link_attributes( $settings["embedpress_pro_{$provider_name}_cta"] );
[119] Fix | Delete
$attributes = '';
[120] Fix | Delete
foreach ( $atts as $att => $value ) {
[121] Fix | Delete
$attributes .= $att . '="' . esc_attr( $value ) . '" ';
[122] Fix | Delete
}
[123] Fix | Delete
$cta .= sprintf( '<a %s>', trim( $attributes ) );
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
[127] Fix | Delete
$imgDom = str_get_html( $img );
[128] Fix | Delete
$imgDom = $imgDom->find( 'img', 0 );
[129] Fix | Delete
$imgDom->setAttribute( 'class', 'watermark' );
[130] Fix | Delete
$imgDom->removeAttribute( 'style' );
[131] Fix | Delete
$imgDom->setAttribute( 'width', 'auto' );
[132] Fix | Delete
$imgDom->setAttribute( 'height', 'auto' );
[133] Fix | Delete
ob_start();
[134] Fix | Delete
echo $imgDom;
[135] Fix | Delete
$cta .= ob_get_clean();
[136] Fix | Delete
$imgDom->clear();
[137] Fix | Delete
unset( $img, $imgDom );
[138] Fix | Delete
[139] Fix | Delete
if ( $url ) {
[140] Fix | Delete
$cta .= '</a>';
[141] Fix | Delete
}
[142] Fix | Delete
$dom = str_get_html( $embed->embed );
[143] Fix | Delete
$wrapDiv = $dom->find( "div.ose-{$provider_name}", 0 );
[144] Fix | Delete
if ( ! empty( $wrapDiv ) && is_object( $wrapDiv ) ) {
[145] Fix | Delete
$wrapDiv->innertext .= $cta;
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
ob_start();
[149] Fix | Delete
echo $wrapDiv;
[150] Fix | Delete
$markup = ob_get_clean();
[151] Fix | Delete
$dom->clear();
[152] Fix | Delete
unset( $dom, $wrapDiv );
[153] Fix | Delete
[154] Fix | Delete
$embed->embed = $style . $markup;
[155] Fix | Delete
[156] Fix | Delete
return $embed;
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
public static function get_link_attributes( $url_control ) {
[160] Fix | Delete
$attributes = [];
[161] Fix | Delete
[162] Fix | Delete
if ( ! empty( $url_control['url'] ) ) {
[163] Fix | Delete
$allowed_protocols = array_merge( wp_allowed_protocols(), [
[164] Fix | Delete
'skype',
[165] Fix | Delete
'viber',
[166] Fix | Delete
] );
[167] Fix | Delete
[168] Fix | Delete
$attributes['href'] = esc_url( $url_control['url'], $allowed_protocols );
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
if ( ! empty( $url_control['is_external'] ) ) {
[172] Fix | Delete
$attributes['target'] = '_blank';
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
if ( ! empty( $url_control['nofollow'] ) ) {
[176] Fix | Delete
$attributes['rel'] = 'nofollow';
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
if ( ! empty( $url_control['custom_attributes'] ) ) {
[180] Fix | Delete
// Custom URL attributes should come as a string of comma-delimited key|value pairs
[181] Fix | Delete
$attributes = array_merge( $attributes, Utils::parse_custom_attributes( $url_control['custom_attributes'] ) );
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
return $attributes;
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
public static function vimeo( $embed, $setting ) {
[188] Fix | Delete
[189] Fix | Delete
if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'VIMEO' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'vimeo' ) {
[190] Fix | Delete
return $embed;
[191] Fix | Delete
}
[192] Fix | Delete
preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
[193] Fix | Delete
$url_full = $match[1];
[194] Fix | Delete
$params = [
[195] Fix | Delete
'color' => str_replace('#', '', isset($setting['embedpress_pro_vimeo_color']) ? $setting['embedpress_pro_vimeo_color'] : ''),
[196] Fix | Delete
'title' => $setting['embedpress_pro_vimeo_display_title'] === 'yes' ? 1 : 0,
[197] Fix | Delete
'byline' => $setting['embedpress_pro_vimeo_display_author'] === 'yes' ? 1 : 0,
[198] Fix | Delete
'portrait' => $setting['embedpress_pro_vimeo_avatar'] === 'yes' ? 1 : 0,
[199] Fix | Delete
'autopause' => 0,
[200] Fix | Delete
];
[201] Fix | Delete
if ( $setting['embedpress_pro_vimeo_auto_play'] === 'yes' ) {
[202] Fix | Delete
$params['autoplay'] = 1;
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
if ( is_embedpress_pro_active() ) {
[206] Fix | Delete
if ( $setting['embedpress_pro_vimeo_loop'] === 'yes' ) {
[207] Fix | Delete
$params['loop'] = 1;
[208] Fix | Delete
}
[209] Fix | Delete
if ( $setting['embedpress_pro_vimeo_autopause'] === 'yes' ) {
[210] Fix | Delete
$params['autopause'] = 1;
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
if ( $setting['embedpress_pro_vimeo_autopause'] !== 'yes' ) {
[214] Fix | Delete
$params ['dnt'] = $setting['embedpress_pro_vimeo_dnt'] === 'yes' ? 1 : 0;
[215] Fix | Delete
}
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
[219] Fix | Delete
$url_modified = str_replace("dnt=1&", "", $url_full);
[220] Fix | Delete
[221] Fix | Delete
foreach ( $params as $param => $value ) {
[222] Fix | Delete
$url_modified = add_query_arg( $param, $value, $url_modified );
[223] Fix | Delete
}
[224] Fix | Delete
[225] Fix | Delete
[226] Fix | Delete
$url_modified .= '#t=' . $setting['embedpress_pro_video_start_time'];
[227] Fix | Delete
// Replaces the old url with the new one.
[228] Fix | Delete
$embed->embed = str_replace( $url_full, $url_modified, $embed->embed );
[229] Fix | Delete
if ( is_embedpress_pro_active() ) {
[230] Fix | Delete
return self::apply_cta_markup( $embed, $setting, 'vimeo' );
[231] Fix | Delete
}
[232] Fix | Delete
[233] Fix | Delete
return $embed;
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
public static function wistia( $embed, $setting ) {
[237] Fix | Delete
if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'WISTIA, INC.' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'wistia' ) {
[238] Fix | Delete
return $embed;
[239] Fix | Delete
}
[240] Fix | Delete
preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
[241] Fix | Delete
[242] Fix | Delete
$url_full = $match[1];
[243] Fix | Delete
[244] Fix | Delete
// Parse the url to retrieve all its info like variables etc.
[245] Fix | Delete
$query = parse_url( $embed->url, PHP_URL_QUERY );
[246] Fix | Delete
$url = str_replace( '?' . $query, '', $url_full );
[247] Fix | Delete
[248] Fix | Delete
if ($query !== null) {
[249] Fix | Delete
parse_str($query, $params);
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
// Set the class in the attributes
[253] Fix | Delete
$embed->attributes->class = str_replace( '{provider_alias}', 'wistia', $embed->attributes->class );
[254] Fix | Delete
$embed->embed = str_replace( 'ose-wistia, inc.', 'ose-wistia', $embed->embed );
[255] Fix | Delete
[256] Fix | Delete
// Embed Options
[257] Fix | Delete
$embedOptions = new \stdClass;
[258] Fix | Delete
$embedOptions->videoFoam = false;
[259] Fix | Delete
$embedOptions->fullscreenButton = ( $setting['embedpress_pro_wistia_fullscreen_button'] === 'yes' );
[260] Fix | Delete
$embedOptions->smallPlayButton = ( $setting['embedpress_pro_wistia_small_play_button'] === 'yes' );
[261] Fix | Delete
$embedOptions->autoPlay = ( $setting['embedpress_pro_wistia_auto_play'] === 'yes' );
[262] Fix | Delete
$embedOptions->playerColor = $setting['embedpress_pro_wistia_color'];
[263] Fix | Delete
$embedOptions->playbar = ( $setting['embedpress_pro_wistia_playbar'] === 'yes' );
[264] Fix | Delete
if($setting['embedpress_pro_video_start_time']){
[265] Fix | Delete
$embedOptions->time = $setting['embedpress_pro_video_start_time'];
[266] Fix | Delete
}
[267] Fix | Delete
if ( is_embedpress_pro_active() ) {
[268] Fix | Delete
$embedOptions->volumeControl = ( $setting['embedpress_pro_wistia_volume_control'] === 'yes' );
[269] Fix | Delete
[270] Fix | Delete
$volume = isset($setting['embedpress_pro_wistia_volume']['size']) ? (float) $setting['embedpress_pro_wistia_volume']['size'] : 0;
[271] Fix | Delete
if ( $volume > 1 ) {
[272] Fix | Delete
$volume = $volume / 100;
[273] Fix | Delete
}
[274] Fix | Delete
$embedOptions->volume = $volume;
[275] Fix | Delete
}
[276] Fix | Delete
[277] Fix | Delete
[278] Fix | Delete
// Plugins
[279] Fix | Delete
$pluginsBaseURL = plugins_url( '../assets/js/wistia/min', dirname( __DIR__ ) . '/embedpress-Wistia.php' );
[280] Fix | Delete
[281] Fix | Delete
$pluginList = [];
[282] Fix | Delete
[283] Fix | Delete
// Resumable
[284] Fix | Delete
[285] Fix | Delete
if ( $setting['embedpress_pro_wistia_resumable'] === 'yes' ) {
[286] Fix | Delete
// Add the resumable plugin
[287] Fix | Delete
$pluginList['resumable'] = [
[288] Fix | Delete
'src' => $pluginsBaseURL . '/resumable.min.js',
[289] Fix | Delete
'async' => true,
[290] Fix | Delete
];
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
[294] Fix | Delete
// Add a fix for the autoplay and resumable work better together
[295] Fix | Delete
if ( isset( $options->autoPlay ) ) {
[296] Fix | Delete
if ( $setting['embedpress_pro_wistia_resumable'] === 'yes' ) {
[297] Fix | Delete
$pluginList['fixautoplayresumable'] = [
[298] Fix | Delete
'src' => $pluginsBaseURL . '/fixautoplayresumable.min.js',
[299] Fix | Delete
];
[300] Fix | Delete
}
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
// Closed Captions plugin
[304] Fix | Delete
if ( is_embedpress_pro_active() ) {
[305] Fix | Delete
if ( $setting['embedpress_pro_wistia_captions'] === 'yes' ) {
[306] Fix | Delete
$isCaptionsEnabled = ( $setting['embedpress_pro_wistia_captions'] === 'yes' );
[307] Fix | Delete
$isCaptionsEnabledByDefault = ( $setting['embedpress_pro_wistia_captions_enabled_by_default'] === 'yes' );
[308] Fix | Delete
if ( $isCaptionsEnabled ) {
[309] Fix | Delete
$pluginList['captions-v1'] = [
[310] Fix | Delete
'onByDefault' => $isCaptionsEnabledByDefault,
[311] Fix | Delete
];
[312] Fix | Delete
}
[313] Fix | Delete
$embedOptions->captions = $isCaptionsEnabled;
[314] Fix | Delete
$embedOptions->captionsDefault = $isCaptionsEnabledByDefault;
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
// Rewind plugin
[321] Fix | Delete
if ( $setting['embedpress_pro_wistia_rewind'] === 'yes' ) {
[322] Fix | Delete
[323] Fix | Delete
$embedOptions->rewindTime = (int) $setting['embedpress_pro_wistia_rewind_time'];
[324] Fix | Delete
$pluginList['rewind'] = [
[325] Fix | Delete
'src' => $pluginsBaseURL . '/rewind.min.js',
[326] Fix | Delete
];
[327] Fix | Delete
[328] Fix | Delete
}
[329] Fix | Delete
// Focus plugin
[330] Fix | Delete
if ( $setting['embedpress_pro_wistia_focus'] === 'yes' ) {
[331] Fix | Delete
$isFocusEnabled = ( $setting['embedpress_pro_wistia_focus'] === 'yes' );
[332] Fix | Delete
$pluginList['dimthelights'] = [
[333] Fix | Delete
'src' => $pluginsBaseURL . '/dimthelights.min.js',
[334] Fix | Delete
'autoDim' => $isFocusEnabled,
[335] Fix | Delete
];
[336] Fix | Delete
[337] Fix | Delete
$embedOptions->focus = $isFocusEnabled;
[338] Fix | Delete
}
[339] Fix | Delete
$embedOptions->plugin = $pluginList;
[340] Fix | Delete
$embedOptions = json_encode( $embedOptions );
[341] Fix | Delete
[342] Fix | Delete
// Get the video ID
[343] Fix | Delete
$videoId = self::get_wistia_video_from_url( $embed->url );
[344] Fix | Delete
$shortVideoId = substr( $videoId, 0, 3 );
[345] Fix | Delete
[346] Fix | Delete
// Responsive?
[347] Fix | Delete
[348] Fix | Delete
$class = [
[349] Fix | Delete
'wistia_embed',
[350] Fix | Delete
'wistia_async_' . $videoId,
[351] Fix | Delete
];
[352] Fix | Delete
[353] Fix | Delete
$attribs = [
[354] Fix | Delete
sprintf( 'id="wistia_%s"', $videoId ),
[355] Fix | Delete
sprintf( 'class="%s"', join( ' ', $class ) ),
[356] Fix | Delete
sprintf( 'style="width:%spx; height:%spx;"', $embed->attributes->{'data-width'}, $embed->attributes->{'data-height'} ),
[357] Fix | Delete
];
[358] Fix | Delete
[359] Fix | Delete
$labels = [
[360] Fix | Delete
'watch_from_beginning' => __( 'Watch from the beginning', 'embedpress-pro' ),
[361] Fix | Delete
'skip_to_where_you_left_off' => __( 'Skip to where you left off', 'embedpress-pro' ),
[362] Fix | Delete
'you_have_watched_it_before' => __( 'It looks like you\'ve watched<br />part of this video before!', 'embedpress-pro' ),
[363] Fix | Delete
];
[364] Fix | Delete
$labels = json_encode( $labels );
[365] Fix | Delete
[366] Fix | Delete
preg_match( '/ose-uid-([a-z0-9]*)/', $embed->embed, $matches );
[367] Fix | Delete
$uid = $matches[1];
[368] Fix | Delete
[369] Fix | Delete
$html = "<div class=\"embedpress-wrapper ose-wistia ose-uid-{$uid} responsive\">";
[370] Fix | Delete
$html .= '<script src="https://fast.wistia.com/assets/external/E-v1.js" async></script>';
[371] Fix | Delete
$html .= "<script>window.pp_embed_wistia_labels = {$labels};</script>\n";
[372] Fix | Delete
$html .= "<script>window._wq = window._wq || []; _wq.push({\"{$shortVideoId}\": {$embedOptions}});</script>\n";
[373] Fix | Delete
$html .= '<div ' . join( ' ', $attribs ) . "></div>\n";
[374] Fix | Delete
$html .= '</div>';
[375] Fix | Delete
$embed->embed = $html;
[376] Fix | Delete
if ( is_embedpress_pro_active() ) {
[377] Fix | Delete
return self::apply_cta_markup( $embed, $setting, 'wistia' );
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
return $embed;
[381] Fix | Delete
}
[382] Fix | Delete
[383] Fix | Delete
/**
[384] Fix | Delete
* Get the Video ID from the URL
[385] Fix | Delete
*
[386] Fix | Delete
* @param string $url
[387] Fix | Delete
*
[388] Fix | Delete
* @return string
[389] Fix | Delete
*/
[390] Fix | Delete
public static function get_wistia_video_from_url( $url ) {
[391] Fix | Delete
// https://fast.wistia.com/embed/medias/xf1edjzn92.jsonp
[392] Fix | Delete
// https://ostraining-1.wistia.com/medias/xf1edjzn92
[393] Fix | Delete
preg_match( '#\/medias\\\?\/([a-z0-9]+)\.?#i', $url, $matches );
[394] Fix | Delete
[395] Fix | Delete
$id = false;
[396] Fix | Delete
if ( isset( $matches[1] ) ) {
[397] Fix | Delete
$id = $matches[1];
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
return $id;
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
public static function soundcloud( $embed, $setting ) {
[404] Fix | Delete
[405] Fix | Delete
if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'SOUNDCLOUD' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'soundcloud' ) {
[406] Fix | Delete
return $embed;
[407] Fix | Delete
}
[408] Fix | Delete
preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
[409] Fix | Delete
$url_full = $match[1];
[410] Fix | Delete
$params = [
[411] Fix | Delete
'color' => str_replace( '#', '', $setting['embedpress_pro_soundcloud_color'] ),
[412] Fix | Delete
'visual' => $setting['embedpress_pro_soundcloud_visual'] === 'yes' ? 'true' : 'false',
[413] Fix | Delete
'auto_play' => $setting['embedpress_pro_soundcloud_autoplay'] === 'yes' ? 'true' : 'false',
[414] Fix | Delete
'sharing' => $setting['embedpress_pro_soundcloud_share_button'] === 'yes' ? 'true' : 'false',
[415] Fix | Delete
'show_comments' => $setting['embedpress_pro_soundcloud_comments'] === 'yes' ? 'true' : 'false',
[416] Fix | Delete
'show_artwork' => $setting['embedpress_pro_soundcloud_artwork'] === 'yes' ? 'true' : 'false',
[417] Fix | Delete
'show_playcount' => $setting['embedpress_pro_soundcloud_play_count'] === 'yes' ? 'true' : 'false',
[418] Fix | Delete
'show_user' => $setting['embedpress_pro_soundcloud_user_name'] === 'yes' ? 'true' : 'false',
[419] Fix | Delete
'buying' => 'false',
[420] Fix | Delete
'download' => 'false',
[421] Fix | Delete
];
[422] Fix | Delete
if ( is_embedpress_pro_active() ) {
[423] Fix | Delete
$params['buying'] = $setting['embedpress_pro_soundcloud_buy_button'] === 'yes' ? 'true' : 'false';
[424] Fix | Delete
$params['download'] = $setting['embedpress_pro_soundcloud_download_button'] === 'yes' ? 'true' : 'false';
[425] Fix | Delete
}
[426] Fix | Delete
[427] Fix | Delete
$url_modified = $url_full;
[428] Fix | Delete
foreach ( $params as $param => $value ) {
[429] Fix | Delete
$url_modified = add_query_arg( $param, $value, $url_modified );
[430] Fix | Delete
}
[431] Fix | Delete
[432] Fix | Delete
// Replaces the old url with the new one.
[433] Fix | Delete
$embed->embed = str_replace( $url_full, $url_modified, $embed->embed );
[434] Fix | Delete
if ( 'false' === $params['visual'] ) {
[435] Fix | Delete
$embed->embed = str_replace( 'height="400"', 'height="200 !important"', $embed->embed );
[436] Fix | Delete
}
[437] Fix | Delete
[438] Fix | Delete
return $embed;
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
public static function dailymotion( $embed, $setting ) {
[442] Fix | Delete
if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'DAILYMOTION' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'dailymotion' ) {
[443] Fix | Delete
return $embed;
[444] Fix | Delete
}
[445] Fix | Delete
preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
[446] Fix | Delete
$url_full = $match[1];
[447] Fix | Delete
$params = [
[448] Fix | Delete
'ui-highlight' => str_replace( '#', '', $setting['embedpress_pro_dailymotion_control_color'] ),
[449] Fix | Delete
'start' => isset( $setting['embedpress_pro_video_start_time'] ) ? (int) $setting['embedpress_pro_video_start_time'] : 0,
[450] Fix | Delete
'mute' => $setting['embedpress_pro_dailymotion_mute'] === 'yes' ? 1 : 0,
[451] Fix | Delete
'autoplay' => $setting['embedpress_pro_dailymotion_autoplay'] === 'yes' ? 1 : 0,
[452] Fix | Delete
'controls' => $setting['embedpress_pro_dailymotion_player_control'] === 'yes' ? 1 : 0,
[453] Fix | Delete
'ui-start-screen-info' => $setting['embedpress_pro_dailymotion_video_info'] === 'yes' ? 1 : 0,
[454] Fix | Delete
'endscreen-enable' => 0,
[455] Fix | Delete
];
[456] Fix | Delete
[457] Fix | Delete
if ( $setting['embedpress_pro_dailymotion_play_on_mobile'] === 'yes' ) {
[458] Fix | Delete
$params['playsinline'] = 1;
[459] Fix | Delete
}
[460] Fix | Delete
if ( is_embedpress_pro_active() ) {
[461] Fix | Delete
$params['ui-logo'] = isset( $setting['embedpress_pro_dailymotion_ui_logo']) && ($setting['embedpress_pro_dailymotion_ui_logo'] === 'yes') ? 1 : 0;
[462] Fix | Delete
}
[463] Fix | Delete
$url_modified = $url_full;
[464] Fix | Delete
foreach ( $params as $param => $value ) {
[465] Fix | Delete
$url_modified = add_query_arg( $param, $value, $url_modified );
[466] Fix | Delete
}
[467] Fix | Delete
$embed->embed = str_replace( $url_full, $url_modified, $embed->embed );
[468] Fix | Delete
if ( is_embedpress_pro_active() ) {
[469] Fix | Delete
return self::apply_cta_markup( $embed, $setting, 'dailymotion' );
[470] Fix | Delete
}
[471] Fix | Delete
return $embed;
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
public static function twitch( $embed_content, $settings ) {
[475] Fix | Delete
if ( ! isset( $embed_content->embed ) || $settings['embedpress_pro_embeded_source'] !== 'twitch' ) {
[476] Fix | Delete
return $embed_content;
[477] Fix | Delete
}
[478] Fix | Delete
$e = current( $embed_content );
[479] Fix | Delete
[480] Fix | Delete
if ( ! isset( $e['provider_name'] ) || strtoupper( $e['provider_name'] ) !== 'TWITCH' ) {
[481] Fix | Delete
return $embed_content;
[482] Fix | Delete
}
[483] Fix | Delete
$time = '0h0m0s';
[484] Fix | Delete
$type = isset( $e['type'] ) ? $e['type'] : '';
[485] Fix | Delete
$content_id = isset( $e['content_id'] ) ? $e['content_id'] : '';
[486] Fix | Delete
$channel = 'channel' === $type ? $content_id : '';
[487] Fix | Delete
$video = 'video' === $type ? $content_id : '';
[488] Fix | Delete
$full_screen = ( 'yes' === $settings['embedpress_pro_fs'] ) ? 'true' : 'false';
[489] Fix | Delete
$autoplay = ( 'yes' === $settings['embedpress_pro_twitch_autoplay'] ) ? 'true' : 'false';
[490] Fix | Delete
$layout = 'video';
[491] Fix | Delete
$width = (int) $settings['width']['size'];
[492] Fix | Delete
$height = (int) $settings['height']['size'];
[493] Fix | Delete
if ( ! empty( $settings['embedpress_pro_video_start_time'] ) ) {
[494] Fix | Delete
$ta = explode( ':', gmdate( "G:i:s", $settings['embedpress_pro_video_start_time'] ) );
[495] Fix | Delete
$h = $ta[0] . 'h';
[496] Fix | Delete
$m = ( $ta[1] * 1 ) . 'm';
[497] Fix | Delete
$s = ( $ta[2] * 1 ) . 's';
[498] Fix | Delete
$time = $h . $m . $s;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function