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