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