| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Tagembed Widget |
| 4 |
* Plugin URI: https://tagembed.com/ |
| 5 |
* Description: Display Facebook feed, Instagram feed, Twitter feed, YouTube Videos and more social feeds from 15+ social networks on any page, posts or widgets using shortcode. Beautifully clean, customizable, and responsive Social Media Feed Widget Plugin for WordPress. |
| 6 |
* Version: 5.2 |
| 7 |
* Author: Tagembed |
| 8 |
* Author URI: https://tagembed.com/ |
| 9 |
*/ |
| 10 |
if (!defined('WPINC')) |
| 11 |
die; |
| 12 |
/* --Start-- Create Constant */ |
| 13 |
!defined('TAGEMBED_PLUGIN_VERSION') && define('TAGEMBED_PLUGIN_VERSION', '5.2'); |
| 14 |
!defined('TAGEMBED_PLUGIN_DIR_PATH') && define('TAGEMBED_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__)); |
| 15 |
!defined('TAGEMBED_PLUGIN_URL') && define('TAGEMBED_PLUGIN_URL', plugin_dir_url(__FILE__)); |
| 16 |
!defined('TAGEMBED_PLUGIN_REDIRECT_URL') && define('TAGEMBED_PLUGIN_REDIRECT_URL', get_admin_url(null, 'admin.php?page=')); |
| 17 |
!defined('TAGEMBED_PLUGIN_API_URL') && define('TAGEMBED_PLUGIN_API_URL', "https://api.tagembed.com/app/"); |
| 18 |
!defined('TAGEMBED_PLUGIN_SERVER_URL') && define('TAGEMBED_PLUGIN_SERVER_URL', "https://api.tagembed.com/app/"); |
| 19 |
!defined('TAGEMBED_PLUGIN_REACT_URL') && define('TAGEMBED_PLUGIN_REACT_URL', "https://widget.tagembed.com/"); |
| 20 |
!defined('TAGEMBED_PLUGIN_CALL_BACK_URL') && define('TAGEMBED_PLUGIN_CALL_BACK_URL', admin_url() . "admin.php?page=tagembed"); |
| 21 |
/* --End-- Create Constant */ |
| 22 |
/* --Start--Include Files */ |
| 23 |
include_once TAGEMBED_PLUGIN_DIR_PATH . "helper/helper.php"; |
| 24 |
/* --End--Include Files */ |
| 25 |
/* --Start-- Add Js And Css */ |
| 26 |
function tagembed_plugin_scripts_css() { |
| 27 |
wp_enqueue_script('__tagembed__embbedJs', TAGEMBED_PLUGIN_REACT_URL . 'embed.min.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); |
| 28 |
if (is_admin()): |
| 29 |
/* CSS */ |
| 30 |
wp_enqueue_style('__tagembed__commonCss', TAGEMBED_PLUGIN_URL . '/assets/css/common.css', '', TAGEMBED_PLUGIN_VERSION); |
| 31 |
wp_enqueue_style('__tagembed__toastCss', TAGEMBED_PLUGIN_URL . '/assets/css/toast.css', '', TAGEMBED_PLUGIN_VERSION); |
| 32 |
wp_enqueue_style('__tagembed__confirmDialogCss', TAGEMBED_PLUGIN_URL . '/assets/css/confirm_dialog.css', '', TAGEMBED_PLUGIN_VERSION); |
| 33 |
wp_enqueue_style('__tagembed__tagembedloaderCss', TAGEMBED_PLUGIN_URL . '/assets/css/loader.css', '', TAGEMBED_PLUGIN_VERSION); |
| 34 |
wp_enqueue_style('__tagembed__popupCss', TAGEMBED_PLUGIN_URL . '/assets/css/styles.css', '', TAGEMBED_PLUGIN_VERSION); |
| 35 |
wp_enqueue_style('__tagembed__editorCss', TAGEMBED_PLUGIN_URL . '/assets/css/editor/editor.css', '', TAGEMBED_PLUGIN_VERSION); |
| 36 |
/* JS */ |
| 37 |
wp_enqueue_script('__tagembed__faJs', TAGEMBED_PLUGIN_URL . '/assets/js/fa.js', ['jquery'], TAGEMBED_PLUGIN_VERSION); |
| 38 |
wp_enqueue_script('__tagembed__toastJs', TAGEMBED_PLUGIN_URL . '/assets/js/toast.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); |
| 39 |
wp_enqueue_script('__tagembed__confirmDialogJs', TAGEMBED_PLUGIN_URL . '/assets/js/confirm_dialog.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); |
| 40 |
wp_enqueue_script('__tagembed__tagemedLoaderJs', TAGEMBED_PLUGIN_URL . '/assets/js/loader.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); |
| 41 |
wp_enqueue_script('__tagembed__deactive-js', TAGEMBED_PLUGIN_URL . '/assets/js/tagembed.deactive.js', ['jquery'], TAGEMBED_PLUGIN_VERSION, true); |
| 42 |
$__tagembed__ajax_call_security_nones = wp_create_nonce('__tagembed__ajax_call_security_nones'); |
| 43 |
wp_localize_script('__tagembed__deactive-js', '__tagembed__ajax_call_security_nones_object', ['__tagembed__ajax_call_security_nones' => $__tagembed__ajax_call_security_nones]); |
| 44 |
wp_enqueue_script('__tagembed__tagembedDialogFormJs', TAGEMBED_PLUGIN_URL . '/assets/js/dialog.form.js', ["jquery"], TAGEMBED_PLUGIN_VERSION, true); |
| 45 |
/* --Start-- Gutenberge */ |
| 46 |
if (!function_exists("register_block_type")): |
| 47 |
return; |
| 48 |
else: |
| 49 |
wp_register_script("__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); |
| 50 |
register_block_type("tagembed-block/tagembed", ["editor_script" => "__editor-js", "editor_style" => "__editor-css", "style" => "__editor-style-css"]); |
| 51 |
endif; |
| 52 |
/* --End-- Gutenberge */ |
| 53 |
endif; |
| 54 |
} |
| 55 |
add_action("init", "tagembed_plugin_scripts_css"); |
| 56 |
add_filter('script_loader_tag', function ($tag, $handle) { |
| 57 |
if ('embbedJs' !== $handle) |
| 58 |
return $tag; |
| 59 |
return str_replace(' src', ' defer src', $tag); |
| 60 |
}, 10, 2); |
| 61 |
/* --End-- Add Js And Css */ |
| 62 |
/* --Start-- Add Menus */ |
| 63 |
function __tagembed__plugin_menus() { |
| 64 |
ob_start(); |
| 65 |
?> |
| 66 |
<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"> |
| 67 |
<title>Tagembed Icon</title> |
| 68 |
<g transform="translate(-211 -31)"><g id="Group_3576" transform="translate(211 31)"> |
| 69 |
<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"/> |
| 70 |
<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"/> |
| 71 |
<g id="Group_3575" transform="translate(16.61 16.942)"><g><g><defs><polygon id="SVGID_1_" points="113.1,97 101.1,148.7 147.3,148.7 158.1,103.6"/></defs><clipPath id="SVGID_2_"><use xlink:href="#SVGID_1_" style="overflow:visible;"/></clipPath><g id="Group_3574" class="st2" clip-path="url(#SVGID_2_)"><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"/></g></g></g></g></g></g></svg> |
| 72 |
<?php |
| 73 |
$svg = ob_get_clean(); |
| 74 |
add_menu_page('Tagembed', 'Tagembed', 'manage_options', 'tagembed', '__tagembed__view', 'data:image/svg+xml;base64,' . base64_encode($svg)); |
| 75 |
} |
| 76 |
add_action("admin_menu", '__tagembed__plugin_menus'); |
| 77 |
/* --End-- Add Menus */ |
| 78 |
|
| 79 |
/* --Start-- Add & Manage Views */ |
| 80 |
function __tagembed__view() { |
| 81 |
if (!empty(__tagembed__user()->isLogin) && __tagembed__user()->isLogin == 'yes'): |
| 82 |
/* Remove This */ /* $__tagembed__menus = __tagembed__menus(['__tagembed__menu_condation' => 'STATUS = 1']); */ |
| 83 |
$__tagembed__menus = __tagembed__menus(['__tagembed__menu_condation' => 1]); |
| 84 |
if (empty($__tagembed__menus)): |
| 85 |
include_once TAGEMBED_PLUGIN_DIR_PATH . "views/widget/widgetView.php"; |
| 86 |
else: |
| 87 |
include_once TAGEMBED_PLUGIN_DIR_PATH . "views/" . $__tagembed__menus[0]->path . ".php"; |
| 88 |
endif; |
| 89 |
else: |
| 90 |
include_once TAGEMBED_PLUGIN_DIR_PATH . "views/account/accountView.php"; |
| 91 |
endif; |
| 92 |
} |
| 93 |
/* --End-- Add & Manage Views */ |
| 94 |
/* --Start-- Manage Ajax Calls */ |
| 95 |
add_action("wp_ajax_data", "__tagembed__dataAjaxHandler"); |
| 96 |
function __tagembed__dataAjaxHandler() { |
| 97 |
if (empty($_REQUEST['__tagembed__ajax_action'])) |
| 98 |
return false; |
| 99 |
$data = __tagembed__sanitizeRequestData($_REQUEST); |
| 100 |
$data = (object) $data; |
| 101 |
/* --Start-- Manage Ajax call Request Security */ |
| 102 |
$__tagembed__ajaxCallSecurityNones = isset($data->__tagembed__ajax_call_nones) ? sanitize_text_field($data->__tagembed__ajax_call_nones) : ''; |
| 103 |
if (!wp_verify_nonce($__tagembed__ajaxCallSecurityNones, "__tagembed__ajax_call_security_nones")) |
| 104 |
return __tagembed__exitWithDanger(); |
| 105 |
/* --End-- Manage Ajax call Request Security */ |
| 106 |
|
| 107 |
/* --Start__ Sanetize All Input */ |
| 108 |
foreach ($data as $key => $value): |
| 109 |
if (!in_array($key, ['emailId', 'password', 'youtubePlaylist'])) |
| 110 |
inputSanetize($value); |
| 111 |
endforeach; |
| 112 |
/* --End__ Sanetize All Input */ |
| 113 |
$param = []; |
| 114 |
global $wpdb; |
| 115 |
$action = $data->__tagembed__ajax_action; |
| 116 |
$__tagembed__user_details = __tagembed__user(); |
| 117 |
switch ($action): |
| 118 |
case "__tagembed__register": |
| 119 |
if (empty($data->emailId) || empty($data->password) || empty($data->fullName)) |
| 120 |
return __tagembed__exitWithDanger(); |
| 121 |
/* --Start-- Manage Param Data */ |
| 122 |
$param['fullName'] = sanitize_text_field($data->fullName); |
| 123 |
$param['emailId'] = sanitize_email($data->emailId); |
| 124 |
$param['password'] = $data->password; |
| 125 |
/* --End-- Manage Param Data */ |
| 126 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/register', $param, []); |
| 127 |
$response = __tagembed__manageApiResponse($response); |
| 128 |
unset($param); |
| 129 |
$param = ['userId' => sanitize_key($response->userId), 'inheritStyles' => 1]; |
| 130 |
__tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $response->accessToken]); |
| 131 |
if (__tagembed__login($response) == true) |
| 132 |
return __tagembed__exitWithSuccess(["redirectUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL]); |
| 133 |
return __tagembed__exitWithDanger(); |
| 134 |
break; |
| 135 |
case "__tagembed__login": |
| 136 |
if (empty($data->emailId) || empty($data->password)) |
| 137 |
return __tagembed__exitWithDanger(); |
| 138 |
/* --Start-- Manage Param Data */ |
| 139 |
$param['emailId'] = sanitize_email($data->emailId); |
| 140 |
$param['password'] = $data->password; |
| 141 |
/* --End-- Manage Param Data */ |
| 142 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/login', $param, []); |
| 143 |
unset($param); |
| 144 |
$response = __tagembed__manageApiResponse($response); |
| 145 |
if (__tagembed__login($response) == true) |
| 146 |
return __tagembed__exitWithSuccess(["redirectUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL]); |
| 147 |
return __tagembed__exitWithDanger(); |
| 148 |
break; |
| 149 |
case "__tagembed__logout": |
| 150 |
if (tagembed_logout()) |
| 151 |
__tagembed__exitWithSuccess(["redirectUrl" => TAGEMBED_PLUGIN_REDIRECT_URL . 'tagembed']); |
| 152 |
return __tagembed__exitWithDanger(); |
| 153 |
break; |
| 154 |
case "__tagembed__get_account_details": |
| 155 |
$data->auth = !empty($data->auth) ? 1 : 0; |
| 156 |
if (empty($__tagembed__user_details)) |
| 157 |
return __tagembed__exitWithDanger(); |
| 158 |
/* --Start-- Manage Param Data */ |
| 159 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 160 |
/* --End-- Manage Param Data */ |
| 161 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getdetails', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 162 |
unset($param); |
| 163 |
$response = __tagembed__manageApiResponse($response); |
| 164 |
return __tagembed__exitWithSuccess($response); |
| 165 |
break; |
| 166 |
case "__tagembed__manage_active_widget": |
| 167 |
if (empty($data->widgetId)) |
| 168 |
return __tagembed__exitWithDanger(); |
| 169 |
if (__tagembed__manageActiveWidget($data->widgetId)) |
| 170 |
__tagembed__exitWithSuccess(); |
| 171 |
return __tagembed__exitWithDanger(); |
| 172 |
break; |
| 173 |
case "__tagembed__menue": |
| 174 |
if (empty($data->menueId)) |
| 175 |
return __tagembed__exitWithDanger(); |
| 176 |
if (__tagembed__menus(['__tagembed__menu_id' => $data->menueId])) |
| 177 |
__tagembed__exitWithSuccess(["redirectUrl" => TAGEMBED_PLUGIN_REDIRECT_URL . 'tagembed']); |
| 178 |
return __tagembed__exitWithDanger(); |
| 179 |
break; |
| 180 |
case "__tagembed__create_widget": |
| 181 |
if (empty($__tagembed__user_details) || empty($data->name)) |
| 182 |
return __tagembed__exitWithDanger("Validation Error", ['name' => 'Widget name is required']); |
| 183 |
$data->profanity = (isset($data->profanity)) ? 0 : 1; |
| 184 |
/* --Start-- Manage Param Data */ |
| 185 |
$param['name'] = sanitize_text_field($data->name); |
| 186 |
$param['profanity'] = sanitize_key($data->profanity); |
| 187 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 188 |
$param['inheritStyles'] = 1; |
| 189 |
/* --End-- Manage Param Data */ |
| 190 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/create', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 191 |
unset($param); |
| 192 |
$response = __tagembed__manageApiResponse($response); |
| 193 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 194 |
return __tagembed__exitWithSuccess(["message" => $response, "redirectUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL]); |
| 195 |
break; |
| 196 |
case "__tagembed__edit_widget": |
| 197 |
if (empty($__tagembed__user_details) || empty($data->name) || empty($data->widgetId)) |
| 198 |
return __tagembed__exitWithDanger("Validation Error", ['name' => 'Widget name is required']); |
| 199 |
/* --Start-- Manage Param Data */ |
| 200 |
$param['name'] = sanitize_text_field($data->name); |
| 201 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 202 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 203 |
/* --End-- Manage Param Data */ |
| 204 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/edit', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 205 |
unset($param); |
| 206 |
$response = __tagembed__manageApiResponse($response); |
| 207 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 208 |
return __tagembed__exitWithSuccess(["message" => $response, "redirectUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL]); |
| 209 |
break; |
| 210 |
case "__tagembed__update_widget_status": |
| 211 |
if (empty($__tagembed__user_details) || empty($data->widgetId)) |
| 212 |
return __tagembed__exitWithDanger(); |
| 213 |
/* --Start-- Manage Param Data */ |
| 214 |
$param['status'] = sanitize_key($data->status); |
| 215 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 216 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 217 |
/* --End-- Manage Param Data */ |
| 218 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 219 |
unset($param); |
| 220 |
$response = __tagembed__manageApiResponse($response); |
| 221 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 222 |
return __tagembed__exitWithSuccess(["message" => $response]); |
| 223 |
break; |
| 224 |
case "__tagembed__delete_widget": |
| 225 |
if (empty($__tagembed__user_details) || empty($data->widgetId)) |
| 226 |
return __tagembed__exitWithDanger(); |
| 227 |
/* --Start-- Manage Param Data */ |
| 228 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 229 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 230 |
/* --End-- Manage Param Data */ |
| 231 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 232 |
unset($param); |
| 233 |
$response = __tagembed__manageApiResponse($response); |
| 234 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 235 |
return __tagembed__exitWithSuccess(["message" => $response]); |
| 236 |
break; |
| 237 |
case "__tagembed__source_networks": |
| 238 |
$data->auth = !empty($data->auth) ? 1 : 0; |
| 239 |
if (empty($__tagembed__user_details)) |
| 240 |
return __tagembed__exitWithDanger(); |
| 241 |
/* --Start-- Manage Param Data */ |
| 242 |
$param['auth'] = sanitize_key($data->auth); |
| 243 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 244 |
/* --End-- Manage Param Data */ |
| 245 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apinetwork/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 246 |
unset($param); |
| 247 |
$response = __tagembed__manageApiResponse($response); |
| 248 |
return __tagembed__exitWithSuccess($response); |
| 249 |
break; |
| 250 |
case "__tagembed__get_themes": |
| 251 |
if (empty($__tagembed__user_details) || empty($data->widgetId)) |
| 252 |
return __tagembed__exitWithDanger(); |
| 253 |
/* --Start-- Manage Param Data */ |
| 254 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 255 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 256 |
/* --End-- Manage Param Data */ |
| 257 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'Apitheme/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 258 |
unset($param); |
| 259 |
$response = __tagembed__manageApiResponse($response); |
| 260 |
return __tagembed__exitWithSuccess($response); |
| 261 |
break; |
| 262 |
case "__tagembed__edit_themes": |
| 263 |
if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->themeId)) |
| 264 |
return __tagembed__exitWithDanger(); |
| 265 |
/* --Start-- Manage Param Data */ |
| 266 |
$param['themeId'] = sanitize_key($data->themeId); |
| 267 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 268 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 269 |
/* --End-- Manage Param Data */ |
| 270 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'Apitheme/edit', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 271 |
unset($param); |
| 272 |
$response = __tagembed__manageApiResponse($response); |
| 273 |
return __tagembed__exitWithSuccess($response); |
| 274 |
break; |
| 275 |
case "__tagembed__get_network_filter": |
| 276 |
if (empty($__tagembed__user_details) || empty($data->networkId)) |
| 277 |
return __tagembed__exitWithDanger(); |
| 278 |
/* --Start-- Manage Param Data */ |
| 279 |
$param['networkId'] = sanitize_key($data->networkId); |
| 280 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 281 |
/* --End-- Manage Param Data */ |
| 282 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apinetwork/filter', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 283 |
unset($param); |
| 284 |
$response = __tagembed__manageApiResponse($response); |
| 285 |
return __tagembed__exitWithSuccess($response); |
| 286 |
break; |
| 287 |
case "__tagembed__get_already_exist_accounts": |
| 288 |
if (empty($__tagembed__user_details)) |
| 289 |
return __tagembed__exitWithDanger(); |
| 290 |
/* --Start-- Manage Param Data */ |
| 291 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 292 |
/* --End-- Manage Param Data */ |
| 293 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/getalreadyexistaccounts', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 294 |
unset($param); |
| 295 |
$response = __tagembed__manageApiResponse($response); |
| 296 |
return __tagembed__exitWithSuccess($response); |
| 297 |
break; |
| 298 |
case "__tagembed__add_or_update_account": |
| 299 |
if (empty($__tagembed__user_details) || empty($data->networkId) || empty($data->type)) |
| 300 |
return __tagembed__exitWithDanger(); |
| 301 |
/* --Start-- Manage Param Data */ |
| 302 |
$param['connectedAccountId'] = $data->connectedAccountId; |
| 303 |
$param['feedId'] = sanitize_key($data->feedId); |
| 304 |
$param['type'] = sanitize_text_field($data->type); |
| 305 |
$param['networkId'] = sanitize_key($data->networkId); |
| 306 |
$param['filterId'] = sanitize_key($data->filterId); |
| 307 |
$param['otherData'] = $data->otherData; |
| 308 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 309 |
/* --End-- Manage Param Data */ |
| 310 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/addorupdate', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 311 |
unset($param); |
| 312 |
$response = __tagembed__manageApiResponse($response); |
| 313 |
return __tagembed__exitWithSuccess(["__tagembed__requestCallBackUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL, "redirectUrl" => TAGEMBED_PLUGIN_API_URL . "apiauth/getauth", "__tagembed__feedData" => $response->__tagembed__feedData]); |
| 314 |
break; |
| 315 |
case "__tagembed__delete_account": |
| 316 |
if (empty($__tagembed__user_details) || empty($data->networkId) || empty($data->parentId)) |
| 317 |
return __tagembed__exitWithDanger(); |
| 318 |
/* --Start-- Manage Param Data */ |
| 319 |
$param['parentId'] = sanitize_key($data->parentId); |
| 320 |
$param['networkId'] = sanitize_key($data->networkId); |
| 321 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 322 |
/* --End-- Manage Param Data */ |
| 323 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 324 |
unset($param); |
| 325 |
$response = __tagembed__manageApiResponse($response); |
| 326 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 327 |
return __tagembed__exitWithSuccess(["message" => $response]); |
| 328 |
break; |
| 329 |
case "__tagembed__get_already_exist_auth": |
| 330 |
if (empty($__tagembed__user_details) || empty($data->networkId)) |
| 331 |
return __tagembed__exitWithDanger(); |
| 332 |
/* --Start-- Manage Param Data */ |
| 333 |
$param['networkId'] = sanitize_key($data->networkId); |
| 334 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 335 |
/* --End-- Manage Param Data */ |
| 336 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 337 |
unset($param); |
| 338 |
$response = __tagembed__manageApiResponse($response); |
| 339 |
return __tagembed__exitWithSuccess($response); |
| 340 |
break; |
| 341 |
case "__tagembed__search_google_location": |
| 342 |
if (empty($__tagembed__user_details) || empty($data->googleLocationName)) |
| 343 |
return __tagembed__exitWithDanger(); |
| 344 |
/* --Start-- Manage Param Data */ |
| 345 |
$param['googleLocationName'] = $data->googleLocationName; |
| 346 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 347 |
/* --End-- Manage Param Data */ |
| 348 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchgooglelocation', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 349 |
unset($param); |
| 350 |
$response = __tagembed__manageApiResponse($response); |
| 351 |
return __tagembed__exitWithSuccess($response); |
| 352 |
break; |
| 353 |
case "__tagembed__search_vk_communities": |
| 354 |
if (empty($__tagembed__user_details) || empty($data->vkCommunitiesName)) |
| 355 |
return __tagembed__exitWithDanger(); |
| 356 |
/* --Start-- Manage Param Data */ |
| 357 |
$param['vkCommunitiesName'] = $data->vkCommunitiesName; |
| 358 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 359 |
/* --End-- Manage Param Data */ |
| 360 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchVkCommunities', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 361 |
unset($param); |
| 362 |
$response = __tagembed__manageApiResponse($response); |
| 363 |
return __tagembed__exitWithSuccess($response); |
| 364 |
break; |
| 365 |
case "__tagembed__search_facebook_page": |
| 366 |
if (empty($data->facebookPageData)) |
| 367 |
return __tagembed__exitWithDanger(); |
| 368 |
/* --Start-- Manage Param Data */ |
| 369 |
$param['facebookPageData'] = $data->facebookPageData; |
| 370 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 371 |
/* --End-- Manage Param Data */ |
| 372 |
/* --Start-- Call And Manage Api Call */ |
| 373 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchfacebookpage', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 374 |
unset($param); |
| 375 |
$response = __tagembed__manageApiResponse($response); |
| 376 |
return __tagembed__exitWithSuccess($response); |
| 377 |
break; |
| 378 |
case "__tagembed__get_facebook_page_albums": |
| 379 |
if (empty($__tagembed__user_details) || empty($data->connectedAccountsId)) |
| 380 |
return __tagembed__exitWithDanger(); |
| 381 |
/* --Start-- Manage Param Data */ |
| 382 |
$param['connectedAccountsId'] = sanitize_key($data->connectedAccountsId); |
| 383 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 384 |
/* --End-- Manage Param Data */ |
| 385 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiauth/apiauthfacebookpagealbums', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 386 |
unset($param); |
| 387 |
$response = __tagembed__manageApiResponse($response); |
| 388 |
return __tagembed__exitWithSuccess($response); |
| 389 |
break; |
| 390 |
case "__tagembed__search_youtube_channel": |
| 391 |
if (empty($__tagembed__user_details) || empty($data->youtubeChannelData)) |
| 392 |
return __tagembed__exitWithDanger(); |
| 393 |
/* --Start-- Manage Param Data */ |
| 394 |
$param['youtubeChannelData'] = $data->youtubeChannelData; |
| 395 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 396 |
/* --End-- Manage Param Data */ |
| 397 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/searchyoutubechannel', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 398 |
unset($param); |
| 399 |
$response = __tagembed__manageApiResponse($response); |
| 400 |
return __tagembed__exitWithSuccess($response); |
| 401 |
break; |
| 402 |
case "__tagembed__get_youtube_playlist": |
| 403 |
if (empty($__tagembed__user_details) || empty($data->youtubeId)) |
| 404 |
return __tagembed__exitWithDanger(); |
| 405 |
/* --Start-- Manage Param Data */ |
| 406 |
$param['youtubeId'] = $data->youtubeId; |
| 407 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 408 |
/* --End-- Manage Param Data */ |
| 409 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getyoutubeplaylist', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 410 |
unset($param); |
| 411 |
$response = __tagembed__manageApiResponse($response); |
| 412 |
return __tagembed__exitWithSuccess($response); |
| 413 |
break; |
| 414 |
case "__tagembed__get_slack_channel_list": |
| 415 |
if (empty($data->connectedAccountsId)) |
| 416 |
return __tagembed__exitWithDanger(); |
| 417 |
/* --Start-- Manage Param Data */ |
| 418 |
$param['connectedAccountsId'] = $data->connectedAccountsId; |
| 419 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 420 |
/* --End-- Manage Param Data */ |
| 421 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/getslackchannellist', $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_feed": |
| 427 |
if (empty($__tagembed__user_details) || empty($data->widgetId)) |
| 428 |
return __tagembed__exitWithDanger(); |
| 429 |
/* --Start-- Manage Param Data */ |
| 430 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 431 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 432 |
/* --End-- Manage Param Data */ |
| 433 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 434 |
unset($param); |
| 435 |
$response = __tagembed__manageApiResponse($response); |
| 436 |
return __tagembed__exitWithSuccess($response); |
| 437 |
break; |
| 438 |
case "__tagembed__update_feed_status": |
| 439 |
if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->feedId)) |
| 440 |
return __tagembed__exitWithDanger(); |
| 441 |
/* --Start-- Manage Param Data */ |
| 442 |
$param['feedId'] = sanitize_key($data->feedId); |
| 443 |
$param['status'] = sanitize_key($data->status); |
| 444 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 445 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 446 |
/* --End-- Manage Param Data */ |
| 447 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 448 |
unset($param); |
| 449 |
$response = __tagembed__manageApiResponse($response); |
| 450 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 451 |
return __tagembed__exitWithSuccess(["message" => $response]); |
| 452 |
break; |
| 453 |
case "__tagembed__delete_feed": |
| 454 |
if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->feedId)) |
| 455 |
return __tagembed__exitWithDanger(); |
| 456 |
/* --Start-- Manage Param Data */ |
| 457 |
$param['feedId'] = sanitize_key($data->feedId); |
| 458 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 459 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 460 |
/* --End-- Manage Param Data */ |
| 461 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/delete', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 462 |
unset($param); |
| 463 |
$response = __tagembed__manageApiResponse($response); |
| 464 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 465 |
return __tagembed__exitWithSuccess(["message" => $response]); |
| 466 |
break; |
| 467 |
case "__tagembed__create_feed": |
| 468 |
if (empty($__tagembed__user_details) || empty($data->widgetName) || empty($data->networkName) || empty($data->filterName) || empty($data->widgetId) || empty($data->networkId) || empty($data->filterId)) |
| 469 |
return __tagembed__exitWithDanger(); |
| 470 |
$__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]; |
| 471 |
$__tagembed__feed_input_data["feed"] = !empty($data->feed) ? sanitize_text_field($data->feed) : '__tagembed__feed'; |
| 472 |
$__tagembed__feed_filter_id = $data->filterId; |
| 473 |
switch ($__tagembed__feed_input_data['networkId']): |
| 474 |
case 1: |
| 475 |
$__tagembed__feed_input_data['auth'] = 1; |
| 476 |
$__tagembed__feed_input_data['multiplePhoto'] = sanitize_key(isset($data->multiplePhoto) ? 1 : 0); |
| 477 |
$__tagembed__feed_input_data['excludeRetweet'] = sanitize_key(isset($data->excludeRetweet) ? 1 : 0); |
| 478 |
if (!empty($data->list)) |
| 479 |
$__tagembed__feed_input_data['list'] = sanitize_key($data->list); |
| 480 |
break; |
| 481 |
case 2: |
| 482 |
$__tagembed__feed_input_data['auth'] = 1; |
| 483 |
break; |
| 484 |
case 3: |
| 485 |
$__tagembed__feed_input_data['auth'] = 1; |
| 486 |
switch ($__tagembed__feed_filter_id): |
| 487 |
case 65: |
| 488 |
$__tagembed__feed_input_data['accountAlbumType'] = sanitize_key(isset($data->accountAlbumType) ? $data->accountAlbumType : ""); |
| 489 |
$__tagembed__feed_input_data['accountAlbumData'] = sanitize_text_field(isset($data->accountAlbumData) ? $data->accountAlbumData : ""); |
| 490 |
break; |
| 491 |
endswitch; |
| 492 |
break; |
| 493 |
case 4: |
| 494 |
if ($__tagembed__feed_filter_id == 29): |
| 495 |
$__tagembed__feed_input_data['auth'] = 1; |
| 496 |
else: |
| 497 |
$__tagembed__feed_input_data['placeId'] = $data->placeId; |
| 498 |
$__tagembed__feed_input_data['placeName'] = $data->placeName; |
| 499 |
endif; |
| 500 |
break; |
| 501 |
case 5: |
| 502 |
switch ($__tagembed__feed_filter_id): |
| 503 |
case 1: |
| 504 |
case 72: |
| 505 |
break; |
| 506 |
case 12: |
| 507 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 508 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 509 |
$pintrestHeaders = explode("/", parse_url($data->feed)['path']); |
| 510 |
$__tagembed__feed_input_data['value1'] = strtolower($pintrestHeaders[1]); |
| 511 |
$__tagembed__feed_input_data['value2'] = strtolower($pintrestHeaders[2]); |
| 512 |
break; |
| 513 |
endswitch; |
| 514 |
break; |
| 515 |
case 6: |
| 516 |
switch ($__tagembed__feed_filter_id): |
| 517 |
case 1: |
| 518 |
case 2: |
| 519 |
$__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; |
| 520 |
break; |
| 521 |
endswitch; |
| 522 |
break; |
| 523 |
case 7: |
| 524 |
if (in_array($__tagembed__feed_filter_id, [1, 71])): |
| 525 |
$isUrl = false; |
| 526 |
if (preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 527 |
$isUrl = true; |
| 528 |
if ((empty($data->youtubeId) || empty($data->youtubeName)) && !$isUrl) |
| 529 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid Channel URL Or Tab On Search Icon"]); |
| 530 |
if ($isUrl): |
| 531 |
$data->youtubeId = explode('/', $data->feed); |
| 532 |
$data->youtubeId = $data->youtubeId[4]; |
| 533 |
$data->youtubeName = "youtube"; |
| 534 |
if (empty($data->youtubeId) || empty($data->youtubeName)) |
| 535 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid Channel URL"]); |
| 536 |
endif; |
| 537 |
endif; |
| 538 |
switch ($__tagembed__feed_filter_id): |
| 539 |
case 1: |
| 540 |
case 71: |
| 541 |
$__tagembed__feed_input_data['youtubeId'] = $data->youtubeId; |
| 542 |
$__tagembed__feed_input_data['youtubeName'] = $data->youtubeName; |
| 543 |
break; |
| 544 |
case 11: |
| 545 |
if (empty($data->youtubePlaylist) && empty($data->youtubeId)): |
| 546 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid Channel URL Or Tab On Search Icon"]); |
| 547 |
elseif (empty($data->youtubePlaylist) && !empty($data->youtubeId)): |
| 548 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Play List Not Found"]); |
| 549 |
endif; |
| 550 |
$data->youtubePlaylist = explode("#", $data->youtubePlaylist); |
| 551 |
$__tagembed__feed_input_data['youtubeId'] = $data->youtubePlaylist[0]; |
| 552 |
$__tagembed__feed_input_data['youtubeName'] = $data->youtubePlaylist[1]; |
| 553 |
$__tagembed__feed_input_data['feed'] = $data->youtubePlaylist[1]; |
| 554 |
unset($data->youtubePlaylist); |
| 555 |
break; |
| 556 |
endswitch; |
| 557 |
break; |
| 558 |
case 8: |
| 559 |
switch ($__tagembed__feed_filter_id): |
| 560 |
case 1: |
| 561 |
case 2: |
| 562 |
$__tagembed__feed_input_data['auth'] = 1; |
| 563 |
break; |
| 564 |
endswitch; |
| 565 |
break; |
| 566 |
case 10: |
| 567 |
if (in_array($__tagembed__feed_filter_id, [1, 16, 17])): |
| 568 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 569 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 570 |
endif; |
| 571 |
switch ($__tagembed__feed_filter_id): |
| 572 |
case 16: |
| 573 |
$postUrl = parse_url($data->feed); |
| 574 |
if (!strstr($postUrl['host'], 'linkedin')) |
| 575 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Linkedin Post Url"]); |
| 576 |
$postUrl = $data->feed; |
| 577 |
$postUrl = rtrim($postUrl, '/'); |
| 578 |
preg_match("/[^\/]+$/", $postUrl, $postId); |
| 579 |
$postId = $postId[0]; |
| 580 |
$postId = (explode("?", $postId)[0]); |
| 581 |
$value1 = 'LinkedIn'; |
| 582 |
if (stripos($postId, "activity") !== false): |
| 583 |
$postId = (explode("activity", $postId)[1]); |
| 584 |
$value2 = "activity"; |
| 585 |
elseif (stripos($postId, "ugcPost") !== false): |
| 586 |
$postId = (explode("ugcPost", $postId)[1]); |
| 587 |
$value2 = "ugcPost"; |
| 588 |
else: |
| 589 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Linkedin Post Url"]); |
| 590 |
endif; |
| 591 |
preg_match_all('!\d+!', $postId, $postId); |
| 592 |
if (isset($postId[0][0]) && empty($postId[0][0])) |
| 593 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Linkedin Post Url"]); |
| 594 |
$value3 = $postId[0][0]; |
| 595 |
if (empty($value1) || empty($value2) || empty($value3)) |
| 596 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Linkedin Post Url"]); |
| 597 |
$__tagembed__feed_input_data['value1'] = $value1; |
| 598 |
$__tagembed__feed_input_data['value2'] = $value2; |
| 599 |
$__tagembed__feed_input_data['value3'] = $value3; |
| 600 |
break; |
| 601 |
case 1: |
| 602 |
case 17: |
| 603 |
$url = parse_url($data->feed); |
| 604 |
$companyPageUrl = $url['scheme'] . "://" . $url['host']; |
| 605 |
$url = explode("/", $url['path']); |
| 606 |
$companyPageUrl = $companyPageUrl . "/" . $url[1] . "/" . $url[2] . "/"; |
| 607 |
$__tagembed__feed_input_data['feed'] = $companyPageUrl; |
| 608 |
$url[2] = str_replace("-", " ", "$url[2]"); |
| 609 |
$__tagembed__feed_input_data['page'] = ucwords($url[2], " "); |
| 610 |
break; |
| 611 |
case 2: |
| 612 |
$__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; |
| 613 |
break; |
| 614 |
endswitch; |
| 615 |
break; |
| 616 |
case 11: |
| 617 |
switch ($__tagembed__feed_filter_id): |
| 618 |
case 1: |
| 619 |
case 2: |
| 620 |
$__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; |
| 621 |
break; |
| 622 |
endswitch; |
| 623 |
break; |
| 624 |
case 12: |
| 625 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 626 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 627 |
$__tagembed__feed_input_data['name'] = $data->name; |
| 628 |
break; |
| 629 |
case 18: |
| 630 |
switch ($__tagembed__feed_filter_id): |
| 631 |
case 23: |
| 632 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 633 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 634 |
break; |
| 635 |
case 26: |
| 636 |
$__tagembed__feed_input_data['hashtagCaption'] = sanitize_key(isset($data->hashtagCaption) ? 1 : 0); |
| 637 |
$__tagembed__feed_input_data['hashtagOlder'] = sanitize_key(isset($data->hashtagOlder) ? 1 : 0); |
| 638 |
break; |
| 639 |
endswitch; |
| 640 |
if (!in_array($__tagembed__feed_filter_id, [34])) |
| 641 |
$__tagembed__feed_input_data['auth'] = 1; |
| 642 |
break; |
| 643 |
case 19: |
| 644 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 645 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 646 |
$yelpBusinessUrl = parse_url($data->feed); |
| 647 |
if (!strstr($yelpBusinessUrl['host'], 'yelp')) |
| 648 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "'Enter Yelp Business Url"]); |
| 649 |
$__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = explode('/', $yelpBusinessUrl['path'])[2]; |
| 650 |
break; |
| 651 |
case 20: |
| 652 |
$__tagembed__feed_input_data['auth'] = 1; |
| 653 |
$slackData = isset($data->slackChannelList) ? $data->slackChannelList : ""; |
| 654 |
if (!empty($slackData)): |
| 655 |
$slackData = explode('#', $slackData); |
| 656 |
$__tagembed__feed_input_data['name'] = $slackData[1]; |
| 657 |
$__tagembed__feed_input_data['feed'] = $slackData[0]; |
| 658 |
endif; |
| 659 |
break; |
| 660 |
case 23: |
| 661 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 662 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 663 |
$airbnbListUrl = parse_url($data->feed); |
| 664 |
if (strstr($airbnbListUrl['host'], 'airbnb')): |
| 665 |
preg_match("/[^\/]+$/", $data->feed, $matches); |
| 666 |
$__tagembed__feed_input_data['listId'] = explode("?", $matches[0])[0]; |
| 667 |
else: |
| 668 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "'Enter Airbnb Url"]); |
| 669 |
endif; |
| 670 |
$__tagembed__feed_input_data['name'] = $data->name; |
| 671 |
break; |
| 672 |
case 28: |
| 673 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 674 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 675 |
$capeterraCompanyUrl = parse_url($data->feed); |
| 676 |
if (!strstr($capeterraCompanyUrl['host'], 'capterra')) |
| 677 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "'Enter Capeterra Company Url"]); |
| 678 |
$__tagembed__feed_input_data['name'] = explode("/", $capeterraCompanyUrl['path'])['3']; |
| 679 |
$__tagembed__feed_input_data['feed'] = explode("/", $capeterraCompanyUrl['path'])['2']; |
| 680 |
break; |
| 681 |
case 29: |
| 682 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 683 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 684 |
$etsyShopUrl = parse_url($data->feed); |
| 685 |
if (!strstr($etsyShopUrl['host'], 'etsy')) |
| 686 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "'Enter Etsy Shop Url"]); |
| 687 |
$__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = explode('/shop/', $etsyShopUrl['path'])[1]; |
| 688 |
break; |
| 689 |
case 31: |
| 690 |
switch ($__tagembed__feed_filter_id): |
| 691 |
case 2: |
| 692 |
$__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; |
| 693 |
break; |
| 694 |
endswitch; |
| 695 |
if (!in_array($__tagembed__feed_filter_id, [2])) |
| 696 |
$__tagembed__feed_input_data['auth'] = 1; |
| 697 |
break; |
| 698 |
case 32: |
| 699 |
switch ($__tagembed__feed_filter_id): |
| 700 |
case 2: |
| 701 |
$__tagembed__feed_input_data['feed'] = $__tagembed__feed_input_data['name'] = $data->feed; |
| 702 |
break; |
| 703 |
case 75: |
| 704 |
$__tagembed__feed_input_data['communitiesName'] = $data->communitiesName; |
| 705 |
$__tagembed__feed_input_data['communitiesId'] = $data->communitiesId; |
| 706 |
break; |
| 707 |
endswitch; |
| 708 |
if (!in_array($__tagembed__feed_filter_id, [2, 75])) |
| 709 |
$__tagembed__feed_input_data['auth'] = 1; |
| 710 |
break; |
| 711 |
case 33: |
| 712 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 713 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 714 |
preg_match("/[^\/]+$/", "$data->feed", $matches); |
| 715 |
$__tagembed__feed_input_data['name'] = $__tagembed__feed_input_data['feed'] = $matches[0]; |
| 716 |
break; |
| 717 |
case 34: |
| 718 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 719 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 720 |
$__tagembed__feed_input_data['name'] = explode('/', $data->feed)[3]; |
| 721 |
$__tagembed__feed_input_data['feed'] = $data->feed; |
| 722 |
break; |
| 723 |
case 35: |
| 724 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 725 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 726 |
$__tagembed__feed_input_data['name'] = explode('Reviews-', $data->feed)[1]; |
| 727 |
$__tagembed__feed_input_data['name'] = explode('.html', $__tagembed__feed_input_data['name'])[0]; |
| 728 |
$__tagembed__feed_input_data['feed'] = $data->feed; |
| 729 |
break; |
| 730 |
case 37: |
| 731 |
$data->feed = explode('.html', $data->feed)[0]; |
| 732 |
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $data->feed)) |
| 733 |
return __tagembed__exitWithDanger("Validation Error", ["feed" => "Enter Valid URL"]); |
| 734 |
$__tagembed__feed_input_data['name'] = $data->feed; |
| 735 |
$__tagembed__feed_input_data['feed'] = explode('item/', $data->feed)[1]; |
| 736 |
break; |
| 737 |
endswitch; |
| 738 |
unset($data); |
| 739 |
/* --Start-- Manage Api Calling */ |
| 740 |
$byApiCall = 0; |
| 741 |
if (empty($__tagembed__feed_input_data['authId'])): |
| 742 |
switch ($__tagembed__feed_input_data['networkId']): |
| 743 |
case 4: |
| 744 |
if ($__tagembed__feed_filter_id == 33): |
| 745 |
$byApiCall = 1; |
| 746 |
$__tagembed__feed_input_data['byApiCall'] = 1; |
| 747 |
endif; |
| 748 |
break; |
| 749 |
case 5: |
| 750 |
case 7: |
| 751 |
case 6: |
| 752 |
case 10: |
| 753 |
case 11: |
| 754 |
case 12: |
| 755 |
case 19: |
| 756 |
case 23: |
| 757 |
case 28: |
| 758 |
case 29: |
| 759 |
case 33: |
| 760 |
case 34: |
| 761 |
case 35: |
| 762 |
case 37: |
| 763 |
$byApiCall = 1; |
| 764 |
$__tagembed__feed_input_data['byApiCall'] = 1; |
| 765 |
break; |
| 766 |
case 31: |
| 767 |
if ($__tagembed__feed_filter_id == 2): |
| 768 |
$byApiCall = 1; |
| 769 |
$__tagembed__feed_input_data['byApiCall'] = 1; |
| 770 |
endif; |
| 771 |
break; |
| 772 |
case 32: |
| 773 |
if (in_array($__tagembed__feed_filter_id, [2, 75])): |
| 774 |
$byApiCall = 1; |
| 775 |
$__tagembed__feed_input_data['byApiCall'] = 1; |
| 776 |
endif; |
| 777 |
break; |
| 778 |
endswitch; |
| 779 |
else: |
| 780 |
$byApiCall = 1; |
| 781 |
$__tagembed__feed_input_data['byApiCall'] = 1; |
| 782 |
endif; |
| 783 |
$__tagembed__feed_input_data['appUser'] = 1; |
| 784 |
/* --End-- Manage Api Calling */ |
| 785 |
|
| 786 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifeed/create', ['feedData' => $__tagembed__feed_input_data], ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 787 |
$response = __tagembed__manageApiResponse($response); |
| 788 |
return __tagembed__exitWithSuccess(["byapiCall" => $byApiCall, "__tagembed__requestCallBackUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL, "redirectUrl" => TAGEMBED_PLUGIN_API_URL . "apiauth/getauth", "__tagembed__feedData" => $response->__tagembed__feedData]); |
| 789 |
break; |
| 790 |
case "__tagembed__make_payment": |
| 791 |
if (empty($__tagembed__user_details) || empty($data->planId) || empty($data->priceCode)) |
| 792 |
return __tagembed__exitWithDanger(); |
| 793 |
/* --Start-- Manage Param Data */ |
| 794 |
$param['planId'] = sanitize_key($data->planId); |
| 795 |
$param['priceCode'] = $data->priceCode; |
| 796 |
/* --Start-- Manage Param Data */ |
| 797 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 798 |
$param['email'] = $__tagembed__user_details->email; |
| 799 |
$param['name'] = $__tagembed__user_details->name; |
| 800 |
/* --End-- Manage Param Data */ |
| 801 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getpaymentdetails', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 802 |
unset($param); |
| 803 |
$response = __tagembed__manageApiResponse($response); |
| 804 |
return __tagembed__exitWithSuccess(["__tagembed__requestCallBackUrl" => TAGEMBED_PLUGIN_CALL_BACK_URL, "redirectUrl" => TAGEMBED_PLUGIN_API_URL . "apiaccount/makepayment", "__tagembed__paymentData" => $response->__tagembed__paymentData]); |
| 805 |
break; |
| 806 |
case "__tagembed__cancel_subscription": |
| 807 |
if (empty($__tagembed__user_details) || empty($data->planId)) |
| 808 |
return __tagembed__exitWithDanger(); |
| 809 |
/* --Start-- Manage Param Data */ |
| 810 |
$param['planId'] = sanitize_key($data->planId); |
| 811 |
/* --Start-- Manage Param Data */ |
| 812 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 813 |
$param['email'] = $__tagembed__user_details->email; |
| 814 |
$param['name'] = $__tagembed__user_details->name; |
| 815 |
/* --End-- Manage Param Data */ |
| 816 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/cancelsubscription', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 817 |
unset($param); |
| 818 |
$response = __tagembed__manageApiResponse($response); |
| 819 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 820 |
return __tagembed__exitWithSuccess(["message" => $response]); |
| 821 |
break; |
| 822 |
case "__tagembed__get_post": |
| 823 |
if (empty($__tagembed__user_details) || empty($data->widgetId) || !isset($data->perPage) || !isset($data->offset) || !isset($data->postStatus)) |
| 824 |
return __tagembed__exitWithDanger(); |
| 825 |
/* --Start-- Manage Param Data */ |
| 826 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 827 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 828 |
$param['perPage'] = sanitize_key($data->perPage); |
| 829 |
$param['offset'] = sanitize_key($data->offset); |
| 830 |
$param['postStatus'] = sanitize_key($data->postStatus); |
| 831 |
$param['feedIds'] = $data->feedIds; |
| 832 |
$param['postType'] = $data->postType; |
| 833 |
$param['highlightFilter'] = sanitize_key($data->highlightFilter); |
| 834 |
$param['pinFilter'] = sanitize_key($data->pinFilter); |
| 835 |
$param['recentFilter'] = sanitize_key($data->recentFilter); |
| 836 |
$param['retweetFilter'] = sanitize_key($data->retweetFilter); |
| 837 |
$param['searchText'] = sanitize_text_field($data->searchText); |
| 838 |
/* --End-- Manage Param Data */ |
| 839 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 840 |
unset($param); |
| 841 |
$response = __tagembed__manageApiResponse($response); |
| 842 |
return __tagembed__exitWithSuccess($response); |
| 843 |
break; |
| 844 |
case "__tagembed__manage_post_status": |
| 845 |
if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postIds) || empty($data->postStatus)) |
| 846 |
return __tagembed__exitWithDanger(); |
| 847 |
/* --Start-- Manage Param Data */ |
| 848 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 849 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 850 |
$param['postIds'] = $data->postIds; |
| 851 |
$param['postStatus'] = sanitize_key($data->postStatus); |
| 852 |
/* --End-- Manage Param Data */ |
| 853 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/status', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 854 |
unset($param); |
| 855 |
$response = __tagembed__manageApiResponse($response); |
| 856 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 857 |
return __tagembed__exitWithSuccess(["message" => $response]); |
| 858 |
break; |
| 859 |
case "__tagembed__feed_for_search": |
| 860 |
if (empty($__tagembed__user_details) || empty($data->widgetId)) |
| 861 |
return __tagembed__exitWithDanger(); |
| 862 |
/* --Start-- Manage Param Data */ |
| 863 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 864 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 865 |
/* --End-- Manage Param Data */ |
| 866 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/getfeeds', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 867 |
unset($param); |
| 868 |
$response = __tagembed__manageApiResponse($response); |
| 869 |
return __tagembed__exitWithSuccess($response); |
| 870 |
break; |
| 871 |
case "__tagembed__manage_post_pin": |
| 872 |
if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postId) || !isset($data->pin)) |
| 873 |
return __tagembed__exitWithDanger(); |
| 874 |
/* --Start-- Manage Param Data */ |
| 875 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 876 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 877 |
$param['postId'] = $data->postId; |
| 878 |
$param['pin'] = sanitize_key($data->pin); |
| 879 |
/* --End-- Manage Param Data */ |
| 880 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/pin', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 881 |
unset($param); |
| 882 |
$response = __tagembed__manageApiResponse($response); |
| 883 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 884 |
return __tagembed__exitWithSuccess(["message" => $response]); |
| 885 |
break; |
| 886 |
case "__tagembed__manage_post_highlight": |
| 887 |
if (empty($__tagembed__user_details) || empty($data->widgetId) || empty($data->postId) || !isset($data->highlight)) |
| 888 |
return __tagembed__exitWithDanger(); |
| 889 |
/* --Start-- Manage Param Data */ |
| 890 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 891 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 892 |
$param['postId'] = $data->postId; |
| 893 |
$param['highlight'] = sanitize_key($data->highlight); |
| 894 |
/* --End-- Manage Param Data */ |
| 895 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apifilter/highlight', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 896 |
unset($param); |
| 897 |
$response = __tagembed__manageApiResponse($response); |
| 898 |
$response = !empty($response->message) ? $response->message : 'Done'; |
| 899 |
return __tagembed__exitWithSuccess(["message" => $response]); |
| 900 |
break; |
| 901 |
case "__tagembed__plugin_version": |
| 902 |
/* --Start-- Manage Param Data */ |
| 903 |
$param = []; |
| 904 |
/* --End-- Manage Param Data */ |
| 905 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/pluginversion', $param, ['Authorization: __tagembed__']); |
| 906 |
$response = __tagembed__manageApiResponse($response); |
| 907 |
unset($param); |
| 908 |
$installedPluginVersion = get_file_data(__FILE__, ['Version' => 'Version'], false); |
| 909 |
$installedPluginVersion = $installedPluginVersion['Version']; |
| 910 |
$response->installedPluginVersion = $installedPluginVersion; |
| 911 |
$response->pluginUpgradeURL = admin_url() . "plugins.php"; |
| 912 |
return __tagembed__exitWithSuccess($response); |
| 913 |
break; |
| 914 |
case "__tagembed__check_user_token": |
| 915 |
if (empty($__tagembed__user_details)) |
| 916 |
return __tagembed__exitWithDanger(); |
| 917 |
/* --Start-- Manage Param Data */ |
| 918 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 919 |
/* --End-- Manage Param Data */ |
| 920 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/checkusertoken', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 921 |
if ($response->head->code == 401 && !$response->head->status) |
| 922 |
tagembed_logout(); |
| 923 |
unset($param); |
| 924 |
return __tagembed__exitWithSuccess($response); |
| 925 |
break; |
| 926 |
case "__tagembed__plugin_deactivate": |
| 927 |
/* --Start-- Manage Param Data */ |
| 928 |
$__tagembed__user_details = __tagembed__userData(); |
| 929 |
$param = []; |
| 930 |
$param['userId'] = !empty($__tagembed__user_details) ? sanitize_key($__tagembed__user_details->userId) : ""; |
| 931 |
$param['userName'] = !empty($__tagembed__user_details) ? sanitize_text_field($__tagembed__user_details->name) : ""; |
| 932 |
$param['userEmail'] = !empty($__tagembed__user_details) ? sanitize_email($__tagembed__user_details->email) : ""; |
| 933 |
$param['pluginDeactivateReason'] = sanitize_text_field($data->pluginDeactivateReason); |
| 934 |
$param['otherReason'] = sanitize_text_field($data->otherReason); |
| 935 |
$param['betterPlugin'] = sanitize_text_field($data->betterPlugin); |
| 936 |
$param['userWebsiteUrl'] = get_site_url(); |
| 937 |
/* --End-- Manage Param Data */ |
| 938 |
__tagembed__dropDatabaseTablesForPlugin(); |
| 939 |
deactivate_plugins(plugin_basename(__FILE__), true); |
| 940 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/deactivateuserdata', $param, ['Authorization: __tagembed__']); |
| 941 |
$response = __tagembed__manageApiResponse($response); |
| 942 |
unset($param); |
| 943 |
return __tagembed__exitWithSuccess(); |
| 944 |
break; |
| 945 |
case "__tagembed__get_customization_option": |
| 946 |
if (empty($__tagembed__user_details) || empty($data->widgetId)) |
| 947 |
return __tagembed__exitWithDanger(); |
| 948 |
/* --Start-- Manage Param Data */ |
| 949 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 950 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 951 |
/* --End-- Manage Param Data */ |
| 952 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/get', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 953 |
unset($param); |
| 954 |
$response = __tagembed__manageApiResponse($response); |
| 955 |
return __tagembed__exitWithSuccess($response); |
| 956 |
break; |
| 957 |
case "__tagembed__update_footer_customization_option": |
| 958 |
/* --Start-- Manage Param Data */ |
| 959 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 960 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 961 |
$param['personalizationId'] = sanitize_key($data->personalizationId); |
| 962 |
$param['themeRuleId'] = sanitize_key($data->themeRuleId); |
| 963 |
$param['loadMoreStatus'] = sanitize_key($data->loadMoreStatus); |
| 964 |
$param['autoScrollStatus'] = sanitize_key($data->autoScrollStatus); |
| 965 |
$param['showMoreTxt'] = $data->showMoreTxt; |
| 966 |
/* --End-- Manage Param Data */ |
| 967 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/footer', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 968 |
unset($param); |
| 969 |
$response = __tagembed__manageApiResponse($response); |
| 970 |
return __tagembed__exitWithSuccess($response); |
| 971 |
break; |
| 972 |
case "__tagembed__update_layout_customization_option": |
| 973 |
/* --Start-- Manage Param Data */ |
| 974 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 975 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 976 |
$param['personalizationId'] = sanitize_key($data->personalizationId); |
| 977 |
$param['themeRuleId'] = sanitize_key($data->themeRuleId); |
| 978 |
$param['numberOfPosts'] = sanitize_key($data->numberOfPosts); |
| 979 |
$param['padding'] = sanitize_key($data->padding); |
| 980 |
$param['minimumPostWidth'] = sanitize_key($data->minimumPostWidth); |
| 981 |
$param['columnCount'] = sanitize_key($data->columnCount); |
| 982 |
$param['columnCountMobile'] = sanitize_key($data->columnCountMobile); |
| 983 |
$param['postText'] = sanitize_key($data->postText); |
| 984 |
$param['mobilePopup'] = sanitize_key($data->mobilePopup); |
| 985 |
$param['postFeatured'] = sanitize_key($data->postFeatured); |
| 986 |
/* --End-- Manage Param Data */ |
| 987 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/layout', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 988 |
unset($param); |
| 989 |
$response = __tagembed__manageApiResponse($response); |
| 990 |
return __tagembed__exitWithSuccess($response); |
| 991 |
break; |
| 992 |
case "__tagembed__update_card_customization_option": |
| 993 |
/* --Start-- Manage Param Data */ |
| 994 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 995 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 996 |
$param['personalizationId'] = sanitize_key($data->personalizationId); |
| 997 |
$param['inheritStyles'] = sanitize_key($data->inheritStyles); |
| 998 |
$param['themeRuleId'] = sanitize_key($data->themeRuleId); |
| 999 |
$param['fontColor'] = $data->fontColor; |
| 1000 |
$param['authorColor'] = $data->authorColor; |
| 1001 |
$param['cardColor'] = $data->cardColor; |
| 1002 |
$param['fontSize'] = sanitize_key($data->fontSize); |
| 1003 |
$param['font'] = sanitize_key($data->font); |
| 1004 |
$param['shareOption'] = sanitize_key($data->shareOption); |
| 1005 |
$param['hideContent'] = sanitize_key($data->hideContent); |
| 1006 |
$param['postAuthor'] = sanitize_key($data->postAuthor); |
| 1007 |
$param['postTime'] = sanitize_key($data->postTime); |
| 1008 |
$param['lineTrim'] = sanitize_key($data->lineTrim); |
| 1009 |
$param['aspectImageRatio'] = $data->aspectImageRatio; |
| 1010 |
$param['textAlignment'] = $data->textAlignment; |
| 1011 |
$param['cardCurve'] = $data->cardCurve; |
| 1012 |
$param['colorType'] = $data->colorType; |
| 1013 |
/* --End-- Manage Param Data */ |
| 1014 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/card', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1015 |
unset($param); |
| 1016 |
$response = __tagembed__manageApiResponse($response); |
| 1017 |
return __tagembed__exitWithSuccess($response); |
| 1018 |
break; |
| 1019 |
case "__tagembed__update_other_customization_option": |
| 1020 |
/* --Start-- Manage Param Data */ |
| 1021 |
$param['widgetId'] = sanitize_key($data->widgetId); |
| 1022 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1023 |
$param['personalizationId'] = sanitize_key($data->personalizationId); |
| 1024 |
$param['themeRuleId'] = sanitize_key($data->themeRuleId); |
| 1025 |
$param['css'] = $data->css; |
| 1026 |
/* --End-- Manage Param Data */ |
| 1027 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apicustomization/other', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1028 |
unset($param); |
| 1029 |
$response = __tagembed__manageApiResponse($response); |
| 1030 |
return __tagembed__exitWithSuccess($response); |
| 1031 |
break; |
| 1032 |
case "__tagembed__get_and_manage_intercom_chat_setting": |
| 1033 |
if (empty($__tagembed__user_details)) |
| 1034 |
return __tagembed__exitWithDanger(); |
| 1035 |
/* --Start-- Manage Param Data */ |
| 1036 |
$param['userId'] = sanitize_key($__tagembed__user_details->userId); |
| 1037 |
/* --End-- Manage Param Data */ |
| 1038 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getIntercomSettingData', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1039 |
unset($param); |
| 1040 |
$response = __tagembed__manageApiResponse($response); |
| 1041 |
return __tagembed__exitWithSuccess($response); |
| 1042 |
break; |
| 1043 |
default: |
| 1044 |
return __tagembed__exitWithDanger(); |
| 1045 |
endswitch; |
| 1046 |
} |
| 1047 |
/* --End-- Manage Ajax Calls */ |
| 1048 |
|
| 1049 |
/* --Start-- Manage Login And Register On Plugin Activate */ |
| 1050 |
function __tagembed__manageLoginAndRegisterOnPluginActivate() { |
| 1051 |
global $wpdb; |
| 1052 |
$__tagembed__activeUserData = wp_get_current_user(); |
| 1053 |
if (empty($__tagembed__activeUserData->roles) || $__tagembed__activeUserData->roles[0] != "administrator") |
| 1054 |
return false; |
| 1055 |
if (!empty($__tagembed__activeUserData->data->user_email) && !empty($__tagembed__activeUserData->data->display_name)): |
| 1056 |
$__tagembed__activeUserName = $__tagembed__activeUserData->data->display_name; |
| 1057 |
$__tagembed__activeUserEmail = $__tagembed__activeUserData->data->user_email; |
| 1058 |
/* --Start-- Mange Other Active Options */ |
| 1059 |
$__tagembed__activeOptions = __tagembed__getActiveOptions(); |
| 1060 |
if (!empty($__tagembed__activeOptions[0]->email)): |
| 1061 |
if (empty($__tagembed__activeOptions[0]->isLogin) || $__tagembed__activeOptions[0]->isLogin == "no") |
| 1062 |
return false; |
| 1063 |
$__tagembed__activeUserEmail = $__tagembed__activeOptions[0]->email; |
| 1064 |
endif; |
| 1065 |
/* --End-- Mange Other Active Options */ |
| 1066 |
$param = []; |
| 1067 |
/* --Start-- Manage Param Data */ |
| 1068 |
$param['emailId'] = sanitize_email($__tagembed__activeUserEmail); |
| 1069 |
/* --End-- Manage Param Data */ |
| 1070 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/checkUserExistOrNotAndGetData', $param); |
| 1071 |
$response = __tagembed__manageApiResponse($response); |
| 1072 |
unset($param); |
| 1073 |
if (!empty($response->userId)) |
| 1074 |
__tagembed__login($response); /* After Register Manage User Login Process */ |
| 1075 |
endif; |
| 1076 |
} |
| 1077 |
/* --End-- Manage Login And Register On Plugin Activate */ |
| 1078 |
|
| 1079 |
/* --Start-- Login */ |
| 1080 |
function __tagembed__login($response) { |
| 1081 |
global $wpdb; |
| 1082 |
$return = false; |
| 1083 |
$user = __tagembed__user($response->emailId); |
| 1084 |
if (empty($user->email)): |
| 1085 |
if ($wpdb->query($wpdb->prepare("INSERT INTO wp_tagembed_user (userId, name, email, accessToken, isLogin) VALUES (%d, %s, %s, %s, %s)", $response->userId, $response->name, $response->emailId, $response->accessToken, 'yes'))): |
| 1086 |
$return = true; |
| 1087 |
endif; |
| 1088 |
else: |
| 1089 |
if ($wpdb->query($wpdb->prepare("UPDATE wp_tagembed_user SET userId = %d, name = %s, email = %s, accessToken = %s, isLogin = %s WHERE email = %s", $response->userId, $response->name, $response->emailId, $response->accessToken, 'yes', $response->emailId))): |
| 1090 |
$return = true; |
| 1091 |
endif; |
| 1092 |
endif; |
| 1093 |
__tagembed__manageActiveOptions($response->emailId, "yes"); /* Manage Active Options */ |
| 1094 |
if ($return): |
| 1095 |
__tagembed__manageActiveWidgetsUser($response->userId); |
| 1096 |
endif; |
| 1097 |
return $return; |
| 1098 |
} |
| 1099 |
/* --End-- Login */ |
| 1100 |
|
| 1101 |
/* --Start-- Manage Active Options */ |
| 1102 |
function __tagembed__manageActiveOptions($email = null, $other = null) { |
| 1103 |
global $wpdb; |
| 1104 |
if ($email == null && $other != null): |
| 1105 |
$wpdb->query($wpdb->prepare("UPDATE wp_tagembed_active_options SET isLogin = %s WHERE id = %d", $other, 1)); |
| 1106 |
else: |
| 1107 |
$__tagembed__activeOptions = $wpdb->get_results($wpdb->prepare("SELECT email FROM wp_tagembed_active_options WHERE id = %d", 1)); |
| 1108 |
if (empty($__tagembed__activeOptions[0]->email)): |
| 1109 |
$wpdb->query($wpdb->prepare("INSERT INTO wp_tagembed_active_options (email, isLogin) VALUES (%s, %s)", $email, $other)); |
| 1110 |
else: |
| 1111 |
$wpdb->query($wpdb->prepare("UPDATE wp_tagembed_active_options SET email = %s, isLogin = %s WHERE id = %d", $email, $other, 1)); |
| 1112 |
endif; |
| 1113 |
endif; |
| 1114 |
} |
| 1115 |
/* --End-- Manage Active Options */ |
| 1116 |
/* --Start--Get User Last Login Email Id */ |
| 1117 |
function __tagembed__getActiveOptions() { |
| 1118 |
global $wpdb; |
| 1119 |
$__tagembed__activeOptions = $wpdb->get_results($wpdb->prepare("SELECT email, isLogin FROM wp_tagembed_active_options WHERE id = %d", 1)); |
| 1120 |
return $__tagembed__activeOptions; |
| 1121 |
} |
| 1122 |
/* --End--Get User last Login Email Id */ |
| 1123 |
/* --Start-- Logout */ |
| 1124 |
function tagembed_logout() { |
| 1125 |
global $wpdb; |
| 1126 |
if ($wpdb->query($wpdb->prepare("UPDATE wp_tagembed_user SET isLogin = %s WHERE isLogin = %s", "no", "yes"))): |
| 1127 |
__tagembed__manageActiveOptions(null, "no"); /* Manage Active Options */ |
| 1128 |
return true; |
| 1129 |
endif; |
| 1130 |
return false; |
| 1131 |
} |
| 1132 |
/* --End-- Logout */ |
| 1133 |
/* --Start--Manage Menues */ |
| 1134 |
function __tagembed__menus($__tagembed__menu_condatation = []) { |
| 1135 |
global $wpdb; |
| 1136 |
if (empty($__tagembed__menu_condatation)) |
| 1137 |
return $wpdb->get_results("SELECT * FROM wp_tagembed_menus"); |
| 1138 |
if (array_key_exists('__tagembed__menu_condation', $__tagembed__menu_condatation)) |
| 1139 |
return $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_tagembed_menus WHERE status = %s", $__tagembed__menu_condatation['__tagembed__menu_condation'])); |
| 1140 |
if (array_key_exists('__tagembed__menu_id', $__tagembed__menu_condatation)): |
| 1141 |
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']))) |
| 1142 |
return true; |
| 1143 |
return false; |
| 1144 |
endif; |
| 1145 |
} |
| 1146 |
/* --End--Manage Menues */ |
| 1147 |
/* --Start-- Get User Details */ |
| 1148 |
function __tagembed__user($email = null) { |
| 1149 |
global $wpdb; |
| 1150 |
$__tagembed__userResponse = ""; |
| 1151 |
if (empty($email)): |
| 1152 |
$__tagembed__userResponse = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_tagembed_user WHERE isLogin = %s", 'yes')); |
| 1153 |
else: |
| 1154 |
$__tagembed__userResponse = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_tagembed_user WHERE email = %s", $email)); |
| 1155 |
endif; |
| 1156 |
if (!empty($__tagembed__userResponse)) |
| 1157 |
return $__tagembed__userResponse[0]; |
| 1158 |
return; |
| 1159 |
} |
| 1160 |
function __tagembed__userData() { |
| 1161 |
global $wpdb; |
| 1162 |
$__tagembed__user_dataResponse = ""; |
| 1163 |
$__tagembed__user_dataResponse = $wpdb->get_results("SELECT * FROM wp_tagembed_user"); |
| 1164 |
if (!empty($__tagembed__user_dataResponse)) |
| 1165 |
return $__tagembed__user_dataResponse[0]; |
| 1166 |
return; |
| 1167 |
} |
| 1168 |
/* --End-- Get User Details */ |
| 1169 |
/* --Start-- Get Widget */ |
| 1170 |
function __tagembed__widgets() { |
| 1171 |
$returnWidgetData = []; |
| 1172 |
$__tagembed__user_details = __tagembed__user(); |
| 1173 |
if (!empty($__tagembed__user_details)): |
| 1174 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiwidget/get', ['userId' => sanitize_key($__tagembed__user_details->userId)], ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1175 |
if (!isset($response->head->status)) |
| 1176 |
return $returnWidgetData; |
| 1177 |
if (!$response->head->status || $response->head->code != 200 || !$response->body || empty($response->body)) |
| 1178 |
return $returnWidgetData; |
| 1179 |
$returnWidgetData = $response->body; |
| 1180 |
endif; |
| 1181 |
return $returnWidgetData; |
| 1182 |
} |
| 1183 |
/* --End-- Get Widget */ |
| 1184 |
/* --Start-- Get Active Widget */ |
| 1185 |
function __tagembed__activeWidget() { |
| 1186 |
global $wpdb; |
| 1187 |
$__tagembed__activeWidgetResponse = ""; |
| 1188 |
$__tagembed__activeWidgetResponse = $wpdb->get_results("SELECT * FROM wp_tagembed_active_widget"); |
| 1189 |
if (!empty($__tagembed__activeWidgetResponse)) |
| 1190 |
return $__tagembed__activeWidgetResponse[0]->widgetId; |
| 1191 |
return; |
| 1192 |
} |
| 1193 |
/* --End-- Get Active Widget */ |
| 1194 |
/* --Start-- Manage Active Widget User */ |
| 1195 |
function __tagembed__manageActiveWidget($widgetId) { |
| 1196 |
global $wpdb; |
| 1197 |
$return = ''; |
| 1198 |
$activeWidgetUserId = __tagembed__activeWidget(); |
| 1199 |
if ($activeWidgetUserId == $widgetId) |
| 1200 |
return true; |
| 1201 |
if (empty($activeWidgetUserId)): |
| 1202 |
$wpdb->query($wpdb->prepare("INSERT INTO wp_tagembed_active_widget (widgetId) VALUES (%s)", $widgetId)); |
| 1203 |
return true; |
| 1204 |
else: |
| 1205 |
$wpdb->query($wpdb->prepare("UPDATE wp_tagembed_active_widget SET widgetId = %s WHERE id = %d", $widgetId, 1)); |
| 1206 |
return true; |
| 1207 |
endif; |
| 1208 |
return false; |
| 1209 |
} |
| 1210 |
/* --End-- Manage Active Widget User */ |
| 1211 |
/* --Start-- Get Active Widget User */ |
| 1212 |
function __tagembed__activeWidgetUser() { |
| 1213 |
global $wpdb; |
| 1214 |
$__tagembed__activeWidgetUserResponse = ""; |
| 1215 |
$__tagembed__activeWidgetUserResponse = $wpdb->get_results("SELECT * FROM wp_tagembed_active_widget_user"); |
| 1216 |
if (!empty($__tagembed__activeWidgetUserResponse)): |
| 1217 |
return $__tagembed__activeWidgetUserResponse[0]->userId; |
| 1218 |
endif; |
| 1219 |
return; |
| 1220 |
} |
| 1221 |
/* --End-- Get Active Widget User */ |
| 1222 |
/* --Start-- Manage Active Widget User */ |
| 1223 |
function __tagembed__manageActiveWidgetsUser($userId) { |
| 1224 |
global $wpdb; |
| 1225 |
$return = ''; |
| 1226 |
$activeWidgetUserId = __tagembed__activeWidgetUser(); |
| 1227 |
if ($activeWidgetUserId == $userId) |
| 1228 |
return true; |
| 1229 |
if (empty($activeWidgetUserId)): |
| 1230 |
$wpdb->query($wpdb->prepare("INSERT INTO wp_tagembed_active_widget_user (userId) VALUES (%d)", $userId)); |
| 1231 |
return true; |
| 1232 |
else: |
| 1233 |
$wpdb->query($wpdb->prepare("UPDATE wp_tagembed_active_widget_user SET userId = %d WHERE id = %d", $userId, 1)); |
| 1234 |
return true; |
| 1235 |
endif; |
| 1236 |
return false; |
| 1237 |
} |
| 1238 |
/* --End-- Manage Active Widget User */ |
| 1239 |
/* * ** DATABASE *** */ |
| 1240 |
/* --Start-- Manage Database */ |
| 1241 |
function __tagembed__createDatabaseTableForPlugin() { |
| 1242 |
global $wpdb; |
| 1243 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 1244 |
$wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_user` (`id` int(11) NOT NULL AUTO_INCREMENT,`userId` varchar(100) NOT NULL,`name` varchar(100) NOT NULL,`email` varchar(100) NOT NULL,`accessToken` varchar(255) NOT NULL,`isLogin` enum('no', 'yes') NOT NULL,PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); |
| 1245 |
$wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_active_widget_user` (`id` int(11) NOT NULL AUTO_INCREMENT,`userId` varchar(100) NOT NULL,PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); |
| 1246 |
$wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_menus` (`id` int(11) NOT NULL AUTO_INCREMENT,`name` varchar(100) NOT NULL,`status` tinyint(2) NOT NULL,`path` varchar(255) NOT NULL,PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); |
| 1247 |
$wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_active_widget` (`id` int(11) NOT NULL AUTO_INCREMENT,`widgetId` varchar(100) NOT NULL,PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); |
| 1248 |
$wpdb->query("CREATE TABLE IF NOT EXISTS `wp_tagembed_active_options` (`id` int(11) NOT NULL AUTO_INCREMENT,`email` varchar(500) NOT NULL,`isLogin` enum('no', 'yes'),PRIMARY KEY(`id`)) ENGINE = InnoDB DEFAULT CHARSET = latin1"); |
| 1249 |
/* --Start-- Manage Tagembed Plugin Menus */ |
| 1250 |
$__tagembed__checkAlreadyExistMenusDataExistOrNot = $wpdb->get_results("SELECT id FROM wp_tagembed_menus"); |
| 1251 |
if (empty($__tagembed__checkAlreadyExistMenusDataExistOrNot)): |
| 1252 |
$__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']]; |
| 1253 |
foreach ($__tagembed__menus as $__tagembed__menu): |
| 1254 |
$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'])); |
| 1255 |
endforeach; |
| 1256 |
endif; |
| 1257 |
/* --End-- Manage Tagembed Plugin Menus */ |
| 1258 |
} |
| 1259 |
function __tagembed__dropDatabaseTablesForPlugin() { |
| 1260 |
global $wpdb; |
| 1261 |
$wpdb->query("DROP table IF EXISTS wp_tagembed_user"); |
| 1262 |
$wpdb->query("DROP table IF EXISTS wp_tagembed_active_widget_user"); |
| 1263 |
$wpdb->query("DROP table IF EXISTS wp_tagembed_active_widget"); |
| 1264 |
$wpdb->query("DROP table IF EXISTS wp_tagembed_menus"); |
| 1265 |
} |
| 1266 |
/* --End-- Manage Database */ |
| 1267 |
/* --Start-- Manage Active Deactive And Uninstall Webhook */ |
| 1268 |
register_activation_hook(__FILE__, '__tagembed__pluginActivate'); |
| 1269 |
function __tagembed__pluginActivate() { |
| 1270 |
__tagembed__createDatabaseTableForPlugin(); |
| 1271 |
__tagembed__manageLoginAndRegisterOnPluginActivate(); |
| 1272 |
add_action('activated_plugin', '__tagembed__plginActivationRedirect'); |
| 1273 |
} |
| 1274 |
register_uninstall_hook(__FILE__, '__tagembed__pluginUnistall'); |
| 1275 |
function __tagembed__pluginUnistall() { |
| 1276 |
__tagembed__dropDatabaseTablesForPlugin(); |
| 1277 |
global $wpdb; |
| 1278 |
$wpdb->query("DROP table IF EXISTS wp_tagembed_active_options"); /* Delete When Plugin Uninstall */ |
| 1279 |
} |
| 1280 |
/* register_deactivation_hook(__FILE__, '__tagembed__pluginDeactivate'); |
| 1281 |
function __tagembed__pluginDeactivate() { |
| 1282 |
__tagembed__dropDatabaseTablesForPlugin(); |
| 1283 |
} */ |
| 1284 |
|
| 1285 |
/* --End-- Manage Active Deactive And Uninstall Webhook */ |
| 1286 |
/* --Start--Manage Redirect After Plugin Activate */ |
| 1287 |
function __tagembed__plginActivationRedirect() { |
| 1288 |
$__tagembed__activeUserData = wp_get_current_user(); |
| 1289 |
if (empty($__tagembed__activeUserData->roles)) |
| 1290 |
return false; |
| 1291 |
exit(wp_redirect(TAGEMBED_PLUGIN_CALL_BACK_URL)); |
| 1292 |
} |
| 1293 |
/* --End--Manage Redirect After Plugin Activate */ |
| 1294 |
/* --Start--Manage Setting Link */ |
| 1295 |
function __tagembed__settingsLink($links) { |
| 1296 |
array_unshift($links, '<a href=' . TAGEMBED_PLUGIN_CALL_BACK_URL . '>Settings</a>'); |
| 1297 |
return $links; |
| 1298 |
} |
| 1299 |
add_filter("plugin_action_links_" . plugin_basename(__FILE__), '__tagembed__settingsLink'); |
| 1300 |
/* --End--Manage Setting Link */ |
| 1301 |
/* --Start--Manage Database On Plugin Update Time */ |
| 1302 |
function __tagembed__manageDatabaseOnPluginUpdateTime() { |
| 1303 |
__tagembed__dropDatabaseTablesForPlugin(); |
| 1304 |
__tagembed__createDatabaseTableForPlugin(); |
| 1305 |
__tagembed__manageLoginAndRegisterOnPluginActivate(); |
| 1306 |
} |
| 1307 |
add_action('upgrader_process_complete', '__tagembed__manageDatabaseOnPluginUpdateTime', 10, 2); |
| 1308 |
/* --End--Manage Database On Plugin Update Time */ |
| 1309 |
/* --Sart--Get And Manage Social Accout Id */ |
| 1310 |
function __tagembed__get_user_social_account_id() { |
| 1311 |
$__tagembed__user_details = __tagembed__user(); |
| 1312 |
$param['userId'] = $__tagembed__user_details->userId; |
| 1313 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/getsocialaccountid', $param, ['Authorization:' . $__tagembed__user_details->accessToken]); |
| 1314 |
if (isset($response->head->status)): |
| 1315 |
if ($response->head->status): |
| 1316 |
$response = __tagembed__manageApiResponse($response); |
| 1317 |
if (!empty($response->userId)): |
| 1318 |
return $response->userId; |
| 1319 |
endif; |
| 1320 |
endif; |
| 1321 |
endif; |
| 1322 |
return false; |
| 1323 |
} |
| 1324 |
/* --End--Manage Chat Hide And Show */ |
| 1325 |
|
| 1326 |
/* --Start-- Show Admin General Notification After Login And Register */ |
| 1327 |
function __tagembed__generalAdminNotice() { |
| 1328 |
$__tagmebed__page_name = ""; |
| 1329 |
if (!empty($_GET['page'])): |
| 1330 |
$__tagmebed__page_name = __tagembed__sanitizeRequestData($_GET); |
| 1331 |
$__tagmebed__page_name = $__tagmebed__page_name['page']; |
| 1332 |
endif; |
| 1333 |
TRY { |
| 1334 |
$response = __tagembed__wpApiCall(TAGEMBED_PLUGIN_API_URL . 'apiaccount/notification', ['callBy' => 'wordpress'], ['Authorization: __tagembed__']); |
| 1335 |
if (!is_wp_error($response)): |
| 1336 |
if (isset($response->head->status)): |
| 1337 |
$response = __tagembed__manageApiResponse($response); |
| 1338 |
if (!empty($response->notifications) && is_array($response->notifications)): |
| 1339 |
$htmlData = ""; |
| 1340 |
foreach ($response->notifications as $notifications): |
| 1341 |
if ($notifications->location == "tagembed" || $notifications->location == "inner"): |
| 1342 |
if ($__tagmebed__page_name != "tagembed") |
| 1343 |
continue; |
| 1344 |
$htmlData .= '<div class="notice notice-' . esc_html($notifications->type) . ' is-dismissible">'; |
| 1345 |
$htmlData .= '<p>' . $notifications->message . '</p>'; |
| 1346 |
$htmlData .= '</div>'; |
| 1347 |
elseif ($notifications->location == "all"): |
| 1348 |
$htmlData .= '<div class="notice notice-' . esc_html($notifications->type) . ' is-dismissible">'; |
| 1349 |
$htmlData .= '<p>' . $notifications->message . '</p>'; |
| 1350 |
$htmlData .= '</div>'; |
| 1351 |
endif; |
| 1352 |
endforeach; |
| 1353 |
echo $htmlData; |
| 1354 |
endif; |
| 1355 |
endif; |
| 1356 |
endif; |
| 1357 |
} CATCH (Exception $e) { |
| 1358 |
|
| 1359 |
} |
| 1360 |
} |
| 1361 |
add_action('in_admin_header', '__tagembed__hideGeneralAdminNotice'); |
| 1362 |
function __tagembed__hideGeneralAdminNotice() { |
| 1363 |
$__tagmebed__page_name = ""; |
| 1364 |
if (!empty($_GET['page'])): |
| 1365 |
$__tagmebed__page_name = __tagembed__sanitizeRequestData($_GET); |
| 1366 |
$__tagmebed__page_name = $__tagmebed__page_name['page']; |
| 1367 |
endif; |
| 1368 |
if ($__tagmebed__page_name == "tagembed"): |
| 1369 |
remove_all_actions('admin_notices'); |
| 1370 |
remove_all_actions('all_admin_notices'); |
| 1371 |
endif; |
| 1372 |
if (!empty(__tagembed__user())): |
| 1373 |
add_action('admin_notices', '__tagembed__generalAdminNotice'); |
| 1374 |
endif; |
| 1375 |
} |
| 1376 |
/* --End-- Show Admin General Notification After Login And Register */ |
| 1377 |
|
| 1378 |
/* --End-- Drop Database Table */ |
| 1379 |
/* --Start-- Create Short Code */ |
| 1380 |
function __tagembed__PluginShortCode($attr) { |
| 1381 |
extract(shortcode_atts(['width' => '', 'height' => '',], $attr, 'tagembed')); |
| 1382 |
$widgetId = (isset($attr[1]) ? $attr[1] : ''); |
| 1383 |
if (!empty($widgetId) && is_numeric($widgetId) && (($width === '' || preg_match('/^\d+(px|%|)$/', $width)) && ($height === '' || preg_match('/^\d+(px|%|)$/', $height)))): |
| 1384 |
$output = '<span class=""></span>'; |
| 1385 |
$output .= '<div style="width:' . $width . '; height:' . $height . ';overflow: auto;" class="tagembed-container">'; |
| 1386 |
$output .= '<div style="width:100%; height:100%;" class="tagembed-socialwall tagembed-analystic" data-wall-id="' . $widgetId . '"></div>'; |
| 1387 |
$output .= '</div>'; |
| 1388 |
else: |
| 1389 |
$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>'; |
| 1390 |
endif; |
| 1391 |
return $output; |
| 1392 |
} |
| 1393 |
add_shortcode("tagembed", "__tagembed__PluginShortCode"); |
| 1394 |
/* --End-- Create Short Code */ |
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
|