PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.9.6
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.9.6
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
586 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', 'wp-i18n', 'wp-url'],
156 $this->pluginVersion,
157 true
158 );
159
160 wp_localize_script($this->pluginName, 'EMBEDPRESS_ADMIN_PARAMS', [
161 'ajaxurl' => admin_url('admin-ajax.php'),
162 'nonce' => wp_create_nonce('embedpress')
163 ]);
164
165
166 $installedPlugins = Core::getPlugins();
167 if (count($installedPlugins) > 0) {
168 foreach ($installedPlugins as $plgSlug => $plgNamespace) {
169 $plgScriptPathRelative = "assets/js/embedpress.{$plgSlug}.js";
170 $plgName = "embedpress-{$plgSlug}";
171
172 if (file_exists(WP_PLUGIN_DIR . "/{$plgName}/{$plgScriptPathRelative}")) {
173 wp_enqueue_script(
174 $plgName,
175 plugins_url($plgName) . '/' . $plgScriptPathRelative,
176 [$this->pluginName],
177 $this->pluginVersion,
178 true
179 );
180 }
181 }
182 }
183 }
184
185 /**
186 * Method that register all stylesheets for the admin area.
187 *
188 * @return void
189 * @since 1.0.0
190 * @static
191 *
192 */
193 public static function enqueueStyles()
194 {
195 if (isset($_GET['page']) && 'embedpress' === $_GET['page']) {
196 wp_enqueue_style('embedpress-admin', plugins_url('embedpress/assets/css/admin.css'));
197 }
198 }
199
200 /**
201 * Method that receive a string via AJAX and return the decoded-shortcoded-version of that string.
202 *
203 * @return void
204 * @since 1.0.0
205 *
206 */
207 public function doShortcodeReceivedViaAjax()
208 {
209 $subject = isset($_POST['subject']) ? $_POST['subject'] : "";
210
211 $response = [
212 'data' => Shortcode::parseContent($subject, true),
213 ];
214
215 header('Content-Type:application/json;charset=UTF-8');
216 echo json_encode($response);
217
218 exit();
219 }
220
221 /**
222 * Method that receive an url via AJAX and return the info about that url/embed.
223 *
224 * @return void
225 * @since 1.0.0
226 *
227 */
228 public function getUrlInfoViaAjax()
229 {
230 $url = isset($_GET['url']) ? trim($_GET['url']) : "";
231
232 $response = [
233 'url' => $url,
234 'canBeResponsive' => false,
235 ];
236
237 if (!!strlen($response['url'])) {
238
239 $additionalServiceProviders = Core::getAdditionalServiceProviders();
240 if (!empty($additionalServiceProviders)) {
241 foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) {
242 Shortcode::addServiceProvider($serviceProviderClassName, $serviceProviderUrls);
243 }
244 }
245 $embera = new Embera([], Shortcode::get_collection());
246
247 $urlInfo = $embera->getUrlData($response['url']);
248 if (isset($urlInfo[$response['url']]) && $urlInfo[$response['url']]['provider_name']) {
249 $response['canBeResponsive'] = Core::canServiceProviderBeResponsive(strtolower($urlInfo[$response['url']]['provider_name']));
250 }
251 }
252
253 header('Content-Type:application/json;charset=UTF-8');
254 echo json_encode($response);
255
256 exit();
257 }
258
259 /**
260 * Returns a list of supported URL schemes for the preview script
261 *
262 * @return array
263 */
264 public function getUrlSchemes()
265 {
266 return [
267 // Apple podcasts
268 'podcasts.apple.com/*',
269 // PollDaddy
270 '*.polldaddy.com/s/*',
271 '*.polldaddy.com/poll/*',
272 '*.polldaddy.com/ratings/*',
273 'polldaddy.com/s/*',
274 'polldaddy.com/poll/*',
275 'polldaddy.com/ratings/*',
276
277 // VideoPress
278 'videopress.com/v/*',
279
280 // Tumblr
281 '*.tumblr.com/post/*',
282
283 // SmugMug
284 'smugmug.com/*',
285 '*.smugmug.com/*',
286
287 // SlideShare
288 'slideshare.net/*/*',
289 '*.slideshare.net/*/*',
290
291 // Reddit
292 'reddit.com/r/[^/]+/comments/*',
293
294 // Photobucket
295 'i*.photobucket.com/albums/*',
296 'gi*.photobucket.com/groups/*',
297
298 // Cloudup
299 'cloudup.com/*',
300
301 // Imgur
302 'imgur.com/*',
303 'i.imgur.com/*',
304
305 // YouTube (http://www.youtube.com/)
306 'youtube.com/watch\\?*',
307 'youtube.com/playlist\\?*',
308 'youtube.com/channel/*',
309 'youtube.com/c/*',
310 'youtube.com/user/*',
311 'youtube.com/(\w+)[^?\/]*$',
312
313 // opensea
314 'opensea.io/collection/*',
315
316 // Flickr (http://www.flickr.com/)
317 'flickr.com/photos/*/*',
318 'flic.kr/p/*',
319
320 // Viddler (http://www.viddler.com/)
321 'viddler.com/v/*',
322
323 // Hulu (http://www.hulu.com/)
324 'hulu.com/watch/*',
325
326 // Vimeo (http://vimeo.com/)
327 'vimeo.com/*',
328 'vimeo.com/groups/*/videos/*',
329
330 // CollegeHumor (http://www.collegehumor.com/)
331 'collegehumor.com/video/*',
332
333 // Deviantart.com (http://www.deviantart.com)
334 '*.deviantart.com/art/*',
335 '*.deviantart.com/*#/d*',
336 'fav.me/*',
337 'sta.sh/*',
338
339 // SlideShare (http://www.slideshare.net/)
340
341 // chirbit.com (http://www.chirbit.com/)
342 'chirb.it/*',
343
344 // nfb.ca (http://www.nfb.ca/)
345 '*.nfb.ca/film/*',
346
347 // Scribd (http://www.scribd.com/)
348 '*.scribd.com/doc/*',
349 '*.scribd.com/document/*',
350
351 // Dotsub (http://dotsub.com/)
352 'dotsub.com/view/*',
353
354 // Animoto (http://animoto.com/)
355 'animoto.com/play/*',
356
357 // Rdio (http://rdio.com/)
358 '*.rdio.com/artist/*',
359 '*.rdio.com/people/*',
360
361 // MixCloud (http://mixcloud.com/)
362 'mixcloud.com/*/*/',
363
364 // FunnyOrDie (http://www.funnyordie.com/)
365 'funnyordie.com/videos/*',
366
367 // Ted (http://ted.com)
368 'ted.com/talks/*',
369
370 // Sapo Videos (http://videos.sapo.pt)
371 'videos.sapo.pt/*',
372
373 // Official FM (http://official.fm)
374 'official.fm/tracks/*',
375 'official.fm/playlists/*',
376
377 // HuffDuffer (http://huffduffer.com)
378 'huffduffer.com/*/*',
379
380 // Shoudio (http://shoudio.com)
381 'shoudio.com/*',
382 'shoud.io/*',
383
384 // Moby Picture (http://www.mobypicture.com)
385 'mobypicture.com/user/*/view/*',
386 'moby.to/*',
387
388 // 23HQ (http://www.23hq.com)
389 '23hq.com/*/photo/*',
390
391 // Cacoo (https://cacoo.com)
392 'cacoo.com/diagrams/*',
393
394 // Dipity (http://www.dipity.com)
395 'dipity.com/*/*/',
396
397 // Roomshare (http://roomshare.jp)
398 'roomshare.jp/post/*',
399 'roomshare.jp/en/post/*',
400
401 // Dailymotion (http://www.dailymotion.com)
402 'dailymotion.com/video/*',
403
404 // Crowd Ranking (http://crowdranking.com)
405 'c9ng.com/*/*',
406
407 // CircuitLab (https://www.circuitlab.com/)
408 'circuitlab.com/circuit/*',
409
410 // Coub (http://coub.com/)
411 'coub.com/view/*',
412 'coub.com/embed/*',
413
414 // SpeakerDeck (https://speakerdeck.com)
415 'speakerdeck.com/*/*',
416
417 // Instagram (https://instagram.com)
418 'instagram.com/p/*',
419 'instagr.am/p/*',
420
421 // SoundCloud (http://soundcloud.com/)
422 'soundcloud.com/*',
423
424 // Kickstarter (http://www.kickstarter.com)
425 'kickstarter.com/projects/*',
426
427 // Ustream (http://www.ustream.tv)
428 '*.ustream.tv/*',
429 '*.ustream.com/*',
430
431 // Daily Mile (http://www.dailymile.com)
432 'dailymile.com/people/*/entries/*',
433
434 // Sketchfab (http://sketchfab.com)
435 'sketchfab.com/models/*',
436 'sketchfab.com/*/folders/*',
437
438 // Meetup (http://www.meetup.com)
439 'meetup.com/*',
440 'meetu.ps/*',
441
442 // AudioSnaps (http://audiosnaps.com)
443 'audiosnaps.com/k/*',
444
445 // RapidEngage (https://rapidengage.com)
446 'rapidengage.com/s/*',
447
448 // Getty Images (http://www.gettyimages.com/)
449 'gty.im/*',
450 'gettyimages.com/detail/photo/*',
451
452 // amCharts Live Editor (http://live.amcharts.com/)
453 'live.amcharts.com/*',
454
455 // Infogram (https://infogr.am/)
456 'infogr.am/*',
457 'infogram.com/*',
458
459 // ChartBlocks (http://www.chartblocks.com/)
460 'public.chartblocks.com/c/*',
461
462 // ReleaseWire (http://www.releasewire.com/)
463 'rwire.com/*',
464
465 // ShortNote (https://www.shortnote.jp/)
466 'shortnote.jp/view/notes/*',
467
468 // EgliseInfo (http://egliseinfo.catholique.fr/)
469 'egliseinfo.catholique.fr/*',
470
471 // Silk (http://www.silk.co/)
472 '*.silk.co/explore/*',
473 '*.silk.co/s/embed/*',
474
475 // Twitter
476 'twitter.com/*/status/*',
477 'twitter.com/i/moments/*',
478 'twitter.com/*/timelines/*',
479
480 // http://bambuser.com
481 'bambuser.com/v/*',
482
483 // https://clyp.it
484 'clyp.it/*',
485
486 // https://gist.github.com
487 'gist.github.com/*/*',
488
489 // http://issuu.com
490 'issuu.com/*',
491
492 // https://portfolium.com
493 'portfolium.com/*',
494
495 // https://www.reverbnation.com
496 'reverbnation.com/*',
497
498 // http://rutube.ru
499 'rutube.ru/video/*',
500
501 // https://spotify.com/
502 'open.spotify.com/*',
503
504 // http://www.videojug.com
505 'videojug.com/*',
506
507 // https://vine.com
508 'vine.co/v/*',
509
510 // Facebook
511 'facebook.com/*',
512 'fb.watch/*',
513
514 // Google Shortened Url
515 'goo.gl/*',
516
517 // Google Maps
518 'google.com/*',
519 'google.com.*/*',
520 'google.co.*/*',
521 'maps.google.com/*',
522
523 // Google Docs
524 'docs.google.com/presentation/*',
525 'docs.google.com/document/*',
526 'docs.google.com/spreadsheets/*',
527 'docs.google.com/forms/*',
528 'docs.google.com/drawings/*',
529
530 // Twitch.tv
531 '*.twitch.tv/*',
532 'twitch.tv/*',
533
534 // Giphy
535 '*.giphy.com/gifs/*',
536 'giphy.com/gifs/*',
537 'i.giphy.com/*',
538 'gph.is/*',
539
540 // Wistia
541 '*.wistia.com/medias/*',
542 'fast.wistia.com/embed/medias/*.jsonp',
543 // Boomplay (http://boomplay.com/)
544 'boomplay.com/*',
545 'codepen.io/*',
546 'archivos.digital/*',
547 'audioclip.naver.com/*',
548 'app.blogcast.host/*',
549 'codepoints.net/*',
550 'codesandbox.io/*',
551 'commaful.com/*',
552 '*.survey.fm/*',
553 'survey.fm/*',
554 'datawrapper.dwcdn.net/*',
555 '*.didacte.com/*',
556 'didacte.com/*',
557 'digiteka.com/*',
558 'docdro.id/*',
559 'edumedia-sciences.com/*',
560 'ethfiddle.com/*',
561 'eyrie.io/*',
562 '*.getfader.com/*',
563 'getfader.com/*',
564 'fitapp.pro/*',
565 'fite.tv/*',
566 'public.flourish.studio/*',
567 'geograph.org.gg/*',
568 'geo-en.hlipp.de/*',
569 'geograph.org.uk/*',
570 'fortest.getshow.io/*',
571 'opensea.io/assets/*',
572 ];
573 }
574
575 /**
576 * Update admin notice view status
577 *
578 * @since 2.5.1
579 */
580 public static function embedpress_notice_dismiss()
581 {
582 check_ajax_referer('embedpress', 'security');
583 update_option('embedpress_social_dismiss_notice', true);
584 }
585 }
586