PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.8.1
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.8.1
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 / Ends / Back / Handler.php
embedpress / EmbedPress / Ends / Back Last commit date
Settings 3 years ago Handler.php 3 years ago index.html 7 years ago
Handler.php
522 lines
1 <?php
2
3 namespace EmbedPress\Ends\Back;
4
5 use EmbedPress\Core;
6 use EmbedPress\Ends\Handler as EndHandlerAbstract;
7 use EmbedPress\Shortcode;
8 use Embera\Embera;
9
10 (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
11
12 /**
13 * The admin-facing functionality of the plugin.
14 * Defines the plugin name, version, and enqueue the admin-specific stylesheets and scripts.
15 *
16 * @package EmbedPress
17 * @subpackage EmbedPress/Ends/Back
18 * @author EmbedPress <help@embedpress.com>
19 * @copyright Copyright (C) 2023 WPDeveloper. All rights reserved.
20 * @license GPLv3 or later
21 * @since 1.0.0
22 */
23 class Handler extends EndHandlerAbstract
24 {
25 /**
26 * Method that register all scripts for the admin area.
27 *
28 * @return void
29 * @since 1.0.0
30 *
31 */
32 public function enqueueScripts()
33 {
34 global $pagenow;
35 if ('post.php' === $pagenow) {
36 $urlSchemes = apply_filters('embedpress:getAdditionalURLSchemes', $this->getUrlSchemes());
37
38 wp_enqueue_script(
39 'embedpress-pdfobject',
40 EMBEDPRESS_URL_ASSETS . 'js/pdfobject.min.js',
41 [],
42 $this->pluginVersion,
43 false
44 );
45
46 wp_enqueue_script("bootbox-bootstrap", EMBEDPRESS_URL_ASSETS . 'js/vendor/bootstrap/bootstrap.min.js', ['jquery'], $this->pluginVersion, false);
47 wp_enqueue_script("bootbox", EMBEDPRESS_URL_ASSETS . 'js/vendor/bootbox.min.js', ['jquery', 'bootbox-bootstrap'], $this->pluginVersion, true);
48 wp_enqueue_script($this->pluginName, EMBEDPRESS_URL_ASSETS . 'js/preview.js', ['jquery', 'bootbox'], $this->pluginVersion, true);
49
50
51 wp_localize_script($this->pluginName, '$data', [
52 'previewSettings' => [
53 'baseUrl' => get_site_url() . '/',
54 'versionUID' => $this->pluginVersion,
55 'debug' => true,
56 ],
57 'EMBEDPRESS_SHORTCODE' => EMBEDPRESS_SHORTCODE,
58 'EMBEDPRESS_URL_ASSETS' => EMBEDPRESS_URL_ASSETS,
59 'urlSchemes' => $urlSchemes,
60 ]);
61 }
62
63 if ('post.php' === $pagenow || 'post-new.php' === $pagenow) {
64 wp_enqueue_script(
65 'plyr.polyfilled',
66 EMBEDPRESS_URL_ASSETS . 'js/plyr.polyfilled.js',
67 [],
68 $this->pluginVersion,
69 false
70 );
71
72 wp_enqueue_style('plyr', EMBEDPRESS_URL_ASSETS . 'css/plyr.css', $this->pluginVersion, true);
73
74 wp_enqueue_style($this->pluginName, EMBEDPRESS_URL_ASSETS . 'css/embedpress.css', $this->pluginVersion, true);
75 }
76
77
78 //load embedpress admin js
79
80 wp_enqueue_script(
81 'embedpress-admin',
82 EMBEDPRESS_URL_ASSETS . 'js/admin.js',
83 ['jquery'],
84 $this->pluginVersion,
85 true
86 );
87
88 wp_enqueue_script(
89 'embedpress-admin',
90 EMBEDPRESS_URL_ASSETS . 'js/admin.js',
91 ['jquery'],
92 $this->pluginVersion,
93 true
94 );
95
96 wp_localize_script($this->pluginName, 'EMBEDPRESS_ADMIN_PARAMS', [
97 'ajaxurl' => admin_url('admin-ajax.php'),
98 'nonce' => wp_create_nonce('embedpress')
99 ]);
100
101
102 $installedPlugins = Core::getPlugins();
103 if (count($installedPlugins) > 0) {
104 foreach ($installedPlugins as $plgSlug => $plgNamespace) {
105 $plgScriptPathRelative = "assets/js/embedpress.{$plgSlug}.js";
106 $plgName = "embedpress-{$plgSlug}";
107
108 if (file_exists(WP_PLUGIN_DIR . "/{$plgName}/{$plgScriptPathRelative}")) {
109 wp_enqueue_script(
110 $plgName,
111 plugins_url($plgName) . '/' . $plgScriptPathRelative,
112 [$this->pluginName],
113 $this->pluginVersion,
114 true
115 );
116 }
117 }
118 }
119 }
120
121 /**
122 * Method that register all stylesheets for the admin area.
123 *
124 * @return void
125 * @since 1.0.0
126 * @static
127 *
128 */
129 public static function enqueueStyles()
130 {
131 if (isset($_GET['page']) && 'embedpress' === $_GET['page']) {
132 wp_enqueue_style('embedpress-admin', plugins_url('embedpress/assets/css/admin.css'));
133 }
134 }
135
136 /**
137 * Method that receive a string via AJAX and return the decoded-shortcoded-version of that string.
138 *
139 * @return void
140 * @since 1.0.0
141 *
142 */
143 public function doShortcodeReceivedViaAjax()
144 {
145 $subject = isset($_POST['subject']) ? $_POST['subject'] : "";
146
147 $response = [
148 'data' => Shortcode::parseContent($subject, true),
149 ];
150
151 header('Content-Type:application/json;charset=UTF-8');
152 echo json_encode($response);
153
154 exit();
155 }
156
157 /**
158 * Method that receive an url via AJAX and return the info about that url/embed.
159 *
160 * @return void
161 * @since 1.0.0
162 *
163 */
164 public function getUrlInfoViaAjax()
165 {
166 $url = isset($_GET['url']) ? trim($_GET['url']) : "";
167
168 $response = [
169 'url' => $url,
170 'canBeResponsive' => false,
171 ];
172
173 if (!!strlen($response['url'])) {
174
175 $additionalServiceProviders = Core::getAdditionalServiceProviders();
176 if (!empty($additionalServiceProviders)) {
177 foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) {
178 Shortcode::addServiceProvider($serviceProviderClassName, $serviceProviderUrls);
179 }
180 }
181 $embera = new Embera([], Shortcode::get_collection());
182
183 $urlInfo = $embera->getUrlData($response['url']);
184 if (isset($urlInfo[$response['url']]) && $urlInfo[$response['url']]['provider_name']) {
185 $response['canBeResponsive'] = Core::canServiceProviderBeResponsive(strtolower($urlInfo[$response['url']]['provider_name']));
186 }
187 }
188
189 header('Content-Type:application/json;charset=UTF-8');
190 echo json_encode($response);
191
192 exit();
193 }
194
195 /**
196 * Returns a list of supported URL schemes for the preview script
197 *
198 * @return array
199 */
200 public function getUrlSchemes()
201 {
202 return [
203 // Apple podcasts
204 'podcasts.apple.com/*',
205 // PollDaddy
206 '*.polldaddy.com/s/*',
207 '*.polldaddy.com/poll/*',
208 '*.polldaddy.com/ratings/*',
209 'polldaddy.com/s/*',
210 'polldaddy.com/poll/*',
211 'polldaddy.com/ratings/*',
212
213 // VideoPress
214 'videopress.com/v/*',
215
216 // Tumblr
217 '*.tumblr.com/post/*',
218
219 // SmugMug
220 'smugmug.com/*',
221 '*.smugmug.com/*',
222
223 // SlideShare
224 'slideshare.net/*/*',
225 '*.slideshare.net/*/*',
226
227 // Reddit
228 'reddit.com/r/[^/]+/comments/*',
229
230 // Photobucket
231 'i*.photobucket.com/albums/*',
232 'gi*.photobucket.com/groups/*',
233
234 // Cloudup
235 'cloudup.com/*',
236
237 // Imgur
238 'imgur.com/*',
239 'i.imgur.com/*',
240
241 // YouTube (http://www.youtube.com/)
242 'youtube.com/watch\\?*',
243 'youtube.com/playlist\\?*',
244 'youtube.com/channel/*',
245 'youtube.com/c/*',
246 'youtube.com/user/*',
247 'youtube.com/(\w+)[^?\/]*$',
248
249 // opensea
250 'opensea.io/collection/*',
251
252 // Flickr (http://www.flickr.com/)
253 'flickr.com/photos/*/*',
254 'flic.kr/p/*',
255
256 // Viddler (http://www.viddler.com/)
257 'viddler.com/v/*',
258
259 // Hulu (http://www.hulu.com/)
260 'hulu.com/watch/*',
261
262 // Vimeo (http://vimeo.com/)
263 'vimeo.com/*',
264 'vimeo.com/groups/*/videos/*',
265
266 // CollegeHumor (http://www.collegehumor.com/)
267 'collegehumor.com/video/*',
268
269 // Deviantart.com (http://www.deviantart.com)
270 '*.deviantart.com/art/*',
271 '*.deviantart.com/*#/d*',
272 'fav.me/*',
273 'sta.sh/*',
274
275 // SlideShare (http://www.slideshare.net/)
276
277 // chirbit.com (http://www.chirbit.com/)
278 'chirb.it/*',
279
280 // nfb.ca (http://www.nfb.ca/)
281 '*.nfb.ca/film/*',
282
283 // Scribd (http://www.scribd.com/)
284 '*.scribd.com/doc/*',
285 '*.scribd.com/document/*',
286
287 // Dotsub (http://dotsub.com/)
288 'dotsub.com/view/*',
289
290 // Animoto (http://animoto.com/)
291 'animoto.com/play/*',
292
293 // Rdio (http://rdio.com/)
294 '*.rdio.com/artist/*',
295 '*.rdio.com/people/*',
296
297 // MixCloud (http://mixcloud.com/)
298 'mixcloud.com/*/*/',
299
300 // FunnyOrDie (http://www.funnyordie.com/)
301 'funnyordie.com/videos/*',
302
303 // Ted (http://ted.com)
304 'ted.com/talks/*',
305
306 // Sapo Videos (http://videos.sapo.pt)
307 'videos.sapo.pt/*',
308
309 // Official FM (http://official.fm)
310 'official.fm/tracks/*',
311 'official.fm/playlists/*',
312
313 // HuffDuffer (http://huffduffer.com)
314 'huffduffer.com/*/*',
315
316 // Shoudio (http://shoudio.com)
317 'shoudio.com/*',
318 'shoud.io/*',
319
320 // Moby Picture (http://www.mobypicture.com)
321 'mobypicture.com/user/*/view/*',
322 'moby.to/*',
323
324 // 23HQ (http://www.23hq.com)
325 '23hq.com/*/photo/*',
326
327 // Cacoo (https://cacoo.com)
328 'cacoo.com/diagrams/*',
329
330 // Dipity (http://www.dipity.com)
331 'dipity.com/*/*/',
332
333 // Roomshare (http://roomshare.jp)
334 'roomshare.jp/post/*',
335 'roomshare.jp/en/post/*',
336
337 // Dailymotion (http://www.dailymotion.com)
338 'dailymotion.com/video/*',
339
340 // Crowd Ranking (http://crowdranking.com)
341 'c9ng.com/*/*',
342
343 // CircuitLab (https://www.circuitlab.com/)
344 'circuitlab.com/circuit/*',
345
346 // Coub (http://coub.com/)
347 'coub.com/view/*',
348 'coub.com/embed/*',
349
350 // SpeakerDeck (https://speakerdeck.com)
351 'speakerdeck.com/*/*',
352
353 // Instagram (https://instagram.com)
354 'instagram.com/p/*',
355 'instagr.am/p/*',
356
357 // SoundCloud (http://soundcloud.com/)
358 'soundcloud.com/*',
359
360 // Kickstarter (http://www.kickstarter.com)
361 'kickstarter.com/projects/*',
362
363 // Ustream (http://www.ustream.tv)
364 '*.ustream.tv/*',
365 '*.ustream.com/*',
366
367 // Daily Mile (http://www.dailymile.com)
368 'dailymile.com/people/*/entries/*',
369
370 // Sketchfab (http://sketchfab.com)
371 'sketchfab.com/models/*',
372 'sketchfab.com/*/folders/*',
373
374 // Meetup (http://www.meetup.com)
375 'meetup.com/*',
376 'meetu.ps/*',
377
378 // AudioSnaps (http://audiosnaps.com)
379 'audiosnaps.com/k/*',
380
381 // RapidEngage (https://rapidengage.com)
382 'rapidengage.com/s/*',
383
384 // Getty Images (http://www.gettyimages.com/)
385 'gty.im/*',
386 'gettyimages.com/detail/photo/*',
387
388 // amCharts Live Editor (http://live.amcharts.com/)
389 'live.amcharts.com/*',
390
391 // Infogram (https://infogr.am/)
392 'infogr.am/*',
393 'infogram.com/*',
394
395 // ChartBlocks (http://www.chartblocks.com/)
396 'public.chartblocks.com/c/*',
397
398 // ReleaseWire (http://www.releasewire.com/)
399 'rwire.com/*',
400
401 // ShortNote (https://www.shortnote.jp/)
402 'shortnote.jp/view/notes/*',
403
404 // EgliseInfo (http://egliseinfo.catholique.fr/)
405 'egliseinfo.catholique.fr/*',
406
407 // Silk (http://www.silk.co/)
408 '*.silk.co/explore/*',
409 '*.silk.co/s/embed/*',
410
411 // Twitter
412 'twitter.com/*/status/*',
413 'twitter.com/i/moments/*',
414 'twitter.com/*/timelines/*',
415
416 // http://bambuser.com
417 'bambuser.com/v/*',
418
419 // https://clyp.it
420 'clyp.it/*',
421
422 // https://gist.github.com
423 'gist.github.com/*/*',
424
425 // http://issuu.com
426 'issuu.com/*',
427
428 // https://portfolium.com
429 'portfolium.com/*',
430
431 // https://www.reverbnation.com
432 'reverbnation.com/*',
433
434 // http://rutube.ru
435 'rutube.ru/video/*',
436
437 // https://spotify.com/
438 'open.spotify.com/*',
439
440 // http://www.videojug.com
441 'videojug.com/*',
442
443 // https://vine.com
444 'vine.co/v/*',
445
446 // Facebook
447 'facebook.com/*',
448 'fb.watch/*',
449
450 // Google Shortened Url
451 'goo.gl/*',
452
453 // Google Maps
454 'google.com/*',
455 'google.com.*/*',
456 'google.co.*/*',
457 'maps.google.com/*',
458
459 // Google Docs
460 'docs.google.com/presentation/*',
461 'docs.google.com/document/*',
462 'docs.google.com/spreadsheets/*',
463 'docs.google.com/forms/*',
464 'docs.google.com/drawings/*',
465
466 // Twitch.tv
467 '*.twitch.tv/*',
468 'twitch.tv/*',
469
470 // Giphy
471 '*.giphy.com/gifs/*',
472 'giphy.com/gifs/*',
473 'i.giphy.com/*',
474 'gph.is/*',
475
476 // Wistia
477 '*.wistia.com/medias/*',
478 'fast.wistia.com/embed/medias/*.jsonp',
479 // Boomplay (http://boomplay.com/)
480 'boomplay.com/*',
481 'codepen.io/*',
482 'archivos.digital/*',
483 'audioclip.naver.com/*',
484 'app.blogcast.host/*',
485 'codepoints.net/*',
486 'codesandbox.io/*',
487 'commaful.com/*',
488 '*.survey.fm/*',
489 'survey.fm/*',
490 'datawrapper.dwcdn.net/*',
491 '*.didacte.com/*',
492 'didacte.com/*',
493 'digiteka.com/*',
494 'docdro.id/*',
495 'edumedia-sciences.com/*',
496 'ethfiddle.com/*',
497 'eyrie.io/*',
498 '*.getfader.com/*',
499 'getfader.com/*',
500 'fitapp.pro/*',
501 'fite.tv/*',
502 'public.flourish.studio/*',
503 'geograph.org.gg/*',
504 'geo-en.hlipp.de/*',
505 'geograph.org.uk/*',
506 'fortest.getshow.io/*',
507 'opensea.io/assets/*',
508 ];
509 }
510
511 /**
512 * Update admin notice view status
513 *
514 * @since 2.5.1
515 */
516 public static function embedpress_notice_dismiss()
517 {
518 check_ajax_referer('embedpress', 'security');
519 update_option('embedpress_social_dismiss_notice', true);
520 }
521 }
522