| @@ -2,24 +2,20 @@ | ||
| 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: 5.7 | |
| 6 | + * Version: 4.5 | |
| 7 | 7 | * Author: Tagembed |
| 8 | 8 | * Author URI: https://tagembed.com/ |
| 9 | - * License: GPLv3 | |
| 10 | - * License URI: https://www.gnu.org/licenses/gpl-3.0.html | |
| 11 | 9 | */ |
| 12 | 10 | if (!defined('WPINC')) |
| 13 | 11 | die; |
| 14 | 12 | /* --Start-- Create Constant */ |
| 15 | -!defined('TAGEMBED_PLUGIN_VERSION') && define('TAGEMBED_PLUGIN_VERSION', '5.7'); | |
| 13 | +!defined('TAGEMBED_PLUGIN_VERSION') && define('TAGEMBED_PLUGIN_VERSION', '4.5'); | |
| 16 | 14 | !defined('TAGEMBED_PLUGIN_DIR_PATH') && define('TAGEMBED_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__)); |
| 17 | 15 | !defined('TAGEMBED_PLUGIN_URL') && define('TAGEMBED_PLUGIN_URL', plugin_dir_url(__FILE__)); |
| 18 | 16 | !defined('TAGEMBED_PLUGIN_REDIRECT_URL') && define('TAGEMBED_PLUGIN_REDIRECT_URL', get_admin_url(null, 'admin.php?page=')); |
| 19 | 17 | !defined('TAGEMBED_PLUGIN_API_URL') && define('TAGEMBED_PLUGIN_API_URL', "https://api.tagembed.com/app/"); |
| 20 | -!defined('TAGEMBED_PLUGIN_SERVER_URL') && define('TAGEMBED_PLUGIN_SERVER_URL', "https://api.tagembed.com/app/"); | |
| 21 | -!defined('TAGEMBED_PLUGIN_REACT_URL') && define('TAGEMBED_PLUGIN_REACT_URL', "https://widget.tagembed.com/"); | |
| 22 | 18 | !defined('TAGEMBED_PLUGIN_CALL_BACK_URL') && define('TAGEMBED_PLUGIN_CALL_BACK_URL', admin_url() . "admin.php?page=tagembed"); |
| 23 | 19 | /* --End-- Create Constant */ |
| 24 | 20 | /* --Start--Include Files */ |
| 25 | 21 | include_once TAGEMBED_PLUGIN_DIR_PATH . "helper/helper.php"; |
| @@ -25,9 +21,9 @@ | ||
| 25 | 21 | include_once TAGEMBED_PLUGIN_DIR_PATH . "helper/helper.php"; |
| 26 | 22 | /* --End--Include Files */ |
| 27 | 23 | /* --Start-- Add Js And Css */ |
| 28 | 24 | function tagembed_plugin_scripts_css() { |
| 29 | - 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); | |
| 30 | 26 | if (is_admin()): |
| 31 | 27 | /* CSS */ |
| 32 | 28 | wp_enqueue_style('__tagembed__commonCss', TAGEMBED_PLUGIN_URL . '/assets/css/common.css', '', TAGEMBED_PLUGIN_VERSION); |
| 33 | 29 | wp_enqueue_style('__tagembed__toastCss', TAGEMBED_PLUGIN_URL . '/assets/css/toast.css', '', TAGEMBED_PLUGIN_VERSION); |
| @@ -35,19 +31,13 @@ | ||
| 35 | 31 | wp_enqueue_style('__tagembed__tagembedloaderCss', TAGEMBED_PLUGIN_URL . '/assets/css/loader.css', '', TAGEMBED_PLUGIN_VERSION); |
| 36 | 32 | wp_enqueue_style('__tagembed__popupCss', TAGEMBED_PLUGIN_URL . '/assets/css/styles.css', '', TAGEMBED_PLUGIN_VERSION); |
| 37 | 33 | wp_enqueue_style('__tagembed__editorCss', TAGEMBED_PLUGIN_URL . '/assets/css/editor/editor.css', '', TAGEMBED_PLUGIN_VERSION); |
| 38 | 34 | /* JS */ |
| 39 | - | |
| 40 | - wp_enqueue_script('__tagembed__faJs', TAGEMBED_PLUGIN_URL . '/assets/js/fa.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 35 | + wp_enqueue_script('__tagembed__faJs', TAGEMBED_PLUGIN_URL . '/assets/js/fa.js', ['jquery'], TAGEMBED_PLUGIN_VERSION); | |
| 41 | 36 | wp_enqueue_script('__tagembed__toastJs', TAGEMBED_PLUGIN_URL . '/assets/js/toast.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); |
| 42 | 37 | wp_enqueue_script('__tagembed__confirmDialogJs', TAGEMBED_PLUGIN_URL . '/assets/js/confirm_dialog.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); |
| 43 | - | |
| 44 | 38 | wp_enqueue_script('__tagembed__tagemedLoaderJs', TAGEMBED_PLUGIN_URL . '/assets/js/loader.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); |
| 45 | - wp_localize_script('__tagembed__tagemedLoaderJs', '__tagembed__pluginLoaderImageUrlObj', ['__tagembed__pluginLoaderImageUrl' => TAGEMBED_PLUGIN_URL]); | |
| 46 | - | |
| 47 | 39 | wp_enqueue_script('__tagembed__deactive-js', TAGEMBED_PLUGIN_URL . '/assets/js/tagembed.deactive.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); |
| 48 | - $__tagembed__ajax_call_security_nones = wp_create_nonce('__tagembed__ajax_call_security_nones'); | |
| 49 | - wp_localize_script('__tagembed__deactive-js', '__tagembed__ajax_call_security_nones_object', ['__tagembed__ajax_call_security_nones' => $__tagembed__ajax_call_security_nones]); | |
| 50 | 40 | wp_enqueue_script('__tagembed__tagembedDialogFormJs', TAGEMBED_PLUGIN_URL . '/assets/js/dialog.form.js', ["jquery"], TAGEMBED_PLUGIN_VERSION, true); |
| 51 | 41 | /* --Start-- Gutenberge */ |
| 52 | 42 | if (!function_exists("register_block_type")): |
| 53 | 43 | return; |
| @@ -84,10 +74,9 @@ | ||
| 84 | 74 | |
| 85 | 75 | /* --Start-- Add & Manage Views */ |
| 86 | 76 | function __tagembed__view() { |
| 87 | 77 | if (!empty(__tagembed__user()->isLogin) && __tagembed__user()->isLogin == 'yes'): |
| 88 | - /* Remove This */ /* $__tagembed__menus = __tagembed__menus(['__tagembed__menu_condation' => 'STATUS = 1']); */ | |
| 89 | - $__tagembed__menus = __tagembed__menus(['__tagembed__menu_condation' => 1]); | |
| 78 | + $__tagembed__menus = __tagembed__menus(['__tagembed__menu_condation' => 'STATUS = 1']); | |
| 90 | 79 | if (empty($__tagembed__menus)): |
| 91 | 80 | include_once TAGEMBED_PLUGIN_DIR_PATH . "views/widget/widgetView.php"; |
| 92 | 81 | else: |
| 93 | 82 | include_once TAGEMBED_PLUGIN_DIR_PATH . "views/" . $__tagembed__menus[0]->path . ".php"; |
| @@ -96,35 +85,19 @@ | ||
| 96 | 85 | include_once TAGEMBED_PLUGIN_DIR_PATH . "views/account/accountView.php"; |
| 97 | 86 | endif; |
| 98 | 87 | } |
| 99 | 88 | /* --End-- Add & Manage Views */ |
| 100 | -/* --Start-- Feed Count For First Time Create */ | |
| 101 | -function __tagembed__get_feed_count_information($userDetails, $networkId) { | |
| 102 | - $param['networkId'] = sanitize_key($networkId); | |
| 103 | - $__tagembed__user_details = __tagembed__user(); | |
| 104 | - $param['userId'] = sanitize_key($userDetails->userId); | |
| 105 | - $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getFeedCountForFirstTimeFeed', $param, ['Authorization:' . $userDetails->accessToken]); | |
| 106 | - if ($response->head->status || $response->head->code == 200 || $response->body || !empty($response->body)): | |
| 107 | - return $response->body; | |
| 108 | - endif; | |
| 109 | -} | |
| 110 | -/* --End-- Feed Count For First Time Create */ | |
| 111 | 89 | /* --Start-- Manage Ajax Calls */ |
| 112 | 90 | add_action("wp_ajax_data", "__tagembed__dataAjaxHandler"); |
| 113 | 91 | function __tagembed__dataAjaxHandler() { |
| 114 | 92 | if (empty($_REQUEST['__tagembed__ajax_action'])) |
| 115 | - return false; | |
| 93 | + return FALSE; | |
| 116 | 94 | $data = __tagembed__sanitizeRequestData($_REQUEST); |
| 117 | 95 | $data = (object) $data; |
| 118 | - /* --Start-- Manage Ajax call Request Security */ | |
| 119 | - $__tagembed__ajaxCallSecurityNones = isset($data->__tagembed__ajax_call_nones) ? sanitize_text_field($data->__tagembed__ajax_call_nones) : ''; | |
| 120 | - if (!wp_verify_nonce($__tagembed__ajaxCallSecurityNones, "__tagembed__ajax_call_security_nones")) | |
| 121 | - return __tagembed__exitWithDanger(); | |
| 122 | - /* --End-- Manage Ajax call Request Security */ | |
| 123 | 96 | /* --Start__ Sanetize All Input */ |
| 124 | 97 | foreach ($data as $key => $value): |
| 125 | 98 | if (!in_array($key, ['emailId', 'password', 'youtubePlaylist'])) |
| 126 | - __tagembed__inputSanetize($value); | |
| 99 | + inputSanetize($value); | |
| 127 | 100 | endforeach; |
| 128 | 101 | /* --End__ Sanetize All Input */ |
| 129 | 102 | $param = []; |
| 130 | 103 | global $wpdb; |
| @@ -138,12 +111,12 @@ | ||
| 138 | 111 | $param['fullName'] = sanitize_text_field($data->fullName); |
| 139 | 112 | $param['emailId'] = sanitize_email($data->emailId); |
| 140 | 113 | $param['password'] = $data->password; |
| 141 | 114 | /* --End-- Manage Param Data */ |
| 142 | - $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/register', $param, []); | |
| 115 | + $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/register', $param); | |
| 143 | 116 | $response = __tagembed__manageApiResponse($response); |
| 144 | 117 | unset($param); |
| 145 | - $param = ['userId' => sanitize_key($response->userId), 'inheritStyles' => 1]; | |
| 118 | + $param = ['userId' => sanitize_key($response->userId)]; | |
| 146 | 119 | __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $response->accessToken]); |
| 147 | 120 | if (__tagembed__login($response) == true) |
| 148 | 121 | return __tagembed__exitWithSuccess(["redirectUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL]); |
| 149 | 122 | return __tagembed__exitWithDanger(); |
| @@ -200,9 +173,8 @@ | ||
| 200 | 173 | /* --Start-- Manage Param Data */ |
| 201 | 174 | $param['name'] = sanitize_text_field($data->name); |
| 202 | 175 | $param['profanity'] = sanitize_key($data->profanity); |
| 203 | 176 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 204 | - $param['inheritStyles'] = 1; | |
| 205 | 177 | /* --End-- Manage Param Data */ |
| 206 | 178 | $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 207 | 179 | unset($param); |
| 208 | 180 | $response = __tagembed__manageApiResponse($response); |
| @@ -377,21 +349,8 @@ | ||
| 377 | 349 | unset($param); |
| 378 | 350 | $response = __tagembed__manageApiResponse($response); |
| 379 | 351 | return __tagembed__exitWithSuccess($response); |
| 380 | 352 | break; |
| 381 | - case "__tagembed__search_facebook_page": | |
| 382 | - if (empty($data->facebookPageData)) | |
| 383 | - return __tagembed__exitWithDanger(); | |
| 384 | - /* --Start-- Manage Param Data */ | |
| 385 | - $param['facebookPageData'] = $data->facebookPageData; | |
| 386 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 387 | - /* --End-- Manage Param Data */ | |
| 388 | - /* --Start-- Call And Manage Api Call */ | |
| 389 | - $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchfacebookpage', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 390 | - unset($param); | |
| 391 | - $response = __tagembed__manageApiResponse($response); | |
| 392 | - return __tagembed__exitWithSuccess($response); | |
| 393 | - break; | |
| 394 | 353 | case "__tagembed__get_facebook_page_albums": |
| 395 | 354 | if (empty($__tagembed__user_details) || empty($data->connectedAccountsId)) |
| 396 | 355 | return __tagembed__exitWithDanger(); |
| 397 | 356 | /* --Start-- Manage Param Data */ |
| @@ -426,20 +385,8 @@ | ||
| 426 | 385 | unset($param); |
| 427 | 386 | $response = __tagembed__manageApiResponse($response); |
| 428 | 387 | return __tagembed__exitWithSuccess($response); |
| 429 | 388 | break; |
| 430 | - case "__tagembed__get_slack_channel_list": | |
| 431 | - if (empty($data->connectedAccountsId)) | |
| 432 | - return __tagembed__exitWithDanger(); | |
| 433 | - /* --Start-- Manage Param Data */ | |
| 434 | - $param['connectedAccountsId'] = $data->connectedAccountsId; | |
| 435 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 436 | - /* --End-- Manage Param Data */ | |
| 437 | - $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getslackchannellist', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 438 | - unset($param); | |
| 439 | - $response = __tagembed__manageApiResponse($response); | |
| 440 | - return __tagembed__exitWithSuccess($response); | |
| 441 | - break; | |
| 442 | 389 | case "__tagembed__get_feed": |
| 443 | 390 | if (empty($__tagembed__user_details) || empty($data->widgetId)) |
| 444 | 391 | return __tagembed__exitWithDanger(); |
| 445 | 392 | /* --Start-- Manage Param Data */ |
| @@ -570,16 +517,8 @@ | ||
| 570 | 517 | unset($data->youtubePlaylist); |
| 571 | 518 | break; |
| 572 | 519 | endswitch; |
| 573 | 520 | break; |
| 574 | - case 8: | |
| 575 | - switch ($__tagembed__feed_filter_id): | |
| 576 | - case 1: | |
| 577 | - case 2: | |
| 578 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 579 | - break; | |
| 580 | - endswitch; | |
| 581 | - break; | |
| 582 | 521 | case 10: |
| 583 | 522 | if (in_array($__tagembed__feed_filter_id, [1, 16, 17])): |
| 584 | 523 | if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 585 | 524 | return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| @@ -643,18 +582,15 @@ | ||
| 643 | 582 | $__tagembed__feed_input_data['name'] = $data->name; |
| 644 | 583 | break; |
| 645 | 584 | case 18: |
| 646 | 585 | switch ($__tagembed__feed_filter_id): |
| 647 | - case 23: | |
| 648 | - if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) | |
| 649 | - return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); | |
| 650 | - break; | |
| 651 | 586 | case 26: |
| 652 | 587 | $__tagembed__feed_input_data['hashtagCaption'] = sanitize_key(isset($data->hashtagCaption) ? 1 : 0); |
| 653 | 588 | $__tagembed__feed_input_data['hashtagOlder'] = sanitize_key(isset($data->hashtagOlder) ? 1 : 0); |
| 654 | 589 | break; |
| 655 | 590 | endswitch; |
| 656 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 591 | + if (!in_array($__tagembed__feed_filter_id, [34])) | |
| 592 | + $__tagembed__feed_input_data['auth'] = 1; | |
| 657 | 593 | break; |
| 658 | 594 | case 19: |
| 659 | 595 | if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 660 | 596 | return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| @@ -662,17 +598,8 @@ | ||
| 662 | 598 | if (!strstr($yelpBusinessUrl['host'], 'yelp')) |
| 663 | 599 | return __tagembed__exitWithDanger("Validation Error", ["feed" => "'Enter Yelp Business Url"]); |
| 664 | 600 | $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = explode('/', $yelpBusinessUrl['path'])[2]; |
| 665 | 601 | break; |
| 666 | - case 20: | |
| 667 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 668 | - $slackData = isset($data->slackChannelList) ? $data->slackChannelList : ""; | |
| 669 | - if (!empty($slackData)): | |
| 670 | - $slackData = explode('#', $slackData); | |
| 671 | - $__tagembed__feed_input_data['name'] = $slackData[1]; | |
| 672 | - $__tagembed__feed_input_data['feed'] = $slackData[0]; | |
| 673 | - endif; | |
| 674 | - break; | |
| 675 | 602 | case 23: |
| 676 | 603 | if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 677 | 604 | return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 678 | 605 | $airbnbListUrl = parse_url($data->feed); |
| @@ -728,117 +655,20 @@ | ||
| 728 | 655 | return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 729 | 656 | preg_match("/[^\/]+$/", "$data->feed", $matches); |
| 730 | 657 | $__tagembed__feed_input_data['name'] = $__tagembed__feed_input_data['feed'] = $matches[0]; |
| 731 | 658 | break; |
| 732 | - case 34: | |
| 733 | - if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) | |
| 734 | - return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); | |
| 735 | - $__tagembed__feed_input_data['name'] = explode('/', $data->feed)[3]; | |
| 736 | - $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 737 | - break; | |
| 738 | - case 35: | |
| 739 | - if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) | |
| 740 | - return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); | |
| 741 | - $__tagembed__feed_input_data['name'] = explode('Reviews-', $data->feed)[1]; | |
| 742 | - $__tagembed__feed_input_data['name'] = explode('.html', $__tagembed__feed_input_data['name'])[0]; | |
| 743 | - $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 744 | - break; | |
| 745 | - case 37: | |
| 746 | - $data->feed = explode('.html', $data->feed)[0]; | |
| 747 | - if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) | |
| 748 | - return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); | |
| 749 | - $__tagembed__feed_input_data['name'] = $data->feed; | |
| 750 | - $__tagembed__feed_input_data['feed'] = explode('item/', $data->feed)[1]; | |
| 751 | - break; | |
| 752 | 659 | endswitch; |
| 753 | 660 | unset($data); |
| 754 | - /* --Start-- Manage Api Calling */ | |
| 755 | - $byApiCall = 0; | |
| 756 | - if (empty($__tagembed__feed_input_data['authId'])): | |
| 757 | - switch ($__tagembed__feed_input_data['networkId']): | |
| 758 | - case 4: | |
| 759 | - if ($__tagembed__feed_filter_id == 33): | |
| 760 | - $byApiCall = 1; | |
| 761 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 762 | - endif; | |
| 763 | - break; | |
| 764 | - case 3: | |
| 765 | - case 18: | |
| 766 | - if ($__tagembed__feed_filter_id == 23 || $__tagembed__feed_filter_id == 26 || $__tagembed__feed_filter_id == 8): | |
| 767 | - $__tagembed__get_feed_count_information = __tagembed__get_feed_count_information($__tagembed__user_details, $__tagembed__feed_input_data['networkId']); | |
| 768 | - if (empty($__tagembed__get_feed_count_information)): | |
| 769 | - $byApiCall = 1; | |
| 770 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 771 | - endif; | |
| 772 | - endif; | |
| 773 | - break; | |
| 774 | - case 1: | |
| 775 | - $__tagembed__get_feed_count_information = __tagembed__get_feed_count_information($__tagembed__user_details, $__tagembed__feed_input_data['networkId']); | |
| 776 | - if (empty($__tagembed__get_feed_count_information)): | |
| 777 | - $byApiCall = 1; | |
| 778 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 779 | - endif; | |
| 780 | - break; | |
| 781 | - /* case 18: | |
| 782 | - if ($__tagembed__feed_filter_id == 23 || $__tagembed__feed_filter_id == 26 && empty($__tagembed__feed_input_data['authId'])): | |
| 783 | - $byApiCall = 1; | |
| 784 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 785 | - endif; | |
| 786 | - break; | |
| 787 | - case 3: | |
| 788 | - if ($__tagembed__feed_filter_id == 8 && empty($__tagembed__feed_input_data['authId'])): | |
| 789 | - $byApiCall = 1; | |
| 790 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 791 | - endif; | |
| 792 | - break; | |
| 793 | - case 1: */ | |
| 794 | - case 5: | |
| 795 | - case 7: | |
| 796 | - case 6: | |
| 797 | - case 10: | |
| 798 | - case 11: | |
| 799 | - case 12: | |
| 800 | - case 19: | |
| 801 | - case 23: | |
| 802 | - case 28: | |
| 803 | - case 29: | |
| 804 | - case 33: | |
| 805 | - case 34: | |
| 806 | - case 35: | |
| 807 | - case 37: | |
| 808 | - $byApiCall = 1; | |
| 809 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 810 | - break; | |
| 811 | - case 31: | |
| 812 | - if ($__tagembed__feed_filter_id == 2): | |
| 813 | - $byApiCall = 1; | |
| 814 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 815 | - endif; | |
| 816 | - break; | |
| 817 | - case 32: | |
| 818 | - if (in_array($__tagembed__feed_filter_id, [2, 75])): | |
| 819 | - $byApiCall = 1; | |
| 820 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 821 | - endif; | |
| 822 | - break; | |
| 823 | - endswitch; | |
| 824 | - else: | |
| 825 | - $byApiCall = 1; | |
| 826 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 827 | - endif; | |
| 828 | - $__tagembed__feed_input_data['appUser'] = 1; | |
| 829 | - /* --End-- Manage Api Calling */ | |
| 830 | - | |
| 831 | 661 | $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/create', ['feedData' => $__tagembed__feed_input_data], ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 832 | 662 | $response = __tagembed__manageApiResponse($response); |
| 833 | - 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]); | |
| 834 | 664 | break; |
| 835 | 665 | case "__tagembed__make_payment": |
| 836 | - if (empty($__tagembed__user_details) || empty($data->planId) || empty($data->priceCode)) | |
| 666 | + if (empty($__tagembed__user_details) || empty($data->plan) || empty($data->price)) | |
| 837 | 667 | return __tagembed__exitWithDanger(); |
| 838 | 668 | /* --Start-- Manage Param Data */ |
| 839 | - $param['planId'] = sanitize_key($data->planId); | |
| 840 | - $param['priceCode'] = $data->priceCode; | |
| 669 | + $param['plan'] = sanitize_key($data->plan); | |
| 670 | + $param['price'] = sanitize_key($data->price); | |
| 841 | 671 | /* --Start-- Manage Param Data */ |
| 842 | 672 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 843 | 673 | $param['email'] = $__tagembed__user_details->email; |
| 844 | 674 | $param['name'] = $__tagembed__user_details->name; |
| @@ -848,12 +678,12 @@ | ||
| 848 | 678 | $response = __tagembed__manageApiResponse($response); |
| 849 | 679 | return __tagembed__exitWithSuccess(["__tagembed__requestCallBackUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL, "redirectUrl" => TAGEMBED_PLUGIN_API_URL . "apiaccount/makepayment", "__tagembed__paymentData" => $response->__tagembed__paymentData]); |
| 850 | 680 | break; |
| 851 | 681 | case "__tagembed__cancel_subscription": |
| 852 | - if (empty($__tagembed__user_details) || empty($data->planId)) | |
| 682 | + if (empty($__tagembed__user_details) || empty($data->plan)) | |
| 853 | 683 | return __tagembed__exitWithDanger(); |
| 854 | 684 | /* --Start-- Manage Param Data */ |
| 855 | - $param['planId'] = sanitize_key($data->planId); | |
| 685 | + $param['plan'] = sanitize_key($data->plan); | |
| 856 | 686 | /* --Start-- Manage Param Data */ |
| 857 | 687 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 858 | 688 | $param['email'] = $__tagembed__user_details->email; |
| 859 | 689 | $param['name'] = $__tagembed__user_details->name; |
| @@ -955,8 +785,36 @@ | ||
| 955 | 785 | $response->installedPluginVersion = $installedPluginVersion; |
| 956 | 786 | $response->pluginUpgradeURL = admin_url() . "plugins.php"; |
| 957 | 787 | return __tagembed__exitWithSuccess($response); |
| 958 | 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; | |
| 959 | 817 | case "__tagembed__check_user_token": |
| 960 | 818 | if (empty($__tagembed__user_details)) |
| 961 | 819 | return __tagembed__exitWithDanger(); |
| 962 | 820 | /* --Start-- Manage Param Data */ |
| @@ -1038,9 +896,8 @@ | ||
| 1038 | 896 | /* --Start-- Manage Param Data */ |
| 1039 | 897 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1040 | 898 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1041 | 899 | $param['personalizationId'] = sanitize_key($data->personalizationId); |
| 1042 | - $param['inheritStyles'] = sanitize_key($data->inheritStyles); | |
| 1043 | 900 | $param['themeRuleId'] = sanitize_key($data->themeRuleId); |
| 1044 | 901 | $param['fontColor'] = $data->fontColor; |
| 1045 | 902 | $param['authorColor'] = $data->authorColor; |
| 1046 | 903 | $param['cardColor'] = $data->cardColor; |
| @@ -1073,33 +930,25 @@ | ||
| 1073 | 930 | unset($param); |
| 1074 | 931 | $response = __tagembed__manageApiResponse($response); |
| 1075 | 932 | return __tagembed__exitWithSuccess($response); |
| 1076 | 933 | break; |
| 1077 | - case "__tagembed__get_and_manage_intercom_chat_setting": | |
| 1078 | - if (empty($__tagembed__user_details)) | |
| 1079 | - return __tagembed__exitWithDanger(); | |
| 1080 | - /* --Start-- Manage Param Data */ | |
| 1081 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1082 | - /* --End-- Manage Param Data */ | |
| 1083 | - $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getIntercomSettingData', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1084 | - unset($param); | |
| 1085 | - $response = __tagembed__manageApiResponse($response); | |
| 1086 | - return __tagembed__exitWithSuccess($response); | |
| 1087 | - break; | |
| 1088 | 934 | default: |
| 1089 | 935 | return __tagembed__exitWithDanger(); |
| 1090 | 936 | endswitch; |
| 1091 | 937 | } |
| 1092 | 938 | /* --End-- Manage Ajax Calls */ |
| 939 | + | |
| 1093 | 940 | /* --Start-- Manage Login And Register On Plugin Activate */ |
| 1094 | 941 | function __tagembed__manageLoginAndRegisterOnPluginActivate() { |
| 1095 | 942 | global $wpdb; |
| 1096 | 943 | $__tagembed__activeUserData = wp_get_current_user(); |
| 1097 | - if (empty($__tagembed__activeUserData->roles) || $__tagembed__activeUserData->roles[0] != "administrator") | |
| 944 | + if ($__tagembed__activeUserData->roles[0] != "administrator") | |
| 1098 | 945 | return false; |
| 946 | + | |
| 1099 | 947 | if (!empty($__tagembed__activeUserData->data->user_email) && !empty($__tagembed__activeUserData->data->display_name)): |
| 1100 | 948 | $__tagembed__activeUserName = $__tagembed__activeUserData->data->display_name; |
| 1101 | 949 | $__tagembed__activeUserEmail = $__tagembed__activeUserData->data->user_email; |
| 950 | + | |
| 1102 | 951 | /* --Start-- Mange Other Active Options */ |
| 1103 | 952 | $__tagembed__activeOptions = __tagembed__getActiveOptions(); |
| 1104 | 953 | if (!empty($__tagembed__activeOptions[0]->email)): |
| 1105 | 954 | if (empty($__tagembed__activeOptions[0]->isLogin) || $__tagembed__activeOptions[0]->isLogin == "no") |
| @@ -1108,15 +957,25 @@ | ||
| 1108 | 957 | endif; |
| 1109 | 958 | /* --End-- Mange Other Active Options */ |
| 1110 | 959 | $param = []; |
| 1111 | 960 | /* --Start-- Manage Param Data */ |
| 961 | + $param['fullName'] = sanitize_text_field($__tagembed__activeUserName); | |
| 1112 | 962 | $param['emailId'] = sanitize_email($__tagembed__activeUserEmail); |
| 963 | + $param['password'] = "TagembedWordpressUserPassword"; | |
| 1113 | 964 | /* --End-- Manage Param Data */ |
| 1114 | - $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/checkUserExistOrNotAndGetData', $param); | |
| 965 | + $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/register', $param); | |
| 1115 | 966 | $response = __tagembed__manageApiResponse($response); |
| 1116 | 967 | unset($param); |
| 1117 | - if (!empty($response->userId)) | |
| 968 | + if (!empty($response->userId)): | |
| 969 | + /* --Start--Mange Frist Widget Create Process */ | |
| 970 | + if ($response->createFirstWidget): | |
| 971 | + $param = ['userId' => sanitize_key($response->userId)]; | |
| 972 | + __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $response->accessToken]); | |
| 973 | + endif; | |
| 974 | + /* --End--Mange Frist Widget Create Process */ | |
| 1118 | 975 | __tagembed__login($response); /* After Register Manage User Login Process */ |
| 976 | + endif; | |
| 977 | + | |
| 1119 | 978 | endif; |
| 1120 | 979 | } |
| 1121 | 980 | /* --End-- Manage Login And Register On Plugin Activate */ |
| 1122 | 981 | |
| @@ -1125,18 +984,21 @@ | ||
| 1125 | 984 | global $wpdb; |
| 1126 | 985 | $return = false; |
| 1127 | 986 | $user = __tagembed__user($response->emailId); |
| 1128 | 987 | if (empty($user->email)): |
| 1129 | - if ($wpdb->query($wpdb->prepare("INSERT INTO wp_tagembed_user (userId, name, email, accessToken, isLogin) VALUES (%d, %s, %s, %s, %s)", $response->userId, $response->name, $response->emailId, $response->accessToken, 'yes'))): | |
| 988 | + if ($wpdb->insert('wp_tagembed_user', ["userId" => $response->userId, "name" => $response->name, "email" => $response->emailId, "accessToken" => $response->accessToken, "isLogin" => "yes"])): | |
| 1130 | 989 | $return = true; |
| 1131 | 990 | endif; |
| 1132 | 991 | else: |
| 1133 | - if ($wpdb->query($wpdb->prepare("UPDATE wp_tagembed_user SET userId = %d, name = %s, email = %s, accessToken = %s, isLogin = %s WHERE email = %s", $response->userId, $response->name, $response->emailId, $response->accessToken, 'yes', $response->emailId))): | |
| 992 | + if ($wpdb->update('wp_tagembed_user', ["userId" => $response->userId, "name" => $response->name, "email" => $response->emailId, "accessToken" => $response->accessToken, "isLogin" => "yes",], ['email' => $response->emailId])): | |
| 1134 | 993 | $return = true; |
| 1135 | 994 | endif; |
| 1136 | 995 | endif; |
| 1137 | 996 | __tagembed__manageActiveOptions($response->emailId, "yes"); /* Manage Active Options */ |
| 1138 | 997 | if ($return): |
| 998 | + if (count($response->collaboratorlist)): | |
| 999 | + __tagembed__manageCollaborator($response->collaboratorlist, $response->userId); | |
| 1000 | + endif; | |
| 1139 | 1001 | __tagembed__manageActiveWidgetsUser($response->userId); |
| 1140 | 1002 | endif; |
| 1141 | 1003 | return $return; |
| 1142 | 1004 | } |
| @@ -1142,18 +1004,18 @@ | ||
| 1142 | 1004 | } |
| 1143 | 1005 | /* --End-- Login */ |
| 1144 | 1006 | |
| 1145 | 1007 | /* --Start-- Manage Active Options */ |
| 1146 | -function __tagembed__manageActiveOptions($email = null, $other = null) { | |
| 1008 | +function __tagembed__manageActiveOptions($email = NULL, $other = NULL) { | |
| 1147 | 1009 | global $wpdb; |
| 1148 | - if ($email == null && $other != null): | |
| 1149 | - $wpdb->query($wpdb->prepare("UPDATE wp_tagembed_active_options SET isLogin = %s WHERE id = %d", $other, 1)); | |
| 1010 | + if ($email == NULL && $other != NULL): | |
| 1011 | + $wpdb->update('wp_tagembed_active_options', ["isLogin" => $other], ['id' => 1]); | |
| 1150 | 1012 | else: |
| 1151 | - $__tagembed__activeOptions = $wpdb->get_results($wpdb->prepare("SELECT email FROM wp_tagembed_active_options WHERE id = %d", 1)); | |
| 1013 | + $__tagembed__activeOptions = $wpdb->get_results("SELECT email FROM wp_tagembed_active_options WHERE(id = 1)"); | |
| 1152 | 1014 | if (empty($__tagembed__activeOptions[0]->email)): |
| 1153 | - $wpdb->query($wpdb->prepare("INSERT INTO wp_tagembed_active_options (email, isLogin) VALUES (%s, %s)", $email, $other)); | |
| 1015 | + $wpdb->insert('wp_tagembed_active_options', ["email" => $email, "isLogin" => $other]); | |
| 1154 | 1016 | else: |
| 1155 | - $wpdb->query($wpdb->prepare("UPDATE wp_tagembed_active_options SET email = %s, isLogin = %s WHERE id = %d", $email, $other, 1)); | |
| 1017 | + $wpdb->update('wp_tagembed_active_options', ["email" => $email, "isLogin" => $other], ['id' => 1]); | |
| 1156 | 1018 | endif; |
| 1157 | 1019 | endif; |
| 1158 | 1020 | } |
| 1159 | 1021 | /* --End-- Manage Active Options */ |
| @@ -1159,9 +1021,9 @@ | ||
| 1159 | 1021 | /* --End-- Manage Active Options */ |
| 1160 | 1022 | /* --Start--Get User Last Login Email Id */ |
| 1161 | 1023 | function __tagembed__getActiveOptions() { |
| 1162 | 1024 | global $wpdb; |
| 1163 | - $__tagembed__activeOptions = $wpdb->get_results($wpdb->prepare("SELECT email, isLogin FROM wp_tagembed_active_options WHERE id = %d", 1)); | |
| 1025 | + $__tagembed__activeOptions = $wpdb->get_results("SELECT email,isLogin FROM wp_tagembed_active_options WHERE(id = 1)"); | |
| 1164 | 1026 | return $__tagembed__activeOptions; |
| 1165 | 1027 | } |
| 1166 | 1028 | /* --End--Get User last Login Email Id */ |
| 1167 | 1029 | /* --Start-- Logout */ |
| @@ -1166,10 +1028,10 @@ | ||
| 1166 | 1028 | /* --End--Get User last Login Email Id */ |
| 1167 | 1029 | /* --Start-- Logout */ |
| 1168 | 1030 | function tagembed_logout() { |
| 1169 | 1031 | global $wpdb; |
| 1170 | - if ($wpdb->query($wpdb->prepare("UPDATE wp_tagembed_user SET isLogin = %s WHERE isLogin = %s", "no", "yes"))): | |
| 1171 | - __tagembed__manageActiveOptions(null, "no"); /* Manage Active Options */ | |
| 1032 | + if ($wpdb->update('wp_tagembed_user', ["isLogin" => "no"], ["isLogin" => "yes"])): | |
| 1033 | + __tagembed__manageActiveOptions(NULL, "no"); /* Manage Active Options */ | |
| 1172 | 1034 | return true; |
| 1173 | 1035 | endif; |
| 1174 | 1036 | return false; |
| 1175 | 1037 | } |
| @@ -1179,11 +1041,11 @@ | ||
| 1179 | 1041 | global $wpdb; |
| 1180 | 1042 | if (empty($__tagembed__menu_condatation)) |
| 1181 | 1043 | return $wpdb->get_results("SELECT * FROM wp_tagembed_menus"); |
| 1182 | 1044 | if (array_key_exists('__tagembed__menu_condation', $__tagembed__menu_condatation)) |
| 1183 | - return $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_tagembed_menus WHERE status = %s", $__tagembed__menu_condatation['__tagembed__menu_condation'])); | |
| 1045 | + return $wpdb->get_results("SELECT * FROM wp_tagembed_menus WHERE " . $__tagembed__menu_condatation['__tagembed__menu_condation']); | |
| 1184 | 1046 | if (array_key_exists('__tagembed__menu_id', $__tagembed__menu_condatation)): |
| 1185 | - if ($wpdb->query($wpdb->prepare("UPDATE wp_tagembed_menus SET status = %d WHERE status = %d", 0, 1)) && $wpdb->query($wpdb->prepare("UPDATE wp_tagembed_menus SET status = %d WHERE id = %d", 1, $__tagembed__menu_condatation['__tagembed__menu_id']))) | |
| 1047 | + if ($wpdb->update('wp_tagembed_menus', ["status" => 0], ["status" => 1]) && $wpdb->update('wp_tagembed_menus', ["status" => 1], ["id" => $__tagembed__menu_condatation['__tagembed__menu_id']])) | |
| 1186 | 1048 | return true; |
| 1187 | 1049 | return false; |
| 1188 | 1050 | endif; |
| 1189 | 1051 | } |
| @@ -1192,11 +1054,11 @@ | ||
| 1192 | 1054 | function __tagembed__user($email = null) { |
| 1193 | 1055 | global $wpdb; |
| 1194 | 1056 | $__tagembed__userResponse = ""; |
| 1195 | 1057 | if (empty($email)): |
| 1196 | - $__tagembed__userResponse = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_tagembed_user WHERE isLogin = %s", 'yes')); | |
| 1058 | + $__tagembed__userResponse = $wpdb->get_results("SELECT * FROM wp_tagembed_user WHERE(isLogin = 'yes')"); | |
| 1197 | 1059 | else: |
| 1198 | - $__tagembed__userResponse = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_tagembed_user WHERE email = %s", $email)); | |
| 1060 | + $__tagembed__userResponse = $wpdb->get_results("SELECT * FROM wp_tagembed_user WHERE(email = '" . $email . "')"); | |
| 1199 | 1061 | endif; |
| 1200 | 1062 | if (!empty($__tagembed__userResponse)) |
| 1201 | 1063 | return $__tagembed__userResponse[0]; |
| 1202 | 1064 | return; |
| @@ -1209,8 +1071,45 @@ | ||
| 1209 | 1071 | return $__tagembed__user_dataResponse[0]; |
| 1210 | 1072 | return; |
| 1211 | 1073 | } |
| 1212 | 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 */ | |
| 1213 | 1112 | /* --Start-- Get Widget */ |
| 1214 | 1113 | function __tagembed__widgets() { |
| 1215 | 1114 | $returnWidgetData = []; |
| 1216 | 1115 | $__tagembed__user_details = __tagembed__user(); |
| @@ -1242,12 +1141,12 @@ | ||
| 1242 | 1141 | $activeWidgetUserId = __tagembed__activeWidget(); |
| 1243 | 1142 | if ($activeWidgetUserId == $widgetId) |
| 1244 | 1143 | return true; |
| 1245 | 1144 | if (empty($activeWidgetUserId)): |
| 1246 | - $wpdb->query($wpdb->prepare("INSERT INTO wp_tagembed_active_widget (widgetId) VALUES (%s)", $widgetId)); | |
| 1145 | + $wpdb->insert('wp_tagembed_active_widget', ["widgetId" => $widgetId]); | |
| 1247 | 1146 | return true; |
| 1248 | 1147 | else: |
| 1249 | - $wpdb->query($wpdb->prepare("UPDATE wp_tagembed_active_widget SET widgetId = %s WHERE id = %d", $widgetId, 1)); | |
| 1148 | + $wpdb->update('wp_tagembed_active_widget', ["widgetId" => $widgetId], ['id' => 1]); | |
| 1250 | 1149 | return true; |
| 1251 | 1150 | endif; |
| 1252 | 1151 | return false; |
| 1253 | 1152 | } |
| @@ -1256,11 +1155,10 @@ | ||
| 1256 | 1155 | function __tagembed__activeWidgetUser() { |
| 1257 | 1156 | global $wpdb; |
| 1258 | 1157 | $__tagembed__activeWidgetUserResponse = ""; |
| 1259 | 1158 | $__tagembed__activeWidgetUserResponse = $wpdb->get_results("SELECT * FROM wp_tagembed_active_widget_user"); |
| 1260 | - if (!empty($__tagembed__activeWidgetUserResponse)): | |
| 1159 | + if (!empty($__tagembed__activeWidgetUserResponse)) | |
| 1261 | 1160 | return $__tagembed__activeWidgetUserResponse[0]->userId; |
| 1262 | - endif; | |
| 1263 | 1161 | return; |
| 1264 | 1162 | } |
| 1265 | 1163 | /* --End-- Get Active Widget User */ |
| 1266 | 1164 | /* --Start-- Manage Active Widget User */ |
| @@ -1270,12 +1168,12 @@ | ||
| 1270 | 1168 | $activeWidgetUserId = __tagembed__activeWidgetUser(); |
| 1271 | 1169 | if ($activeWidgetUserId == $userId) |
| 1272 | 1170 | return true; |
| 1273 | 1171 | if (empty($activeWidgetUserId)): |
| 1274 | - $wpdb->query($wpdb->prepare("INSERT INTO wp_tagembed_active_widget_user (userId) VALUES (%d)", $userId)); | |
| 1172 | + $wpdb->insert('wp_tagembed_active_widget_user', ["userId" => $userId]); | |
| 1275 | 1173 | return true; |
| 1276 | 1174 | else: |
| 1277 | - $wpdb->query($wpdb->prepare("UPDATE wp_tagembed_active_widget_user SET userId = %d WHERE id = %d", $userId, 1)); | |
| 1175 | + $wpdb->update('wp_tagembed_active_widget_user', ["userId" => $userId], ['id' => 1]); | |
| 1278 | 1176 | return true; |
| 1279 | 1177 | endif; |
| 1280 | 1178 | return false; |
| 1281 | 1179 | } |
| @@ -1285,25 +1183,22 @@ | ||
| 1285 | 1183 | function __tagembed__createDatabaseTableForPlugin() { |
| 1286 | 1184 | global $wpdb; |
| 1287 | 1185 | require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 1288 | 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"); | |
| 1289 | 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"); |
| 1290 | 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"); |
| 1291 | 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"); |
| 1292 | 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"); |
| 1293 | - /* --Start-- Manage Tagembed Plugin Menus */ | |
| 1294 | - $__tagembed__checkAlreadyExistMenusDataExistOrNot = $wpdb->get_results("SELECT id FROM wp_tagembed_menus"); | |
| 1295 | - if (empty($__tagembed__checkAlreadyExistMenusDataExistOrNot)): | |
| 1296 | - $__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']]; | |
| 1297 | - foreach ($__tagembed__menus as $__tagembed__menu): | |
| 1298 | - $wpdb->query($wpdb->prepare("INSERT INTO wp_tagembed_menus (name, status, path) VALUES (%s, %s, %s)", $__tagembed__menu['name'], $__tagembed__menu['status'], $__tagembed__menu['path'])); | |
| 1299 | - endforeach; | |
| 1300 | - endif; | |
| 1301 | - /* --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']]); | |
| 1302 | 1196 | } |
| 1303 | 1197 | function __tagembed__dropDatabaseTablesForPlugin() { |
| 1304 | 1198 | global $wpdb; |
| 1305 | 1199 | $wpdb->query("DROP table IF EXISTS wp_tagembed_user"); |
| 1200 | + $wpdb->query("DROP table IF EXISTS wp_tagembed_collaborator"); | |
| 1306 | 1201 | $wpdb->query("DROP table IF EXISTS wp_tagembed_active_widget_user"); |
| 1307 | 1202 | $wpdb->query("DROP table IF EXISTS wp_tagembed_active_widget"); |
| 1308 | 1203 | $wpdb->query("DROP table IF EXISTS wp_tagembed_menus"); |
| 1309 | 1204 | } |
| @@ -1324,15 +1219,11 @@ | ||
| 1324 | 1219 | /* register_deactivation_hook(__FILE__, '__tagembed__pluginDeactivate'); |
| 1325 | 1220 | function __tagembed__pluginDeactivate() { |
| 1326 | 1221 | __tagembed__dropDatabaseTablesForPlugin(); |
| 1327 | 1222 | } */ |
| 1328 | - | |
| 1329 | 1223 | /* --End-- Manage Active Deactive And Uninstall Webhook */ |
| 1330 | 1224 | /* --Start--Manage Redirect After Plugin Activate */ |
| 1331 | 1225 | function __tagembed__plginActivationRedirect() { |
| 1332 | - $__tagembed__activeUserData = wp_get_current_user(); | |
| 1333 | - if (empty($__tagembed__activeUserData->roles)) | |
| 1334 | - return false; | |
| 1335 | 1226 | exit(wp_redirect(TAGEMBED_PLUGIN_CALL_BACK_URL)); |
| 1336 | 1227 | } |
| 1337 | 1228 | /* --End--Manage Redirect After Plugin Activate */ |
| 1338 | 1229 | /* --Start--Manage Setting Link */ |
| @@ -1349,25 +1240,34 @@ | ||
| 1349 | 1240 | __tagembed__manageLoginAndRegisterOnPluginActivate(); |
| 1350 | 1241 | } |
| 1351 | 1242 | add_action('upgrader_process_complete', '__tagembed__manageDatabaseOnPluginUpdateTime', 10, 2); |
| 1352 | 1243 | /* --End--Manage Database On Plugin Update Time */ |
| 1353 | -/* --Sart--Get And Manage Social Accout Id */ | |
| 1354 | -function __tagembed__get_user_social_account_id() { | |
| 1355 | - $__tagembed__user_details = __tagembed__user(); | |
| 1356 | - $param['userId'] = $__tagembed__user_details->userId; | |
| 1357 | - $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getsocialaccountid', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1358 | - if (isset($response->head->status)): | |
| 1359 | - if ($response->head->status): | |
| 1360 | - $response = __tagembed__manageApiResponse($response); | |
| 1361 | - if (!empty($response->userId)): | |
| 1362 | - return $response->userId; | |
| 1244 | +/* --Sart--Manage Chat Hide And Show */ | |
| 1245 | +function __tagembed__chat() { | |
| 1246 | + $returnData = false; | |
| 1247 | + TRY { | |
| 1248 | + $response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/chat', ['pluginName' => 'wordpress'], ['Authorization: __tagembed__']); | |
| 1249 | + if (isset($response->head->status)): | |
| 1250 | + if ($response->head->status): | |
| 1251 | + $response = __tagembed__manageApiResponse($response); | |
| 1252 | + if (!empty($response->chat) && is_array($response->chat)): | |
| 1253 | + foreach ($response->chat as $chat): | |
| 1254 | + if ($chat->location == "all"): | |
| 1255 | + $returnData = "all"; | |
| 1256 | + elseif ($chat->location == "inner"): | |
| 1257 | + $returnData = "inner"; | |
| 1258 | + endif; | |
| 1259 | + endforeach; | |
| 1260 | + endif; | |
| 1363 | 1261 | endif; |
| 1364 | 1262 | endif; |
| 1365 | - endif; | |
| 1366 | - return false; | |
| 1263 | + } CATCH (Exception $e) { | |
| 1264 | + | |
| 1265 | + } | |
| 1266 | + return $returnData; | |
| 1367 | 1267 | } |
| 1368 | 1268 | /* --End--Manage Chat Hide And Show */ |
| 1369 | -/* --Start-- Show Admin General Notification After Login And Register */ | |
| 1269 | +/* --Start-- Manage Hide And Show Admin Notificationa */ | |
| 1370 | 1270 | function __tagembed__generalAdminNotice() { |
| 1371 | 1271 | $__tagmebed__page_name = ""; |
| 1372 | 1272 | if (!empty($_GET['page'])): |
| 1373 | 1273 | $__tagmebed__page_name = __tagembed__sanitizeRequestData($_GET); |
| @@ -1392,9 +1292,9 @@ | ||
| 1392 | 1292 | $htmlData .= '<p>' . $notifications->message . '</p>'; |
| 1393 | 1293 | $htmlData .= '</div>'; |
| 1394 | 1294 | endif; |
| 1395 | 1295 | endforeach; |
| 1396 | - echo wp_kses_post($htmlData); | |
| 1296 | + echo $htmlData; | |
| 1397 | 1297 | endif; |
| 1398 | 1298 | endif; |
| 1399 | 1299 | endif; |
| 1400 | 1300 | } CATCH (Exception $e) { |
| @@ -1411,28 +1311,24 @@ | ||
| 1411 | 1311 | if ($__tagmebed__page_name == "tagembed"): |
| 1412 | 1312 | remove_all_actions('admin_notices'); |
| 1413 | 1313 | remove_all_actions('all_admin_notices'); |
| 1414 | 1314 | endif; |
| 1415 | - if (!empty(__tagembed__user())): | |
| 1416 | - add_action('admin_notices', '__tagembed__generalAdminNotice'); | |
| 1417 | - endif; | |
| 1315 | + add_action('admin_notices', '__tagembed__generalAdminNotice'); | |
| 1418 | 1316 | } |
| 1419 | -/* --End-- Show Admin General Notification After Login And Register */ | |
| 1420 | - | |
| 1317 | +/* --End-- Manage Hide And Show Admin Notificationa */ | |
| 1421 | 1318 | /* --End-- Drop Database Table */ |
| 1422 | 1319 | /* --Start-- Create Short Code */ |
| 1320 | +add_shortcode("tagembed", "__tagembed__PluginShortCode"); | |
| 1423 | 1321 | function __tagembed__PluginShortCode($attr) { |
| 1424 | - extract(shortcode_atts(['width' => '', 'height' => '',], $attr, 'tagembed')); | |
| 1425 | 1322 | $widgetId = (isset($attr[1]) ? $attr[1] : ''); |
| 1426 | - if (!empty($widgetId) && is_numeric($widgetId) && (($width === '' || preg_match('/^\d+(px|%|)$/', $width)) && ($height === '' || preg_match('/^\d+(px|%|)$/', $height)))): | |
| 1427 | - $output = '<span class=""></span>'; | |
| 1428 | - $output .= '<div style="width:' . $width . '; height:' . $height . ';overflow: auto;" class="tagembed-container">'; | |
| 1429 | - $output .= '<div style="width:100%; height:100%;" class="tagembed-socialwall tagembed-analystic" data-wall-id="' . $widgetId . '"></div>'; | |
| 1430 | - $output .= '</div>'; | |
| 1431 | - else: | |
| 1432 | - $output = '<span style="display: block;text-align: center;border: 1px solid #eee;padding: 5px 15px;background-color: #fafafa;">Invalid Parameters Provided In The Tagembed Shortcode.</span>'; | |
| 1433 | - endif; | |
| 1434 | - return $output; | |
| 1323 | + $width = (isset($attr['width']) ? $attr['width'] : ''); | |
| 1324 | + $height = (isset($attr['height']) ? $attr['height'] : ''); | |
| 1325 | + $code = '<span class=""></span>'; | |
| 1326 | + $code .= '<div style="width:' . $width . '; height:' . $height . ';overflow: auto;" class="tagembed-container">'; | |
| 1327 | + $code .= '<div style="width:100%; height:100%;" class="tagembed-socialwall tagembed-analystic" data-wall-id="' . $widgetId . '"></div>'; | |
| 1328 | + $code .= '</div>'; | |
| 1329 | + return $code; | |
| 1435 | 1330 | } |
| 1436 | -add_shortcode("tagembed", "__tagembed__PluginShortCode"); | |
| 1437 | 1331 | /* --End-- Create Short Code */ |
| 1332 | + | |
| 1333 | + | |
| 1438 | 1334 | |