Changeset 1970870
- Timestamp:
- 11/08/2018 11:34:20 AM (7 years ago)
- Location:
- clym
- Files:
-
- 78 added
- 2 deleted
- 4 edited
- 1 copied
-
tags/2.0 (copied) (copied from clym/trunk)
-
tags/2.0/admin (added)
-
tags/2.0/admin/clym-admin.php (added)
-
tags/2.0/admin/clym-quick-setup.php (added)
-
tags/2.0/admin/clym-settings.php (added)
-
tags/2.0/admin/css (added)
-
tags/2.0/admin/css/bootstrap.min.css (added)
-
tags/2.0/admin/css/custom.css (added)
-
tags/2.0/admin/img (added)
-
tags/2.0/admin/img/app-dark.png (added)
-
tags/2.0/admin/img/cerc.png (added)
-
tags/2.0/admin/img/clym-load.gif (added)
-
tags/2.0/admin/img/clym-logo.png (added)
-
tags/2.0/admin/img/dashboard-dark.png (added)
-
tags/2.0/admin/img/dashboard-white.png (added)
-
tags/2.0/admin/img/down-arrow.png (added)
-
tags/2.0/admin/img/facebook.png (added)
-
tags/2.0/admin/img/help-dark.png (added)
-
tags/2.0/admin/img/icon.png (added)
-
tags/2.0/admin/img/linkedin.png (added)
-
tags/2.0/admin/img/menu.png (added)
-
tags/2.0/admin/img/metatag-dark.png (added)
-
tags/2.0/admin/img/metatag-white.png (added)
-
tags/2.0/admin/img/plugin-dark.png (added)
-
tags/2.0/admin/img/plugin-white.png (added)
-
tags/2.0/admin/img/twitter.png (added)
-
tags/2.0/admin/img/up-arrow.png (added)
-
tags/2.0/admin/img/widget-dark.png (added)
-
tags/2.0/admin/img/widget-white.png (added)
-
tags/2.0/admin/index.php (added)
-
tags/2.0/admin/js (added)
-
tags/2.0/admin/js/bootstrap.min.js (added)
-
tags/2.0/admin/js/custom.js (added)
-
tags/2.0/admin/js/jquery.min.js (added)
-
tags/2.0/clym.php (modified) (7 diffs)
-
tags/2.0/img (deleted)
-
tags/2.0/includes (added)
-
tags/2.0/includes/config.json (added)
-
tags/2.0/includes/plugins.json (added)
-
tags/2.0/languages (added)
-
tags/2.0/public (added)
-
tags/2.0/public/clym-public.php (added)
-
tags/2.0/readme.txt (modified) (3 diffs)
-
trunk/admin (added)
-
trunk/admin/clym-admin.php (added)
-
trunk/admin/clym-quick-setup.php (added)
-
trunk/admin/clym-settings.php (added)
-
trunk/admin/css (added)
-
trunk/admin/css/bootstrap.min.css (added)
-
trunk/admin/css/custom.css (added)
-
trunk/admin/img (added)
-
trunk/admin/img/app-dark.png (added)
-
trunk/admin/img/cerc.png (added)
-
trunk/admin/img/clym-load.gif (added)
-
trunk/admin/img/clym-logo.png (added)
-
trunk/admin/img/dashboard-dark.png (added)
-
trunk/admin/img/dashboard-white.png (added)
-
trunk/admin/img/down-arrow.png (added)
-
trunk/admin/img/facebook.png (added)
-
trunk/admin/img/help-dark.png (added)
-
trunk/admin/img/icon.png (added)
-
trunk/admin/img/linkedin.png (added)
-
trunk/admin/img/menu.png (added)
-
trunk/admin/img/metatag-dark.png (added)
-
trunk/admin/img/metatag-white.png (added)
-
trunk/admin/img/plugin-dark.png (added)
-
trunk/admin/img/plugin-white.png (added)
-
trunk/admin/img/twitter.png (added)
-
trunk/admin/img/up-arrow.png (added)
-
trunk/admin/img/widget-dark.png (added)
-
trunk/admin/img/widget-white.png (added)
-
trunk/admin/index.php (added)
-
trunk/admin/js (added)
-
trunk/admin/js/bootstrap.min.js (added)
-
trunk/admin/js/custom.js (added)
-
trunk/admin/js/jquery.min.js (added)
-
trunk/clym.php (modified) (7 diffs)
-
trunk/img (deleted)
-
trunk/includes (added)
-
trunk/includes/config.json (added)
-
trunk/includes/plugins.json (added)
-
trunk/languages (added)
-
trunk/public (added)
-
trunk/public/clym-public.php (added)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
clym/tags/2.0/clym.php
r1958203 r1970870 5 5 Description: One platform for global privacy needs. Manage Cookies, Consent, Subjects’ Requests, Policies, Terms and prove compliance through consent receipts. 6 6 Author: Clym.io 7 Version: 1.37 Version: 2.0 8 8 Author URI: https://www.clym.io/category/product-updates 9 9 */ 10 10 // Make sure we don't expose any info if called directly 11 $CLYM_VERSION = '1.3'; 11 $CLYM_VERSION = '2.0'; 12 12 13 if (!defined('ABSPATH')) { 13 14 echo 'Hi there! I\'m just a plugin, not much I can do when called directly.'; 14 15 exit; 15 16 } 17 18 if (!is_admin()) { 19 require_once plugin_dir_path(__FILE__) . 'public/clym-public.php'; 20 } 21 16 22 if (is_admin()) { 17 23 $clym = json_decode(get_option('clym'), true); 18 24 if ($clym['clym']['version'] !== $CLYM_VERSION) { 19 clym_install _plugin();25 clym_install(); 20 26 } 21 27 } 22 function clym_inject_meta_tag()23 {24 $clym = json_decode(get_option('clym'), true);25 if (strlen($clym['clym']['meta_tag']) > 0)26 echo $clym['clym']['meta_tag'];27 }28 29 add_action('wp_head', 'clym_inject_meta_tag', 1);30 31 function clym_inject_widget()32 {33 $clym = json_decode(get_option('clym'), true);34 if (strlen($clym['clym']['widget']['script']) > 0)35 echo $clym['clym']['widget']['script'];36 }37 38 add_action('wp_' . json_decode(get_option('clym'), true)['clym']['widget']['location'], 'clym_inject_widget');39 40 function clym_block_scripts()41 {42 global $wp_scripts;43 $clym = json_decode(get_option('clym'), true);44 if (strlen($clym['clym']['widget']['script']) === 0) return;45 foreach ($wp_scripts->queue as $handle) {46 if (in_array($wp_scripts->registered[$handle]->src, $clym['clym']['found']['js']))47 unset($wp_scripts->registered[$handle]);48 }49 }50 51 add_action('wp_print_scripts', 'clym_block_scripts');52 53 function clym_detect_scripts()54 {55 global $wp_scripts;56 if (is_admin()) return;57 $clym = json_decode(get_option('clym'), true);58 if ($clym['clym']['key'] !== $_GET['clym']) return;59 $plugins = $clym['clym']['plugins'];60 $scripts = array();61 foreach ($wp_scripts->queue as $handle) {62 for ($i = 0; $i < count($plugins); $i++) {63 $found = false;64 for ($j = 0; $j < count($plugins[$i]['blacklist']['js']); $j++) {65 if (strpos($wp_scripts->registered[$handle]->src, $plugins[$i]['blacklist']['js'][$j])) {66 $found = true;67 }68 }69 if ($found) {70 array_push($scripts, $wp_scripts->registered[$handle]->src);71 array_push($plugins[$i]['scripts_found']['js'], $wp_scripts->registered[$handle]->src);72 }73 }74 }75 $clym['clym']['plugins'] = $plugins;76 $clym['clym']['found']['js'] = $scripts;77 update_option('clym', json_encode($clym));78 $notification = 0;79 if (count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']) > 0)80 $notification = count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']);81 update_option('clym_notification', $notification);82 }83 84 add_action('wp_print_scripts', 'clym_detect_scripts');85 28 86 29 function clym_create_request() … … 88 31 $clym = json_decode(get_option('clym'), true); 89 32 $url = get_site_url(); 90 $url .= '?clym =' . $clym['clym']['key'];33 $url .= '?clym_request=' . $clym['key']; 91 34 $WP_Http = new WP_Http(); 92 35 $WP_Http->request($url); 93 36 } 94 37 95 function clym_ detect_active_plugins()38 function clym_install() 96 39 { 97 $clym = json_decode(get_option('clym'), true); 98 $plugins = $clym['clym']['plugins']; 99 $active_plugins = array(); 100 for ($i = 0; $i < count($plugins); $i++) { 101 if (in_array($plugins[$i]['key'], get_option('active_plugins'))) { 102 $plugins[$i]['is_active'] = true; 103 array_push($active_plugins, $plugins[$i]['key']); 104 } else { 105 $plugins[$i]['is_active'] = false; 106 } 107 } 108 $clym['clym']['plugins'] = $plugins; 109 $clym['clym']['active_plugins'] = $active_plugins; 110 update_option('clym', json_encode($clym)); 111 clym_create_request(); 112 clym_create_request(); 113 } 114 115 116 function clym_install_plugin() 117 { 118 $clym = file_get_contents(plugins_url('settings/config.json', __FILE__)); 40 $clym = file_get_contents(plugins_url('includes/config.json', __FILE__)); 119 41 $clymJson = json_decode($clym, true); 120 $clymJson[' clym']['key'] = substr(str_shuffle(str_repeat($key = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(64 / strlen($key)))), 1, 64);42 $clymJson['key'] = substr(str_shuffle(str_repeat($key = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(64 / strlen($key)))), 1, 64); 121 43 if (!get_option('clym')) { 122 44 update_option('clym', json_encode($clymJson)); 123 45 } else { 124 46 $clymBkp = json_decode(get_option('clym'), true); 125 $clymJson[' clym']['have_account'] = $clymBkp['clym']['have_account'];126 $clymJson[' clym']['defaultLanguage'] = $clymBkp['clym']['defaultLanguage'];127 $clymJson[' clym']['meta_tag'] = $clymBkp['clym']['meta_tag'];128 $clymJson[' clym']['widget']['script'] = $clymBkp['clym']['widget']['script'];129 $clymJson[' clym']['widget']['location'] = $clymBkp['clym']['widget']['location'];47 $clymJson['have_account'] = $clymBkp['have_account']; 48 $clymJson['language']['default'] = $clymBkp['language']['default']; 49 $clymJson['meta_tag'] = $clymBkp['meta_tag']; 50 $clymJson['widget']['script'] = $clymBkp['widget']['script']; 51 $clymJson['widget']['location'] = $clymBkp['widget']['location']; 130 52 update_option('clym', json_encode($clymJson)); 131 53 } 132 clym_detect_active_plugins();133 54 } 134 55 135 register_activation_hook(__FILE__, 'clym_install _plugin');56 register_activation_hook(__FILE__, 'clym_install'); 136 57 137 function clym_delete_plugin() 58 59 function clym_delete() 138 60 { 139 61 delete_option('clym'); 140 62 } 141 63 142 register_uninstall_hook(__FILE__, 'clym_delete _plugin');64 register_uninstall_hook(__FILE__, 'clym_delete'); 143 65 144 $TEMPLATE_DIR = 'templates/desktop/';145 //if (wp_is_mobile()) {146 // $TEMPLATE_DIR = 'templates/mobile/';147 //}148 66 149 function clym_ general_settings()67 function clym_admin() 150 68 { 151 init_clym_admin_scripts(); 152 global $TEMPLATE_DIR; 153 include $TEMPLATE_DIR . 'general.php'; 154 69 if (!is_admin()) return; 70 require_once plugin_dir_path(__FILE__) . 'admin/clym-admin.php'; 155 71 } 156 72 157 function init_clym_admin_scripts()73 function clym_admin_menu() 158 74 { 159 wp_register_style('clym_desktop_css', plugins_url('templates/desktop/css/style.css', __FILE__), array(), 'v1.3.1'); 160 wp_enqueue_style('clym_desktop_css'); 161 wp_register_script('clym_desktop_script', plugins_url('templates/desktop/js/style.js', __FILE__), array(), 'v1.3.1'); 162 wp_enqueue_script('clym_desktop_script'); 75 $notification = get_option('clym_notification'); 76 77 add_menu_page('Clym', 78 $notification ? 'Clym <span class="awaiting-mod">' . $notification . '</span>' : 'Clym', 79 'manage_options', 80 'clym-admin', 81 'clym_admin', 82 plugins_url('admin/img/icon.png', __FILE__), 83 80); 163 84 } 85 86 add_action('admin_menu', 'clym_admin_menu'); 87 164 88 165 89 function clym_validate_request($data) 166 90 { 167 if (!isset($data[' field'])) return false;168 $field = $data[' field'];91 if (!isset($data['key'])) return false; 92 $field = $data['key']; 169 93 $value = $data['value']; 170 94 switch ($field) { 171 case ' clym_lang':95 case 'lang': 172 96 { 173 97 $languages = array("en", "ro"); … … 175 99 break; 176 100 } 177 case ' clym_meta_tag':101 case 'meta_tag': 178 102 { 179 103 if (isset($value) && strlen($value) > 80) return false; 180 104 break; 181 105 } 182 case ' clym_widget':106 case 'widget': 183 107 { 184 108 $location = array("head", "footer"); … … 188 112 break; 189 113 } 190 case ' clym_plugin':114 case 'plugin': 191 115 { 192 116 if (isset($value)) { … … 196 120 break; 197 121 } 198 case ' clym_account':122 case 'account': 199 123 { 200 124 return true; … … 211 135 { 212 136 $clym = json_decode(get_option('clym'), true); 213 214 137 $data = $_POST['data']; 215 138 $status = 'error'; 216 139 if (clym_validate_request($data)) { 217 140 $status = 'success'; 218 $field = $data[' field'];141 $field = $data['key']; 219 142 $value = $data['value']; 220 143 switch ($field) { 221 case ' clym_lang':144 case 'lang': 222 145 { 223 $clym[' clym']['defaultLanguage'] = $value;146 $clym['defaultLanguage'] = $value; 224 147 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT)); 225 148 break; 226 149 } 227 case ' clym_meta_tag':150 case 'meta_tag': 228 151 { 229 $clym[' clym']['meta_tag'] = stripslashes_deep($value);230 $clym[' clym']['have_account'] = true;152 $clym['meta_tag'] = stripslashes_deep($value); 153 $clym['have_account'] = true; 231 154 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT)); 232 155 break; 233 156 } 234 case ' clym_widget':157 case 'widget': 235 158 { 236 $clym[' clym']['widget']['script'] = stripslashes_deep($value['script']);237 $clym[' clym']['widget']['location'] = $value['location'];238 $clym[' clym']['have_account'] = true;159 $clym['widget']['script'] = stripslashes_deep($value['script']); 160 $clym['widget']['location'] = $value['location']; 161 $clym['have_account'] = true; 239 162 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT)); 240 break; 241 } 242 case 'clym_plugin': 243 { 244 $value = stripslashes_deep($value); 245 for ($i = 0; count($clym['clym']['plugins']); $i++) { 246 if ($clym['clym']['plugins'][$i]['key'] === $value) { 247 if (!$clym['clym']['plugins'][$i]['is_added']) 248 $clym['clym']['plugins'][$i]['is_added'] = true; 249 if (!in_array($value, $clym['clym']['configured_plugins'])) 250 array_push($clym['clym']['configured_plugins'], $value); 251 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT)); 252 break; 253 } 254 } 255 $notification = 0; 256 if (count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']) > 0) 257 $notification = count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']); 258 update_option('clym_notification', $notification); 163 clym_create_request(); 259 164 break; 260 165 } 261 166 case 'clym_account': 262 167 { 263 $clym[' clym']['have_account'] = true;168 $clym['have_account'] = true; 264 169 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT)); 265 170 } … … 273 178 274 179 add_action("wp_ajax_clym_update_option", "clym_update_option"); 275 276 /**277 * Add Clym in settings menu278 */279 function clym_admin_menu()280 {281 $notification = get_option('clym_notification');282 283 add_menu_page('Clym',284 $notification ? 'Clym <span class="awaiting-mod">' . $notification . '</span>' : 'Clym',285 'manage_options',286 'clym-general-settings',287 'clym_general_settings',288 plugins_url('/img/icon.png', __FILE__),289 80);290 }291 292 add_action('admin_menu', 'clym_admin_menu');293 294 function detect_plugin_activation($plugin)295 {296 $clym = json_decode(get_option('clym'), true);297 $is_active = 'deactivated_plugin' === current_filter() ? false : true;298 $found_plugin = false;299 for ($i = 0; $i < count($clym['clym']['plugins']); $i++) {300 unset($clym['clym']['plugins'][$i]['scripts_found']['js']);301 $clym['clym']['plugins'][$i]['scripts_found']['js'] = array();302 if ($clym['clym']['plugins'][$i]['key'] === $plugin) {303 $found_plugin = true;304 $clym['clym']['plugins'][$i]['is_active'] = $is_active;305 if ($is_active) {306 array_push($clym['clym']['active_plugins'], $plugin);307 } else {308 if (($key = array_search($plugin, $clym['clym']['active_plugins'])) !== false) {309 unset($clym['clym']['active_plugins'][$key]);310 }311 }312 }313 }314 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT));315 clym_create_request();316 if ($found_plugin) {317 if ($is_active) clym_create_request();318 $notification = 0;319 if (count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']) > 0) {320 $notification = count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']);321 if ($is_active)322 update_option('clym_alert', "show");323 }324 update_option('clym_notification', $notification);325 }326 }327 328 add_action('activated_plugin', 'detect_plugin_activation', 10);329 add_action('deactivated_plugin', 'detect_plugin_activation', 10);330 331 332 -
clym/tags/2.0/readme.txt
r1958174 r1970870 1 1 === Clym - GDPR Cookie Consent Management === 2 2 Contributors: Clym.io 3 Stable tag: 1.33 Stable tag: 2.0 4 4 Tags: cookie consent, gdpr cookie consent, consent, gdpr, compliance, cookie notice, subjects requests, general data protection regulation, data privacy 5 5 Requires at least: 4 … … 85 85 = 1.2 = Add mobile version 86 86 = 1.3 = Add old settings 87 = 2.0 = Change design 87 88 88 89 == Changelog == … … 91 92 1.2 Add mobile version 92 93 1.3 Add old settings 94 2.0 Change design -
clym/trunk/clym.php
r1958203 r1970870 5 5 Description: One platform for global privacy needs. Manage Cookies, Consent, Subjects’ Requests, Policies, Terms and prove compliance through consent receipts. 6 6 Author: Clym.io 7 Version: 1.37 Version: 2.0 8 8 Author URI: https://www.clym.io/category/product-updates 9 9 */ 10 10 // Make sure we don't expose any info if called directly 11 $CLYM_VERSION = '1.3'; 11 $CLYM_VERSION = '2.0'; 12 12 13 if (!defined('ABSPATH')) { 13 14 echo 'Hi there! I\'m just a plugin, not much I can do when called directly.'; 14 15 exit; 15 16 } 17 18 if (!is_admin()) { 19 require_once plugin_dir_path(__FILE__) . 'public/clym-public.php'; 20 } 21 16 22 if (is_admin()) { 17 23 $clym = json_decode(get_option('clym'), true); 18 24 if ($clym['clym']['version'] !== $CLYM_VERSION) { 19 clym_install _plugin();25 clym_install(); 20 26 } 21 27 } 22 function clym_inject_meta_tag()23 {24 $clym = json_decode(get_option('clym'), true);25 if (strlen($clym['clym']['meta_tag']) > 0)26 echo $clym['clym']['meta_tag'];27 }28 29 add_action('wp_head', 'clym_inject_meta_tag', 1);30 31 function clym_inject_widget()32 {33 $clym = json_decode(get_option('clym'), true);34 if (strlen($clym['clym']['widget']['script']) > 0)35 echo $clym['clym']['widget']['script'];36 }37 38 add_action('wp_' . json_decode(get_option('clym'), true)['clym']['widget']['location'], 'clym_inject_widget');39 40 function clym_block_scripts()41 {42 global $wp_scripts;43 $clym = json_decode(get_option('clym'), true);44 if (strlen($clym['clym']['widget']['script']) === 0) return;45 foreach ($wp_scripts->queue as $handle) {46 if (in_array($wp_scripts->registered[$handle]->src, $clym['clym']['found']['js']))47 unset($wp_scripts->registered[$handle]);48 }49 }50 51 add_action('wp_print_scripts', 'clym_block_scripts');52 53 function clym_detect_scripts()54 {55 global $wp_scripts;56 if (is_admin()) return;57 $clym = json_decode(get_option('clym'), true);58 if ($clym['clym']['key'] !== $_GET['clym']) return;59 $plugins = $clym['clym']['plugins'];60 $scripts = array();61 foreach ($wp_scripts->queue as $handle) {62 for ($i = 0; $i < count($plugins); $i++) {63 $found = false;64 for ($j = 0; $j < count($plugins[$i]['blacklist']['js']); $j++) {65 if (strpos($wp_scripts->registered[$handle]->src, $plugins[$i]['blacklist']['js'][$j])) {66 $found = true;67 }68 }69 if ($found) {70 array_push($scripts, $wp_scripts->registered[$handle]->src);71 array_push($plugins[$i]['scripts_found']['js'], $wp_scripts->registered[$handle]->src);72 }73 }74 }75 $clym['clym']['plugins'] = $plugins;76 $clym['clym']['found']['js'] = $scripts;77 update_option('clym', json_encode($clym));78 $notification = 0;79 if (count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']) > 0)80 $notification = count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']);81 update_option('clym_notification', $notification);82 }83 84 add_action('wp_print_scripts', 'clym_detect_scripts');85 28 86 29 function clym_create_request() … … 88 31 $clym = json_decode(get_option('clym'), true); 89 32 $url = get_site_url(); 90 $url .= '?clym =' . $clym['clym']['key'];33 $url .= '?clym_request=' . $clym['key']; 91 34 $WP_Http = new WP_Http(); 92 35 $WP_Http->request($url); 93 36 } 94 37 95 function clym_ detect_active_plugins()38 function clym_install() 96 39 { 97 $clym = json_decode(get_option('clym'), true); 98 $plugins = $clym['clym']['plugins']; 99 $active_plugins = array(); 100 for ($i = 0; $i < count($plugins); $i++) { 101 if (in_array($plugins[$i]['key'], get_option('active_plugins'))) { 102 $plugins[$i]['is_active'] = true; 103 array_push($active_plugins, $plugins[$i]['key']); 104 } else { 105 $plugins[$i]['is_active'] = false; 106 } 107 } 108 $clym['clym']['plugins'] = $plugins; 109 $clym['clym']['active_plugins'] = $active_plugins; 110 update_option('clym', json_encode($clym)); 111 clym_create_request(); 112 clym_create_request(); 113 } 114 115 116 function clym_install_plugin() 117 { 118 $clym = file_get_contents(plugins_url('settings/config.json', __FILE__)); 40 $clym = file_get_contents(plugins_url('includes/config.json', __FILE__)); 119 41 $clymJson = json_decode($clym, true); 120 $clymJson[' clym']['key'] = substr(str_shuffle(str_repeat($key = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(64 / strlen($key)))), 1, 64);42 $clymJson['key'] = substr(str_shuffle(str_repeat($key = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(64 / strlen($key)))), 1, 64); 121 43 if (!get_option('clym')) { 122 44 update_option('clym', json_encode($clymJson)); 123 45 } else { 124 46 $clymBkp = json_decode(get_option('clym'), true); 125 $clymJson[' clym']['have_account'] = $clymBkp['clym']['have_account'];126 $clymJson[' clym']['defaultLanguage'] = $clymBkp['clym']['defaultLanguage'];127 $clymJson[' clym']['meta_tag'] = $clymBkp['clym']['meta_tag'];128 $clymJson[' clym']['widget']['script'] = $clymBkp['clym']['widget']['script'];129 $clymJson[' clym']['widget']['location'] = $clymBkp['clym']['widget']['location'];47 $clymJson['have_account'] = $clymBkp['have_account']; 48 $clymJson['language']['default'] = $clymBkp['language']['default']; 49 $clymJson['meta_tag'] = $clymBkp['meta_tag']; 50 $clymJson['widget']['script'] = $clymBkp['widget']['script']; 51 $clymJson['widget']['location'] = $clymBkp['widget']['location']; 130 52 update_option('clym', json_encode($clymJson)); 131 53 } 132 clym_detect_active_plugins();133 54 } 134 55 135 register_activation_hook(__FILE__, 'clym_install _plugin');56 register_activation_hook(__FILE__, 'clym_install'); 136 57 137 function clym_delete_plugin() 58 59 function clym_delete() 138 60 { 139 61 delete_option('clym'); 140 62 } 141 63 142 register_uninstall_hook(__FILE__, 'clym_delete _plugin');64 register_uninstall_hook(__FILE__, 'clym_delete'); 143 65 144 $TEMPLATE_DIR = 'templates/desktop/';145 //if (wp_is_mobile()) {146 // $TEMPLATE_DIR = 'templates/mobile/';147 //}148 66 149 function clym_ general_settings()67 function clym_admin() 150 68 { 151 init_clym_admin_scripts(); 152 global $TEMPLATE_DIR; 153 include $TEMPLATE_DIR . 'general.php'; 154 69 if (!is_admin()) return; 70 require_once plugin_dir_path(__FILE__) . 'admin/clym-admin.php'; 155 71 } 156 72 157 function init_clym_admin_scripts()73 function clym_admin_menu() 158 74 { 159 wp_register_style('clym_desktop_css', plugins_url('templates/desktop/css/style.css', __FILE__), array(), 'v1.3.1'); 160 wp_enqueue_style('clym_desktop_css'); 161 wp_register_script('clym_desktop_script', plugins_url('templates/desktop/js/style.js', __FILE__), array(), 'v1.3.1'); 162 wp_enqueue_script('clym_desktop_script'); 75 $notification = get_option('clym_notification'); 76 77 add_menu_page('Clym', 78 $notification ? 'Clym <span class="awaiting-mod">' . $notification . '</span>' : 'Clym', 79 'manage_options', 80 'clym-admin', 81 'clym_admin', 82 plugins_url('admin/img/icon.png', __FILE__), 83 80); 163 84 } 85 86 add_action('admin_menu', 'clym_admin_menu'); 87 164 88 165 89 function clym_validate_request($data) 166 90 { 167 if (!isset($data[' field'])) return false;168 $field = $data[' field'];91 if (!isset($data['key'])) return false; 92 $field = $data['key']; 169 93 $value = $data['value']; 170 94 switch ($field) { 171 case ' clym_lang':95 case 'lang': 172 96 { 173 97 $languages = array("en", "ro"); … … 175 99 break; 176 100 } 177 case ' clym_meta_tag':101 case 'meta_tag': 178 102 { 179 103 if (isset($value) && strlen($value) > 80) return false; 180 104 break; 181 105 } 182 case ' clym_widget':106 case 'widget': 183 107 { 184 108 $location = array("head", "footer"); … … 188 112 break; 189 113 } 190 case ' clym_plugin':114 case 'plugin': 191 115 { 192 116 if (isset($value)) { … … 196 120 break; 197 121 } 198 case ' clym_account':122 case 'account': 199 123 { 200 124 return true; … … 211 135 { 212 136 $clym = json_decode(get_option('clym'), true); 213 214 137 $data = $_POST['data']; 215 138 $status = 'error'; 216 139 if (clym_validate_request($data)) { 217 140 $status = 'success'; 218 $field = $data[' field'];141 $field = $data['key']; 219 142 $value = $data['value']; 220 143 switch ($field) { 221 case ' clym_lang':144 case 'lang': 222 145 { 223 $clym[' clym']['defaultLanguage'] = $value;146 $clym['defaultLanguage'] = $value; 224 147 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT)); 225 148 break; 226 149 } 227 case ' clym_meta_tag':150 case 'meta_tag': 228 151 { 229 $clym[' clym']['meta_tag'] = stripslashes_deep($value);230 $clym[' clym']['have_account'] = true;152 $clym['meta_tag'] = stripslashes_deep($value); 153 $clym['have_account'] = true; 231 154 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT)); 232 155 break; 233 156 } 234 case ' clym_widget':157 case 'widget': 235 158 { 236 $clym[' clym']['widget']['script'] = stripslashes_deep($value['script']);237 $clym[' clym']['widget']['location'] = $value['location'];238 $clym[' clym']['have_account'] = true;159 $clym['widget']['script'] = stripslashes_deep($value['script']); 160 $clym['widget']['location'] = $value['location']; 161 $clym['have_account'] = true; 239 162 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT)); 240 break; 241 } 242 case 'clym_plugin': 243 { 244 $value = stripslashes_deep($value); 245 for ($i = 0; count($clym['clym']['plugins']); $i++) { 246 if ($clym['clym']['plugins'][$i]['key'] === $value) { 247 if (!$clym['clym']['plugins'][$i]['is_added']) 248 $clym['clym']['plugins'][$i]['is_added'] = true; 249 if (!in_array($value, $clym['clym']['configured_plugins'])) 250 array_push($clym['clym']['configured_plugins'], $value); 251 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT)); 252 break; 253 } 254 } 255 $notification = 0; 256 if (count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']) > 0) 257 $notification = count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']); 258 update_option('clym_notification', $notification); 163 clym_create_request(); 259 164 break; 260 165 } 261 166 case 'clym_account': 262 167 { 263 $clym[' clym']['have_account'] = true;168 $clym['have_account'] = true; 264 169 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT)); 265 170 } … … 273 178 274 179 add_action("wp_ajax_clym_update_option", "clym_update_option"); 275 276 /**277 * Add Clym in settings menu278 */279 function clym_admin_menu()280 {281 $notification = get_option('clym_notification');282 283 add_menu_page('Clym',284 $notification ? 'Clym <span class="awaiting-mod">' . $notification . '</span>' : 'Clym',285 'manage_options',286 'clym-general-settings',287 'clym_general_settings',288 plugins_url('/img/icon.png', __FILE__),289 80);290 }291 292 add_action('admin_menu', 'clym_admin_menu');293 294 function detect_plugin_activation($plugin)295 {296 $clym = json_decode(get_option('clym'), true);297 $is_active = 'deactivated_plugin' === current_filter() ? false : true;298 $found_plugin = false;299 for ($i = 0; $i < count($clym['clym']['plugins']); $i++) {300 unset($clym['clym']['plugins'][$i]['scripts_found']['js']);301 $clym['clym']['plugins'][$i]['scripts_found']['js'] = array();302 if ($clym['clym']['plugins'][$i]['key'] === $plugin) {303 $found_plugin = true;304 $clym['clym']['plugins'][$i]['is_active'] = $is_active;305 if ($is_active) {306 array_push($clym['clym']['active_plugins'], $plugin);307 } else {308 if (($key = array_search($plugin, $clym['clym']['active_plugins'])) !== false) {309 unset($clym['clym']['active_plugins'][$key]);310 }311 }312 }313 }314 update_option('clym', json_encode($clym, JSON_FORCE_OBJECT));315 clym_create_request();316 if ($found_plugin) {317 if ($is_active) clym_create_request();318 $notification = 0;319 if (count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']) > 0) {320 $notification = count($clym['clym']['active_plugins']) - count($clym['clym']['configured_plugins']);321 if ($is_active)322 update_option('clym_alert', "show");323 }324 update_option('clym_notification', $notification);325 }326 }327 328 add_action('activated_plugin', 'detect_plugin_activation', 10);329 add_action('deactivated_plugin', 'detect_plugin_activation', 10);330 331 332 -
clym/trunk/readme.txt
r1958174 r1970870 1 1 === Clym - GDPR Cookie Consent Management === 2 2 Contributors: Clym.io 3 Stable tag: 1.33 Stable tag: 2.0 4 4 Tags: cookie consent, gdpr cookie consent, consent, gdpr, compliance, cookie notice, subjects requests, general data protection regulation, data privacy 5 5 Requires at least: 4 … … 85 85 = 1.2 = Add mobile version 86 86 = 1.3 = Add old settings 87 = 2.0 = Change design 87 88 88 89 == Changelog == … … 91 92 1.2 Add mobile version 92 93 1.3 Add old settings 94 2.0 Change design
Note: See TracChangeset
for help on using the changeset viewer.