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