PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.9.0
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.9.0
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
Settings 2 years ago Handler.php 2 years ago index.html 7 years ago
Handler.php
594 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 use EmbedPress\Includes\Classes\Helper;
10
11 (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
12
13 /**
14 * The admin-facing functionality of the plugin.
15 * Defines the plugin name, version, and enqueue the admin-specific stylesheets and scripts.
16 *
17 * @package EmbedPress
18 * @subpackage EmbedPress/Ends/Back
19 * @author EmbedPress <help@embedpress.com>
20 * @copyright Copyright (C) 2023 WPDeveloper. All rights reserved.
21 * @license GPLv3 or later
22 * @since 1.0.0
23 */
24 class Handler extends EndHandlerAbstract
25 {
26 /**
27 * Method that register all scripts for the admin area.
28 *
29 * @return void
30 * @since 1.0.0
31 *
32 */
33
34 public function __construct($pluginName, $pluginVersion)
35 {
36 parent::__construct($pluginName, $pluginVersion);
37
38 add_action('init', [$this, 'handle_calendly_data']);
39 }
40
41 public function handle_calendly_data()
42 {
43
44 if ((!empty($_GET['access_token']) && isset($_GET['page_type']) && $_GET['page_type'] == 'calendly') || (isset($_GET['calendly_status']) && ($_GET['calendly_status'] == 'sync' || $_GET['calendly_status'] == 'connect'))) {
45
46 update_option('is_calendly_connected', true);
47
48 if (isset($_GET['access_token']) && !empty($_GET['access_token'])) {
49 $access_token = $_GET['access_token'];
50 $refresh_token = $_GET['refresh_token'];
51 $expires_in = $_GET['expires_in'];
52 $created_at = $_GET['created_at'];
53 } elseif (isset($_GET['calendly_status']) && ($_GET['calendly_status'] == 'sync' || $_GET['calendly_status'] == 'connect')) {
54 $token_data = get_option('calendly_tokens');
55 $access_token = $token_data['access_token'];
56 $refresh_token = $token_data['refresh_token'];
57 $expires_in = $token_data['expires_in'];
58 $created_at = $token_data['created_at'];
59 }
60
61 // Create an array to store the tokens and expiration time
62 $token_data = array(
63 'access_token' => $access_token,
64 'refresh_token' => $refresh_token,
65 'expires_in' => $expires_in,
66 'created_at' => $created_at
67 );
68
69 // Save the serialized data in a single option key
70 update_option('calendly_tokens', $token_data);
71
72 $user_info = Helper::getCalendlyUserInfo($access_token);
73 $event_types = Helper::getCalaendlyEventTypes($user_info['resource']['uri'], $access_token);
74 $scheduled_events = Helper::getCalaendlyScheduledEvents($user_info['resource']['uri'], $access_token);
75
76 $invite_list = [];
77
78 foreach ($scheduled_events['collection'] as $event) :
79 $uuid = Helper::getCalendlyUuid($event['uri']);
80 $invite_list[$uuid] = Helper::getListEventInvitee($uuid, $access_token);
81 endforeach;
82
83 update_option('calendly_user_info', $user_info);
84
85
86
87 if (is_embedpress_pro_active() && (!isset($event_types['title']) && $event_types['title'] !== 'Unauthenticated')) {
88 update_option('calendly_event_types', $event_types);
89 update_option('calendly_scheduled_events', $scheduled_events);
90 update_option('calendly_invitees_list', $invite_list);
91 }
92
93 if (!is_embedpress_pro_active()) {
94 update_option('calendly_event_types', []);
95 update_option('calendly_scheduled_events', []);
96 update_option('calendly_invitees_list', []);
97 }
98
99 wp_redirect(admin_url('admin.php?page=embedpress&page_type=calendly'), 302);
100 exit();
101 }
102 }
103
104 public function enqueueScripts()
105 {
106 global $pagenow;
107 if ('post.php' === $pagenow) {
108 $urlSchemes = apply_filters('embedpress:getAdditionalURLSchemes', $this->getUrlSchemes());
109
110 wp_enqueue_script(
111 'embedpress-pdfobject',
112 EMBEDPRESS_URL_ASSETS . 'js/pdfobject.min.js',
113 [],
114 $this->pluginVersion,
115 false
116 );
117
118 wp_enqueue_script("bootbox-bootstrap", EMBEDPRESS_URL_ASSETS . 'js/vendor/bootstrap/bootstrap.min.js', ['jquery'], $this->pluginVersion, false);
119 wp_enqueue_script("bootbox", EMBEDPRESS_URL_ASSETS . 'js/vendor/bootbox.min.js', ['jquery', 'bootbox-bootstrap'], $this->pluginVersion, true);
120 wp_enqueue_script($this->pluginName, EMBEDPRESS_URL_ASSETS . 'js/preview.js', ['jquery', 'bootbox'], $this->pluginVersion, true);
121
122
123 wp_localize_script($this->pluginName, '$data', [
124 'previewSettings' => [
125 'baseUrl' => get_site_url() . '/',
126 'versionUID' => $this->pluginVersion,
127 'debug' => true,
128 ],
129 'EMBEDPRESS_SHORTCODE' => EMBEDPRESS_SHORTCODE,
130 'EMBEDPRESS_URL_ASSETS' => EMBEDPRESS_URL_ASSETS,
131 'urlSchemes' => $urlSchemes,
132 ]);
133 }
134
135 if ('post.php' === $pagenow || 'post-new.php' === $pagenow) {
136 wp_enqueue_script(
137 'plyr.polyfilled',
138 EMBEDPRESS_URL_ASSETS . 'js/plyr.polyfilled.js',
139 [],
140 $this->pluginVersion,
141 false
142 );
143
144 wp_enqueue_style('plyr', EMBEDPRESS_URL_ASSETS . 'css/plyr.css', $this->pluginVersion, true);
145
146 wp_enqueue_style($this->pluginName, EMBEDPRESS_URL_ASSETS . 'css/embedpress.css', $this->pluginVersion, true);
147 }
148
149
150 //load embedpress admin js
151
152 wp_enqueue_script(
153 'embedpress-admin',
154 EMBEDPRESS_URL_ASSETS . 'js/admin.js',
155 ['jquery'],
156 $this->pluginVersion,
157 true
158 );
159
160 wp_enqueue_script(
161 'embedpress-admin',
162 EMBEDPRESS_URL_ASSETS . 'js/admin.js',
163 ['jquery'],
164 $this->pluginVersion,
165 true
166 );
167
168 wp_localize_script($this->pluginName, 'EMBEDPRESS_ADMIN_PARAMS', [
169 'ajaxurl' => admin_url('admin-ajax.php'),
170 'nonce' => wp_create_nonce('embedpress')
171 ]);
172
173
174 $installedPlugins = Core::getPlugins();
175 if (count($installedPlugins) > 0) {
176 foreach ($installedPlugins as $plgSlug => $plgNamespace) {
177 $plgScriptPathRelative = "assets/js/embedpress.{$plgSlug}.js";
178 $plgName = "embedpress-{$plgSlug}";
179
180 if (file_exists(WP_PLUGIN_DIR . "/{$plgName}/{$plgScriptPathRelative}")) {
181 wp_enqueue_script(
182 $plgName,
183 plugins_url($plgName) . '/' . $plgScriptPathRelative,
184 [$this->pluginName],
185 $this->pluginVersion,
186 true
187 );
188 }
189 }
190 }
191 }
192
193 /**
194 * Method that register all stylesheets for the admin area.
195 *
196 * @return void
197 * @since 1.0.0
198 * @static
199 *
200 */
201 public static function enqueueStyles()
202 {
203 if (isset($_GET['page']) && 'embedpress' === $_GET['page']) {
204 wp_enqueue_style('embedpress-admin', plugins_url('embedpress/assets/css/admin.css'));
205 }
206 }
207
208 /**
209 * Method that receive a string via AJAX and return the decoded-shortcoded-version of that string.
210 *
211 * @return void
212 * @since 1.0.0
213 *
214 */
215 public function doShortcodeReceivedViaAjax()
216 {
217 $subject = isset($_POST['subject']) ? $_POST['subject'] : "";
218
219 $response = [
220 'data' => Shortcode::parseContent($subject, true),
221 ];
222
223 header('Content-Type:application/json;charset=UTF-8');
224 echo json_encode($response);
225
226 exit();
227 }
228
229 /**
230 * Method that receive an url via AJAX and return the info about that url/embed.
231 *
232 * @return void
233 * @since 1.0.0
234 *
235 */
236 public function getUrlInfoViaAjax()
237 {
238 $url = isset($_GET['url']) ? trim($_GET['url']) : "";
239
240 $response = [
241 'url' => $url,
242 'canBeResponsive' => false,
243 ];
244
245 if (!!strlen($response['url'])) {
246
247 $additionalServiceProviders = Core::getAdditionalServiceProviders();
248 if (!empty($additionalServiceProviders)) {
249 foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) {
250 Shortcode::addServiceProvider($serviceProviderClassName, $serviceProviderUrls);
251 }
252 }
253 $embera = new Embera([], Shortcode::get_collection());
254
255 $urlInfo = $embera->getUrlData($response['url']);
256 if (isset($urlInfo[$response['url']]) && $urlInfo[$response['url']]['provider_name']) {
257 $response['canBeResponsive'] = Core::canServiceProviderBeResponsive(strtolower($urlInfo[$response['url']]['provider_name']));
258 }
259 }
260
261 header('Content-Type:application/json;charset=UTF-8');
262 echo json_encode($response);
263
264 exit();
265 }
266
267 /**
268 * Returns a list of supported URL schemes for the preview script
269 *
270 * @return array
271 */
272 public function getUrlSchemes()
273 {
274 return [
275 // Apple podcasts
276 'podcasts.apple.com/*',
277 // PollDaddy
278 '*.polldaddy.com/s/*',
279 '*.polldaddy.com/poll/*',
280 '*.polldaddy.com/ratings/*',
281 'polldaddy.com/s/*',
282 'polldaddy.com/poll/*',
283 'polldaddy.com/ratings/*',
284
285 // VideoPress
286 'videopress.com/v/*',
287
288 // Tumblr
289 '*.tumblr.com/post/*',
290
291 // SmugMug
292 'smugmug.com/*',
293 '*.smugmug.com/*',
294
295 // SlideShare
296 'slideshare.net/*/*',
297 '*.slideshare.net/*/*',
298
299 // Reddit
300 'reddit.com/r/[^/]+/comments/*',
301
302 // Photobucket
303 'i*.photobucket.com/albums/*',
304 'gi*.photobucket.com/groups/*',
305
306 // Cloudup
307 'cloudup.com/*',
308
309 // Imgur
310 'imgur.com/*',
311 'i.imgur.com/*',
312
313 // YouTube (http://www.youtube.com/)
314 'youtube.com/watch\\?*',
315 'youtube.com/playlist\\?*',
316 'youtube.com/channel/*',
317 'youtube.com/c/*',
318 'youtube.com/user/*',
319 'youtube.com/(\w+)[^?\/]*$',
320
321 // opensea
322 'opensea.io/collection/*',
323
324 // Flickr (http://www.flickr.com/)
325 'flickr.com/photos/*/*',
326 'flic.kr/p/*',
327
328 // Viddler (http://www.viddler.com/)
329 'viddler.com/v/*',
330
331 // Hulu (http://www.hulu.com/)
332 'hulu.com/watch/*',
333
334 // Vimeo (http://vimeo.com/)
335 'vimeo.com/*',
336 'vimeo.com/groups/*/videos/*',
337
338 // CollegeHumor (http://www.collegehumor.com/)
339 'collegehumor.com/video/*',
340
341 // Deviantart.com (http://www.deviantart.com)
342 '*.deviantart.com/art/*',
343 '*.deviantart.com/*#/d*',
344 'fav.me/*',
345 'sta.sh/*',
346
347 // SlideShare (http://www.slideshare.net/)
348
349 // chirbit.com (http://www.chirbit.com/)
350 'chirb.it/*',
351
352 // nfb.ca (http://www.nfb.ca/)
353 '*.nfb.ca/film/*',
354
355 // Scribd (http://www.scribd.com/)
356 '*.scribd.com/doc/*',
357 '*.scribd.com/document/*',
358
359 // Dotsub (http://dotsub.com/)
360 'dotsub.com/view/*',
361
362 // Animoto (http://animoto.com/)
363 'animoto.com/play/*',
364
365 // Rdio (http://rdio.com/)
366 '*.rdio.com/artist/*',
367 '*.rdio.com/people/*',
368
369 // MixCloud (http://mixcloud.com/)
370 'mixcloud.com/*/*/',
371
372 // FunnyOrDie (http://www.funnyordie.com/)
373 'funnyordie.com/videos/*',
374
375 // Ted (http://ted.com)
376 'ted.com/talks/*',
377
378 // Sapo Videos (http://videos.sapo.pt)
379 'videos.sapo.pt/*',
380
381 // Official FM (http://official.fm)
382 'official.fm/tracks/*',
383 'official.fm/playlists/*',
384
385 // HuffDuffer (http://huffduffer.com)
386 'huffduffer.com/*/*',
387
388 // Shoudio (http://shoudio.com)
389 'shoudio.com/*',
390 'shoud.io/*',
391
392 // Moby Picture (http://www.mobypicture.com)
393 'mobypicture.com/user/*/view/*',
394 'moby.to/*',
395
396 // 23HQ (http://www.23hq.com)
397 '23hq.com/*/photo/*',
398
399 // Cacoo (https://cacoo.com)
400 'cacoo.com/diagrams/*',
401
402 // Dipity (http://www.dipity.com)
403 'dipity.com/*/*/',
404
405 // Roomshare (http://roomshare.jp)
406 'roomshare.jp/post/*',
407 'roomshare.jp/en/post/*',
408
409 // Dailymotion (http://www.dailymotion.com)
410 'dailymotion.com/video/*',
411
412 // Crowd Ranking (http://crowdranking.com)
413 'c9ng.com/*/*',
414
415 // CircuitLab (https://www.circuitlab.com/)
416 'circuitlab.com/circuit/*',
417
418 // Coub (http://coub.com/)
419 'coub.com/view/*',
420 'coub.com/embed/*',
421
422 // SpeakerDeck (https://speakerdeck.com)
423 'speakerdeck.com/*/*',
424
425 // Instagram (https://instagram.com)
426 'instagram.com/p/*',
427 'instagr.am/p/*',
428
429 // SoundCloud (http://soundcloud.com/)
430 'soundcloud.com/*',
431
432 // Kickstarter (http://www.kickstarter.com)
433 'kickstarter.com/projects/*',
434
435 // Ustream (http://www.ustream.tv)
436 '*.ustream.tv/*',
437 '*.ustream.com/*',
438
439 // Daily Mile (http://www.dailymile.com)
440 'dailymile.com/people/*/entries/*',
441
442 // Sketchfab (http://sketchfab.com)
443 'sketchfab.com/models/*',
444 'sketchfab.com/*/folders/*',
445
446 // Meetup (http://www.meetup.com)
447 'meetup.com/*',
448 'meetu.ps/*',
449
450 // AudioSnaps (http://audiosnaps.com)
451 'audiosnaps.com/k/*',
452
453 // RapidEngage (https://rapidengage.com)
454 'rapidengage.com/s/*',
455
456 // Getty Images (http://www.gettyimages.com/)
457 'gty.im/*',
458 'gettyimages.com/detail/photo/*',
459
460 // amCharts Live Editor (http://live.amcharts.com/)
461 'live.amcharts.com/*',
462
463 // Infogram (https://infogr.am/)
464 'infogr.am/*',
465 'infogram.com/*',
466
467 // ChartBlocks (http://www.chartblocks.com/)
468 'public.chartblocks.com/c/*',
469
470 // ReleaseWire (http://www.releasewire.com/)
471 'rwire.com/*',
472
473 // ShortNote (https://www.shortnote.jp/)
474 'shortnote.jp/view/notes/*',
475
476 // EgliseInfo (http://egliseinfo.catholique.fr/)
477 'egliseinfo.catholique.fr/*',
478
479 // Silk (http://www.silk.co/)
480 '*.silk.co/explore/*',
481 '*.silk.co/s/embed/*',
482
483 // Twitter
484 'twitter.com/*/status/*',
485 'twitter.com/i/moments/*',
486 'twitter.com/*/timelines/*',
487
488 // http://bambuser.com
489 'bambuser.com/v/*',
490
491 // https://clyp.it
492 'clyp.it/*',
493
494 // https://gist.github.com
495 'gist.github.com/*/*',
496
497 // http://issuu.com
498 'issuu.com/*',
499
500 // https://portfolium.com
501 'portfolium.com/*',
502
503 // https://www.reverbnation.com
504 'reverbnation.com/*',
505
506 // http://rutube.ru
507 'rutube.ru/video/*',
508
509 // https://spotify.com/
510 'open.spotify.com/*',
511
512 // http://www.videojug.com
513 'videojug.com/*',
514
515 // https://vine.com
516 'vine.co/v/*',
517
518 // Facebook
519 'facebook.com/*',
520 'fb.watch/*',
521
522 // Google Shortened Url
523 'goo.gl/*',
524
525 // Google Maps
526 'google.com/*',
527 'google.com.*/*',
528 'google.co.*/*',
529 'maps.google.com/*',
530
531 // Google Docs
532 'docs.google.com/presentation/*',
533 'docs.google.com/document/*',
534 'docs.google.com/spreadsheets/*',
535 'docs.google.com/forms/*',
536 'docs.google.com/drawings/*',
537
538 // Twitch.tv
539 '*.twitch.tv/*',
540 'twitch.tv/*',
541
542 // Giphy
543 '*.giphy.com/gifs/*',
544 'giphy.com/gifs/*',
545 'i.giphy.com/*',
546 'gph.is/*',
547
548 // Wistia
549 '*.wistia.com/medias/*',
550 'fast.wistia.com/embed/medias/*.jsonp',
551 // Boomplay (http://boomplay.com/)
552 'boomplay.com/*',
553 'codepen.io/*',
554 'archivos.digital/*',
555 'audioclip.naver.com/*',
556 'app.blogcast.host/*',
557 'codepoints.net/*',
558 'codesandbox.io/*',
559 'commaful.com/*',
560 '*.survey.fm/*',
561 'survey.fm/*',
562 'datawrapper.dwcdn.net/*',
563 '*.didacte.com/*',
564 'didacte.com/*',
565 'digiteka.com/*',
566 'docdro.id/*',
567 'edumedia-sciences.com/*',
568 'ethfiddle.com/*',
569 'eyrie.io/*',
570 '*.getfader.com/*',
571 'getfader.com/*',
572 'fitapp.pro/*',
573 'fite.tv/*',
574 'public.flourish.studio/*',
575 'geograph.org.gg/*',
576 'geo-en.hlipp.de/*',
577 'geograph.org.uk/*',
578 'fortest.getshow.io/*',
579 'opensea.io/assets/*',
580 ];
581 }
582
583 /**
584 * Update admin notice view status
585 *
586 * @since 2.5.1
587 */
588 public static function embedpress_notice_dismiss()
589 {
590 check_ajax_referer('embedpress', 'security');
591 update_option('embedpress_social_dismiss_notice', true);
592 }
593 }
594