Plugin Directory

Changeset 2023805


Ignore:
Timestamp:
02/02/2019 02:58:11 PM (7 years ago)
Author:
antsanchez
Message:

Update to version 2.4

Location:
easy-cookie-law/trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • easy-cookie-law/trunk/class/easy-cookie-law.php

    r2019905 r2023805  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    24
    35class EasyCookieLaw {
     
    57    const ECL_COOKIE_NAME = "easy-cookie-law";
    68    const ECL_OPTIONS_DB = "ecl_options";
    7     const ECL_OPTIONS = array(
    8         "ecl_text"              => "Cookies help us deliver our services. By using our services, you agree to our use of cookies.",
    9         "ecl_link"              => "http://www.aboutcookies.org/",
    10         "ecl_link_text"         => "More Info",
    11         "ecl_link_target"       => "_blank",
    12         "ecl_close"             => "Close",
    13         "ecl_position"          => "bottom",
    14         "ecl_custom"            => 0,
    15         "ecl_noticecolor"       => "#ffffff",
    16         "ecl_textcolor"         => "#000000",
    17         "ecl_linkscolor"        => "#b30000",
    18         "ecl_gtm_header"        => "",
    19         "ecl_gtm_body"          => "",
    20         "ecl_custom_func"       => 0
    21     );
     9    const ECL_SETTINGS = [
     10        "ecl_text" => [
     11            "default"   => "Cookies help us deliver our services. By using our services, you agree to our use of cookies.",
     12            "sanitize"  => "sanitize_text_field",
     13            "escape"    => "esc_textarea"
     14        ],
     15        "ecl_link" => [
     16            "default"   => "http://www.aboutcookies.org/",
     17            "sanitize"  => "esc_url",
     18            "escape"    => "esc_url"
     19        ],
     20        "ecl_link_text" => [
     21            "default"   => "More Info",
     22            "sanitize"  => "sanitize_text_field",
     23            "escape"    => "esc_textarea"
     24        ],
     25        "ecl_link_target" => [
     26            "default"   => "_blank",
     27            "sanitize"  => "esc_attr",
     28            "escape"    => "esc_attr"
     29        ],
     30        "ecl_close" => [
     31            "default"   => "Close",
     32            "sanitize"  => "sanitize_text_field",
     33            "escape"    => "esc_textarea"
     34        ],
     35        "ecl_position" => [
     36            "default"   => "bottom",
     37            "sanitize"  => "esc_attr",
     38            "escape"    => "esc_attr"
     39        ],
     40        "ecl_custom" => [
     41            "default"   => 0,
     42            "sanitize"  => "ecl_to_int",
     43            "escape"    => "ecl_to_int"
     44        ],
     45        "ecl_noticecolor" => [
     46            "default"   => "#ffffff",
     47            "sanitize"  => "esc_attr",
     48            "escape"    => "esc_attr"
     49        ],
     50        "ecl_textcolor" => [
     51            "default"   => "#000000",
     52            "sanitize"  => "esc_attr",
     53            "escape"    => "esc_attr"
     54        ],
     55        "ecl_linkscolor" => [
     56            "default"   => "#b30000",
     57            "sanitize"  => "esc_attr",
     58            "escape"    => "esc_attr"
     59        ],
     60        "ecl_gtm_header" => [
     61            "default"   => "",
     62            "sanitize"  => 'ecl_sanitize_js',
     63            "escape"    => 'ecl_escape_js'
     64        ],
     65        "ecl_gtm_body" => [
     66            "default"   => "",
     67            "sanitize"  => 'ecl_sanitize_js',
     68            "escape"    => 'ecl_sanitize_js'
     69        ],
     70        "ecl_custom_func" => [
     71            "default"   => 0,
     72            "sanitize"  => "ecl_to_int",
     73            "escape"    => "ecl_to_int"
     74        ],
     75        "ecl_hide_admin" => [
     76            "default"   => 1,
     77            "sanitize"  => "ecl_to_int",
     78            "escape"    => "ecl_to_int"
     79        ],
     80        "ecl_hide_editor" => [
     81            "default"   => 1,
     82            "sanitize"  => "ecl_to_int",
     83            "escape"    => "ecl_to_int"
     84        ],
     85        "ecl_hide_author" => [
     86            "default"   => 1,
     87            "sanitize"  => "ecl_to_int",
     88            "escape"    => "ecl_to_int"
     89        ],
     90    ];
    2291    const ECL_GTM_HP = "&lt;script&gt;(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    2392        new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
     
    2998    private $options;
    3099   
     100    /**
     101     * Load the options variable
     102     */
    31103    function __construct()
    32104    {
     
    34106    }
    35107
    36     private function allowedTags()
    37     {
    38         return array_merge(
    39             wp_kses_allowed_html( 'post' ),
    40             array(
    41                 'iframe' => array(
    42                     'allowfullscreen' => array(),
    43                     'frameborder' => array(),
    44                     'height' => array(),
    45                     'src' => array(),
    46                     'width' => array(),
    47                 ),
    48                 'noscript' => array(),
    49                 "script" => array(
    50                     'async' => array(),
    51                     'charset' => array(),
    52                     'src' => array(),
    53                     'type' => array()
    54                 ),
    55                 'style' => array(
    56                     'type' => array()
    57                 )
    58             )
    59         );
    60     }
    61 
    62     /**
    63      * Get and format data from DB
     108    /**
     109     * Returns an array extracting the values from the indicated keys
     110     * from the subarrays
     111     *
     112     * @var array $array Array to be used
     113     * @var string $field_name Name of the field to be extracted
     114     * @return array
     115     */
     116    private function extractFromArray($array, $field_name)
     117    {
     118        $options = [];
     119        foreach($array as $key => $value)
     120        {
     121            $options[$key] = $value[$field_name];
     122        }
     123        return $options;
     124    }
     125
     126    /**
     127     * Get the default options and values
     128     *
     129     * @return array
     130     */
     131    private function defaultOptions()
     132    {
     133        return self::extractFromArray(self::ECL_SETTINGS, 'default');
     134    }
     135
     136    /**
     137     * Get the default options and and sanitize functions names
     138     *
     139     * @return array
     140     */
     141    private function formSanitizeFields()
     142    {
     143        return self::extractFromArray(self::ECL_SETTINGS, 'sanitize');
     144    }
     145
     146    /**
     147     * Get the default options and and escape functions names
     148     *
     149     * @return array
     150     */
     151    private function formEscapeFields()
     152    {
     153        return self::extractFromArray(self::ECL_SETTINGS, 'escape');
     154    }
     155
     156    /**
     157     * Get options from DB
     158     * If a option is not saved, use the default values
    64159     */
    65160    private function getOptions()
    66161    {
    67         $ecl_options = get_option(self::ECL_OPTIONS_DB, self::ECL_OPTIONS);
    68 
    69         $this->options['text']          = esc_textarea($ecl_options['ecl_text']);
    70         $this->options['link']          = esc_url($ecl_options['ecl_link']);
    71         $this->options['link_text']     = esc_textarea($ecl_options['ecl_link_text']);
    72         $this->options['link_target']   = esc_attr($ecl_options['ecl_link_target']);
    73         $this->options['close']         = esc_textarea($ecl_options['ecl_close']);
    74         $this->options['position']      = esc_textarea($ecl_options['ecl_position']);
    75         $this->options['custom']        = esc_attr($ecl_options['ecl_custom']);
    76         $this->options['noticecolor']   = esc_attr($ecl_options['ecl_noticecolor']);
    77         $this->options['textcolor']     = esc_attr($ecl_options['ecl_textcolor']);
    78         $this->options['linkscolor']    = esc_attr($ecl_options['ecl_linkscolor']);
    79         $this->options['gtm_header']    = self::escapeJS($ecl_options['ecl_gtm_header']);
    80         $this->options['gtm_body']      = self::escapeJS($ecl_options['ecl_gtm_body']);
    81         $this->options['custom_func']   = esc_attr($ecl_options['ecl_custom_func']);
    82     }
    83 
    84     /**
    85      * Print the cookie notice and all needed JS and CSS for the visitor
     162        $default_options = $this->defaultOptions();
     163        $ecl_options = get_option(self::ECL_OPTIONS_DB, $default_options);
     164
     165        // In case any options is missing
     166        foreach($default_options as $key => $value)
     167        {
     168            if(!isset($ecl_options[$key]))
     169            {
     170                $ecl_options[$key] = $value;
     171            }
     172        }
     173
     174        // Escape the options
     175        $escape_fields = $this->formEscapeFields();
     176        foreach($escape_fields as $key => $value)
     177        {
     178            $name = str_replace('ecl_', '', $key);
     179            $this->options[$name] = $value($ecl_options[$key]);
     180        }
     181    }
     182
     183    /**
     184     * Print the JS and CSS needed for the notice
    86185     */
    87186    public function printNotice()
     
    114213    }
    115214
     215    /**
     216     * Print the notice on the footer
     217     */
    116218    public function printFooterNotice()
    117219    {
     220        if(self::hideForUser()){
     221            return;
     222        }
     223
    118224        $ecl_style_otuput = "";
    119225        if( $this->options['custom'] == 0 ) {
     
    144250    }
    145251
    146     // Sanitize JS before saving it to DB
    147     private function sanitizeJS($input)
    148     {
    149         return wp_kses($input, self::allowedTags());
    150     }
    151 
    152     // Escape JS before echoing it
    153     private function escapeJS($input)
    154     {
    155         return stripslashes_deep( html_entity_decode( trim( self::sanitizeJS($input) ) ) );
    156     }
    157 
     252    /**
     253     * Print the GTM header script
     254     */
    158255    public function printGtmHeader()
    159256    {
    160257        if(!empty($this->options['gtm_header']) )
    161258        {
    162             echo self::escapeJS($this->options['gtm_header']);
     259            echo $this->options['gtm_header'];
    163260        }
    164261    }
     
    166263    /**
    167264     * Collects the POST options and saves it to DB
     265     * Echoes a success message
    168266     */
    169267    public function saveOptions()
     
    171269
    172270        // Save options if form was sended
    173         if( isset($_POST['ecl_save_data']) ) {
    174 
    175             $ecl_options = self::ECL_OPTIONS;
    176 
    177             if(isset($_POST['ecltext'])){
    178                 $ecl_options['ecl_text'] = sanitize_text_field($_POST['ecltext']);
    179             }
    180             if(isset($_POST['ecllink'])){
    181                 $ecl_options['ecl_link'] = esc_url($_POST['ecllink']);
    182             }
    183             if(isset($_POST['ecllinktext'])){
    184                 $ecl_options['ecl_link_text'] = sanitize_text_field($_POST['ecllinktext']);
    185             }
    186             if(isset($_POST['eclclose'])){
    187                 $ecl_options['ecl_close'] = sanitize_text_field($_POST['eclclose']);
    188             }
    189             if(isset($_POST['eclposition'])){
    190                 $ecl_options['ecl_position'] = esc_attr($_POST['eclposition']);
    191             }
    192             if(isset($_POST['eclcustom'])){
    193                 $ecl_options['ecl_custom'] = esc_attr($_POST['eclcustom']);
    194             }
    195             if(isset($_POST['eclnoticecolor'])){
    196                 $ecl_options['ecl_noticecolor'] = esc_attr($_POST['eclnoticecolor']);
    197             }
    198             if(isset($_POST['ecltextcolor'])){
    199                 $ecl_options['ecl_textcolor'] = esc_attr($_POST['ecltextcolor']);
    200             }
    201             if(isset($_POST['ecllinkscolor'])){
    202                 $ecl_options['ecl_linkscolor'] = esc_attr($_POST['ecllinkscolor']);
    203             }
    204             if(isset($_POST['ecl_link_target'])){
    205                 $ecl_options['ecl_link_target'] = esc_attr($_POST['ecl_link_target']);
    206             }
    207             if(isset($_POST['ecl_gtm_header'])){
    208                 $ecl_gtm_header = str_replace("<script>", "", $_POST['ecl_gtm_header']);
    209                 $ecl_gtm_header = str_replace("</script>", "", $ecl_gtm_header);
    210                 $ecl_options['ecl_gtm_header'] = self::sanitizeJS($ecl_gtm_header);
    211             }
    212             if(isset($_POST['ecl_gtm_body'])){
    213                 $ecl_options['ecl_gtm_body'] = self::sanitizeJS($_POST['ecl_gtm_body']);
    214             }
    215             if(isset($_POST['ecl_custom_func'])){
    216                 $ecl_options['ecl_custom_func'] = esc_attr($_POST['ecl_custom_func']);
    217             }
    218 
    219             echo "<div class='wrap' id='saved'>" . __('Saved!', 'easy-cookie-law') . "</div>";
     271        if( isset($_POST['ecl_save_data']) )
     272        {
     273            $ecl_options = self::getOptions();
     274            $fields = self::formSanitizeFields();
     275            foreach($fields as $key => $value)
     276            {
     277                if(isset($_POST[$key]))
     278                {
     279                    $ecl_options[$key] = $value($_POST[$key]);
     280                }
     281                else
     282                {
     283                    $ecl_options[$key] = false;
     284                }
     285            }
     286
     287            // Remove script tags from gtm_header
     288            $ecl_options['ecl_gtm_header'] = str_replace("<script>", "", $ecl_options['ecl_gtm_header']);
     289            $ecl_options['ecl_gtm_header'] = str_replace("<script type=\"text/javascript\">", "", $ecl_options['ecl_gtm_header']);
     290            $ecl_options['ecl_gtm_header'] = str_replace("</script>", "", $ecl_options['ecl_gtm_header']);
    220291
    221292            update_option("ecl_options", $ecl_options);
     293            echo "<div class='wrap' id='ecl_saved'>" . __('Saved!', 'easy-cookie-law') . "</div>";
    222294        }
    223295    }
     
    243315                <div class="caja">
    244316                <div class="form-box">
    245                     <label for="ecltext"><?php echo __('Message', 'easy-cookie-law'); ?></label>
    246                     <textarea rows="5" name="ecltext" id="ecltext"><?php echo $this->options["text"]; ?></textarea>
     317                    <label for="ecl_text"><?php echo __('Message', 'easy-cookie-law'); ?></label>
     318                    <textarea rows="5" name="ecl_text" id="ecl_text"><?php echo $this->options["text"]; ?></textarea>
    247319                    <em><?php echo __("People will see this notice only if the use of cookies has not been accepted yet", "easy-cookie-law"); ?></em><br>
    248320                </div>
     
    252324                <div class="caja">
    253325                <div class="form-box">
    254                     <label for="ecllink"><?php echo __('More Info URL', 'easy-cookie-law'); ?></label>
    255                     <input type="url" name="ecllink" id="ecllink" value="<?php echo $this->options["link"]; ?>" />
    256                 </div>
    257                 <div class="form-box">
    258                     <label for="ecllinktext"><?php echo __('More Info text (text showed in the link)', 'easy-cookie-law'); ?></label>
    259                     <input type="text" name="ecllinktext" id="ecllinktext" value="<?php echo $this->options["link_text"]; ?>" />
    260                 </div>
    261                 <div class="form-box">
    262                     <label for="ecllinktarget"><?php echo __('Target of the link', 'easy-cookie-law'); ?></label>
    263                     <select name="ecllinktarget">
     326                    <label for="ecl_link"><?php echo __('More Info URL', 'easy-cookie-law'); ?></label>
     327                    <input type="url" name="ecl_link" id="ecl_link" value="<?php echo $this->options["link"]; ?>" />
     328                </div>
     329                <div class="form-box">
     330                    <label for="ecl_link_text"><?php echo __('More Info text (text showed in the link)', 'easy-cookie-law'); ?></label>
     331                    <input type="text" name="ecl_link_text" id="ecl_link_text" value="<?php echo $this->options["link_text"]; ?>" />
     332                </div>
     333                <div class="form-box">
     334                    <label for="ecl_link_target"><?php echo __('Target of the link', 'easy-cookie-law'); ?></label>
     335                    <select name="ecl_link_target">
    264336                        <option value="_blank" <?php if($this->options["link_target"] == "_blank") : ?> selected <?php endif; ?>><?php echo __("New tab or windows", 'easy-cookie-law'); ?></option>
    265337                        <option value="_self" <?php if($this->options["link_target"] == "_self") : ?> selected <?php endif; ?>><?php echo __("Same window", 'easy-cookie-law'); ?></option>
     
    267339                </div>
    268340                <div class="form-box">
    269                     <label for="eclclose"><?php echo __('Text for the link to close the message', 'easy-cookie-law'); ?></label>
    270                     <input type="text" name="eclclose" id="eclclose" value="<?php echo $this->options["close"]; ?>" />
     341                    <label for="ecl_close"><?php echo __('Text for the link to close the message', 'easy-cookie-law'); ?></label>
     342                    <input type="text" name="ecl_close" id="ecl_close" value="<?php echo $this->options["close"]; ?>" />
    271343                </div>
    272344                </div>
     
    275347                <div class="caja">
    276348                <div class="form-box">
    277                     <label for="eclposition"><?php echo __('Position of the notice', 'easy-cookie-law'); ?></label>
     349                    <label for="ecl_position"><?php echo __('Position of the notice', 'easy-cookie-law'); ?></label>
    278350                    <?php $top = $this->options['position'] == "top" ? 1 : 2 ; ?>
    279                     <input type="radio" name="eclposition" value="top" <?php if($top == "1"): ?>checked<?php endif; ?>><?php echo __('Top', 'easy-cookie-law'); ?></input>
    280                     &nbsp; <input type="radio" name="eclposition" value="bottom" <?php if($top == "2"): ?>checked<?php endif; ?>><?php echo __('Bottom', 'easy-cookie-law'); ?></input>
    281                 </div>
    282                 <div class="form-box">
    283                     <label for="eclnoticecolor"><?php echo __('Background color of the notice', 'easy-cookie-law'); ?></label>
    284                     <input type="color" name="eclnoticecolor" id="eclnoticecolor" value="<?php echo $this->options["noticecolor"]; ?>" />
    285                 </div>
    286                 <div class="form-box">
    287                     <label for="ecltextcolor"><?php echo __('Text color of the notice', 'easy-cookie-law'); ?></label>
    288                     <input type="color" name="ecltextcolor" id="ecltextcolor" value="<?php echo $this->options["textcolor"]; ?>" />
    289                 </div>
    290                 <div class="form-box">
    291                     <label for="ecllinkscolor"><?php echo __('Links color of the notice', 'easy-cookie-law'); ?></label>
    292                     <input type="color" name="ecllinkscolor" id="ecllinkscolor" value="<?php echo $this->options["linkscolor"]; ?>" />
     351                    <input type="radio" name="ecl_position" value="top" <?php if($top == "1"): ?>checked<?php endif; ?>><?php echo __('Top', 'easy-cookie-law'); ?></input>
     352                    &nbsp; <input type="radio" name="ecl_position" value="bottom" <?php if($top == "2"): ?>checked<?php endif; ?>><?php echo __('Bottom', 'easy-cookie-law'); ?></input>
     353                </div>
     354                <div class="form-box">
     355                    <label for="ecl_noticecolor"><?php echo __('Background color of the notice', 'easy-cookie-law'); ?></label>
     356                    <input type="color" name="ecl_noticecolor" id="ecl_noticecolor" value="<?php echo $this->options["noticecolor"]; ?>" />
     357                </div>
     358                <div class="form-box">
     359                    <label for="ecl_textcolor"><?php echo __('Text color of the notice', 'easy-cookie-law'); ?></label>
     360                    <input type="color" name="ecl_textcolor" id="ecl_textcolor" value="<?php echo $this->options["textcolor"]; ?>" />
     361                </div>
     362                <div class="form-box">
     363                    <label for="ecl_linkscolor"><?php echo __('Links color of the notice', 'easy-cookie-law'); ?></label>
     364                    <input type="color" name="ecl_linkscolor" id="ecl_linkscolor" value="<?php echo $this->options["linkscolor"]; ?>" />
    293365                </div>
    294366                </div>
     
    297369                <div class="caja">
    298370                <div class="form-box-check">
    299                     <label for="eclcustom"><?php echo __('Let me use my own CSS', 'easy-cookie-law'); ?></label>
    300                     <input type="checkbox" name="eclcustom" id="eclcustom" value='1' <?php if($this->options['custom'] == 1){ echo "checked";} ?> />
     371                    <label for="ecl_custom"><?php echo __('Let me use my own CSS', 'easy-cookie-law'); ?></label>
     372                    <input type="checkbox" name="ecl_custom" id="ecl_custom" value='1' <?php if($this->options['custom'] === 1){ echo "checked";} ?> />
    301373                    <?php echo __('The plugin will not print any styles. Check this if you want to use your custom CSS written in any other stylesheet or inline.<br>All your stlyes should be  using the CSS id #ecl_notice, since it is the only css ID that this plugin uses for the notice.', 'easy-cookie-law'); ?>
     374                </div>
     375                </div>
     376
     377                <!-- Roles -->
     378                <div class="caja">
     379                <div class="form-box-check">
     380                    <label for="ecl_hide_admin">
     381                        <input type="checkbox" name="ecl_hide_admin" id="ecl_hide_admin" value='1' <?php if($this->options['hide_admin'] == 1){ echo "checked";} ?> />
     382                        <?php echo __('Remove notice and tracking code for admins', 'easy-cookie-law'); ?>
     383                    </label>
     384                </div>
     385                <div class="form-box-check">
     386                    <label for="ecl_hide_editor">
     387                        <input type="checkbox" name="ecl_hide_editor" id="ecl_hide_editor" value='1' <?php if($this->options['hide_editor'] == 1){ echo "checked";} ?> />
     388                        <?php echo __('Remove notice and tracking code for editors', 'easy-cookie-law'); ?>
     389                    </label>
     390                </div>
     391                <div class="form-box-check">
     392                    <label for="ecl_hide_author">
     393                        <input type="checkbox" name="ecl_hide_author" id="ecl_hide_author" value='1' <?php if($this->options['hide_author'] == 1){ echo "checked";} ?> />
     394                        <?php echo __('Remove notice and tracking code for registered users', 'easy-cookie-law'); ?>
     395                    </label>
    302396                </div>
    303397                </div>
     
    331425                <div class="form-box-check">
    332426                    <label for="ecl_custom_func"><?php echo __('Let me manually print the GMT code for the header where I want', 'easy-cookie-law'); ?></label>
    333                     <input type="checkbox" name="ecl_custom_func" id="ecl_custom_func" value='1' <?php if($this->options['custom_func'] == 1){ echo "checked";} ?> />
     427                    <input type="checkbox" name="ecl_custom_func" id="ecl_custom_func" value='1' <?php if($this->options['custom_func'] === 1){ echo "checked";} ?> />
    334428                    <em>
    335429                        <?php echo __('Check this if you want to modify your theme to print the GMT header code where you want. For this, you have to put this function where you want to print the code:', 'easy-cookie-law'); ?><br>
    336                         <pre><code>&lt;?php if(function_exists('ecl_print_all')) ecl_print_all(); ?&gt;;</code></pre>
     430                        <pre><code>&lt;?php if(function_exists('ecl_print_all')) ecl_print_all(); ?&gt;</code></pre>
    337431                        <?php echo __('This function will print he GMT code for the header in the position you want, instead of using the wp_head action hook. Normally you should use this if you want to print the code on the top of your &lt;head&gt;; tag, as Google recommends.', 'easy-cookie-law'); ?>
    338432                    </em>
     
    352446    }
    353447
     448    /**
     449     * Returns false if the visitor should be able to see the notice based on its role
     450     *
     451     * @return boolean
     452     */
     453    private function hideForUser()
     454    {
     455        $current_user = wp_get_current_user();
     456       
     457        if($this->options['hide_admin'] == 1 && in_array('administrator', $current_user->roles))
     458        {
     459            return true;
     460        }
     461
     462        if($this->options['hide_editor'] == 1 && in_array('editor', $current_user->roles))
     463        {
     464            return true;
     465        }
     466
     467        if($this->options['hide_author'] == 1 && in_array('author', $current_user->roles))
     468        {
     469            return true;
     470        }
     471
     472        return false;
     473    }
     474
     475    /**
     476     * Get the GTM body script
     477     *
     478     * @return string
     479     */
    354480    public function returnBodyScripts()
    355481    {
    356         return $this->options['gtm_body'];
    357     }
    358 
    359     // Using same format for function name as in JS
     482        if( !self::hideForUser() ){
     483            return $this->options['gtm_body'];
     484        }
     485    }
     486
     487    /**
     488     * Check if cookies are accepted
     489     * This function use same format for the name as in JS for usability reasons
     490     *
     491     * @return boolean
     492     */
    360493    public function is_cookie_accepted()
    361494    {
     
    363496    }
    364497
     498     /**
     499     * Check if the wp_head action hook should be used
     500     *
     501     * @return boolean
     502     */
    365503    public function useWPHeadHook()
    366504    {
     
    369507            return true;
    370508        }
    371         else
    372         {
    373             return false;
    374         }
     509       
     510        return false;
    375511    }
    376512}
  • easy-cookie-law/trunk/css/ecl-style.css

    r2019898 r2023805  
    2222}
    2323
    24 .ecl_options #saved{
     24#ecl_saved{
    2525    background-color: #449d44;
    2626    color: #fff;
  • easy-cookie-law/trunk/easy-cookie-law.php

    r2019905 r2023805  
    44 * Description: Minimal code to help your website respect the cookie law
    55 * Plugin URI: https://antsanchez.com
    6  * Version: 2.3
     6 * Version: 2.4
    77 * Author: antsanchez
    88 * Author URI: https://antsanchez.com
     
    2727*/
    2828
     29if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
     30
    2931// Include Class
     32include_once( plugin_dir_path( __FILE__ ) . 'functions/functions.php');
    3033include_once( plugin_dir_path( __FILE__ ) . 'class/easy-cookie-law.php');
    3134
     
    7578    $ecl_plugin->printForm();
    7679}
    77 
    7880
    7981/**
  • easy-cookie-law/trunk/languages/easy-cookie-law-es_ES.po

    r2019898 r2023805  
    22msgstr ""
    33"Project-Id-Version: Easy Cookie Law\n"
    4 "POT-Creation-Date: 2019-01-27 13:56+0100\n"
    5 "PO-Revision-Date: 2019-01-27 13:57+0100\n"
     4"POT-Creation-Date: 2019-02-02 15:25+0100\n"
     5"PO-Revision-Date: 2019-02-02 15:25+0100\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    2222"X-Poedit-SearchPathExcluded-0: *.js\n"
    2323
    24 #: class/easy-cookie-law.php:223
     24#: class/easy-cookie-law.php:291
    2525msgid "Saved!"
    2626msgstr "¡Guardado!"
    2727
    28 #: class/easy-cookie-law.php:243
     28#: class/easy-cookie-law.php:309
    2929msgid "Easy Cookie Law Menu Options"
    3030msgstr "Menú de opciones de Easy Cookie Law"
    3131
    32 #: class/easy-cookie-law.php:249
     32#: class/easy-cookie-law.php:315
    3333msgid "Message"
    3434msgstr "Mensaje"
    3535
    36 #: class/easy-cookie-law.php:251
     36#: class/easy-cookie-law.php:317
    3737msgid ""
    3838"People will see this notice only if the use of cookies has not been accepted "
     
    4242"todavía"
    4343
    44 #: class/easy-cookie-law.php:258
     44#: class/easy-cookie-law.php:324
    4545msgid "More Info URL"
    4646msgstr "Más Info URL"
    4747
    48 #: class/easy-cookie-law.php:262
     48#: class/easy-cookie-law.php:328
    4949msgid "More Info text (text showed in the link)"
    5050msgstr "Más información texto (texto mostrado en el enlace)"
    5151
    52 #: class/easy-cookie-law.php:266
     52#: class/easy-cookie-law.php:332
    5353msgid "Target of the link"
    5454msgstr "Objetivo del enlace"
    5555
    56 #: class/easy-cookie-law.php:268
     56#: class/easy-cookie-law.php:334
    5757msgid "New tab or windows"
    5858msgstr "Nueva pestaña o ventanas"
    5959
    60 #: class/easy-cookie-law.php:269
     60#: class/easy-cookie-law.php:335
    6161msgid "Same window"
    6262msgstr "Misma ventana"
    6363
    64 #: class/easy-cookie-law.php:273
     64#: class/easy-cookie-law.php:339
    6565msgid "Text for the link to close the message"
    6666msgstr "Texto del vínculo para cerrar el mensaje"
    6767
    68 #: class/easy-cookie-law.php:281
     68#: class/easy-cookie-law.php:347
    6969msgid "Position of the notice"
    7070msgstr "Posición del aviso"
    7171
    72 #: class/easy-cookie-law.php:283
     72#: class/easy-cookie-law.php:349
    7373msgid "Top"
    7474msgstr "Arriba"
    7575
    76 #: class/easy-cookie-law.php:284
     76#: class/easy-cookie-law.php:350
    7777msgid "Bottom"
    7878msgstr "Abajo"
    7979
    80 #: class/easy-cookie-law.php:287
     80#: class/easy-cookie-law.php:353
    8181msgid "Background color of the notice"
    8282msgstr "Color de fondo del aviso"
    8383
    84 #: class/easy-cookie-law.php:291
     84#: class/easy-cookie-law.php:357
    8585msgid "Text color of the notice"
    8686msgstr "Color del texto del aviso"
    8787
    88 #: class/easy-cookie-law.php:295
     88#: class/easy-cookie-law.php:361
    8989msgid "Links color of the notice"
    9090msgstr "Color de los links del aviso"
    9191
    92 #: class/easy-cookie-law.php:303
     92#: class/easy-cookie-law.php:369
    9393msgid "Let me use my own CSS"
    9494msgstr "Permítanme usar mi propio CSS"
    9595
    96 #: class/easy-cookie-law.php:305
     96#: class/easy-cookie-law.php:371
    9797msgid ""
    9898"The plugin will not print any styles. Check this if you want to use your "
     
    106106"único ID CSS que este plugin utiliza para el aviso."
    107107
    108 #: class/easy-cookie-law.php:311
     108#: class/easy-cookie-law.php:380
     109msgid "Remove notice and tracking code for admins"
     110msgstr "Eliminar el aviso y el código de seguimiento para los administradores"
     111
     112#: class/easy-cookie-law.php:386
     113msgid "Remove notice and tracking code for editors"
     114msgstr "Eliminar el aviso y el código de seguimiento para los editores"
     115
     116#: class/easy-cookie-law.php:392
     117msgid "Remove notice and tracking code for registered users"
     118msgstr ""
     119"Eliminar el aviso y el código de seguimiento para los usuarios registrados"
     120
     121#: class/easy-cookie-law.php:399
    109122msgid "Optional: Google Tag Manager"
    110123msgstr "Opcional: Google Tag Manager"
    111124
    112 #: class/easy-cookie-law.php:313
     125#: class/easy-cookie-law.php:401
    113126msgid ""
    114127"If you use Google Tag Manager, you can put the code here below and this "
     
    120133"uso de cookies."
    121134
    122 #: class/easy-cookie-law.php:318
     135#: class/easy-cookie-law.php:406
    123136msgid "Code after the opening of the &lt;head&gt; tag:"
    124137msgstr "Código después de la apertura de la etiqueta  &lt;head&gt; :"
    125138
    126 #: class/easy-cookie-law.php:320
     139#: class/easy-cookie-law.php:408
    127140msgid ""
    128141"Introduce the code withouth &lt;script&gt;&lt;/script&gt; tags. The plugin "
     
    132145"plugin bloqueará la ejecución del código hasta que se acepten las cookies"
    133146
    134 #: class/easy-cookie-law.php:323
     147#: class/easy-cookie-law.php:411
    135148msgid "Code after the opening of the &lt;body&gt; tag:"
    136149msgstr "Código después de la apertura de la etiqueta &lt;body&gt; :"
    137150
    138 #: class/easy-cookie-law.php:326
     151#: class/easy-cookie-law.php:414
    139152msgid ""
    140153"This requires a tiny manual action from your side: you need to put the "
     
    144157"siguientes líneas de PHP en su tema:"
    145158
    146 #: class/easy-cookie-law.php:328
     159#: class/easy-cookie-law.php:416
    147160msgid ""
    148161"Normally, you must put this only in your 'header.php' file, directly after "
     
    154167"dependiendo de su tema."
    155168
    156 #: class/easy-cookie-law.php:330
     169#: class/easy-cookie-law.php:418
    157170#, php-format
    158171msgid ""
     
    165178"target=„_blank“>support forum</a>."
    166179
    167 #: class/easy-cookie-law.php:336
     180#: class/easy-cookie-law.php:424
    168181msgid "Let me manually print the GMT code for the header where I want"
    169182msgstr "Permíteme imprimir manualmente el código GMT del hacer donde quiera"
    170183
    171 #: class/easy-cookie-law.php:339
     184#: class/easy-cookie-law.php:427
    172185msgid ""
    173186"Check this if you want to modify your theme to print the GMT header code "
     
    179192"quieras imprimir el código:"
    180193
    181 #: class/easy-cookie-law.php:341
     194#: class/easy-cookie-law.php:429
    182195msgid ""
    183196"This function will print he GMT code for the header in the position you "
     
    191204"etiqueta &lt;head&gt; como recomienda Google."
    192205
    193 #: class/easy-cookie-law.php:349
     206#: class/easy-cookie-law.php:437
    194207msgid "Update"
    195208msgstr "Actualizar"
    196209
    197 #: easy-cookie-law.php:70
     210#: easy-cookie-law.php:71
    198211msgid "You do not have sufficient permissions to access this page."
    199212msgstr "No tienes suficientes permisos para acceder a esta página."
  • easy-cookie-law/trunk/readme.txt

    r2019905 r2023805  
    55Requires PHP: 5.2
    66Tested up to: 5.0.3
    7 Stable tag: 2.3
     7Stable tag: 2.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7070== Changelog ==
    7171
     72= 2.4 =
     73* Added check of user roles
     74* Fixed some PHP Warnings (Thanks to [Łukasz Muchlado](https://bapro.pl))
     75
    7276= 2.3 =
    7377* Fixed some small JavaScript bugs
     
    9296
    9397= 1.7 =
    94 * Bugfix in output string submitted by Giomba (www.ilgiomba.it)
     98* Bugfix in output string (Thanks to [Giomba](www.ilgiomba.it))
    9599
    96100= 1.6 =
     
    108112= 1.0 =
    109113* First published version.
    110 
    111 == Upgrade Notice ==
    112 = 2.2 =
    113 * Added support for Google Tag Manager
Note: See TracChangeset for help on using the changeset viewer.