Handler.php
838 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 | |
| 43 | if (!empty($_GET['page_type']) && $_GET['page_type'] == 'calendly') { |
| 44 | add_action('init', [$this, 'handle_calendly_data']); |
| 45 | } |
| 46 | |
| 47 | if (defined('EMBEDPRESS_SL_ITEM_SLUG') && is_admin()) { |
| 48 | add_action('admin_enqueue_scripts', [$this, 'enqueueLisenceScripts']); |
| 49 | } |
| 50 | |
| 51 | add_action('wp_ajax_sync_instagram_data_ajax', [$this, 'sync_instagram_data_ajax']); |
| 52 | add_action('wp_ajax_nopriv_sync_instagram_data_ajax', [$this, 'sync_instagram_data_ajax']); |
| 53 | |
| 54 | |
| 55 | } |
| 56 | |
| 57 | |
| 58 | public function get_instagram_userdata_ajax() |
| 59 | { |
| 60 | |
| 61 | if (!current_user_can('manage_options')) { |
| 62 | wp_send_json_error(array('message' => 'You do not have sufficient permissions to access this functionality.')); |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | if (isset($_POST['_nonce']) && wp_verify_nonce($_POST['_nonce'], 'embedpress_elements_action')) { |
| 67 | if (isset($_POST['access_token'])) { |
| 68 | $access_token = sanitize_text_field($_POST['access_token']); |
| 69 | $account_type = sanitize_text_field($_POST['account_type']); |
| 70 | |
| 71 | $user_data = $this->get_instagram_userdata($access_token, $account_type); |
| 72 | |
| 73 | $this->handle_instagram_data($user_data); |
| 74 | |
| 75 | $access_token = sanitize_text_field($_POST['access_token']); |
| 76 | $account_type = sanitize_text_field($_POST['account_type']); |
| 77 | $user_id = $this->get_instagram_userid($access_token, $account_type); |
| 78 | |
| 79 | $option_key = 'ep_instagram_feed_data'; |
| 80 | $feed_data = get_option($option_key, array()); |
| 81 | |
| 82 | $feed_userinfo = Helper::getInstagramUserInfo($access_token, $account_type, $user_id, true); |
| 83 | $feed_posts = Helper::getInstagramPosts($access_token, $account_type, $user_id, 100, true); |
| 84 | |
| 85 | if (!empty($user_id)) { |
| 86 | $feed_data[$user_id] = [ |
| 87 | 'feed_userinfo' => $feed_userinfo, |
| 88 | 'feed_posts' => $feed_posts, |
| 89 | ]; |
| 90 | |
| 91 | delete_transient('instagram_user_info_' . $user_id); |
| 92 | delete_transient('instagram_posts_' . $user_id); |
| 93 | update_option('ep_instagram_feed_data', $feed_data); |
| 94 | } else { |
| 95 | $feed_data['error'] = "Access token Invalid or expired."; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | wp_send_json($feed_data); |
| 100 | } else { |
| 101 | wp_send_json_error('Access token not provided'); |
| 102 | } |
| 103 | } else { |
| 104 | wp_send_json_error('Nonce verification failed'); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | public function sync_instagram_data_ajax() |
| 109 | { |
| 110 | if (!current_user_can('manage_options')) { |
| 111 | wp_send_json_error(array('message' => 'You do not have sufficient permissions to access this functionality.')); |
| 112 | return; |
| 113 | } |
| 114 | |
| 115 | if (isset($_POST['_nonce']) && wp_verify_nonce($_POST['_nonce'], 'embedpress_elements_action')) { |
| 116 | if (isset($_POST['access_token'])) { |
| 117 | |
| 118 | $access_token = sanitize_text_field($_POST['access_token']); |
| 119 | $account_type = sanitize_text_field($_POST['account_type']); |
| 120 | $user_id = sanitize_text_field($_POST['user_id']); |
| 121 | |
| 122 | $option_key = 'ep_instagram_feed_data'; |
| 123 | $feed_data = get_option($option_key, array()); |
| 124 | |
| 125 | $feed_userinfo = Helper::getInstagramUserInfo($access_token, $account_type, $user_id, true); |
| 126 | $feed_posts = Helper::getInstagramPosts($access_token, $account_type, $user_id, 100, true); |
| 127 | |
| 128 | $feed_data[$user_id] = [ |
| 129 | 'feed_userinfo' => $feed_userinfo, |
| 130 | 'feed_posts' => $feed_posts, |
| 131 | ]; |
| 132 | |
| 133 | delete_transient('instagram_user_info_' . $user_id); |
| 134 | delete_transient('instagram_posts_' . $user_id); |
| 135 | update_option('ep_instagram_feed_data', $feed_data); |
| 136 | |
| 137 | |
| 138 | wp_send_json($feed_data); |
| 139 | } else { |
| 140 | wp_send_json_error('Access token not provided'); |
| 141 | } |
| 142 | } else { |
| 143 | wp_send_json_error('Nonce verification failed'); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | |
| 148 | public function get_instagram_userid($access_token) |
| 149 | { |
| 150 | $response = "https://graph.facebook.com/v19.0/me/accounts?fields=connected_instagram_account{id}&access_token=$access_token"; |
| 151 | if (!is_wp_error($response)) { |
| 152 | |
| 153 | $body = wp_remote_retrieve_body($response); |
| 154 | $data = json_decode($body, true); |
| 155 | |
| 156 | // Extract the connected Instagram account ID |
| 157 | if (isset($data['data'][0]['connected_instagram_account']['id'])) { |
| 158 | return $data['data'][0]['connected_instagram_account']['id']; |
| 159 | } else { |
| 160 | return ''; |
| 161 | } |
| 162 | } else { |
| 163 | $user_data['error'] = "Error: Unable to connect to Instagram API."; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | public function get_instagram_profile_picture($access_token, $userid) {} |
| 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 | wp_redirect(admin_url('admin.php?page=embedpress&page_type=calendly'), 302); |
| 397 | exit(); |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | public function enqueueScripts() |
| 402 | { |
| 403 | // Assets and localization are now handled by AssetManager and LocalizationManager |
| 404 | // This method is kept for backward compatibility but functionality has been moved |
| 405 | } |
| 406 | |
| 407 | public function enqueueLisenceScripts() |
| 408 | { |
| 409 | // Assets and localization are now handled by AssetManager and LocalizationManager |
| 410 | // This method is kept for backward compatibility but functionality has been moved |
| 411 | } |
| 412 | |
| 413 | |
| 414 | /** |
| 415 | * Method that register all stylesheets for the admin area. |
| 416 | * |
| 417 | * @return void |
| 418 | * @since 1.0.0 |
| 419 | * @static |
| 420 | * |
| 421 | */ |
| 422 | public static function enqueueStyles() |
| 423 | { |
| 424 | // Assets are now handled by AssetManager |
| 425 | // This method is kept for backward compatibility |
| 426 | } |
| 427 | |
| 428 | /** |
| 429 | * Method that receive a string via AJAX and return the decoded-shortcoded-version of that string. |
| 430 | * |
| 431 | * @return void |
| 432 | * @since 1.0.0 |
| 433 | * |
| 434 | */ |
| 435 | public function doShortcodeReceivedViaAjax() |
| 436 | { |
| 437 | $subject = isset($_POST['subject']) ? $_POST['subject'] : ""; |
| 438 | |
| 439 | $response = [ |
| 440 | 'data' => Shortcode::parseContent($subject, true), |
| 441 | ]; |
| 442 | |
| 443 | header('Content-Type:application/json;charset=UTF-8'); |
| 444 | echo json_encode($response); |
| 445 | |
| 446 | exit(); |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * Method that receive an url via AJAX and return the info about that url/embed. |
| 451 | * |
| 452 | * @return void |
| 453 | * @since 1.0.0 |
| 454 | * |
| 455 | */ |
| 456 | public function getUrlInfoViaAjax() |
| 457 | { |
| 458 | $url = isset($_GET['url']) ? trim($_GET['url']) : ""; |
| 459 | |
| 460 | $response = [ |
| 461 | 'url' => $url, |
| 462 | 'canBeResponsive' => false, |
| 463 | ]; |
| 464 | |
| 465 | if (!!strlen($response['url'])) { |
| 466 | |
| 467 | $additionalServiceProviders = Core::getAdditionalServiceProviders(); |
| 468 | if (!empty($additionalServiceProviders)) { |
| 469 | foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) { |
| 470 | Shortcode::addServiceProvider($serviceProviderClassName, $serviceProviderUrls); |
| 471 | } |
| 472 | } |
| 473 | $embera = new Embera([], Shortcode::get_collection()); |
| 474 | |
| 475 | $urlInfo = $embera->getUrlData($response['url']); |
| 476 | if (isset($urlInfo[$response['url']]) && $urlInfo[$response['url']]['provider_name']) { |
| 477 | $response['canBeResponsive'] = Core::canServiceProviderBeResponsive(strtolower($urlInfo[$response['url']]['provider_name'])); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | header('Content-Type:application/json;charset=UTF-8'); |
| 482 | echo json_encode($response); |
| 483 | |
| 484 | exit(); |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * Returns a list of supported URL schemes for the preview script |
| 489 | * |
| 490 | * @return array |
| 491 | */ |
| 492 | public function getUrlSchemes() |
| 493 | { |
| 494 | return [ |
| 495 | // Apple podcasts |
| 496 | 'podcasts.apple.com/*', |
| 497 | // PollDaddy |
| 498 | '*.polldaddy.com/s/*', |
| 499 | '*.polldaddy.com/poll/*', |
| 500 | '*.polldaddy.com/ratings/*', |
| 501 | 'polldaddy.com/s/*', |
| 502 | 'polldaddy.com/poll/*', |
| 503 | 'polldaddy.com/ratings/*', |
| 504 | |
| 505 | // VideoPress |
| 506 | 'videopress.com/v/*', |
| 507 | |
| 508 | // Tumblr |
| 509 | '*.tumblr.com/post/*', |
| 510 | |
| 511 | // SmugMug |
| 512 | 'smugmug.com/*', |
| 513 | '*.smugmug.com/*', |
| 514 | |
| 515 | // SlideShare |
| 516 | 'slideshare.net/*/*', |
| 517 | '*.slideshare.net/*/*', |
| 518 | |
| 519 | |
| 520 | 'reddit.com/r/[^/]+/comments/*', |
| 521 | |
| 522 | // Photobucket |
| 523 | 'i*.photobucket.com/albums/*', |
| 524 | 'gi*.photobucket.com/groups/*', |
| 525 | |
| 526 | // Cloudup |
| 527 | 'cloudup.com/*', |
| 528 | |
| 529 | // Imgur |
| 530 | 'imgur.com/*', |
| 531 | 'i.imgur.com/*', |
| 532 | |
| 533 | // YouTube (http://www.youtube.com/) |
| 534 | 'youtube.com/watch\\?*', |
| 535 | 'youtube.com/playlist\\?*', |
| 536 | 'youtube.com/channel/*', |
| 537 | 'youtube.com/c/*', |
| 538 | 'youtube.com/user/*', |
| 539 | 'youtube.com/(\w+)[^?\/]*$', |
| 540 | |
| 541 | // opensea |
| 542 | 'opensea.io/collection/*', |
| 543 | |
| 544 | // Flickr (http://www.flickr.com/) |
| 545 | 'flickr.com/photos/*/*', |
| 546 | 'flic.kr/p/*', |
| 547 | |
| 548 | // Viddler (http://www.viddler.com/) |
| 549 | 'viddler.com/v/*', |
| 550 | |
| 551 | // Hulu (http://www.hulu.com/) |
| 552 | 'hulu.com/watch/*', |
| 553 | |
| 554 | // Vimeo (http://vimeo.com/) |
| 555 | 'vimeo.com/*', |
| 556 | 'vimeo.com/groups/*/videos/*', |
| 557 | |
| 558 | // CollegeHumor (http://www.collegehumor.com/) |
| 559 | 'collegehumor.com/video/*', |
| 560 | |
| 561 | // Deviantart.com (http://www.deviantart.com) |
| 562 | '*.deviantart.com/art/*', |
| 563 | '*.deviantart.com/*#/d*', |
| 564 | 'fav.me/*', |
| 565 | 'sta.sh/*', |
| 566 | |
| 567 | // SlideShare (http://www.slideshare.net/) |
| 568 | |
| 569 | // chirbit.com (http://www.chirbit.com/) |
| 570 | 'chirb.it/*', |
| 571 | |
| 572 | // nfb.ca (http://www.nfb.ca/) |
| 573 | '*.nfb.ca/film/*', |
| 574 | |
| 575 | // Scribd (http://www.scribd.com/) |
| 576 | '*.scribd.com/doc/*', |
| 577 | '*.scribd.com/document/*', |
| 578 | |
| 579 | // Dotsub (http://dotsub.com/) |
| 580 | 'dotsub.com/view/*', |
| 581 | |
| 582 | // Animoto (http://animoto.com/) |
| 583 | 'animoto.com/play/*', |
| 584 | |
| 585 | // Rdio (http://rdio.com/) |
| 586 | '*.rdio.com/artist/*', |
| 587 | '*.rdio.com/people/*', |
| 588 | |
| 589 | // MixCloud (http://mixcloud.com/) |
| 590 | 'mixcloud.com/*/*/', |
| 591 | |
| 592 | // FunnyOrDie (http://www.funnyordie.com/) |
| 593 | 'funnyordie.com/videos/*', |
| 594 | |
| 595 | // Ted (http://ted.com) |
| 596 | 'ted.com/talks/*', |
| 597 | |
| 598 | // Sapo Videos (http://videos.sapo.pt) |
| 599 | 'videos.sapo.pt/*', |
| 600 | |
| 601 | // Official FM (http://official.fm) |
| 602 | 'official.fm/tracks/*', |
| 603 | 'official.fm/playlists/*', |
| 604 | |
| 605 | // HuffDuffer (http://huffduffer.com) |
| 606 | 'huffduffer.com/*/*', |
| 607 | |
| 608 | // Shoudio (http://shoudio.com) |
| 609 | 'shoudio.com/*', |
| 610 | 'shoud.io/*', |
| 611 | |
| 612 | // Moby Picture (http://www.mobypicture.com) |
| 613 | 'mobypicture.com/user/*/view/*', |
| 614 | 'moby.to/*', |
| 615 | |
| 616 | // 23HQ (http://www.23hq.com) |
| 617 | '23hq.com/*/photo/*', |
| 618 | |
| 619 | // Cacoo (https://cacoo.com) |
| 620 | 'cacoo.com/diagrams/*', |
| 621 | |
| 622 | // Dipity (http://www.dipity.com) |
| 623 | 'dipity.com/*/*/', |
| 624 | |
| 625 | // Roomshare (http://roomshare.jp) |
| 626 | 'roomshare.jp/post/*', |
| 627 | 'roomshare.jp/en/post/*', |
| 628 | |
| 629 | // Dailymotion (http://www.dailymotion.com) |
| 630 | 'dailymotion.com/video/*', |
| 631 | |
| 632 | // Crowd Ranking (http://crowdranking.com) |
| 633 | 'c9ng.com/*/*', |
| 634 | |
| 635 | // CircuitLab (https://www.circuitlab.com/) |
| 636 | 'circuitlab.com/circuit/*', |
| 637 | |
| 638 | // Coub (http://coub.com/) |
| 639 | 'coub.com/view/*', |
| 640 | 'coub.com/embed/*', |
| 641 | |
| 642 | // SpeakerDeck (https://speakerdeck.com) |
| 643 | 'speakerdeck.com/*/*', |
| 644 | |
| 645 | // Instagram (https://instagram.com) |
| 646 | 'instagram.com/p/*', |
| 647 | 'instagr.am/p/*', |
| 648 | |
| 649 | // SoundCloud (http://soundcloud.com/) |
| 650 | 'soundcloud.com/*', |
| 651 | |
| 652 | // Kickstarter (http://www.kickstarter.com) |
| 653 | 'kickstarter.com/projects/*', |
| 654 | |
| 655 | // Ustream (http://www.ustream.tv) |
| 656 | '*.ustream.tv/*', |
| 657 | '*.ustream.com/*', |
| 658 | |
| 659 | // Daily Mile (http://www.dailymile.com) |
| 660 | 'dailymile.com/people/*/entries/*', |
| 661 | |
| 662 | // Sketchfab (http://sketchfab.com) |
| 663 | 'sketchfab.com/models/*', |
| 664 | 'sketchfab.com/*/folders/*', |
| 665 | |
| 666 | // Meetup (http://www.meetup.com) |
| 667 | 'meetup.com/*', |
| 668 | 'meetu.ps/*', |
| 669 | |
| 670 | // AudioSnaps (http://audiosnaps.com) |
| 671 | 'audiosnaps.com/k/*', |
| 672 | |
| 673 | // RapidEngage (https://rapidengage.com) |
| 674 | 'rapidengage.com/s/*', |
| 675 | |
| 676 | // Getty Images (http://www.gettyimages.com/) |
| 677 | 'gty.im/*', |
| 678 | 'gettyimages.com/detail/photo/*', |
| 679 | |
| 680 | // amCharts Live Editor (http://live.amcharts.com/) |
| 681 | 'live.amcharts.com/*', |
| 682 | |
| 683 | // Infogram (https://infogr.am/) |
| 684 | 'infogr.am/*', |
| 685 | 'infogram.com/*', |
| 686 | |
| 687 | // ChartBlocks (http://www.chartblocks.com/) |
| 688 | 'public.chartblocks.com/c/*', |
| 689 | |
| 690 | // ReleaseWire (http://www.releasewire.com/) |
| 691 | 'rwire.com/*', |
| 692 | |
| 693 | // ShortNote (https://www.shortnote.jp/) |
| 694 | 'shortnote.jp/view/notes/*', |
| 695 | |
| 696 | // EgliseInfo (http://egliseinfo.catholique.fr/) |
| 697 | 'egliseinfo.catholique.fr/*', |
| 698 | |
| 699 | // Silk (http://www.silk.co/) |
| 700 | '*.silk.co/explore/*', |
| 701 | '*.silk.co/s/embed/*', |
| 702 | |
| 703 | |
| 704 | 'twitter.com/*/status/*', |
| 705 | 'twitter.com/i/moments/*', |
| 706 | 'twitter.com/*/timelines/*', |
| 707 | |
| 708 | // http://bambuser.com |
| 709 | 'bambuser.com/v/*', |
| 710 | |
| 711 | // https://clyp.it |
| 712 | 'clyp.it/*', |
| 713 | |
| 714 | // https://gist.github.com |
| 715 | 'gist.github.com/*/*', |
| 716 | |
| 717 | // http://issuu.com |
| 718 | 'issuu.com/*', |
| 719 | |
| 720 | // https://portfolium.com |
| 721 | 'portfolium.com/*', |
| 722 | |
| 723 | // https://www.reverbnation.com |
| 724 | 'reverbnation.com/*', |
| 725 | |
| 726 | // http://rutube.ru |
| 727 | 'rutube.ru/video/*', |
| 728 | |
| 729 | // https://spotify.com/ |
| 730 | 'open.spotify.com/*', |
| 731 | |
| 732 | // http://www.videojug.com |
| 733 | 'videojug.com/*', |
| 734 | |
| 735 | // https://vine.com |
| 736 | 'vine.co/v/*', |
| 737 | |
| 738 | |
| 739 | 'facebook.com/*', |
| 740 | 'fb.watch/*', |
| 741 | |
| 742 | // Google Shortened Url |
| 743 | 'goo.gl/*', |
| 744 | |
| 745 | // Google Maps |
| 746 | 'google.com/*', |
| 747 | 'google.com.*/*', |
| 748 | 'google.co.*/*', |
| 749 | 'maps.google.com/*', |
| 750 | |
| 751 | // Google Docs |
| 752 | 'docs.google.com/presentation/*', |
| 753 | 'docs.google.com/document/*', |
| 754 | 'docs.google.com/spreadsheets/*', |
| 755 | 'docs.google.com/forms/*', |
| 756 | 'docs.google.com/drawings/*', |
| 757 | |
| 758 | // Twitch.tv |
| 759 | '*.twitch.tv/*', |
| 760 | 'twitch.tv/*', |
| 761 | |
| 762 | // Giphy |
| 763 | '*.giphy.com/gifs/*', |
| 764 | 'giphy.com/gifs/*', |
| 765 | 'i.giphy.com/*', |
| 766 | 'gph.is/*', |
| 767 | |
| 768 | // Wistia |
| 769 | '*.wistia.com/medias/*', |
| 770 | 'fast.wistia.com/embed/medias/*.jsonp', |
| 771 | // Boomplay (http://boomplay.com/) |
| 772 | 'boomplay.com/*', |
| 773 | 'codepen.io/*', |
| 774 | 'archivos.digital/*', |
| 775 | 'audioclip.naver.com/*', |
| 776 | 'app.blogcast.host/*', |
| 777 | 'codepoints.net/*', |
| 778 | 'codesandbox.io/*', |
| 779 | 'commaful.com/*', |
| 780 | '*.survey.fm/*', |
| 781 | 'survey.fm/*', |
| 782 | 'datawrapper.dwcdn.net/*', |
| 783 | '*.didacte.com/*', |
| 784 | 'didacte.com/*', |
| 785 | 'digiteka.com/*', |
| 786 | 'docdro.id/*', |
| 787 | 'edumedia-sciences.com/*', |
| 788 | 'ethfiddle.com/*', |
| 789 | 'eyrie.io/*', |
| 790 | '*.getfader.com/*', |
| 791 | 'getfader.com/*', |
| 792 | 'fitapp.pro/*', |
| 793 | 'fite.tv/*', |
| 794 | 'public.flourish.studio/*', |
| 795 | 'geograph.org.gg/*', |
| 796 | 'geo-en.hlipp.de/*', |
| 797 | 'geograph.org.uk/*', |
| 798 | 'fortest.getshow.io/*', |
| 799 | 'opensea.io/assets/*', |
| 800 | ]; |
| 801 | } |
| 802 | |
| 803 | public function delete_instagram_account() |
| 804 | { |
| 805 | if (!current_user_can('manage_options')) { |
| 806 | wp_send_json_error(array('message' => 'You do not have sufficient permissions to access this functionality.')); |
| 807 | return; |
| 808 | } |
| 809 | |
| 810 | if (isset($_POST['_nonce']) && wp_verify_nonce($_POST['_nonce'], 'embedpress_elements_action')) { |
| 811 | $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : ''; |
| 812 | $account_type = isset($_POST['account_type']) ? $_POST['account_type'] : ''; |
| 813 | $account_data = get_option('ep_instagram_account_data'); |
| 814 | |
| 815 | $data = array_filter($account_data, function ($item) use ($user_id) { |
| 816 | return $item['user_id'] !== $user_id; |
| 817 | }); |
| 818 | $data = array_values($data); |
| 819 | update_option('ep_instagram_account_data', $data); |
| 820 | } else { |
| 821 | wp_die('Nonce verification failed.'); |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | |
| 826 | |
| 827 | /** |
| 828 | * Update admin notice view status |
| 829 | * |
| 830 | * @since 2.5.1 |
| 831 | */ |
| 832 | public static function embedpress_notice_dismiss() |
| 833 | { |
| 834 | check_ajax_referer('embedpress', 'security'); |
| 835 | update_option('embedpress_social_dismiss_notice', true); |
| 836 | } |
| 837 | } |
| 838 |