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