PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 4.4.0
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v4.4.0
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / EmbedPress / Core.php
embedpress / EmbedPress Last commit date
AMP 2 years ago Analytics 9 months ago Elementor 9 months ago Ends 9 months ago Gutenberg 9 months ago Includes 9 months ago Plugins 1 year ago Providers 9 months ago ThirdParty 9 months ago AutoLoader.php 2 years ago Compatibility.php 2 years ago Core.php 9 months ago CoreLegacy.php 9 months ago DisablerLegacy.php 2 years ago Loader.php 2 years ago RestAPI.php 1 year ago Shortcode.php 9 months ago index.html 7 years ago simple_html_dom.php 4 years ago
Core.php
708 lines
1 <?php
2
3 namespace EmbedPress;
4
5 use EmbedPress\Ends\Back\Handler as EndHandlerAdmin;
6 use EmbedPress\Ends\Back\Settings\EmbedpressSettings;
7 use EmbedPress\Ends\Front\Handler as EndHandlerPublic;
8 use EmbedPress\Includes\Traits\Shared;
9
10
11 (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
12
13 /**
14 * Entity that glues together all pieces that the plugin is made of, for WordPress 5+.
15 *
16 * @package EmbedPress
17 * @author EmbedPress <help@embedpress.com>
18 * @copyright Copyright (C) 2021 WPDeveloper. All rights reserved.
19 * @license GPLv3 or later
20 * @since 1.0.0
21 */
22 class Core
23 {
24 use Shared;
25
26 /**
27 * The name of the plugin.
28 *
29 * @since 1.0.0
30 * @access protected
31 *
32 * @var string $pluginName The name of the plugin.
33 */
34 protected $pluginName;
35
36 /**
37 * The version of the plugin.
38 *
39 * @since 1.0.0
40 * @access protected
41 *
42 * @var string $pluginVersion The version of the plugin.
43 */
44 protected $pluginVersion;
45
46 /**
47 * An instance of the plugin loader.
48 *
49 * @since 1.0.0
50 * @access protected
51 *
52 * @var Loader $pluginVersion The version of the plugin.
53 */
54 protected $loaderInstance;
55
56 /**
57 * An associative array storing all registered/active EmbedPress plugins and their namespaces.
58 *
59 * @since 1.4.0
60 * @access private
61 * @static
62 *
63 * @var array
64 */
65 private static $plugins = [];
66
67 /**
68 * Initialize the plugin and set its properties.
69 *
70 * @return void
71 * @since 1.0.0
72 *
73 */
74 public function __construct()
75 {
76 $this->pluginName = EMBEDPRESS_PLG_NAME;
77 $this->pluginVersion = EMBEDPRESS_VERSION;
78
79 $this->loaderInstance = new Loader();
80
81 add_action('in_admin_header', [$this, 'remove_admin_notice'], 99);
82 add_action('ep_admin_notices', [$this, 'embedpress_admin_notice']);
83 add_action('ep_admin_notices', [$this, 'admin_notice']);
84
85 add_filter('upload_mimes', [$this, 'extended_mime_types']);
86 }
87
88 /**
89 * Method that retrieves the plugin name.
90 *
91 * @return string
92 * @since 1.0.0
93 *
94 */
95 public function getPluginName()
96 {
97 return $this->pluginName;
98 }
99
100 /**
101 * Method that retrieves the plugin version.
102 *
103 * @return string
104 * @since 1.0.0
105 *
106 */
107 public function getPluginVersion()
108 {
109 return $this->pluginVersion;
110 }
111
112 /**
113 * Method that retrieves the loader instance.
114 *
115 * @return Loader
116 * @since 1.0.0
117 *
118 */
119 public function getLoader()
120 {
121 return $this->loaderInstance;
122 }
123
124 /**
125 * Method responsible to connect all required hooks in order to make the plugin work.
126 *
127 * @return void
128 * @since 1.0.0
129 *
130 */
131 public function initialize()
132 {
133 global $wp_actions;
134 add_filter('oembed_providers', [$this, 'addOEmbedProviders']);
135 add_action('rest_api_init', [$this, 'registerOEmbedRestRoutes']);
136 add_action('rest_api_init', [$this, 'register_feedback_email_endpoint']);
137
138
139 $this->start_plugin_tracking();
140
141 if (is_admin()) {
142 new EmbedpressSettings();
143
144 add_action('init', [$this, 'admin_notice']);
145
146 add_filter(
147 'plugin_action_links_embedpress/embedpress.php',
148 ['\\EmbedPress\\Core', 'handleActionLinks'],
149 10,
150 2
151 );
152
153 // Old enqueue handlers removed - now handled by AssetManager
154 add_action('wp_ajax_embedpress_notice_dismiss', ['\\EmbedPress\\Ends\\Back\\Handler', 'embedpress_notice_dismiss']);
155 new EndHandlerAdmin($this->getPluginName(), $this->getPluginVersion());
156 // Asset enqueuing now handled by AssetManager - keeping only non-asset functionality
157 } else {
158 // Asset enqueuing now handled by AssetManager - keeping only non-asset functionality
159 new EndHandlerPublic($this->getPluginName(), $this->getPluginVersion());
160 }
161
162 // Add support for embeds on AMP pages
163 add_filter('pp_embed_parsed_content', ['\\EmbedPress\\AMP\\EmbedHandler', 'processParsedContent'], 10, 3);
164
165 // Add support for our embeds on Beaver Builder. Without this it only run the native embeds.
166 add_filter(
167 'fl_builder_before_render_shortcodes',
168 ['\\EmbedPress\\ThirdParty\\BeaverBuilder', 'before_render_shortcodes']
169 );
170 $this->loaderInstance->run();
171 }
172
173 /**
174 * Initialize minimal plugin functionality without script handlers
175 * Used when the new block system is active to avoid conflicts
176 *
177 * @return void
178 * @since 4.2.7
179 */
180 public function initialize_minimal()
181 {
182
183 add_filter('oembed_providers', [$this, 'addOEmbedProviders']);
184 add_action('rest_api_init', [$this, 'registerOEmbedRestRoutes']);
185 add_action('rest_api_init', [$this, 'register_feedback_email_endpoint']);
186
187 $this->start_plugin_tracking();
188
189 // Skip the admin and frontend handlers that enqueue scripts
190 // Only initialize core functionality
191
192
193 // Add support for embeds on AMP pages
194 add_filter('pp_embed_parsed_content', ['\\EmbedPress\\AMP\\EmbedHandler', 'processParsedContent'], 10, 3);
195
196 // Add support for our embeds on Beaver Builder
197 add_filter(
198 'fl_builder_before_render_shortcodes',
199 ['\\EmbedPress\\ThirdParty\\BeaverBuilder', 'before_render_shortcodes']
200 );
201
202 $this->loaderInstance->run();
203 }
204
205 /**
206 * @param $providers
207 *
208 * @return mixed
209 */
210 public function addOEmbedProviders($providers)
211 {
212 $newProviders = [
213 // Viddler
214 '#https?://(.+\.)?viddler\.com/v/.+#i' => 'viddler',
215
216 // Deviantart.com (http://www.deviantart.com)
217 // '#https?://(.+\.)?deviantart\.com/art/.+#i' => 'devianart',
218 // '#https?://(.+\.)?deviantart\.com/.+#i' => 'devianart',
219 // '#https?://(.+\.)?deviantart\.com/.*/d.+#i' => 'devianart',
220 // '#https?://(.+\.)?fav\.me/.+#i' => 'devianart',
221 // '#https?://(.+\.)?sta\.sh/.+#i' => 'devianart',
222
223 // chirbit.com (http://www.chirbit.com/)
224 //'#https?://(.+\.)?chirb\.it/.+#i' => 'chirbit',
225
226
227 // nfb.ca (http://www.nfb.ca/)
228 //'#https?://(.+\.)?nfb\.ca/film/.+#i' => 'nfb',
229
230 // Dotsub (http://dotsub.com/)
231 //'#https?://(.+\.)?dotsub\.com/view/.+#i' => 'dotsub',
232
233 // Rdio (http://rdio.com/)
234 '#https?://(.+\.)?rdio\.com/(artist|people)/.+#i' => 'rdio',
235
236 // Sapo Videos (http://videos.sapo.pt)
237 //'#https?://(.+\.)?videos\.sapo\.pt/.+#i' => 'sapo',
238
239 // Official FM (http://official.fm)
240 '#https?://(.+\.)?official\.fm/(tracks|playlists)/.+#i' => 'officialfm',
241
242 // HuffDuffer (http://huffduffer.com)
243 //'#https?://(.+\.)?huffduffer\.com/.+#i' => 'huffduffer',
244
245 // Shoudio (http://shoudio.com)
246 //'#https?://(.+\.)?shoudio\.(com|io)/.+#i' => 'shoudio',
247
248 // Moby Picture (http://www.mobypicture.com)
249 '#https?://(.+\.)?mobypicture\.com/user/.+/view/.+#i' => 'mobypicture',
250 '#https?://(.+\.)?moby\.to/.+#i' => 'mobypicture',
251
252 // 23HQ (http://www.23hq.com)
253 //'#https?://(.+\.)?23hq\.com/.+/photo/.+#i' => '23hq',
254
255 // Cacoo (https://cacoo.com)
256 '#https?://(.+\.)?cacoo\.com/diagrams/.+#i' => 'cacoo',
257
258 // Dipity (http://www.dipity.com)
259 '#https?://(.+\.)?dipity\.com/.+#i' => 'dipity',
260
261 // Roomshare (http://roomshare.jp)
262 //'#https?://(.+\.)?roomshare\.jp/(en/)?post/.+#i' => 'roomshare',
263
264 // Crowd Ranking (http://crowdranking.com)
265 '#https?://(.+\.)?c9ng\.com/.+#i' => 'crowd',
266
267 // CircuitLab (https://www.circuitlab.com/)
268 //'#https?://(.+\.)?circuitlab\.com/circuit/.+#i' => 'circuitlab',
269
270 // Coub (http://coub.com/)
271 //'#https?://(.+\.)?coub\.com/(view|embed)/.+#i' => 'coub',
272
273 // Ustream (http://www.ustream.tv)
274 //'#https?://(.+\.)?ustream\.(tv|com)/.+#i' => 'ustream',
275
276 // Daily Mile (http://www.dailymile.com)
277 '#https?://(.+\.)?dailymile\.com/people/.+/entries/.+#i' => 'daily',
278
279 // Sketchfab (http://sketchfab.com)
280 '#https?://(.+\.)?sketchfab\.com/models/.+#i' => 'sketchfab',
281 '#https?://(.+\.)?sketchfab\.com/.+/folders/.+#i' => 'sketchfab',
282
283 // AudioSnaps (http://audiosnaps.com)
284 '#https?://(.+\.)?audiosnaps\.com/k/.+#i' => 'audiosnaps',
285
286 // RapidEngage (https://rapidengage.com)
287 '#https?://(.+\.)?rapidengage\.com/s/.+#i' => 'rapidengage',
288
289 // Getty Images (http://www.gettyimages.com/)
290 //'#https?://(.+\.)?gty\.im/.+#i' => 'gettyimages',
291 //'#https?://(.+\.)?gettyimages\.com/detail/photo/.+#i' => 'gettyimages',
292
293 // amCharts Live Editor (http://live.amcharts.com/)
294 //'#https?://(.+\.)?live\.amcharts\.com/.+#i' => 'amcharts',
295
296 // Infogram (https://infogr.am/)
297 //'#https?://(.+\.)?infogr\.am/.+#i' => 'infogram',
298 //(https://infogram.com/)
299 //'#https?://(.+\.)?infogram\.com/.+#i' => 'infogram',
300
301 // ChartBlocks (http://www.chartblocks.com/)
302 //'#https?://(.+\.)?public\.chartblocks\.com/c/.+#i' => 'chartblocks',
303
304 // ReleaseWire (http://www.releasewire.com/)
305 //'#https?://(.+\.)?rwire\.com/.+#i' => 'releasewire',
306
307 // ShortNote (https://www.shortnote.jp/)
308 //'#https?://(.+\.)?shortnote\.jp/view/notes/.+#i' => 'shortnote',
309
310 // EgliseInfo (http://egliseinfo.catholique.fr/)
311 '#https?://(.+\.)?egliseinfo\.catholique\.fr/.+#i' => 'egliseinfo',
312
313 // Silk (http://www.silk.co/)
314 '#https?://(.+\.)?silk\.co/explore/.+#i' => 'silk',
315 '#https?://(.+\.)?silk\.co/s/embed/.+#i' => 'silk',
316
317 // http://bambuser.com
318 '#https?://(.+\.)?bambuser\.com/v/.+#i' => 'bambuser',
319
320 // https://clyp.it
321 //'#https?://(.+\.)?clyp\.it/.+#i' => 'clyp',
322
323 // https://gist.github.com
324 // '#https?://(.+\.)?gist\.github\.com/.+#i' => 'github',
325
326 // https://portfolium.com
327 //'#https?://(.+\.)?portfolium\.com/.+#i' => 'portfolium',
328
329 // http://rutube.ru
330 '#https?://(.+\.)?rutube\.ru/video/.+#i' => 'rutube',
331
332 // http://www.videojug.com
333 '#https?://(.+\.)?videojug\.com/.+#i' => 'videojug',
334
335 // https://vine.com
336 //'#https?://(.+\.)?vine\.co/v/.+#i' => 'vine',
337
338 // Google Shortened Url
339 '#https?://(.+\.)?goo\.gl/.+#i' => 'google',
340
341 // Google Maps
342 //'#https?://(.+\.)?google\.com/maps/.+#i' => 'googlemaps',
343 //'#https?://(.+\.)?maps\.google\.com/.+#i' => 'googlemaps',
344
345 // Google Docs
346 //'#https?://(.+\.)?docs\.google\.com/(.+/)?(document|presentation|spreadsheets|forms|drawings)/.+#i' => 'googledocs',
347
348 // Twitch.tv
349 //'#https?://(.+\.)?twitch\.tv/.+#i' => 'twitch',
350
351 // Giphy
352 //'#https?://(.+\.)?giphy\.com/gifs/.+#i' => 'giphy',
353 //'#https?://(.+\.)?i\.giphy\.com/.+#i' => 'giphy',
354 //'#https?://(.+\.)?gph\.is/.+#i' => 'giphy',
355
356 // Wistia
357 //'#https?://(.+\.)?wistia\.com/medias/.+#i' => 'wistia',
358 //'#https?://(.+\.)?fast\.wistia\.com/embed/medias/.+#i\.jsonp' => 'wistia',
359 ];
360
361 /**
362 * ========================================
363 * Make sure the $wp_write global is set.
364 * This fix compatibility with JetPack, Classical Editor and Disable Gutenberg. JetPack makes
365 * the oembed_providers filter be called and this activates our class too, but one dependency
366 * of the rest_url method is not loaded yet.
367 */
368 global $wp_rewrite;
369
370 if (!class_exists('\\WP_Rewrite')) {
371 $path = ABSPATH . WPINC . '/class-wp-rewrite.php';
372 if (file_exists($path)) {
373 require_once $path;
374 }
375 }
376
377 if (!is_object($wp_rewrite)) {
378 $wp_rewrite = new \WP_Rewrite();
379 $_GLOBALS['wp_write'] = $wp_rewrite;
380 }
381 /*========================================*/
382
383 foreach ($newProviders as $url => &$data) {
384 $data = [
385 rest_url('embedpress/v1/oembed/' . $data),
386 true,
387 ];
388 }
389
390 $providers = array_merge($providers, $newProviders);
391
392 return $providers;
393 }
394
395 /**
396 * Register OEmbed Rest Routes
397 */
398 public function registerOEmbedRestRoutes()
399 {
400 register_rest_route(
401 'embedpress/v1',
402 '/oembed/(?P<provider>[a-zA-Z0-9\-]+)',
403 [
404 'methods' => \WP_REST_Server::READABLE,
405 'callback' => ['\\EmbedPress\\RestAPI', 'oembed'],
406 'permission_callback' => '__return_true',
407 ]
408 );
409 register_rest_route(
410 'embedpress/v1',
411 '/oembed/(?P<provider>[a-zA-Z0-9\-]+)',
412 [
413 'methods' => \WP_REST_Server::CREATABLE,
414 'callback' => ['\\EmbedPress\\RestAPI', 'oembed'],
415 'permission_callback' => '__return_true',
416 ]
417 );
418 }
419
420 public function send_user_feedback_email($params)
421 {
422 $params = $params->get_params();
423
424 $site_name = get_bloginfo('name');
425 $site_url = get_site_url();
426 $admin_email = get_option('admin_email');
427 $wp_version = get_bloginfo('version');
428
429 $admin_user = get_user_by('ID', 1);
430 if ($admin_user) {
431 $first_name = get_user_meta($admin_user->ID, 'first_name', true);
432 $last_name = get_user_meta($admin_user->ID, 'last_name', true);
433
434 $admin_full_name = trim("$first_name $last_name");
435
436 // Fallback to display name if full name is not set
437 if (empty($admin_full_name)) {
438 $admin_full_name = $admin_user->display_name;
439 }
440 } else {
441 $admin_full_name = 'Unknown';
442 }
443
444 $to = 'akash@wpdeveloper.com, rasel@wpdeveloper.com, nahid@wpdeveloper.com, md-nahid-hasan@wpdeveloper.com'; // Replace with the recipient's email
445 $subject = '[IMPORTANT] New feedback received from an EmbedPress user.';
446
447 // HTML Email Template
448 $message = '<html><body style="font-family: Arial, sans-serif; padding: 20px;">';
449 $message .= '<div style="max-width: 600px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin: auto;">';
450 $message .= '<div style="text-align: center; padding-bottom: 20px; border-bottom: 1px solid #ddd">';
451 $message .= '<img src="https://embedpress.com/wp-content/uploads/2025/03/logo.png" alt="EmbedPress" style="max-width: 150px;">';
452 $message .= '</div>';
453 $message .= '<h2 style="font-family: system-ui; color: #333; text-align: center;">Feedback Overview</h2>';
454 $message .= '<table style="font-family: system-ui; width: 100%; border-collapse: collapse; border: 1px solid #ddd">';
455
456 // Email
457 $message .= '<tr><td style="padding: 10px; font-weight: bold; width: 100px; border-bottom: 1px solid #ddd;">Email :</td>';
458 $message .= '<td style="padding: 10px; border-bottom: 1px solid #ddd;"><a href="mailto:' . esc_attr($params['email']) . '">' . esc_html($params['email']) . '</a></td></tr>';
459
460 // Rating
461 $message .= '<tr><td style="padding: 10px; font-weight: bold; width: 100px; border-bottom: 1px solid #ddd;">Rating :</td>';
462 $message .= '<td style="padding: 10px; border-bottom: 1px solid #ddd;">' . esc_html($params['rating']) . ' ⭐️</td></tr>';
463
464 // User
465 $message .= '<tr><td style="padding: 10px; font-weight: bold; width: 100px; border-bottom: 1px solid #ddd;">Name :</td>';
466 $message .= '<td style="padding: 10px; border-bottom: 1px solid #ddd; font-weight: 500;">' . esc_html($admin_full_name) . '</td></tr>';
467
468 // Pack
469 $message .= '<tr><td style="padding: 10px; font-weight: bold; width: 100px; border-bottom: 1px solid #ddd;">Site Url :</td>';
470 $message .= '<td style="padding: 10px; border-bottom: 1px solid #ddd;"><a target="_blank" href="' . esc_url($site_url) . '" style="color: blue;">' . esc_html($site_url) . '</a></td></tr>';
471
472 // Feedback
473 $message .= '<tr><td style="padding: 10px; font-weight: bold; width: 100px; display: flex;">Feedback :</td>';
474 $message .= '<td style="padding: 10px;">' . nl2br(esc_html($params['message'])) . '</td></tr>';
475
476 $message .= '</table>';
477 $message .= '</div></body></html>';
478
479 $headers = [
480 'Content-Type: text/html; charset=UTF-8',
481 'From: ' . esc_html($params['name']) . ' <' . esc_html($params['email']) . '>'
482 ];
483
484 // Send the email
485 $sent = wp_mail($to, $subject, $message, $headers);
486
487 if ($sent) {
488 update_option('embedpress_feedback_submited', true);
489 return new \WP_REST_Response(['message' => 'Email sent successfully!'], 200);
490 } else {
491 return new \WP_REST_Response(['message' => 'Failed to send email.'], 500);
492 }
493 }
494
495
496 public function register_feedback_email_endpoint()
497 {
498 register_rest_route('embedpress/v1', '/send-feedback', [
499 'methods' => 'POST',
500 'callback' => [$this, 'send_user_feedback_email'],
501 'permission_callback' => '__return_true'
502 ]);
503 }
504
505
506
507 /**
508 * Callback called right after the plugin has been activated.
509 *
510 * @return void
511 * @since 1.0.0
512 * @static
513 *
514 */
515 public static function onPluginActivationCallback()
516 {
517 $dirname = wp_get_upload_dir()['basedir'] . '/embedpress';
518 if (!file_exists($dirname)) {
519 mkdir($dirname, 0777);
520 }
521 flush_rewrite_rules();
522 embedpress_schedule_cache_cleanup();
523
524 // Set flag for activation redirect
525 $settings = get_option(EMBEDPRESS_PLG_NAME, []);
526 $settings['need_first_time_redirect'] = true;
527 update_option(EMBEDPRESS_PLG_NAME, $settings);
528
529 // Clear any previous redirect done flag
530 delete_option('embedpress_activation_redirect_done');
531 }
532
533 /**
534 * Callback called right after the plugin has been deactivated.
535 *
536 * @return void
537 * @since 1.0.0
538 * @static
539 *
540 */
541 public static function onPluginDeactivationCallback()
542 {
543 flush_rewrite_rules();
544 embedpress_cache_cleanup();
545 $timestamp = wp_next_scheduled('embedpress_backup_cleanup_action');
546 if ($timestamp) {
547 wp_unschedule_event($timestamp, 'embedpress_backup_cleanup_action');
548 }
549 }
550
551 /**
552 * Method that retrieves all additional service providers defined in the ~<plugin_root_path>/providers.php file.
553 *
554 * @return array
555 * @since 1.0.0
556 * @static
557 *
558 */
559 public static function getAdditionalServiceProviders()
560 {
561 $additionalProvidersFilePath = EMBEDPRESS_PATH_BASE . 'providers.php';
562 if (file_exists($additionalProvidersFilePath)) {
563 include $additionalProvidersFilePath;
564
565 if (isset($additionalServiceProviders)) {
566 return apply_filters('embedpress_additional_service_providers', $additionalServiceProviders);
567 }
568 }
569
570 return apply_filters('embedpress_additional_service_providers', []);
571 }
572
573 /**
574 * Method that checks if an embed of a given service provider can be responsive.
575 *
576 * @param string $serviceProviderAlias The service's slug.
577 *
578 * @return boolean
579 * @since 1.0.0
580 * @static
581 *
582 */
583 public static function canServiceProviderBeResponsive($serviceProviderAlias)
584 {
585 return in_array($serviceProviderAlias, [
586 "dailymotion",
587 "kickstarter",
588 "rutube",
589 "ted",
590 "vimeo",
591 "youtube",
592 "ustream",
593 "google-docs",
594 "animatron",
595 "amcharts",
596 "on-aol-com",
597 "animoto",
598 "videojug",
599 'issuu',
600 ]);
601 }
602
603 /**
604 * Method that retrieves the plugin settings defined by the user.
605 *
606 * @return object
607 * @since 1.0.0
608 * @static
609 *
610 */
611 public static function getSettings()
612 {
613 // Fetch settings from the database
614 $settings = get_option(EMBEDPRESS_PLG_NAME);
615
616 // If the settings are not an array (it might return false), initialize as an empty array
617 if (!is_array($settings)) {
618 $settings = [];
619 }
620
621 // Default values if settings are missing
622 if (!isset($settings['enablePluginInAdmin'])) {
623 $settings['enablePluginInAdmin'] = true;
624 }
625
626 if (!isset($settings['enablePluginInFront'])) {
627 $settings['enablePluginInFront'] = true;
628 }
629
630 if (!isset($settings['enableGlobalEmbedResize'])) {
631 $settings['enableGlobalEmbedResize'] = false;
632 }
633
634 if (!isset($settings['enableEmbedResizeHeight'])) {
635 $settings['enableEmbedResizeHeight'] = 550; // old 552
636 }
637
638 if (!isset($settings['enableEmbedResizeWidth'])) {
639 $settings['enableEmbedResizeWidth'] = 600; // old 652
640 }
641
642 return (object) $settings;
643 }
644
645 /**
646 * Retrieve all registered plugins.
647 *
648 * @return array
649 * @since 1.4.0
650 * @static
651 *
652 */
653 public static function getPlugins()
654 {
655 return self::$plugins;
656 }
657
658 /**
659 * Handle links displayed below the plugin name in the WordPress Installed Plugins page.
660 *
661 * @return array
662 * @since 1.4.0
663 * @static
664 *
665 */
666 public static function handleActionLinks($links, $file)
667 {
668 $settingsLink = '<a href="' . admin_url('admin.php?page=embedpress') . '" aria-label="' . __(
669 'Open settings page',
670 'embedpress'
671 ) . '">' . __('Settings', 'embedpress') . '</a>';
672
673 array_unshift($links, $settingsLink);
674 if (!apply_filters('embedpress/is_allow_rander', false)) {
675 $links[] = '<a href="https://wpdeveloper.com/in/upgrade-embedpress" target="_blank" class="embedpress-go-pro-action" style="color: green">' . __('Go Pro', 'embedpress') . '</a>';
676 }
677 return $links;
678 }
679
680
681 /**
682 * Method that ensures the API's url are whitelisted to WordPress external requests.
683 *
684 * @param boolean $isAllowed
685 * @param string $host
686 * @param string $url
687 *
688 * @return boolean
689 * @since 1.4.0
690 * @static
691 *
692 */
693 public static function allowApiHost($isAllowed, $host, $url)
694 {
695 if ($host === EMBEDPRESS_LICENSES_API_HOST) {
696 $isAllowed = true;
697 }
698
699 return $isAllowed;
700 }
701
702 public function extended_mime_types($mimes)
703 {
704 $mimes['ppsx'] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
705 return $mimes;
706 }
707 }
708