: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
use EmbedPress\Ends\Back\Handler as EndHandlerAdmin;
use EmbedPress\Ends\Back\Settings\EmbedpressSettings;
use EmbedPress\Ends\Front\Handler as EndHandlerPublic;
use EmbedPress\Includes\Traits\Shared;
(defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
* Entity that glues together all pieces that the plugin is made of, for WordPress 5+.
* @author EmbedPress <help@embedpress.com>
* @copyright Copyright (C) 2021 WPDeveloper. All rights reserved.
* @license GPLv3 or later
* The name of the plugin.
* @var string $pluginName The name of the plugin.
* The version of the plugin.
* @var string $pluginVersion The version of the plugin.
protected $pluginVersion;
* An instance of the plugin loader.
* @var Loader $pluginVersion The version of the plugin.
protected $loaderInstance;
* An associative array storing all registered/active EmbedPress plugins and their namespaces.
private static $plugins = [];
* Initialize the plugin and set its properties.
public function __construct () {
$this->pluginName = EMBEDPRESS_PLG_NAME;
$this->pluginVersion = EMBEDPRESS_VERSION;
$this->loaderInstance = new Loader();
add_action('admin_notices',[$this,'embedpress_admin_notice']);
add_filter('upload_mimes', [$this, 'extended_mime_types']);
* Method that retrieves the plugin name.
public function getPluginName () {
return $this->pluginName;
* Method that retrieves the plugin version.
public function getPluginVersion () {
return $this->pluginVersion;
* Method that retrieves the loader instance.
public function getLoader () {
return $this->loaderInstance;
* Method responsible to connect all required hooks in order to make the plugin work.
public function initialize () {
add_filter('oembed_providers', [$this, 'addOEmbedProviders']);
add_action('rest_api_init', [$this, 'registerOEmbedRestRoutes']);
$this->start_plugin_tracking();
new EmbedpressSettings();
$plgSettings = self::getSettings();
add_filter('plugin_action_links_embedpress/embedpress.php', ['\\EmbedPress\\Core', 'handleActionLinks'], 10,
add_action('admin_enqueue_scripts', ['\\EmbedPress\\Ends\\Back\\Handler', 'enqueueStyles']);
add_action('wp_ajax_embedpress_notice_dismiss', ['\\EmbedPress\\Ends\\Back\\Handler', 'embedpress_notice_dismiss']);
$plgHandlerAdminInstance = new EndHandlerAdmin($this->getPluginName(), $this->getPluginVersion());
if ( $plgSettings->enablePluginInAdmin ) {
$this->loaderInstance->add_action('admin_enqueue_scripts', $plgHandlerAdminInstance, 'enqueueScripts');
$plgHandlerPublicInstance = new EndHandlerPublic($this->getPluginName(), $this->getPluginVersion());
$this->loaderInstance->add_action('wp_enqueue_scripts', $plgHandlerPublicInstance, 'enqueueScripts');
$this->loaderInstance->add_action('wp_enqueue_scripts', $plgHandlerPublicInstance, 'enqueueStyles');
unset($plgHandlerPublicInstance);
// Add support for embeds on AMP pages
add_filter('pp_embed_parsed_content', ['\\EmbedPress\\AMP\\EmbedHandler', 'processParsedContent'], 10, 3);
// Add support for our embeds on Beaver Builder. Without this it only run the native embeds.
add_filter('fl_builder_before_render_shortcodes',
['\\EmbedPress\\ThirdParty\\BeaverBuilder', 'before_render_shortcodes']);
$this->loaderInstance->run();
public function addOEmbedProviders ($providers) {
'#https?://(.+\.)?viddler\.com/v/.+#i' => 'viddler',
// Deviantart.com (http://www.deviantart.com)
// '#https?://(.+\.)?deviantart\.com/art/.+#i' => 'devianart',
// '#https?://(.+\.)?deviantart\.com/.+#i' => 'devianart',
// '#https?://(.+\.)?deviantart\.com/.*/d.+#i' => 'devianart',
// '#https?://(.+\.)?fav\.me/.+#i' => 'devianart',
// '#https?://(.+\.)?sta\.sh/.+#i' => 'devianart',
// chirbit.com (http://www.chirbit.com/)
//'#https?://(.+\.)?chirb\.it/.+#i' => 'chirbit',
// nfb.ca (http://www.nfb.ca/)
//'#https?://(.+\.)?nfb\.ca/film/.+#i' => 'nfb',
// Dotsub (http://dotsub.com/)
//'#https?://(.+\.)?dotsub\.com/view/.+#i' => 'dotsub',
// Rdio (http://rdio.com/)
'#https?://(.+\.)?rdio\.com/(artist|people)/.+#i' => 'rdio',
// Sapo Videos (http://videos.sapo.pt)
//'#https?://(.+\.)?videos\.sapo\.pt/.+#i' => 'sapo',
// Official FM (http://official.fm)
'#https?://(.+\.)?official\.fm/(tracks|playlists)/.+#i' => 'officialfm',
// HuffDuffer (http://huffduffer.com)
//'#https?://(.+\.)?huffduffer\.com/.+#i' => 'huffduffer',
// Shoudio (http://shoudio.com)
//'#https?://(.+\.)?shoudio\.(com|io)/.+#i' => 'shoudio',
// Moby Picture (http://www.mobypicture.com)
'#https?://(.+\.)?mobypicture\.com/user/.+/view/.+#i' => 'mobypicture',
'#https?://(.+\.)?moby\.to/.+#i' => 'mobypicture',
// 23HQ (http://www.23hq.com)
//'#https?://(.+\.)?23hq\.com/.+/photo/.+#i' => '23hq',
// Cacoo (https://cacoo.com)
'#https?://(.+\.)?cacoo\.com/diagrams/.+#i' => 'cacoo',
// Dipity (http://www.dipity.com)
'#https?://(.+\.)?dipity\.com/.+#i' => 'dipity',
// Roomshare (http://roomshare.jp)
//'#https?://(.+\.)?roomshare\.jp/(en/)?post/.+#i' => 'roomshare',
// Crowd Ranking (http://crowdranking.com)
'#https?://(.+\.)?c9ng\.com/.+#i' => 'crowd',
// CircuitLab (https://www.circuitlab.com/)
//'#https?://(.+\.)?circuitlab\.com/circuit/.+#i' => 'circuitlab',
// Coub (http://coub.com/)
//'#https?://(.+\.)?coub\.com/(view|embed)/.+#i' => 'coub',
// Ustream (http://www.ustream.tv)
//'#https?://(.+\.)?ustream\.(tv|com)/.+#i' => 'ustream',
// Daily Mile (http://www.dailymile.com)
'#https?://(.+\.)?dailymile\.com/people/.+/entries/.+#i' => 'daily',
// Sketchfab (http://sketchfab.com)
'#https?://(.+\.)?sketchfab\.com/models/.+#i' => 'sketchfab',
'#https?://(.+\.)?sketchfab\.com/.+/folders/.+#i' => 'sketchfab',
// AudioSnaps (http://audiosnaps.com)
'#https?://(.+\.)?audiosnaps\.com/k/.+#i' => 'audiosnaps',
// RapidEngage (https://rapidengage.com)
'#https?://(.+\.)?rapidengage\.com/s/.+#i' => 'rapidengage',
// Getty Images (http://www.gettyimages.com/)
//'#https?://(.+\.)?gty\.im/.+#i' => 'gettyimages',
//'#https?://(.+\.)?gettyimages\.com/detail/photo/.+#i' => 'gettyimages',
// amCharts Live Editor (http://live.amcharts.com/)
//'#https?://(.+\.)?live\.amcharts\.com/.+#i' => 'amcharts',
// Infogram (https://infogr.am/)
//'#https?://(.+\.)?infogr\.am/.+#i' => 'infogram',
//(https://infogram.com/)
//'#https?://(.+\.)?infogram\.com/.+#i' => 'infogram',
// ChartBlocks (http://www.chartblocks.com/)
//'#https?://(.+\.)?public\.chartblocks\.com/c/.+#i' => 'chartblocks',
// ReleaseWire (http://www.releasewire.com/)
//'#https?://(.+\.)?rwire\.com/.+#i' => 'releasewire',
// ShortNote (https://www.shortnote.jp/)
//'#https?://(.+\.)?shortnote\.jp/view/notes/.+#i' => 'shortnote',
// EgliseInfo (http://egliseinfo.catholique.fr/)
'#https?://(.+\.)?egliseinfo\.catholique\.fr/.+#i' => 'egliseinfo',
// Silk (http://www.silk.co/)
'#https?://(.+\.)?silk\.co/explore/.+#i' => 'silk',
'#https?://(.+\.)?silk\.co/s/embed/.+#i' => 'silk',
'#https?://(.+\.)?bambuser\.com/v/.+#i' => 'bambuser',
//'#https?://(.+\.)?clyp\.it/.+#i' => 'clyp',
// https://gist.github.com
// '#https?://(.+\.)?gist\.github\.com/.+#i' => 'github',
// https://portfolium.com
//'#https?://(.+\.)?portfolium\.com/.+#i' => 'portfolium',
'#https?://(.+\.)?rutube\.ru/video/.+#i' => 'rutube',
// http://www.videojug.com
'#https?://(.+\.)?videojug\.com/.+#i' => 'videojug',
//'#https?://(.+\.)?vine\.co/v/.+#i' => 'vine',
'#https?://(.+\.)?goo\.gl/.+#i' => 'google',
//'#https?://(.+\.)?google\.com/maps/.+#i' => 'googlemaps',
//'#https?://(.+\.)?maps\.google\.com/.+#i' => 'googlemaps',
//'#https?://(.+\.)?docs\.google\.com/(.+/)?(document|presentation|spreadsheets|forms|drawings)/.+#i' => 'googledocs',
//'#https?://(.+\.)?twitch\.tv/.+#i' => 'twitch',
//'#https?://(.+\.)?giphy\.com/gifs/.+#i' => 'giphy',
//'#https?://(.+\.)?i\.giphy\.com/.+#i' => 'giphy',
//'#https?://(.+\.)?gph\.is/.+#i' => 'giphy',
//'#https?://(.+\.)?wistia\.com/medias/.+#i' => 'wistia',
//'#https?://(.+\.)?fast\.wistia\.com/embed/medias/.+#i\.jsonp' => 'wistia',
* ========================================
* Make sure the $wp_write global is set.
* This fix compatibility with JetPack, Classical Editor and Disable Gutenberg. JetPack makes
* the oembed_providers filter be called and this activates our class too, but one dependency
* of the rest_url method is not loaded yet.
if (!class_exists('\\WP_Rewrite')) {
$path = ABSPATH.WPINC.'/class-wp-rewrite.php';
if (file_exists($path)) {
if (!is_object($wp_rewrite)) {
$wp_rewrite = new \WP_Rewrite();
$_GLOBALS['wp_write'] = $wp_rewrite;
/*========================================*/
foreach ($newProviders as $url => &$data) {
rest_url('embedpress/v1/oembed/'.$data),
$providers = array_merge($providers, $newProviders);
* Register OEmbed Rest Routes
public function registerOEmbedRestRoutes () {
'embedpress/v1', '/oembed/(?P<provider>[a-zA-Z0-9\-]+)',
'methods' => \WP_REST_Server::READABLE,
'callback' => ['\\EmbedPress\\RestAPI', 'oembed'],
'permission_callback' => '__return_true',
'embedpress/v1', '/oembed/(?P<provider>[a-zA-Z0-9\-]+)',
'methods' => \WP_REST_Server::CREATABLE,
'callback' => ['\\EmbedPress\\RestAPI', 'oembed'],
'permission_callback' => '__return_true',
* Callback called right after the plugin has been activated.
public static function onPluginActivationCallback () {
$dirname = wp_get_upload_dir()['basedir'].'/embedpress';
if (!file_exists($dirname)) {
embedpress_schedule_cache_cleanup();
* Callback called right after the plugin has been deactivated.
public static function onPluginDeactivationCallback () {
embedpress_cache_cleanup();
$timestamp = wp_next_scheduled( 'embedpress_backup_cleanup_action' );
wp_unschedule_event( $timestamp, 'embedpress_backup_cleanup_action' );
* Method that retrieves all additional service providers defined in the ~<plugin_root_path>/providers.php file.
public static function getAdditionalServiceProviders () {
$additionalProvidersFilePath = EMBEDPRESS_PATH_BASE.'providers.php';
if (file_exists($additionalProvidersFilePath)) {
include $additionalProvidersFilePath;
if (isset($additionalServiceProviders)) {
return apply_filters( 'embedpress_additional_service_providers', $additionalServiceProviders);
return apply_filters( 'embedpress_additional_service_providers', []);
* Method that checks if an embed of a given service provider can be responsive.
* @param string $serviceProviderAlias The service's slug.
public static function canServiceProviderBeResponsive ($serviceProviderAlias) {
return in_array($serviceProviderAlias, [
* Method that retrieves the plugin settings defined by the user.
public static function getSettings () {
$settings = get_option(EMBEDPRESS_PLG_NAME);
if (!isset($settings['enablePluginInAdmin'])) {
$settings['enablePluginInAdmin'] = true;
if (!isset($settings['enablePluginInFront'])) {
$settings['enablePluginInFront'] = true;
if (!isset($settings['enableGlobalEmbedResize'])) {
$settings['enableGlobalEmbedResize'] = false;
if (!isset($settings['enableEmbedResizeHeight'])) {
$settings['enableEmbedResizeHeight'] = 550; // old 552
if (!isset($settings['enableEmbedResizeWidth'])) {
$settings['enableEmbedResizeWidth'] = 600; // old 652
return (object) $settings;
* Retrieve all registered plugins.