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