| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | /** |
| 4 | 4 | * Plugin Name: Tagembed: Social Media Feeds and Customer Reviews Widget |
| 5 | 5 | * Plugin URI: https://tagembed.com/ |
| 6 | 6 | * Description: Display social media feeds and user-generated content in an interactive widget. |
| 7 | - * Version: 7.8 | |
| 7 | + * Version: 8.1 | |
| 8 | 8 | * Author: Tagembed |
| 9 | 9 | * Author URI: https://tagembed.com/ |
| 10 | 10 | * License: GPLv3 |
| 11 | 11 | * License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| @@ -15,9 +15,9 @@ | ||
| 15 | 15 | die; |
| 16 | 16 | endif; |
| 17 | 17 | |
| 18 | 18 | /* --Start-- Create Constant */ |
| 19 | -!defined('TAGEMBED_PLUGIN_VERSION') && define('TAGEMBED_PLUGIN_VERSION', '7.8'); | |
| 19 | +!defined('TAGEMBED_PLUGIN_VERSION') && define('TAGEMBED_PLUGIN_VERSION', '8.1'); | |
| 20 | 20 | !defined('TAGEMBED_PLUGIN_DIR_PATH') && define('TAGEMBED_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__)); |
| 21 | 21 | !defined('TAGEMBED_PLUGIN_URL') && define('TAGEMBED_PLUGIN_URL', plugin_dir_url(__FILE__)); |
| 22 | 22 | !defined('TAGEMBED_PLUGIN_REDIRECT_URL') && define('TAGEMBED_PLUGIN_REDIRECT_URL', get_admin_url(null, 'admin.php?page=')); |
| 23 | 23 | |
| @@ -180,8 +180,9 @@ | ||
| 180 | 180 | $param['emailId'] = sanitize_email($data->emailId); |
| 181 | 181 | $param['password'] = $data->password; |
| 182 | 182 | $param['contact_no'] = $data->contact_no; |
| 183 | 183 | $param['calling_code'] = $data->calling_code; |
| 184 | + $param['timezone'] = !empty($data->timezone) ? sanitize_text_field($data->timezone) : ''; | |
| 184 | 185 | $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 185 | 186 | /* --End-- Manage Param Data */ |
| 186 | 187 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/register', $param, []); |
| 187 | 188 | $response = ___tagembed__manageApiResponse($response); |
| @@ -254,8 +255,64 @@ | ||
| 254 | 255 | unset($param); |
| 255 | 256 | $response = ___tagembed__manageApiResponse($response); |
| 256 | 257 | return ___tagembed__exitWithSuccess($response); |
| 257 | 258 | break; |
| 259 | + case '__tagembed__get_cards': | |
| 260 | + if (empty($__tagembed__user_details)) : | |
| 261 | + return ___tagembed__exitWithDanger(); | |
| 262 | + endif; | |
| 263 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 264 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 265 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getcards', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 266 | + unset($param); | |
| 267 | + $response = ___tagembed__manageApiResponse($response); | |
| 268 | + return ___tagembed__exitWithSuccess($response); | |
| 269 | + break; | |
| 270 | + case '__tagembed__card_session': | |
| 271 | + if (empty($__tagembed__user_details)) : | |
| 272 | + return ___tagembed__exitWithDanger(); | |
| 273 | + endif; | |
| 274 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 275 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 276 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/cardsession', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 277 | + unset($param); | |
| 278 | + $response = ___tagembed__manageApiResponse($response); | |
| 279 | + return ___tagembed__exitWithSuccess($response); | |
| 280 | + break; | |
| 281 | + case '__tagembed__get_plan_status': | |
| 282 | + if (empty($__tagembed__user_details)) : | |
| 283 | + return ___tagembed__exitWithDanger(); | |
| 284 | + endif; | |
| 285 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 286 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 287 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/planstatus', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 288 | + unset($param); | |
| 289 | + $response = ___tagembed__manageApiResponse($response); | |
| 290 | + return ___tagembed__exitWithSuccess($response); | |
| 291 | + break; | |
| 292 | + case '__tagembed__get_invoice_pdf': | |
| 293 | + if (empty($__tagembed__user_details) || empty($data->invoiceId)) : | |
| 294 | + return ___tagembed__exitWithDanger(); | |
| 295 | + endif; | |
| 296 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 297 | + $param['invoiceId'] = sanitize_text_field($data->invoiceId); | |
| 298 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 299 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/invoicepdf', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 300 | + unset($param); | |
| 301 | + $response = ___tagembed__manageApiResponse($response); | |
| 302 | + return ___tagembed__exitWithSuccess($response); | |
| 303 | + break; | |
| 304 | + case '__tagembed__get_invoices': | |
| 305 | + if (empty($__tagembed__user_details)) : | |
| 306 | + return ___tagembed__exitWithDanger(); | |
| 307 | + endif; | |
| 308 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 309 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 310 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getinvoices', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 311 | + unset($param); | |
| 312 | + $response = ___tagembed__manageApiResponse($response); | |
| 313 | + return ___tagembed__exitWithSuccess($response); | |
| 314 | + break; | |
| 258 | 315 | case '__tagembed__get_account_details': |
| 259 | 316 | $data->auth = !empty($data->auth) ? 1 : 0; |
| 260 | 317 | if (empty($__tagembed__user_details)) : |
| 261 | 318 | return ___tagembed__exitWithDanger(); |
| @@ -705,44 +762,35 @@ | ||
| 705 | 762 | endswitch; |
| 706 | 763 | break; |
| 707 | 764 | case 10: |
| 708 | 765 | if (in_array($__tagembed__feed_filter_id, [1, 16, 17])) : |
| 709 | - if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 766 | + if (!preg_match('/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 710 | 767 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); |
| 711 | 768 | endif; |
| 712 | 769 | endif; |
| 713 | 770 | switch ($__tagembed__feed_filter_id): |
| 714 | 771 | case 16: |
| 715 | - $postUrl = parse_url($data->feed); | |
| 716 | - if (!strstr($postUrl['host'], 'linkedin')) : | |
| 717 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); | |
| 772 | + $__tagembed__postHostUrl = wp_parse_url($data->feed, PHP_URL_HOST); | |
| 773 | + $__tagembed__postHostUrl = is_string($__tagembed__postHostUrl) ? strtolower($__tagembed__postHostUrl) : ''; | |
| 774 | + if ($__tagembed__postHostUrl === 'lnkd.in' || substr($__tagembed__postHostUrl, -8) === '.lnkd.in') : | |
| 775 | + $__tagembed__expandedPostUrl = ___tagembed__expandLinkedinShortUrl($data->feed); | |
| 776 | + if (!empty($__tagembed__expandedPostUrl)) : | |
| 777 | + $data->feed = $__tagembed__expandedPostUrl; | |
| 778 | + $__tagembed__postHostUrl = wp_parse_url($data->feed, PHP_URL_HOST); | |
| 779 | + $__tagembed__postHostUrl = is_string($__tagembed__postHostUrl) ? strtolower($__tagembed__postHostUrl) : ''; | |
| 780 | + endif; | |
| 718 | 781 | endif; |
| 719 | - $postUrl = $data->feed; | |
| 720 | - $postUrl = rtrim($postUrl, '/'); | |
| 721 | - preg_match('/[^\/]+$/', $postUrl, $postId); | |
| 722 | - $postId = $postId[0]; | |
| 723 | - $postId = (explode('?', $postId)[0]); | |
| 724 | - $value1 = 'LinkedIn'; | |
| 725 | - if (stripos($postId, 'activity') !== false) : | |
| 726 | - $postId = (explode('activity', $postId)[1]); | |
| 727 | - $value2 = 'activity'; | |
| 728 | - elseif (stripos($postId, 'ugcPost') !== false) : | |
| 729 | - $postId = (explode('ugcPost', $postId)[1]); | |
| 730 | - $value2 = 'ugcPost'; | |
| 731 | - else : | |
| 782 | + if (!strstr($__tagembed__postHostUrl, 'linkedin')) : | |
| 732 | 783 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); |
| 733 | 784 | endif; |
| 734 | - preg_match_all('!\d+!', $postId, $postId); | |
| 735 | - if (isset($postId[0][0]) && empty($postId[0][0])) : | |
| 785 | + $__tagembed__parsedPost = ___tagembed__parseLinkedinPostUrl($data->feed); | |
| 786 | + if (empty($__tagembed__parsedPost['value2']) || empty($__tagembed__parsedPost['value3'])) : | |
| 736 | 787 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); |
| 737 | 788 | endif; |
| 738 | - $value3 = $postId[0][0]; | |
| 739 | - if (empty($value1) || empty($value2) || empty($value3)) : | |
| 740 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); | |
| 741 | - endif; | |
| 742 | - $__tagembed__feed_input_data['value1'] = $value1; | |
| 743 | - $__tagembed__feed_input_data['value2'] = $value2; | |
| 744 | - $__tagembed__feed_input_data['value3'] = $value3; | |
| 789 | + $__tagembed__feed_input_data['feed'] = sanitize_text_field($data->feed); | |
| 790 | + $__tagembed__feed_input_data['value1'] = 'LinkedIn'; | |
| 791 | + $__tagembed__feed_input_data['value2'] = $__tagembed__parsedPost['value2']; | |
| 792 | + $__tagembed__feed_input_data['value3'] = $__tagembed__parsedPost['value3']; | |
| 745 | 793 | break; |
| 746 | 794 | case 1: |
| 747 | 795 | case 17: |
| 748 | 796 | $url = parse_url($data->feed); |
| @@ -958,8 +1006,20 @@ | ||
| 958 | 1006 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getpaymentdetails', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 959 | 1007 | unset($param); |
| 960 | 1008 | $response = ___tagembed__manageApiResponse($response); |
| 961 | 1009 | return ___tagembed__exitWithSuccess(['__tagembed__requestCallBackUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL, 'redirectUrl' => TAGEMBED_PLUGIN_API_URL . 'apiaccount/makepayment', '__tagembed__paymentData' => $response->__tagembed__paymentData]); |
| 1010 | + break; | |
| 1011 | + case '__tagembed__resume_subscription': | |
| 1012 | + if (empty($__tagembed__user_details)) : | |
| 1013 | + return ___tagembed__exitWithDanger(); | |
| 1014 | + endif; | |
| 1015 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1016 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 1017 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/resumesubscription', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1018 | + unset($param); | |
| 1019 | + $response = ___tagembed__manageApiResponse($response); | |
| 1020 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 1021 | + return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 962 | 1022 | break; |
| 963 | 1023 | case '__tagembed__cancel_subscription': |
| 964 | 1024 | if (empty($__tagembed__user_details) || empty($data->planId)) : |
| 965 | 1025 | return ___tagembed__exitWithDanger(); |