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