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