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