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