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