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