PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 2.0.1
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v2.0.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
Handler.php 8 years ago Settings.php 8 years ago index.html 9 years ago
Handler.php
412 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 PressShack. 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
219 // Dotsub (http://dotsub.com/)
220 'dotsub.com/view/*',
221
222 // Animoto (http://animoto.com/)
223 'animoto.com/play/*',
224
225 // Rdio (http://rdio.com/)
226 '*.rdio.com/artist/*',
227 '*.rdio.com/people/*',
228
229 // MixCloud (http://mixcloud.com/)
230 'mixcloud.com/*/*/',
231
232 // FunnyOrDie (http://www.funnyordie.com/)
233 'funnyordie.com/videos/*',
234
235 // Ted (http://ted.com)
236 'ted.com/talks/*',
237
238 // Sapo Videos (http://videos.sapo.pt)
239 'videos.sapo.pt/*',
240
241 // Official FM (http://official.fm)
242 'official.fm/tracks/*',
243 'official.fm/playlists/*',
244
245 // HuffDuffer (http://huffduffer.com)
246 'huffduffer.com/*/*',
247
248 // Shoudio (http://shoudio.com)
249 'shoudio.com/*',
250 'shoud.io/*',
251
252 // Moby Picture (http://www.mobypicture.com)
253 'mobypicture.com/user/*/view/*',
254 'moby.to/*',
255
256 // 23HQ (http://www.23hq.com)
257 '23hq.com/*/photo/*',
258
259 // Cacoo (https://cacoo.com)
260 'cacoo.com/diagrams/*',
261
262 // Dipity (http://www.dipity.com)
263 'dipity.com/*/*/',
264
265 // Roomshare (http://roomshare.jp)
266 'roomshare.jp/post/*',
267 'roomshare.jp/en/post/*',
268
269 // Dailymotion (http://www.dailymotion.com)
270 'dailymotion.com/video/*',
271
272 // Crowd Ranking (http://crowdranking.com)
273 'c9ng.com/*/*',
274
275 // CircuitLab (https://www.circuitlab.com/)
276 'circuitlab.com/circuit/*',
277
278 // Coub (http://coub.com/)
279 'coub.com/view/*',
280 'coub.com/embed/*',
281
282 // SpeakerDeck (https://speakerdeck.com)
283 'speakerdeck.com/*/*',
284
285 // Instagram (https://instagram.com)
286 'instagram.com/p/*',
287 'instagr.am/p/*',
288
289 // SoundCloud (http://soundcloud.com/)
290 'soundcloud.com/*',
291
292 // Kickstarter (http://www.kickstarter.com)
293 'kickstarter.com/projects/*',
294
295 // Ustream (http://www.ustream.tv)
296 '*.ustream.tv/*',
297 '*.ustream.com/*',
298
299 // Daily Mile (http://www.dailymile.com)
300 'dailymile.com/people/*/entries/*',
301
302 // Sketchfab (http://sketchfab.com)
303 'sketchfab.com/models/*',
304 'sketchfab.com/*/folders/*',
305
306 // Meetup (http://www.meetup.com)
307 'meetup.com/*',
308 'meetu.ps/*',
309
310 // AudioSnaps (http://audiosnaps.com)
311 'audiosnaps.com/k/*',
312
313 // RapidEngage (https://rapidengage.com)
314 'rapidengage.com/s/*',
315
316 // Getty Images (http://www.gettyimages.com/)
317 'gty.im/*',
318 'gettyimages.com/detail/photo/*',
319
320 // amCharts Live Editor (http://live.amcharts.com/)
321 'live.amcharts.com/*',
322
323 // Infogram (https://infogr.am/)
324 'infogr.am/*',
325
326 // ChartBlocks (http://www.chartblocks.com/)
327 'public.chartblocks.com/c/*',
328
329 // ReleaseWire (http://www.releasewire.com/)
330 'rwire.com/*',
331
332 // ShortNote (https://www.shortnote.jp/)
333 'shortnote.jp/view/notes/*',
334
335 // EgliseInfo (http://egliseinfo.catholique.fr/)
336 'egliseinfo.catholique.fr/*',
337
338 // Silk (http://www.silk.co/)
339 '*.silk.co/explore/*',
340 '*.silk.co/s/embed/*',
341
342 // Twitter
343 'twitter.com/*/status/*',
344 'twitter.com/i/moments/*',
345 'twitter.com/*/timelines/*',
346
347 // http://bambuser.com
348 'bambuser.com/v/*',
349
350 // https://clyp.it
351 'clyp.it/*',
352
353 // https://gist.github.com
354 'gist.github.com/*/*',
355
356 // http://issuu.com
357 'issuu.com/*',
358
359 // https://portfolium.com
360 'portfolium.com/*',
361
362 // https://www.reverbnation.com
363 'reverbnation.com/*',
364
365 // http://rutube.ru
366 'rutube.ru/video/*',
367
368 // https://spotify.com/
369 'open.spotify.com/*',
370
371 // http://www.videojug.com
372 'videojug.com/*',
373
374 // https://vine.com
375 'vine.co/v/*',
376
377 // Facebook
378 'facebook.com/*',
379
380 // Google Shortened Url
381 'goo.gl/*',
382
383 // Google Maps
384 'google.com/*',
385 'google.com.*/*',
386 'google.co.*/*',
387 'maps.google.com/*',
388
389 // Google Docs
390 'docs.google.com/presentation/*',
391 'docs.google.com/document/*',
392 'docs.google.com/spreadsheets/*',
393 'docs.google.com/forms/*',
394 'docs.google.com/drawings/*',
395
396 // Twitch.tv
397 '*.twitch.tv/*',
398 'twitch.tv/*',
399
400 // Giphy
401 '*.giphy.com/gifs/*',
402 'giphy.com/gifs/*',
403 'i.giphy.com/*',
404 'gph.is/*',
405
406 // Wistia
407 '*.wistia.com/medias/*',
408 'fast.wistia.com/embed/medias/*.jsonp'
409 );
410 }
411 }
412