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