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