Plugin Directory

Changeset 872141


Ignore:
Timestamp:
03/09/2014 11:14:56 AM (12 years ago)
Author:
versvs
Message:

Cookie verification client-side

Location:
cartograf-cookie-filter/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cartograf-cookie-filter/trunk/cartograf-cookie-filter.php

    r846932 r872141  
    44Plugin URI: http://www.cartograf.net/plugin-wordpress-cumplir-ley-de-cookies-espana
    55Description: Previene la instalación de cookies previa al consentimiento informado de los visitantes
    6 Version: 1.0.7
    7 Author: Jose Alcántara & Dima Kam / Cartograf
     6Version: 1.1.0
     7Author: Cartograf
    88Author URI: http://www.cartograf.net
    99Author Email: info@cartograf.net
     
    1414require_once('functions.php');
    1515require_once('settings_page.php');
    16 
    1716
    1817register_activation_hook( __FILE__, 'cg_cf_activate' );
     
    4039add_filter("plugin_action_links_{$plugin}", 'cg_cf_settings_link' );
    4140
    42 function cg_cf_head(){
    43         if (cg_cf_cookie_accepted()){
    44                 cg_cf_head_accepted();
    45         }else{
    46                 cg_cf_head_denied();
    47         }
    48 }
     41// TODO: remove this hook because it is no longer needed.
     42function cg_cf_head(){}
    4943add_action('wp_head','cg_cf_head',999999+2);
    5044
    5145function cg_cf_foot(){
    52         if (cg_cf_cookie_accepted()){
    53                 cg_cf_foot_accepted();
    54         }else{
    55                 cg_cf_foot_denied();
    56                 cg_cf_cookie_bar();
    57                 cg_cf_code_templates();
    58         }
     46        cg_cf_cookie_bar();
     47        cg_cf_code_templates();
    5948}
    6049add_action('wp_footer','cg_cf_foot',999999+2);
    6150
    6251function cg_cf_enqueue_script() {
    63         if (!cg_cf_cookie_accepted()){
    64                 wp_enqueue_script( 'jquery' );
    65                 wp_enqueue_script( 'cg_cookie-filter', plugins_url('cartograf-cookie-filter').'/script.js',array('jquery') );
    66         }
    67 
     52        wp_enqueue_script( 'jquery' );
     53        wp_enqueue_script( 'cg_cookie-filter', plugins_url('cartograf-cookie-filter').'/script.js',array('jquery') );
    6854}
    6955
  • cartograf-cookie-filter/trunk/functions.php

    r837080 r872141  
    11<?php
    2 function cg_cf_cookie_accepted(){
    3     return !empty($_COOKIE['cg_cookie_accepted']);
    4 }
    5 
    62function cg_cf_cookie_bar(){
    73    $text = get_option('cg_cf_text');
     
    2319    );
    2420
    25     echo '<script type="text/template" id="cg_cf_head_template">/*!* ';
     21    echo '<script type="text/template" id="cg_cf_head_template_accepted">/*!* ';
    2622        echo str_replace($replace['from'],$replace['to'],cg_cf_get_head_accepted());
    2723    echo ' *!*/</script>';
    28     echo '<script type="text/template" id="cg_cf_foot_template">/*!* ';
     24    echo '<script type="text/template" id="cg_cf_head_template_denied">/*!* ';
     25        echo str_replace($replace['from'],$replace['to'],cg_cf_get_head_denied());
     26    echo ' *!*/</script>';
     27    echo '<script type="text/template" id="cg_cf_foot_template_accepted">/*!* ';
    2928        echo str_replace($replace['from'],$replace['to'],cg_cf_get_foot_accepted());
     29    echo ' *!*/</script>';
     30    echo '<script type="text/template" id="cg_cf_foot_template_denied">/*!* ';
     31        echo str_replace($replace['from'],$replace['to'],cg_cf_get_foot_denied());
    3032    echo ' *!*/</script>';
    3133}
     
    3638}
    3739
    38 function cg_cf_head_accepted(){
    39     echo cg_cf_get_head_accepted();
    40 }
    41 
    4240function cg_cf_get_head_denied(){
    4341    $code = get_option('cg_cf_head_denied_code');
    4442    return $code;
    45 }
    46 
    47 function cg_cf_head_denied(){
    48     echo cg_cf_get_head_denied();
    4943}
    5044
     
    5448}
    5549
    56 function cg_cf_foot_accepted(){
    57     echo cg_cf_get_foot_accepted();
    58 }
    59 
    6050function cg_cf_get_foot_denied(){
    6151    $code = get_option('cg_cf_foot_denied_code');
    6252    return $code;
    63 }
    64 
    65 function cg_cf_foot_denied(){
    66     echo cg_cf_get_foot_denied();
    6753}
    6854
  • cartograf-cookie-filter/trunk/readme.txt

    r846932 r872141  
    66Requires at least: 3.6
    77Tested up to: 3.8.1
    8 Stable tag: 1.0.7
     8Stable tag: 1.1.0
    99License: GPLv3 or later
    1010License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    5555== Changelog ==
    5656
     57= 1.1.0 =
     58* Cookie checking is now implemented client-side, to make the plugin compatible with cache plugins. Thanks to Sergio Folgar (/sfolgar) for this contribution.
     59
    5760= 1.0.7 =
    5861* Added info about compatibility with cache plugins
     
    8184* Overwrite previous version of the plugin.
    8285
     86== Contributors ==
     87
     88* Jose Alcántara
     89* Dima Kam
     90* Sergio Folgar
     91
    8392
    8493== About Cartograf ==
  • cartograf-cookie-filter/trunk/script.js

    r837080 r872141  
    2525            });
    2626        }
    27    
     27
     28        insertTemplatesDenied();
     29    } else {
     30        cookies_accepted();
    2831    }
    2932});
     
    3538        hide_cookie_bar();
    3639        jQuery('a').unbind('click',cookies_accepted);
    37         insertTemplates();
     40        insertTemplatesAccepted();
    3841    }
    3942}
     
    6770function needToCheckCookie(){
    6871    var userDate = new Date();
    69     timezone = -(userDate.getTimezoneOffset()/60);
     72    var timezone = -(userDate.getTimezoneOffset()/60);
     73    var cookie_preset = document.cookie.indexOf('cg_cookie_accepted=1') >= 0;
    7074
    71     var result = timezone>=0 && timezone<=3;
     75    var result = timezone>=0 && timezone<=3 && !cookie_preset;
    7276
    7377    return result;
    7478}
    7579
    76 function insertTemplates(){
     80function insertTemplatesAccepted(){
     81    insertTemplates('accepted');
     82}
     83
     84function insertTemplatesDenied(){
     85    insertTemplates('denied');
     86}
     87
     88function insertTemplates(sufix){
    7789    var templates = [
    78         'cg_cf_head_template',
    79         'cg_cf_foot_template'
     90        'cg_cf_head_template_' + sufix,
     91        'cg_cf_foot_template_' + sufix
    8092    ];
    8193    for(var i=0; i < templates.length; i++){
  • cartograf-cookie-filter/trunk/style.css

    r837080 r872141  
    11#cg_cookie_bar {
     2    display: none;
    23    position:fixed;
    34    top:0px;
Note: See TracChangeset for help on using the changeset viewer.