| @@ -1,1550 +1,1623 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Plugin Name: Tagembed: Social Media Feeds and Customer Reviews Widget | |
| 5 | - * Plugin URI: https://tagembed.com/ | |
| 6 | - * Description: Display social media feeds and user-generated content in an interactive widget. | |
| 7 | - * Version: 7.7 | |
| 8 | - * Author: Tagembed | |
| 9 | - * Author URI: https://tagembed.com/ | |
| 10 | - * License: GPLv3 | |
| 11 | - * License URI: https://www.gnu.org/licenses/gpl-3.0.html | |
| 12 | - * Text Domain: tagembed-widget | |
| 13 | - */ | |
| 14 | -if (!defined('WPINC')) : | |
| 15 | - die; | |
| 16 | -endif; | |
| 17 | - | |
| 18 | -/* --Start-- Create Constant */ | |
| 19 | -!defined('TAGEMBED_PLUGIN_VERSION') && define('TAGEMBED_PLUGIN_VERSION', '7.7'); | |
| 20 | -!defined('TAGEMBED_PLUGIN_DIR_PATH') && define('TAGEMBED_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__)); | |
| 21 | -!defined('TAGEMBED_PLUGIN_URL') && define('TAGEMBED_PLUGIN_URL', plugin_dir_url(__FILE__)); | |
| 22 | -!defined('TAGEMBED_PLUGIN_REDIRECT_URL') && define('TAGEMBED_PLUGIN_REDIRECT_URL', get_admin_url(null, 'admin.php?page=')); | |
| 23 | - | |
| 24 | -!defined('TAGEMBED_PLUGIN_API_URL') && define('TAGEMBED_PLUGIN_API_URL', 'https://api.tagembed.com/app/'); | |
| 25 | -!defined('TAGEMBED_PLUGIN_SERVER_URL') && define('TAGEMBED_PLUGIN_SERVER_URL', 'https://api.tagembed.com/app/'); | |
| 26 | - | |
| 27 | -!defined('TAGEMBED_PLUGIN_REACT_URL') && define('TAGEMBED_PLUGIN_REACT_URL', 'https://widget.tagembed.com/'); | |
| 28 | -!defined('TAGEMBED_PLUGIN_CALL_BACK_URL') && define('TAGEMBED_PLUGIN_CALL_BACK_URL', admin_url() . 'admin.php?page=tagembed'); | |
| 29 | -!defined('TAGEMBED_PLUGIN_PLATFORM') && define('TAGEMBED_PLUGIN_PLATFORM', 'tagembed'); | |
| 30 | - | |
| 31 | -/* --End-- Create Constant */ | |
| 32 | - | |
| 33 | -/* --Start--Include Files */ | |
| 34 | -require_once TAGEMBED_PLUGIN_DIR_PATH . 'helper/helper.php'; | |
| 35 | -/* --End--Include Files */ | |
| 36 | - | |
| 37 | -/* --Start-- Add Js And Css */ | |
| 38 | -function tagembed_plugin_scripts_css() | |
| 39 | -{ | |
| 40 | - wp_enqueue_script('__tagembed__embbedJs', TAGEMBED_PLUGIN_REACT_URL . 'embed.min.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 41 | - if (is_admin()) : | |
| 42 | - /* CSS */ | |
| 43 | - wp_enqueue_style('__tagembed__commonCss', TAGEMBED_PLUGIN_URL . '/assets/css/common.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 44 | - wp_enqueue_style('__tagembed__toastCss', TAGEMBED_PLUGIN_URL . '/assets/css/toast.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 45 | - wp_enqueue_style('__tagembed__confirmDialogCss', TAGEMBED_PLUGIN_URL . '/assets/css/confirm_dialog.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 46 | - wp_enqueue_style('__tagembed__tagembedloaderCss', TAGEMBED_PLUGIN_URL . '/assets/css/loader.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 47 | - wp_enqueue_style('__tagembed__popupCss', TAGEMBED_PLUGIN_URL . '/assets/css/styles.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 48 | - /* JS */ | |
| 49 | - wp_enqueue_script('__tagembed__toastJs', TAGEMBED_PLUGIN_URL . '/assets/js/toast.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 50 | - wp_enqueue_script('__tagembed__confirmDialogJs', TAGEMBED_PLUGIN_URL . '/assets/js/confirm_dialog.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 51 | - wp_enqueue_script('__tagembed__tagemedLoaderJs', TAGEMBED_PLUGIN_URL . '/assets/js/loader.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 52 | - wp_localize_script('__tagembed__tagemedLoaderJs', '__tagembed__pluginLoaderImageUrlObj', ['__tagembed__pluginLoaderImageUrl' => TAGEMBED_PLUGIN_URL]); | |
| 53 | - wp_enqueue_script('__tagembed__deactive-js', TAGEMBED_PLUGIN_URL . '/assets/js/tagembed.deactive.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 54 | - $__tagembed__ajax_call_security_nones = wp_create_nonce('__tagembed__ajax_call_security_nones'); | |
| 55 | - wp_localize_script('__tagembed__deactive-js', '__tagembed__ajax_call_security_nones_object', ['__tagembed__ajax_call_security_nones' => $__tagembed__ajax_call_security_nones]); | |
| 56 | - wp_enqueue_script('__tagembed__tagembedDialogFormJs', TAGEMBED_PLUGIN_URL . '/assets/js/dialog.form.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 57 | - /* --Start-- Gutenberge */ | |
| 58 | - if (!function_exists('register_block_type')) : | |
| 59 | - return; | |
| 60 | - else : | |
| 61 | - wp_enqueue_style('__tagembed__editorCss', TAGEMBED_PLUGIN_URL . '/assets/css/editor/editor.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 62 | - wp_register_script('__tagembed__editor-js', TAGEMBED_PLUGIN_URL . '/assets/js/editor/editor.js', ['wp-block-editor', 'wp-blocks', 'wp-element', 'wp-components', 'wp-i18n', 'wp-data', 'wp-compose'], TAGEMBED_PLUGIN_VERSION); | |
| 63 | - register_block_type('tagembed-block/tagembed', ['editor_script' => '__tagembed__editor-js', 'editor_style' => '__tagembed__editorCss', 'style' => '']); | |
| 64 | - endif; | |
| 65 | - /* --End-- Gutenberge */ | |
| 66 | - endif; | |
| 67 | -} | |
| 68 | -add_action('init', 'tagembed_plugin_scripts_css'); | |
| 69 | -add_filter( | |
| 70 | - 'script_loader_tag', | |
| 71 | - function ($tag, $handle) { | |
| 72 | - if ('embbedJs' !== $handle) : | |
| 73 | - return $tag; | |
| 74 | - else : | |
| 75 | - return str_replace('src', 'defer src', $tag); | |
| 76 | - endif; | |
| 77 | - }, | |
| 78 | - 10, | |
| 79 | - 2 | |
| 80 | -); | |
| 81 | -/* --End-- Add Js And Css */ | |
| 82 | - | |
| 83 | -/* --Start-- Add Menus */ | |
| 84 | -function ___tagembed__plugin_menus() | |
| 85 | -{ | |
| 86 | - ob_start(); | |
| 87 | -?> | |
| 88 | - <svg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 200 200' style='enable-background:new 0 0 200 200;' xml:space='preserve'> | |
| 89 | - <title>Tagembed Icon</title> | |
| 90 | - <g transform='translate(-211 -31)'> | |
| 91 | - <g id='Group_3576' transform='translate(211 31)'> | |
| 92 | - <path id='Path_5098' fill='#00E9FF' d='M64.3,119.1c5.4-25.2,10.2-49.2,15.6-73.8c0.6-3.6,1.2-7.2,1.8-10.8c0.6-10.8-6.6-19.8-17.4-21.6c-10.8-2.4-21,4.2-23.4,15C33,63.3,25.2,99.3,18,134.7c-3,14.4,7.2,25.2,22.8,25.2c32.4,1.2,65.4,1.8,97.8,2.4c6.6,0,12.6-0.6,18.6-3c7.8-4.2,12-13.2,9.6-22.2c-2.4-9.6-10.8-16.2-20.4-16.2c-21-0.6-42.6-1.2-63.6-1.8C76.9,119.1,70.9,119.1,64.3,119.1z' /> | |
| 93 | - <path id='Path_5099' fill='#4179FF' d='M136.9,81.9c-25.8,0-50.4,0-75,0c-3.6,0-7.2,0-10.8-0.6c-10.8-1.8-18-10.8-18-21.6s9-19.8,19.8-19.8c36,0,72.6,0,109.2,0c14.4,0,22.8,12,19.8,27.6c-6,31.8-12,64.2-18,96c-1.2,6.6-3.6,12.6-7.2,17.4c-6,6.6-15.6,8.4-23.4,4.8c-9-4.2-13.2-13.8-11.4-23.4c3.6-21,7.8-41.4,11.4-62.4C134.5,94.5,135.7,87.9,136.9,81.9z' /> | |
| 94 | - <g id='Group_3575' transform='translate(16.61 16.942)'> | |
| 95 | - <g> | |
| 96 | - <g> | |
| 97 | - <defs> | |
| 98 | - <polygon id='SVGID_1_' points='113.1,97 101.1,148.7 147.3,148.7 158.1,103.6' /> | |
| 99 | - </defs> | |
| 100 | - <clipPath id='SVGID_2_'> | |
| 101 | - <use xlink:href='#SVGID_1_' style='overflow:visible;' /> | |
| 102 | - </clipPath> | |
| 103 | - <g id='Group_3574' class='st2' clip-path='url(#SVGID_2_)'> | |
| 104 | - <path id='Path_5100' fill='#00E9FF' d='M47.7,101.8C53.1,76.6,57.9,52.6,63.3,28c0.6-3.6,1.2-7.2,1.8-10.8C65.7,6.4,58.5-2.6,47.7-4.4c-10.8-1.8-21,4.8-23.4,15.6C16.5,46.6,8.7,82,1.5,118.1c-3,14.4,7.2,25.2,22.8,25.2c33,0.6,65.4,1.8,98.4,2.4c6.6,0,12.6-0.6,18.6-3c7.8-4.2,12-13.2,9.6-22.2c-2.4-9.6-10.8-16.2-21-16.2c-21-0.6-42-1.2-63-1.8C60.3,102.4,54.3,102.4,47.7,101.8z' /> | |
| 105 | - </g> | |
| 106 | - </g> | |
| 107 | - </g> | |
| 108 | - </g> | |
| 109 | - </g> | |
| 110 | - </g> | |
| 111 | - </svg> | |
| 112 | -<?php | |
| 113 | - $svg = ob_get_clean(); | |
| 114 | - add_menu_page('Tagembed', 'Tagembed', 'manage_options', 'tagembed', '___tagembed__view', 'data:image/svg+xml;base64,' . base64_encode($svg)); | |
| 115 | -} | |
| 116 | -add_action('admin_menu', '___tagembed__plugin_menus'); | |
| 117 | -/* --End-- Add Menus */ | |
| 118 | - | |
| 119 | -/* --Start-- Add & Manage Views */ | |
| 120 | -function ___tagembed__view() | |
| 121 | -{ | |
| 122 | - if (!empty(___tagembed__user()->isLogin) && ___tagembed__user()->isLogin == 'yes') : | |
| 123 | - $__tagembed__menus = ___tagembed__menus(['__tagembed__menu_condation' => 1]); | |
| 124 | - if (empty($__tagembed__menus)) : | |
| 125 | - include_once TAGEMBED_PLUGIN_DIR_PATH . 'views/widget/widgetView.php'; | |
| 126 | - else : | |
| 127 | - include_once TAGEMBED_PLUGIN_DIR_PATH . 'views/' . $__tagembed__menus[0]->path . '.php'; | |
| 128 | - endif; | |
| 129 | - else : | |
| 130 | - include_once TAGEMBED_PLUGIN_DIR_PATH . 'views/account/accountView.php'; | |
| 131 | - endif; | |
| 132 | -} | |
| 133 | -/* --End-- Add & Manage Views */ | |
| 134 | - | |
| 135 | -/* --Start-- Manage Ajax Calls */ | |
| 136 | -add_action('wp_ajax_tagembed_data', '___tagembed__dataAjaxHandler'); | |
| 137 | -function ___tagembed__dataAjaxHandler() | |
| 138 | -{ | |
| 139 | - if (!current_user_can('manage_options')) : | |
| 140 | - return ___tagembed__exitWithDanger('You do not have sufficient permissions to access this page.'); | |
| 141 | - endif; | |
| 142 | - /* --Start-- Manage Ajax call Request Security (Verified Before Any Other Request Data Is Used) */ | |
| 143 | - $__tagembed__ajaxCallSecurityNones = isset($_REQUEST['__tagembed__ajax_call_nones']) ? sanitize_text_field(wp_unslash($_REQUEST['__tagembed__ajax_call_nones'])) : ''; | |
| 144 | - if (!wp_verify_nonce($__tagembed__ajaxCallSecurityNones, '__tagembed__ajax_call_security_nones')) : | |
| 145 | - return ___tagembed__exitWithDanger(); | |
| 146 | - endif; | |
| 147 | - /* --End-- Manage Ajax call Request Security */ | |
| 148 | - if (empty($_REQUEST['__tagembed__ajax_action'])) : | |
| 149 | - return false; | |
| 150 | - endif; | |
| 151 | - $data = ___tagembed__sanitizeRequestData(wp_unslash($_REQUEST)); | |
| 152 | - $data = (object)$data; | |
| 153 | - /* --Start__ Sanetize All Input */ | |
| 154 | - foreach ($data as $key => $value) : | |
| 155 | - if (!in_array($key, ['emailId', 'password', 'youtubePlaylist'])) : | |
| 156 | - ___tagembed__inputSanetize($value); | |
| 157 | - endif; | |
| 158 | - endforeach; | |
| 159 | - /* --End__ Sanetize All Input */ | |
| 160 | - | |
| 161 | - $param = []; | |
| 162 | - $action = $data->__tagembed__ajax_action; | |
| 163 | - $__tagembed__user_details = ___tagembed__user(); | |
| 164 | - switch ($action): | |
| 165 | - case '__tagembed__getCallingCode': | |
| 166 | - /* --Start-- Manage Param Data */ | |
| 167 | - $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 168 | - /* --End-- Manage Param Data */ | |
| 169 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getCallingCode', $param, []); | |
| 170 | - $response = ___tagembed__manageApiResponse($response); | |
| 171 | - unset($param); | |
| 172 | - return ___tagembed__exitWithSuccess(['callingCode' => $response]); | |
| 173 | - break; | |
| 174 | - case '__tagembed__register': | |
| 175 | - if (empty($data->emailId) || empty($data->password) || empty($data->fullName)) : | |
| 176 | - return ___tagembed__exitWithDanger(); | |
| 177 | - endif; | |
| 178 | - /* --Start-- Manage Param Data */ | |
| 179 | - $param['fullName'] = sanitize_text_field($data->fullName); | |
| 180 | - $param['emailId'] = sanitize_email($data->emailId); | |
| 181 | - $param['password'] = $data->password; | |
| 182 | - $param['contact_no'] = $data->contact_no; | |
| 183 | - $param['calling_code'] = $data->calling_code; | |
| 184 | - $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 185 | - /* --End-- Manage Param Data */ | |
| 186 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/register', $param, []); | |
| 187 | - $response = ___tagembed__manageApiResponse($response); | |
| 188 | - unset($param); | |
| 189 | - $param = ['userId' => sanitize_key($response->userId), 'inheritStyles' => 1]; | |
| 190 | - ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $response->access_token]); | |
| 191 | - if (___tagembed__login($response) == true) : | |
| 192 | - return ___tagembed__exitWithSuccess(['redirectUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL]); | |
| 193 | - else : | |
| 194 | - return ___tagembed__exitWithDanger(); | |
| 195 | - endif; | |
| 196 | - break; | |
| 197 | - case '__tagembed__login': | |
| 198 | - if (empty($data->emailId) || empty($data->password)) : | |
| 199 | - return ___tagembed__exitWithDanger(); | |
| 200 | - endif; | |
| 201 | - /* --Start-- Manage Param Data */ | |
| 202 | - $param['emailId'] = sanitize_email($data->emailId); | |
| 203 | - $param['password'] = $data->password; | |
| 204 | - $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 205 | - /* --End-- Manage Param Data */ | |
| 206 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/login', $param, []); | |
| 207 | - unset($param); | |
| 208 | - $response = ___tagembed__manageApiResponse($response); | |
| 209 | - if (___tagembed__login($response) == true) : | |
| 210 | - return ___tagembed__exitWithSuccess(['redirectUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL]); | |
| 211 | - else : | |
| 212 | - return ___tagembed__exitWithDanger(); | |
| 213 | - endif; | |
| 214 | - break; | |
| 215 | - case '__tagembed__logout': | |
| 216 | - if (tagembed_logout()) : | |
| 217 | - return ___tagembed__exitWithSuccess(['redirectUrl' => TAGEMBED_PLUGIN_REDIRECT_URL . 'tagembed']); | |
| 218 | - else : | |
| 219 | - return ___tagembed__exitWithDanger(); | |
| 220 | - endif; | |
| 221 | - break; | |
| 222 | - case '__tagembed__check_plan_premium_feature': | |
| 223 | - if (empty($__tagembed__user_details)) : | |
| 224 | - return ___tagembed__exitWithDanger(); | |
| 225 | - endif; | |
| 226 | - /* --Start-- Manage Param Data */ | |
| 227 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 228 | - /* --End-- Manage Param Data */ | |
| 229 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/checkPlanPremiumFeature', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 230 | - unset($param); | |
| 231 | - $response = ___tagembed__manageApiResponse($response); | |
| 232 | - return ___tagembed__exitWithSuccess($response); | |
| 233 | - break; | |
| 234 | - case '__tagembed__check_user_accout_status': | |
| 235 | - if (empty($__tagembed__user_details)) : | |
| 236 | - return ___tagembed__exitWithDanger(); | |
| 237 | - endif; | |
| 238 | - /* --Start-- Manage Param Data */ | |
| 239 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 240 | - /* --End-- Manage Param Data */ | |
| 241 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/checkUserAccountStatus', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 242 | - unset($param); | |
| 243 | - $response = ___tagembed__manageApiResponse($response); | |
| 244 | - return ___tagembed__exitWithSuccess($response); | |
| 245 | - break; | |
| 246 | - case '__tagembed__get_account_details': | |
| 247 | - $data->auth = !empty($data->auth) ? 1 : 0; | |
| 248 | - if (empty($__tagembed__user_details)) : | |
| 249 | - return ___tagembed__exitWithDanger(); | |
| 250 | - endif; | |
| 251 | - /* --Start-- Manage Param Data */ | |
| 252 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 253 | - $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 254 | - /* --End-- Manage Param Data */ | |
| 255 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getdetails', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 256 | - unset($param); | |
| 257 | - $response = ___tagembed__manageApiResponse($response); | |
| 258 | - return ___tagembed__exitWithSuccess($response); | |
| 259 | - break; | |
| 260 | - | |
| 261 | - case '__tagembed__manage_active_widget': | |
| 262 | - if (empty($data->widgetId)) : | |
| 263 | - return ___tagembed__exitWithDanger(); | |
| 264 | - endif; | |
| 265 | - if (___tagembed__manageActiveWidget($data->widgetId)) : | |
| 266 | - return ___tagembed__exitWithSuccess(); | |
| 267 | - else : | |
| 268 | - return ___tagembed__exitWithDanger(); | |
| 269 | - endif; | |
| 270 | - break; | |
| 271 | - case '__tagembed__menue': | |
| 272 | - if (empty($data->menueId)) : | |
| 273 | - return ___tagembed__exitWithDanger(); | |
| 274 | - endif; | |
| 275 | - if (___tagembed__menus(['__tagembed__menu_id' => $data->menueId])) : | |
| 276 | - return ___tagembed__exitWithSuccess(['redirectUrl' => TAGEMBED_PLUGIN_REDIRECT_URL . 'tagembed']); | |
| 277 | - else : | |
| 278 | - return ___tagembed__exitWithDanger(); | |
| 279 | - endif; | |
| 280 | - break; | |
| 281 | - case '__tagembed__create_widget': | |
| 282 | - if (empty($__tagembed__user_details) || empty($data->name)) : | |
| 283 | - return ___tagembed__exitWithDanger('Validation Error', ['name' => 'Widget name is required']); | |
| 284 | - endif; | |
| 285 | - $data->profanity = (isset($data->profanity)) ? 0 : 1; | |
| 286 | - /* --Start-- Manage Param Data */ | |
| 287 | - $param['name'] = sanitize_text_field($data->name); | |
| 288 | - $param['profanity'] = sanitize_key($data->profanity); | |
| 289 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 290 | - $param['inheritStyles'] = 1; | |
| 291 | - /* --End-- Manage Param Data */ | |
| 292 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 293 | - unset($param); | |
| 294 | - $response = ___tagembed__manageApiResponse($response); | |
| 295 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 296 | - return ___tagembed__exitWithSuccess(['message' => $response, 'redirectUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL]); | |
| 297 | - break; | |
| 298 | - case '__tagembed__edit_widget': | |
| 299 | - if (empty($__tagembed__user_details) || empty($data->name) || empty($data->widgetId)) : | |
| 300 | - return ___tagembed__exitWithDanger('Validation Error', ['name' => 'Widget name is required']); | |
| 301 | - endif; | |
| 302 | - /* --Start-- Manage Param Data */ | |
| 303 | - $param['name'] = sanitize_text_field($data->name); | |
| 304 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 305 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 306 | - /* --End-- Manage Param Data */ | |
| 307 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/edit', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 308 | - unset($param); | |
| 309 | - $response = ___tagembed__manageApiResponse($response); | |
| 310 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 311 | - return ___tagembed__exitWithSuccess(['message' => $response, 'redirectUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL]); | |
| 312 | - break; | |
| 313 | - case '__tagembed__update_widget_status': | |
| 314 | - if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 315 | - return ___tagembed__exitWithDanger(); | |
| 316 | - endif; | |
| 317 | - /* --Start-- Manage Param Data */ | |
| 318 | - $param['status'] = sanitize_key($data->status); | |
| 319 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 320 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 321 | - /* --End-- Manage Param Data */ | |
| 322 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 323 | - unset($param); | |
| 324 | - $response = ___tagembed__manageApiResponse($response); | |
| 325 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 326 | - return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 327 | - break; | |
| 328 | - case '__tagembed__delete_widget': | |
| 329 | - if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 330 | - return ___tagembed__exitWithDanger(); | |
| 331 | - endif; | |
| 332 | - /* --Start-- Manage Param Data */ | |
| 333 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 334 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 335 | - /* --End-- Manage Param Data */ | |
| 336 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 337 | - unset($param); | |
| 338 | - $response = ___tagembed__manageApiResponse($response); | |
| 339 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 340 | - return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 341 | - break; | |
| 342 | - case '__tagembed__source_networks': | |
| 343 | - $data->auth = !empty($data->auth) ? 1 : 0; | |
| 344 | - if (empty($__tagembed__user_details)) : | |
| 345 | - return ___tagembed__exitWithDanger(); | |
| 346 | - endif; | |
| 347 | - /* --Start-- Manage Param Data */ | |
| 348 | - $param['auth'] = sanitize_key($data->auth); | |
| 349 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 350 | - /* --End-- Manage Param Data */ | |
| 351 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apinetwork/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 352 | - unset($param); | |
| 353 | - $response = ___tagembed__manageApiResponse($response); | |
| 354 | - return ___tagembed__exitWithSuccess($response); | |
| 355 | - break; | |
| 356 | - case '__tagembed__get_themes': | |
| 357 | - if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 358 | - return ___tagembed__exitWithDanger(); | |
| 359 | - endif; | |
| 360 | - /* --Start-- Manage Param Data */ | |
| 361 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 362 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 363 | - /* --End-- Manage Param Data */ | |
| 364 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'Apitheme/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 365 | - unset($param); | |
| 366 | - $response = ___tagembed__manageApiResponse($response); | |
| 367 | - return ___tagembed__exitWithSuccess($response); | |
| 368 | - break; | |
| 369 | - case '__tagembed__edit_themes': | |
| 370 | - if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->themeId)) : | |
| 371 | - return ___tagembed__exitWithDanger(); | |
| 372 | - endif; | |
| 373 | - /* --Start-- Manage Param Data */ | |
| 374 | - $param['themeId'] = sanitize_key($data->themeId); | |
| 375 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 376 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 377 | - /* --End-- Manage Param Data */ | |
| 378 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'Apitheme/edit', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 379 | - unset($param); | |
| 380 | - $response = ___tagembed__manageApiResponse($response); | |
| 381 | - return ___tagembed__exitWithSuccess($response); | |
| 382 | - break; | |
| 383 | - case '__tagembed__get_network_filter': | |
| 384 | - if (empty($__tagembed__user_details) || empty($data->networkId)) : | |
| 385 | - return ___tagembed__exitWithDanger(); | |
| 386 | - endif; | |
| 387 | - /* --Start-- Manage Param Data */ | |
| 388 | - $param['networkId'] = sanitize_key($data->networkId); | |
| 389 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 390 | - /* --End-- Manage Param Data */ | |
| 391 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apinetwork/filter', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 392 | - unset($param); | |
| 393 | - $response = ___tagembed__manageApiResponse($response); | |
| 394 | - return ___tagembed__exitWithSuccess($response); | |
| 395 | - break; | |
| 396 | - case '__tagembed__get_already_exist_accounts': | |
| 397 | - if (empty($__tagembed__user_details)) : | |
| 398 | - return ___tagembed__exitWithDanger(); | |
| 399 | - endif; | |
| 400 | - /* --Start-- Manage Param Data */ | |
| 401 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 402 | - /* --End-- Manage Param Data */ | |
| 403 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/getalreadyexistaccounts', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 404 | - unset($param); | |
| 405 | - $response = ___tagembed__manageApiResponse($response); | |
| 406 | - return ___tagembed__exitWithSuccess($response); | |
| 407 | - break; | |
| 408 | - case '__tagembed__add_or_update_account': | |
| 409 | - if (empty($__tagembed__user_details) || empty($data->networkId) || empty($data->type)) : | |
| 410 | - return ___tagembed__exitWithDanger(); | |
| 411 | - endif; | |
| 412 | - /* --Start-- Manage Param Data */ | |
| 413 | - $param['connectedAccountId'] = $data->connectedAccountId; | |
| 414 | - $param['feedId'] = sanitize_key($data->feedId); | |
| 415 | - $param['type'] = sanitize_text_field($data->type); | |
| 416 | - $param['networkId'] = sanitize_key($data->networkId); | |
| 417 | - $param['filterId'] = sanitize_key($data->filterId); | |
| 418 | - $param['otherData'] = $data->otherData; | |
| 419 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 420 | - /* --End-- Manage Param Data */ | |
| 421 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/addorupdate', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 422 | - unset($param); | |
| 423 | - $response = ___tagembed__manageApiResponse($response); | |
| 424 | - return ___tagembed__exitWithSuccess(['__tagembed__requestCallBackUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL, 'redirectUrl' => TAGEMBED_PLUGIN_API_URL . 'apiauth/getauth', '__tagembed__feedData' => $response->__tagembed__feedData]); | |
| 425 | - break; | |
| 426 | - case '__tagembed__delete_account': | |
| 427 | - if (empty($__tagembed__user_details) || empty($data->networkId) || empty($data->parentId)) : | |
| 428 | - return ___tagembed__exitWithDanger(); | |
| 429 | - endif; | |
| 430 | - /* --Start-- Manage Param Data */ | |
| 431 | - $param['parentId'] = sanitize_key($data->parentId); | |
| 432 | - $param['networkId'] = sanitize_key($data->networkId); | |
| 433 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 434 | - /* --End-- Manage Param Data */ | |
| 435 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 436 | - unset($param); | |
| 437 | - $response = ___tagembed__manageApiResponse($response); | |
| 438 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 439 | - return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 440 | - break; | |
| 441 | - case '__tagembed__get_already_exist_auth': | |
| 442 | - if (empty($__tagembed__user_details) || empty($data->networkId)) : | |
| 443 | - return ___tagembed__exitWithDanger(); | |
| 444 | - endif; | |
| 445 | - /* --Start-- Manage Param Data */ | |
| 446 | - $param['networkId'] = sanitize_key($data->networkId); | |
| 447 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 448 | - /* --End-- Manage Param Data */ | |
| 449 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 450 | - unset($param); | |
| 451 | - $response = ___tagembed__manageApiResponse($response); | |
| 452 | - return ___tagembed__exitWithSuccess($response); | |
| 453 | - break; | |
| 454 | - case '__tagembed__search_google_location': | |
| 455 | - if (empty($__tagembed__user_details) || empty($data->googleLocationName)) : | |
| 456 | - return ___tagembed__exitWithDanger(); | |
| 457 | - endif; | |
| 458 | - /* --Start-- Manage Param Data */ | |
| 459 | - $param['googleLocationName'] = $data->googleLocationName; | |
| 460 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 461 | - /* --End-- Manage Param Data */ | |
| 462 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchgooglelocation', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 463 | - unset($param); | |
| 464 | - $response = ___tagembed__manageApiResponse($response); | |
| 465 | - return ___tagembed__exitWithSuccess($response); | |
| 466 | - break; | |
| 467 | - case '__tagembed__search_vk_communities': | |
| 468 | - if (empty($__tagembed__user_details) || empty($data->vkCommunitiesName)) : | |
| 469 | - return ___tagembed__exitWithDanger(); | |
| 470 | - endif; | |
| 471 | - /* --Start-- Manage Param Data */ | |
| 472 | - $param['vkCommunitiesName'] = $data->vkCommunitiesName; | |
| 473 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 474 | - /* --End-- Manage Param Data */ | |
| 475 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchVkCommunities', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 476 | - unset($param); | |
| 477 | - $response = ___tagembed__manageApiResponse($response); | |
| 478 | - return ___tagembed__exitWithSuccess($response); | |
| 479 | - break; | |
| 480 | - case '__tagembed__search_facebook_page': | |
| 481 | - if (empty($data->facebookPageData)) : | |
| 482 | - return ___tagembed__exitWithDanger(); | |
| 483 | - endif; | |
| 484 | - /* --Start-- Manage Param Data */ | |
| 485 | - $param['facebookPageData'] = $data->facebookPageData; | |
| 486 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 487 | - /* --End-- Manage Param Data */ | |
| 488 | - /* --Start-- Call And Manage Api Call */ | |
| 489 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchfacebookpage', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 490 | - unset($param); | |
| 491 | - $response = ___tagembed__manageApiResponse($response); | |
| 492 | - return ___tagembed__exitWithSuccess($response); | |
| 493 | - break; | |
| 494 | - case '__tagembed__get_facebook_page_albums': | |
| 495 | - if (empty($__tagembed__user_details) || empty($data->connectedAccountsId)) : | |
| 496 | - return ___tagembed__exitWithDanger(); | |
| 497 | - endif; | |
| 498 | - /* --Start-- Manage Param Data */ | |
| 499 | - $param['connectedAccountsId'] = sanitize_key($data->connectedAccountsId); | |
| 500 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 501 | - /* --End-- Manage Param Data */ | |
| 502 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/apiauthfacebookpagealbums', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 503 | - unset($param); | |
| 504 | - $response = ___tagembed__manageApiResponse($response); | |
| 505 | - return ___tagembed__exitWithSuccess($response); | |
| 506 | - break; | |
| 507 | - case '__tagembed__search_youtube_channel': | |
| 508 | - if (empty($__tagembed__user_details) || empty($data->youtubeChannelData)) : | |
| 509 | - return ___tagembed__exitWithDanger(); | |
| 510 | - endif; | |
| 511 | - /* --Start-- Manage Param Data */ | |
| 512 | - $param['youtubeChannelData'] = $data->youtubeChannelData; | |
| 513 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 514 | - /* --End-- Manage Param Data */ | |
| 515 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchyoutubechannel', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 516 | - unset($param); | |
| 517 | - $response = ___tagembed__manageApiResponse($response); | |
| 518 | - return ___tagembed__exitWithSuccess($response); | |
| 519 | - break; | |
| 520 | - case '__tagembed__get_youtube_playlist': | |
| 521 | - if (empty($__tagembed__user_details) || empty($data->youtubeId)) : | |
| 522 | - return ___tagembed__exitWithDanger(); | |
| 523 | - endif; | |
| 524 | - /* --Start-- Manage Param Data */ | |
| 525 | - $param['youtubeId'] = $data->youtubeId; | |
| 526 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 527 | - /* --End-- Manage Param Data */ | |
| 528 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getyoutubeplaylist', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 529 | - unset($param); | |
| 530 | - $response = ___tagembed__manageApiResponse($response); | |
| 531 | - return ___tagembed__exitWithSuccess($response); | |
| 532 | - break; | |
| 533 | - case '__tagembed__get_slack_channel_list': | |
| 534 | - if (empty($data->connectedAccountsId)) : | |
| 535 | - return ___tagembed__exitWithDanger(); | |
| 536 | - endif; | |
| 537 | - /* --Start-- Manage Param Data */ | |
| 538 | - $param['connectedAccountsId'] = $data->connectedAccountsId; | |
| 539 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 540 | - /* --End-- Manage Param Data */ | |
| 541 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getslackchannellist', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 542 | - unset($param); | |
| 543 | - $response = ___tagembed__manageApiResponse($response); | |
| 544 | - return ___tagembed__exitWithSuccess($response); | |
| 545 | - break; | |
| 546 | - case '__tagembed__get_feed': | |
| 547 | - if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 548 | - return ___tagembed__exitWithDanger(); | |
| 549 | - endif; | |
| 550 | - /* --Start-- Manage Param Data */ | |
| 551 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 552 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 553 | - /* --End-- Manage Param Data */ | |
| 554 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 555 | - unset($param); | |
| 556 | - $response = ___tagembed__manageApiResponse($response); | |
| 557 | - return ___tagembed__exitWithSuccess($response); | |
| 558 | - break; | |
| 559 | - case '__tagembed__update_feed_status': | |
| 560 | - if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->feedId)) : | |
| 561 | - return ___tagembed__exitWithDanger(); | |
| 562 | - endif; | |
| 563 | - /* --Start-- Manage Param Data */ | |
| 564 | - $param['feedId'] = sanitize_key($data->feedId); | |
| 565 | - $param['status'] = sanitize_key($data->status); | |
| 566 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 567 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 568 | - /* --End-- Manage Param Data */ | |
| 569 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 570 | - unset($param); | |
| 571 | - $response = ___tagembed__manageApiResponse($response); | |
| 572 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 573 | - return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 574 | - break; | |
| 575 | - case '__tagembed__delete_feed': | |
| 576 | - if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->feedId)) : | |
| 577 | - return ___tagembed__exitWithDanger(); | |
| 578 | - endif; | |
| 579 | - /* --Start-- Manage Param Data */ | |
| 580 | - $param['feedId'] = sanitize_key($data->feedId); | |
| 581 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 582 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 583 | - /* --End-- Manage Param Data */ | |
| 584 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 585 | - unset($param); | |
| 586 | - $response = ___tagembed__manageApiResponse($response); | |
| 587 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 588 | - return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 589 | - break; | |
| 590 | - case '__tagembed__create_feed': | |
| 591 | - if (empty($__tagembed__user_details) || empty($data->widgetName) || empty($data->networkName) || empty($data->filterName) || empty($data->widgetId) || empty($data->networkId) || empty($data->filterId)) : | |
| 592 | - return ___tagembed__exitWithDanger(); | |
| 593 | - endif; | |
| 594 | - $__tagembed__feed_input_data = ['feed' => sanitize_text_field($data->feed), 'userId' => sanitize_key($__tagembed__user_details->userId), 'moderation' => sanitize_key(isset($data->moderation) ? 1 : 0), 'widgetName' => sanitize_text_field($data->widgetName), 'networkName' => sanitize_text_field($data->networkName), 'filterName' => sanitize_text_field($data->filterName), 'widgetId' => sanitize_key($data->widgetId), 'networkId' => sanitize_key($data->networkId), 'filterId' => sanitize_key($data->filterId), 'auth' => 0, 'authId' => isset($data->authId) ? sanitize_key($data->authId) : 0]; | |
| 595 | - $__tagembed__feed_input_data['feed'] = !empty($data->feed) ? sanitize_text_field($data->feed) : '__tagembed__feed'; | |
| 596 | - $__tagembed__feed_filter_id = $data->filterId; | |
| 597 | - switch ($__tagembed__feed_input_data['networkId']): | |
| 598 | - case 1: | |
| 599 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 600 | - $__tagembed__feed_input_data['multiplePhoto'] = sanitize_key(isset($data->multiplePhoto) ? 1 : 0); | |
| 601 | - $__tagembed__feed_input_data['excludeRetweet'] = sanitize_key(isset($data->excludeRetweet) ? 1 : 0); | |
| 602 | - if (!empty($data->list)) : | |
| 603 | - $__tagembed__feed_input_data['list'] = sanitize_key($data->list); | |
| 604 | - endif; | |
| 605 | - break; | |
| 606 | - case 2: | |
| 607 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 608 | - break; | |
| 609 | - case 3: | |
| 610 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 611 | - switch ($__tagembed__feed_filter_id): | |
| 612 | - case 65: | |
| 613 | - $__tagembed__feed_input_data['accountAlbumType'] = sanitize_key(isset($data->accountAlbumType) ? $data->accountAlbumType : ''); | |
| 614 | - $__tagembed__feed_input_data['accountAlbumData'] = sanitize_text_field(isset($data->accountAlbumData) ? $data->accountAlbumData : ''); | |
| 615 | - break; | |
| 616 | - endswitch; | |
| 617 | - break; | |
| 618 | - case 4: | |
| 619 | - if ($__tagembed__feed_filter_id == 29) : | |
| 620 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 621 | - else : | |
| 622 | - $__tagembed__feed_input_data['placeId'] = $data->placeId; | |
| 623 | - $__tagembed__feed_input_data['placeName'] = $data->placeName; | |
| 624 | - endif; | |
| 625 | - break; | |
| 626 | - case 5: | |
| 627 | - switch ($__tagembed__feed_filter_id): | |
| 628 | - case 1: | |
| 629 | - case 71: | |
| 630 | - break; | |
| 631 | - case 12: | |
| 632 | - if (!preg_match('/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 633 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 634 | - endif; | |
| 635 | - $pintrestHeaders = explode('/', parse_url($data->feed)['path']); | |
| 636 | - $__tagembed__feed_input_data['value1'] = strtolower($pintrestHeaders[1]); | |
| 637 | - $__tagembed__feed_input_data['value2'] = strtolower($pintrestHeaders[2]); | |
| 638 | - break; | |
| 639 | - endswitch; | |
| 640 | - break; | |
| 641 | - case 6: | |
| 642 | - switch ($__tagembed__feed_filter_id): | |
| 643 | - case 1: | |
| 644 | - case 2: | |
| 645 | - $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; | |
| 646 | - break; | |
| 647 | - endswitch; | |
| 648 | - break; | |
| 649 | - case 7: | |
| 650 | - if (in_array($__tagembed__feed_filter_id, [1, 71])) : | |
| 651 | - $isUrl = false; | |
| 652 | - if (preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 653 | - $isUrl = true; | |
| 654 | - endif; | |
| 655 | - if ((empty($data->youtubeId) || empty($data->youtubeName)) && !$isUrl) : | |
| 656 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid Channel URL Or Tab On Search Icon']); | |
| 657 | - endif; | |
| 658 | - if ($isUrl) : | |
| 659 | - $data->youtubeId = explode('/', $data->feed); | |
| 660 | - $data->youtubeId = $data->youtubeId[4]; | |
| 661 | - $data->youtubeName = 'youtube'; | |
| 662 | - if (empty($data->youtubeId) || empty($data->youtubeName)) : | |
| 663 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid Channel URL']); | |
| 664 | - endif; | |
| 665 | - endif; | |
| 666 | - endif; | |
| 667 | - switch ($__tagembed__feed_filter_id): | |
| 668 | - case 1: | |
| 669 | - case 75: | |
| 670 | - $__tagembed__feed_input_data['youtubeId'] = $data->youtubeId; | |
| 671 | - $__tagembed__feed_input_data['youtubeName'] = $data->youtubeName; | |
| 672 | - break; | |
| 673 | - case 11: | |
| 674 | - if (empty($data->youtubePlaylist) && empty($data->youtubeId)) : | |
| 675 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid Channel URL Or Tab On Search Icon']); | |
| 676 | - elseif (empty($data->youtubePlaylist) && !empty($data->youtubeId)) : | |
| 677 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Play List Not Found']); | |
| 678 | - endif; | |
| 679 | - $data->youtubePlaylist = explode('#', $data->youtubePlaylist); | |
| 680 | - $__tagembed__feed_input_data['youtubeId'] = $data->youtubePlaylist[0]; | |
| 681 | - $__tagembed__feed_input_data['youtubeName'] = $data->youtubePlaylist[1]; | |
| 682 | - $__tagembed__feed_input_data['feed'] = $data->youtubePlaylist[1]; | |
| 683 | - unset($data->youtubePlaylist); | |
| 684 | - break; | |
| 685 | - endswitch; | |
| 686 | - break; | |
| 687 | - case 8: | |
| 688 | - switch ($__tagembed__feed_filter_id): | |
| 689 | - case 1: | |
| 690 | - case 2: | |
| 691 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 692 | - break; | |
| 693 | - endswitch; | |
| 694 | - break; | |
| 695 | - case 10: | |
| 696 | - if (in_array($__tagembed__feed_filter_id, [1, 16, 17])) : | |
| 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 | - endif; | |
| 700 | - endif; | |
| 701 | - switch ($__tagembed__feed_filter_id): | |
| 702 | - case 16: | |
| 703 | - $postUrl = parse_url($data->feed); | |
| 704 | - if (!strstr($postUrl['host'], 'linkedin')) : | |
| 705 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); | |
| 706 | - endif; | |
| 707 | - $postUrl = $data->feed; | |
| 708 | - $postUrl = rtrim($postUrl, '/'); | |
| 709 | - preg_match('/[^\/]+$/', $postUrl, $postId); | |
| 710 | - $postId = $postId[0]; | |
| 711 | - $postId = (explode('?', $postId)[0]); | |
| 712 | - $value1 = 'LinkedIn'; | |
| 713 | - if (stripos($postId, 'activity') !== false) : | |
| 714 | - $postId = (explode('activity', $postId)[1]); | |
| 715 | - $value2 = 'activity'; | |
| 716 | - elseif (stripos($postId, 'ugcPost') !== false) : | |
| 717 | - $postId = (explode('ugcPost', $postId)[1]); | |
| 718 | - $value2 = 'ugcPost'; | |
| 719 | - else : | |
| 720 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); | |
| 721 | - endif; | |
| 722 | - preg_match_all('!\d+!', $postId, $postId); | |
| 723 | - if (isset($postId[0][0]) && empty($postId[0][0])) : | |
| 724 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); | |
| 725 | - endif; | |
| 726 | - $value3 = $postId[0][0]; | |
| 727 | - if (empty($value1) || empty($value2) || empty($value3)) : | |
| 728 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); | |
| 729 | - endif; | |
| 730 | - $__tagembed__feed_input_data['value1'] = $value1; | |
| 731 | - $__tagembed__feed_input_data['value2'] = $value2; | |
| 732 | - $__tagembed__feed_input_data['value3'] = $value3; | |
| 733 | - break; | |
| 734 | - case 1: | |
| 735 | - case 17: | |
| 736 | - $url = parse_url($data->feed); | |
| 737 | - $companyPageUrl = $url['scheme'] . '://' . $url['host']; | |
| 738 | - $url = explode('/', $url['path']); | |
| 739 | - $companyPageUrl = $companyPageUrl . '/' . $url[1] . '/' . $url[2] . '/'; | |
| 740 | - $__tagembed__feed_input_data['feed'] = $companyPageUrl; | |
| 741 | - $url[2] = str_replace('-', ' ', '$url[2]'); | |
| 742 | - $__tagembed__feed_input_data['page'] = ucwords($url[2], ' '); | |
| 743 | - break; | |
| 744 | - case 2: | |
| 745 | - $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; | |
| 746 | - break; | |
| 747 | - endswitch; | |
| 748 | - break; | |
| 749 | - case 11: | |
| 750 | - switch ($__tagembed__feed_filter_id): | |
| 751 | - case 1: | |
| 752 | - case 2: | |
| 753 | - $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; | |
| 754 | - break; | |
| 755 | - endswitch; | |
| 756 | - break; | |
| 757 | - case 12: | |
| 758 | - if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 759 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 760 | - endif; | |
| 761 | - $__tagembed__feed_input_data['name'] = $data->name; | |
| 762 | - break; | |
| 763 | - case 18: | |
| 764 | - switch ($__tagembed__feed_filter_id): | |
| 765 | - case 23: | |
| 766 | - if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 767 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 768 | - endif; | |
| 769 | - break; | |
| 770 | - case 26: | |
| 771 | - $__tagembed__feed_input_data['hashtagCaption'] = sanitize_key(isset($data->hashtagCaption) ? 1 : 0); | |
| 772 | - $__tagembed__feed_input_data['hashtagOlder'] = sanitize_key(isset($data->hashtagOlder) ? 1 : 0); | |
| 773 | - break; | |
| 774 | - endswitch; | |
| 775 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 776 | - break; | |
| 777 | - case 19: | |
| 778 | - if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 779 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 780 | - endif; | |
| 781 | - $yelpBusinessUrl = parse_url($data->feed); | |
| 782 | - if (!strstr($yelpBusinessUrl['host'], 'yelp')) : | |
| 783 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Yelp Business Url']); | |
| 784 | - endif; | |
| 785 | - $yelpBusinessPath = explode('/', $yelpBusinessUrl['path']); | |
| 786 | - $__tagembed__feed_input_data['feed'] = $yelpBusinessPath[2]; | |
| 787 | - $__tagembed__feed_input_data['name'] = $yelpBusinessPath[2]; | |
| 788 | - break; | |
| 789 | - case 20: | |
| 790 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 791 | - $slackData = isset($data->slackChannelList) ? $data->slackChannelList : ''; | |
| 792 | - if (!empty($slackData)) : | |
| 793 | - $slackData = explode('#', $slackData); | |
| 794 | - $__tagembed__feed_input_data['name'] = $slackData[1]; | |
| 795 | - $__tagembed__feed_input_data['feed'] = $slackData[0]; | |
| 796 | - endif; | |
| 797 | - break; | |
| 798 | - case 23: | |
| 799 | - if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 800 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 801 | - endif; | |
| 802 | - $airbnbListUrl = parse_url($data->feed); | |
| 803 | - if (strstr($airbnbListUrl['host'], 'airbnb')) : | |
| 804 | - preg_match('/[^\/]+$/', $data->feed, $matches); | |
| 805 | - $__tagembed__feed_input_data['listId'] = explode('?', $matches[0])[0]; | |
| 806 | - else : | |
| 807 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Airbnb Url']); | |
| 808 | - endif; | |
| 809 | - $__tagembed__feed_input_data['name'] = $data->name; | |
| 810 | - break; | |
| 811 | - case 36: | |
| 812 | - if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 813 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 814 | - endif; | |
| 815 | - $etsyShopUrl = parse_url($data->feed); | |
| 816 | - if (!strstr($etsyShopUrl['host'], 'etsy')) : | |
| 817 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Etsy Shop Url']); | |
| 818 | - endif; | |
| 819 | - $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = explode('/shop/', $etsyShopUrl['path'])[1]; | |
| 820 | - break; | |
| 821 | - case 28: | |
| 822 | - switch ($__tagembed__feed_filter_id): | |
| 823 | - case 72: | |
| 824 | - $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 825 | - $__tagembed__feed_input_data['name'] = $data->feed; | |
| 826 | - break; | |
| 827 | - endswitch; | |
| 828 | - if (!in_array($__tagembed__feed_filter_id, [72])) : | |
| 829 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 830 | - endif; | |
| 831 | - break; | |
| 832 | - case 30: | |
| 833 | - switch ($__tagembed__feed_filter_id): | |
| 834 | - case 2: | |
| 835 | - $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 836 | - $__tagembed__feed_input_data['name'] = $data->feed; | |
| 837 | - break; | |
| 838 | - case 75: | |
| 839 | - $__tagembed__feed_input_data['communitiesName'] = $data->communitiesName; | |
| 840 | - $__tagembed__feed_input_data['communitiesId'] = $data->communitiesId; | |
| 841 | - break; | |
| 842 | - endswitch; | |
| 843 | - if (!in_array($__tagembed__feed_filter_id, [2, 75])) : | |
| 844 | - $__tagembed__feed_input_data['auth'] = 1; | |
| 845 | - endif; | |
| 846 | - break; | |
| 847 | - case 33: | |
| 848 | - if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 849 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 850 | - endif; | |
| 851 | - preg_match('/[^\/]+$/', '$data->feed', $matches); | |
| 852 | - $__tagembed__feed_input_data['feed'] = $matches[0]; | |
| 853 | - $__tagembed__feed_input_data['name'] = $matches[0]; | |
| 854 | - break; | |
| 855 | - case 34: | |
| 856 | - if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 857 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 858 | - endif; | |
| 859 | - $__tagembed__feed_input_data['name'] = explode('/', $data->feed)[3]; | |
| 860 | - $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 861 | - break; | |
| 862 | - case 35: | |
| 863 | - if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 864 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 865 | - endif; | |
| 866 | - $__tagembed__feed_input_data['name'] = explode('Reviews-', $data->feed)[1]; | |
| 867 | - $__tagembed__feed_input_data['name'] = explode('.html', $__tagembed__feed_input_data['name'])[0]; | |
| 868 | - $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 869 | - break; | |
| 870 | - case 37: | |
| 871 | - $data->feed = explode('.html', $data->feed)[0]; | |
| 872 | - if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 873 | - return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 874 | - endif; | |
| 875 | - $__tagembed__feed_input_data['name'] = $data->feed; | |
| 876 | - $__tagembed__feed_input_data['feed'] = explode('item/', $data->feed)[1]; | |
| 877 | - break; | |
| 878 | - endswitch; | |
| 879 | - unset($data); | |
| 880 | - | |
| 881 | - /* --Start-- Manage Api Calling */ | |
| 882 | - $byApiCall = 0; | |
| 883 | - if (empty($__tagembed__feed_input_data['authId'])) : | |
| 884 | - switch ($__tagembed__feed_input_data['networkId']): | |
| 885 | - case 4: | |
| 886 | - if (33 == $__tagembed__feed_filter_id) : | |
| 887 | - $byApiCall = 1; | |
| 888 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 889 | - endif; | |
| 890 | - break; | |
| 891 | - case 5: | |
| 892 | - case 7: | |
| 893 | - case 6: | |
| 894 | - case 10: | |
| 895 | - case 11: | |
| 896 | - case 12: | |
| 897 | - case 19: | |
| 898 | - case 23: | |
| 899 | - case 28: | |
| 900 | - case 29: | |
| 901 | - case 33: | |
| 902 | - case 34: | |
| 903 | - case 35: | |
| 904 | - case 37: | |
| 905 | - $byApiCall = 1; | |
| 906 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 907 | - break; | |
| 908 | - case 31: | |
| 909 | - if (2 == $__tagembed__feed_filter_id) : | |
| 910 | - $byApiCall = 1; | |
| 911 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 912 | - endif; | |
| 913 | - break; | |
| 914 | - case 32: | |
| 915 | - if (in_array($__tagembed__feed_filter_id, [2, 75])) : | |
| 916 | - $byApiCall = 1; | |
| 917 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 918 | - endif; | |
| 919 | - break; | |
| 920 | - endswitch; | |
| 921 | - else : | |
| 922 | - $byApiCall = 1; | |
| 923 | - $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 924 | - endif; | |
| 925 | - $__tagembed__feed_input_data['appUser'] = 1; | |
| 926 | - $__tagembed__feed_input_data['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 927 | - /* --End-- Manage Api Calling */ | |
| 928 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/create', ['feedData' => $__tagembed__feed_input_data], ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 929 | - $response = ___tagembed__manageApiResponse($response); | |
| 930 | - return ___tagembed__exitWithSuccess(['byapiCall' => $byApiCall, '__tagembed__requestCallBackUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL, 'redirectUrl' => TAGEMBED_PLUGIN_API_URL . 'apiauth/getauth', '__tagembed__feedData' => $response->__tagembed__feedData]); | |
| 931 | - break; | |
| 932 | - case '__tagembed__make_payment': | |
| 933 | - | |
| 934 | - if (empty($__tagembed__user_details) || empty($data->planId)) : | |
| 935 | - return ___tagembed__exitWithDanger(); | |
| 936 | - endif; | |
| 937 | - /* --Start-- Manage Param Data */ | |
| 938 | - $param['planId'] = sanitize_key($data->planId); | |
| 939 | - $param['priceCode'] = $data->priceCode; | |
| 940 | - /* --Start-- Manage Param Data */ | |
| 941 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 942 | - $param['email'] = $__tagembed__user_details->email; | |
| 943 | - $param['name'] = $__tagembed__user_details->name; | |
| 944 | - $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 945 | - /* --End-- Manage Param Data */ | |
| 946 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getpaymentdetails', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 947 | - unset($param); | |
| 948 | - $response = ___tagembed__manageApiResponse($response); | |
| 949 | - return ___tagembed__exitWithSuccess(['__tagembed__requestCallBackUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL, 'redirectUrl' => TAGEMBED_PLUGIN_API_URL . 'apiaccount/makepayment', '__tagembed__paymentData' => $response->__tagembed__paymentData]); | |
| 950 | - break; | |
| 951 | - case '__tagembed__cancel_subscription': | |
| 952 | - if (empty($__tagembed__user_details) || empty($data->planId)) : | |
| 953 | - return ___tagembed__exitWithDanger(); | |
| 954 | - endif; | |
| 955 | - /* --Start-- Manage Param Data */ | |
| 956 | - $param['planId'] = sanitize_key($data->planId); | |
| 957 | - /* --Start-- Manage Param Data */ | |
| 958 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 959 | - $param['email'] = $__tagembed__user_details->email; | |
| 960 | - $param['name'] = $__tagembed__user_details->name; | |
| 961 | - $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 962 | - /* --End-- Manage Param Data */ | |
| 963 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/cancelsubscription', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 964 | - unset($param); | |
| 965 | - $response = ___tagembed__manageApiResponse($response); | |
| 966 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 967 | - return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 968 | - break; | |
| 969 | - case '__tagembed__get_post': | |
| 970 | - if (empty($__tagembed__user_details) || empty($data->widgetId) || !isset($data->perPage) || !isset($data->offset) || !isset($data->postStatus)) : | |
| 971 | - return ___tagembed__exitWithDanger(); | |
| 972 | - endif; | |
| 973 | - /* --Start-- Manage Param Data */ | |
| 974 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 975 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 976 | - $param['perPage'] = sanitize_key($data->perPage); | |
| 977 | - $param['offset'] = sanitize_key($data->offset); | |
| 978 | - $param['postStatus'] = sanitize_key($data->postStatus); | |
| 979 | - $param['feedIds'] = $data->feedIds; | |
| 980 | - $param['postType'] = $data->postType; | |
| 981 | - $param['highlightFilter'] = sanitize_key($data->highlightFilter); | |
| 982 | - $param['pinFilter'] = sanitize_key($data->pinFilter); | |
| 983 | - $param['recentFilter'] = sanitize_key($data->recentFilter); | |
| 984 | - $param['retweetFilter'] = sanitize_key($data->retweetFilter); | |
| 985 | - $param['searchText'] = sanitize_text_field($data->searchText); | |
| 986 | - /* --End-- Manage Param Data */ | |
| 987 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 988 | - unset($param); | |
| 989 | - $response = ___tagembed__manageApiResponse($response); | |
| 990 | - return ___tagembed__exitWithSuccess($response); | |
| 991 | - break; | |
| 992 | - case '__tagembed__manage_post_status': | |
| 993 | - if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postIds) || empty($data->postStatus)) : | |
| 994 | - return ___tagembed__exitWithDanger(); | |
| 995 | - endif; | |
| 996 | - /* --Start-- Manage Param Data */ | |
| 997 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 998 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 999 | - $param['postIds'] = $data->postIds; | |
| 1000 | - $param['postStatus'] = sanitize_key($data->postStatus); | |
| 1001 | - /* --End-- Manage Param Data */ | |
| 1002 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1003 | - unset($param); | |
| 1004 | - $response = ___tagembed__manageApiResponse($response); | |
| 1005 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 1006 | - return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 1007 | - break; | |
| 1008 | - case '__tagembed__feed_for_search': | |
| 1009 | - if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 1010 | - return ___tagembed__exitWithDanger(); | |
| 1011 | - endif; | |
| 1012 | - /* --Start-- Manage Param Data */ | |
| 1013 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1014 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1015 | - /* --End-- Manage Param Data */ | |
| 1016 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/getfeeds', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1017 | - unset($param); | |
| 1018 | - $response = ___tagembed__manageApiResponse($response); | |
| 1019 | - return ___tagembed__exitWithSuccess($response); | |
| 1020 | - break; | |
| 1021 | - case '__tagembed__manage_post_pin': | |
| 1022 | - if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postId) || !isset($data->pin)) : | |
| 1023 | - return ___tagembed__exitWithDanger(); | |
| 1024 | - endif; | |
| 1025 | - /* --Start-- Manage Param Data */ | |
| 1026 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1027 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1028 | - $param['postId'] = $data->postId; | |
| 1029 | - $param['pin'] = sanitize_key($data->pin); | |
| 1030 | - /* --End-- Manage Param Data */ | |
| 1031 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/pin', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1032 | - unset($param); | |
| 1033 | - $response = ___tagembed__manageApiResponse($response); | |
| 1034 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 1035 | - return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 1036 | - break; | |
| 1037 | - case '__tagembed__manage_post_highlight': | |
| 1038 | - if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postId) || !isset($data->highlight)) : | |
| 1039 | - return ___tagembed__exitWithDanger(); | |
| 1040 | - endif; | |
| 1041 | - /* --Start-- Manage Param Data */ | |
| 1042 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1043 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1044 | - $param['postId'] = $data->postId; | |
| 1045 | - $param['highlight'] = sanitize_key($data->highlight); | |
| 1046 | - /* --End-- Manage Param Data */ | |
| 1047 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/highlight', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1048 | - unset($param); | |
| 1049 | - $response = ___tagembed__manageApiResponse($response); | |
| 1050 | - $response = !empty($response->message) ? $response->message : 'Done'; | |
| 1051 | - return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 1052 | - break; | |
| 1053 | - case '__tagembed__plugin_version': | |
| 1054 | - /* --Start-- Manage Param Data */ | |
| 1055 | - $param = []; | |
| 1056 | - $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 1057 | - /* --End-- Manage Param Data */ | |
| 1058 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/pluginversion', $param, []); | |
| 1059 | - $response = ___tagembed__manageApiResponse($response); | |
| 1060 | - unset($param); | |
| 1061 | - $installedPluginVersion = get_file_data(__FILE__, ['Version' => 'Version'], false); | |
| 1062 | - $installedPluginVersion = $installedPluginVersion['Version']; | |
| 1063 | - $response->installedPluginVersion = $installedPluginVersion; | |
| 1064 | - $response->pluginUpgradeURL = admin_url() . 'plugins.php'; | |
| 1065 | - return ___tagembed__exitWithSuccess($response); | |
| 1066 | - break; | |
| 1067 | - case '__tagembed__check_user_token': | |
| 1068 | - if (empty($__tagembed__user_details)) : | |
| 1069 | - return ___tagembed__exitWithDanger(); | |
| 1070 | - endif; | |
| 1071 | - /* --Start-- Manage Param Data */ | |
| 1072 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1073 | - /* --End-- Manage Param Data */ | |
| 1074 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/checkusertoken', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1075 | - if (!empty($response->head) && 401 == $response->head->code && empty($response->head->status)) : | |
| 1076 | - tagembed_logout(); | |
| 1077 | - endif; | |
| 1078 | - unset($param); | |
| 1079 | - return ___tagembed__exitWithSuccess($response); | |
| 1080 | - break; | |
| 1081 | - case '__tagembed__plugin_deactivate': | |
| 1082 | - /* --Start-- Manage Param Data */ | |
| 1083 | - $__tagembed__user_details = ___tagembed__userData(); | |
| 1084 | - $param = []; | |
| 1085 | - $param['userId'] = !empty($__tagembed__user_details) ? sanitize_key($__tagembed__user_details->userId) : ''; | |
| 1086 | - $param['userName'] = !empty($__tagembed__user_details) ? sanitize_text_field($__tagembed__user_details->name) : ''; | |
| 1087 | - $param['userEmail'] = !empty($__tagembed__user_details) ? sanitize_email($__tagembed__user_details->email) : ''; | |
| 1088 | - $param['pluginDeactivateReason'] = sanitize_text_field($data->pluginDeactivateReason); | |
| 1089 | - $param['otherReason'] = sanitize_text_field($data->otherReason); | |
| 1090 | - $param['betterPlugin'] = sanitize_text_field($data->betterPlugin); | |
| 1091 | - $param['userWebsiteUrl'] = get_site_url(); | |
| 1092 | - $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 1093 | - /* --End-- Manage Param Data */ | |
| 1094 | - ___tagembed__dropDatabaseTablesForPlugin(); | |
| 1095 | - deactivate_plugins(plugin_basename(__FILE__), true); | |
| 1096 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/deactivateuserdata', $param, []); | |
| 1097 | - $response = ___tagembed__manageApiResponse($response); | |
| 1098 | - unset($param); | |
| 1099 | - return ___tagembed__exitWithSuccess(); | |
| 1100 | - break; | |
| 1101 | - case '__tagembed__get_customization_option': | |
| 1102 | - if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 1103 | - return ___tagembed__exitWithDanger(); | |
| 1104 | - endif; | |
| 1105 | - /* --Start-- Manage Param Data */ | |
| 1106 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1107 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1108 | - /* --End-- Manage Param Data */ | |
| 1109 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1110 | - unset($param); | |
| 1111 | - $response = ___tagembed__manageApiResponse($response); | |
| 1112 | - return ___tagembed__exitWithSuccess($response); | |
| 1113 | - break; | |
| 1114 | - case '__tagembed__update_footer_customization_option': | |
| 1115 | - /* --Start-- Manage Param Data */ | |
| 1116 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1117 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1118 | - $param['personalizationId'] = sanitize_key($data->personalizationId); | |
| 1119 | - $param['themeRuleId'] = sanitize_key($data->themeRuleId); | |
| 1120 | - $param['loadMoreStatus'] = sanitize_key($data->loadMoreStatus); | |
| 1121 | - $param['autoScrollStatus'] = sanitize_key($data->autoScrollStatus); | |
| 1122 | - /* --End-- Manage Param Data */ | |
| 1123 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/footer', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1124 | - unset($param); | |
| 1125 | - $response = ___tagembed__manageApiResponse($response); | |
| 1126 | - return ___tagembed__exitWithSuccess($response); | |
| 1127 | - break; | |
| 1128 | - case '__tagembed__update_layout_customization_option': | |
| 1129 | - /* --Start-- Manage Param Data */ | |
| 1130 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1131 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1132 | - $param['personalizationId'] = sanitize_key($data->personalizationId); | |
| 1133 | - $param['themeRuleId'] = sanitize_key($data->themeRuleId); | |
| 1134 | - $param['numberOfPosts'] = sanitize_key($data->numberOfPosts); | |
| 1135 | - $param['padding'] = sanitize_key($data->padding); | |
| 1136 | - $param['minimumPostWidth'] = sanitize_key($data->minimumPostWidth); | |
| 1137 | - $param['columnCount'] = sanitize_key($data->columnCount); | |
| 1138 | - $param['columnCountMobile'] = sanitize_key($data->columnCountMobile); | |
| 1139 | - $param['postText'] = sanitize_key($data->postText); | |
| 1140 | - $param['mobilePopup'] = sanitize_key($data->mobilePopup); | |
| 1141 | - $param['postFeatured'] = sanitize_key($data->postFeatured); | |
| 1142 | - /* --End-- Manage Param Data */ | |
| 1143 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/layout', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1144 | - unset($param); | |
| 1145 | - $response = ___tagembed__manageApiResponse($response); | |
| 1146 | - return ___tagembed__exitWithSuccess($response); | |
| 1147 | - break; | |
| 1148 | - case '__tagembed__update_card_customization_option': | |
| 1149 | - /* --Start-- Manage Param Data */ | |
| 1150 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1151 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1152 | - $param['personalizationId'] = sanitize_key($data->personalizationId); | |
| 1153 | - $param['inheritStyles'] = sanitize_key($data->inheritStyles); | |
| 1154 | - $param['themeRuleId'] = sanitize_key($data->themeRuleId); | |
| 1155 | - $param['fontColor'] = $data->fontColor; | |
| 1156 | - $param['authorColor'] = $data->authorColor; | |
| 1157 | - $param['cardColor'] = $data->cardColor; | |
| 1158 | - $param['fontSize'] = sanitize_key($data->fontSize); | |
| 1159 | - $param['shareOption'] = sanitize_key($data->shareOption); | |
| 1160 | - $param['hideContent'] = sanitize_key($data->hideContent); | |
| 1161 | - $param['postAuthor'] = sanitize_key($data->postAuthor); | |
| 1162 | - $param['postTime'] = sanitize_key($data->postTime); | |
| 1163 | - $param['lineTrim'] = sanitize_key($data->lineTrim); | |
| 1164 | - $param['aspectImageRatio'] = $data->aspectImageRatio; | |
| 1165 | - $param['textAlignment'] = $data->textAlignment; | |
| 1166 | - $param['roundEdge'] = $data->roundEdge; | |
| 1167 | - /* --End-- Manage Param Data */ | |
| 1168 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/card', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1169 | - unset($param); | |
| 1170 | - $response = ___tagembed__manageApiResponse($response); | |
| 1171 | - return ___tagembed__exitWithSuccess($response); | |
| 1172 | - break; | |
| 1173 | - case '__tagembed__update_other_customization_option': | |
| 1174 | - /* --Start-- Manage Param Data */ | |
| 1175 | - $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1176 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1177 | - $param['personalizationId'] = sanitize_key($data->personalizationId); | |
| 1178 | - $param['themeRuleId'] = sanitize_key($data->themeRuleId); | |
| 1179 | - $param['css'] = $data->css; | |
| 1180 | - /* --End-- Manage Param Data */ | |
| 1181 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/other', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1182 | - unset($param); | |
| 1183 | - $response = ___tagembed__manageApiResponse($response); | |
| 1184 | - return ___tagembed__exitWithSuccess($response); | |
| 1185 | - break; | |
| 1186 | - case '__tagembed__get_and_manage_intercom_chat_setting': | |
| 1187 | - if (empty($__tagembed__user_details)) : | |
| 1188 | - return ___tagembed__exitWithDanger(); | |
| 1189 | - endif; | |
| 1190 | - /* --Start-- Manage Param Data */ | |
| 1191 | - $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1192 | - /* --End-- Manage Param Data */ | |
| 1193 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getIntercomSettingData', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1194 | - unset($param); | |
| 1195 | - $response = ___tagembed__manageApiResponse($response); | |
| 1196 | - return ___tagembed__exitWithSuccess($response); | |
| 1197 | - break; | |
| 1198 | - default: | |
| 1199 | - return ___tagembed__exitWithDanger(); | |
| 1200 | - endswitch; | |
| 1201 | -} | |
| 1202 | -/* --End-- Manage Ajax Calls */ | |
| 1203 | - | |
| 1204 | -/* --Start-- Login */ | |
| 1205 | -function ___tagembed__login($response) | |
| 1206 | -{ | |
| 1207 | - global $wpdb; | |
| 1208 | - $return = false; | |
| 1209 | - $user = ___tagembed__user($response->emailId); | |
| 1210 | - if (empty($user->email)) : | |
| 1211 | - 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->access_token, 'yes'))) : | |
| 1212 | - $return = true; | |
| 1213 | - endif; | |
| 1214 | - else : | |
| 1215 | - 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->access_token, 'yes', $response->emailId))) : | |
| 1216 | - $return = true; | |
| 1217 | - endif; | |
| 1218 | - endif; | |
| 1219 | - ___tagembed__manageActiveOptions($response->emailId, 'yes'); /* Manage Active Options */ | |
| 1220 | - if ($return) : | |
| 1221 | - ___tagembed__manageActiveWidgetsUser($response->userId); | |
| 1222 | - endif; | |
| 1223 | - return $return; | |
| 1224 | -} | |
| 1225 | -/* --End-- Login */ | |
| 1226 | - | |
| 1227 | -/* --Start-- Manage Active Options */ | |
| 1228 | -function ___tagembed__manageActiveOptions($email = null, $other = null) | |
| 1229 | -{ | |
| 1230 | - global $wpdb; | |
| 1231 | - if (null == $email && null != $other) : | |
| 1232 | - $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_options SET isLogin = %s WHERE id = %d', $other, 1)); | |
| 1233 | - else : | |
| 1234 | - $__tagembed__activeOptions = $wpdb->get_results($wpdb->prepare('SELECT email FROM wp_tagembed_active_options WHERE id = %d', 1)); | |
| 1235 | - if (empty($__tagembed__activeOptions[0]->email)) : | |
| 1236 | - $wpdb->query($wpdb->prepare('INSERT INTO wp_tagembed_active_options (email, isLogin) VALUES (%s, %s)', $email, $other)); | |
| 1237 | - else : | |
| 1238 | - $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_options SET email = %s, isLogin = %s WHERE id = %d', $email, $other, 1)); | |
| 1239 | - endif; | |
| 1240 | - endif; | |
| 1241 | -} | |
| 1242 | -/* --End-- Manage Active Options */ | |
| 1243 | - | |
| 1244 | -/* --Start-- Logout */ | |
| 1245 | -function tagembed_logout() | |
| 1246 | -{ | |
| 1247 | - global $wpdb; | |
| 1248 | - if ($wpdb->query($wpdb->prepare('UPDATE wp_tagembed_user SET isLogin = %s WHERE isLogin = %s', 'no', 'yes'))) : | |
| 1249 | - ___tagembed__manageActiveOptions(null, 'no'); /* Manage Active Options */ | |
| 1250 | - return true; | |
| 1251 | - endif; | |
| 1252 | - return false; | |
| 1253 | -} | |
| 1254 | -/* --End-- Logout */ | |
| 1255 | - | |
| 1256 | -/* --Start--Manage Menues */ | |
| 1257 | -function ___tagembed__menus($__tagembed__menu_condatation = []) | |
| 1258 | -{ | |
| 1259 | - global $wpdb; | |
| 1260 | - if (empty($__tagembed__menu_condatation)) : | |
| 1261 | - return $wpdb->get_results('SELECT * FROM wp_tagembed_menus'); | |
| 1262 | - endif; | |
| 1263 | - if (array_key_exists('__tagembed__menu_condation', $__tagembed__menu_condatation)) : | |
| 1264 | - return $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_tagembed_menus WHERE status = %s', $__tagembed__menu_condatation['__tagembed__menu_condation'])); | |
| 1265 | - endif; | |
| 1266 | - if (array_key_exists('__tagembed__menu_id', $__tagembed__menu_condatation)) : | |
| 1267 | - 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']))) : | |
| 1268 | - return true; | |
| 1269 | - else : | |
| 1270 | - return false; | |
| 1271 | - endif; | |
| 1272 | - endif; | |
| 1273 | -} | |
| 1274 | -/* --End--Manage Menues */ | |
| 1275 | - | |
| 1276 | -/* --Start-- Get User Details */ | |
| 1277 | -function ___tagembed__user($email = null) | |
| 1278 | -{ | |
| 1279 | - global $wpdb; | |
| 1280 | - $__tagembed__userResponse = ''; | |
| 1281 | - if (empty($email)) : | |
| 1282 | - $__tagembed__userResponse = $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_tagembed_user WHERE isLogin = %s', 'yes')); | |
| 1283 | - else : | |
| 1284 | - $__tagembed__userResponse = $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_tagembed_user WHERE email = %s', $email)); | |
| 1285 | - endif; | |
| 1286 | - if (!empty($__tagembed__userResponse)) : | |
| 1287 | - return $__tagembed__userResponse[0]; | |
| 1288 | - else : | |
| 1289 | - return; | |
| 1290 | - endif; | |
| 1291 | -} | |
| 1292 | -function ___tagembed__userData() | |
| 1293 | -{ | |
| 1294 | - global $wpdb; | |
| 1295 | - $__tagembed__user_dataResponse = ''; | |
| 1296 | - $__tagembed__user_dataResponse = $wpdb->get_results('SELECT * FROM wp_tagembed_user'); | |
| 1297 | - if (!empty($__tagembed__user_dataResponse)) : | |
| 1298 | - return $__tagembed__user_dataResponse[0]; | |
| 1299 | - else : | |
| 1300 | - return; | |
| 1301 | - endif; | |
| 1302 | -} | |
| 1303 | -/* --End-- Get User Details */ | |
| 1304 | - | |
| 1305 | -/* --Start-- Get Widget */ | |
| 1306 | -function ___tagembed__widgets() | |
| 1307 | -{ | |
| 1308 | - $returnWidgetData = []; | |
| 1309 | - $__tagembed__user_details = ___tagembed__user(); | |
| 1310 | - if (!empty($__tagembed__user_details)) : | |
| 1311 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/get', ['userId' => sanitize_key($__tagembed__user_details->userId)], ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1312 | - if (!isset($response->head->status)) : | |
| 1313 | - return $returnWidgetData; | |
| 1314 | - endif; | |
| 1315 | - if (false == $response->head->status || 200 != $response->head->code || false == $response->body || empty($response->body)) : | |
| 1316 | - return $returnWidgetData; | |
| 1317 | - endif; | |
| 1318 | - $returnWidgetData = $response->body; | |
| 1319 | - endif; | |
| 1320 | - return $returnWidgetData; | |
| 1321 | -} | |
| 1322 | -/* --End-- Get Widget */ | |
| 1323 | - | |
| 1324 | -/* --Start-- Get Active Widget */ | |
| 1325 | -function ___tagembed__activeWidget() | |
| 1326 | -{ | |
| 1327 | - global $wpdb; | |
| 1328 | - $__tagembed__activeWidgetResponse = ''; | |
| 1329 | - $__tagembed__activeWidgetResponse = $wpdb->get_results('SELECT * FROM wp_tagembed_active_widget'); | |
| 1330 | - if (!empty($__tagembed__activeWidgetResponse)) : | |
| 1331 | - return $__tagembed__activeWidgetResponse[0]->widgetId; | |
| 1332 | - else : | |
| 1333 | - return; | |
| 1334 | - endif; | |
| 1335 | -} | |
| 1336 | -/* --End-- Get Active Widget */ | |
| 1337 | - | |
| 1338 | -/* --Start-- Manage Active Widget User */ | |
| 1339 | -function ___tagembed__manageActiveWidget($widgetId) | |
| 1340 | -{ | |
| 1341 | - global $wpdb; | |
| 1342 | - $activeWidgetUserId = ___tagembed__activeWidget(); | |
| 1343 | - if ($activeWidgetUserId == $widgetId) : | |
| 1344 | - return true; | |
| 1345 | - endif; | |
| 1346 | - if (empty($activeWidgetUserId)) : | |
| 1347 | - $wpdb->query($wpdb->prepare('INSERT INTO wp_tagembed_active_widget (widgetId) VALUES (%s)', $widgetId)); | |
| 1348 | - return true; | |
| 1349 | - else : | |
| 1350 | - $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_widget SET widgetId = %s WHERE id = %d', $widgetId, 1)); | |
| 1351 | - return true; | |
| 1352 | - endif; | |
| 1353 | - return false; | |
| 1354 | -} | |
| 1355 | -/* --End-- Manage Active Widget User */ | |
| 1356 | - | |
| 1357 | -/* --Start-- Get Active Widget User */ | |
| 1358 | -function ___tagembed__activeWidgetUser() | |
| 1359 | -{ | |
| 1360 | - global $wpdb; | |
| 1361 | - $__tagembed__activeWidgetUserResponse = ''; | |
| 1362 | - $__tagembed__activeWidgetUserResponse = $wpdb->get_results('SELECT * FROM wp_tagembed_active_widget_user'); | |
| 1363 | - if (!empty($__tagembed__activeWidgetUserResponse)) : | |
| 1364 | - return $__tagembed__activeWidgetUserResponse[0]->userId; | |
| 1365 | - endif; | |
| 1366 | - return; | |
| 1367 | -} | |
| 1368 | -/* --End-- Get Active Widget User */ | |
| 1369 | - | |
| 1370 | -/* --Start-- Manage Active Widget User */ | |
| 1371 | -function ___tagembed__manageActiveWidgetsUser($userId) | |
| 1372 | -{ | |
| 1373 | - global $wpdb; | |
| 1374 | - $activeWidgetUserId = ___tagembed__activeWidgetUser(); | |
| 1375 | - if ($activeWidgetUserId == $userId) : | |
| 1376 | - return true; | |
| 1377 | - endif; | |
| 1378 | - if (empty($activeWidgetUserId)) : | |
| 1379 | - $wpdb->query($wpdb->prepare('INSERT INTO wp_tagembed_active_widget_user (userId) VALUES (%d)', $userId)); | |
| 1380 | - return true; | |
| 1381 | - else : | |
| 1382 | - $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_widget_user SET userId = %d WHERE id = %d', $userId, 1)); | |
| 1383 | - return true; | |
| 1384 | - endif; | |
| 1385 | - return false; | |
| 1386 | -} | |
| 1387 | -/* --End-- Manage Active Widget User */ | |
| 1388 | - | |
| 1389 | -/* * ** DATABASE *** */ | |
| 1390 | -/* --Start-- Manage Database */ | |
| 1391 | -function ___tagembed__createDatabaseTableForPlugin() | |
| 1392 | -{ | |
| 1393 | - global $wpdb; | |
| 1394 | - include_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 1395 | - $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=utf8mb4 COLLATE=utf8mb4_unicode_ci'); | |
| 1396 | - $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=utf8mb4 COLLATE=utf8mb4_unicode_ci'); | |
| 1397 | - $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=utf8mb4 COLLATE=utf8mb4_unicode_ci'); | |
| 1398 | - $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=utf8mb4 COLLATE=utf8mb4_unicode_ci'); | |
| 1399 | - $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=utf8mb4 COLLATE=utf8mb4_unicode_ci'); | |
| 1400 | - /* --Start-- Manage Tagembed Plugin Menus */ | |
| 1401 | - $__tagembed__checkAlreadyExistMenusDataExistOrNot = $wpdb->get_results('SELECT id FROM wp_tagembed_menus'); | |
| 1402 | - if (empty($__tagembed__checkAlreadyExistMenusDataExistOrNot)) : | |
| 1403 | - $__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']]; | |
| 1404 | - foreach ($__tagembed__menus as $__tagembed__menu) : | |
| 1405 | - $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'])); | |
| 1406 | - endforeach; | |
| 1407 | - endif; | |
| 1408 | - /* --End-- Manage Tagembed Plugin Menus */ | |
| 1409 | -} | |
| 1410 | -function ___tagembed__dropDatabaseTablesForPlugin() | |
| 1411 | -{ | |
| 1412 | - global $wpdb; | |
| 1413 | - $wpdb->query('DROP table IF EXISTS wp_tagembed_active_widget_user'); | |
| 1414 | - $wpdb->query('DROP table IF EXISTS wp_tagembed_active_widget'); | |
| 1415 | - $wpdb->query('DROP table IF EXISTS wp_tagembed_menus'); | |
| 1416 | -} | |
| 1417 | -/* --End-- Manage Database */ | |
| 1418 | - | |
| 1419 | -/* --Start-- Manage Active Deactive And Uninstall Webhook */ | |
| 1420 | -register_activation_hook(__FILE__, '___tagembed__pluginActivate'); | |
| 1421 | -function ___tagembed__pluginActivate() | |
| 1422 | -{ | |
| 1423 | - ___tagembed__createDatabaseTableForPlugin(); | |
| 1424 | - add_action('activated_plugin', '___tagembed__plginActivationRedirect'); | |
| 1425 | -} | |
| 1426 | -register_uninstall_hook(__FILE__, '___tagembed__pluginUnistall'); | |
| 1427 | -function ___tagembed__pluginUnistall() | |
| 1428 | -{ | |
| 1429 | - ___tagembed__dropDatabaseTablesForPlugin(); | |
| 1430 | - global $wpdb; | |
| 1431 | - $wpdb->query('DROP table IF EXISTS wp_tagembed_active_options'); | |
| 1432 | - $wpdb->query('DROP table IF EXISTS wp_tagembed_user'); | |
| 1433 | -} | |
| 1434 | -/* --End-- Manage Active Deactive And Uninstall Webhook */ | |
| 1435 | - | |
| 1436 | -/* --Start--Manage Redirect After Plugin Activate */ | |
| 1437 | -function ___tagembed__plginActivationRedirect() | |
| 1438 | -{ | |
| 1439 | - $__tagembed__activeUserData = wp_get_current_user(); | |
| 1440 | - if (empty($__tagembed__activeUserData->roles)) : | |
| 1441 | - return false; | |
| 1442 | - endif; | |
| 1443 | - $__tagembed__pluginCallbackUrl = esc_url(TAGEMBED_PLUGIN_CALL_BACK_URL); | |
| 1444 | - wp_safe_redirect($__tagembed__pluginCallbackUrl); | |
| 1445 | - exit; | |
| 1446 | -} | |
| 1447 | -/* --End--Manage Redirect After Plugin Activate */ | |
| 1448 | - | |
| 1449 | -/* --Start--Manage Setting Link */ | |
| 1450 | -function ___tagembed__settingsLink($links) | |
| 1451 | -{ | |
| 1452 | - array_unshift($links, '<a href=' . TAGEMBED_PLUGIN_CALL_BACK_URL . '>Settings</a>'); | |
| 1453 | - return $links; | |
| 1454 | -} | |
| 1455 | -add_filter('plugin_action_links_' . plugin_basename(__FILE__), '___tagembed__settingsLink'); | |
| 1456 | -/* --End--Manage Setting Link */ | |
| 1457 | - | |
| 1458 | -/* --Start--Manage Database On Plugin Update Time */ | |
| 1459 | -function ___tagembed__manageDatabaseOnPluginUpdateTime() | |
| 1460 | -{ | |
| 1461 | - ___tagembed__dropDatabaseTablesForPlugin(); | |
| 1462 | - ___tagembed__createDatabaseTableForPlugin(); | |
| 1463 | -} | |
| 1464 | -add_action('upgrader_process_complete', '___tagembed__manageDatabaseOnPluginUpdateTime', 10, 2); | |
| 1465 | -/* --End--Manage Database On Plugin Update Time */ | |
| 1466 | - | |
| 1467 | -/* --Sart--Get And Manage Social Accout Id */ | |
| 1468 | -function ___tagembed__get_user_social_account_id() | |
| 1469 | -{ | |
| 1470 | - $__tagembed__user_details = ___tagembed__user(); | |
| 1471 | - $param['userId'] = $__tagembed__user_details->userId; | |
| 1472 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getsocialaccountid', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1473 | - if (!empty($response->head->status)) : | |
| 1474 | - if (!empty($response->body->userId)) : | |
| 1475 | - return $response->body->userId; | |
| 1476 | - endif; | |
| 1477 | - endif; | |
| 1478 | - return false; | |
| 1479 | -} | |
| 1480 | -/* --End--Get And Manage Social Accout Id */ | |
| 1481 | - | |
| 1482 | -/* --Start-- Show Admin General Notification After Login And Register */ | |
| 1483 | -function ___tagembed__generalAdminNotice() | |
| 1484 | -{ | |
| 1485 | - $__tagmebed__page_name = ''; | |
| 1486 | - if (!empty($_GET['page'])) : | |
| 1487 | - $__tagmebed__page_name = ___tagembed__sanitizeRequestData($_GET); | |
| 1488 | - $__tagmebed__page_name = $__tagmebed__page_name['page']; | |
| 1489 | - endif; | |
| 1490 | - $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/notification', ['callBy' => 'wordpress'], []); | |
| 1491 | - if (!is_wp_error($response)) : | |
| 1492 | - if (!empty($response->head->status) && !empty($response->body)) : | |
| 1493 | - $response = $response->body; | |
| 1494 | - if (!empty($response->notifications) && is_array($response->notifications)) : | |
| 1495 | - $htmlData = ''; | |
| 1496 | - foreach ($response->notifications as $notifications) : | |
| 1497 | - if ('tagembed' == $notifications->location || 'inner' == $notifications->location) : | |
| 1498 | - if ('tagembed' != $__tagmebed__page_name) : | |
| 1499 | - continue; | |
| 1500 | - endif; | |
| 1501 | - $htmlData .= '<div class=\'notice notice-' . esc_attr($notifications->type) . ' is-dismissible\'>'; | |
| 1502 | - $htmlData .= '<p>' . $notifications->message . '</p>'; | |
| 1503 | - $htmlData .= '</div>'; | |
| 1504 | - elseif ('all' == $notifications->location) : | |
| 1505 | - $htmlData .= '<div class=\'notice notice-' . esc_attr($notifications->type) . ' is-dismissible\'>'; | |
| 1506 | - $htmlData .= '<p>' . $notifications->message . '</p>'; | |
| 1507 | - $htmlData .= '</div>'; | |
| 1508 | - endif; | |
| 1509 | - endforeach; | |
| 1510 | - echo wp_kses_post($htmlData); | |
| 1511 | - endif; | |
| 1512 | - endif; | |
| 1513 | - endif; | |
| 1514 | -} | |
| 1515 | -add_action('in_admin_header', '___tagembed__hideGeneralAdminNotice'); | |
| 1516 | -function ___tagembed__hideGeneralAdminNotice() | |
| 1517 | -{ | |
| 1518 | - $__tagmebed__page_name = ''; | |
| 1519 | - if (!empty($_GET['page'])) : | |
| 1520 | - $__tagmebed__page_name = ___tagembed__sanitizeRequestData($_GET); | |
| 1521 | - $__tagmebed__page_name = $__tagmebed__page_name['page']; | |
| 1522 | - endif; | |
| 1523 | - if ('tagembed' == $__tagmebed__page_name) : | |
| 1524 | - remove_all_actions('admin_notices'); | |
| 1525 | - remove_all_actions('all_admin_notices'); | |
| 1526 | - endif; | |
| 1527 | - if (!empty(___tagembed__user())) : | |
| 1528 | - add_action('admin_notices', '___tagembed__generalAdminNotice'); | |
| 1529 | - endif; | |
| 1530 | -} | |
| 1531 | -/* --End-- Show Admin General Notification After Login And Register */ | |
| 1532 | -/* --End-- Drop Database Table */ | |
| 1533 | - | |
| 1534 | -/* --Start-- Create Short Code */ | |
| 1535 | -function ___tagembed__PluginShortCode($__tagembed__shortCodeAttr) | |
| 1536 | -{ | |
| 1537 | - $__tagembed__shortCodeDefaultAttr = ['width' => '', 'height' => '', 1 => '']; | |
| 1538 | - $__tagembed__shortCodeAttr = shortcode_atts($__tagembed__shortCodeDefaultAttr, $__tagembed__shortCodeAttr, 'tagembed'); | |
| 1539 | - $width = isset($__tagembed__shortCodeAttr['width']) ? sanitize_text_field($__tagembed__shortCodeAttr['width']) : ''; | |
| 1540 | - $height = isset($__tagembed__shortCodeAttr['height']) ? sanitize_text_field($__tagembed__shortCodeAttr['height']) : ''; | |
| 1541 | - $widgetId = isset($__tagembed__shortCodeAttr[1]) ? sanitize_text_field($__tagembed__shortCodeAttr[1]) : ''; | |
| 1542 | - if (!empty($widgetId) && is_numeric($widgetId) && (('' === $width || preg_match('/^\d+(px|%|)$/', $width)) && ('' === $height || preg_match('/^\d+(px|%|)$/', $height)))) : | |
| 1543 | - $output = '<div class=\'tagembed-widget\' style=\'width:' . esc_attr($width) . '; height:' . esc_attr($height) . ';\' data-widget-id=\'' . esc_attr($widgetId) . '\' view-url=\'https://widget.tagembed.com/' . esc_attr($widgetId) . '\'></div>'; | |
| 1544 | - else : | |
| 1545 | - $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>'; | |
| 1546 | - endif; | |
| 1547 | - return $output; | |
| 1548 | -} | |
| 1549 | -add_shortcode('tagembed', '___tagembed__PluginShortCode'); | |
| 1550 | -/* --End-- Create Short Code */ | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Plugin Name: Tagembed: Social Media Feeds and Customer Reviews Widget | |
| 5 | + * Plugin URI: https://tagembed.com/ | |
| 6 | + * Description: Display social media feeds and user-generated content in an interactive widget. | |
| 7 | + * Version: 7.8 | |
| 8 | + * Author: Tagembed | |
| 9 | + * Author URI: https://tagembed.com/ | |
| 10 | + * License: GPLv3 | |
| 11 | + * License URI: https://www.gnu.org/licenses/gpl-3.0.html | |
| 12 | + * Text Domain: tagembed-widget | |
| 13 | + */ | |
| 14 | +if (!defined('WPINC')) : | |
| 15 | + die; | |
| 16 | +endif; | |
| 17 | + | |
| 18 | +/* --Start-- Create Constant */ | |
| 19 | +!defined('TAGEMBED_PLUGIN_VERSION') && define('TAGEMBED_PLUGIN_VERSION', '7.8'); | |
| 20 | +!defined('TAGEMBED_PLUGIN_DIR_PATH') && define('TAGEMBED_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__)); | |
| 21 | +!defined('TAGEMBED_PLUGIN_URL') && define('TAGEMBED_PLUGIN_URL', plugin_dir_url(__FILE__)); | |
| 22 | +!defined('TAGEMBED_PLUGIN_REDIRECT_URL') && define('TAGEMBED_PLUGIN_REDIRECT_URL', get_admin_url(null, 'admin.php?page=')); | |
| 23 | + | |
| 24 | +!defined('TAGEMBED_PLUGIN_API_URL') && define('TAGEMBED_PLUGIN_API_URL', 'https://api.tagembed.com/app/'); | |
| 25 | +!defined('TAGEMBED_PLUGIN_SERVER_URL') && define('TAGEMBED_PLUGIN_SERVER_URL', 'https://api.tagembed.com/app/'); | |
| 26 | + | |
| 27 | +!defined('TAGEMBED_PLUGIN_REACT_URL') && define('TAGEMBED_PLUGIN_REACT_URL', 'https://widget.tagembed.com/'); | |
| 28 | +!defined('TAGEMBED_PLUGIN_CALL_BACK_URL') && define('TAGEMBED_PLUGIN_CALL_BACK_URL', admin_url() . 'admin.php?page=tagembed'); | |
| 29 | +!defined('TAGEMBED_PLUGIN_PLATFORM') && define('TAGEMBED_PLUGIN_PLATFORM', 'tagembed'); | |
| 30 | + | |
| 31 | +/* --End-- Create Constant */ | |
| 32 | + | |
| 33 | +/* --Start--Include Files */ | |
| 34 | +require_once TAGEMBED_PLUGIN_DIR_PATH . 'helper/helper.php'; | |
| 35 | +/* --End--Include Files */ | |
| 36 | + | |
| 37 | +/* --Start-- Add Js And Css */ | |
| 38 | +function tagembed_plugin_scripts_css() | |
| 39 | +{ | |
| 40 | + wp_enqueue_script('__tagembed__embbedJs', TAGEMBED_PLUGIN_REACT_URL . 'embed.min.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 41 | + if (is_admin()) : | |
| 42 | + /* CSS */ | |
| 43 | + wp_enqueue_style('__tagembed__commonCss', TAGEMBED_PLUGIN_URL . '/assets/css/common.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 44 | + wp_enqueue_style('__tagembed__toastCss', TAGEMBED_PLUGIN_URL . '/assets/css/toast.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 45 | + wp_enqueue_style('__tagembed__confirmDialogCss', TAGEMBED_PLUGIN_URL . '/assets/css/confirm_dialog.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 46 | + wp_enqueue_style('__tagembed__tagembedloaderCss', TAGEMBED_PLUGIN_URL . '/assets/css/loader.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 47 | + wp_enqueue_style('__tagembed__popupCss', TAGEMBED_PLUGIN_URL . '/assets/css/styles.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 48 | + /* JS */ | |
| 49 | + wp_enqueue_script('__tagembed__toastJs', TAGEMBED_PLUGIN_URL . '/assets/js/toast.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 50 | + wp_enqueue_script('__tagembed__confirmDialogJs', TAGEMBED_PLUGIN_URL . '/assets/js/confirm_dialog.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 51 | + wp_enqueue_script('__tagembed__tagemedLoaderJs', TAGEMBED_PLUGIN_URL . '/assets/js/loader.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 52 | + wp_localize_script('__tagembed__tagemedLoaderJs', '__tagembed__pluginLoaderImageUrlObj', ['__tagembed__pluginLoaderImageUrl' => TAGEMBED_PLUGIN_URL]); | |
| 53 | + wp_enqueue_script('__tagembed__deactive-js', TAGEMBED_PLUGIN_URL . '/assets/js/tagembed.deactive.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 54 | + $__tagembed__ajax_call_security_nones = wp_create_nonce('__tagembed__ajax_call_security_nones'); | |
| 55 | + wp_localize_script('__tagembed__deactive-js', '__tagembed__ajax_call_security_nones_object', ['__tagembed__ajax_call_security_nones' => $__tagembed__ajax_call_security_nones]); | |
| 56 | + wp_enqueue_script('__tagembed__tagembedDialogFormJs', TAGEMBED_PLUGIN_URL . '/assets/js/dialog.form.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); | |
| 57 | + /* --Start-- Gutenberge */ | |
| 58 | + if (!function_exists('register_block_type')) : | |
| 59 | + return; | |
| 60 | + else : | |
| 61 | + wp_enqueue_style('__tagembed__editorCss', TAGEMBED_PLUGIN_URL . '/assets/css/editor/editor.css', '', TAGEMBED_PLUGIN_VERSION); | |
| 62 | + wp_register_script('__tagembed__editor-js', TAGEMBED_PLUGIN_URL . '/assets/js/editor/editor.js', ['wp-block-editor', 'wp-blocks', 'wp-element', 'wp-components', 'wp-i18n', 'wp-data', 'wp-compose'], TAGEMBED_PLUGIN_VERSION); | |
| 63 | + register_block_type('tagembed-block/tagembed', ['editor_script' => '__tagembed__editor-js', 'editor_style' => '__tagembed__editorCss', 'style' => '']); | |
| 64 | + endif; | |
| 65 | + /* --End-- Gutenberge */ | |
| 66 | + endif; | |
| 67 | +} | |
| 68 | +add_action('init', 'tagembed_plugin_scripts_css'); | |
| 69 | +add_filter( | |
| 70 | + 'script_loader_tag', | |
| 71 | + function ($tag, $handle) { | |
| 72 | + if ('embbedJs' !== $handle) : | |
| 73 | + return $tag; | |
| 74 | + else : | |
| 75 | + return str_replace('src', 'defer src', $tag); | |
| 76 | + endif; | |
| 77 | + }, | |
| 78 | + 10, | |
| 79 | + 2 | |
| 80 | +); | |
| 81 | +/* --End-- Add Js And Css */ | |
| 82 | + | |
| 83 | +/* --Start-- Add Menus */ | |
| 84 | +function ___tagembed__plugin_menus() | |
| 85 | +{ | |
| 86 | + ob_start(); | |
| 87 | +?> | |
| 88 | + <svg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 200 200' style='enable-background:new 0 0 200 200;' xml:space='preserve'> | |
| 89 | + <title>Tagembed Icon</title> | |
| 90 | + <g transform='translate(-211 -31)'> | |
| 91 | + <g id='Group_3576' transform='translate(211 31)'> | |
| 92 | + <path id='Path_5098' fill='#00E9FF' d='M64.3,119.1c5.4-25.2,10.2-49.2,15.6-73.8c0.6-3.6,1.2-7.2,1.8-10.8c0.6-10.8-6.6-19.8-17.4-21.6c-10.8-2.4-21,4.2-23.4,15C33,63.3,25.2,99.3,18,134.7c-3,14.4,7.2,25.2,22.8,25.2c32.4,1.2,65.4,1.8,97.8,2.4c6.6,0,12.6-0.6,18.6-3c7.8-4.2,12-13.2,9.6-22.2c-2.4-9.6-10.8-16.2-20.4-16.2c-21-0.6-42.6-1.2-63.6-1.8C76.9,119.1,70.9,119.1,64.3,119.1z' /> | |
| 93 | + <path id='Path_5099' fill='#4179FF' d='M136.9,81.9c-25.8,0-50.4,0-75,0c-3.6,0-7.2,0-10.8-0.6c-10.8-1.8-18-10.8-18-21.6s9-19.8,19.8-19.8c36,0,72.6,0,109.2,0c14.4,0,22.8,12,19.8,27.6c-6,31.8-12,64.2-18,96c-1.2,6.6-3.6,12.6-7.2,17.4c-6,6.6-15.6,8.4-23.4,4.8c-9-4.2-13.2-13.8-11.4-23.4c3.6-21,7.8-41.4,11.4-62.4C134.5,94.5,135.7,87.9,136.9,81.9z' /> | |
| 94 | + <g id='Group_3575' transform='translate(16.61 16.942)'> | |
| 95 | + <g> | |
| 96 | + <g> | |
| 97 | + <defs> | |
| 98 | + <polygon id='SVGID_1_' points='113.1,97 101.1,148.7 147.3,148.7 158.1,103.6' /> | |
| 99 | + </defs> | |
| 100 | + <clipPath id='SVGID_2_'> | |
| 101 | + <use xlink:href='#SVGID_1_' style='overflow:visible;' /> | |
| 102 | + </clipPath> | |
| 103 | + <g id='Group_3574' class='st2' clip-path='url(#SVGID_2_)'> | |
| 104 | + <path id='Path_5100' fill='#00E9FF' d='M47.7,101.8C53.1,76.6,57.9,52.6,63.3,28c0.6-3.6,1.2-7.2,1.8-10.8C65.7,6.4,58.5-2.6,47.7-4.4c-10.8-1.8-21,4.8-23.4,15.6C16.5,46.6,8.7,82,1.5,118.1c-3,14.4,7.2,25.2,22.8,25.2c33,0.6,65.4,1.8,98.4,2.4c6.6,0,12.6-0.6,18.6-3c7.8-4.2,12-13.2,9.6-22.2c-2.4-9.6-10.8-16.2-21-16.2c-21-0.6-42-1.2-63-1.8C60.3,102.4,54.3,102.4,47.7,101.8z' /> | |
| 105 | + </g> | |
| 106 | + </g> | |
| 107 | + </g> | |
| 108 | + </g> | |
| 109 | + </g> | |
| 110 | + </g> | |
| 111 | + </svg> | |
| 112 | +<?php | |
| 113 | + $svg = ob_get_clean(); | |
| 114 | + add_menu_page('Tagembed', 'Tagembed', 'manage_options', 'tagembed', '___tagembed__view', 'data:image/svg+xml;base64,' . base64_encode($svg)); | |
| 115 | +} | |
| 116 | +add_action('admin_menu', '___tagembed__plugin_menus'); | |
| 117 | +/* --End-- Add Menus */ | |
| 118 | + | |
| 119 | +/* --Start-- Add & Manage Views */ | |
| 120 | +function ___tagembed__view() | |
| 121 | +{ | |
| 122 | + if (!empty(___tagembed__user()->isLogin) && ___tagembed__user()->isLogin == 'yes') : | |
| 123 | + $__tagembed__menus = ___tagembed__menus(['__tagembed__menu_condation' => 1]); | |
| 124 | + if (empty($__tagembed__menus)) : | |
| 125 | + include_once TAGEMBED_PLUGIN_DIR_PATH . 'views/widget/widgetView.php'; | |
| 126 | + else : | |
| 127 | + include_once TAGEMBED_PLUGIN_DIR_PATH . 'views/' . $__tagembed__menus[0]->path . '.php'; | |
| 128 | + endif; | |
| 129 | + else : | |
| 130 | + include_once TAGEMBED_PLUGIN_DIR_PATH . 'views/account/accountView.php'; | |
| 131 | + endif; | |
| 132 | +} | |
| 133 | +/* --End-- Add & Manage Views */ | |
| 134 | + | |
| 135 | +/* --Start-- Manage Ajax Calls */ | |
| 136 | +add_action('wp_ajax_tagembed_data', '___tagembed__dataAjaxHandler'); | |
| 137 | +function ___tagembed__dataAjaxHandler() | |
| 138 | +{ | |
| 139 | + if (!current_user_can('manage_options')) : | |
| 140 | + return ___tagembed__exitWithDanger('You do not have sufficient permissions to access this page.'); | |
| 141 | + endif; | |
| 142 | + /* --Start-- Manage Ajax call Request Security (Verified Before Any Other Request Data Is Used) */ | |
| 143 | + $__tagembed__ajaxCallSecurityNones = isset($_REQUEST['__tagembed__ajax_call_nones']) ? sanitize_text_field(wp_unslash($_REQUEST['__tagembed__ajax_call_nones'])) : ''; | |
| 144 | + if (!wp_verify_nonce($__tagembed__ajaxCallSecurityNones, '__tagembed__ajax_call_security_nones')) : | |
| 145 | + return ___tagembed__exitWithDanger(); | |
| 146 | + endif; | |
| 147 | + /* --End-- Manage Ajax call Request Security */ | |
| 148 | + if (empty($_REQUEST['__tagembed__ajax_action'])) : | |
| 149 | + return false; | |
| 150 | + endif; | |
| 151 | + $data = ___tagembed__sanitizeRequestData(wp_unslash($_REQUEST)); | |
| 152 | + $data = (object)$data; | |
| 153 | + /* --Start__ Sanetize All Input */ | |
| 154 | + foreach ($data as $key => $value) : | |
| 155 | + if (!in_array($key, ['emailId', 'password', 'youtubePlaylist'])) : | |
| 156 | + ___tagembed__inputSanetize($value); | |
| 157 | + endif; | |
| 158 | + endforeach; | |
| 159 | + /* --End__ Sanetize All Input */ | |
| 160 | + | |
| 161 | + $param = []; | |
| 162 | + $action = $data->__tagembed__ajax_action; | |
| 163 | + $__tagembed__user_details = ___tagembed__user(); | |
| 164 | + switch ($action): | |
| 165 | + case '__tagembed__getCallingCode': | |
| 166 | + /* --Start-- Manage Param Data */ | |
| 167 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 168 | + /* --End-- Manage Param Data */ | |
| 169 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getCallingCode', $param, []); | |
| 170 | + $response = ___tagembed__manageApiResponse($response); | |
| 171 | + unset($param); | |
| 172 | + return ___tagembed__exitWithSuccess(['callingCode' => $response]); | |
| 173 | + break; | |
| 174 | + case '__tagembed__register': | |
| 175 | + if (empty($data->emailId) || empty($data->password) || empty($data->fullName)) : | |
| 176 | + return ___tagembed__exitWithDanger(); | |
| 177 | + endif; | |
| 178 | + /* --Start-- Manage Param Data */ | |
| 179 | + $param['fullName'] = sanitize_text_field($data->fullName); | |
| 180 | + $param['emailId'] = sanitize_email($data->emailId); | |
| 181 | + $param['password'] = $data->password; | |
| 182 | + $param['contact_no'] = $data->contact_no; | |
| 183 | + $param['calling_code'] = $data->calling_code; | |
| 184 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 185 | + /* --End-- Manage Param Data */ | |
| 186 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/register', $param, []); | |
| 187 | + $response = ___tagembed__manageApiResponse($response); | |
| 188 | + unset($param); | |
| 189 | + $param = ['userId' => sanitize_key($response->userId), 'inheritStyles' => 1]; | |
| 190 | + ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $response->access_token]); | |
| 191 | + if (___tagembed__login($response) == true) : | |
| 192 | + return ___tagembed__exitWithSuccess(['redirectUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL]); | |
| 193 | + else : | |
| 194 | + return ___tagembed__exitWithDanger(); | |
| 195 | + endif; | |
| 196 | + break; | |
| 197 | + case '__tagembed__login': | |
| 198 | + if (empty($data->emailId) || empty($data->password)) : | |
| 199 | + return ___tagembed__exitWithDanger(); | |
| 200 | + endif; | |
| 201 | + /* --Start-- Manage Param Data */ | |
| 202 | + $param['emailId'] = sanitize_email($data->emailId); | |
| 203 | + $param['password'] = $data->password; | |
| 204 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 205 | + /* --End-- Manage Param Data */ | |
| 206 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/login', $param, []); | |
| 207 | + unset($param); | |
| 208 | + $response = ___tagembed__manageApiResponse($response); | |
| 209 | + if (___tagembed__login($response) == true) : | |
| 210 | + return ___tagembed__exitWithSuccess(['redirectUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL]); | |
| 211 | + else : | |
| 212 | + return ___tagembed__exitWithDanger(); | |
| 213 | + endif; | |
| 214 | + break; | |
| 215 | + case '__tagembed__google_auth_url': | |
| 216 | + $__tagembed__google_state = wp_generate_password(32, false, false); | |
| 217 | + $__tagembed__google_verifier = wp_generate_password(64, false, false); | |
| 218 | + set_transient('__tagembed__google_' . $__tagembed__google_state, ['verifier' => $__tagembed__google_verifier, 'userId' => get_current_user_id()], 10 * MINUTE_IN_SECONDS); | |
| 219 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 220 | + $param['state'] = $__tagembed__google_state; | |
| 221 | + $param['challenge'] = hash('sha256', $__tagembed__google_verifier); | |
| 222 | + $param['returnUrl'] = TAGEMBED_PLUGIN_CALL_BACK_URL; | |
| 223 | + $__tagembed__google_auth_url = TAGEMBED_PLUGIN_API_URL . 'apiaccount/googleauth?' . http_build_query($param, '', '&'); | |
| 224 | + unset($param); | |
| 225 | + return ___tagembed__exitWithSuccess(['authUrl' => $__tagembed__google_auth_url]); | |
| 226 | + break; | |
| 227 | + case '__tagembed__logout': | |
| 228 | + if (tagembed_logout()) : | |
| 229 | + return ___tagembed__exitWithSuccess(['redirectUrl' => TAGEMBED_PLUGIN_REDIRECT_URL . 'tagembed']); | |
| 230 | + else : | |
| 231 | + return ___tagembed__exitWithDanger(); | |
| 232 | + endif; | |
| 233 | + break; | |
| 234 | + case '__tagembed__check_plan_premium_feature': | |
| 235 | + if (empty($__tagembed__user_details)) : | |
| 236 | + return ___tagembed__exitWithDanger(); | |
| 237 | + endif; | |
| 238 | + /* --Start-- Manage Param Data */ | |
| 239 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 240 | + /* --End-- Manage Param Data */ | |
| 241 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/checkPlanPremiumFeature', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 242 | + unset($param); | |
| 243 | + $response = ___tagembed__manageApiResponse($response); | |
| 244 | + return ___tagembed__exitWithSuccess($response); | |
| 245 | + break; | |
| 246 | + case '__tagembed__check_user_accout_status': | |
| 247 | + if (empty($__tagembed__user_details)) : | |
| 248 | + return ___tagembed__exitWithDanger(); | |
| 249 | + endif; | |
| 250 | + /* --Start-- Manage Param Data */ | |
| 251 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 252 | + /* --End-- Manage Param Data */ | |
| 253 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/checkUserAccountStatus', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 254 | + unset($param); | |
| 255 | + $response = ___tagembed__manageApiResponse($response); | |
| 256 | + return ___tagembed__exitWithSuccess($response); | |
| 257 | + break; | |
| 258 | + case '__tagembed__get_account_details': | |
| 259 | + $data->auth = !empty($data->auth) ? 1 : 0; | |
| 260 | + if (empty($__tagembed__user_details)) : | |
| 261 | + return ___tagembed__exitWithDanger(); | |
| 262 | + endif; | |
| 263 | + /* --Start-- Manage Param Data */ | |
| 264 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 265 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 266 | + /* --End-- Manage Param Data */ | |
| 267 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getdetails', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 268 | + unset($param); | |
| 269 | + $response = ___tagembed__manageApiResponse($response); | |
| 270 | + return ___tagembed__exitWithSuccess($response); | |
| 271 | + break; | |
| 272 | + | |
| 273 | + case '__tagembed__manage_active_widget': | |
| 274 | + if (empty($data->widgetId)) : | |
| 275 | + return ___tagembed__exitWithDanger(); | |
| 276 | + endif; | |
| 277 | + if (___tagembed__manageActiveWidget($data->widgetId)) : | |
| 278 | + return ___tagembed__exitWithSuccess(); | |
| 279 | + else : | |
| 280 | + return ___tagembed__exitWithDanger(); | |
| 281 | + endif; | |
| 282 | + break; | |
| 283 | + case '__tagembed__menue': | |
| 284 | + if (empty($data->menueId)) : | |
| 285 | + return ___tagembed__exitWithDanger(); | |
| 286 | + endif; | |
| 287 | + if (___tagembed__menus(['__tagembed__menu_id' => $data->menueId])) : | |
| 288 | + return ___tagembed__exitWithSuccess(['redirectUrl' => TAGEMBED_PLUGIN_REDIRECT_URL . 'tagembed']); | |
| 289 | + else : | |
| 290 | + return ___tagembed__exitWithDanger(); | |
| 291 | + endif; | |
| 292 | + break; | |
| 293 | + case '__tagembed__create_widget': | |
| 294 | + if (empty($__tagembed__user_details) || empty($data->name)) : | |
| 295 | + return ___tagembed__exitWithDanger('Validation Error', ['name' => 'Widget name is required']); | |
| 296 | + endif; | |
| 297 | + $data->profanity = (isset($data->profanity)) ? 0 : 1; | |
| 298 | + /* --Start-- Manage Param Data */ | |
| 299 | + $param['name'] = sanitize_text_field($data->name); | |
| 300 | + $param['profanity'] = sanitize_key($data->profanity); | |
| 301 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 302 | + $param['inheritStyles'] = 1; | |
| 303 | + /* --End-- Manage Param Data */ | |
| 304 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 305 | + unset($param); | |
| 306 | + $response = ___tagembed__manageApiResponse($response); | |
| 307 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 308 | + return ___tagembed__exitWithSuccess(['message' => $response, 'redirectUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL]); | |
| 309 | + break; | |
| 310 | + case '__tagembed__edit_widget': | |
| 311 | + if (empty($__tagembed__user_details) || empty($data->name) || empty($data->widgetId)) : | |
| 312 | + return ___tagembed__exitWithDanger('Validation Error', ['name' => 'Widget name is required']); | |
| 313 | + endif; | |
| 314 | + /* --Start-- Manage Param Data */ | |
| 315 | + $param['name'] = sanitize_text_field($data->name); | |
| 316 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 317 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 318 | + /* --End-- Manage Param Data */ | |
| 319 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/edit', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 320 | + unset($param); | |
| 321 | + $response = ___tagembed__manageApiResponse($response); | |
| 322 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 323 | + return ___tagembed__exitWithSuccess(['message' => $response, 'redirectUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL]); | |
| 324 | + break; | |
| 325 | + case '__tagembed__update_widget_status': | |
| 326 | + if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 327 | + return ___tagembed__exitWithDanger(); | |
| 328 | + endif; | |
| 329 | + /* --Start-- Manage Param Data */ | |
| 330 | + $param['status'] = sanitize_key($data->status); | |
| 331 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 332 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 333 | + /* --End-- Manage Param Data */ | |
| 334 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 335 | + unset($param); | |
| 336 | + $response = ___tagembed__manageApiResponse($response); | |
| 337 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 338 | + return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 339 | + break; | |
| 340 | + case '__tagembed__delete_widget': | |
| 341 | + if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 342 | + return ___tagembed__exitWithDanger(); | |
| 343 | + endif; | |
| 344 | + /* --Start-- Manage Param Data */ | |
| 345 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 346 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 347 | + /* --End-- Manage Param Data */ | |
| 348 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 349 | + unset($param); | |
| 350 | + $response = ___tagembed__manageApiResponse($response); | |
| 351 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 352 | + return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 353 | + break; | |
| 354 | + case '__tagembed__source_networks': | |
| 355 | + $data->auth = !empty($data->auth) ? 1 : 0; | |
| 356 | + if (empty($__tagembed__user_details)) : | |
| 357 | + return ___tagembed__exitWithDanger(); | |
| 358 | + endif; | |
| 359 | + /* --Start-- Manage Param Data */ | |
| 360 | + $param['auth'] = sanitize_key($data->auth); | |
| 361 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 362 | + /* --End-- Manage Param Data */ | |
| 363 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apinetwork/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 364 | + unset($param); | |
| 365 | + $response = ___tagembed__manageApiResponse($response); | |
| 366 | + return ___tagembed__exitWithSuccess($response); | |
| 367 | + break; | |
| 368 | + case '__tagembed__get_themes': | |
| 369 | + if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 370 | + return ___tagembed__exitWithDanger(); | |
| 371 | + endif; | |
| 372 | + /* --Start-- Manage Param Data */ | |
| 373 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 374 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 375 | + /* --End-- Manage Param Data */ | |
| 376 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'Apitheme/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 377 | + unset($param); | |
| 378 | + $response = ___tagembed__manageApiResponse($response); | |
| 379 | + return ___tagembed__exitWithSuccess($response); | |
| 380 | + break; | |
| 381 | + case '__tagembed__edit_themes': | |
| 382 | + if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->themeId)) : | |
| 383 | + return ___tagembed__exitWithDanger(); | |
| 384 | + endif; | |
| 385 | + /* --Start-- Manage Param Data */ | |
| 386 | + $param['themeId'] = sanitize_key($data->themeId); | |
| 387 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 388 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 389 | + /* --End-- Manage Param Data */ | |
| 390 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'Apitheme/edit', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 391 | + unset($param); | |
| 392 | + $response = ___tagembed__manageApiResponse($response); | |
| 393 | + return ___tagembed__exitWithSuccess($response); | |
| 394 | + break; | |
| 395 | + case '__tagembed__get_network_filter': | |
| 396 | + if (empty($__tagembed__user_details) || empty($data->networkId)) : | |
| 397 | + return ___tagembed__exitWithDanger(); | |
| 398 | + endif; | |
| 399 | + /* --Start-- Manage Param Data */ | |
| 400 | + $param['networkId'] = sanitize_key($data->networkId); | |
| 401 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 402 | + /* --End-- Manage Param Data */ | |
| 403 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apinetwork/filter', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 404 | + unset($param); | |
| 405 | + $response = ___tagembed__manageApiResponse($response); | |
| 406 | + return ___tagembed__exitWithSuccess($response); | |
| 407 | + break; | |
| 408 | + case '__tagembed__get_already_exist_accounts': | |
| 409 | + if (empty($__tagembed__user_details)) : | |
| 410 | + return ___tagembed__exitWithDanger(); | |
| 411 | + endif; | |
| 412 | + /* --Start-- Manage Param Data */ | |
| 413 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 414 | + /* --End-- Manage Param Data */ | |
| 415 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/getalreadyexistaccounts', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 416 | + unset($param); | |
| 417 | + $response = ___tagembed__manageApiResponse($response); | |
| 418 | + return ___tagembed__exitWithSuccess($response); | |
| 419 | + break; | |
| 420 | + case '__tagembed__add_or_update_account': | |
| 421 | + if (empty($__tagembed__user_details) || empty($data->networkId) || empty($data->type)) : | |
| 422 | + return ___tagembed__exitWithDanger(); | |
| 423 | + endif; | |
| 424 | + /* --Start-- Manage Param Data */ | |
| 425 | + $param['connectedAccountId'] = $data->connectedAccountId; | |
| 426 | + $param['feedId'] = sanitize_key($data->feedId); | |
| 427 | + $param['type'] = sanitize_text_field($data->type); | |
| 428 | + $param['networkId'] = sanitize_key($data->networkId); | |
| 429 | + $param['filterId'] = sanitize_key($data->filterId); | |
| 430 | + $param['otherData'] = $data->otherData; | |
| 431 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 432 | + /* --End-- Manage Param Data */ | |
| 433 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/addorupdate', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 434 | + unset($param); | |
| 435 | + $response = ___tagembed__manageApiResponse($response); | |
| 436 | + return ___tagembed__exitWithSuccess(['__tagembed__requestCallBackUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL, 'redirectUrl' => TAGEMBED_PLUGIN_API_URL . 'apiauth/getauth', '__tagembed__feedData' => $response->__tagembed__feedData]); | |
| 437 | + break; | |
| 438 | + case '__tagembed__delete_account': | |
| 439 | + if (empty($__tagembed__user_details) || empty($data->networkId) || empty($data->parentId)) : | |
| 440 | + return ___tagembed__exitWithDanger(); | |
| 441 | + endif; | |
| 442 | + /* --Start-- Manage Param Data */ | |
| 443 | + $param['parentId'] = sanitize_key($data->parentId); | |
| 444 | + $param['networkId'] = sanitize_key($data->networkId); | |
| 445 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 446 | + /* --End-- Manage Param Data */ | |
| 447 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 448 | + unset($param); | |
| 449 | + $response = ___tagembed__manageApiResponse($response); | |
| 450 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 451 | + return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 452 | + break; | |
| 453 | + case '__tagembed__get_already_exist_auth': | |
| 454 | + if (empty($__tagembed__user_details) || empty($data->networkId)) : | |
| 455 | + return ___tagembed__exitWithDanger(); | |
| 456 | + endif; | |
| 457 | + /* --Start-- Manage Param Data */ | |
| 458 | + $param['networkId'] = sanitize_key($data->networkId); | |
| 459 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 460 | + /* --End-- Manage Param Data */ | |
| 461 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 462 | + unset($param); | |
| 463 | + $response = ___tagembed__manageApiResponse($response); | |
| 464 | + return ___tagembed__exitWithSuccess($response); | |
| 465 | + break; | |
| 466 | + case '__tagembed__search_google_location': | |
| 467 | + if (empty($__tagembed__user_details) || empty($data->googleLocationName)) : | |
| 468 | + return ___tagembed__exitWithDanger(); | |
| 469 | + endif; | |
| 470 | + /* --Start-- Manage Param Data */ | |
| 471 | + $param['googleLocationName'] = $data->googleLocationName; | |
| 472 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 473 | + /* --End-- Manage Param Data */ | |
| 474 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchgooglelocation', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 475 | + unset($param); | |
| 476 | + $response = ___tagembed__manageApiResponse($response); | |
| 477 | + return ___tagembed__exitWithSuccess($response); | |
| 478 | + break; | |
| 479 | + case '__tagembed__search_vk_communities': | |
| 480 | + if (empty($__tagembed__user_details) || empty($data->vkCommunitiesName)) : | |
| 481 | + return ___tagembed__exitWithDanger(); | |
| 482 | + endif; | |
| 483 | + /* --Start-- Manage Param Data */ | |
| 484 | + $param['vkCommunitiesName'] = $data->vkCommunitiesName; | |
| 485 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 486 | + /* --End-- Manage Param Data */ | |
| 487 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchVkCommunities', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 488 | + unset($param); | |
| 489 | + $response = ___tagembed__manageApiResponse($response); | |
| 490 | + return ___tagembed__exitWithSuccess($response); | |
| 491 | + break; | |
| 492 | + case '__tagembed__search_facebook_page': | |
| 493 | + if (empty($data->facebookPageData)) : | |
| 494 | + return ___tagembed__exitWithDanger(); | |
| 495 | + endif; | |
| 496 | + /* --Start-- Manage Param Data */ | |
| 497 | + $param['facebookPageData'] = $data->facebookPageData; | |
| 498 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 499 | + /* --End-- Manage Param Data */ | |
| 500 | + /* --Start-- Call And Manage Api Call */ | |
| 501 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchfacebookpage', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 502 | + unset($param); | |
| 503 | + $response = ___tagembed__manageApiResponse($response); | |
| 504 | + return ___tagembed__exitWithSuccess($response); | |
| 505 | + break; | |
| 506 | + case '__tagembed__get_facebook_page_albums': | |
| 507 | + if (empty($__tagembed__user_details) || empty($data->connectedAccountsId)) : | |
| 508 | + return ___tagembed__exitWithDanger(); | |
| 509 | + endif; | |
| 510 | + /* --Start-- Manage Param Data */ | |
| 511 | + $param['connectedAccountsId'] = sanitize_key($data->connectedAccountsId); | |
| 512 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 513 | + /* --End-- Manage Param Data */ | |
| 514 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/apiauthfacebookpagealbums', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 515 | + unset($param); | |
| 516 | + $response = ___tagembed__manageApiResponse($response); | |
| 517 | + return ___tagembed__exitWithSuccess($response); | |
| 518 | + break; | |
| 519 | + case '__tagembed__search_youtube_channel': | |
| 520 | + if (empty($__tagembed__user_details) || empty($data->youtubeChannelData)) : | |
| 521 | + return ___tagembed__exitWithDanger(); | |
| 522 | + endif; | |
| 523 | + /* --Start-- Manage Param Data */ | |
| 524 | + $param['youtubeChannelData'] = $data->youtubeChannelData; | |
| 525 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 526 | + /* --End-- Manage Param Data */ | |
| 527 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchyoutubechannel', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 528 | + unset($param); | |
| 529 | + $response = ___tagembed__manageApiResponse($response); | |
| 530 | + return ___tagembed__exitWithSuccess($response); | |
| 531 | + break; | |
| 532 | + case '__tagembed__get_youtube_playlist': | |
| 533 | + if (empty($__tagembed__user_details) || empty($data->youtubeId)) : | |
| 534 | + return ___tagembed__exitWithDanger(); | |
| 535 | + endif; | |
| 536 | + /* --Start-- Manage Param Data */ | |
| 537 | + $param['youtubeId'] = $data->youtubeId; | |
| 538 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 539 | + /* --End-- Manage Param Data */ | |
| 540 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getyoutubeplaylist', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 541 | + unset($param); | |
| 542 | + $response = ___tagembed__manageApiResponse($response); | |
| 543 | + return ___tagembed__exitWithSuccess($response); | |
| 544 | + break; | |
| 545 | + case '__tagembed__get_slack_channel_list': | |
| 546 | + if (empty($data->connectedAccountsId)) : | |
| 547 | + return ___tagembed__exitWithDanger(); | |
| 548 | + endif; | |
| 549 | + /* --Start-- Manage Param Data */ | |
| 550 | + $param['connectedAccountsId'] = $data->connectedAccountsId; | |
| 551 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 552 | + /* --End-- Manage Param Data */ | |
| 553 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getslackchannellist', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 554 | + unset($param); | |
| 555 | + $response = ___tagembed__manageApiResponse($response); | |
| 556 | + return ___tagembed__exitWithSuccess($response); | |
| 557 | + break; | |
| 558 | + case '__tagembed__get_feed': | |
| 559 | + if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 560 | + return ___tagembed__exitWithDanger(); | |
| 561 | + endif; | |
| 562 | + /* --Start-- Manage Param Data */ | |
| 563 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 564 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 565 | + /* --End-- Manage Param Data */ | |
| 566 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 567 | + unset($param); | |
| 568 | + $response = ___tagembed__manageApiResponse($response); | |
| 569 | + return ___tagembed__exitWithSuccess($response); | |
| 570 | + break; | |
| 571 | + case '__tagembed__update_feed_status': | |
| 572 | + if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->feedId)) : | |
| 573 | + return ___tagembed__exitWithDanger(); | |
| 574 | + endif; | |
| 575 | + /* --Start-- Manage Param Data */ | |
| 576 | + $param['feedId'] = sanitize_key($data->feedId); | |
| 577 | + $param['status'] = sanitize_key($data->status); | |
| 578 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 579 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 580 | + /* --End-- Manage Param Data */ | |
| 581 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 582 | + unset($param); | |
| 583 | + $response = ___tagembed__manageApiResponse($response); | |
| 584 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 585 | + return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 586 | + break; | |
| 587 | + case '__tagembed__delete_feed': | |
| 588 | + if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->feedId)) : | |
| 589 | + return ___tagembed__exitWithDanger(); | |
| 590 | + endif; | |
| 591 | + /* --Start-- Manage Param Data */ | |
| 592 | + $param['feedId'] = sanitize_key($data->feedId); | |
| 593 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 594 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 595 | + /* --End-- Manage Param Data */ | |
| 596 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 597 | + unset($param); | |
| 598 | + $response = ___tagembed__manageApiResponse($response); | |
| 599 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 600 | + return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 601 | + break; | |
| 602 | + case '__tagembed__create_feed': | |
| 603 | + if (empty($__tagembed__user_details) || empty($data->widgetName) || empty($data->networkName) || empty($data->filterName) || empty($data->widgetId) || empty($data->networkId) || empty($data->filterId)) : | |
| 604 | + return ___tagembed__exitWithDanger(); | |
| 605 | + endif; | |
| 606 | + $__tagembed__feed_input_data = ['feed' => sanitize_text_field($data->feed), 'userId' => sanitize_key($__tagembed__user_details->userId), 'moderation' => sanitize_key(isset($data->moderation) ? 1 : 0), 'widgetName' => sanitize_text_field($data->widgetName), 'networkName' => sanitize_text_field($data->networkName), 'filterName' => sanitize_text_field($data->filterName), 'widgetId' => sanitize_key($data->widgetId), 'networkId' => sanitize_key($data->networkId), 'filterId' => sanitize_key($data->filterId), 'auth' => 0, 'authId' => isset($data->authId) ? sanitize_key($data->authId) : 0]; | |
| 607 | + $__tagembed__feed_input_data['feed'] = !empty($data->feed) ? sanitize_text_field($data->feed) : '__tagembed__feed'; | |
| 608 | + $__tagembed__feed_filter_id = $data->filterId; | |
| 609 | + switch ($__tagembed__feed_input_data['networkId']): | |
| 610 | + case 1: | |
| 611 | + $__tagembed__feed_input_data['auth'] = 1; | |
| 612 | + $__tagembed__feed_input_data['multiplePhoto'] = sanitize_key(isset($data->multiplePhoto) ? 1 : 0); | |
| 613 | + $__tagembed__feed_input_data['excludeRetweet'] = sanitize_key(isset($data->excludeRetweet) ? 1 : 0); | |
| 614 | + if (!empty($data->list)) : | |
| 615 | + $__tagembed__feed_input_data['list'] = sanitize_key($data->list); | |
| 616 | + endif; | |
| 617 | + break; | |
| 618 | + case 2: | |
| 619 | + $__tagembed__feed_input_data['auth'] = 1; | |
| 620 | + break; | |
| 621 | + case 3: | |
| 622 | + $__tagembed__feed_input_data['auth'] = 1; | |
| 623 | + switch ($__tagembed__feed_filter_id): | |
| 624 | + case 65: | |
| 625 | + $__tagembed__feed_input_data['accountAlbumType'] = sanitize_key(isset($data->accountAlbumType) ? $data->accountAlbumType : ''); | |
| 626 | + $__tagembed__feed_input_data['accountAlbumData'] = sanitize_text_field(isset($data->accountAlbumData) ? $data->accountAlbumData : ''); | |
| 627 | + break; | |
| 628 | + endswitch; | |
| 629 | + break; | |
| 630 | + case 4: | |
| 631 | + if ($__tagembed__feed_filter_id == 29) : | |
| 632 | + $__tagembed__feed_input_data['auth'] = 1; | |
| 633 | + else : | |
| 634 | + $__tagembed__feed_input_data['placeId'] = $data->placeId; | |
| 635 | + $__tagembed__feed_input_data['placeName'] = $data->placeName; | |
| 636 | + endif; | |
| 637 | + break; | |
| 638 | + case 5: | |
| 639 | + switch ($__tagembed__feed_filter_id): | |
| 640 | + case 1: | |
| 641 | + case 71: | |
| 642 | + break; | |
| 643 | + case 12: | |
| 644 | + if (!preg_match('/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 645 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 646 | + endif; | |
| 647 | + $pintrestHeaders = explode('/', parse_url($data->feed)['path']); | |
| 648 | + $__tagembed__feed_input_data['value1'] = strtolower($pintrestHeaders[1]); | |
| 649 | + $__tagembed__feed_input_data['value2'] = strtolower($pintrestHeaders[2]); | |
| 650 | + break; | |
| 651 | + endswitch; | |
| 652 | + break; | |
| 653 | + case 6: | |
| 654 | + switch ($__tagembed__feed_filter_id): | |
| 655 | + case 1: | |
| 656 | + case 2: | |
| 657 | + $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; | |
| 658 | + break; | |
| 659 | + endswitch; | |
| 660 | + break; | |
| 661 | + case 7: | |
| 662 | + if (in_array($__tagembed__feed_filter_id, [1, 71])) : | |
| 663 | + $isUrl = false; | |
| 664 | + if (preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 665 | + $isUrl = true; | |
| 666 | + endif; | |
| 667 | + if ((empty($data->youtubeId) || empty($data->youtubeName)) && !$isUrl) : | |
| 668 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid Channel URL Or Tab On Search Icon']); | |
| 669 | + endif; | |
| 670 | + if ($isUrl) : | |
| 671 | + $data->youtubeId = explode('/', $data->feed); | |
| 672 | + $data->youtubeId = $data->youtubeId[4]; | |
| 673 | + $data->youtubeName = 'youtube'; | |
| 674 | + if (empty($data->youtubeId) || empty($data->youtubeName)) : | |
| 675 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid Channel URL']); | |
| 676 | + endif; | |
| 677 | + endif; | |
| 678 | + endif; | |
| 679 | + switch ($__tagembed__feed_filter_id): | |
| 680 | + case 1: | |
| 681 | + case 75: | |
| 682 | + $__tagembed__feed_input_data['youtubeId'] = $data->youtubeId; | |
| 683 | + $__tagembed__feed_input_data['youtubeName'] = $data->youtubeName; | |
| 684 | + break; | |
| 685 | + case 11: | |
| 686 | + if (empty($data->youtubePlaylist) && empty($data->youtubeId)) : | |
| 687 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid Channel URL Or Tab On Search Icon']); | |
| 688 | + elseif (empty($data->youtubePlaylist) && !empty($data->youtubeId)) : | |
| 689 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Play List Not Found']); | |
| 690 | + endif; | |
| 691 | + $data->youtubePlaylist = explode('#', $data->youtubePlaylist); | |
| 692 | + $__tagembed__feed_input_data['youtubeId'] = $data->youtubePlaylist[0]; | |
| 693 | + $__tagembed__feed_input_data['youtubeName'] = $data->youtubePlaylist[1]; | |
| 694 | + $__tagembed__feed_input_data['feed'] = $data->youtubePlaylist[1]; | |
| 695 | + unset($data->youtubePlaylist); | |
| 696 | + break; | |
| 697 | + endswitch; | |
| 698 | + break; | |
| 699 | + case 8: | |
| 700 | + switch ($__tagembed__feed_filter_id): | |
| 701 | + case 1: | |
| 702 | + case 2: | |
| 703 | + $__tagembed__feed_input_data['auth'] = 1; | |
| 704 | + break; | |
| 705 | + endswitch; | |
| 706 | + break; | |
| 707 | + case 10: | |
| 708 | + 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)) : | |
| 710 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 711 | + endif; | |
| 712 | + endif; | |
| 713 | + switch ($__tagembed__feed_filter_id): | |
| 714 | + 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']); | |
| 718 | + 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 : | |
| 732 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); | |
| 733 | + endif; | |
| 734 | + preg_match_all('!\d+!', $postId, $postId); | |
| 735 | + if (isset($postId[0][0]) && empty($postId[0][0])) : | |
| 736 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); | |
| 737 | + 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; | |
| 745 | + break; | |
| 746 | + case 1: | |
| 747 | + case 17: | |
| 748 | + $url = parse_url($data->feed); | |
| 749 | + $companyPageUrl = $url['scheme'] . '://' . $url['host']; | |
| 750 | + $url = explode('/', $url['path']); | |
| 751 | + $companyPageUrl = $companyPageUrl . '/' . $url[1] . '/' . $url[2] . '/'; | |
| 752 | + $__tagembed__feed_input_data['feed'] = $companyPageUrl; | |
| 753 | + $url[2] = str_replace('-', ' ', '$url[2]'); | |
| 754 | + $__tagembed__feed_input_data['page'] = ucwords($url[2], ' '); | |
| 755 | + break; | |
| 756 | + case 2: | |
| 757 | + $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; | |
| 758 | + break; | |
| 759 | + endswitch; | |
| 760 | + break; | |
| 761 | + case 11: | |
| 762 | + switch ($__tagembed__feed_filter_id): | |
| 763 | + case 1: | |
| 764 | + case 2: | |
| 765 | + $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; | |
| 766 | + break; | |
| 767 | + endswitch; | |
| 768 | + break; | |
| 769 | + case 12: | |
| 770 | + if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 771 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 772 | + endif; | |
| 773 | + $__tagembed__feed_input_data['name'] = $data->name; | |
| 774 | + break; | |
| 775 | + case 18: | |
| 776 | + switch ($__tagembed__feed_filter_id): | |
| 777 | + case 23: | |
| 778 | + if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 779 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 780 | + endif; | |
| 781 | + break; | |
| 782 | + case 26: | |
| 783 | + $__tagembed__feed_input_data['hashtagCaption'] = sanitize_key(isset($data->hashtagCaption) ? 1 : 0); | |
| 784 | + $__tagembed__feed_input_data['hashtagOlder'] = sanitize_key(isset($data->hashtagOlder) ? 1 : 0); | |
| 785 | + break; | |
| 786 | + endswitch; | |
| 787 | + $__tagembed__feed_input_data['auth'] = 1; | |
| 788 | + break; | |
| 789 | + case 19: | |
| 790 | + if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 791 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 792 | + endif; | |
| 793 | + $yelpBusinessUrl = parse_url($data->feed); | |
| 794 | + if (!strstr($yelpBusinessUrl['host'], 'yelp')) : | |
| 795 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Yelp Business Url']); | |
| 796 | + endif; | |
| 797 | + $yelpBusinessPath = explode('/', $yelpBusinessUrl['path']); | |
| 798 | + $__tagembed__feed_input_data['feed'] = $yelpBusinessPath[2]; | |
| 799 | + $__tagembed__feed_input_data['name'] = $yelpBusinessPath[2]; | |
| 800 | + break; | |
| 801 | + case 20: | |
| 802 | + $__tagembed__feed_input_data['auth'] = 1; | |
| 803 | + $slackData = isset($data->slackChannelList) ? $data->slackChannelList : ''; | |
| 804 | + if (!empty($slackData)) : | |
| 805 | + $slackData = explode('#', $slackData); | |
| 806 | + $__tagembed__feed_input_data['name'] = $slackData[1]; | |
| 807 | + $__tagembed__feed_input_data['feed'] = $slackData[0]; | |
| 808 | + endif; | |
| 809 | + break; | |
| 810 | + case 23: | |
| 811 | + if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 812 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 813 | + endif; | |
| 814 | + $airbnbListUrl = parse_url($data->feed); | |
| 815 | + if (strstr($airbnbListUrl['host'], 'airbnb')) : | |
| 816 | + preg_match('/[^\/]+$/', $data->feed, $matches); | |
| 817 | + $__tagembed__feed_input_data['listId'] = explode('?', $matches[0])[0]; | |
| 818 | + else : | |
| 819 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Airbnb Url']); | |
| 820 | + endif; | |
| 821 | + $__tagembed__feed_input_data['name'] = $data->name; | |
| 822 | + break; | |
| 823 | + case 36: | |
| 824 | + if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 825 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 826 | + endif; | |
| 827 | + $etsyShopUrl = parse_url($data->feed); | |
| 828 | + if (!strstr($etsyShopUrl['host'], 'etsy')) : | |
| 829 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Etsy Shop Url']); | |
| 830 | + endif; | |
| 831 | + $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = explode('/shop/', $etsyShopUrl['path'])[1]; | |
| 832 | + break; | |
| 833 | + case 28: | |
| 834 | + switch ($__tagembed__feed_filter_id): | |
| 835 | + case 72: | |
| 836 | + $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 837 | + $__tagembed__feed_input_data['name'] = $data->feed; | |
| 838 | + break; | |
| 839 | + endswitch; | |
| 840 | + if (!in_array($__tagembed__feed_filter_id, [72])) : | |
| 841 | + $__tagembed__feed_input_data['auth'] = 1; | |
| 842 | + endif; | |
| 843 | + break; | |
| 844 | + case 30: | |
| 845 | + switch ($__tagembed__feed_filter_id): | |
| 846 | + case 2: | |
| 847 | + $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 848 | + $__tagembed__feed_input_data['name'] = $data->feed; | |
| 849 | + break; | |
| 850 | + case 75: | |
| 851 | + $__tagembed__feed_input_data['communitiesName'] = $data->communitiesName; | |
| 852 | + $__tagembed__feed_input_data['communitiesId'] = $data->communitiesId; | |
| 853 | + break; | |
| 854 | + endswitch; | |
| 855 | + if (!in_array($__tagembed__feed_filter_id, [2, 75])) : | |
| 856 | + $__tagembed__feed_input_data['auth'] = 1; | |
| 857 | + endif; | |
| 858 | + break; | |
| 859 | + case 33: | |
| 860 | + if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 861 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 862 | + endif; | |
| 863 | + preg_match('/[^\/]+$/', '$data->feed', $matches); | |
| 864 | + $__tagembed__feed_input_data['feed'] = $matches[0]; | |
| 865 | + $__tagembed__feed_input_data['name'] = $matches[0]; | |
| 866 | + break; | |
| 867 | + case 34: | |
| 868 | + if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 869 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 870 | + endif; | |
| 871 | + $__tagembed__feed_input_data['name'] = explode('/', $data->feed)[3]; | |
| 872 | + $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 873 | + break; | |
| 874 | + case 35: | |
| 875 | + if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 876 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 877 | + endif; | |
| 878 | + $__tagembed__feed_input_data['name'] = explode('Reviews-', $data->feed)[1]; | |
| 879 | + $__tagembed__feed_input_data['name'] = explode('.html', $__tagembed__feed_input_data['name'])[0]; | |
| 880 | + $__tagembed__feed_input_data['feed'] = $data->feed; | |
| 881 | + break; | |
| 882 | + case 37: | |
| 883 | + $data->feed = explode('.html', $data->feed)[0]; | |
| 884 | + if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : | |
| 885 | + return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); | |
| 886 | + endif; | |
| 887 | + $__tagembed__feed_input_data['name'] = $data->feed; | |
| 888 | + $__tagembed__feed_input_data['feed'] = explode('item/', $data->feed)[1]; | |
| 889 | + break; | |
| 890 | + endswitch; | |
| 891 | + unset($data); | |
| 892 | + | |
| 893 | + /* --Start-- Manage Api Calling */ | |
| 894 | + $byApiCall = 0; | |
| 895 | + if (empty($__tagembed__feed_input_data['authId'])) : | |
| 896 | + switch ($__tagembed__feed_input_data['networkId']): | |
| 897 | + case 4: | |
| 898 | + if (33 == $__tagembed__feed_filter_id) : | |
| 899 | + $byApiCall = 1; | |
| 900 | + $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 901 | + endif; | |
| 902 | + break; | |
| 903 | + case 5: | |
| 904 | + case 7: | |
| 905 | + case 6: | |
| 906 | + case 10: | |
| 907 | + case 11: | |
| 908 | + case 12: | |
| 909 | + case 19: | |
| 910 | + case 23: | |
| 911 | + case 28: | |
| 912 | + case 29: | |
| 913 | + case 33: | |
| 914 | + case 34: | |
| 915 | + case 35: | |
| 916 | + case 37: | |
| 917 | + $byApiCall = 1; | |
| 918 | + $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 919 | + break; | |
| 920 | + case 31: | |
| 921 | + if (2 == $__tagembed__feed_filter_id) : | |
| 922 | + $byApiCall = 1; | |
| 923 | + $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 924 | + endif; | |
| 925 | + break; | |
| 926 | + case 32: | |
| 927 | + if (in_array($__tagembed__feed_filter_id, [2, 75])) : | |
| 928 | + $byApiCall = 1; | |
| 929 | + $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 930 | + endif; | |
| 931 | + break; | |
| 932 | + endswitch; | |
| 933 | + else : | |
| 934 | + $byApiCall = 1; | |
| 935 | + $__tagembed__feed_input_data['byApiCall'] = 1; | |
| 936 | + endif; | |
| 937 | + $__tagembed__feed_input_data['appUser'] = 1; | |
| 938 | + $__tagembed__feed_input_data['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 939 | + /* --End-- Manage Api Calling */ | |
| 940 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/create', ['feedData' => $__tagembed__feed_input_data], ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 941 | + $response = ___tagembed__manageApiResponse($response); | |
| 942 | + return ___tagembed__exitWithSuccess(['byapiCall' => $byApiCall, '__tagembed__requestCallBackUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL, 'redirectUrl' => TAGEMBED_PLUGIN_API_URL . 'apiauth/getauth', '__tagembed__feedData' => $response->__tagembed__feedData]); | |
| 943 | + break; | |
| 944 | + case '__tagembed__make_payment': | |
| 945 | + | |
| 946 | + if (empty($__tagembed__user_details) || empty($data->planId)) : | |
| 947 | + return ___tagembed__exitWithDanger(); | |
| 948 | + endif; | |
| 949 | + /* --Start-- Manage Param Data */ | |
| 950 | + $param['planId'] = sanitize_key($data->planId); | |
| 951 | + $param['priceCode'] = $data->priceCode; | |
| 952 | + /* --Start-- Manage Param Data */ | |
| 953 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 954 | + $param['email'] = $__tagembed__user_details->email; | |
| 955 | + $param['name'] = $__tagembed__user_details->name; | |
| 956 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 957 | + /* --End-- Manage Param Data */ | |
| 958 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getpaymentdetails', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 959 | + unset($param); | |
| 960 | + $response = ___tagembed__manageApiResponse($response); | |
| 961 | + return ___tagembed__exitWithSuccess(['__tagembed__requestCallBackUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL, 'redirectUrl' => TAGEMBED_PLUGIN_API_URL . 'apiaccount/makepayment', '__tagembed__paymentData' => $response->__tagembed__paymentData]); | |
| 962 | + break; | |
| 963 | + case '__tagembed__cancel_subscription': | |
| 964 | + if (empty($__tagembed__user_details) || empty($data->planId)) : | |
| 965 | + return ___tagembed__exitWithDanger(); | |
| 966 | + endif; | |
| 967 | + /* --Start-- Manage Param Data */ | |
| 968 | + $param['planId'] = sanitize_key($data->planId); | |
| 969 | + /* --Start-- Manage Param Data */ | |
| 970 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 971 | + $param['email'] = $__tagembed__user_details->email; | |
| 972 | + $param['name'] = $__tagembed__user_details->name; | |
| 973 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 974 | + /* --End-- Manage Param Data */ | |
| 975 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/cancelsubscription', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 976 | + unset($param); | |
| 977 | + $response = ___tagembed__manageApiResponse($response); | |
| 978 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 979 | + return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 980 | + break; | |
| 981 | + case '__tagembed__get_post': | |
| 982 | + if (empty($__tagembed__user_details) || empty($data->widgetId) || !isset($data->perPage) || !isset($data->offset) || !isset($data->postStatus)) : | |
| 983 | + return ___tagembed__exitWithDanger(); | |
| 984 | + endif; | |
| 985 | + /* --Start-- Manage Param Data */ | |
| 986 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 987 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 988 | + $param['perPage'] = sanitize_key($data->perPage); | |
| 989 | + $param['offset'] = sanitize_key($data->offset); | |
| 990 | + $param['postStatus'] = sanitize_key($data->postStatus); | |
| 991 | + $param['feedIds'] = $data->feedIds; | |
| 992 | + $param['postType'] = $data->postType; | |
| 993 | + $param['highlightFilter'] = sanitize_key($data->highlightFilter); | |
| 994 | + $param['pinFilter'] = sanitize_key($data->pinFilter); | |
| 995 | + $param['recentFilter'] = sanitize_key($data->recentFilter); | |
| 996 | + $param['retweetFilter'] = sanitize_key($data->retweetFilter); | |
| 997 | + $param['searchText'] = sanitize_text_field($data->searchText); | |
| 998 | + /* --End-- Manage Param Data */ | |
| 999 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1000 | + unset($param); | |
| 1001 | + $response = ___tagembed__manageApiResponse($response); | |
| 1002 | + return ___tagembed__exitWithSuccess($response); | |
| 1003 | + break; | |
| 1004 | + case '__tagembed__manage_post_status': | |
| 1005 | + if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postIds) || empty($data->postStatus)) : | |
| 1006 | + return ___tagembed__exitWithDanger(); | |
| 1007 | + endif; | |
| 1008 | + /* --Start-- Manage Param Data */ | |
| 1009 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1010 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1011 | + $param['postIds'] = $data->postIds; | |
| 1012 | + $param['postStatus'] = sanitize_key($data->postStatus); | |
| 1013 | + /* --End-- Manage Param Data */ | |
| 1014 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1015 | + unset($param); | |
| 1016 | + $response = ___tagembed__manageApiResponse($response); | |
| 1017 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 1018 | + return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 1019 | + break; | |
| 1020 | + case '__tagembed__feed_for_search': | |
| 1021 | + if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 1022 | + return ___tagembed__exitWithDanger(); | |
| 1023 | + endif; | |
| 1024 | + /* --Start-- Manage Param Data */ | |
| 1025 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1026 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1027 | + /* --End-- Manage Param Data */ | |
| 1028 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/getfeeds', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1029 | + unset($param); | |
| 1030 | + $response = ___tagembed__manageApiResponse($response); | |
| 1031 | + return ___tagembed__exitWithSuccess($response); | |
| 1032 | + break; | |
| 1033 | + case '__tagembed__manage_post_pin': | |
| 1034 | + if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postId) || !isset($data->pin)) : | |
| 1035 | + return ___tagembed__exitWithDanger(); | |
| 1036 | + endif; | |
| 1037 | + /* --Start-- Manage Param Data */ | |
| 1038 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1039 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1040 | + $param['postId'] = $data->postId; | |
| 1041 | + $param['pin'] = sanitize_key($data->pin); | |
| 1042 | + /* --End-- Manage Param Data */ | |
| 1043 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/pin', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1044 | + unset($param); | |
| 1045 | + $response = ___tagembed__manageApiResponse($response); | |
| 1046 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 1047 | + return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 1048 | + break; | |
| 1049 | + case '__tagembed__manage_post_highlight': | |
| 1050 | + if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postId) || !isset($data->highlight)) : | |
| 1051 | + return ___tagembed__exitWithDanger(); | |
| 1052 | + endif; | |
| 1053 | + /* --Start-- Manage Param Data */ | |
| 1054 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1055 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1056 | + $param['postId'] = $data->postId; | |
| 1057 | + $param['highlight'] = sanitize_key($data->highlight); | |
| 1058 | + /* --End-- Manage Param Data */ | |
| 1059 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/highlight', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1060 | + unset($param); | |
| 1061 | + $response = ___tagembed__manageApiResponse($response); | |
| 1062 | + $response = !empty($response->message) ? $response->message : 'Done'; | |
| 1063 | + return ___tagembed__exitWithSuccess(['message' => $response]); | |
| 1064 | + break; | |
| 1065 | + case '__tagembed__plugin_version': | |
| 1066 | + /* --Start-- Manage Param Data */ | |
| 1067 | + $param = []; | |
| 1068 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 1069 | + /* --End-- Manage Param Data */ | |
| 1070 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/pluginversion', $param, []); | |
| 1071 | + $response = ___tagembed__manageApiResponse($response); | |
| 1072 | + unset($param); | |
| 1073 | + $installedPluginVersion = get_file_data(__FILE__, ['Version' => 'Version'], false); | |
| 1074 | + $installedPluginVersion = $installedPluginVersion['Version']; | |
| 1075 | + $response->installedPluginVersion = $installedPluginVersion; | |
| 1076 | + $response->pluginUpgradeURL = admin_url() . 'plugins.php'; | |
| 1077 | + return ___tagembed__exitWithSuccess($response); | |
| 1078 | + break; | |
| 1079 | + case '__tagembed__check_user_token': | |
| 1080 | + if (empty($__tagembed__user_details)) : | |
| 1081 | + return ___tagembed__exitWithDanger(); | |
| 1082 | + endif; | |
| 1083 | + /* --Start-- Manage Param Data */ | |
| 1084 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1085 | + /* --End-- Manage Param Data */ | |
| 1086 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/checkusertoken', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1087 | + if (!empty($response->head) && 401 == $response->head->code && empty($response->head->status)) : | |
| 1088 | + tagembed_logout(); | |
| 1089 | + endif; | |
| 1090 | + unset($param); | |
| 1091 | + return ___tagembed__exitWithSuccess($response); | |
| 1092 | + break; | |
| 1093 | + case '__tagembed__plugin_deactivate': | |
| 1094 | + /* --Start-- Manage Param Data */ | |
| 1095 | + $__tagembed__user_details = ___tagembed__userData(); | |
| 1096 | + $param = []; | |
| 1097 | + $param['userId'] = !empty($__tagembed__user_details) ? sanitize_key($__tagembed__user_details->userId) : ''; | |
| 1098 | + $param['userName'] = !empty($__tagembed__user_details) ? sanitize_text_field($__tagembed__user_details->name) : ''; | |
| 1099 | + $param['userEmail'] = !empty($__tagembed__user_details) ? sanitize_email($__tagembed__user_details->email) : ''; | |
| 1100 | + $param['pluginDeactivateReason'] = sanitize_text_field($data->pluginDeactivateReason); | |
| 1101 | + $param['otherReason'] = sanitize_text_field($data->otherReason); | |
| 1102 | + $param['betterPlugin'] = sanitize_text_field($data->betterPlugin); | |
| 1103 | + $param['userWebsiteUrl'] = get_site_url(); | |
| 1104 | + $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; | |
| 1105 | + /* --End-- Manage Param Data */ | |
| 1106 | + ___tagembed__dropDatabaseTablesForPlugin(); | |
| 1107 | + deactivate_plugins(plugin_basename(__FILE__), true); | |
| 1108 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/deactivateuserdata', $param, []); | |
| 1109 | + $response = ___tagembed__manageApiResponse($response); | |
| 1110 | + unset($param); | |
| 1111 | + return ___tagembed__exitWithSuccess(); | |
| 1112 | + break; | |
| 1113 | + case '__tagembed__get_customization_option': | |
| 1114 | + if (empty($__tagembed__user_details) || empty($data->widgetId)) : | |
| 1115 | + return ___tagembed__exitWithDanger(); | |
| 1116 | + endif; | |
| 1117 | + /* --Start-- Manage Param Data */ | |
| 1118 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1119 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1120 | + /* --End-- Manage Param Data */ | |
| 1121 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1122 | + unset($param); | |
| 1123 | + $response = ___tagembed__manageApiResponse($response); | |
| 1124 | + return ___tagembed__exitWithSuccess($response); | |
| 1125 | + break; | |
| 1126 | + case '__tagembed__update_footer_customization_option': | |
| 1127 | + /* --Start-- Manage Param Data */ | |
| 1128 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1129 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1130 | + $param['personalizationId'] = sanitize_key($data->personalizationId); | |
| 1131 | + $param['themeRuleId'] = sanitize_key($data->themeRuleId); | |
| 1132 | + $param['loadMoreStatus'] = sanitize_key($data->loadMoreStatus); | |
| 1133 | + $param['autoScrollStatus'] = sanitize_key($data->autoScrollStatus); | |
| 1134 | + /* --End-- Manage Param Data */ | |
| 1135 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/footer', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1136 | + unset($param); | |
| 1137 | + $response = ___tagembed__manageApiResponse($response); | |
| 1138 | + return ___tagembed__exitWithSuccess($response); | |
| 1139 | + break; | |
| 1140 | + case '__tagembed__update_layout_customization_option': | |
| 1141 | + /* --Start-- Manage Param Data */ | |
| 1142 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1143 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1144 | + $param['personalizationId'] = sanitize_key($data->personalizationId); | |
| 1145 | + $param['themeRuleId'] = sanitize_key($data->themeRuleId); | |
| 1146 | + $param['numberOfPosts'] = sanitize_key($data->numberOfPosts); | |
| 1147 | + $param['padding'] = sanitize_key($data->padding); | |
| 1148 | + $param['minimumPostWidth'] = sanitize_key($data->minimumPostWidth); | |
| 1149 | + $param['columnCount'] = sanitize_key($data->columnCount); | |
| 1150 | + $param['columnCountMobile'] = sanitize_key($data->columnCountMobile); | |
| 1151 | + $param['postText'] = sanitize_key($data->postText); | |
| 1152 | + $param['mobilePopup'] = sanitize_key($data->mobilePopup); | |
| 1153 | + $param['postFeatured'] = sanitize_key($data->postFeatured); | |
| 1154 | + /* --End-- Manage Param Data */ | |
| 1155 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/layout', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1156 | + unset($param); | |
| 1157 | + $response = ___tagembed__manageApiResponse($response); | |
| 1158 | + return ___tagembed__exitWithSuccess($response); | |
| 1159 | + break; | |
| 1160 | + case '__tagembed__update_card_customization_option': | |
| 1161 | + /* --Start-- Manage Param Data */ | |
| 1162 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1163 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1164 | + $param['personalizationId'] = sanitize_key($data->personalizationId); | |
| 1165 | + $param['inheritStyles'] = sanitize_key($data->inheritStyles); | |
| 1166 | + $param['themeRuleId'] = sanitize_key($data->themeRuleId); | |
| 1167 | + $param['fontColor'] = $data->fontColor; | |
| 1168 | + $param['authorColor'] = $data->authorColor; | |
| 1169 | + $param['cardColor'] = $data->cardColor; | |
| 1170 | + $param['fontSize'] = sanitize_key($data->fontSize); | |
| 1171 | + $param['shareOption'] = sanitize_key($data->shareOption); | |
| 1172 | + $param['hideContent'] = sanitize_key($data->hideContent); | |
| 1173 | + $param['postAuthor'] = sanitize_key($data->postAuthor); | |
| 1174 | + $param['postTime'] = sanitize_key($data->postTime); | |
| 1175 | + $param['lineTrim'] = sanitize_key($data->lineTrim); | |
| 1176 | + $param['aspectImageRatio'] = $data->aspectImageRatio; | |
| 1177 | + $param['textAlignment'] = $data->textAlignment; | |
| 1178 | + $param['roundEdge'] = $data->roundEdge; | |
| 1179 | + /* --End-- Manage Param Data */ | |
| 1180 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/card', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1181 | + unset($param); | |
| 1182 | + $response = ___tagembed__manageApiResponse($response); | |
| 1183 | + return ___tagembed__exitWithSuccess($response); | |
| 1184 | + break; | |
| 1185 | + case '__tagembed__update_other_customization_option': | |
| 1186 | + /* --Start-- Manage Param Data */ | |
| 1187 | + $param['widgetId'] = sanitize_key($data->widgetId); | |
| 1188 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1189 | + $param['personalizationId'] = sanitize_key($data->personalizationId); | |
| 1190 | + $param['themeRuleId'] = sanitize_key($data->themeRuleId); | |
| 1191 | + $param['css'] = $data->css; | |
| 1192 | + /* --End-- Manage Param Data */ | |
| 1193 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/other', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1194 | + unset($param); | |
| 1195 | + $response = ___tagembed__manageApiResponse($response); | |
| 1196 | + return ___tagembed__exitWithSuccess($response); | |
| 1197 | + break; | |
| 1198 | + case '__tagembed__get_and_manage_intercom_chat_setting': | |
| 1199 | + if (empty($__tagembed__user_details)) : | |
| 1200 | + return ___tagembed__exitWithDanger(); | |
| 1201 | + endif; | |
| 1202 | + /* --Start-- Manage Param Data */ | |
| 1203 | + $param['userId'] = sanitize_key($__tagembed__user_details->userId); | |
| 1204 | + /* --End-- Manage Param Data */ | |
| 1205 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getIntercomSettingData', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1206 | + unset($param); | |
| 1207 | + $response = ___tagembed__manageApiResponse($response); | |
| 1208 | + return ___tagembed__exitWithSuccess($response); | |
| 1209 | + break; | |
| 1210 | + default: | |
| 1211 | + return ___tagembed__exitWithDanger(); | |
| 1212 | + endswitch; | |
| 1213 | +} | |
| 1214 | +/* --End-- Manage Ajax Calls */ | |
| 1215 | + | |
| 1216 | +add_action('admin_init', '___tagembed__googleAuthListener'); | |
| 1217 | +function ___tagembed__googleAuthListener() | |
| 1218 | +{ | |
| 1219 | + if (empty($_GET['__tb_google_state'])) : | |
| 1220 | + return; | |
| 1221 | + endif; | |
| 1222 | + if (empty($_GET['page']) || 'tagembed' !== sanitize_key(wp_unslash($_GET['page']))) : | |
| 1223 | + return; | |
| 1224 | + endif; | |
| 1225 | + if (!current_user_can('manage_options')) : | |
| 1226 | + return; | |
| 1227 | + endif; | |
| 1228 | + $__tagembed__google_state = isset($_GET['__tb_google_state']) ? sanitize_text_field(wp_unslash($_GET['__tb_google_state'])) : ''; | |
| 1229 | + if ('' === $__tagembed__google_state || !preg_match('/^[A-Za-z0-9]{16,64}$/', $__tagembed__google_state)) : | |
| 1230 | + return; | |
| 1231 | + endif; | |
| 1232 | + $__tagembed__google_session = get_transient('__tagembed__google_' . $__tagembed__google_state); | |
| 1233 | + delete_transient('__tagembed__google_' . $__tagembed__google_state); | |
| 1234 | + if (empty($__tagembed__google_session['verifier']) || (int) $__tagembed__google_session['userId'] !== get_current_user_id()) : | |
| 1235 | + return ___tagembed__googleAuthFailed('expired'); | |
| 1236 | + endif; | |
| 1237 | + if (empty($_GET['__tb_google_code'])) : | |
| 1238 | + $__tagembed__google_error_code = isset($_GET['__tb_google_error']) ? sanitize_text_field(wp_unslash($_GET['__tb_google_error'])) : 'failed'; | |
| 1239 | + return ___tagembed__googleAuthFailed($__tagembed__google_error_code); | |
| 1240 | + endif; | |
| 1241 | + $param = [ | |
| 1242 | + 'token' => sanitize_text_field(wp_unslash($_GET['__tb_google_code'])), | |
| 1243 | + 'verifier' => $__tagembed__google_session['verifier'], | |
| 1244 | + 'platform' => TAGEMBED_PLUGIN_PLATFORM, | |
| 1245 | + ]; | |
| 1246 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/googleexchange', $param, []); | |
| 1247 | + unset($param); | |
| 1248 | + if (empty($response->head) || empty($response->head->status) || empty($response->body->userId) || empty($response->body->emailId) || empty($response->body->access_token)) : | |
| 1249 | + return ___tagembed__googleAuthFailed('failed'); | |
| 1250 | + endif; | |
| 1251 | + $__tagembed__google_user = $response->body; | |
| 1252 | + if (!empty($__tagembed__google_user->createFirstWidget)) : | |
| 1253 | + ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', ['userId' => sanitize_key($__tagembed__google_user->userId), 'inheritStyles' => 1], ['Authorization:' . $__tagembed__google_user->access_token]); | |
| 1254 | + endif; | |
| 1255 | + if (___tagembed__login($__tagembed__google_user) !== true) : | |
| 1256 | + return ___tagembed__googleAuthFailed('failed'); | |
| 1257 | + endif; | |
| 1258 | + wp_safe_redirect(TAGEMBED_PLUGIN_CALL_BACK_URL); | |
| 1259 | + exit; | |
| 1260 | +} | |
| 1261 | +function ___tagembed__googleAuthFailed($errorCode) | |
| 1262 | +{ | |
| 1263 | + $__tagembed__google_errors = [ | |
| 1264 | + 'cancelled' => 'Google sign in was cancelled. Please try again.', | |
| 1265 | + 'expired' => 'Google sign in session has expired. Please try again.', | |
| 1266 | + 'email' => 'Your Google account email could not be verified. Please use another account.', | |
| 1267 | + 'account' => 'Your account is not active. Please contact support.', | |
| 1268 | + 'register' => 'We could not create an account with this Google email. Please sign up with your email instead.', | |
| 1269 | + 'process' => 'Your registration is already in progress. Please wait a moment and try again.', | |
| 1270 | + 'failed' => 'Google sign in failed. Please try again.', | |
| 1271 | + ]; | |
| 1272 | + $__tagembed__google_message = isset($__tagembed__google_errors[$errorCode]) ? $__tagembed__google_errors[$errorCode] : $__tagembed__google_errors['failed']; | |
| 1273 | + set_transient('__tagembed__google_error_' . get_current_user_id(), $__tagembed__google_message, MINUTE_IN_SECONDS); | |
| 1274 | + wp_safe_redirect(TAGEMBED_PLUGIN_CALL_BACK_URL); | |
| 1275 | + exit; | |
| 1276 | +} | |
| 1277 | +/* --Start-- Login */ | |
| 1278 | +function ___tagembed__login($response) | |
| 1279 | +{ | |
| 1280 | + global $wpdb; | |
| 1281 | + $return = false; | |
| 1282 | + $user = ___tagembed__user($response->emailId); | |
| 1283 | + if (empty($user->email)) : | |
| 1284 | + 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->access_token, 'yes'))) : | |
| 1285 | + $return = true; | |
| 1286 | + endif; | |
| 1287 | + else : | |
| 1288 | + 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->access_token, 'yes', $response->emailId))) : | |
| 1289 | + $return = true; | |
| 1290 | + endif; | |
| 1291 | + endif; | |
| 1292 | + ___tagembed__manageActiveOptions($response->emailId, 'yes'); /* Manage Active Options */ | |
| 1293 | + if ($return) : | |
| 1294 | + ___tagembed__manageActiveWidgetsUser($response->userId); | |
| 1295 | + endif; | |
| 1296 | + return $return; | |
| 1297 | +} | |
| 1298 | +/* --End-- Login */ | |
| 1299 | + | |
| 1300 | +/* --Start-- Manage Active Options */ | |
| 1301 | +function ___tagembed__manageActiveOptions($email = null, $other = null) | |
| 1302 | +{ | |
| 1303 | + global $wpdb; | |
| 1304 | + if (null == $email && null != $other) : | |
| 1305 | + $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_options SET isLogin = %s WHERE id = %d', $other, 1)); | |
| 1306 | + else : | |
| 1307 | + $__tagembed__activeOptions = $wpdb->get_results($wpdb->prepare('SELECT email FROM wp_tagembed_active_options WHERE id = %d', 1)); | |
| 1308 | + if (empty($__tagembed__activeOptions[0]->email)) : | |
| 1309 | + $wpdb->query($wpdb->prepare('INSERT INTO wp_tagembed_active_options (email, isLogin) VALUES (%s, %s)', $email, $other)); | |
| 1310 | + else : | |
| 1311 | + $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_options SET email = %s, isLogin = %s WHERE id = %d', $email, $other, 1)); | |
| 1312 | + endif; | |
| 1313 | + endif; | |
| 1314 | +} | |
| 1315 | +/* --End-- Manage Active Options */ | |
| 1316 | + | |
| 1317 | +/* --Start-- Logout */ | |
| 1318 | +function tagembed_logout() | |
| 1319 | +{ | |
| 1320 | + global $wpdb; | |
| 1321 | + if ($wpdb->query($wpdb->prepare('UPDATE wp_tagembed_user SET isLogin = %s WHERE isLogin = %s', 'no', 'yes'))) : | |
| 1322 | + ___tagembed__manageActiveOptions(null, 'no'); /* Manage Active Options */ | |
| 1323 | + return true; | |
| 1324 | + endif; | |
| 1325 | + return false; | |
| 1326 | +} | |
| 1327 | +/* --End-- Logout */ | |
| 1328 | + | |
| 1329 | +/* --Start--Manage Menues */ | |
| 1330 | +function ___tagembed__menus($__tagembed__menu_condatation = []) | |
| 1331 | +{ | |
| 1332 | + global $wpdb; | |
| 1333 | + if (empty($__tagembed__menu_condatation)) : | |
| 1334 | + return $wpdb->get_results('SELECT * FROM wp_tagembed_menus'); | |
| 1335 | + endif; | |
| 1336 | + if (array_key_exists('__tagembed__menu_condation', $__tagembed__menu_condatation)) : | |
| 1337 | + return $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_tagembed_menus WHERE status = %s', $__tagembed__menu_condatation['__tagembed__menu_condation'])); | |
| 1338 | + endif; | |
| 1339 | + if (array_key_exists('__tagembed__menu_id', $__tagembed__menu_condatation)) : | |
| 1340 | + 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']))) : | |
| 1341 | + return true; | |
| 1342 | + else : | |
| 1343 | + return false; | |
| 1344 | + endif; | |
| 1345 | + endif; | |
| 1346 | +} | |
| 1347 | +/* --End--Manage Menues */ | |
| 1348 | + | |
| 1349 | +/* --Start-- Get User Details */ | |
| 1350 | +function ___tagembed__user($email = null) | |
| 1351 | +{ | |
| 1352 | + global $wpdb; | |
| 1353 | + $__tagembed__userResponse = ''; | |
| 1354 | + if (empty($email)) : | |
| 1355 | + $__tagembed__userResponse = $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_tagembed_user WHERE isLogin = %s', 'yes')); | |
| 1356 | + else : | |
| 1357 | + $__tagembed__userResponse = $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_tagembed_user WHERE email = %s', $email)); | |
| 1358 | + endif; | |
| 1359 | + if (!empty($__tagembed__userResponse)) : | |
| 1360 | + return $__tagembed__userResponse[0]; | |
| 1361 | + else : | |
| 1362 | + return; | |
| 1363 | + endif; | |
| 1364 | +} | |
| 1365 | +function ___tagembed__userData() | |
| 1366 | +{ | |
| 1367 | + global $wpdb; | |
| 1368 | + $__tagembed__user_dataResponse = ''; | |
| 1369 | + $__tagembed__user_dataResponse = $wpdb->get_results('SELECT * FROM wp_tagembed_user'); | |
| 1370 | + if (!empty($__tagembed__user_dataResponse)) : | |
| 1371 | + return $__tagembed__user_dataResponse[0]; | |
| 1372 | + else : | |
| 1373 | + return; | |
| 1374 | + endif; | |
| 1375 | +} | |
| 1376 | +/* --End-- Get User Details */ | |
| 1377 | + | |
| 1378 | +/* --Start-- Get Widget */ | |
| 1379 | +function ___tagembed__widgets() | |
| 1380 | +{ | |
| 1381 | + $returnWidgetData = []; | |
| 1382 | + $__tagembed__user_details = ___tagembed__user(); | |
| 1383 | + if (!empty($__tagembed__user_details)) : | |
| 1384 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/get', ['userId' => sanitize_key($__tagembed__user_details->userId)], ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1385 | + if (!isset($response->head->status)) : | |
| 1386 | + return $returnWidgetData; | |
| 1387 | + endif; | |
| 1388 | + if (false == $response->head->status || 200 != $response->head->code || false == $response->body || empty($response->body)) : | |
| 1389 | + return $returnWidgetData; | |
| 1390 | + endif; | |
| 1391 | + $returnWidgetData = $response->body; | |
| 1392 | + endif; | |
| 1393 | + return $returnWidgetData; | |
| 1394 | +} | |
| 1395 | +/* --End-- Get Widget */ | |
| 1396 | + | |
| 1397 | +/* --Start-- Get Active Widget */ | |
| 1398 | +function ___tagembed__activeWidget() | |
| 1399 | +{ | |
| 1400 | + global $wpdb; | |
| 1401 | + $__tagembed__activeWidgetResponse = ''; | |
| 1402 | + $__tagembed__activeWidgetResponse = $wpdb->get_results('SELECT * FROM wp_tagembed_active_widget'); | |
| 1403 | + if (!empty($__tagembed__activeWidgetResponse)) : | |
| 1404 | + return $__tagembed__activeWidgetResponse[0]->widgetId; | |
| 1405 | + else : | |
| 1406 | + return; | |
| 1407 | + endif; | |
| 1408 | +} | |
| 1409 | +/* --End-- Get Active Widget */ | |
| 1410 | + | |
| 1411 | +/* --Start-- Manage Active Widget User */ | |
| 1412 | +function ___tagembed__manageActiveWidget($widgetId) | |
| 1413 | +{ | |
| 1414 | + global $wpdb; | |
| 1415 | + $activeWidgetUserId = ___tagembed__activeWidget(); | |
| 1416 | + if ($activeWidgetUserId == $widgetId) : | |
| 1417 | + return true; | |
| 1418 | + endif; | |
| 1419 | + if (empty($activeWidgetUserId)) : | |
| 1420 | + $wpdb->query($wpdb->prepare('INSERT INTO wp_tagembed_active_widget (widgetId) VALUES (%s)', $widgetId)); | |
| 1421 | + return true; | |
| 1422 | + else : | |
| 1423 | + $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_widget SET widgetId = %s WHERE id = %d', $widgetId, 1)); | |
| 1424 | + return true; | |
| 1425 | + endif; | |
| 1426 | + return false; | |
| 1427 | +} | |
| 1428 | +/* --End-- Manage Active Widget User */ | |
| 1429 | + | |
| 1430 | +/* --Start-- Get Active Widget User */ | |
| 1431 | +function ___tagembed__activeWidgetUser() | |
| 1432 | +{ | |
| 1433 | + global $wpdb; | |
| 1434 | + $__tagembed__activeWidgetUserResponse = ''; | |
| 1435 | + $__tagembed__activeWidgetUserResponse = $wpdb->get_results('SELECT * FROM wp_tagembed_active_widget_user'); | |
| 1436 | + if (!empty($__tagembed__activeWidgetUserResponse)) : | |
| 1437 | + return $__tagembed__activeWidgetUserResponse[0]->userId; | |
| 1438 | + endif; | |
| 1439 | + return; | |
| 1440 | +} | |
| 1441 | +/* --End-- Get Active Widget User */ | |
| 1442 | + | |
| 1443 | +/* --Start-- Manage Active Widget User */ | |
| 1444 | +function ___tagembed__manageActiveWidgetsUser($userId) | |
| 1445 | +{ | |
| 1446 | + global $wpdb; | |
| 1447 | + $activeWidgetUserId = ___tagembed__activeWidgetUser(); | |
| 1448 | + if ($activeWidgetUserId == $userId) : | |
| 1449 | + return true; | |
| 1450 | + endif; | |
| 1451 | + if (empty($activeWidgetUserId)) : | |
| 1452 | + $wpdb->query($wpdb->prepare('INSERT INTO wp_tagembed_active_widget_user (userId) VALUES (%d)', $userId)); | |
| 1453 | + return true; | |
| 1454 | + else : | |
| 1455 | + $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_widget_user SET userId = %d WHERE id = %d', $userId, 1)); | |
| 1456 | + return true; | |
| 1457 | + endif; | |
| 1458 | + return false; | |
| 1459 | +} | |
| 1460 | +/* --End-- Manage Active Widget User */ | |
| 1461 | + | |
| 1462 | +/* * ** DATABASE *** */ | |
| 1463 | +/* --Start-- Manage Database */ | |
| 1464 | +function ___tagembed__createDatabaseTableForPlugin() | |
| 1465 | +{ | |
| 1466 | + global $wpdb; | |
| 1467 | + include_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| 1468 | + $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=utf8mb4 COLLATE=utf8mb4_unicode_ci'); | |
| 1469 | + $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=utf8mb4 COLLATE=utf8mb4_unicode_ci'); | |
| 1470 | + $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=utf8mb4 COLLATE=utf8mb4_unicode_ci'); | |
| 1471 | + $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=utf8mb4 COLLATE=utf8mb4_unicode_ci'); | |
| 1472 | + $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=utf8mb4 COLLATE=utf8mb4_unicode_ci'); | |
| 1473 | + /* --Start-- Manage Tagembed Plugin Menus */ | |
| 1474 | + $__tagembed__checkAlreadyExistMenusDataExistOrNot = $wpdb->get_results('SELECT id FROM wp_tagembed_menus'); | |
| 1475 | + if (empty($__tagembed__checkAlreadyExistMenusDataExistOrNot)) : | |
| 1476 | + $__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']]; | |
| 1477 | + foreach ($__tagembed__menus as $__tagembed__menu) : | |
| 1478 | + $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'])); | |
| 1479 | + endforeach; | |
| 1480 | + endif; | |
| 1481 | + /* --End-- Manage Tagembed Plugin Menus */ | |
| 1482 | +} | |
| 1483 | +function ___tagembed__dropDatabaseTablesForPlugin() | |
| 1484 | +{ | |
| 1485 | + global $wpdb; | |
| 1486 | + $wpdb->query('DROP table IF EXISTS wp_tagembed_active_widget_user'); | |
| 1487 | + $wpdb->query('DROP table IF EXISTS wp_tagembed_active_widget'); | |
| 1488 | + $wpdb->query('DROP table IF EXISTS wp_tagembed_menus'); | |
| 1489 | +} | |
| 1490 | +/* --End-- Manage Database */ | |
| 1491 | + | |
| 1492 | +/* --Start-- Manage Active Deactive And Uninstall Webhook */ | |
| 1493 | +register_activation_hook(__FILE__, '___tagembed__pluginActivate'); | |
| 1494 | +function ___tagembed__pluginActivate() | |
| 1495 | +{ | |
| 1496 | + ___tagembed__createDatabaseTableForPlugin(); | |
| 1497 | + add_action('activated_plugin', '___tagembed__plginActivationRedirect'); | |
| 1498 | +} | |
| 1499 | +register_uninstall_hook(__FILE__, '___tagembed__pluginUnistall'); | |
| 1500 | +function ___tagembed__pluginUnistall() | |
| 1501 | +{ | |
| 1502 | + ___tagembed__dropDatabaseTablesForPlugin(); | |
| 1503 | + global $wpdb; | |
| 1504 | + $wpdb->query('DROP table IF EXISTS wp_tagembed_active_options'); | |
| 1505 | + $wpdb->query('DROP table IF EXISTS wp_tagembed_user'); | |
| 1506 | +} | |
| 1507 | +/* --End-- Manage Active Deactive And Uninstall Webhook */ | |
| 1508 | + | |
| 1509 | +/* --Start--Manage Redirect After Plugin Activate */ | |
| 1510 | +function ___tagembed__plginActivationRedirect() | |
| 1511 | +{ | |
| 1512 | + $__tagembed__activeUserData = wp_get_current_user(); | |
| 1513 | + if (empty($__tagembed__activeUserData->roles)) : | |
| 1514 | + return false; | |
| 1515 | + endif; | |
| 1516 | + $__tagembed__pluginCallbackUrl = esc_url(TAGEMBED_PLUGIN_CALL_BACK_URL); | |
| 1517 | + wp_safe_redirect($__tagembed__pluginCallbackUrl); | |
| 1518 | + exit; | |
| 1519 | +} | |
| 1520 | +/* --End--Manage Redirect After Plugin Activate */ | |
| 1521 | + | |
| 1522 | +/* --Start--Manage Setting Link */ | |
| 1523 | +function ___tagembed__settingsLink($links) | |
| 1524 | +{ | |
| 1525 | + array_unshift($links, '<a href=' . TAGEMBED_PLUGIN_CALL_BACK_URL . '>Settings</a>'); | |
| 1526 | + return $links; | |
| 1527 | +} | |
| 1528 | +add_filter('plugin_action_links_' . plugin_basename(__FILE__), '___tagembed__settingsLink'); | |
| 1529 | +/* --End--Manage Setting Link */ | |
| 1530 | + | |
| 1531 | +/* --Start--Manage Database On Plugin Update Time */ | |
| 1532 | +function ___tagembed__manageDatabaseOnPluginUpdateTime() | |
| 1533 | +{ | |
| 1534 | + ___tagembed__dropDatabaseTablesForPlugin(); | |
| 1535 | + ___tagembed__createDatabaseTableForPlugin(); | |
| 1536 | +} | |
| 1537 | +add_action('upgrader_process_complete', '___tagembed__manageDatabaseOnPluginUpdateTime', 10, 2); | |
| 1538 | +/* --End--Manage Database On Plugin Update Time */ | |
| 1539 | + | |
| 1540 | +/* --Sart--Get And Manage Social Accout Id */ | |
| 1541 | +function ___tagembed__get_user_social_account_id() | |
| 1542 | +{ | |
| 1543 | + $__tagembed__user_details = ___tagembed__user(); | |
| 1544 | + $param['userId'] = $__tagembed__user_details->userId; | |
| 1545 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getsocialaccountid', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); | |
| 1546 | + if (!empty($response->head->status)) : | |
| 1547 | + if (!empty($response->body->userId)) : | |
| 1548 | + return $response->body->userId; | |
| 1549 | + endif; | |
| 1550 | + endif; | |
| 1551 | + return false; | |
| 1552 | +} | |
| 1553 | +/* --End--Get And Manage Social Accout Id */ | |
| 1554 | + | |
| 1555 | +/* --Start-- Show Admin General Notification After Login And Register */ | |
| 1556 | +function ___tagembed__generalAdminNotice() | |
| 1557 | +{ | |
| 1558 | + $__tagmebed__page_name = ''; | |
| 1559 | + if (!empty($_GET['page'])) : | |
| 1560 | + $__tagmebed__page_name = ___tagembed__sanitizeRequestData($_GET); | |
| 1561 | + $__tagmebed__page_name = $__tagmebed__page_name['page']; | |
| 1562 | + endif; | |
| 1563 | + $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/notification', ['callBy' => 'wordpress'], []); | |
| 1564 | + if (!is_wp_error($response)) : | |
| 1565 | + if (!empty($response->head->status) && !empty($response->body)) : | |
| 1566 | + $response = $response->body; | |
| 1567 | + if (!empty($response->notifications) && is_array($response->notifications)) : | |
| 1568 | + $htmlData = ''; | |
| 1569 | + foreach ($response->notifications as $notifications) : | |
| 1570 | + if ('tagembed' == $notifications->location || 'inner' == $notifications->location) : | |
| 1571 | + if ('tagembed' != $__tagmebed__page_name) : | |
| 1572 | + continue; | |
| 1573 | + endif; | |
| 1574 | + $htmlData .= '<div class=\'notice notice-' . esc_attr($notifications->type) . ' is-dismissible\'>'; | |
| 1575 | + $htmlData .= '<p>' . $notifications->message . '</p>'; | |
| 1576 | + $htmlData .= '</div>'; | |
| 1577 | + elseif ('all' == $notifications->location) : | |
| 1578 | + $htmlData .= '<div class=\'notice notice-' . esc_attr($notifications->type) . ' is-dismissible\'>'; | |
| 1579 | + $htmlData .= '<p>' . $notifications->message . '</p>'; | |
| 1580 | + $htmlData .= '</div>'; | |
| 1581 | + endif; | |
| 1582 | + endforeach; | |
| 1583 | + echo wp_kses_post($htmlData); | |
| 1584 | + endif; | |
| 1585 | + endif; | |
| 1586 | + endif; | |
| 1587 | +} | |
| 1588 | +add_action('in_admin_header', '___tagembed__hideGeneralAdminNotice'); | |
| 1589 | +function ___tagembed__hideGeneralAdminNotice() | |
| 1590 | +{ | |
| 1591 | + $__tagmebed__page_name = ''; | |
| 1592 | + if (!empty($_GET['page'])) : | |
| 1593 | + $__tagmebed__page_name = ___tagembed__sanitizeRequestData($_GET); | |
| 1594 | + $__tagmebed__page_name = $__tagmebed__page_name['page']; | |
| 1595 | + endif; | |
| 1596 | + if ('tagembed' == $__tagmebed__page_name) : | |
| 1597 | + remove_all_actions('admin_notices'); | |
| 1598 | + remove_all_actions('all_admin_notices'); | |
| 1599 | + endif; | |
| 1600 | + if (!empty(___tagembed__user())) : | |
| 1601 | + add_action('admin_notices', '___tagembed__generalAdminNotice'); | |
| 1602 | + endif; | |
| 1603 | +} | |
| 1604 | +/* --End-- Show Admin General Notification After Login And Register */ | |
| 1605 | +/* --End-- Drop Database Table */ | |
| 1606 | + | |
| 1607 | +/* --Start-- Create Short Code */ | |
| 1608 | +function ___tagembed__PluginShortCode($__tagembed__shortCodeAttr) | |
| 1609 | +{ | |
| 1610 | + $__tagembed__shortCodeDefaultAttr = ['width' => '', 'height' => '', 1 => '']; | |
| 1611 | + $__tagembed__shortCodeAttr = shortcode_atts($__tagembed__shortCodeDefaultAttr, $__tagembed__shortCodeAttr, 'tagembed'); | |
| 1612 | + $width = isset($__tagembed__shortCodeAttr['width']) ? sanitize_text_field($__tagembed__shortCodeAttr['width']) : ''; | |
| 1613 | + $height = isset($__tagembed__shortCodeAttr['height']) ? sanitize_text_field($__tagembed__shortCodeAttr['height']) : ''; | |
| 1614 | + $widgetId = isset($__tagembed__shortCodeAttr[1]) ? sanitize_text_field($__tagembed__shortCodeAttr[1]) : ''; | |
| 1615 | + if (!empty($widgetId) && is_numeric($widgetId) && (('' === $width || preg_match('/^\d+(px|%|)$/', $width)) && ('' === $height || preg_match('/^\d+(px|%|)$/', $height)))) : | |
| 1616 | + $output = '<div class=\'tagembed-widget\' style=\'width:' . esc_attr($width) . '; height:' . esc_attr($height) . ';\' data-widget-id=\'' . esc_attr($widgetId) . '\' view-url=\'https://widget.tagembed.com/' . esc_attr($widgetId) . '\'></div>'; | |
| 1617 | + else : | |
| 1618 | + $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>'; | |
| 1619 | + endif; | |
| 1620 | + return $output; | |
| 1621 | +} | |
| 1622 | +add_shortcode('tagembed', '___tagembed__PluginShortCode'); | |
| 1623 | +/* --End-- Create Short Code */ | |