: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$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);
public function enhance_soundcloud($embed)
$isSoundcloud = (isset($embed->provider_name) && strtoupper($embed->provider_name) === 'SOUNDCLOUD') || (isset($embed->url) && isset($embed->{$embed->url}) && isset($embed->{$embed->url}['provider_name']) && strtoupper($embed->{$embed->url}['provider_name']) === 'SOUNDCLOUD');
$isSoundcloud && isset($embed->embed)
&& preg_match('/src=\"(.+?)\"/', $embed->embed, $match)
$options = $this->getOptions('soundcloud', $this->get_soundcloud_settings_schema());
// Parse the url to retrieve all its info like variables etc.
'color' => str_replace('#', '', $options['color']),
'visual' => isset($options['visual']) && $options['visual'] == '1' ? 'true' : 'false',
'auto_play' => isset($options['autoplay']) && $options['autoplay'] == '1' ? 'true' : 'false',
'sharing' => isset($options['share_button']) && $options['share_button'] == '1' ? 'true' : 'false',
'show_comments' => isset($options['comments']) && $options['comments'] == '1' ? 'true' : 'false',
'show_artwork' => isset($options['artwork']) && $options['artwork'] == '1' ? 'true' : 'false',
'show_playcount' => isset($options['play_count']) && $options['play_count'] == '1' ? 'true' : 'false',
'show_user' => isset($options['username']) && $options['username'] == '1' ? 'true' : 'false',
if (is_embedpress_pro_active()) {
$params['buying'] = isset($options['buy_button']) && $options['buy_button'] == '1' ? 'true' : 'false';
$params['download'] = isset($options['download_button']) && $options['download_button'] == '1' ? '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 function embedpress_gutenberg_register_block_youtube($youtube_params)
$youtube_options = $this->getOptions('youtube', $this->get_youtube_settings_schema());
return $this->get_youtube_params($youtube_options);
public function embedpress_gutenberg_register_block_vimeo()
if (function_exists('register_block_type')) :
register_block_type('embedpress/vimeo-block', array(
'render_callback' => [$this, 'embedpress_gutenberg_render_block_vimeo']
public function embedpress_gutenberg_render_block_vimeo($attributes)
if (!empty($attributes) && !empty($attributes['iframeSrc'])) :
$vimeo_options = $this->getOptions('vimeo', $this->get_vimeo_settings_schema());
$vimeo_params = $this->get_vimeo_params($vimeo_options);
$iframeUrl = $attributes['iframeSrc'];
$align = 'align' . (isset($attributes['align']) ? $attributes['align'] : 'center');
foreach ($vimeo_params as $param => $value) {
$iframeUrl = add_query_arg($param, $value, $iframeUrl);
//@TODO; test responsive without static height width, keeping for now backward compatibility
<div class="ose-vimeo wp-block-embed-vimeo <?php echo esc_attr($align); ?>">
<iframe src="<?php echo esc_url($iframeUrl); ?>" allowtransparency="true" frameborder="0" width="640" height="360">
return apply_filters('embedpress_gutenberg_block_markup', ob_get_clean());
public function get_youtube_settings_schema()
public function get_vimeo_settings_schema()
'classes' => 'color-field'
'display_title' => array(
'display_author' => array(
'display_avatar' => array(
public function get_wistia_settings_schema()
'display_fullscreen_button' => array(
'display_playbar' => array(
'small_play_button' => array(
'display_volume_control' => array(
'plugin_resumable' => array(
'plugin_captions' => array(
'plugin_captions_default' => array(
'plugin_rewind' => array(
'plugin_rewind_time' => array(
public function getVideoIDFromURL($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 function embedpress_wistia_block_after_embed($attributes)
$embedOptions = $this->embedpress_wistia_pro_get_options();
$videoId = $this->getVideoIDFromURL($attributes['url']);
$shortVideoId = $videoId;
'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!', 'embedpress'),
$labels = json_encode($labels);
$html = '<script src="https://fast.wistia.com/assets/external/E-v1.js"></script>';
$html .= "<script>window.pp_embed_wistia_labels = {$labels};</script>\n";
$html .= "<script>wistiaEmbed = Wistia.embed( \"{$shortVideoId}\", {$embedOptions} );</script>\n";
public function embedpress_wistia_pro_get_options()
$options = $this->getOptions('wistia', $this->get_wistia_settings_schema());
$embedOptions = new \stdClass;
// $embedOptions->videoFoam = true;
$embedOptions->fullscreenButton = (isset($options['display_fullscreen_button']) && (bool) $options['display_fullscreen_button'] === true);
$embedOptions->smallPlayButton = (isset($options['small_play_button']) && (bool) $options['small_play_button'] === true);
$embedOptions->autoPlay = (isset($options['autoplay']) && (bool) $options['autoplay'] === true);
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' => '//fast.wistia.com/labs/resumable/plugin.js',
// Add a fix for the autoplay and resumable work better together
//@TODO; check baseurl deeply, not looking good
if ($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' => '//fast.wistia.com/labs/dim-the-lights/plugin.js',
'autoDim' => $isFocusEnabled
$embedOptions->focus = $isFocusEnabled;
$embedOptions->plugin = $pluginList;
$embedOptions = apply_filters('embedpress_wistia_params', $embedOptions);
$embedOptions = json_encode($embedOptions);
return apply_filters('embedpress_wistia_params_after_encode', $embedOptions);
public function get_twitch_settings_schema()
'embedpress_pro_twitch_autoplay' => [
'embedpress_pro_twitch_chat' => [
'embedpress_pro_twitch_theme' => [
'embedpress_pro_twitch_mute' => [
public function get_dailymotion_settings_schema()
public function get_soundcloud_settings_schema()
public function enhance_missing_title($embed)
$embed_arr = get_object_vars($embed);
if (strpos($url, 'gettyimages') !== false) {
$title = $embed_arr[$url]['title'];
$embed->embed = $embed->embed . "
if (typeof gie === 'function') {
var iframe = document.querySelector('.ose-embedpress-responsive iframe');
if(iframe && !iframe.getAttribute('title')){
iframe.setAttribute('title', '$title')