: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace EmbedPress\Includes\Classes;
use Elementor\Group_Control_Image_Size;
use EmbedPress\Includes\Classes\Helper;
class Elementor_Enhancer {
public static function youtube( $embed, $setting ) {
if ( isset( $setting['embedpress_pro_embeded_source'] ) && 'youtube' === $setting['embedpress_pro_embeded_source'] && isset( $embed->embed ) && preg_match( '/src=\"(.+?)\"/', $embed->embed, $match ) ) {
$query = parse_url( $url_full, PHP_URL_QUERY );
parse_str( $query, $params );
$params['controls'] = $setting['embedpress_pro_youtube_display_controls'];
$params['iv_load_policy'] = $setting['embedpress_pro_youtube_display_video_annotations'];
$params['fs'] = ( $setting['embedpress_pro_youtube_enable_fullscreen_button'] === 'yes' ) ? 1 : 0;
$params['rel'] = ( $setting['embedpress_pro_youtube_display_related_videos'] === 'yes' ) ? 1 : 0;
$params['end'] = $setting['embedpress_pro_youtube_end_time'];
if ( $setting['embedpress_pro_youtube_auto_play'] === 'yes' ) {
$params['start'] = $setting['embedpress_pro_video_start_time'];
$params['color'] = $setting['embedpress_pro_youtube_progress_bar_color'];
if ( is_embedpress_pro_active() ) {
$params['modestbranding'] = $setting['embedpress_pro_youtube_modest_branding'];
if ( $setting['embedpress_pro_youtube_force_closed_captions'] === 'yes' ) {
$params['cc_load_policy'] = 1;
preg_match( '/(.+)?\?/', $url_full, $url );
// Reassemble the url with the new variables.
$url_modified = $url . '?';
foreach ( $params as $paramName => $paramValue ) {
$url_modified .= $paramName . '=' . $paramValue . '&';
// Replaces the old url with the new one.
$embed->embed = str_replace( $url_full, rtrim( $url_modified, '&' ), $embed->embed );
if ( is_embedpress_pro_active() ) {
$embed = self::apply_cta_markup( $embed, $setting, 'youtube' );
public static function apply_cta_markup( $embed, $settings, $provider_name = '' ) {
if ( empty( $settings["embedpress_pro_{$provider_name}_logo"] ) || empty( $settings["embedpress_pro_{$provider_name}_logo"]['url'] ) ) {
$img = Group_Control_Image_Size::get_attachment_image_html( $settings, "embedpress_pro_{$provider_name}_logo" );
$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%';
$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%';
$cssClass = isset( $embed->url ) ? '.ose-uid-' . md5( $embed->url ) : ".ose-{$provider_name}";
.ep-embed-content-wraper .watermark {
.ep-embed-content-wraper .watermark {
-o-transition: opacity 0.5s ease-in-out;
-moz-transition: opacity 0.5s ease-in-out;
-webkit-transition: opacity 0.5s ease-in-out;
transition: opacity 0.5s ease-in-out;
<?php echo esc_html($cssClass); ?> .watermark {
bottom: <?php echo esc_html($y); ?>;
right: <?php echo esc_html($x); ?>;
.ep-embed-content-wraper .watermark:hover {
if ( ! class_exists( '\simple_html_dom' ) ) {
include_once EMBEDPRESS_PATH_CORE . 'simple_html_dom.php';
if ( ! empty( $settings["embedpress_pro_{$provider_name}_cta"] ) && ! empty( $settings["embedpress_pro_{$provider_name}_cta"]['url'] ) ) {
$url = $settings["embedpress_pro_{$provider_name}_cta"]['url'];
$atts = self::get_link_attributes( $settings["embedpress_pro_{$provider_name}_cta"] );
foreach ( $atts as $att => $value ) {
$attributes .= $att . '="' . esc_attr( $value ) . '" ';
$cta .= sprintf( '<a %s>', trim( $attributes ) );
$imgDom = str_get_html( $img );
$imgDom = $imgDom->find( 'img', 0 );
$imgDom->setAttribute( 'class', 'watermark' );
$imgDom->removeAttribute( 'style' );
$imgDom->setAttribute( 'width', 'auto' );
$imgDom->setAttribute( 'height', 'auto' );
$dom = str_get_html( $embed->embed );
$wrapDiv = $dom->find( "div.ose-{$provider_name}", 0 );
if ( ! empty( $wrapDiv ) && is_object( $wrapDiv ) ) {
$wrapDiv->innertext .= $cta;
$markup = ob_get_clean();
$embed->embed = $style . $markup;
public static function get_link_attributes( $url_control ) {
if ( ! empty( $url_control['url'] ) ) {
$allowed_protocols = array_merge( wp_allowed_protocols(), [
$attributes['href'] = esc_url( $url_control['url'], $allowed_protocols );
if ( ! empty( $url_control['is_external'] ) ) {
$attributes['target'] = '_blank';
if ( ! empty( $url_control['nofollow'] ) ) {
$attributes['rel'] = 'nofollow';
if ( ! empty( $url_control['custom_attributes'] ) ) {
// Custom URL attributes should come as a string of comma-delimited key|value pairs
$attributes = array_merge( $attributes, Utils::parse_custom_attributes( $url_control['custom_attributes'] ) );
public static function vimeo( $embed, $setting ) {
if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'VIMEO' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'vimeo' ) {
preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
'color' => str_replace('#', '', isset($setting['embedpress_pro_vimeo_color']) ? $setting['embedpress_pro_vimeo_color'] : ''),
'title' => $setting['embedpress_pro_vimeo_display_title'] === 'yes' ? 1 : 0,
'byline' => $setting['embedpress_pro_vimeo_display_author'] === 'yes' ? 1 : 0,
'portrait' => $setting['embedpress_pro_vimeo_avatar'] === 'yes' ? 1 : 0,
if ( $setting['embedpress_pro_vimeo_auto_play'] === 'yes' ) {
if ( is_embedpress_pro_active() ) {
if ( $setting['embedpress_pro_vimeo_loop'] === 'yes' ) {
if ( $setting['embedpress_pro_vimeo_autopause'] === 'yes' ) {
$params['autopause'] = 1;
if ( $setting['embedpress_pro_vimeo_autopause'] !== 'yes' ) {
$params ['dnt'] = $setting['embedpress_pro_vimeo_dnt'] === 'yes' ? 1 : 0;
$url_modified = str_replace("dnt=1&", "", $url_full);
foreach ( $params as $param => $value ) {
$url_modified = add_query_arg( $param, $value, $url_modified );
$url_modified .= '#t=' . $setting['embedpress_pro_video_start_time'];
// Replaces the old url with the new one.
$embed->embed = str_replace( $url_full, $url_modified, $embed->embed );
if ( is_embedpress_pro_active() ) {
return self::apply_cta_markup( $embed, $setting, 'vimeo' );
public static function wistia( $embed, $setting ) {
if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'WISTIA, INC.' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'wistia' ) {
preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
// Parse the url to retrieve all its info like variables etc.
$query = parse_url( $embed->url, PHP_URL_QUERY );
$url = str_replace( '?' . $query, '', $url_full );
parse_str($query, $params);
// Set the class in the attributes
$embed->attributes->class = str_replace( '{provider_alias}', 'wistia', $embed->attributes->class );
$embed->embed = str_replace( 'ose-wistia, inc.', 'ose-wistia', $embed->embed );
$embedOptions = new \stdClass;
$embedOptions->videoFoam = false;
$embedOptions->fullscreenButton = ( $setting['embedpress_pro_wistia_fullscreen_button'] === 'yes' );
$embedOptions->smallPlayButton = ( $setting['embedpress_pro_wistia_small_play_button'] === 'yes' );
$embedOptions->autoPlay = ( $setting['embedpress_pro_wistia_auto_play'] === 'yes' );
$embedOptions->playerColor = $setting['embedpress_pro_wistia_color'];
$embedOptions->playbar = ( $setting['embedpress_pro_wistia_playbar'] === 'yes' );
if($setting['embedpress_pro_video_start_time']){
$embedOptions->time = $setting['embedpress_pro_video_start_time'];
if ( is_embedpress_pro_active() ) {
$embedOptions->volumeControl = ( $setting['embedpress_pro_wistia_volume_control'] === 'yes' );
$volume = isset($setting['embedpress_pro_wistia_volume']['size']) ? (float) $setting['embedpress_pro_wistia_volume']['size'] : 0;
$embedOptions->volume = $volume;
$pluginsBaseURL = plugins_url( '../assets/js/wistia/min', dirname( __DIR__ ) . '/embedpress-Wistia.php' );
if ( $setting['embedpress_pro_wistia_resumable'] === 'yes' ) {
// Add the resumable plugin
$pluginList['resumable'] = [
'src' => $pluginsBaseURL . '/resumable.min.js',
// Add a fix for the autoplay and resumable work better together
if ( isset( $options->autoPlay ) ) {
if ( $setting['embedpress_pro_wistia_resumable'] === 'yes' ) {
$pluginList['fixautoplayresumable'] = [
'src' => $pluginsBaseURL . '/fixautoplayresumable.min.js',
// Closed Captions plugin
if ( is_embedpress_pro_active() ) {
if ( $setting['embedpress_pro_wistia_captions'] === 'yes' ) {
$isCaptionsEnabled = ( $setting['embedpress_pro_wistia_captions'] === 'yes' );
$isCaptionsEnabledByDefault = ( $setting['embedpress_pro_wistia_captions_enabled_by_default'] === 'yes' );
if ( $isCaptionsEnabled ) {
$pluginList['captions-v1'] = [
'onByDefault' => $isCaptionsEnabledByDefault,
$embedOptions->captions = $isCaptionsEnabled;
$embedOptions->captionsDefault = $isCaptionsEnabledByDefault;
if ( $setting['embedpress_pro_wistia_rewind'] === 'yes' ) {
$embedOptions->rewindTime = (int) $setting['embedpress_pro_wistia_rewind_time'];
$pluginList['rewind'] = [
'src' => $pluginsBaseURL . '/rewind.min.js',
if ( $setting['embedpress_pro_wistia_focus'] === 'yes' ) {
$isFocusEnabled = ( $setting['embedpress_pro_wistia_focus'] === 'yes' );
$pluginList['dimthelights'] = [
'src' => $pluginsBaseURL . '/dimthelights.min.js',
'autoDim' => $isFocusEnabled,
$embedOptions->focus = $isFocusEnabled;
$embedOptions->plugin = $pluginList;
$embedOptions = json_encode( $embedOptions );
$videoId = self::get_wistia_video_from_url( $embed->url );
$shortVideoId = substr( $videoId, 0, 3 );
'wistia_async_' . $videoId,
sprintf( 'id="wistia_%s"', $videoId ),
sprintf( 'class="%s"', join( ' ', $class ) ),
sprintf( 'style="width:%spx; height:%spx;"', $embed->attributes->{'data-width'}, $embed->attributes->{'data-height'} ),
'watch_from_beginning' => __( 'Watch from the beginning', 'embedpress-pro' ),
'skip_to_where_you_left_off' => __( 'Skip to where you left off', 'embedpress-pro' ),
'you_have_watched_it_before' => __( 'It looks like you\'ve watched<br />part of this video before!', 'embedpress-pro' ),
$labels = json_encode( $labels );
preg_match( '/ose-uid-([a-z0-9]*)/', $embed->embed, $matches );
$html = "<div class=\"embedpress-wrapper ose-wistia ose-uid-{$uid} responsive\">";
$html .= '<script src="https://fast.wistia.com/assets/external/E-v1.js" async></script>';
$html .= "<script>window.pp_embed_wistia_labels = {$labels};</script>\n";
$html .= "<script>window._wq = window._wq || []; _wq.push({\"{$shortVideoId}\": {$embedOptions}});</script>\n";
$html .= '<div ' . join( ' ', $attribs ) . "></div>\n";
if ( is_embedpress_pro_active() ) {
return self::apply_cta_markup( $embed, $setting, 'wistia' );
* Get the Video ID from the URL
public static function get_wistia_video_from_url( $url ) {
// https://fast.wistia.com/embed/medias/xf1edjzn92.jsonp
// https://ostraining-1.wistia.com/medias/xf1edjzn92
preg_match( '#\/medias\\\?\/([a-z0-9]+)\.?#i', $url, $matches );
if ( isset( $matches[1] ) ) {
public static function soundcloud( $embed, $setting ) {
if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'SOUNDCLOUD' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'soundcloud' ) {
preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
'color' => str_replace( '#', '', $setting['embedpress_pro_soundcloud_color'] ),
'visual' => $setting['embedpress_pro_soundcloud_visual'] === 'yes' ? 'true' : 'false',
'auto_play' => $setting['embedpress_pro_soundcloud_autoplay'] === 'yes' ? 'true' : 'false',
'sharing' => $setting['embedpress_pro_soundcloud_share_button'] === 'yes' ? 'true' : 'false',
'show_comments' => $setting['embedpress_pro_soundcloud_comments'] === 'yes' ? 'true' : 'false',
'show_artwork' => $setting['embedpress_pro_soundcloud_artwork'] === 'yes' ? 'true' : 'false',
'show_playcount' => $setting['embedpress_pro_soundcloud_play_count'] === 'yes' ? 'true' : 'false',
'show_user' => $setting['embedpress_pro_soundcloud_user_name'] === 'yes' ? 'true' : 'false',
if ( is_embedpress_pro_active() ) {
$params['buying'] = $setting['embedpress_pro_soundcloud_buy_button'] === 'yes' ? 'true' : 'false';
$params['download'] = $setting['embedpress_pro_soundcloud_download_button'] === 'yes' ? 'true' : 'false';
$url_modified = $url_full;
foreach ( $params as $param => $value ) {
$url_modified = add_query_arg( $param, $value, $url_modified );
// Replaces the old url with the new one.
$embed->embed = str_replace( $url_full, $url_modified, $embed->embed );
if ( 'false' === $params['visual'] ) {
$embed->embed = str_replace( 'height="400"', 'height="200 !important"', $embed->embed );
public static function dailymotion( $embed, $setting ) {
if ( ! isset( $embed->provider_name ) || strtoupper( $embed->provider_name ) !== 'DAILYMOTION' || ! isset( $embed->embed ) || $setting['embedpress_pro_embeded_source'] !== 'dailymotion' ) {
preg_match( '/src=\"(.+?)\"/', $embed->embed, $match );
'ui-highlight' => str_replace( '#', '', $setting['embedpress_pro_dailymotion_control_color'] ),
'start' => isset( $setting['embedpress_pro_video_start_time'] ) ? (int) $setting['embedpress_pro_video_start_time'] : 0,
'mute' => $setting['embedpress_pro_dailymotion_mute'] === 'yes' ? 1 : 0,
'autoplay' => $setting['embedpress_pro_dailymotion_autoplay'] === 'yes' ? 1 : 0,
'controls' => $setting['embedpress_pro_dailymotion_player_control'] === 'yes' ? 1 : 0,
'ui-start-screen-info' => $setting['embedpress_pro_dailymotion_video_info'] === 'yes' ? 1 : 0,
if ( $setting['embedpress_pro_dailymotion_play_on_mobile'] === 'yes' ) {
$params['playsinline'] = 1;
if ( is_embedpress_pro_active() ) {
$params['ui-logo'] = isset( $setting['embedpress_pro_dailymotion_ui_logo']) && ($setting['embedpress_pro_dailymotion_ui_logo'] === 'yes') ? 1 : 0;
$url_modified = $url_full;
foreach ( $params as $param => $value ) {
$url_modified = add_query_arg( $param, $value, $url_modified );
$embed->embed = str_replace( $url_full, $url_modified, $embed->embed );
if ( is_embedpress_pro_active() ) {
return self::apply_cta_markup( $embed, $setting, 'dailymotion' );
public static function twitch( $embed_content, $settings ) {
if ( ! isset( $embed_content->embed ) || $settings['embedpress_pro_embeded_source'] !== 'twitch' ) {
$e = current( $embed_content );
if ( ! isset( $e['provider_name'] ) || strtoupper( $e['provider_name'] ) !== 'TWITCH' ) {
$type = isset( $e['type'] ) ? $e['type'] : '';
$content_id = isset( $e['content_id'] ) ? $e['content_id'] : '';
$channel = 'channel' === $type ? $content_id : '';
$video = 'video' === $type ? $content_id : '';
$full_screen = ( 'yes' === $settings['embedpress_pro_fs'] ) ? 'true' : 'false';
$autoplay = ( 'yes' === $settings['embedpress_pro_twitch_autoplay'] ) ? 'true' : 'false';
$width = (int) $settings['width']['size'];
$height = (int) $settings['height']['size'];
if ( ! empty( $settings['embedpress_pro_video_start_time'] ) ) {
$ta = explode( ':', gmdate( "G:i:s", $settings['embedpress_pro_video_start_time'] ) );
$m = ( $ta[1] * 1 ) . 'm';
$s = ( $ta[2] * 1 ) . 's';