PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.0.2
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.0.2
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
935 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('wp_ajax_delete_instagram_account', [$this, 'delete_instagram_account']);
39 // add_action('init', [$this, 'handle_instagram_data']);
40
41 add_action('wp_ajax_get_instagram_userdata_ajax', [$this, 'get_instagram_userdata_ajax']);
42 add_action('wp_ajax_nopriv_get_instagram_userdata_ajax', [$this, 'get_instagram_userdata_ajax']);
43
44 if (!empty($_GET['page_type']) && $_GET['page_type'] == 'calendly') {
45 add_action('init', [$this, 'handle_calendly_data']);
46 }
47
48 if (defined('EMBEDPRESS_SL_ITEM_SLUG') && is_admin()) {
49 add_action('admin_enqueue_scripts', [$this, 'enqueueLisenceScripts']);
50 }
51
52 add_action('wp_ajax_sync_instagram_data_ajax', [$this, 'sync_instagram_data_ajax']);
53 add_action('wp_ajax_nopriv_sync_instagram_data_ajax', [$this, 'sync_instagram_data_ajax']);
54 }
55
56
57 public function get_instagram_userdata_ajax()
58 {
59 if (isset($_POST['_nonce']) && wp_verify_nonce($_POST['_nonce'], 'embedpress_elements_action')) {
60 if (isset($_POST['access_token'])) {
61 $access_token = sanitize_text_field($_POST['access_token']);
62 $account_type = sanitize_text_field($_POST['account_type']);
63
64 $user_data = $this->get_instagram_userdata($access_token, $account_type);
65
66 $this->handle_instagram_data($user_data);
67
68 $access_token = sanitize_text_field($_POST['access_token']);
69 $account_type = sanitize_text_field($_POST['account_type']);
70 $user_id = $this->get_instagram_userid($access_token, $account_type);
71
72 $option_key = 'ep_instagram_feed_data';
73 $feed_data = get_option($option_key, array());
74
75 $feed_userinfo = Helper::getInstagramUserInfo($access_token, $account_type, $user_id, true);
76 $feed_posts = Helper::getInstagramPosts($access_token, $account_type, $user_id, 100, true);
77
78 if (!empty($user_id)) {
79 $feed_data[$user_id] = [
80 'feed_userinfo' => $feed_userinfo,
81 'feed_posts' => $feed_posts,
82 ];
83
84 delete_transient('instagram_user_info_' . $user_id);
85 delete_transient('instagram_posts_' . $user_id);
86 update_option('ep_instagram_feed_data', $feed_data);
87 } else {
88 $feed_data['error'] = "Access token Invalid or expired.";
89 }
90
91
92 wp_send_json($feed_data);
93 } else {
94 wp_send_json_error('Access token not provided');
95 }
96 } else {
97 wp_send_json_error('Nonce verification failed');
98 }
99 }
100
101 public function sync_instagram_data_ajax()
102 {
103 if (isset($_POST['_nonce']) && wp_verify_nonce($_POST['_nonce'], 'embedpress_elements_action')) {
104 if (isset($_POST['access_token'])) {
105
106 $access_token = sanitize_text_field($_POST['access_token']);
107 $account_type = sanitize_text_field($_POST['account_type']);
108 $user_id = sanitize_text_field($_POST['user_id']);
109
110 $option_key = 'ep_instagram_feed_data';
111 $feed_data = get_option($option_key, array());
112
113 $feed_userinfo = Helper::getInstagramUserInfo($access_token, $account_type, $user_id, true);
114 $feed_posts = Helper::getInstagramPosts($access_token, $account_type, $user_id, 100, true);
115
116 $feed_data[$user_id] = [
117 'feed_userinfo' => $feed_userinfo,
118 'feed_posts' => $feed_posts,
119 ];
120
121 delete_transient('instagram_user_info_' . $user_id);
122 delete_transient('instagram_posts_' . $user_id);
123 update_option('ep_instagram_feed_data', $feed_data);
124
125
126 wp_send_json($feed_data);
127 } else {
128 wp_send_json_error('Access token not provided');
129 }
130 } else {
131 wp_send_json_error('Nonce verification failed');
132 }
133 }
134
135
136 public function get_instagram_userid($access_token)
137 {
138 $response = "https://graph.facebook.com/v19.0/me/accounts?fields=connected_instagram_account{id}&access_token=$access_token";
139 if (!is_wp_error($response)) {
140
141 $body = wp_remote_retrieve_body($response);
142 $data = json_decode($body, true);
143
144 // Extract the connected Instagram account ID
145 if (isset($data['data'][0]['connected_instagram_account']['id'])) {
146 return $data['data'][0]['connected_instagram_account']['id'];
147 } else {
148 return '';
149 }
150 } else {
151 $user_data['error'] = "Error: Unable to connect to Instagram API.";
152 }
153 }
154
155 public function get_instagram_profile_picture($access_token, $userid)
156 { }
157
158 public function get_instagram_user_id($access_token, $account_type)
159 {
160 // Check if user data is already cached
161 $user_id = get_transient('instagram_user_id_' . $access_token);
162
163 if (!$user_id) {
164 $user_id = array();
165
166 if ($account_type == 'personal') {
167 $response = wp_remote_get('https://graph.instagram.com/me?fields=id,username,account_type&access_token=' . $access_token);
168 } else {
169 $response = wp_remote_get('https://graph.facebook.com/v19.0/me/accounts?fields=connected_instagram_account{id,name,username,followers_count}&access_token=' . $access_token);
170 }
171
172
173 if (!is_wp_error($response)) {
174
175 $body = wp_remote_retrieve_body($response);
176 $data = json_decode($body, true);
177
178 if ($account_type == 'personal') {
179
180 if (isset($data['id']) && isset($data['username'])) {
181 return $data['id'];
182
183 set_transient('instagram_user_id_' . $access_token, $data['id'], HOUR_IN_SECONDS);
184 return $data['id'];
185 } else {
186 $data['error'] = "Access token Invalid or expired.";
187 }
188 } else {
189 if (isset($data['data'][0]['connected_instagram_account']['id']) && isset($data['data'][0]['connected_instagram_account']['username'])) {
190 set_transient('instagram_user_id_' . $access_token, $data['data'][0]['connected_instagram_account']['id'], HOUR_IN_SECONDS);
191 return $data['data'][0]['connected_instagram_account']['id'];
192 } else {
193 $data['error'] = "Access token Invalid or expired.";
194 }
195 }
196 } else {
197 $data['error'] = "Error: Unable to connect to Instagram API.";
198 }
199 }
200
201 return $data;
202 }
203
204 public function get_instagram_userdata($access_token, $account_type)
205 {
206 // Check if user data is already cached
207 $user_data = get_transient('instagram_user_data_' . $access_token);
208
209 if (!$user_data) {
210 $user_data = array();
211
212 if ($account_type == 'personal') {
213 $response = wp_remote_get('https://graph.instagram.com/me?fields=id,username,account_type&access_token=' . $access_token);
214 } else {
215 $response = wp_remote_get('https://graph.facebook.com/v19.0/me/accounts?fields=connected_instagram_account{id,name,username,followers_count}&access_token=' . $access_token);
216 }
217
218
219 if (!is_wp_error($response)) {
220
221 $body = wp_remote_retrieve_body($response);
222 $data = json_decode($body, true);
223
224 if ($account_type == 'personal') {
225
226 if (isset($data['id']) && isset($data['username'])) {
227 $user_data['access_token'] = $access_token;
228 $user_data['user_id'] = $data['id'];
229 $user_data['username'] = $data['username'];
230 $user_data['account_type'] = $account_type;
231
232 set_transient('instagram_user_data_' . $access_token, $user_data, HOUR_IN_SECONDS);
233 } else {
234 $user_data['error'] = "Access token Invalid or expired.";
235 }
236 } else {
237 if (isset($data['data'][0]['connected_instagram_account']['id']) && isset($data['data'][0]['connected_instagram_account']['username'])) {
238 $user_data['access_token'] = $access_token;
239 $user_data['user_id'] = $data['data'][0]['connected_instagram_account']['id']; // Assuming 'id' refers to Facebook account ID
240 $user_data['instagram_id'] = $data['data'][0]['connected_instagram_account']['id'];
241 $user_data['username'] = $data['data'][0]['connected_instagram_account']['username'];
242 $user_data['account_type'] = $account_type;
243
244 set_transient('instagram_user_data_' . $access_token, $user_data, HOUR_IN_SECONDS);
245 } else {
246 $user_data['error'] = "Access token Invalid or expired.";
247 }
248 }
249 } else {
250 $user_data['error'] = "Error: Unable to connect to Instagram API.";
251 }
252 }
253
254 return $user_data;
255 }
256
257
258
259
260 public function handle_instagram_data($user_data)
261 {
262 if (empty($user_data['error'])) {
263 $user_id = isset($user_data['user_id']) ? $user_data['user_id'] : '';
264 $username = isset($user_data['username']) ? $user_data['username'] : '';
265 $account_type = isset($user_data['account_type']) ? $user_data['account_type'] : '';
266 $access_token = isset($user_data['access_token']) ? $user_data['access_token'] : '';
267
268 $get_instagram_data = get_option('ep_instagram_account_data');
269
270 $token_data = [
271 [
272 'user_id' => $user_id,
273 'username' => $username,
274 'account_type' => $account_type,
275 'access_token' => $access_token,
276 ]
277 ];
278
279 if (!empty($get_instagram_data)) {
280 $updated = false;
281
282 foreach ($get_instagram_data as &$data) {
283
284 if ($data['user_id'] === $user_id) {
285
286 // If user_id matches, update the data
287 $data['username'] = $username;
288 $data['account_type'] = $account_type;
289 $data['access_token'] = $access_token;
290
291 $updated = true;
292 break;
293 }
294 }
295
296 if (!$updated) {
297 // If user_id does not exist, add new data
298 $get_instagram_data[] = $token_data[0];
299 }
300 } else {
301 // If $get_instagram_data is empty, add the new data directly
302 $get_instagram_data = $token_data;
303 }
304
305 update_option('ep_instagram_account_data', $get_instagram_data);
306
307 wp_redirect(admin_url('admin.php?page=embedpress&page_type=instagram'), 301);
308
309 exit();
310 }
311 }
312
313 public function handle_calendly_data()
314 {
315
316 if (empty($_GET['_nonce'])) {
317 return false;
318 }
319
320 $verify = wp_verify_nonce($_GET['_nonce'], 'calendly_nonce');
321
322 // Check if access_token or calendly_status is present and nonce is invalid
323 if (!$verify) {
324 echo esc_html__('Invalid nonce', 'embedpress');
325 die;
326 }
327
328 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'))) {
329
330 if ($_GET['calendly_status'] === 'connect') {
331 update_option('is_calendly_connected', true);
332 }
333
334 if (isset($_GET['access_token']) && !empty($_GET['access_token'])) {
335 $access_token = $_GET['access_token'];
336 $refresh_token = $_GET['refresh_token'];
337 $expires_in = $_GET['expires_in'];
338 $created_at = $_GET['created_at'];
339 } elseif (isset($_GET['calendly_status']) && ($_GET['calendly_status'] == 'sync' || $_GET['calendly_status'] == 'connect')) {
340 $token_data = get_option('calendly_tokens');
341 $access_token = $token_data['access_token'];
342 $refresh_token = $token_data['refresh_token'];
343 $expires_in = $token_data['expires_in'];
344 $created_at = $token_data['created_at'];
345 }
346
347
348 // Create an array to store the tokens and expiration time
349 $token_data = array(
350 'access_token' => $access_token,
351 'refresh_token' => $refresh_token,
352 'expires_in' => $expires_in,
353 'created_at' => $created_at
354 );
355
356 // Save the serialized data in a single option key
357 update_option('calendly_tokens', $token_data);
358
359 $user_info = json_decode(Helper::getCalendlyUserInfo($access_token), true);
360
361 if (!empty($user_info['resource']['uri'])) {
362 $event_types = Helper::getCalaendlyEventTypes($user_info['resource']['uri'], $access_token);
363 $scheduled_events = Helper::getCalaendlyScheduledEvents($user_info['resource']['uri'], $access_token);
364
365 $invite_list = [];
366
367 if (is_array($scheduled_events['collection'])) {
368 foreach ($scheduled_events['collection'] as $event) :
369 $uuid = Helper::getCalendlyUuid($event['uri']);
370 $invite_list[$uuid] = Helper::getListEventInvitee($uuid, $access_token);
371 endforeach;
372 }
373
374 update_option('calendly_user_info', $user_info);
375
376 if (is_embedpress_pro_active() && (empty($event_types['title']))) {
377
378 update_option('calendly_event_types', $event_types);
379 update_option('calendly_scheduled_events', $scheduled_events);
380 update_option('calendly_invitees_list', $invite_list);
381 }
382
383 if (!is_embedpress_pro_active()) {
384 update_option('calendly_event_types', []);
385 update_option('calendly_scheduled_events', []);
386 update_option('calendly_invitees_list', []);
387 }
388 }
389
390 wp_redirect(admin_url('admin.php?page=embedpress&page_type=calendly'), 302);
391 exit();
392 }
393 }
394
395 public function enqueueScripts()
396 {
397 global $pagenow;
398 if ('post.php' === $pagenow) {
399 $urlSchemes = apply_filters('embedpress:getAdditionalURLSchemes', $this->getUrlSchemes());
400
401 wp_enqueue_script(
402 'embedpress-pdfobject',
403 EMBEDPRESS_URL_ASSETS . 'js/pdfobject.min.js',
404 [],
405 $this->pluginVersion,
406 false
407 );
408
409 wp_enqueue_script("bootbox-bootstrap", EMBEDPRESS_URL_ASSETS . 'js/vendor/bootstrap/bootstrap.min.js', ['jquery'], $this->pluginVersion, false);
410 wp_enqueue_script("bootbox", EMBEDPRESS_URL_ASSETS . 'js/vendor/bootbox.min.js', ['jquery', 'bootbox-bootstrap'], $this->pluginVersion, true);
411 wp_enqueue_script($this->pluginName, EMBEDPRESS_URL_ASSETS . 'js/preview.js', ['jquery', 'bootbox'], $this->pluginVersion, true);
412
413
414 wp_localize_script($this->pluginName, '$data', [
415 'previewSettings' => [
416 'baseUrl' => get_site_url() . '/',
417 'versionUID' => $this->pluginVersion,
418 'debug' => true,
419 ],
420 'EMBEDPRESS_SHORTCODE' => EMBEDPRESS_SHORTCODE,
421 'EMBEDPRESS_URL_ASSETS' => EMBEDPRESS_URL_ASSETS,
422 'urlSchemes' => $urlSchemes,
423 ]);
424 }
425
426 if ('post.php' === $pagenow || 'post-new.php' === $pagenow) {
427 wp_enqueue_script(
428 'plyr.polyfilled',
429 EMBEDPRESS_URL_ASSETS . 'js/plyr.polyfilled.js',
430 [],
431 $this->pluginVersion,
432 false
433 );
434 wp_enqueue_script(
435 'gutenberg-general',
436 EMBEDPRESS_URL_ASSETS . 'js/gutneberg-script.js',
437 ['wp-data'],
438 $this->pluginVersion,
439 false
440 );
441
442 wp_enqueue_style('plyr', EMBEDPRESS_URL_ASSETS . 'css/plyr.css', array(), $this->pluginVersion);
443 wp_enqueue_style($this->pluginName, EMBEDPRESS_URL_ASSETS . 'css/embedpress.css', array(), $this->pluginVersion);
444
445
446 wp_enqueue_script(
447 'cg-carousel',
448 EMBEDPRESS_URL_ASSETS . 'js/carousel.min.js',
449 ['jquery'],
450 $this->pluginVersion,
451 false
452 );
453 wp_enqueue_script(
454 'init-carousel',
455 EMBEDPRESS_URL_ASSETS . 'js/initCarousel.js',
456 ['jquery', 'cg-carousel'],
457 $this->pluginVersion,
458 false
459 );
460
461 wp_enqueue_style('cg-carousel', EMBEDPRESS_URL_ASSETS . 'css/carousel.min.css', $this->pluginVersion, true);
462
463 wp_enqueue_style($this->pluginName, EMBEDPRESS_URL_ASSETS . 'css/embedpress.css', $this->pluginVersion, true);
464 }
465
466 //load embedpress admin js
467
468 wp_enqueue_script(
469 'embedpress-admin',
470 EMBEDPRESS_URL_ASSETS . 'js/admin.js',
471 ['jquery', 'wp-i18n', 'wp-url'],
472 $this->pluginVersion,
473 true
474 );
475
476 wp_localize_script($this->pluginName, 'EMBEDPRESS_ADMIN_PARAMS', [
477 'ajaxurl' => admin_url('admin-ajax.php'),
478 'nonce' => wp_create_nonce('embedpress')
479 ]);
480
481
482 $installedPlugins = Core::getPlugins();
483 if (count($installedPlugins) > 0) {
484 foreach ($installedPlugins as $plgSlug => $plgNamespace) {
485 $plgScriptPathRelative = "assets/js/embedpress.{$plgSlug}.js";
486 $plgName = "embedpress-{$plgSlug}";
487
488 if (file_exists(WP_PLUGIN_DIR . "/{$plgName}/{$plgScriptPathRelative}")) {
489 wp_enqueue_script(
490 $plgName,
491 plugins_url($plgName) . '/' . $plgScriptPathRelative,
492 [$this->pluginName],
493 $this->pluginVersion,
494 true
495 );
496 }
497 }
498 }
499 }
500
501 public function enqueueLisenceScripts()
502 {
503 wp_enqueue_script(
504 'embedpress-lisence',
505 EMBEDPRESS_URL_ASSETS . 'js/license.js',
506 ['jquery', 'wp-i18n', 'wp-url'],
507 $this->pluginVersion,
508 true
509 );
510
511 wp_localize_script('embedpress-lisence', 'wpdeveloperLicenseManagerNonce', array('embedpress_lisence_nonce' => wp_create_nonce('wpdeveloper_sl_' . EMBEDPRESS_SL_ITEM_ID . '_nonce')));
512 }
513
514
515 /**
516 * Method that register all stylesheets for the admin area.
517 *
518 * @return void
519 * @since 1.0.0
520 * @static
521 *
522 */
523 public static function enqueueStyles()
524 {
525 if (isset($_GET['page']) && 'embedpress' === $_GET['page']) {
526 wp_enqueue_style('embedpress-admin', plugins_url('embedpress/assets/css/admin.css'));
527 }
528 }
529
530 /**
531 * Method that receive a string via AJAX and return the decoded-shortcoded-version of that string.
532 *
533 * @return void
534 * @since 1.0.0
535 *
536 */
537 public function doShortcodeReceivedViaAjax()
538 {
539 $subject = isset($_POST['subject']) ? $_POST['subject'] : "";
540
541 $response = [
542 'data' => Shortcode::parseContent($subject, true),
543 ];
544
545 header('Content-Type:application/json;charset=UTF-8');
546 echo json_encode($response);
547
548 exit();
549 }
550
551 /**
552 * Method that receive an url via AJAX and return the info about that url/embed.
553 *
554 * @return void
555 * @since 1.0.0
556 *
557 */
558 public function getUrlInfoViaAjax()
559 {
560 $url = isset($_GET['url']) ? trim($_GET['url']) : "";
561
562 $response = [
563 'url' => $url,
564 'canBeResponsive' => false,
565 ];
566
567 if (!!strlen($response['url'])) {
568
569 $additionalServiceProviders = Core::getAdditionalServiceProviders();
570 if (!empty($additionalServiceProviders)) {
571 foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) {
572 Shortcode::addServiceProvider($serviceProviderClassName, $serviceProviderUrls);
573 }
574 }
575 $embera = new Embera([], Shortcode::get_collection());
576
577 $urlInfo = $embera->getUrlData($response['url']);
578 if (isset($urlInfo[$response['url']]) && $urlInfo[$response['url']]['provider_name']) {
579 $response['canBeResponsive'] = Core::canServiceProviderBeResponsive(strtolower($urlInfo[$response['url']]['provider_name']));
580 }
581 }
582
583 header('Content-Type:application/json;charset=UTF-8');
584 echo json_encode($response);
585
586 exit();
587 }
588
589 /**
590 * Returns a list of supported URL schemes for the preview script
591 *
592 * @return array
593 */
594 public function getUrlSchemes()
595 {
596 return [
597 // Apple podcasts
598 'podcasts.apple.com/*',
599 // PollDaddy
600 '*.polldaddy.com/s/*',
601 '*.polldaddy.com/poll/*',
602 '*.polldaddy.com/ratings/*',
603 'polldaddy.com/s/*',
604 'polldaddy.com/poll/*',
605 'polldaddy.com/ratings/*',
606
607 // VideoPress
608 'videopress.com/v/*',
609
610 // Tumblr
611 '*.tumblr.com/post/*',
612
613 // SmugMug
614 'smugmug.com/*',
615 '*.smugmug.com/*',
616
617 // SlideShare
618 'slideshare.net/*/*',
619 '*.slideshare.net/*/*',
620
621 // Reddit
622 'reddit.com/r/[^/]+/comments/*',
623
624 // Photobucket
625 'i*.photobucket.com/albums/*',
626 'gi*.photobucket.com/groups/*',
627
628 // Cloudup
629 'cloudup.com/*',
630
631 // Imgur
632 'imgur.com/*',
633 'i.imgur.com/*',
634
635 // YouTube (http://www.youtube.com/)
636 'youtube.com/watch\\?*',
637 'youtube.com/playlist\\?*',
638 'youtube.com/channel/*',
639 'youtube.com/c/*',
640 'youtube.com/user/*',
641 'youtube.com/(\w+)[^?\/]*$',
642
643 // opensea
644 'opensea.io/collection/*',
645
646 // Flickr (http://www.flickr.com/)
647 'flickr.com/photos/*/*',
648 'flic.kr/p/*',
649
650 // Viddler (http://www.viddler.com/)
651 'viddler.com/v/*',
652
653 // Hulu (http://www.hulu.com/)
654 'hulu.com/watch/*',
655
656 // Vimeo (http://vimeo.com/)
657 'vimeo.com/*',
658 'vimeo.com/groups/*/videos/*',
659
660 // CollegeHumor (http://www.collegehumor.com/)
661 'collegehumor.com/video/*',
662
663 // Deviantart.com (http://www.deviantart.com)
664 '*.deviantart.com/art/*',
665 '*.deviantart.com/*#/d*',
666 'fav.me/*',
667 'sta.sh/*',
668
669 // SlideShare (http://www.slideshare.net/)
670
671 // chirbit.com (http://www.chirbit.com/)
672 'chirb.it/*',
673
674 // nfb.ca (http://www.nfb.ca/)
675 '*.nfb.ca/film/*',
676
677 // Scribd (http://www.scribd.com/)
678 '*.scribd.com/doc/*',
679 '*.scribd.com/document/*',
680
681 // Dotsub (http://dotsub.com/)
682 'dotsub.com/view/*',
683
684 // Animoto (http://animoto.com/)
685 'animoto.com/play/*',
686
687 // Rdio (http://rdio.com/)
688 '*.rdio.com/artist/*',
689 '*.rdio.com/people/*',
690
691 // MixCloud (http://mixcloud.com/)
692 'mixcloud.com/*/*/',
693
694 // FunnyOrDie (http://www.funnyordie.com/)
695 'funnyordie.com/videos/*',
696
697 // Ted (http://ted.com)
698 'ted.com/talks/*',
699
700 // Sapo Videos (http://videos.sapo.pt)
701 'videos.sapo.pt/*',
702
703 // Official FM (http://official.fm)
704 'official.fm/tracks/*',
705 'official.fm/playlists/*',
706
707 // HuffDuffer (http://huffduffer.com)
708 'huffduffer.com/*/*',
709
710 // Shoudio (http://shoudio.com)
711 'shoudio.com/*',
712 'shoud.io/*',
713
714 // Moby Picture (http://www.mobypicture.com)
715 'mobypicture.com/user/*/view/*',
716 'moby.to/*',
717
718 // 23HQ (http://www.23hq.com)
719 '23hq.com/*/photo/*',
720
721 // Cacoo (https://cacoo.com)
722 'cacoo.com/diagrams/*',
723
724 // Dipity (http://www.dipity.com)
725 'dipity.com/*/*/',
726
727 // Roomshare (http://roomshare.jp)
728 'roomshare.jp/post/*',
729 'roomshare.jp/en/post/*',
730
731 // Dailymotion (http://www.dailymotion.com)
732 'dailymotion.com/video/*',
733
734 // Crowd Ranking (http://crowdranking.com)
735 'c9ng.com/*/*',
736
737 // CircuitLab (https://www.circuitlab.com/)
738 'circuitlab.com/circuit/*',
739
740 // Coub (http://coub.com/)
741 'coub.com/view/*',
742 'coub.com/embed/*',
743
744 // SpeakerDeck (https://speakerdeck.com)
745 'speakerdeck.com/*/*',
746
747 // Instagram (https://instagram.com)
748 'instagram.com/p/*',
749 'instagr.am/p/*',
750
751 // SoundCloud (http://soundcloud.com/)
752 'soundcloud.com/*',
753
754 // Kickstarter (http://www.kickstarter.com)
755 'kickstarter.com/projects/*',
756
757 // Ustream (http://www.ustream.tv)
758 '*.ustream.tv/*',
759 '*.ustream.com/*',
760
761 // Daily Mile (http://www.dailymile.com)
762 'dailymile.com/people/*/entries/*',
763
764 // Sketchfab (http://sketchfab.com)
765 'sketchfab.com/models/*',
766 'sketchfab.com/*/folders/*',
767
768 // Meetup (http://www.meetup.com)
769 'meetup.com/*',
770 'meetu.ps/*',
771
772 // AudioSnaps (http://audiosnaps.com)
773 'audiosnaps.com/k/*',
774
775 // RapidEngage (https://rapidengage.com)
776 'rapidengage.com/s/*',
777
778 // Getty Images (http://www.gettyimages.com/)
779 'gty.im/*',
780 'gettyimages.com/detail/photo/*',
781
782 // amCharts Live Editor (http://live.amcharts.com/)
783 'live.amcharts.com/*',
784
785 // Infogram (https://infogr.am/)
786 'infogr.am/*',
787 'infogram.com/*',
788
789 // ChartBlocks (http://www.chartblocks.com/)
790 'public.chartblocks.com/c/*',
791
792 // ReleaseWire (http://www.releasewire.com/)
793 'rwire.com/*',
794
795 // ShortNote (https://www.shortnote.jp/)
796 'shortnote.jp/view/notes/*',
797
798 // EgliseInfo (http://egliseinfo.catholique.fr/)
799 'egliseinfo.catholique.fr/*',
800
801 // Silk (http://www.silk.co/)
802 '*.silk.co/explore/*',
803 '*.silk.co/s/embed/*',
804
805 // Twitter
806 'twitter.com/*/status/*',
807 'twitter.com/i/moments/*',
808 'twitter.com/*/timelines/*',
809
810 // http://bambuser.com
811 'bambuser.com/v/*',
812
813 // https://clyp.it
814 'clyp.it/*',
815
816 // https://gist.github.com
817 'gist.github.com/*/*',
818
819 // http://issuu.com
820 'issuu.com/*',
821
822 // https://portfolium.com
823 'portfolium.com/*',
824
825 // https://www.reverbnation.com
826 'reverbnation.com/*',
827
828 // http://rutube.ru
829 'rutube.ru/video/*',
830
831 // https://spotify.com/
832 'open.spotify.com/*',
833
834 // http://www.videojug.com
835 'videojug.com/*',
836
837 // https://vine.com
838 'vine.co/v/*',
839
840 // Facebook
841 'facebook.com/*',
842 'fb.watch/*',
843
844 // Google Shortened Url
845 'goo.gl/*',
846
847 // Google Maps
848 'google.com/*',
849 'google.com.*/*',
850 'google.co.*/*',
851 'maps.google.com/*',
852
853 // Google Docs
854 'docs.google.com/presentation/*',
855 'docs.google.com/document/*',
856 'docs.google.com/spreadsheets/*',
857 'docs.google.com/forms/*',
858 'docs.google.com/drawings/*',
859
860 // Twitch.tv
861 '*.twitch.tv/*',
862 'twitch.tv/*',
863
864 // Giphy
865 '*.giphy.com/gifs/*',
866 'giphy.com/gifs/*',
867 'i.giphy.com/*',
868 'gph.is/*',
869
870 // Wistia
871 '*.wistia.com/medias/*',
872 'fast.wistia.com/embed/medias/*.jsonp',
873 // Boomplay (http://boomplay.com/)
874 'boomplay.com/*',
875 'codepen.io/*',
876 'archivos.digital/*',
877 'audioclip.naver.com/*',
878 'app.blogcast.host/*',
879 'codepoints.net/*',
880 'codesandbox.io/*',
881 'commaful.com/*',
882 '*.survey.fm/*',
883 'survey.fm/*',
884 'datawrapper.dwcdn.net/*',
885 '*.didacte.com/*',
886 'didacte.com/*',
887 'digiteka.com/*',
888 'docdro.id/*',
889 'edumedia-sciences.com/*',
890 'ethfiddle.com/*',
891 'eyrie.io/*',
892 '*.getfader.com/*',
893 'getfader.com/*',
894 'fitapp.pro/*',
895 'fite.tv/*',
896 'public.flourish.studio/*',
897 'geograph.org.gg/*',
898 'geo-en.hlipp.de/*',
899 'geograph.org.uk/*',
900 'fortest.getshow.io/*',
901 'opensea.io/assets/*',
902 ];
903 }
904
905 public function delete_instagram_account()
906 {
907 if (isset($_POST['_nonce']) && wp_verify_nonce($_POST['_nonce'], 'embedpress_elements_action')) {
908 $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : '';
909 $account_type = isset($_POST['account_type']) ? $_POST['account_type'] : '';
910 $account_data = get_option('ep_instagram_account_data');
911
912 $data = array_filter($account_data, function ($item) use ($user_id) {
913 return $item['user_id'] !== $user_id;
914 });
915 $data = array_values($data);
916 update_option('ep_instagram_account_data', $data);
917 } else {
918 wp_die('Nonce verification failed.');
919 }
920 }
921
922
923
924 /**
925 * Update admin notice view status
926 *
927 * @since 2.5.1
928 */
929 public static function embedpress_notice_dismiss()
930 {
931 check_ajax_referer('embedpress', 'security');
932 update_option('embedpress_social_dismiss_notice', true);
933 }
934 }
935