: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
return apply_filters('emebedpress_get_options', $options);
public function get_youtube_params($options)
// Handle `autoplay` option.
if (isset($options['autoplay']) && (bool) $options['autoplay'] === true) {
unset($params['autoplay']);
// Handle `controls` option.
if (isset($options['controls']) && in_array((int) $options['controls'], [0, 1, 2])) {
$params['controls'] = (int) $options['controls'];
unset($params['controls']);
if (isset($options['fs']) && in_array((int) $options['fs'], [0, 1])) {
$params['fs'] = (int) $options['fs'];
// Handle `iv_load_policy` option.
if (isset($options['iv_load_policy']) && in_array((int) $options['iv_load_policy'], [1, 3])) {
$params['iv_load_policy'] = (int) $options['iv_load_policy'];
unset($params['iv_load_policy']);
return apply_filters('embedpress_youtube_params', $params);
public function get_vimeo_params($options)
// Handle `display_title` option.
if (isset($options['display_title']) && (bool) $options['display_title'] === true) {
// Handle `autoplay` option.
if (!empty($options['autoplay'])) {
unset($params['autoplay']);
// Handle `color` option.
if (!empty($options['color'])) {
$params['color'] = str_replace('#', '', $options['color']);
return apply_filters('embedpress_vimeo_params', $params);
//--- For CLASSIC AND BLOCK EDITOR
public function enhance_youtube($embed)
$isYoutube = (isset($embed->provider_name) && strtoupper($embed->provider_name) === 'YOUTUBE') || (isset($embed->url) && isset($embed->{$embed->url}) && isset($embed->{$embed->url}['provider_name']) && strtoupper($embed->{$embed->url}['provider_name']) === 'YOUTUBE');
$isYoutube && isset($embed->embed)
&& preg_match('/src=\"(.+?)\"/', $embed->embed, $match)
// for compatibility only, @TODO; remove later after deep testing.
$options = $this->getOptions('youtube', $this->get_youtube_settings_schema());
// Parse the url to retrieve all its info like variables etc.
$query = parse_url($url_full, PHP_URL_QUERY);
parse_str($query, $params);
// Handle `color` option.
if (!empty($options['color'])) {
$params['color'] = $options['color'];
if (isset($options['rel']) && in_array((int) $options['rel'], [0, 1])) {
$params['rel'] = (int) $options['rel'];
// Handle `autoplay` option.
if (isset($options['autoplay']) && (bool) $options['autoplay'] === true) {
unset($params['autoplay']);
// Handle `controls` option.
if (isset($options['controls']) && in_array((int) $options['controls'], [0, 1, 2])) {
$params['controls'] = (int) $options['controls'];
unset($params['controls']);
if (isset($options['start_time'])) {
$params['start'] = $options['start_time'];
if (isset($options['end_time'])) {
$params['end'] = $options['end_time'];
if (isset($options['fs']) && in_array((int) $options['fs'], [0, 1])) {
$params['fs'] = (int) $options['fs'];
// Handle `iv_load_policy` option.
if (isset($options['iv_load_policy']) && in_array((int) $options['iv_load_policy'], [1, 3])) {
$params['iv_load_policy'] = (int) $options['iv_load_policy'];
unset($params['iv_load_policy']);
// pro controls will be handled by the pro so remove it from the free.
$pro_controls = ['cc_load_policy', 'modestbranding'];
foreach ($pro_controls as $pro_control) {
if (isset($params[$pro_control])) {
unset($params[$pro_control]);
preg_match('/(.+)?\?/', $url_full, $url);
if (is_object($embed->attributes) && !empty($embed->attributes)) {
$attributes = (array) $embed->attributes;
$params['controls'] = isset($attributes['data-controls']) ? $attributes['data-controls'] : '1';
$params['iv_load_policy'] = !empty($attributes['data-videoannotations']) && ($attributes['data-videoannotations'] == 'true') ? 1 : 0;
$params['fs'] = !empty($attributes['data-fullscreen']) && ($attributes['data-fullscreen'] == 'true') ? 1 : 0;
$params['rel'] = !empty($attributes['data-relatedvideos']) && ($attributes['data-relatedvideos'] == 'true') ? 1 : 0;
$params['end'] = !empty($attributes['data-endtime']) ? $attributes['data-endtime'] : '';
$params['autoplay'] = !empty($attributes['data-autoplay']) && ($attributes['data-autoplay'] == 'true') ? 1 : 0;
$params['start'] = !empty($attributes['data-starttime']) ? $attributes['data-starttime'] : '';
$params['color'] = !empty($attributes['data-progressbarcolor']) ? $attributes['data-progressbarcolor'] : 'red';
$params['modestbranding'] = empty($attributes['data-modestbranding']) ? 0 : 1; // Reverse the condition value for modestbranding. 0 = display, 1 = do not display
$params['cc_load_policy'] = !empty($attributes['data-closedcaptions']) && ($attributes['data-closedcaptions'] == 'true') ? 0 : 1;
// 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);
public function enhance_vimeo($embed)
isset($embed->provider_name)
&& strtoupper($embed->provider_name) === 'VIMEO'
&& preg_match('/src=\"(.+?)\"/', $embed->embed, $match)
// old schema is for backward compatibility only @todo; remove it in the next version after deep test
$options = $this->getOptions('vimeo', $this->get_vimeo_settings_schema());
// Handle `display_title` option.
if (isset($options['display_title']) && (bool) $options['display_title'] === true) {
// Handle `autoplay` option.
if (isset($options['autoplay']) && (bool) $options['autoplay'] === true) {
unset($params['autoplay']);
// Handle `color` option.
if (!empty($options['color'])) {
$params['color'] = str_replace('#', '', $options['color']);
// Handle `display_author` option.
if (isset($options['display_author']) && (bool) $options['display_author'] === true) {
// Handle `display_avatar` option.
if (isset($options['display_avatar']) && (bool) $options['display_avatar'] === true) {
// NOTE: 'vimeo_dnt' is actually only 'dnt' in the params, so unset 'dnt' only
//@todo; maybe extract unsetting pro vars to a function later
$pro_controls = ['loop', 'autopause', 'dnt',];
foreach ($pro_controls as $pro_control) {
if (isset($params[$pro_control])) {
unset($params[$pro_control]);
if (!empty($params['autopause'])) {
unset($params['amp;dnt']);
// Reassemble the url with the new variables.
$url_modified = str_replace("&dnt=1", "", $url_full);
if (is_object($embed->attributes) && !empty($embed->attributes)) {
$attributes = (array) $embed->attributes;
$attributes = stringToBoolean($attributes);
$params['title'] = !empty($attributes['data-vtitle']) ? 1 : 0;
$params['byline'] = !empty($attributes['data-vauthor']) ? 1 : 0;
$params['portrait'] = !empty($attributes['data-vavatar']) ? 1 : 0;
$params['autoplay'] = !empty($attributes['data-vautoplay']) ? 1 : 0;
$params['loop'] = !empty($attributes['data-vloop']) ? 1 : 0;
$params['autopause'] = !empty($attributes['data-vautopause']) ? 1 : 0;
if (empty($attributes['data-vautopause'])) :
$params['dnt'] = !empty($attributes['data-vdnt']) ? 1 : 0;
$params['color'] = !empty($attributes['data-vscheme']) ? str_replace("#", "", $attributes['data-vscheme']) : '00ADEF';
if (!empty($attributes['data-vstarttime'])) :
$params['t'] = !empty($attributes['data-vstarttime']) ? $attributes['data-vstarttime'] : '';
foreach ($params as $param => $value) {
$url_modified = add_query_arg($param, $value, $url_modified);
$url_modified = str_replace("&t=", "#t=", $url_modified);
foreach ($params as $param => $value) {
$url_modified = add_query_arg($param, $value, $url_modified);
if (empty($attributes['data-vstarttime']) && isset($options['start_time'])) {
$url_modified .= '#t=' . $options['start_time'];
do_action('embedpress_after_modified_url', $url_modified, $url_full, $params);
// Replaces the old url with the new one.
$embed->embed = str_replace($url_full, $url_modified, $embed->embed);
public function enhance_wistia($embed)
isset($embed->provider_name)
&& strtoupper($embed->provider_name) === 'WISTIA, INC.'
&& preg_match('/src=\"(.+?)\"/', $embed->embed, $match)
$options = $this->getOptions('wistia', $this->get_wistia_settings_schema());
// 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 = (isset($options['display_fullscreen_button']) && (bool) $options['display_fullscreen_button'] === true);
$embedOptions->playbar = (isset($options['display_playbar']) && (bool) $options['display_playbar'] === true);
$embedOptions->smallPlayButton = (isset($options['small_play_button']) && (bool) $options['small_play_button'] === true);
$embedOptions->autoPlay = (isset($options['autoplay']) && (bool) $options['autoplay'] === true);
if (!empty($options['start_time'])) {
$embedOptions->time = isset($options['start_time']) ? $options['start_time'] : 0;
if (isset($options['player_color'])) {
$color = $options['player_color'];
$embedOptions->playerColor = $color;
$pluginsBaseURL = plugins_url('assets/js/wistia/min', dirname(__DIR__) . '/embedpress-Wistia.php');
if (isset($options['plugin_resumable'])) {
$isResumableEnabled = $options['plugin_resumable'];
if ($isResumableEnabled) {
// Add the resumable plugin
$pluginList['resumable'] = array(
'src' => $pluginsBaseURL . '/resumable.min.js',
// Add a fix for the autoplay and resumable work better together
if (isset($options->autoPlay)) {
if ($isResumableEnabled) {
$pluginList['fixautoplayresumable'] = array(
'src' => $pluginsBaseURL . '/fixautoplayresumable.min.js'
if (isset($options['plugin_focus'])) {
$isFocusEnabled = $options['plugin_focus'];
$pluginList['dimthelights'] = array(
'src' => $pluginsBaseURL . '/dimthelights.min.js',
'autoDim' => $isFocusEnabled
$embedOptions->focus = $isFocusEnabled;
if (isset($options['plugin_rewind'])) {
if ($options['plugin_rewind']) {
$embedOptions->rewindTime = isset($options['plugin_rewind_time']) ? (int) $options['plugin_rewind_time'] : 10;
$pluginList['rewind'] = array(
'src' => $pluginsBaseURL . '/rewind.min.js'
$embedOptions->plugin = $pluginList;
$embedOptions = json_encode($embedOptions);
$videoId = $this->getVideoIDFromURL($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->width, $embed->height)
'watch_from_beginning' => __('Watch from the beginning', 'embedpress'),
'skip_to_where_you_left_off' => __('Skip to where you left off', 'embedpress'),
'you_have_watched_it_before' => __(
'It looks like you\'ve watched<br />part of this video before!',
$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";
public function enhance_twitch($embed_content)
$e = isset($embed_content->url) && isset($embed_content->{$embed_content->url}) ? $embed_content->{$embed_content->url} : [];
if (isset($e['provider_name']) && strtoupper($e['provider_name']) === 'TWITCH' && isset($embed_content->embed)) {
$settings = $this->getOptions('twitch', $this->get_twitch_settings_schema());
$atts = isset($embed_content->attributes) ? $embed_content->attributes : [];
$content_id = $e['content_id'];
$channel = 'channel' === $type ? $content_id : '';
$video = 'video' === $type ? $content_id : '';
$muted = isset($settings['embedpress_pro_twitch_mute']) && ('yes' === $settings['embedpress_pro_twitch_mute']) ? 'true' : 'false';
$full_screen = isset($settings['embedpress_pro_fs']) && ('yes' === $settings['embedpress_pro_fs']) ? 'true' : 'false';
$autoplay = isset($settings['embedpress_pro_twitch_autoplay']) && ('yes' === $settings['embedpress_pro_twitch_autoplay']) ? 'true' : 'false';
$theme = !empty($settings['embedpress_pro_twitch_theme']) ? esc_attr($settings['embedpress_pro_twitch_theme']) : 'dark';
$width = !empty($atts->{'data-width'}) ? (int) $atts->{'data-width'} : 800;
$height = !empty($atts->{'data-height'}) ? (int) $atts->{'data-height'} : 450;
if (!empty($settings['start_time'])) {
$ta = explode(':', gmdate("G:i:s", $settings['start_time']));
$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}";
$pars_url = wp_parse_url(get_site_url());
$url = !empty($pars_url['host']) ? $url . '&parent=' . $pars_url['host'] : $url;
<div class="embedpress_wrapper" data-url="<?php echo esc_url($embed_content->url); ?>">
<iframe src="<?php echo esc_url($url); ?>" allowfullscreen="" scrolling="no" frameborder="0" allow="autoplay; fullscreen" title="Twitch" sandbox="allow-modals allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox" width="<?php echo esc_attr($width); ?>" height="<?php echo esc_attr($height); ?>" style="max-width: <?php echo esc_attr($width); ?>px; max-height:<?php echo esc_attr($height); ?>px;"></iframe>
$embed_content->embed = $c;
public function enhance_dailymotion($embed)
$options = $this->getOptions('dailymotion', $this->get_dailymotion_settings_schema());
$isDailymotion = (isset($embed->provider_name) && strtoupper($embed->provider_name) === 'DAILYMOTION') || (isset($embed->url) && isset($embed->{$embed->url}) && isset($embed->{$embed->url}['provider_name']) && strtoupper($embed->{$embed->url}['provider_name']) === 'DAILYMOTION');
$isDailymotion && isset($embed->embed)
&& preg_match('/src=\"(.+?)\"/', $embed->embed, $match)
// Parse the url to retrieve all its info like variables etc.
'ui-highlight' => str_replace('#', '', isset($options['color']) ? $options['color'] : null),
'mute' => (int) isset($options['mute']) ? $options['mute'] : null,
'autoplay' => (int) isset($options['autoplay']) ? $options['autoplay'] : null,
'controls' => (int) isset($options['controls']) ? $options['controls'] : null,
'ui-start-screen-info' => (int) isset($options['video_info']) ? $options['video_info'] : null,
if (isset($options['play_on_mobile']) && $options['play_on_mobile'] == '1') {
$params['playsinline'] = 1;
$params['start'] = (int) isset($options['start_time']) ? $options['start_time'] : null;
if (is_embedpress_pro_active()) {
$params['ui-logo'] = (int) isset($options['show_logo']) ? $options['show_logo'] : null;