Plugin root
assets
4 days ago
helper
4 days ago
views
4 days ago
readme.txt
17.8 KB
4 days ago
tagembed.php
81.0 KB
4 days ago
tagembed.php in Tagembed: Social Media Feeds and Customer Reviews Widget 7.9, at tagembed.php
| 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.9 |
| 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.9'); |
| 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_plan_status': |
| 259 | if (empty($__tagembed__user_details)) : |
| 260 | return ___tagembed__exitWithDanger(); |
| 261 | endif; |
| 262 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 263 | $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 264 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/planstatus', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 265 | unset($param); |
| 266 | $response = ___tagembed__manageApiResponse($response); |
| 267 | return ___tagembed__exitWithSuccess($response); |
| 268 | break; |
| 269 | case '__tagembed__get_invoice_pdf': |
| 270 | if (empty($__tagembed__user_details) || empty($data->invoiceId)) : |
| 271 | return ___tagembed__exitWithDanger(); |
| 272 | endif; |
| 273 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 274 | $param['invoiceId'] = sanitize_text_field($data->invoiceId); |
| 275 | $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 276 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/invoicepdf', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 277 | unset($param); |
| 278 | $response = ___tagembed__manageApiResponse($response); |
| 279 | return ___tagembed__exitWithSuccess($response); |
| 280 | break; |
| 281 | case '__tagembed__get_invoices': |
| 282 | if (empty($__tagembed__user_details)) : |
| 283 | return ___tagembed__exitWithDanger(); |
| 284 | endif; |
| 285 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 286 | $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 287 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getinvoices', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 288 | unset($param); |
| 289 | $response = ___tagembed__manageApiResponse($response); |
| 290 | return ___tagembed__exitWithSuccess($response); |
| 291 | break; |
| 292 | case '__tagembed__get_account_details': |
| 293 | $data->auth = !empty($data->auth) ? 1 : 0; |
| 294 | if (empty($__tagembed__user_details)) : |
| 295 | return ___tagembed__exitWithDanger(); |
| 296 | endif; |
| 297 | /* --Start-- Manage Param Data */ |
| 298 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 299 | $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 300 | /* --End-- Manage Param Data */ |
| 301 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getdetails', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 302 | unset($param); |
| 303 | $response = ___tagembed__manageApiResponse($response); |
| 304 | return ___tagembed__exitWithSuccess($response); |
| 305 | break; |
| 306 | |
| 307 | case '__tagembed__manage_active_widget': |
| 308 | if (empty($data->widgetId)) : |
| 309 | return ___tagembed__exitWithDanger(); |
| 310 | endif; |
| 311 | if (___tagembed__manageActiveWidget($data->widgetId)) : |
| 312 | return ___tagembed__exitWithSuccess(); |
| 313 | else : |
| 314 | return ___tagembed__exitWithDanger(); |
| 315 | endif; |
| 316 | break; |
| 317 | case '__tagembed__menue': |
| 318 | if (empty($data->menueId)) : |
| 319 | return ___tagembed__exitWithDanger(); |
| 320 | endif; |
| 321 | if (___tagembed__menus(['__tagembed__menu_id' => $data->menueId])) : |
| 322 | return ___tagembed__exitWithSuccess(['redirectUrl' => TAGEMBED_PLUGIN_REDIRECT_URL . 'tagembed']); |
| 323 | else : |
| 324 | return ___tagembed__exitWithDanger(); |
| 325 | endif; |
| 326 | break; |
| 327 | case '__tagembed__create_widget': |
| 328 | if (empty($__tagembed__user_details) || empty($data->name)) : |
| 329 | return ___tagembed__exitWithDanger('Validation Error', ['name' => 'Widget name is required']); |
| 330 | endif; |
| 331 | $data->profanity = (isset($data->profanity)) ? 0 : 1; |
| 332 | /* --Start-- Manage Param Data */ |
| 333 | $param['name'] = sanitize_text_field($data->name); |
| 334 | $param['profanity'] = sanitize_key($data->profanity); |
| 335 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 336 | $param['inheritStyles'] = 1; |
| 337 | /* --End-- Manage Param Data */ |
| 338 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 339 | unset($param); |
| 340 | $response = ___tagembed__manageApiResponse($response); |
| 341 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 342 | return ___tagembed__exitWithSuccess(['message' => $response, 'redirectUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL]); |
| 343 | break; |
| 344 | case '__tagembed__edit_widget': |
| 345 | if (empty($__tagembed__user_details) || empty($data->name) || empty($data->widgetId)) : |
| 346 | return ___tagembed__exitWithDanger('Validation Error', ['name' => 'Widget name is required']); |
| 347 | endif; |
| 348 | /* --Start-- Manage Param Data */ |
| 349 | $param['name'] = sanitize_text_field($data->name); |
| 350 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 351 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 352 | /* --End-- Manage Param Data */ |
| 353 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/edit', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 354 | unset($param); |
| 355 | $response = ___tagembed__manageApiResponse($response); |
| 356 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 357 | return ___tagembed__exitWithSuccess(['message' => $response, 'redirectUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL]); |
| 358 | break; |
| 359 | case '__tagembed__update_widget_status': |
| 360 | if (empty($__tagembed__user_details) || empty($data->widgetId)) : |
| 361 | return ___tagembed__exitWithDanger(); |
| 362 | endif; |
| 363 | /* --Start-- Manage Param Data */ |
| 364 | $param['status'] = sanitize_key($data->status); |
| 365 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 366 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 367 | /* --End-- Manage Param Data */ |
| 368 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 369 | unset($param); |
| 370 | $response = ___tagembed__manageApiResponse($response); |
| 371 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 372 | return ___tagembed__exitWithSuccess(['message' => $response]); |
| 373 | break; |
| 374 | case '__tagembed__delete_widget': |
| 375 | if (empty($__tagembed__user_details) || empty($data->widgetId)) : |
| 376 | return ___tagembed__exitWithDanger(); |
| 377 | endif; |
| 378 | /* --Start-- Manage Param Data */ |
| 379 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 380 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 381 | /* --End-- Manage Param Data */ |
| 382 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 383 | unset($param); |
| 384 | $response = ___tagembed__manageApiResponse($response); |
| 385 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 386 | return ___tagembed__exitWithSuccess(['message' => $response]); |
| 387 | break; |
| 388 | case '__tagembed__source_networks': |
| 389 | $data->auth = !empty($data->auth) ? 1 : 0; |
| 390 | if (empty($__tagembed__user_details)) : |
| 391 | return ___tagembed__exitWithDanger(); |
| 392 | endif; |
| 393 | /* --Start-- Manage Param Data */ |
| 394 | $param['auth'] = sanitize_key($data->auth); |
| 395 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 396 | /* --End-- Manage Param Data */ |
| 397 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apinetwork/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 398 | unset($param); |
| 399 | $response = ___tagembed__manageApiResponse($response); |
| 400 | return ___tagembed__exitWithSuccess($response); |
| 401 | break; |
| 402 | case '__tagembed__get_themes': |
| 403 | if (empty($__tagembed__user_details) || empty($data->widgetId)) : |
| 404 | return ___tagembed__exitWithDanger(); |
| 405 | endif; |
| 406 | /* --Start-- Manage Param Data */ |
| 407 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 408 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 409 | /* --End-- Manage Param Data */ |
| 410 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'Apitheme/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 411 | unset($param); |
| 412 | $response = ___tagembed__manageApiResponse($response); |
| 413 | return ___tagembed__exitWithSuccess($response); |
| 414 | break; |
| 415 | case '__tagembed__edit_themes': |
| 416 | if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->themeId)) : |
| 417 | return ___tagembed__exitWithDanger(); |
| 418 | endif; |
| 419 | /* --Start-- Manage Param Data */ |
| 420 | $param['themeId'] = sanitize_key($data->themeId); |
| 421 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 422 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 423 | /* --End-- Manage Param Data */ |
| 424 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'Apitheme/edit', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 425 | unset($param); |
| 426 | $response = ___tagembed__manageApiResponse($response); |
| 427 | return ___tagembed__exitWithSuccess($response); |
| 428 | break; |
| 429 | case '__tagembed__get_network_filter': |
| 430 | if (empty($__tagembed__user_details) || empty($data->networkId)) : |
| 431 | return ___tagembed__exitWithDanger(); |
| 432 | endif; |
| 433 | /* --Start-- Manage Param Data */ |
| 434 | $param['networkId'] = sanitize_key($data->networkId); |
| 435 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 436 | /* --End-- Manage Param Data */ |
| 437 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apinetwork/filter', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 438 | unset($param); |
| 439 | $response = ___tagembed__manageApiResponse($response); |
| 440 | return ___tagembed__exitWithSuccess($response); |
| 441 | break; |
| 442 | case '__tagembed__get_already_exist_accounts': |
| 443 | if (empty($__tagembed__user_details)) : |
| 444 | return ___tagembed__exitWithDanger(); |
| 445 | endif; |
| 446 | /* --Start-- Manage Param Data */ |
| 447 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 448 | /* --End-- Manage Param Data */ |
| 449 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/getalreadyexistaccounts', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 450 | unset($param); |
| 451 | $response = ___tagembed__manageApiResponse($response); |
| 452 | return ___tagembed__exitWithSuccess($response); |
| 453 | break; |
| 454 | case '__tagembed__add_or_update_account': |
| 455 | if (empty($__tagembed__user_details) || empty($data->networkId) || empty($data->type)) : |
| 456 | return ___tagembed__exitWithDanger(); |
| 457 | endif; |
| 458 | /* --Start-- Manage Param Data */ |
| 459 | $param['connectedAccountId'] = $data->connectedAccountId; |
| 460 | $param['feedId'] = sanitize_key($data->feedId); |
| 461 | $param['type'] = sanitize_text_field($data->type); |
| 462 | $param['networkId'] = sanitize_key($data->networkId); |
| 463 | $param['filterId'] = sanitize_key($data->filterId); |
| 464 | $param['otherData'] = $data->otherData; |
| 465 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 466 | /* --End-- Manage Param Data */ |
| 467 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/addorupdate', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 468 | unset($param); |
| 469 | $response = ___tagembed__manageApiResponse($response); |
| 470 | return ___tagembed__exitWithSuccess(['__tagembed__requestCallBackUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL, 'redirectUrl' => TAGEMBED_PLUGIN_API_URL . 'apiauth/getauth', '__tagembed__feedData' => $response->__tagembed__feedData]); |
| 471 | break; |
| 472 | case '__tagembed__delete_account': |
| 473 | if (empty($__tagembed__user_details) || empty($data->networkId) || empty($data->parentId)) : |
| 474 | return ___tagembed__exitWithDanger(); |
| 475 | endif; |
| 476 | /* --Start-- Manage Param Data */ |
| 477 | $param['parentId'] = sanitize_key($data->parentId); |
| 478 | $param['networkId'] = sanitize_key($data->networkId); |
| 479 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 480 | /* --End-- Manage Param Data */ |
| 481 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 482 | unset($param); |
| 483 | $response = ___tagembed__manageApiResponse($response); |
| 484 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 485 | return ___tagembed__exitWithSuccess(['message' => $response]); |
| 486 | break; |
| 487 | case '__tagembed__get_already_exist_auth': |
| 488 | if (empty($__tagembed__user_details) || empty($data->networkId)) : |
| 489 | return ___tagembed__exitWithDanger(); |
| 490 | endif; |
| 491 | /* --Start-- Manage Param Data */ |
| 492 | $param['networkId'] = sanitize_key($data->networkId); |
| 493 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 494 | /* --End-- Manage Param Data */ |
| 495 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 496 | unset($param); |
| 497 | $response = ___tagembed__manageApiResponse($response); |
| 498 | return ___tagembed__exitWithSuccess($response); |
| 499 | break; |
| 500 | case '__tagembed__search_google_location': |
| 501 | if (empty($__tagembed__user_details) || empty($data->googleLocationName)) : |
| 502 | return ___tagembed__exitWithDanger(); |
| 503 | endif; |
| 504 | /* --Start-- Manage Param Data */ |
| 505 | $param['googleLocationName'] = $data->googleLocationName; |
| 506 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 507 | /* --End-- Manage Param Data */ |
| 508 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchgooglelocation', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 509 | unset($param); |
| 510 | $response = ___tagembed__manageApiResponse($response); |
| 511 | return ___tagembed__exitWithSuccess($response); |
| 512 | break; |
| 513 | case '__tagembed__search_vk_communities': |
| 514 | if (empty($__tagembed__user_details) || empty($data->vkCommunitiesName)) : |
| 515 | return ___tagembed__exitWithDanger(); |
| 516 | endif; |
| 517 | /* --Start-- Manage Param Data */ |
| 518 | $param['vkCommunitiesName'] = $data->vkCommunitiesName; |
| 519 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 520 | /* --End-- Manage Param Data */ |
| 521 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchVkCommunities', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 522 | unset($param); |
| 523 | $response = ___tagembed__manageApiResponse($response); |
| 524 | return ___tagembed__exitWithSuccess($response); |
| 525 | break; |
| 526 | case '__tagembed__search_facebook_page': |
| 527 | if (empty($data->facebookPageData)) : |
| 528 | return ___tagembed__exitWithDanger(); |
| 529 | endif; |
| 530 | /* --Start-- Manage Param Data */ |
| 531 | $param['facebookPageData'] = $data->facebookPageData; |
| 532 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 533 | /* --End-- Manage Param Data */ |
| 534 | /* --Start-- Call And Manage Api Call */ |
| 535 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchfacebookpage', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 536 | unset($param); |
| 537 | $response = ___tagembed__manageApiResponse($response); |
| 538 | return ___tagembed__exitWithSuccess($response); |
| 539 | break; |
| 540 | case '__tagembed__get_facebook_page_albums': |
| 541 | if (empty($__tagembed__user_details) || empty($data->connectedAccountsId)) : |
| 542 | return ___tagembed__exitWithDanger(); |
| 543 | endif; |
| 544 | /* --Start-- Manage Param Data */ |
| 545 | $param['connectedAccountsId'] = sanitize_key($data->connectedAccountsId); |
| 546 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 547 | /* --End-- Manage Param Data */ |
| 548 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/apiauthfacebookpagealbums', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 549 | unset($param); |
| 550 | $response = ___tagembed__manageApiResponse($response); |
| 551 | return ___tagembed__exitWithSuccess($response); |
| 552 | break; |
| 553 | case '__tagembed__search_youtube_channel': |
| 554 | if (empty($__tagembed__user_details) || empty($data->youtubeChannelData)) : |
| 555 | return ___tagembed__exitWithDanger(); |
| 556 | endif; |
| 557 | /* --Start-- Manage Param Data */ |
| 558 | $param['youtubeChannelData'] = $data->youtubeChannelData; |
| 559 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 560 | /* --End-- Manage Param Data */ |
| 561 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchyoutubechannel', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 562 | unset($param); |
| 563 | $response = ___tagembed__manageApiResponse($response); |
| 564 | return ___tagembed__exitWithSuccess($response); |
| 565 | break; |
| 566 | case '__tagembed__get_youtube_playlist': |
| 567 | if (empty($__tagembed__user_details) || empty($data->youtubeId)) : |
| 568 | return ___tagembed__exitWithDanger(); |
| 569 | endif; |
| 570 | /* --Start-- Manage Param Data */ |
| 571 | $param['youtubeId'] = $data->youtubeId; |
| 572 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 573 | /* --End-- Manage Param Data */ |
| 574 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getyoutubeplaylist', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 575 | unset($param); |
| 576 | $response = ___tagembed__manageApiResponse($response); |
| 577 | return ___tagembed__exitWithSuccess($response); |
| 578 | break; |
| 579 | case '__tagembed__get_slack_channel_list': |
| 580 | if (empty($data->connectedAccountsId)) : |
| 581 | return ___tagembed__exitWithDanger(); |
| 582 | endif; |
| 583 | /* --Start-- Manage Param Data */ |
| 584 | $param['connectedAccountsId'] = $data->connectedAccountsId; |
| 585 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 586 | /* --End-- Manage Param Data */ |
| 587 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getslackchannellist', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 588 | unset($param); |
| 589 | $response = ___tagembed__manageApiResponse($response); |
| 590 | return ___tagembed__exitWithSuccess($response); |
| 591 | break; |
| 592 | case '__tagembed__get_feed': |
| 593 | if (empty($__tagembed__user_details) || empty($data->widgetId)) : |
| 594 | return ___tagembed__exitWithDanger(); |
| 595 | endif; |
| 596 | /* --Start-- Manage Param Data */ |
| 597 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 598 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 599 | /* --End-- Manage Param Data */ |
| 600 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 601 | unset($param); |
| 602 | $response = ___tagembed__manageApiResponse($response); |
| 603 | return ___tagembed__exitWithSuccess($response); |
| 604 | break; |
| 605 | case '__tagembed__update_feed_status': |
| 606 | if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->feedId)) : |
| 607 | return ___tagembed__exitWithDanger(); |
| 608 | endif; |
| 609 | /* --Start-- Manage Param Data */ |
| 610 | $param['feedId'] = sanitize_key($data->feedId); |
| 611 | $param['status'] = sanitize_key($data->status); |
| 612 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 613 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 614 | /* --End-- Manage Param Data */ |
| 615 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 616 | unset($param); |
| 617 | $response = ___tagembed__manageApiResponse($response); |
| 618 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 619 | return ___tagembed__exitWithSuccess(['message' => $response]); |
| 620 | break; |
| 621 | case '__tagembed__delete_feed': |
| 622 | if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->feedId)) : |
| 623 | return ___tagembed__exitWithDanger(); |
| 624 | endif; |
| 625 | /* --Start-- Manage Param Data */ |
| 626 | $param['feedId'] = sanitize_key($data->feedId); |
| 627 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 628 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 629 | /* --End-- Manage Param Data */ |
| 630 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 631 | unset($param); |
| 632 | $response = ___tagembed__manageApiResponse($response); |
| 633 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 634 | return ___tagembed__exitWithSuccess(['message' => $response]); |
| 635 | break; |
| 636 | case '__tagembed__create_feed': |
| 637 | if (empty($__tagembed__user_details) || empty($data->widgetName) || empty($data->networkName) || empty($data->filterName) || empty($data->widgetId) || empty($data->networkId) || empty($data->filterId)) : |
| 638 | return ___tagembed__exitWithDanger(); |
| 639 | endif; |
| 640 | $__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]; |
| 641 | $__tagembed__feed_input_data['feed'] = !empty($data->feed) ? sanitize_text_field($data->feed) : '__tagembed__feed'; |
| 642 | $__tagembed__feed_filter_id = $data->filterId; |
| 643 | switch ($__tagembed__feed_input_data['networkId']): |
| 644 | case 1: |
| 645 | $__tagembed__feed_input_data['auth'] = 1; |
| 646 | $__tagembed__feed_input_data['multiplePhoto'] = sanitize_key(isset($data->multiplePhoto) ? 1 : 0); |
| 647 | $__tagembed__feed_input_data['excludeRetweet'] = sanitize_key(isset($data->excludeRetweet) ? 1 : 0); |
| 648 | if (!empty($data->list)) : |
| 649 | $__tagembed__feed_input_data['list'] = sanitize_key($data->list); |
| 650 | endif; |
| 651 | break; |
| 652 | case 2: |
| 653 | $__tagembed__feed_input_data['auth'] = 1; |
| 654 | break; |
| 655 | case 3: |
| 656 | $__tagembed__feed_input_data['auth'] = 1; |
| 657 | switch ($__tagembed__feed_filter_id): |
| 658 | case 65: |
| 659 | $__tagembed__feed_input_data['accountAlbumType'] = sanitize_key(isset($data->accountAlbumType) ? $data->accountAlbumType : ''); |
| 660 | $__tagembed__feed_input_data['accountAlbumData'] = sanitize_text_field(isset($data->accountAlbumData) ? $data->accountAlbumData : ''); |
| 661 | break; |
| 662 | endswitch; |
| 663 | break; |
| 664 | case 4: |
| 665 | if ($__tagembed__feed_filter_id == 29) : |
| 666 | $__tagembed__feed_input_data['auth'] = 1; |
| 667 | else : |
| 668 | $__tagembed__feed_input_data['placeId'] = $data->placeId; |
| 669 | $__tagembed__feed_input_data['placeName'] = $data->placeName; |
| 670 | endif; |
| 671 | break; |
| 672 | case 5: |
| 673 | switch ($__tagembed__feed_filter_id): |
| 674 | case 1: |
| 675 | case 71: |
| 676 | break; |
| 677 | case 12: |
| 678 | if (!preg_match('/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : |
| 679 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); |
| 680 | endif; |
| 681 | $pintrestHeaders = explode('/', parse_url($data->feed)['path']); |
| 682 | $__tagembed__feed_input_data['value1'] = strtolower($pintrestHeaders[1]); |
| 683 | $__tagembed__feed_input_data['value2'] = strtolower($pintrestHeaders[2]); |
| 684 | break; |
| 685 | endswitch; |
| 686 | break; |
| 687 | case 6: |
| 688 | switch ($__tagembed__feed_filter_id): |
| 689 | case 1: |
| 690 | case 2: |
| 691 | $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; |
| 692 | break; |
| 693 | endswitch; |
| 694 | break; |
| 695 | case 7: |
| 696 | if (in_array($__tagembed__feed_filter_id, [1, 71])) : |
| 697 | $isUrl = false; |
| 698 | if (preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : |
| 699 | $isUrl = true; |
| 700 | endif; |
| 701 | if ((empty($data->youtubeId) || empty($data->youtubeName)) && !$isUrl) : |
| 702 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid Channel URL Or Tab On Search Icon']); |
| 703 | endif; |
| 704 | if ($isUrl) : |
| 705 | $data->youtubeId = explode('/', $data->feed); |
| 706 | $data->youtubeId = $data->youtubeId[4]; |
| 707 | $data->youtubeName = 'youtube'; |
| 708 | if (empty($data->youtubeId) || empty($data->youtubeName)) : |
| 709 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid Channel URL']); |
| 710 | endif; |
| 711 | endif; |
| 712 | endif; |
| 713 | switch ($__tagembed__feed_filter_id): |
| 714 | case 1: |
| 715 | case 75: |
| 716 | $__tagembed__feed_input_data['youtubeId'] = $data->youtubeId; |
| 717 | $__tagembed__feed_input_data['youtubeName'] = $data->youtubeName; |
| 718 | break; |
| 719 | case 11: |
| 720 | if (empty($data->youtubePlaylist) && empty($data->youtubeId)) : |
| 721 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid Channel URL Or Tab On Search Icon']); |
| 722 | elseif (empty($data->youtubePlaylist) && !empty($data->youtubeId)) : |
| 723 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Play List Not Found']); |
| 724 | endif; |
| 725 | $data->youtubePlaylist = explode('#', $data->youtubePlaylist); |
| 726 | $__tagembed__feed_input_data['youtubeId'] = $data->youtubePlaylist[0]; |
| 727 | $__tagembed__feed_input_data['youtubeName'] = $data->youtubePlaylist[1]; |
| 728 | $__tagembed__feed_input_data['feed'] = $data->youtubePlaylist[1]; |
| 729 | unset($data->youtubePlaylist); |
| 730 | break; |
| 731 | endswitch; |
| 732 | break; |
| 733 | case 8: |
| 734 | switch ($__tagembed__feed_filter_id): |
| 735 | case 1: |
| 736 | case 2: |
| 737 | $__tagembed__feed_input_data['auth'] = 1; |
| 738 | break; |
| 739 | endswitch; |
| 740 | break; |
| 741 | case 10: |
| 742 | if (in_array($__tagembed__feed_filter_id, [1, 16, 17])) : |
| 743 | if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : |
| 744 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); |
| 745 | endif; |
| 746 | endif; |
| 747 | switch ($__tagembed__feed_filter_id): |
| 748 | case 16: |
| 749 | $postUrl = parse_url($data->feed); |
| 750 | if (!strstr($postUrl['host'], 'linkedin')) : |
| 751 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); |
| 752 | endif; |
| 753 | $postUrl = $data->feed; |
| 754 | $postUrl = rtrim($postUrl, '/'); |
| 755 | preg_match('/[^\/]+$/', $postUrl, $postId); |
| 756 | $postId = $postId[0]; |
| 757 | $postId = (explode('?', $postId)[0]); |
| 758 | $value1 = 'LinkedIn'; |
| 759 | if (stripos($postId, 'activity') !== false) : |
| 760 | $postId = (explode('activity', $postId)[1]); |
| 761 | $value2 = 'activity'; |
| 762 | elseif (stripos($postId, 'ugcPost') !== false) : |
| 763 | $postId = (explode('ugcPost', $postId)[1]); |
| 764 | $value2 = 'ugcPost'; |
| 765 | else : |
| 766 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); |
| 767 | endif; |
| 768 | preg_match_all('!\d+!', $postId, $postId); |
| 769 | if (isset($postId[0][0]) && empty($postId[0][0])) : |
| 770 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); |
| 771 | endif; |
| 772 | $value3 = $postId[0][0]; |
| 773 | if (empty($value1) || empty($value2) || empty($value3)) : |
| 774 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Linkedin Post Url']); |
| 775 | endif; |
| 776 | $__tagembed__feed_input_data['value1'] = $value1; |
| 777 | $__tagembed__feed_input_data['value2'] = $value2; |
| 778 | $__tagembed__feed_input_data['value3'] = $value3; |
| 779 | break; |
| 780 | case 1: |
| 781 | case 17: |
| 782 | $url = parse_url($data->feed); |
| 783 | $companyPageUrl = $url['scheme'] . '://' . $url['host']; |
| 784 | $url = explode('/', $url['path']); |
| 785 | $companyPageUrl = $companyPageUrl . '/' . $url[1] . '/' . $url[2] . '/'; |
| 786 | $__tagembed__feed_input_data['feed'] = $companyPageUrl; |
| 787 | $url[2] = str_replace('-', ' ', '$url[2]'); |
| 788 | $__tagembed__feed_input_data['page'] = ucwords($url[2], ' '); |
| 789 | break; |
| 790 | case 2: |
| 791 | $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; |
| 792 | break; |
| 793 | endswitch; |
| 794 | break; |
| 795 | case 11: |
| 796 | switch ($__tagembed__feed_filter_id): |
| 797 | case 1: |
| 798 | case 2: |
| 799 | $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; |
| 800 | break; |
| 801 | endswitch; |
| 802 | break; |
| 803 | case 12: |
| 804 | if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : |
| 805 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); |
| 806 | endif; |
| 807 | $__tagembed__feed_input_data['name'] = $data->name; |
| 808 | break; |
| 809 | case 18: |
| 810 | switch ($__tagembed__feed_filter_id): |
| 811 | case 23: |
| 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 | break; |
| 816 | case 26: |
| 817 | $__tagembed__feed_input_data['hashtagCaption'] = sanitize_key(isset($data->hashtagCaption) ? 1 : 0); |
| 818 | $__tagembed__feed_input_data['hashtagOlder'] = sanitize_key(isset($data->hashtagOlder) ? 1 : 0); |
| 819 | break; |
| 820 | endswitch; |
| 821 | $__tagembed__feed_input_data['auth'] = 1; |
| 822 | break; |
| 823 | case 19: |
| 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 | $yelpBusinessUrl = parse_url($data->feed); |
| 828 | if (!strstr($yelpBusinessUrl['host'], 'yelp')) : |
| 829 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Yelp Business Url']); |
| 830 | endif; |
| 831 | $yelpBusinessPath = explode('/', $yelpBusinessUrl['path']); |
| 832 | $__tagembed__feed_input_data['feed'] = $yelpBusinessPath[2]; |
| 833 | $__tagembed__feed_input_data['name'] = $yelpBusinessPath[2]; |
| 834 | break; |
| 835 | case 20: |
| 836 | $__tagembed__feed_input_data['auth'] = 1; |
| 837 | $slackData = isset($data->slackChannelList) ? $data->slackChannelList : ''; |
| 838 | if (!empty($slackData)) : |
| 839 | $slackData = explode('#', $slackData); |
| 840 | $__tagembed__feed_input_data['name'] = $slackData[1]; |
| 841 | $__tagembed__feed_input_data['feed'] = $slackData[0]; |
| 842 | endif; |
| 843 | break; |
| 844 | case 23: |
| 845 | if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : |
| 846 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); |
| 847 | endif; |
| 848 | $airbnbListUrl = parse_url($data->feed); |
| 849 | if (strstr($airbnbListUrl['host'], 'airbnb')) : |
| 850 | preg_match('/[^\/]+$/', $data->feed, $matches); |
| 851 | $__tagembed__feed_input_data['listId'] = explode('?', $matches[0])[0]; |
| 852 | else : |
| 853 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Airbnb Url']); |
| 854 | endif; |
| 855 | $__tagembed__feed_input_data['name'] = $data->name; |
| 856 | break; |
| 857 | case 36: |
| 858 | if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : |
| 859 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); |
| 860 | endif; |
| 861 | $etsyShopUrl = parse_url($data->feed); |
| 862 | if (!strstr($etsyShopUrl['host'], 'etsy')) : |
| 863 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Etsy Shop Url']); |
| 864 | endif; |
| 865 | $__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = explode('/shop/', $etsyShopUrl['path'])[1]; |
| 866 | break; |
| 867 | case 28: |
| 868 | switch ($__tagembed__feed_filter_id): |
| 869 | case 72: |
| 870 | $__tagembed__feed_input_data['feed'] = $data->feed; |
| 871 | $__tagembed__feed_input_data['name'] = $data->feed; |
| 872 | break; |
| 873 | endswitch; |
| 874 | if (!in_array($__tagembed__feed_filter_id, [72])) : |
| 875 | $__tagembed__feed_input_data['auth'] = 1; |
| 876 | endif; |
| 877 | break; |
| 878 | case 30: |
| 879 | switch ($__tagembed__feed_filter_id): |
| 880 | case 2: |
| 881 | $__tagembed__feed_input_data['feed'] = $data->feed; |
| 882 | $__tagembed__feed_input_data['name'] = $data->feed; |
| 883 | break; |
| 884 | case 75: |
| 885 | $__tagembed__feed_input_data['communitiesName'] = $data->communitiesName; |
| 886 | $__tagembed__feed_input_data['communitiesId'] = $data->communitiesId; |
| 887 | break; |
| 888 | endswitch; |
| 889 | if (!in_array($__tagembed__feed_filter_id, [2, 75])) : |
| 890 | $__tagembed__feed_input_data['auth'] = 1; |
| 891 | endif; |
| 892 | break; |
| 893 | case 33: |
| 894 | if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : |
| 895 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); |
| 896 | endif; |
| 897 | preg_match('/[^\/]+$/', '$data->feed', $matches); |
| 898 | $__tagembed__feed_input_data['feed'] = $matches[0]; |
| 899 | $__tagembed__feed_input_data['name'] = $matches[0]; |
| 900 | break; |
| 901 | case 34: |
| 902 | if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : |
| 903 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); |
| 904 | endif; |
| 905 | $__tagembed__feed_input_data['name'] = explode('/', $data->feed)[3]; |
| 906 | $__tagembed__feed_input_data['feed'] = $data->feed; |
| 907 | break; |
| 908 | case 35: |
| 909 | if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : |
| 910 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); |
| 911 | endif; |
| 912 | $__tagembed__feed_input_data['name'] = explode('Reviews-', $data->feed)[1]; |
| 913 | $__tagembed__feed_input_data['name'] = explode('.html', $__tagembed__feed_input_data['name'])[0]; |
| 914 | $__tagembed__feed_input_data['feed'] = $data->feed; |
| 915 | break; |
| 916 | case 37: |
| 917 | $data->feed = explode('.html', $data->feed)[0]; |
| 918 | if (!preg_match('/\b(?:(?:https?|ftp) :\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $data->feed)) : |
| 919 | return ___tagembed__exitWithDanger('Validation Error', ['feed' => 'Enter Valid URL']); |
| 920 | endif; |
| 921 | $__tagembed__feed_input_data['name'] = $data->feed; |
| 922 | $__tagembed__feed_input_data['feed'] = explode('item/', $data->feed)[1]; |
| 923 | break; |
| 924 | endswitch; |
| 925 | unset($data); |
| 926 | |
| 927 | /* --Start-- Manage Api Calling */ |
| 928 | $byApiCall = 0; |
| 929 | if (empty($__tagembed__feed_input_data['authId'])) : |
| 930 | switch ($__tagembed__feed_input_data['networkId']): |
| 931 | case 4: |
| 932 | if (33 == $__tagembed__feed_filter_id) : |
| 933 | $byApiCall = 1; |
| 934 | $__tagembed__feed_input_data['byApiCall'] = 1; |
| 935 | endif; |
| 936 | break; |
| 937 | case 5: |
| 938 | case 7: |
| 939 | case 6: |
| 940 | case 10: |
| 941 | case 11: |
| 942 | case 12: |
| 943 | case 19: |
| 944 | case 23: |
| 945 | case 28: |
| 946 | case 29: |
| 947 | case 33: |
| 948 | case 34: |
| 949 | case 35: |
| 950 | case 37: |
| 951 | $byApiCall = 1; |
| 952 | $__tagembed__feed_input_data['byApiCall'] = 1; |
| 953 | break; |
| 954 | case 31: |
| 955 | if (2 == $__tagembed__feed_filter_id) : |
| 956 | $byApiCall = 1; |
| 957 | $__tagembed__feed_input_data['byApiCall'] = 1; |
| 958 | endif; |
| 959 | break; |
| 960 | case 32: |
| 961 | if (in_array($__tagembed__feed_filter_id, [2, 75])) : |
| 962 | $byApiCall = 1; |
| 963 | $__tagembed__feed_input_data['byApiCall'] = 1; |
| 964 | endif; |
| 965 | break; |
| 966 | endswitch; |
| 967 | else : |
| 968 | $byApiCall = 1; |
| 969 | $__tagembed__feed_input_data['byApiCall'] = 1; |
| 970 | endif; |
| 971 | $__tagembed__feed_input_data['appUser'] = 1; |
| 972 | $__tagembed__feed_input_data['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 973 | /* --End-- Manage Api Calling */ |
| 974 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/create', ['feedData' => $__tagembed__feed_input_data], ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 975 | $response = ___tagembed__manageApiResponse($response); |
| 976 | return ___tagembed__exitWithSuccess(['byapiCall' => $byApiCall, '__tagembed__requestCallBackUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL, 'redirectUrl' => TAGEMBED_PLUGIN_API_URL . 'apiauth/getauth', '__tagembed__feedData' => $response->__tagembed__feedData]); |
| 977 | break; |
| 978 | case '__tagembed__make_payment': |
| 979 | |
| 980 | if (empty($__tagembed__user_details) || empty($data->planId)) : |
| 981 | return ___tagembed__exitWithDanger(); |
| 982 | endif; |
| 983 | /* --Start-- Manage Param Data */ |
| 984 | $param['planId'] = sanitize_key($data->planId); |
| 985 | $param['priceCode'] = $data->priceCode; |
| 986 | /* --Start-- Manage Param Data */ |
| 987 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 988 | $param['email'] = $__tagembed__user_details->email; |
| 989 | $param['name'] = $__tagembed__user_details->name; |
| 990 | $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 991 | /* --End-- Manage Param Data */ |
| 992 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getpaymentdetails', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 993 | unset($param); |
| 994 | $response = ___tagembed__manageApiResponse($response); |
| 995 | return ___tagembed__exitWithSuccess(['__tagembed__requestCallBackUrl' => TAGEMBED_PLUGIN_CALL_BACK_URL, 'redirectUrl' => TAGEMBED_PLUGIN_API_URL . 'apiaccount/makepayment', '__tagembed__paymentData' => $response->__tagembed__paymentData]); |
| 996 | break; |
| 997 | case '__tagembed__resume_subscription': |
| 998 | if (empty($__tagembed__user_details)) : |
| 999 | return ___tagembed__exitWithDanger(); |
| 1000 | endif; |
| 1001 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1002 | $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 1003 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/resumesubscription', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1004 | unset($param); |
| 1005 | $response = ___tagembed__manageApiResponse($response); |
| 1006 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 1007 | return ___tagembed__exitWithSuccess(['message' => $response]); |
| 1008 | break; |
| 1009 | case '__tagembed__cancel_subscription': |
| 1010 | if (empty($__tagembed__user_details) || empty($data->planId)) : |
| 1011 | return ___tagembed__exitWithDanger(); |
| 1012 | endif; |
| 1013 | /* --Start-- Manage Param Data */ |
| 1014 | $param['planId'] = sanitize_key($data->planId); |
| 1015 | /* --Start-- Manage Param Data */ |
| 1016 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1017 | $param['email'] = $__tagembed__user_details->email; |
| 1018 | $param['name'] = $__tagembed__user_details->name; |
| 1019 | $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 1020 | /* --End-- Manage Param Data */ |
| 1021 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/cancelsubscription', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1022 | unset($param); |
| 1023 | $response = ___tagembed__manageApiResponse($response); |
| 1024 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 1025 | return ___tagembed__exitWithSuccess(['message' => $response]); |
| 1026 | break; |
| 1027 | case '__tagembed__get_post': |
| 1028 | if (empty($__tagembed__user_details) || empty($data->widgetId) || !isset($data->perPage) || !isset($data->offset) || !isset($data->postStatus)) : |
| 1029 | return ___tagembed__exitWithDanger(); |
| 1030 | endif; |
| 1031 | /* --Start-- Manage Param Data */ |
| 1032 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1033 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1034 | $param['perPage'] = sanitize_key($data->perPage); |
| 1035 | $param['offset'] = sanitize_key($data->offset); |
| 1036 | $param['postStatus'] = sanitize_key($data->postStatus); |
| 1037 | $param['feedIds'] = $data->feedIds; |
| 1038 | $param['postType'] = $data->postType; |
| 1039 | $param['highlightFilter'] = sanitize_key($data->highlightFilter); |
| 1040 | $param['pinFilter'] = sanitize_key($data->pinFilter); |
| 1041 | $param['recentFilter'] = sanitize_key($data->recentFilter); |
| 1042 | $param['retweetFilter'] = sanitize_key($data->retweetFilter); |
| 1043 | $param['searchText'] = sanitize_text_field($data->searchText); |
| 1044 | /* --End-- Manage Param Data */ |
| 1045 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1046 | unset($param); |
| 1047 | $response = ___tagembed__manageApiResponse($response); |
| 1048 | return ___tagembed__exitWithSuccess($response); |
| 1049 | break; |
| 1050 | case '__tagembed__manage_post_status': |
| 1051 | if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postIds) || empty($data->postStatus)) : |
| 1052 | return ___tagembed__exitWithDanger(); |
| 1053 | endif; |
| 1054 | /* --Start-- Manage Param Data */ |
| 1055 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1056 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1057 | $param['postIds'] = $data->postIds; |
| 1058 | $param['postStatus'] = sanitize_key($data->postStatus); |
| 1059 | /* --End-- Manage Param Data */ |
| 1060 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1061 | unset($param); |
| 1062 | $response = ___tagembed__manageApiResponse($response); |
| 1063 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 1064 | return ___tagembed__exitWithSuccess(['message' => $response]); |
| 1065 | break; |
| 1066 | case '__tagembed__feed_for_search': |
| 1067 | if (empty($__tagembed__user_details) || empty($data->widgetId)) : |
| 1068 | return ___tagembed__exitWithDanger(); |
| 1069 | endif; |
| 1070 | /* --Start-- Manage Param Data */ |
| 1071 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1072 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1073 | /* --End-- Manage Param Data */ |
| 1074 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/getfeeds', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1075 | unset($param); |
| 1076 | $response = ___tagembed__manageApiResponse($response); |
| 1077 | return ___tagembed__exitWithSuccess($response); |
| 1078 | break; |
| 1079 | case '__tagembed__manage_post_pin': |
| 1080 | if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postId) || !isset($data->pin)) : |
| 1081 | return ___tagembed__exitWithDanger(); |
| 1082 | endif; |
| 1083 | /* --Start-- Manage Param Data */ |
| 1084 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1085 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1086 | $param['postId'] = $data->postId; |
| 1087 | $param['pin'] = sanitize_key($data->pin); |
| 1088 | /* --End-- Manage Param Data */ |
| 1089 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/pin', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1090 | unset($param); |
| 1091 | $response = ___tagembed__manageApiResponse($response); |
| 1092 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 1093 | return ___tagembed__exitWithSuccess(['message' => $response]); |
| 1094 | break; |
| 1095 | case '__tagembed__manage_post_highlight': |
| 1096 | if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postId) || !isset($data->highlight)) : |
| 1097 | return ___tagembed__exitWithDanger(); |
| 1098 | endif; |
| 1099 | /* --Start-- Manage Param Data */ |
| 1100 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1101 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1102 | $param['postId'] = $data->postId; |
| 1103 | $param['highlight'] = sanitize_key($data->highlight); |
| 1104 | /* --End-- Manage Param Data */ |
| 1105 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/highlight', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1106 | unset($param); |
| 1107 | $response = ___tagembed__manageApiResponse($response); |
| 1108 | $response = !empty($response->message) ? $response->message : 'Done'; |
| 1109 | return ___tagembed__exitWithSuccess(['message' => $response]); |
| 1110 | break; |
| 1111 | case '__tagembed__plugin_version': |
| 1112 | /* --Start-- Manage Param Data */ |
| 1113 | $param = []; |
| 1114 | $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 1115 | /* --End-- Manage Param Data */ |
| 1116 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/pluginversion', $param, []); |
| 1117 | $response = ___tagembed__manageApiResponse($response); |
| 1118 | unset($param); |
| 1119 | $installedPluginVersion = get_file_data(__FILE__, ['Version' => 'Version'], false); |
| 1120 | $installedPluginVersion = $installedPluginVersion['Version']; |
| 1121 | $response->installedPluginVersion = $installedPluginVersion; |
| 1122 | $response->pluginUpgradeURL = admin_url() . 'plugins.php'; |
| 1123 | return ___tagembed__exitWithSuccess($response); |
| 1124 | break; |
| 1125 | case '__tagembed__check_user_token': |
| 1126 | if (empty($__tagembed__user_details)) : |
| 1127 | return ___tagembed__exitWithDanger(); |
| 1128 | endif; |
| 1129 | /* --Start-- Manage Param Data */ |
| 1130 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1131 | /* --End-- Manage Param Data */ |
| 1132 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/checkusertoken', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1133 | if (!empty($response->head) && 401 == $response->head->code && empty($response->head->status)) : |
| 1134 | tagembed_logout(); |
| 1135 | endif; |
| 1136 | unset($param); |
| 1137 | return ___tagembed__exitWithSuccess($response); |
| 1138 | break; |
| 1139 | case '__tagembed__plugin_deactivate': |
| 1140 | /* --Start-- Manage Param Data */ |
| 1141 | $__tagembed__user_details = ___tagembed__userData(); |
| 1142 | $param = []; |
| 1143 | $param['userId'] = !empty($__tagembed__user_details) ? sanitize_key($__tagembed__user_details->userId) : ''; |
| 1144 | $param['userName'] = !empty($__tagembed__user_details) ? sanitize_text_field($__tagembed__user_details->name) : ''; |
| 1145 | $param['userEmail'] = !empty($__tagembed__user_details) ? sanitize_email($__tagembed__user_details->email) : ''; |
| 1146 | $param['pluginDeactivateReason'] = sanitize_text_field($data->pluginDeactivateReason); |
| 1147 | $param['otherReason'] = sanitize_text_field($data->otherReason); |
| 1148 | $param['betterPlugin'] = sanitize_text_field($data->betterPlugin); |
| 1149 | $param['userWebsiteUrl'] = get_site_url(); |
| 1150 | $param['platform'] = TAGEMBED_PLUGIN_PLATFORM; |
| 1151 | /* --End-- Manage Param Data */ |
| 1152 | ___tagembed__dropDatabaseTablesForPlugin(); |
| 1153 | deactivate_plugins(plugin_basename(__FILE__), true); |
| 1154 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/deactivateuserdata', $param, []); |
| 1155 | $response = ___tagembed__manageApiResponse($response); |
| 1156 | unset($param); |
| 1157 | return ___tagembed__exitWithSuccess(); |
| 1158 | break; |
| 1159 | case '__tagembed__get_customization_option': |
| 1160 | if (empty($__tagembed__user_details) || empty($data->widgetId)) : |
| 1161 | return ___tagembed__exitWithDanger(); |
| 1162 | endif; |
| 1163 | /* --Start-- Manage Param Data */ |
| 1164 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1165 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1166 | /* --End-- Manage Param Data */ |
| 1167 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1168 | unset($param); |
| 1169 | $response = ___tagembed__manageApiResponse($response); |
| 1170 | return ___tagembed__exitWithSuccess($response); |
| 1171 | break; |
| 1172 | case '__tagembed__update_footer_customization_option': |
| 1173 | /* --Start-- Manage Param Data */ |
| 1174 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1175 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1176 | $param['personalizationId'] = sanitize_key($data->personalizationId); |
| 1177 | $param['themeRuleId'] = sanitize_key($data->themeRuleId); |
| 1178 | $param['loadMoreStatus'] = sanitize_key($data->loadMoreStatus); |
| 1179 | $param['autoScrollStatus'] = sanitize_key($data->autoScrollStatus); |
| 1180 | /* --End-- Manage Param Data */ |
| 1181 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/footer', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1182 | unset($param); |
| 1183 | $response = ___tagembed__manageApiResponse($response); |
| 1184 | return ___tagembed__exitWithSuccess($response); |
| 1185 | break; |
| 1186 | case '__tagembed__update_layout_customization_option': |
| 1187 | /* --Start-- Manage Param Data */ |
| 1188 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1189 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1190 | $param['personalizationId'] = sanitize_key($data->personalizationId); |
| 1191 | $param['themeRuleId'] = sanitize_key($data->themeRuleId); |
| 1192 | $param['numberOfPosts'] = sanitize_key($data->numberOfPosts); |
| 1193 | $param['padding'] = sanitize_key($data->padding); |
| 1194 | $param['minimumPostWidth'] = sanitize_key($data->minimumPostWidth); |
| 1195 | $param['columnCount'] = sanitize_key($data->columnCount); |
| 1196 | $param['columnCountMobile'] = sanitize_key($data->columnCountMobile); |
| 1197 | $param['postText'] = sanitize_key($data->postText); |
| 1198 | $param['mobilePopup'] = sanitize_key($data->mobilePopup); |
| 1199 | $param['postFeatured'] = sanitize_key($data->postFeatured); |
| 1200 | /* --End-- Manage Param Data */ |
| 1201 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/layout', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1202 | unset($param); |
| 1203 | $response = ___tagembed__manageApiResponse($response); |
| 1204 | return ___tagembed__exitWithSuccess($response); |
| 1205 | break; |
| 1206 | case '__tagembed__update_card_customization_option': |
| 1207 | /* --Start-- Manage Param Data */ |
| 1208 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1209 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1210 | $param['personalizationId'] = sanitize_key($data->personalizationId); |
| 1211 | $param['inheritStyles'] = sanitize_key($data->inheritStyles); |
| 1212 | $param['themeRuleId'] = sanitize_key($data->themeRuleId); |
| 1213 | $param['fontColor'] = $data->fontColor; |
| 1214 | $param['authorColor'] = $data->authorColor; |
| 1215 | $param['cardColor'] = $data->cardColor; |
| 1216 | $param['fontSize'] = sanitize_key($data->fontSize); |
| 1217 | $param['shareOption'] = sanitize_key($data->shareOption); |
| 1218 | $param['hideContent'] = sanitize_key($data->hideContent); |
| 1219 | $param['postAuthor'] = sanitize_key($data->postAuthor); |
| 1220 | $param['postTime'] = sanitize_key($data->postTime); |
| 1221 | $param['lineTrim'] = sanitize_key($data->lineTrim); |
| 1222 | $param['aspectImageRatio'] = $data->aspectImageRatio; |
| 1223 | $param['textAlignment'] = $data->textAlignment; |
| 1224 | $param['roundEdge'] = $data->roundEdge; |
| 1225 | /* --End-- Manage Param Data */ |
| 1226 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/card', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1227 | unset($param); |
| 1228 | $response = ___tagembed__manageApiResponse($response); |
| 1229 | return ___tagembed__exitWithSuccess($response); |
| 1230 | break; |
| 1231 | case '__tagembed__update_other_customization_option': |
| 1232 | /* --Start-- Manage Param Data */ |
| 1233 | $param['widgetId'] = sanitize_key($data->widgetId); |
| 1234 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1235 | $param['personalizationId'] = sanitize_key($data->personalizationId); |
| 1236 | $param['themeRuleId'] = sanitize_key($data->themeRuleId); |
| 1237 | $param['css'] = $data->css; |
| 1238 | /* --End-- Manage Param Data */ |
| 1239 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/other', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1240 | unset($param); |
| 1241 | $response = ___tagembed__manageApiResponse($response); |
| 1242 | return ___tagembed__exitWithSuccess($response); |
| 1243 | break; |
| 1244 | case '__tagembed__get_and_manage_intercom_chat_setting': |
| 1245 | if (empty($__tagembed__user_details)) : |
| 1246 | return ___tagembed__exitWithDanger(); |
| 1247 | endif; |
| 1248 | /* --Start-- Manage Param Data */ |
| 1249 | $param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1250 | /* --End-- Manage Param Data */ |
| 1251 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getIntercomSettingData', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1252 | unset($param); |
| 1253 | $response = ___tagembed__manageApiResponse($response); |
| 1254 | return ___tagembed__exitWithSuccess($response); |
| 1255 | break; |
| 1256 | default: |
| 1257 | return ___tagembed__exitWithDanger(); |
| 1258 | endswitch; |
| 1259 | } |
| 1260 | /* --End-- Manage Ajax Calls */ |
| 1261 | |
| 1262 | add_action('admin_init', '___tagembed__googleAuthListener'); |
| 1263 | function ___tagembed__googleAuthListener() |
| 1264 | { |
| 1265 | if (empty($_GET['__tb_google_state'])) : |
| 1266 | return; |
| 1267 | endif; |
| 1268 | if (empty($_GET['page']) || 'tagembed' !== sanitize_key(wp_unslash($_GET['page']))) : |
| 1269 | return; |
| 1270 | endif; |
| 1271 | if (!current_user_can('manage_options')) : |
| 1272 | return; |
| 1273 | endif; |
| 1274 | $__tagembed__google_state = isset($_GET['__tb_google_state']) ? sanitize_text_field(wp_unslash($_GET['__tb_google_state'])) : ''; |
| 1275 | if ('' === $__tagembed__google_state || !preg_match('/^[A-Za-z0-9]{16,64}$/', $__tagembed__google_state)) : |
| 1276 | return; |
| 1277 | endif; |
| 1278 | $__tagembed__google_session = get_transient('__tagembed__google_' . $__tagembed__google_state); |
| 1279 | delete_transient('__tagembed__google_' . $__tagembed__google_state); |
| 1280 | if (empty($__tagembed__google_session['verifier']) || (int) $__tagembed__google_session['userId'] !== get_current_user_id()) : |
| 1281 | return ___tagembed__googleAuthFailed('expired'); |
| 1282 | endif; |
| 1283 | if (empty($_GET['__tb_google_code'])) : |
| 1284 | $__tagembed__google_error_code = isset($_GET['__tb_google_error']) ? sanitize_text_field(wp_unslash($_GET['__tb_google_error'])) : 'failed'; |
| 1285 | return ___tagembed__googleAuthFailed($__tagembed__google_error_code); |
| 1286 | endif; |
| 1287 | $param = [ |
| 1288 | 'token' => sanitize_text_field(wp_unslash($_GET['__tb_google_code'])), |
| 1289 | 'verifier' => $__tagembed__google_session['verifier'], |
| 1290 | 'platform' => TAGEMBED_PLUGIN_PLATFORM, |
| 1291 | ]; |
| 1292 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/googleexchange', $param, []); |
| 1293 | unset($param); |
| 1294 | if (empty($response->head) || empty($response->head->status) || empty($response->body->userId) || empty($response->body->emailId) || empty($response->body->access_token)) : |
| 1295 | return ___tagembed__googleAuthFailed('failed'); |
| 1296 | endif; |
| 1297 | $__tagembed__google_user = $response->body; |
| 1298 | if (!empty($__tagembed__google_user->createFirstWidget)) : |
| 1299 | ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', ['userId' => sanitize_key($__tagembed__google_user->userId), 'inheritStyles' => 1], ['Authorization:' . $__tagembed__google_user->access_token]); |
| 1300 | endif; |
| 1301 | if (___tagembed__login($__tagembed__google_user) !== true) : |
| 1302 | return ___tagembed__googleAuthFailed('failed'); |
| 1303 | endif; |
| 1304 | wp_safe_redirect(TAGEMBED_PLUGIN_CALL_BACK_URL); |
| 1305 | exit; |
| 1306 | } |
| 1307 | function ___tagembed__googleAuthFailed($errorCode) |
| 1308 | { |
| 1309 | $__tagembed__google_errors = [ |
| 1310 | 'cancelled' => 'Google sign in was cancelled. Please try again.', |
| 1311 | 'expired' => 'Google sign in session has expired. Please try again.', |
| 1312 | 'email' => 'Your Google account email could not be verified. Please use another account.', |
| 1313 | 'account' => 'Your account is not active. Please contact support.', |
| 1314 | 'register' => 'We could not create an account with this Google email. Please sign up with your email instead.', |
| 1315 | 'process' => 'Your registration is already in progress. Please wait a moment and try again.', |
| 1316 | 'failed' => 'Google sign in failed. Please try again.', |
| 1317 | ]; |
| 1318 | $__tagembed__google_message = isset($__tagembed__google_errors[$errorCode]) ? $__tagembed__google_errors[$errorCode] : $__tagembed__google_errors['failed']; |
| 1319 | set_transient('__tagembed__google_error_' . get_current_user_id(), $__tagembed__google_message, MINUTE_IN_SECONDS); |
| 1320 | wp_safe_redirect(TAGEMBED_PLUGIN_CALL_BACK_URL); |
| 1321 | exit; |
| 1322 | } |
| 1323 | /* --Start-- Login */ |
| 1324 | function ___tagembed__login($response) |
| 1325 | { |
| 1326 | global $wpdb; |
| 1327 | $return = false; |
| 1328 | $user = ___tagembed__user($response->emailId); |
| 1329 | if (empty($user->email)) : |
| 1330 | 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'))) : |
| 1331 | $return = true; |
| 1332 | endif; |
| 1333 | else : |
| 1334 | 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))) : |
| 1335 | $return = true; |
| 1336 | endif; |
| 1337 | endif; |
| 1338 | ___tagembed__manageActiveOptions($response->emailId, 'yes'); /* Manage Active Options */ |
| 1339 | if ($return) : |
| 1340 | ___tagembed__manageActiveWidgetsUser($response->userId); |
| 1341 | endif; |
| 1342 | return $return; |
| 1343 | } |
| 1344 | /* --End-- Login */ |
| 1345 | |
| 1346 | /* --Start-- Manage Active Options */ |
| 1347 | function ___tagembed__manageActiveOptions($email = null, $other = null) |
| 1348 | { |
| 1349 | global $wpdb; |
| 1350 | if (null == $email && null != $other) : |
| 1351 | $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_options SET isLogin = %s WHERE id = %d', $other, 1)); |
| 1352 | else : |
| 1353 | $__tagembed__activeOptions = $wpdb->get_results($wpdb->prepare('SELECT email FROM wp_tagembed_active_options WHERE id = %d', 1)); |
| 1354 | if (empty($__tagembed__activeOptions[0]->email)) : |
| 1355 | $wpdb->query($wpdb->prepare('INSERT INTO wp_tagembed_active_options (email, isLogin) VALUES (%s, %s)', $email, $other)); |
| 1356 | else : |
| 1357 | $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_options SET email = %s, isLogin = %s WHERE id = %d', $email, $other, 1)); |
| 1358 | endif; |
| 1359 | endif; |
| 1360 | } |
| 1361 | /* --End-- Manage Active Options */ |
| 1362 | |
| 1363 | /* --Start-- Logout */ |
| 1364 | function tagembed_logout() |
| 1365 | { |
| 1366 | global $wpdb; |
| 1367 | if ($wpdb->query($wpdb->prepare('UPDATE wp_tagembed_user SET isLogin = %s WHERE isLogin = %s', 'no', 'yes'))) : |
| 1368 | ___tagembed__manageActiveOptions(null, 'no'); /* Manage Active Options */ |
| 1369 | return true; |
| 1370 | endif; |
| 1371 | return false; |
| 1372 | } |
| 1373 | /* --End-- Logout */ |
| 1374 | |
| 1375 | /* --Start--Manage Menues */ |
| 1376 | function ___tagembed__menus($__tagembed__menu_condatation = []) |
| 1377 | { |
| 1378 | global $wpdb; |
| 1379 | if (empty($__tagembed__menu_condatation)) : |
| 1380 | return $wpdb->get_results('SELECT * FROM wp_tagembed_menus'); |
| 1381 | endif; |
| 1382 | if (array_key_exists('__tagembed__menu_condation', $__tagembed__menu_condatation)) : |
| 1383 | return $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_tagembed_menus WHERE status = %s', $__tagembed__menu_condatation['__tagembed__menu_condation'])); |
| 1384 | endif; |
| 1385 | if (array_key_exists('__tagembed__menu_id', $__tagembed__menu_condatation)) : |
| 1386 | 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']))) : |
| 1387 | return true; |
| 1388 | else : |
| 1389 | return false; |
| 1390 | endif; |
| 1391 | endif; |
| 1392 | } |
| 1393 | /* --End--Manage Menues */ |
| 1394 | |
| 1395 | /* --Start-- Get User Details */ |
| 1396 | function ___tagembed__user($email = null) |
| 1397 | { |
| 1398 | global $wpdb; |
| 1399 | $__tagembed__userResponse = ''; |
| 1400 | if (empty($email)) : |
| 1401 | $__tagembed__userResponse = $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_tagembed_user WHERE isLogin = %s', 'yes')); |
| 1402 | else : |
| 1403 | $__tagembed__userResponse = $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_tagembed_user WHERE email = %s', $email)); |
| 1404 | endif; |
| 1405 | if (!empty($__tagembed__userResponse)) : |
| 1406 | return $__tagembed__userResponse[0]; |
| 1407 | else : |
| 1408 | return; |
| 1409 | endif; |
| 1410 | } |
| 1411 | function ___tagembed__userData() |
| 1412 | { |
| 1413 | global $wpdb; |
| 1414 | $__tagembed__user_dataResponse = ''; |
| 1415 | $__tagembed__user_dataResponse = $wpdb->get_results('SELECT * FROM wp_tagembed_user'); |
| 1416 | if (!empty($__tagembed__user_dataResponse)) : |
| 1417 | return $__tagembed__user_dataResponse[0]; |
| 1418 | else : |
| 1419 | return; |
| 1420 | endif; |
| 1421 | } |
| 1422 | /* --End-- Get User Details */ |
| 1423 | |
| 1424 | /* --Start-- Get Widget */ |
| 1425 | function ___tagembed__widgets() |
| 1426 | { |
| 1427 | $returnWidgetData = []; |
| 1428 | $__tagembed__user_details = ___tagembed__user(); |
| 1429 | if (!empty($__tagembed__user_details)) : |
| 1430 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/get', ['userId' => sanitize_key($__tagembed__user_details->userId)], ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1431 | if (!isset($response->head->status)) : |
| 1432 | return $returnWidgetData; |
| 1433 | endif; |
| 1434 | if (false == $response->head->status || 200 != $response->head->code || false == $response->body || empty($response->body)) : |
| 1435 | return $returnWidgetData; |
| 1436 | endif; |
| 1437 | $returnWidgetData = $response->body; |
| 1438 | endif; |
| 1439 | return $returnWidgetData; |
| 1440 | } |
| 1441 | /* --End-- Get Widget */ |
| 1442 | |
| 1443 | /* --Start-- Get Active Widget */ |
| 1444 | function ___tagembed__activeWidget() |
| 1445 | { |
| 1446 | global $wpdb; |
| 1447 | $__tagembed__activeWidgetResponse = ''; |
| 1448 | $__tagembed__activeWidgetResponse = $wpdb->get_results('SELECT * FROM wp_tagembed_active_widget'); |
| 1449 | if (!empty($__tagembed__activeWidgetResponse)) : |
| 1450 | return $__tagembed__activeWidgetResponse[0]->widgetId; |
| 1451 | else : |
| 1452 | return; |
| 1453 | endif; |
| 1454 | } |
| 1455 | /* --End-- Get Active Widget */ |
| 1456 | |
| 1457 | /* --Start-- Manage Active Widget User */ |
| 1458 | function ___tagembed__manageActiveWidget($widgetId) |
| 1459 | { |
| 1460 | global $wpdb; |
| 1461 | $activeWidgetUserId = ___tagembed__activeWidget(); |
| 1462 | if ($activeWidgetUserId == $widgetId) : |
| 1463 | return true; |
| 1464 | endif; |
| 1465 | if (empty($activeWidgetUserId)) : |
| 1466 | $wpdb->query($wpdb->prepare('INSERT INTO wp_tagembed_active_widget (widgetId) VALUES (%s)', $widgetId)); |
| 1467 | return true; |
| 1468 | else : |
| 1469 | $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_widget SET widgetId = %s WHERE id = %d', $widgetId, 1)); |
| 1470 | return true; |
| 1471 | endif; |
| 1472 | return false; |
| 1473 | } |
| 1474 | /* --End-- Manage Active Widget User */ |
| 1475 | |
| 1476 | /* --Start-- Get Active Widget User */ |
| 1477 | function ___tagembed__activeWidgetUser() |
| 1478 | { |
| 1479 | global $wpdb; |
| 1480 | $__tagembed__activeWidgetUserResponse = ''; |
| 1481 | $__tagembed__activeWidgetUserResponse = $wpdb->get_results('SELECT * FROM wp_tagembed_active_widget_user'); |
| 1482 | if (!empty($__tagembed__activeWidgetUserResponse)) : |
| 1483 | return $__tagembed__activeWidgetUserResponse[0]->userId; |
| 1484 | endif; |
| 1485 | return; |
| 1486 | } |
| 1487 | /* --End-- Get Active Widget User */ |
| 1488 | |
| 1489 | /* --Start-- Manage Active Widget User */ |
| 1490 | function ___tagembed__manageActiveWidgetsUser($userId) |
| 1491 | { |
| 1492 | global $wpdb; |
| 1493 | $activeWidgetUserId = ___tagembed__activeWidgetUser(); |
| 1494 | if ($activeWidgetUserId == $userId) : |
| 1495 | return true; |
| 1496 | endif; |
| 1497 | if (empty($activeWidgetUserId)) : |
| 1498 | $wpdb->query($wpdb->prepare('INSERT INTO wp_tagembed_active_widget_user (userId) VALUES (%d)', $userId)); |
| 1499 | return true; |
| 1500 | else : |
| 1501 | $wpdb->query($wpdb->prepare('UPDATE wp_tagembed_active_widget_user SET userId = %d WHERE id = %d', $userId, 1)); |
| 1502 | return true; |
| 1503 | endif; |
| 1504 | return false; |
| 1505 | } |
| 1506 | /* --End-- Manage Active Widget User */ |
| 1507 | |
| 1508 | /* * ** DATABASE *** */ |
| 1509 | /* --Start-- Manage Database */ |
| 1510 | function ___tagembed__createDatabaseTableForPlugin() |
| 1511 | { |
| 1512 | global $wpdb; |
| 1513 | include_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 1514 | $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'); |
| 1515 | $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'); |
| 1516 | $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'); |
| 1517 | $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'); |
| 1518 | $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'); |
| 1519 | /* --Start-- Manage Tagembed Plugin Menus */ |
| 1520 | $__tagembed__checkAlreadyExistMenusDataExistOrNot = $wpdb->get_results('SELECT id FROM wp_tagembed_menus'); |
| 1521 | if (empty($__tagembed__checkAlreadyExistMenusDataExistOrNot)) : |
| 1522 | $__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']]; |
| 1523 | foreach ($__tagembed__menus as $__tagembed__menu) : |
| 1524 | $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'])); |
| 1525 | endforeach; |
| 1526 | endif; |
| 1527 | /* --End-- Manage Tagembed Plugin Menus */ |
| 1528 | } |
| 1529 | function ___tagembed__dropDatabaseTablesForPlugin() |
| 1530 | { |
| 1531 | global $wpdb; |
| 1532 | $wpdb->query('DROP table IF EXISTS wp_tagembed_active_widget_user'); |
| 1533 | $wpdb->query('DROP table IF EXISTS wp_tagembed_active_widget'); |
| 1534 | $wpdb->query('DROP table IF EXISTS wp_tagembed_menus'); |
| 1535 | } |
| 1536 | /* --End-- Manage Database */ |
| 1537 | |
| 1538 | /* --Start-- Manage Active Deactive And Uninstall Webhook */ |
| 1539 | register_activation_hook(__FILE__, '___tagembed__pluginActivate'); |
| 1540 | function ___tagembed__pluginActivate() |
| 1541 | { |
| 1542 | ___tagembed__createDatabaseTableForPlugin(); |
| 1543 | add_action('activated_plugin', '___tagembed__plginActivationRedirect'); |
| 1544 | } |
| 1545 | register_uninstall_hook(__FILE__, '___tagembed__pluginUnistall'); |
| 1546 | function ___tagembed__pluginUnistall() |
| 1547 | { |
| 1548 | ___tagembed__dropDatabaseTablesForPlugin(); |
| 1549 | global $wpdb; |
| 1550 | $wpdb->query('DROP table IF EXISTS wp_tagembed_active_options'); |
| 1551 | $wpdb->query('DROP table IF EXISTS wp_tagembed_user'); |
| 1552 | } |
| 1553 | /* --End-- Manage Active Deactive And Uninstall Webhook */ |
| 1554 | |
| 1555 | /* --Start--Manage Redirect After Plugin Activate */ |
| 1556 | function ___tagembed__plginActivationRedirect() |
| 1557 | { |
| 1558 | $__tagembed__activeUserData = wp_get_current_user(); |
| 1559 | if (empty($__tagembed__activeUserData->roles)) : |
| 1560 | return false; |
| 1561 | endif; |
| 1562 | $__tagembed__pluginCallbackUrl = esc_url(TAGEMBED_PLUGIN_CALL_BACK_URL); |
| 1563 | wp_safe_redirect($__tagembed__pluginCallbackUrl); |
| 1564 | exit; |
| 1565 | } |
| 1566 | /* --End--Manage Redirect After Plugin Activate */ |
| 1567 | |
| 1568 | /* --Start--Manage Setting Link */ |
| 1569 | function ___tagembed__settingsLink($links) |
| 1570 | { |
| 1571 | array_unshift($links, '<a href=' . TAGEMBED_PLUGIN_CALL_BACK_URL . '>Settings</a>'); |
| 1572 | return $links; |
| 1573 | } |
| 1574 | add_filter('plugin_action_links_' . plugin_basename(__FILE__), '___tagembed__settingsLink'); |
| 1575 | /* --End--Manage Setting Link */ |
| 1576 | |
| 1577 | /* --Start--Manage Database On Plugin Update Time */ |
| 1578 | function ___tagembed__manageDatabaseOnPluginUpdateTime() |
| 1579 | { |
| 1580 | ___tagembed__dropDatabaseTablesForPlugin(); |
| 1581 | ___tagembed__createDatabaseTableForPlugin(); |
| 1582 | } |
| 1583 | add_action('upgrader_process_complete', '___tagembed__manageDatabaseOnPluginUpdateTime', 10, 2); |
| 1584 | /* --End--Manage Database On Plugin Update Time */ |
| 1585 | |
| 1586 | /* --Sart--Get And Manage Social Accout Id */ |
| 1587 | function ___tagembed__get_user_social_account_id() |
| 1588 | { |
| 1589 | $__tagembed__user_details = ___tagembed__user(); |
| 1590 | $param['userId'] = $__tagembed__user_details->userId; |
| 1591 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getsocialaccountid', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1592 | if (!empty($response->head->status)) : |
| 1593 | if (!empty($response->body->userId)) : |
| 1594 | return $response->body->userId; |
| 1595 | endif; |
| 1596 | endif; |
| 1597 | return false; |
| 1598 | } |
| 1599 | /* --End--Get And Manage Social Accout Id */ |
| 1600 | |
| 1601 | /* --Start-- Show Admin General Notification After Login And Register */ |
| 1602 | function ___tagembed__generalAdminNotice() |
| 1603 | { |
| 1604 | $__tagmebed__page_name = ''; |
| 1605 | if (!empty($_GET['page'])) : |
| 1606 | $__tagmebed__page_name = ___tagembed__sanitizeRequestData($_GET); |
| 1607 | $__tagmebed__page_name = $__tagmebed__page_name['page']; |
| 1608 | endif; |
| 1609 | $response = ___tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/notification', ['callBy' => 'wordpress'], []); |
| 1610 | if (!is_wp_error($response)) : |
| 1611 | if (!empty($response->head->status) && !empty($response->body)) : |
| 1612 | $response = $response->body; |
| 1613 | if (!empty($response->notifications) && is_array($response->notifications)) : |
| 1614 | $htmlData = ''; |
| 1615 | foreach ($response->notifications as $notifications) : |
| 1616 | if ('tagembed' == $notifications->location || 'inner' == $notifications->location) : |
| 1617 | if ('tagembed' != $__tagmebed__page_name) : |
| 1618 | continue; |
| 1619 | endif; |
| 1620 | $htmlData .= '<div class=\'notice notice-' . esc_attr($notifications->type) . ' is-dismissible\'>'; |
| 1621 | $htmlData .= '<p>' . $notifications->message . '</p>'; |
| 1622 | $htmlData .= '</div>'; |
| 1623 | elseif ('all' == $notifications->location) : |
| 1624 | $htmlData .= '<div class=\'notice notice-' . esc_attr($notifications->type) . ' is-dismissible\'>'; |
| 1625 | $htmlData .= '<p>' . $notifications->message . '</p>'; |
| 1626 | $htmlData .= '</div>'; |
| 1627 | endif; |
| 1628 | endforeach; |
| 1629 | echo wp_kses_post($htmlData); |
| 1630 | endif; |
| 1631 | endif; |
| 1632 | endif; |
| 1633 | } |
| 1634 | add_action('in_admin_header', '___tagembed__hideGeneralAdminNotice'); |
| 1635 | function ___tagembed__hideGeneralAdminNotice() |
| 1636 | { |
| 1637 | $__tagmebed__page_name = ''; |
| 1638 | if (!empty($_GET['page'])) : |
| 1639 | $__tagmebed__page_name = ___tagembed__sanitizeRequestData($_GET); |
| 1640 | $__tagmebed__page_name = $__tagmebed__page_name['page']; |
| 1641 | endif; |
| 1642 | if ('tagembed' == $__tagmebed__page_name) : |
| 1643 | remove_all_actions('admin_notices'); |
| 1644 | remove_all_actions('all_admin_notices'); |
| 1645 | endif; |
| 1646 | if (!empty(___tagembed__user())) : |
| 1647 | add_action('admin_notices', '___tagembed__generalAdminNotice'); |
| 1648 | endif; |
| 1649 | } |
| 1650 | /* --End-- Show Admin General Notification After Login And Register */ |
| 1651 | /* --End-- Drop Database Table */ |
| 1652 | |
| 1653 | /* --Start-- Create Short Code */ |
| 1654 | function ___tagembed__PluginShortCode($__tagembed__shortCodeAttr) |
| 1655 | { |
| 1656 | $__tagembed__shortCodeDefaultAttr = ['width' => '', 'height' => '', 1 => '']; |
| 1657 | $__tagembed__shortCodeAttr = shortcode_atts($__tagembed__shortCodeDefaultAttr, $__tagembed__shortCodeAttr, 'tagembed'); |
| 1658 | $width = isset($__tagembed__shortCodeAttr['width']) ? sanitize_text_field($__tagembed__shortCodeAttr['width']) : ''; |
| 1659 | $height = isset($__tagembed__shortCodeAttr['height']) ? sanitize_text_field($__tagembed__shortCodeAttr['height']) : ''; |
| 1660 | $widgetId = isset($__tagembed__shortCodeAttr[1]) ? sanitize_text_field($__tagembed__shortCodeAttr[1]) : ''; |
| 1661 | if (!empty($widgetId) && is_numeric($widgetId) && (('' === $width || preg_match('/^\d+(px|%|)$/', $width)) && ('' === $height || preg_match('/^\d+(px|%|)$/', $height)))) : |
| 1662 | $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>'; |
| 1663 | else : |
| 1664 | $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>'; |
| 1665 | endif; |
| 1666 | return $output; |
| 1667 | } |
| 1668 | add_shortcode('tagembed', '___tagembed__PluginShortCode'); |
| 1669 | /* --End-- Create Short Code */ |
| 1670 |