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