Plugin Directory

Changeset 1970870


Ignore:
Timestamp:
11/08/2018 11:34:20 AM (7 years ago)
Author:
clym
Message:

tagging version 2.0

Location:
clym
Files:
78 added
2 deleted
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • clym/tags/2.0/clym.php

    r1958203 r1970870  
    55Description: One platform for global privacy needs. Manage Cookies, Consent, Subjects’ Requests, Policies, Terms and prove compliance through consent receipts.
    66Author: Clym.io
    7 Version: 1.3
     7Version: 2.0
    88Author URI: https://www.clym.io/category/product-updates
    99*/
    1010// Make sure we don't expose any info if called directly
    11 $CLYM_VERSION = '1.3';
     11$CLYM_VERSION = '2.0';
     12
    1213if (!defined('ABSPATH')) {
    1314    echo 'Hi there!  I\'m just a plugin, not much I can do when called directly.';
    1415    exit;
    1516}
     17
     18if (!is_admin()) {
     19    require_once plugin_dir_path(__FILE__) . 'public/clym-public.php';
     20}
     21
    1622if (is_admin()) {
    1723    $clym = json_decode(get_option('clym'), true);
    1824    if ($clym['clym']['version'] !== $CLYM_VERSION) {
    19         clym_install_plugin();
     25        clym_install();
    2026    }
    2127}
    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');
    8528
    8629function clym_create_request()
     
    8831    $clym = json_decode(get_option('clym'), true);
    8932    $url = get_site_url();
    90     $url .= '?clym=' . $clym['clym']['key'];
     33    $url .= '?clym_request=' . $clym['key'];
    9134    $WP_Http = new WP_Http();
    9235    $WP_Http->request($url);
    9336}
    9437
    95 function clym_detect_active_plugins()
     38function clym_install()
    9639{
    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__));
    11941    $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);
    12143    if (!get_option('clym')) {
    12244        update_option('clym', json_encode($clymJson));
    12345    } else {
    12446        $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'];
    13052        update_option('clym', json_encode($clymJson));
    13153    }
    132     clym_detect_active_plugins();
    13354}
    13455
    135 register_activation_hook(__FILE__, 'clym_install_plugin');
     56register_activation_hook(__FILE__, 'clym_install');
    13657
    137 function clym_delete_plugin()
     58
     59function clym_delete()
    13860{
    13961    delete_option('clym');
    14062}
    14163
    142 register_uninstall_hook(__FILE__, 'clym_delete_plugin');
     64register_uninstall_hook(__FILE__, 'clym_delete');
    14365
    144 $TEMPLATE_DIR = 'templates/desktop/';
    145 //if (wp_is_mobile()) {
    146 //    $TEMPLATE_DIR = 'templates/mobile/';
    147 //}
    14866
    149 function clym_general_settings()
     67function clym_admin()
    15068{
    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';
    15571}
    15672
    157 function init_clym_admin_scripts()
     73function clym_admin_menu()
    15874{
    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);
    16384}
     85
     86add_action('admin_menu', 'clym_admin_menu');
     87
    16488
    16589function clym_validate_request($data)
    16690{
    167     if (!isset($data['field'])) return false;
    168     $field = $data['field'];
     91    if (!isset($data['key'])) return false;
     92    $field = $data['key'];
    16993    $value = $data['value'];
    17094    switch ($field) {
    171         case 'clym_lang':
     95        case 'lang':
    17296            {
    17397                $languages = array("en", "ro");
     
    17599                break;
    176100            }
    177         case 'clym_meta_tag':
     101        case 'meta_tag':
    178102            {
    179103                if (isset($value) && strlen($value) > 80) return false;
    180104                break;
    181105            }
    182         case 'clym_widget':
     106        case 'widget':
    183107            {
    184108                $location = array("head", "footer");
     
    188112                break;
    189113            }
    190         case 'clym_plugin':
     114        case 'plugin':
    191115            {
    192116                if (isset($value)) {
     
    196120                break;
    197121            }
    198         case 'clym_account':
     122        case 'account':
    199123            {
    200124                return true;
     
    211135{
    212136    $clym = json_decode(get_option('clym'), true);
    213 
    214137    $data = $_POST['data'];
    215138    $status = 'error';
    216139    if (clym_validate_request($data)) {
    217140        $status = 'success';
    218         $field = $data['field'];
     141        $field = $data['key'];
    219142        $value = $data['value'];
    220143        switch ($field) {
    221             case 'clym_lang':
     144            case 'lang':
    222145                {
    223                     $clym['clym']['defaultLanguage'] = $value;
     146                    $clym['defaultLanguage'] = $value;
    224147                    update_option('clym', json_encode($clym, JSON_FORCE_OBJECT));
    225148                    break;
    226149                }
    227             case 'clym_meta_tag':
     150            case 'meta_tag':
    228151                {
    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;
    231154                    update_option('clym', json_encode($clym, JSON_FORCE_OBJECT));
    232155                    break;
    233156                }
    234             case 'clym_widget':
     157            case 'widget':
    235158                {
    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;
    239162                    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();
    259164                    break;
    260165                }
    261166            case 'clym_account':
    262167                {
    263                     $clym['clym']['have_account'] = true;
     168                    $clym['have_account'] = true;
    264169                    update_option('clym', json_encode($clym, JSON_FORCE_OBJECT));
    265170                }
     
    273178
    274179add_action("wp_ajax_clym_update_option", "clym_update_option");
    275 
    276 /**
    277  * Add Clym in settings menu
    278  */
    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  
    11=== Clym - GDPR Cookie Consent Management ===
    22Contributors: Clym.io
    3 Stable tag: 1.3
     3Stable tag: 2.0
    44Tags: cookie consent, gdpr cookie consent, consent, gdpr, compliance, cookie notice, subjects requests, general data protection regulation, data privacy
    55Requires at least: 4
     
    8585= 1.2 = Add mobile version
    8686= 1.3 = Add old settings
     87= 2.0 = Change design
    8788
    8889== Changelog ==
     
    91921.2 Add mobile version
    92931.3 Add old settings
     942.0 Change design
  • clym/trunk/clym.php

    r1958203 r1970870  
    55Description: One platform for global privacy needs. Manage Cookies, Consent, Subjects’ Requests, Policies, Terms and prove compliance through consent receipts.
    66Author: Clym.io
    7 Version: 1.3
     7Version: 2.0
    88Author URI: https://www.clym.io/category/product-updates
    99*/
    1010// Make sure we don't expose any info if called directly
    11 $CLYM_VERSION = '1.3';
     11$CLYM_VERSION = '2.0';
     12
    1213if (!defined('ABSPATH')) {
    1314    echo 'Hi there!  I\'m just a plugin, not much I can do when called directly.';
    1415    exit;
    1516}
     17
     18if (!is_admin()) {
     19    require_once plugin_dir_path(__FILE__) . 'public/clym-public.php';
     20}
     21
    1622if (is_admin()) {
    1723    $clym = json_decode(get_option('clym'), true);
    1824    if ($clym['clym']['version'] !== $CLYM_VERSION) {
    19         clym_install_plugin();
     25        clym_install();
    2026    }
    2127}
    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');
    8528
    8629function clym_create_request()
     
    8831    $clym = json_decode(get_option('clym'), true);
    8932    $url = get_site_url();
    90     $url .= '?clym=' . $clym['clym']['key'];
     33    $url .= '?clym_request=' . $clym['key'];
    9134    $WP_Http = new WP_Http();
    9235    $WP_Http->request($url);
    9336}
    9437
    95 function clym_detect_active_plugins()
     38function clym_install()
    9639{
    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__));
    11941    $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);
    12143    if (!get_option('clym')) {
    12244        update_option('clym', json_encode($clymJson));
    12345    } else {
    12446        $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'];
    13052        update_option('clym', json_encode($clymJson));
    13153    }
    132     clym_detect_active_plugins();
    13354}
    13455
    135 register_activation_hook(__FILE__, 'clym_install_plugin');
     56register_activation_hook(__FILE__, 'clym_install');
    13657
    137 function clym_delete_plugin()
     58
     59function clym_delete()
    13860{
    13961    delete_option('clym');
    14062}
    14163
    142 register_uninstall_hook(__FILE__, 'clym_delete_plugin');
     64register_uninstall_hook(__FILE__, 'clym_delete');
    14365
    144 $TEMPLATE_DIR = 'templates/desktop/';
    145 //if (wp_is_mobile()) {
    146 //    $TEMPLATE_DIR = 'templates/mobile/';
    147 //}
    14866
    149 function clym_general_settings()
     67function clym_admin()
    15068{
    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';
    15571}
    15672
    157 function init_clym_admin_scripts()
     73function clym_admin_menu()
    15874{
    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);
    16384}
     85
     86add_action('admin_menu', 'clym_admin_menu');
     87
    16488
    16589function clym_validate_request($data)
    16690{
    167     if (!isset($data['field'])) return false;
    168     $field = $data['field'];
     91    if (!isset($data['key'])) return false;
     92    $field = $data['key'];
    16993    $value = $data['value'];
    17094    switch ($field) {
    171         case 'clym_lang':
     95        case 'lang':
    17296            {
    17397                $languages = array("en", "ro");
     
    17599                break;
    176100            }
    177         case 'clym_meta_tag':
     101        case 'meta_tag':
    178102            {
    179103                if (isset($value) && strlen($value) > 80) return false;
    180104                break;
    181105            }
    182         case 'clym_widget':
     106        case 'widget':
    183107            {
    184108                $location = array("head", "footer");
     
    188112                break;
    189113            }
    190         case 'clym_plugin':
     114        case 'plugin':
    191115            {
    192116                if (isset($value)) {
     
    196120                break;
    197121            }
    198         case 'clym_account':
     122        case 'account':
    199123            {
    200124                return true;
     
    211135{
    212136    $clym = json_decode(get_option('clym'), true);
    213 
    214137    $data = $_POST['data'];
    215138    $status = 'error';
    216139    if (clym_validate_request($data)) {
    217140        $status = 'success';
    218         $field = $data['field'];
     141        $field = $data['key'];
    219142        $value = $data['value'];
    220143        switch ($field) {
    221             case 'clym_lang':
     144            case 'lang':
    222145                {
    223                     $clym['clym']['defaultLanguage'] = $value;
     146                    $clym['defaultLanguage'] = $value;
    224147                    update_option('clym', json_encode($clym, JSON_FORCE_OBJECT));
    225148                    break;
    226149                }
    227             case 'clym_meta_tag':
     150            case 'meta_tag':
    228151                {
    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;
    231154                    update_option('clym', json_encode($clym, JSON_FORCE_OBJECT));
    232155                    break;
    233156                }
    234             case 'clym_widget':
     157            case 'widget':
    235158                {
    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;
    239162                    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();
    259164                    break;
    260165                }
    261166            case 'clym_account':
    262167                {
    263                     $clym['clym']['have_account'] = true;
     168                    $clym['have_account'] = true;
    264169                    update_option('clym', json_encode($clym, JSON_FORCE_OBJECT));
    265170                }
     
    273178
    274179add_action("wp_ajax_clym_update_option", "clym_update_option");
    275 
    276 /**
    277  * Add Clym in settings menu
    278  */
    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  
    11=== Clym - GDPR Cookie Consent Management ===
    22Contributors: Clym.io
    3 Stable tag: 1.3
     3Stable tag: 2.0
    44Tags: cookie consent, gdpr cookie consent, consent, gdpr, compliance, cookie notice, subjects requests, general data protection regulation, data privacy
    55Requires at least: 4
     
    8585= 1.2 = Add mobile version
    8686= 1.3 = Add old settings
     87= 2.0 = Change design
    8788
    8889== Changelog ==
     
    91921.2 Add mobile version
    92931.3 Add old settings
     942.0 Change design
Note: See TracChangeset for help on using the changeset viewer.