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