Plugin Directory

Changeset 2782403


Ignore:
Timestamp:
09/09/2022 11:28:23 AM (4 years ago)
Author:
bpassini
Message:

v1.2.0

Location:
gdpr-helper
Files:
28 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • gdpr-helper/trunk/README.md

    r2779731 r2782403  
    55Requires at least: 4.7
    66Tested up to: 6.0.2
    7 Stable tag: 1.1.1
     7Stable tag: 1.2.0
    88Requires PHP: 7.0
    99License: GPLv3
     
    2424== Changelog ==
    2525
     26= 1.2.0 =
     27
     28- add custom Elementor widget: 2-click shortcode (Requires consent from users before showing the shortcode)
    2629
    2730= 1.1.1 =
    2831
    2932- fix bug that prevented the plugin to be uninstalled
    30 
    3133
    3234= 1.1.0 =
  • gdpr-helper/trunk/css/frontend_style.css

    r2779727 r2782403  
    1 .gh__map-container {
     1.gh__widget_placeholder-container {
    22  display: flex;
    33  align-items: center;
     
    88}
    99
    10 .gh__map-container img {
     10.gh__widget_placeholder-container img {
    1111  object-fit: cover;
    1212}
    1313
    14 .gh__map-container .gh__show-tooltip-button {
     14.gh__widget_placeholder-container .gh__show-tooltip-button {
    1515  position: absolute;
    1616  bottom: 20%;
     
    2121}
    2222
    23 .gh__map-container .gh__show-tooltip-button:hover {
     23.gh__widget_placeholder-container .gh__show-tooltip-button:hover {
    2424  background: #efefef;
    2525  color: black;
    2626}
    2727
    28 .gh__map-container .gh__tooltip-container {
     28.gh__widget_placeholder-container .gh__tooltip-container {
    2929  display: none;
    3030  flex-direction: column;
     
    3636}
    3737
    38 .gh__map-container .gh__tooltip-container .gh__buttons-container {
     38.gh__widget_placeholder-container .gh__tooltip-container .gh__buttons-container {
    3939  display: flex;
    4040  justify-content: space-evenly;
    4141}
    4242
    43 .gh__map-container
     43.gh__widget_placeholder-container
    4444  .gh__tooltip-container
    4545  .gh__buttons-container
    4646  .gh__hide-tooltip-button,
    47 .gh__map-container
     47.gh__widget_placeholder-container
    4848  .gh__tooltip-container
    4949  .gh__buttons-container
     
    5757}
    5858
    59 .gh__map-container
     59.gh__widget_placeholder-container
    6060  .gh__tooltip-container
    6161  .gh__buttons-container
  • gdpr-helper/trunk/includes/backendPage.php

    r2779727 r2782403  
    5454    wp_enqueue_media();
    5555
    56     wp_enqueue_script('gh__backend_js', GH__PLUGIN_URL . '/js/backend_script.js', [], GH__CURRENT_VERSION, true);
     56    wp_enqueue_script('gh__backend_js', GH__PLUGIN_URL . '/js/backend_script.js', array('jquery'), GH__CURRENT_VERSION, true);
    5757    wp_enqueue_style('gh__backend_css', GH__PLUGIN_URL . '/css/backend_style.css', [], GH__CURRENT_VERSION);
    5858}
     
    191191{
    192192    foreach ($new_value as $key => $value) {
    193         $sanitized_value = preg_replace('/\R/u', ' ', $value);
    194 
    195         // Sanitize directive value, see https://www.w3.org/TR/CSP3/#framework-directives
    196         $regex = '/[^\x21-\x2B\x2D-\x3A\x3C-\x7E\x09\x20]/u';
    197         $sanitized_value = preg_replace($regex, '', $sanitized_value);
    198 
     193        $sanitized_value = $value;
     194
     195        if ($key == GH__SETTINGS_FIELDS__CSP_STRING) {
     196            // Sanitize directive value, see https://www.w3.org/TR/CSP3/#framework-directives
     197            $regex = '/[^\x21-\x2B\x2D-\x3A\x3C-\x7E\x09\x20\n;]/u';
     198            $sanitized_value = preg_replace($regex, '', $value);
     199            // The newlines will be stripped before setting the http header. Leaving the in here will make it more readable for the user inside the texarea
     200        }
    199201        $new_value[$key] = $sanitized_value;
    200202    }
     
    276278                        </td>
    277279                        <td>
    278                             <code>default-src 'self' 'unsafe-inline' data:</code>
     280                            <code>default-src 'self' data:</code>
    279281                        </td>
    280282                    </tr>
     
    300302                                connect-src 'self';<br />
    301303                                frame-src 'none';<br />
    302                                 img-src https://openlayers.org https://tile.openstreetmap.org http://a.tile.openstreetmap.org http://b.tile.openstreetmap.org http://c.tile.openstreetmap.org;<br />
    303                                 script-src 'unsafe-eval' 'unsafe-inline' https://openlayers.org;<br />
    304                                 style-src 'unsafe-inline' https://openlayers.org;
     304                                img-src 'self' https://openlayers.org https://tile.openstreetmap.org http://a.tile.openstreetmap.org http://b.tile.openstreetmap.org http://c.tile.openstreetmap.org;<br />
     305                                script-src 'self' 'unsafe-eval' 'unsafe-inline' https://openlayers.org;<br />
     306                                style-src 'self' 'unsafe-inline' https://openlayers.org;
    305307                            </code>
    306308                        </td>
     
    404406
    405407?>
    406     <textarea id='id__<?php echo $field_name; ?>' name='<?php echo $name ?>' rows='5' cols='50'><?php echo $value; ?></textarea>
     408    <textarea id='id__<?php echo $field_name; ?>' name='<?php echo $name ?>' rows='10' cols='100'><?php echo $value; ?></textarea>
    407409    <br />
    408410    <label for='id__<?php echo $field_name; ?>'><?php echo $label_text; ?></label>
  • gdpr-helper/trunk/includes/ghMain.php

    r2779727 r2782403  
    99{
    1010    require_once(GH__PLUGIN_INCLUDES_PATH . '/includes/magicStrings.php');
     11    require_once(GH__PLUGIN_INCLUDES_PATH . '/includes/elementor/helper.php');
    1112
    1213    add_action('init', 'gdprhelper__load_language_domain');
    1314
    14     $option = get_option(GH__SETTINGS_PAGE__ID);
     15    add_action('init', 'gdprhelper__set_cookies');
     16
    1517    $is_backend = is_admin() && !wp_doing_ajax();
    1618
     
    1921        gdprhelper__main_backend($pluginfile);
    2022    } else {
    21         wp_enqueue_script('gh__frontend_js', GH__PLUGIN_URL . '/js/frontend_script.js', [], GH__CURRENT_VERSION, true);
     23        wp_enqueue_script('gh__frontend_js', GH__PLUGIN_URL . '/js/frontend_script.js', array('jquery'), GH__CURRENT_VERSION, true);
    2224        wp_enqueue_style('gh__frontend_css', GH__PLUGIN_URL . '/css/frontend_style.css', [], GH__CURRENT_VERSION);
    23    
    24     }
    25 
    26     // Check for additional settings
    27     if (gdprhelper__option_equals_value($option, GH__SETTINGS_FIELDS__MAPS_HELPER_ENABLED, true)) {
    28         require_once(GH__PLUGIN_INCLUDES_PATH . '/includes/mapHandler.php');
    29         gdprhelper__map_handler__entry($pluginfile);
    30     }
     25    }
     26
     27    add_action('init', 'gdprhelper__load_in_init');
    3128
    3229    // Lastly set the correct CSP header
    3330    add_action('init', 'gdprhelper__setHeader');
     31}
     32
     33function gdprhelper__load_in_init()
     34{
     35    if (gdprhelper__helper__is_elementor_installed_and_active()) {
     36        // Load map placeholder if enabled
     37        $option = get_option(GH__SETTINGS_PAGE__ID);
     38        if (gdprhelper__option_equals_value($option, GH__SETTINGS_FIELDS__MAPS_HELPER_ENABLED, true)) {
     39            require_once(GH__PLUGIN_INCLUDES_PATH . '/includes/elementor/mapHandler.php');
     40            gdprhelper__map_handler__entry();
     41        }
     42
     43        // Add custom Elementor widgets
     44        require_once(GH__PLUGIN_INCLUDES_PATH . '/includes/elementor/widgetShortcode.php');
     45        gdprhelper__custom_elementor__entry();
     46    }
     47}
     48
     49function gdprhelper__set_cookies()
     50{
     51    if (isset($_GET[GH__COOKIES__PRIVACY_POLICY_ACCEPTED]) && ($_GET[GH__COOKIES__PRIVACY_POLICY_ACCEPTED] == 'true')) {
     52        $id = (int) $_GET['id'];
     53        check_admin_referer(GH__COOKIES__PRIVACY_POLICY_ACCEPTED . $id);
     54
     55        setcookie(GH__COOKIES__PRIVACY_POLICY_ACCEPTED, 'yes', 0, COOKIEPATH, COOKIE_DOMAIN); // Session cookie
     56
     57        $url = $_SERVER['REQUEST_URI'];
     58        $scrollto = $_REQUEST['scrollto'];
     59        $url = remove_query_arg(array(GH__COOKIES__PRIVACY_POLICY_ACCEPTED, 'scrollto', 'id', '_wpnonce'), $url);
     60        $url = add_query_arg('clearcache', $id . '#' . $scrollto, $url);
     61        wp_redirect($url);
     62
     63        die();
     64    }
    3465}
    3566
     
    72103
    73104    // Checks
    74     if ($_COOKIE[GH__COOKIES__ALLOW_MAP]) {
     105    if ($_COOKIE[GH__COOKIES__PRIVACY_POLICY_ACCEPTED]) {
    75106        $maps_enabled = true;
    76107    }
  • gdpr-helper/trunk/includes/magicStrings.php

    r2779731 r2782403  
    33defined('ABSPATH') || die('error');
    44
    5 const GH__CURRENT_VERSION = '1.1.1';
     5const GH__CURRENT_VERSION = '1.2.0';
    66const GH__TEXT_DOMAIN = 'gdpr-helper';
    77
     
    2121
    2222// Cookies
    23 const GH__COOKIES__ALLOW_MAP = 'gh_cookies_allow_map';
     23const GH__COOKIES__PRIVACY_POLICY_ACCEPTED = 'gh_cookies_privacy_policy_accepted';
     24
     25// Elementor
     26const GH__ELEMENTOR__SHORTCODE__NAME = 'gh_shortcode';
     27const GH__ELEMENTOR__SHORTCODE__CONTROL_SHORTCODE = 'gh_shortcode_control_shortcode';
     28const GH__ELEMENTOR__SHORTCODE__CONTROL_TEXT = 'gh_shortcode_control_text';
     29const GH__ELEMENTOR__SHORTCODE__CONTROL_HEIGHT = 'gh_shortcode_control_height';
     30const GH__ELEMENTOR__SHORTCODE__CONTROL_IMAGE = 'gh_shortcode_control_image';
  • gdpr-helper/trunk/js/frontend_script.js

    r2779727 r2782403  
    11jQuery(document).ready(function (e) {
    2     jQuery('.gh__map-container button.gh__show-tooltip-button').on('click', function () {
    3         jQuery('.gh__map-container .gh__tooltip-container').css('display', 'flex');
     2    jQuery('.gh__widget_placeholder-container button.gh__show-tooltip-button').on('click', function () {
     3        jQuery(this).parent().find('.gh__tooltip-container').css('display', 'flex');
     4        jQuery(this).parent().find('button.gh__show-tooltip-button').css('display', 'none');
    45    });
    56
    6     jQuery('.gh__map-container .gh__tooltip-container .gh__hide-tooltip-button').on('click', function () {
    7         jQuery('.gh__map-container .gh__tooltip-container').css('display', 'none');
     7    jQuery('.gh__widget_placeholder-container .gh__tooltip-container .gh__hide-tooltip-button').on('click', function () {
     8        jQuery(this).parents('.gh__tooltip-container').css('display', 'none');
     9        jQuery(this).parents('.gh__widget_placeholder-container').find('button.gh__show-tooltip-button').css('display', 'block');
    810    });
    911});
Note: See TracChangeset for help on using the changeset viewer.