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