| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Tagembed Widget |
| 4 | 4 | * Plugin URI: https://tagembed.com/ |
| 5 | 5 | * Description: Display Facebook feed, Instagram feed, Twitter feed, YouTube Videos and more social feeds from 15+ social networks on any page, posts or widgets using shortcode. Beautifully clean, customizable, and responsive Social Media Feed Widget Plugin for WordPress. |
| 6 | - * Version: 4.6 | |
| 6 | + * Version: 4.5 | |
| 7 | 7 | * Author: Tagembed |
| 8 | 8 | * Author URI: https://tagembed.com/ |
| 9 | 9 | */ |
| 10 | 10 | if (!defined('WPINC')) |
| @@ -9,15 +9,13 @@ | ||
| 9 | 9 | */ |
| 10 | 10 | if (!defined('WPINC')) |
| 11 | 11 | die; |
| 12 | 12 | /* --Start-- Create Constant */ |
| 13 | -!defined('TAGEMBED_PLUGIN_VERSION') && define('TAGEMBED_PLUGIN_VERSION', '4.6'); | |
| 13 | +!defined('TAGEMBED_PLUGIN_VERSION') && define('TAGEMBED_PLUGIN_VERSION', '4.5'); | |
| 14 | 14 | !defined('TAGEMBED_PLUGIN_DIR_PATH') && define('TAGEMBED_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__)); |
| 15 | 15 | !defined('TAGEMBED_PLUGIN_URL') && define('TAGEMBED_PLUGIN_URL', plugin_dir_url(__FILE__)); |
| 16 | 16 | !defined('TAGEMBED_PLUGIN_REDIRECT_URL') && define('TAGEMBED_PLUGIN_REDIRECT_URL', get_admin_url(null, 'admin.php?page=')); |
| 17 | 17 | !defined('TAGEMBED_PLUGIN_API_URL') && define('TAGEMBED_PLUGIN_API_URL', "https://api.tagembed.com/app/"); |
| 18 | -!defined('TAGEMBED_PLUGIN_SERVER_URL') && define('TAGEMBED_PLUGIN_SERVER_URL', "https://api.tagembed.com/app/"); | |
| 19 | -!defined('TAGEMBED_PLUGIN_REACT_URL') && define('TAGEMBED_PLUGIN_REACT_URL', "https://widget.tagembed.com/"); | |
| 20 | 18 | !defined('TAGEMBED_PLUGIN_CALL_BACK_URL') && define('TAGEMBED_PLUGIN_CALL_BACK_URL', admin_url() . "admin.php?page=tagembed"); |
| 21 | 19 | /* --End-- Create Constant */ |
| 22 | 20 | /* --Start--Include Files */ |
| 23 | 21 | include_once TAGEMBED_PLUGIN_DIR_PATH . "helper/helper.php"; |
| @@ -23,9 +21,9 @@ | ||
| 23 | 21 | include_once TAGEMBED_PLUGIN_DIR_PATH . "helper/helper.php"; |
| 24 | 22 | /* --End--Include Files */ |
| 25 | 23 | /* --Start-- Add Js And Css */ |
| 26 | 24 | function tagembed_plugin_scripts_css() { |
| 27 | - wp_enqueue_script('__tagembed__embbedJs', TAGEMBED_PLUGIN_REACT_URL . 'embed.min.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 25 | + wp_enqueue_script('__tagembed__embbedJs', 'https://widget.tagembed.com/embed.min.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 28 | 26 | if (is_admin()): |
| 29 | 27 | /* CSS */ |
| 30 | 28 | wp_enqueue_style('__tagembed__commonCss', TAGEMBED_PLUGIN_URL . '/assets/css/common.css', '', TAGEMBED_PLUGIN_VERSION); |
| 31 | 29 | wp_enqueue_style('__tagembed__toastCss', TAGEMBED_PLUGIN_URL . '/assets/css/toast.css', '', TAGEMBED_PLUGIN_VERSION); |
| @@ -91,9 +89,9 @@ | ||
| 91 | 89 | /* --Start-- Manage Ajax Calls */ |
| 92 | 90 | add_action("wp_ajax_data", "__tagembed__dataAjaxHandler"); |
| 93 | 91 | function __tagembed__dataAjaxHandler() { |
| 94 | 92 | if (empty($_REQUEST['__tagembed__ajax_action'])) |
| 95 | - return false; | |
| 93 | + return FALSE; | |
| 96 | 94 | $data = __tagembed__sanitizeRequestData($_REQUEST); |
| 97 | 95 | $data = (object) $data; |
| 98 | 96 | /* --Start__ Sanetize All Input */ |
| 99 | 97 | foreach ($data as $key => $value): |
| @@ -113,9 +111,9 @@ | ||
| 113 | 111 | $param['fullName'] = sanitize_text_field($data->fullName); |
| 114 | 112 | $param['emailId'] = sanitize_email($data->emailId); |
| 115 | 113 | $param['password'] = $data->password; |
| 116 | 114 | /* --End-- Manage Param Data */ |
| 117 | - $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/register', $param, []); | |
| 115 | + $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/register', $param); | |
| 118 | 116 | $response = __tagembed__manageApiResponse($response); |
| 119 | 117 | unset($param); |
| 120 | 118 | $param = ['userId' => sanitize_key($response->userId)]; |
| 121 | 119 | __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $response->accessToken]); |
| @@ -387,20 +385,8 @@ | ||
| 387 | 385 | unset($param); |
| 388 | 386 | $response = __tagembed__manageApiResponse($response); |
| 389 | 387 | return __tagembed__exitWithSuccess($response); |
| 390 | 388 | break; |
| 391 | - case "__tagembed__get_slack_channel_list": | |
| 392 | - if (empty($data->connectedAccountsId)) | |
| 393 | - return __tagembed__exitWithDanger(); | |
| 394 | - /* --Start-- Manage Param Data */ | |
| 395 | - $param['connectedAccountsId'] = $data->connectedAccountsId; | |
| 396 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 397 | - /* --End-- Manage Param Data */ | |
| 398 | - $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getslackchannellist', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 399 | - unset($param); | |
| 400 | - $response = __tagembed__manageApiResponse($response); | |
| 401 | - return __tagembed__exitWithSuccess($response); | |
| 402 | - break; | |
| 403 | 389 | case "__tagembed__get_feed": |
| 404 | 390 | if (empty($__tagembed__user_details) || empty($data->widgetId)) |
| 405 | 391 | return __tagembed__exitWithDanger(); |
| 406 | 392 | /* --Start-- Manage Param Data */ |
| @@ -531,16 +517,8 @@ | ||
| 531 | 517 | unset($data->youtubePlaylist); |
| 532 | 518 | break; |
| 533 | 519 | endswitch; |
| 534 | 520 | break; |
| 535 | - case 8: | |
| 536 | - switch ($__tagembed__feed_filter_id): | |
| 537 | - case 1: | |
| 538 | - case 2: | |
| 539 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 540 | - break; | |
| 541 | - endswitch; | |
| 542 | - break; | |
| 543 | 521 | case 10: |
| 544 | 522 | if (in_array($__tagembed__feed_filter_id, [1, 16, 17])): |
| 545 | 523 | if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 546 | 524 | return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| @@ -620,17 +598,8 @@ | ||
| 620 | 598 | if (!strstr($yelpBusinessUrl['host'], 'yelp')) |
| 621 | 599 | return __tagembed__exitWithDanger("Validation Error", ["feed" => "'Enter Yelp Business Url"]); |
| 622 | 600 | $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = explode('/', $yelpBusinessUrl['path'])[2]; |
| 623 | 601 | break; |
| 624 | - case 20: | |
| 625 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 626 | - $slackData = isset($data->slackChannelList) ? $data->slackChannelList : ""; | |
| 627 | - if (!empty($slackData)): | |
| 628 | - $slackData = explode('#', $slackData); | |
| 629 | - $__tagembed__feed_input_data['name'] = $slackData[1]; | |
| 630 | - $__tagembed__feed_input_data['feed'] = $slackData[0]; | |
| 631 | - endif; | |
| 632 | - break; | |
| 633 | 602 | case 23: |
| 634 | 603 | if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 635 | 604 | return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 636 | 605 | $airbnbListUrl = parse_url($data->feed); |
| @@ -686,87 +655,20 @@ | ||
| 686 | 655 | return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 687 | 656 | preg_match("/[^\/]+$/", "$data->feed", $matches); |
| 688 | 657 | $__tagembed__feed_input_data['name'] = $__tagembed__feed_input_data['feed'] = $matches[0]; |
| 689 | 658 | break; |
| 690 | - case 34: | |
| 691 | - if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) | |
| 692 | - return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); | |
| 693 | - $__tagembed__feed_input_data['name'] = explode('/', $data->feed)[3]; | |
| 694 | - $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 695 | - break; | |
| 696 | - case 35: | |
| 697 | - if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) | |
| 698 | - return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); | |
| 699 | - $__tagembed__feed_input_data['name'] = explode('Reviews-', $data->feed)[1]; | |
| 700 | - $__tagembed__feed_input_data['name'] = explode('.html', $__tagembed__feed_input_data['name'])[0]; | |
| 701 | - $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 702 | - break; | |
| 703 | - case 37: | |
| 704 | - $data->feed = explode('.html', $data->feed)[0]; | |
| 705 | - if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) | |
| 706 | - return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); | |
| 707 | - $__tagembed__feed_input_data['name'] = $data->feed; | |
| 708 | - $__tagembed__feed_input_data['feed'] = explode('item/', $data->feed)[1]; | |
| 709 | - break; | |
| 710 | 659 | endswitch; |
| 711 | 660 | unset($data); |
| 712 | - /* --Start-- Manage Api Calling */ | |
| 713 | - $byApiCall = 0; | |
| 714 | - if (empty($__tagembed__feed_input_data['authId'])): | |
| 715 | - switch ($__tagembed__feed_input_data['networkId']): | |
| 716 | - case 4: | |
| 717 | - if ($__tagembed__feed_filter_id == 33): | |
| 718 | - $byApiCall = 1; | |
| 719 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 720 | - endif; | |
| 721 | - break; | |
| 722 | - case 5: | |
| 723 | - case 7: | |
| 724 | - case 6: | |
| 725 | - case 10: | |
| 726 | - case 11: | |
| 727 | - case 12: | |
| 728 | - case 19: | |
| 729 | - case 23: | |
| 730 | - case 28: | |
| 731 | - case 29: | |
| 732 | - case 33: | |
| 733 | - case 34: | |
| 734 | - case 35: | |
| 735 | - case 37: | |
| 736 | - $byApiCall = 1; | |
| 737 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 738 | - break; | |
| 739 | - case 31: | |
| 740 | - if ($__tagembed__feed_filter_id == 2): | |
| 741 | - $byApiCall = 1; | |
| 742 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 743 | - endif; | |
| 744 | - break; | |
| 745 | - case 32: | |
| 746 | - if (in_array($__tagembed__feed_filter_id, [2, 75])): | |
| 747 | - $byApiCall = 1; | |
| 748 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 749 | - endif; | |
| 750 | - break; | |
| 751 | - endswitch; | |
| 752 | - else: | |
| 753 | - $byApiCall = 1; | |
| 754 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 755 | - endif; | |
| 756 | - $__tagembed__feed_input_data['appUser'] = 1; | |
| 757 | - /* --End-- Manage Api Calling */ | |
| 758 | - | |
| 759 | 661 | $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/create', ['feedData' => $__tagembed__feed_input_data], ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 760 | 662 | $response = __tagembed__manageApiResponse($response); |
| 761 | - return __tagembed__exitWithSuccess(["byapiCall" => $byApiCall, "__tagembed__requestCallBackUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL, "redirectUrl" => TAGEMBED_PLUGIN_API_URL . "apiauth/getauth", "__tagembed__feedData" => $response->__tagembed__feedData]); | |
| 663 | + return __tagembed__exitWithSuccess(["__tagembed__requestCallBackUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL, "redirectUrl" => TAGEMBED_PLUGIN_API_URL . "apiauth/getauth", "__tagembed__feedData" => $response->__tagembed__feedData]); | |
| 762 | 664 | break; |
| 763 | 665 | case "__tagembed__make_payment": |
| 764 | - if (empty($__tagembed__user_details) || empty($data->planId) || empty($data->priceCode)) | |
| 666 | + if (empty($__tagembed__user_details) || empty($data->plan) || empty($data->price)) | |
| 765 | 667 | return __tagembed__exitWithDanger(); |
| 766 | 668 | /* --Start-- Manage Param Data */ |
| 767 | - $param['planId'] = sanitize_key($data->planId); | |
| 768 | - $param['priceCode'] = $data->priceCode; | |
| 669 | + $param['plan'] = sanitize_key($data->plan); | |
| 670 | + $param['price'] = sanitize_key($data->price); | |
| 769 | 671 | /* --Start-- Manage Param Data */ |
| 770 | 672 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 771 | 673 | $param['email'] = $__tagembed__user_details->email; |
| 772 | 674 | $param['name'] = $__tagembed__user_details->name; |
| @@ -776,12 +678,12 @@ | ||
| 776 | 678 | $response = __tagembed__manageApiResponse($response); |
| 777 | 679 | return __tagembed__exitWithSuccess(["__tagembed__requestCallBackUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL, "redirectUrl" => TAGEMBED_PLUGIN_API_URL . "apiaccount/makepayment", "__tagembed__paymentData" => $response->__tagembed__paymentData]); |
| 778 | 680 | break; |
| 779 | 681 | case "__tagembed__cancel_subscription": |
| 780 | - if (empty($__tagembed__user_details) || empty($data->planId)) | |
| 682 | + if (empty($__tagembed__user_details) || empty($data->plan)) | |
| 781 | 683 | return __tagembed__exitWithDanger(); |
| 782 | 684 | /* --Start-- Manage Param Data */ |
| 783 | - $param['planId'] = sanitize_key($data->planId); | |
| 685 | + $param['plan'] = sanitize_key($data->plan); | |
| 784 | 686 | /* --Start-- Manage Param Data */ |
| 785 | 687 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 786 | 688 | $param['email'] = $__tagembed__user_details->email; |
| 787 | 689 | $param['name'] = $__tagembed__user_details->name; |
| @@ -883,8 +785,36 @@ | ||
| 883 | 785 | $response->installedPluginVersion = $installedPluginVersion; |
| 884 | 786 | $response->pluginUpgradeURL = admin_url() . "plugins.php"; |
| 885 | 787 | return __tagembed__exitWithSuccess($response); |
| 886 | 788 | break; |
| 789 | + case "__tagembed__get_en_user_id": | |
| 790 | + if (empty($__tagembed__user_details)) | |
| 791 | + return __tagembed__exitWithDanger(); | |
| 792 | + /* --Start-- Manage Param Data */ | |
| 793 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 794 | + /* --End-- Manage Param Data */ | |
| 795 | + $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/enuserid', $param, ['Authorization: __tagembed__']); | |
| 796 | + $response = __tagembed__manageApiResponse($response); | |
| 797 | + unset($param); | |
| 798 | + if (!empty($response->userId)) | |
| 799 | + return __tagembed__exitWithSuccess(["shareLink" => "https://app.tagembed.com/apiauth/connections/" . $response->userId]); | |
| 800 | + return __tagembed__exitWithDanger(); | |
| 801 | + break; | |
| 802 | + case "__tagembed__share_link": | |
| 803 | + if (empty($__tagembed__user_details) || empty($data->emailIds) || empty($data->enUserId)) | |
| 804 | + return __tagembed__exitWithDanger(); | |
| 805 | + /* --Start-- Manage Param Data */ | |
| 806 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 807 | + $param['userEmailId'] = sanitize_email($__tagembed__user_details->email); | |
| 808 | + $param['userName'] = sanitize_text_field($__tagembed__user_details->name); | |
| 809 | + $param['emailIds'] = sanitize_text_field($data->emailIds); | |
| 810 | + $param['enUserId'] = sanitize_key($data->enUserId); | |
| 811 | + /* --End-- Manage Param Data */ | |
| 812 | + $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/sendconnectionemail', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 813 | + $response = __tagembed__manageApiResponse($response); | |
| 814 | + unset($param); | |
| 815 | + return __tagembed__exitWithSuccess($response); | |
| 816 | + break; | |
| 887 | 817 | case "__tagembed__check_user_token": |
| 888 | 818 | if (empty($__tagembed__user_details)) |
| 889 | 819 | return __tagembed__exitWithDanger(); |
| 890 | 820 | /* --Start-- Manage Param Data */ |
| @@ -1010,10 +940,11 @@ | ||
| 1010 | 940 | /* --Start-- Manage Login And Register On Plugin Activate */ |
| 1011 | 941 | function __tagembed__manageLoginAndRegisterOnPluginActivate() { |
| 1012 | 942 | global $wpdb; |
| 1013 | 943 | $__tagembed__activeUserData = wp_get_current_user(); |
| 1014 | - if (empty($__tagembed__activeUserData->roles) || $__tagembed__activeUserData->roles[0] != "administrator") | |
| 944 | + if ($__tagembed__activeUserData->roles[0] != "administrator") | |
| 1015 | 945 | return false; |
| 946 | + | |
| 1016 | 947 | if (!empty($__tagembed__activeUserData->data->user_email) && !empty($__tagembed__activeUserData->data->display_name)): |
| 1017 | 948 | $__tagembed__activeUserName = $__tagembed__activeUserData->data->display_name; |
| 1018 | 949 | $__tagembed__activeUserEmail = $__tagembed__activeUserData->data->user_email; |
| 1019 | 950 | |
| @@ -1063,8 +994,11 @@ | ||
| 1063 | 994 | endif; |
| 1064 | 995 | endif; |
| 1065 | 996 | __tagembed__manageActiveOptions($response->emailId, "yes"); /* Manage Active Options */ |
| 1066 | 997 | if ($return): |
| 998 | + if (count($response->collaboratorlist)): | |
| 999 | + __tagembed__manageCollaborator($response->collaboratorlist, $response->userId); | |
| 1000 | + endif; | |
| 1067 | 1001 | __tagembed__manageActiveWidgetsUser($response->userId); |
| 1068 | 1002 | endif; |
| 1069 | 1003 | return $return; |
| 1070 | 1004 | } |
| @@ -1070,11 +1004,11 @@ | ||
| 1070 | 1004 | } |
| 1071 | 1005 | /* --End-- Login */ |
| 1072 | 1006 | |
| 1073 | 1007 | /* --Start-- Manage Active Options */ |
| 1074 | -function __tagembed__manageActiveOptions($email = null, $other = null) { | |
| 1008 | +function __tagembed__manageActiveOptions($email = NULL, $other = NULL) { | |
| 1075 | 1009 | global $wpdb; |
| 1076 | - if ($email == null && $other != null): | |
| 1010 | + if ($email == NULL && $other != NULL): | |
| 1077 | 1011 | $wpdb->update('wp_tagembed_active_options', ["isLogin" => $other], ['id' => 1]); |
| 1078 | 1012 | else: |
| 1079 | 1013 | $__tagembed__activeOptions = $wpdb->get_results("SELECT email FROM wp_tagembed_active_options WHERE(id = 1)"); |
| 1080 | 1014 | if (empty($__tagembed__activeOptions[0]->email)): |
| @@ -1095,9 +1029,9 @@ | ||
| 1095 | 1029 | /* --Start-- Logout */ |
| 1096 | 1030 | function tagembed_logout() { |
| 1097 | 1031 | global $wpdb; |
| 1098 | 1032 | if ($wpdb->update('wp_tagembed_user', ["isLogin" => "no"], ["isLogin" => "yes"])): |
| 1099 | - __tagembed__manageActiveOptions(null, "no"); /* Manage Active Options */ | |
| 1033 | + __tagembed__manageActiveOptions(NULL, "no"); /* Manage Active Options */ | |
| 1100 | 1034 | return true; |
| 1101 | 1035 | endif; |
| 1102 | 1036 | return false; |
| 1103 | 1037 | } |
| @@ -1137,8 +1071,45 @@ | ||
| 1137 | 1071 | return $__tagembed__user_dataResponse[0]; |
| 1138 | 1072 | return; |
| 1139 | 1073 | } |
| 1140 | 1074 | /* --End-- Get User Details */ |
| 1075 | +/* --Start-- Get Collaborator Details */ | |
| 1076 | +function __tagembed__collaborator($userId) { | |
| 1077 | + global $wpdb; | |
| 1078 | + return $wpdb->get_results("SELECT * FROM wp_tagembed_collaborator WHERE(userId = '" . $userId . "')"); | |
| 1079 | +} | |
| 1080 | +/* --End-- Get Collaborator Details */ | |
| 1081 | +/* --Start-- Manage Collaborator */ | |
| 1082 | +function __tagembed__manageCollaborator($collaboratorList, $userId) { | |
| 1083 | + global $wpdb; | |
| 1084 | + $prevCollaboratorList = __tagembed__convertObjectToArray(__tagembed__collaborator($userId)); | |
| 1085 | + $collaboratorList = __tagembed__convertObjectToArray($collaboratorList); | |
| 1086 | + $collaboratorListIds = []; | |
| 1087 | + if (is_array($collaboratorList)) | |
| 1088 | + $collaboratorListIds = array_column($collaboratorList, 'id'); | |
| 1089 | + $prevCollaboratorListIds = []; | |
| 1090 | + if (is_array($prevCollaboratorList)): | |
| 1091 | + $prevCollaboratorListIds = array_column($prevCollaboratorList, 'collaboratorId'); | |
| 1092 | + $commonCollaboratorIds = array_intersect($prevCollaboratorListIds, $collaboratorListIds); | |
| 1093 | + $prevCollaboratorListIds = array_diff($prevCollaboratorListIds, $commonCollaboratorIds); | |
| 1094 | + $collaboratorListIds = array_diff($collaboratorListIds, $commonCollaboratorIds); | |
| 1095 | + endif; | |
| 1096 | + if (count($prevCollaboratorListIds)): | |
| 1097 | + foreach ($prevCollaboratorListIds as $delId): | |
| 1098 | + if ($wpdb->delete('wp_tagembed_collaborator', ["collaboratorId" => $delId, "userId" => $userId])) | |
| 1099 | + $wpdb->delete('wp_tagembed_widget', ["userId" => $delId]); | |
| 1100 | + endforeach; | |
| 1101 | + endif; | |
| 1102 | + foreach ($collaboratorList as $key => $collaborator): | |
| 1103 | + if (in_array($collaborator['id'], $collaboratorListIds)): | |
| 1104 | + $wpdb->insert('wp_tagembed_collaborator', ["userId" => $userId, "collaboratorId" => $collaboratorList[$key]['id'], "name" => $collaboratorList[$key]['name']]); | |
| 1105 | + elseif (in_array($collaborator['id'], $commonCollaboratorIds)): | |
| 1106 | + $wpdb->update('wp_tagembed_collaborator', ["userId" => $userId, "name" => $collaboratorList[$key]['name'],], ['collaboratorId' => $collaborator['id'], "userId" => $userId]); | |
| 1107 | + endif; | |
| 1108 | + endforeach; | |
| 1109 | + return true; | |
| 1110 | +} | |
| 1111 | +/* --End-- Manage Collaborator */ | |
| 1141 | 1112 | /* --Start-- Get Widget */ |
| 1142 | 1113 | function __tagembed__widgets() { |
| 1143 | 1114 | $returnWidgetData = []; |
| 1144 | 1115 | $__tagembed__user_details = __tagembed__user(); |
| @@ -1184,11 +1155,10 @@ | ||
| 1184 | 1155 | function __tagembed__activeWidgetUser() { |
| 1185 | 1156 | global $wpdb; |
| 1186 | 1157 | $__tagembed__activeWidgetUserResponse = ""; |
| 1187 | 1158 | $__tagembed__activeWidgetUserResponse = $wpdb->get_results("SELECT * FROM wp_tagembed_active_widget_user"); |
| 1188 | - if (!empty($__tagembed__activeWidgetUserResponse)): | |
| 1159 | + if (!empty($__tagembed__activeWidgetUserResponse)) | |
| 1189 | 1160 | return $__tagembed__activeWidgetUserResponse[0]->userId; |
| 1190 | - endif; | |
| 1191 | 1161 | return; |
| 1192 | 1162 | } |
| 1193 | 1163 | /* --End-- Get Active Widget User */ |
| 1194 | 1164 | /* --Start-- Manage Active Widget User */ |
| @@ -1213,26 +1183,22 @@ | ||
| 1213 | 1183 | function __tagembed__createDatabaseTableForPlugin() { |
| 1214 | 1184 | global $wpdb; |
| 1215 | 1185 | require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 1216 | 1186 | $wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_user` (`id` int(11) NOT NULL AUTO_INCREMENT,`userId` varchar(100) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100) NOT NULL,`accessToken` varchar(255) NOT NULL,`isLogin` enum('no', 'yes') NOT NULL,PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); |
| 1187 | + $wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_collaborator` (`id` int(11) NOT NULL AUTO_INCREMENT,`userId` varchar(100) NOT NULL,`collaboratorId` varchar(100) NOT NULL,`name` varchar(100) NOT NULL,PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); | |
| 1217 | 1188 | $wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_active_widget_user` (`id` int(11) NOT NULL AUTO_INCREMENT,`userId` varchar(100) NOT NULL,PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); |
| 1218 | 1189 | $wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_menus` (`id` int(11) NOT NULL AUTO_INCREMENT,`name` varchar(100) NOT NULL,`status` tinyint(2) NOT NULL,`path` varchar(255) NOT NULL,PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); |
| 1219 | 1190 | $wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_active_widget` (`id` int(11) NOT NULL AUTO_INCREMENT,`widgetId` varchar(100) NOT NULL,PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); |
| 1220 | 1191 | $wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_active_options` (`id` int(11) NOT NULL AUTO_INCREMENT,`email` varchar(500) NOT NULL,`isLogin` enum('no', 'yes'),PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); |
| 1221 | - | |
| 1222 | - /* --Start-- Manage Tagembed Plugin Menus */ | |
| 1223 | - $__tagembed__checkAlreadyExistMenusDataExistOrNot = $wpdb->get_results("SELECT id FROM wp_tagembed_menus"); | |
| 1224 | - if (empty($__tagembed__checkAlreadyExistMenusDataExistOrNot)): | |
| 1225 | - $__tagembed__menus = [['name' => 'Widget', 'status' => 0, 'path' => 'widget/widgetView'], ['name' => 'Feed', 'status' => 1, 'path' => 'feed/addView'], ['name' => 'Choose Theme', 'status' => 0, 'path' => 'theme/themeView'], ['name' => 'Filter', 'status' => 0, 'path' => 'filter/filterView'], ['name' => 'Customize', 'status' => 0, 'path' => 'customize/customizeView'], ['name' => 'Display', 'status' => 0, 'path' => 'display/displayView'], ['name' => 'Social Accounts', 'status' => 0, 'path' => 'socialAccount/socialAccountView'], ['name' => 'Support', 'status' => 0, 'path' => 'support/supportView'], ['name' => 'Upgrade', 'status' => 0, 'path' => 'upgrade/upgradeView'], ['name' => 'Analytics', 'status' => 0, 'path' => 'analytics/analyticsView']]; | |
| 1226 | - foreach ($__tagembed__menus as $__tagembed__menu): | |
| 1227 | - $wpdb->insert('wp_tagembed_menus', ["name" => $__tagembed__menu['name'], "status" => $__tagembed__menu['status'], "path" => $__tagembed__menu['path']]); | |
| 1228 | - endforeach; | |
| 1229 | - endif; | |
| 1230 | - /* --End-- Manage Tagembed Plugin Menus */ | |
| 1192 | + /* Manage Tagembed Plugin Menus */ | |
| 1193 | + $__tagembed__menus = [['name' => 'Widget', 'status' => 0, 'path' => 'widget/widgetView'], ['name' => 'Feed', 'status' => 1, 'path' => 'feed/addView'], ['name' => 'Choose Theme', 'status' => 0, 'path' => 'theme/themeView'], ['name' => 'Filter', 'status' => 0, 'path' => 'filter/filterView'], ['name' => 'Customize', 'status' => 0, 'path' => 'customize/customizeView'], ['name' => 'Display', 'status' => 0, 'path' => 'display/displayView'], ['name' => 'Social Accounts', 'status' => 0, 'path' => 'socialAccount/socialAccountView'], ['name' => 'Support', 'status' => 0, 'path' => 'support/supportView'], ['name' => 'Upgrade', 'status' => 0, 'path' => 'upgrade/upgradeView'], ['name' => 'Analytics', 'status' => 0, 'path' => 'analytics/analyticsView']]; | |
| 1194 | + foreach ($__tagembed__menus as $__tagembed__menu) | |
| 1195 | + $wpdb->insert('wp_tagembed_menus', ["name" => $__tagembed__menu['name'], "status" => $__tagembed__menu['status'], "path" => $__tagembed__menu['path']]); | |
| 1231 | 1196 | } |
| 1232 | 1197 | function __tagembed__dropDatabaseTablesForPlugin() { |
| 1233 | 1198 | global $wpdb; |
| 1234 | 1199 | $wpdb->query("DROP table IF EXISTS wp_tagembed_user"); |
| 1200 | + $wpdb->query("DROP table IF EXISTS wp_tagembed_collaborator"); | |
| 1235 | 1201 | $wpdb->query("DROP table IF EXISTS wp_tagembed_active_widget_user"); |
| 1236 | 1202 | $wpdb->query("DROP table IF EXISTS wp_tagembed_active_widget"); |
| 1237 | 1203 | $wpdb->query("DROP table IF EXISTS wp_tagembed_menus"); |
| 1238 | 1204 | } |
| @@ -1253,15 +1219,11 @@ | ||
| 1253 | 1219 | /* register_deactivation_hook(__FILE__, '__tagembed__pluginDeactivate'); |
| 1254 | 1220 | function __tagembed__pluginDeactivate() { |
| 1255 | 1221 | __tagembed__dropDatabaseTablesForPlugin(); |
| 1256 | 1222 | } */ |
| 1257 | - | |
| 1258 | 1223 | /* --End-- Manage Active Deactive And Uninstall Webhook */ |
| 1259 | 1224 | /* --Start--Manage Redirect After Plugin Activate */ |
| 1260 | 1225 | function __tagembed__plginActivationRedirect() { |
| 1261 | - $__tagembed__activeUserData = wp_get_current_user(); | |
| 1262 | - if (empty($__tagembed__activeUserData->roles)) | |
| 1263 | - return false; | |
| 1264 | 1226 | exit(wp_redirect(TAGEMBED_PLUGIN_CALL_BACK_URL)); |
| 1265 | 1227 | } |
| 1266 | 1228 | /* --End--Manage Redirect After Plugin Activate */ |
| 1267 | 1229 | /* --Start--Manage Setting Link */ |
| @@ -1270,9 +1232,8 @@ | ||
| 1270 | 1232 | return $links; |
| 1271 | 1233 | } |
| 1272 | 1234 | add_filter("plugin_action_links_" . plugin_basename(__FILE__), '__tagembed__settingsLink'); |
| 1273 | 1235 | /* --End--Manage Setting Link */ |
| 1274 | - | |
| 1275 | 1236 | /* --Start--Manage Database On Plugin Update Time */ |
| 1276 | 1237 | function __tagembed__manageDatabaseOnPluginUpdateTime() { |
| 1277 | 1238 | __tagembed__dropDatabaseTablesForPlugin(); |
| 1278 | 1239 | __tagembed__createDatabaseTableForPlugin(); |
| @@ -1279,9 +1240,8 @@ | ||
| 1279 | 1240 | __tagembed__manageLoginAndRegisterOnPluginActivate(); |
| 1280 | 1241 | } |
| 1281 | 1242 | add_action('upgrader_process_complete', '__tagembed__manageDatabaseOnPluginUpdateTime', 10, 2); |
| 1282 | 1243 | /* --End--Manage Database On Plugin Update Time */ |
| 1283 | - | |
| 1284 | 1244 | /* --Sart--Manage Chat Hide And Show */ |
| 1285 | 1245 | function __tagembed__chat() { |
| 1286 | 1246 | $returnData = false; |
| 1287 | 1247 | TRY { |
| @@ -1305,26 +1265,8 @@ | ||
| 1305 | 1265 | } |
| 1306 | 1266 | return $returnData; |
| 1307 | 1267 | } |
| 1308 | 1268 | /* --End--Manage Chat Hide And Show */ |
| 1309 | - | |
| 1310 | -/* --Sart--Get And Manage Social Accout Id */ | |
| 1311 | -function __tagembed__get_user_social_account_id() { | |
| 1312 | - $__tagembed__user_details = __tagembed__user(); | |
| 1313 | - $param['userId'] = $__tagembed__user_details->userId; | |
| 1314 | - $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getsocialaccountid', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1315 | - if (isset($response->head->status)): | |
| 1316 | - if ($response->head->status): | |
| 1317 | - $response = __tagembed__manageApiResponse($response); | |
| 1318 | - if (!empty($response->userId)): | |
| 1319 | - return $response->userId; | |
| 1320 | - endif; | |
| 1321 | - endif; | |
| 1322 | - endif; | |
| 1323 | - return false; | |
| 1324 | -} | |
| 1325 | -/* --End--Manage Chat Hide And Show */ | |
| 1326 | - | |
| 1327 | 1269 | /* --Start-- Manage Hide And Show Admin Notificationa */ |
| 1328 | 1270 | function __tagembed__generalAdminNotice() { |
| 1329 | 1271 | $__tagmebed__page_name = ""; |
| 1330 | 1272 | if (!empty($_GET['page'])): |