Git Product home page Git Product logo

cookie-notice's Introduction

Cookie Notice by dFactory

Cookie Notice allows you to elegantly inform users that your site uses cookies and to comply with the EU cookie law regulations.

Description

Cookie Notice allows you to elegantly inform users that your site uses cookies and to comply with the EU cookie law regulations.

For more information, check out plugin page at dFactory or plugin support forum.

Features include:

  • Customize the cookie message
  • Redirect users to specified page for more cookie information
  • Set cookie expiry
  • Link to more info page
  • Option to accept cookies on scroll
  • Option to set on scroll offset
  • Option to refuse functional cookies
  • Select the position of the cookie message box
  • Animate the message box after cookie is accepted
  • Select bottons style from None, WordPress and Bootstrap
  • Set the text and bar background colors
  • WPML and Polylang compatible
  • .pot file for translations included

Usage:

If you'd like to code a functionality depending on the cookie notice value use the function below:

if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) { // Your third-party non functional code here }

Get involved

Feel free to contribute to the source code on the dFactory GitHub Repository.

Installation

  1. Install Cookie Notice either via the WordPress.org plugin directory, or by uploading the files to your server
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Go to the Cookie Notice settings and set your options.

Changelog

1.3.1

  • Fix: Unable to select Privacy policy link
  • Fix: Blank Cookies policy link in a message
  • Fix: Undefined index: on_click
  • Tweak: Adjusted default opacity back to 100

1.3.0

  • New: Introducing Corona Banner that displays data about Coronavirus pandemia and five steps recommended by the WHO (World Health Organization)
  • New: Option to set bar opacity
  • New: Accept the notice with close icon
  • Fix: Policy link added to message without policy option enabled

1.2.51

  • Fix: Problems with iOS and OK/Reject button
  • Tweak: Added Separate cookie expiry for Reject, props Carlos Buchart

1.2.50

  • Fix: The body css class always set to "cookies-refused"
  • Tweak: Improve IE & Safari CustomEvent and ClassList support
  • Tweak: Change the plugin js init event

1.2.49

  • New: Option to accept the notice with any page click
  • Tweak: Remove jQuery dependency
  • Tweak: Swtich from jQuery to CSS3 animations
  • Tweak: Improve the CSS and HTML structure

1.2.48

  • Fix: HTML tags stripped from cookie message
  • Fix: Link target not accepted in inline privacy link

1.2.47

  • New: Option to select the privacy policy link position
  • Tweak: Do not relad the page on refuse button click
  • Tweak: Added aria-label attribute to cookie notice container

1.2.46

  • Tweak: Remove WP Super Cache cookie on deactivation
  • Tweak: Remove plugin version from the db on deactivation

1.2.45

  • Tweak: Improved WP Super Cache support
  • Tweak: CSS container style issue and media query for mobile

1.2.44

  • Fix: The text of the revoke button ignored in shortcode
  • Fix: Revoke consent button not displayed automatically in top position
  • Tweak: Add shortcode parsing for content of [cookies_accepted], thanks to dsturm

1.2.43

  • New: Option to revoke the user consent
  • New: Script blocking extended to header and footer
  • New: Synchronization with WordPress 4.9.6 Privacy Policy page
  • New: Custom button class option
  • Tweak: Added 1 hour cookie expiry option

1.2.42

  • New: Introducing [cookies_accepted][/cookies_accepted] shortcode
  • Fix: Infinite cookie expiry issue

1.2.41

  • Fix: Infinite redirection loop with scroll enabled

1.2.40

  • Fix: Div align center on some themes
  • Tweak: Extended list of allowed HTML tags in refuse code
  • Tweak: Minified CSS and JS

1.2.39

  • New: Option to reload the page after cookies are accepted

1.2.38

  • Tweak: Move frontend cookie js functions before the document ready call, thanks to fgreinus
  • Tweak: Adjust functional javascript code handling
  • Fix: Chhromium infinity expiration date not valid
  • Fix: Remove deprecated screen_icon() function

1.2.37

  • Tweak: Add aria landmark role="banner"
  • Tweak: Extend cn_cookie_notice_args with button class

1.2.36.1

  • Fix: Repository upload issue with 1.2.36

1.2.36

  • Fix: String translation support for WMPL 3.2+
  • Fix: Global var possible conflict with other plugins
  • Tweak: Add $options array to "cn_cookie_notice_output" filter, thanks to chesio.
  • Tweak: Removed local translation files in favor of WP repository translations.

1.2.35

  • Tweak: Use html_entity_decode on non-functional code block
  • Tweak: get_pages() function placement optimization
  • Tweak: Filterable manage cookie notice capability

1.2.21

1.2.20

  • New: Option to select scripts placement, header or footer

1.2.19

  • New: Danish translation, thanks to Lui Wallentin Gottler

1.2.18.1

  • Fix: Quick fix for 1.2.18 print_r in code

1.2.18

  • New: More info link target option
  • Tweak: Additional HTML ids, for more flexible customization

1.2.17

1.2.16

  • Tweak: Dutch translation missing due to a typo

1.2.15

  • New: Danish translation, thanks to Hans C. Jorgensen
  • Fix: Notice bar not visible if no animation selected

1.2.14

  • New: Hungarian translation, thanks to Surbma

1.2.13

1.2.12

  • New: Slovenian translation, thanks to Thomas Cuk

1.2.11

1.2.10

  • New: Italian translation, thanks to Luca
  • Tweak: Confirmed WP 4.0 compatibility

1.2.9.1

  • Tweak: Enable HTML in cookie message text
  • New: Option to donate this plugin :)

1.2.8

1.2.7

  • New: French translation, thanks to Laura Orsal
  • New: Deleting plugin settings on deactivation as an option

1.2.6

  • New: German translation, thanks to Alex Ernst

1.2.5

  • New: Spanish translation, thanks to Fernando Blasco

1.2.4

  • New: Added filter hooks to customize where and how display the cookie notice

1.2.3

  • New: Portuguese translation, thanks to Luis Maia

1.2.2

  • Fix: Read more linking to default site language in WPML & Polylang

1.2.1

  • Tweak: UI improvements for WP 3.8

1.2.0

  • Fix: Cookie not saving in IE
  • Fix: Notice hidden under Admin bar bug
  • Tweak: Improved WPML & Polylang compatibility

1.1.0

  • New: Rewritten cookie setting method to pure JS
  • Fix: Compatibility with WP Super Cache and other caching plugins

1.0.2

  • New: Dutch translation, thanks to Heleen van den Bos

1.0.1

  • Tweak: Changed setting cookie mode from AJAX to JS driven

1.0.0

Initial release

cookie-notice's People

Contributors

ahmad-ali14 avatar bartoszarendt avatar cbuchart avatar chesio avatar claytoncollie avatar cristianp6 avatar fgreinus avatar francoismassart avatar garymarkfuller avatar loru88 avatar lucspe avatar matthieumota avatar mweimerskirch avatar psielicki avatar ve3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cookie-notice's Issues

Uncaught TypeError

I got this error in my console log

Uncaught TypeError: Cannot read properties of null (reading 'classList')
    at Object.init (/app/plugins/cookie-…nt.js?ver=2.1.5:372)
    at /app/plugins/cookie-…nt.js?ver=2.1.5:455

Occurs on front.js line 372

Version on GitHub does not match version on WP.org SVN

Hi, my PR was merged in April to this repo for ADA compliance but I do not see the new code in the SVN repo on wordpress.org. I see the latest version of the plugin on GitHub is 1.2.35 and the one on WP.org is 1.2.46.

Are the two out of sync?

Is there a way to rectify it?

Thanks for the help!

Not compatible with webpack bundles

As a webpack user, I'm unable to use this plugin without hacking the functions.

When using webpack to bundle jQuery and, ie, Bootstrap JS together one has to deregister WordPress's own jQuery and register webpack's manifest.js, vendor.js (which is where jQuery is residing), and app.js (user scripts).

However, this plugin places its front.js above vendor.js which throws an error in the inspector console that jQuery isn't loaded.

Either the plugin must be modified to take this into account and either check if vendor is enqueued instead, force-place itself below other enqueues, or the check for jQuery must be removed (which is sort of counter-productive).

Minify js

Why don't you minify your assets?

For example, you could minify the javascript file using a grunt task. Since this project is not under heavy development you could minify the file manually with a tool like https://jscompress.com/ every time you make a new release.

The same will apply to the file css/front.css

This is the current file minimized (you could replace your current file js/front.js and keep the old file with a different name for further development):

!function(o){o.fn.setCookieNotice=function(e){var c=new Date,i=new Date,n=o("#cookie-notice"),t=this;if(i.setTime(parseInt(c.getTime())+1e3*parseInt(cnArgs.cookieTime)),e="accept"===e,document.cookie=cnArgs.cookieName+"="+e+";expires="+i.toGMTString()+";"+(void 0!==cnArgs.cookieDomain&&""!==cnArgs.cookieDomain?"domain="+cnArgs.cookieDomain+";":"")+(void 0!==cnArgs.cookiePath&&""!==cnArgs.cookiePath?"path="+cnArgs.cookiePath+";":""),o.event.trigger({type:"setCookieNotice",value:e,time:c,expires:i}),"fade"===cnArgs.hideEffect?n.fadeOut(300,function(){t.removeCookieNotice()}):"slide"===cnArgs.hideEffect?n.slideUp(300,function(){t.removeCookieNotice()}):t.removeCookieNotice(),e&&"1"===cnArgs.redirection){var a=window.location.protocol+"//",r=window.location.host+"/"+window.location.pathname;"1"===cnArgs.cache?(a=a+r.replace("//","/")+(""===window.location.search?"?":window.location.search+"&")+"cn-reloaded=1"+window.location.hash,window.location.href=a):(a=a+r.replace("//","/")+window.location.search+window.location.hash,window.location.reload(!0))}else;},o.fn.removeCookieNotice=function(e){o("#cookie-notice").remove(),o("body").removeClass("cookies-not-accepted")},o(document).ready(function(){var e=o("#cookie-notice");if(o(document).on("click",".cn-set-cookie",function(e){e.preventDefault(),o(this).setCookieNotice(o(this).data("cookie-set"))}),"yes"==cnArgs.onScroll){var c=function(){var e=o(this);e.scrollTop()>parseInt(cnArgs.onScrollOffset)&&(e.setCookieNotice("accept"),e.off("scroll",c))};o(window).on("scroll",c)}-1===document.cookie.indexOf("cookie_notice_accepted")?("fade"===cnArgs.hideEffect?e.fadeIn(300):"slide"===cnArgs.hideEffect?e.slideDown(300):e.show(),o("body").addClass("cookies-not-accepted")):e.removeCookieNotice()})}(jQuery);

Exclude cookie notice on some pages

Hi guys,

I am using cookie notice plugin and wants not to show the cookie notice on my thank you page in iframe after i fill some form on my site and redirected to thank you page.

Is there a way that can i place some code in cookie notice settings page to hide the cookie notice message based on page id?

Please note: until we do not accept the cookie it shows on all pages as by design, i want to hide it on some pages till it is not accepted.

Thanks,

wpsc_add_cookie called on init causes corruption

Thank you for using wpsc_add_cookie()! Unfortunately it's causing problems because it's being called on init. Multiple processes on websites using WP Super Cache try to update the plugin configuration file which causes the file to be corrupted as writes happen so often. We're going to address this issue in WP Super Cache but until then it's still a problem.

It could probably be avoided by using admin_init rather than the init action, but the cookies should really only be updated on the settings page for this plugin.

Change cookie name

Hello!

I have a WordPress multisite installation where each site has its own set of cookies. Therefore, I would like the user to see the cookie notice each time s/he navigates to a different child site.

To do so, I think it would be enough to modify the cookie name, so that it contains the blog_id value. A filter on the cookie name would be enough. This is example code of what I would need:

$cookie_name = 'cookie_notice_accepted';
$blog_id = get_current_blog_id();
if ($blog_id)
    $cookie_name .= '-' . $blog_id;

Is there somebody who's already working on this feature, or should I go on and try to implement it?

Thanks,
Guido

Banner Text Extends Off Viewport

On mobile and narrow browser windows, the text on the right side of the banner flows off the edge of the viewport.

It looks like this happens because .cookie-notice-container has a width of 100% and 15px padding.

Adding "box-sizing: border-box" appears to fix the problem.

Thanks!

[Feature Request] add filter to the cookieDomain param

Hi,

the cookieDomain variable is used for sending to javascript the domain in which the cookie will be stored. Currently its value would be the COOKIE_DOMAIN constant if it exists, or an empty string otherwise.

I would like to suggest to give users the opportunity to customize the cookieDomain value before it will be sended to javascript (via wp_localize_script).

In some situations, (like in a multisite environment) this could leads to some troubles if the COOKIE_DOMAIN constant is already defined by the user, for example in wp-config.php.

To be more specific, if the COOKIE_DOMAIN value is different from the current domain in the client's browser the cookie will no more recognized by the $_COOKIE and the plugins does not work.
Consider that this could be a real scenario in a multisite environment with domains mapped to subdomains.

The following could be an easy implementation of the feature request that could be definitely resolve the issue:

'cookieDomain' => apply_filters( 'cn_cookie_domain', ( defined( 'COOKIE_DOMAIN' ) ? COOKIE_DOMAIN : '' ) )

Add a cn_cookies_rejected() function - or similar name

First off, great plugin! Super clean and just the right amount of features.

In some instances it would be beneficial to run some code if a user has rejected "said no" to the cookie notice. We would like a way to determine the difference between a new visitor with no cookie_notice_accepted cookie and someone that "said no" (has the cookie_notice_accepted but the value is false.

I can submit a PR if needed, but it seems like your team is really active on this right now and may be more efficient for you to add it. Let us know your thoughts!

feature request: Add custom classes to the buttons

A feature request:
To have the ability to enter additional class names in wp-admin, to be added to the class attribute for the buttons in the cookie notice banner.
These can be added in addition to the current css styles: none/wordpress/bootstrap

I've already made the modifications necessary but can't seem to create a pull request to submit my changes. Would you like my contribution? (changes to file: cookie-notice.php)

Feature request/suggestion – better placement options for cookie notice

Hi there,

Hope you are well.

Firstly, thanks for providing such a great plugin to the WP community!

Here's a feature request/suggestion, which I think would be appreciated by a lot of your users:

I think it would be great if there were a few more options for the placement of the cookie notice. For example, the 'Cookie Consent' plugin by Catapult Themes has a nice way of making the notice 'push down' the page content instead of laying on top of it. Here's an example where you'll see what I mean. They also offer to position it as a kind of pop-up window in the corner a little into the page, here's an example of that. However, to me personally, the 'push down' effect is by far the most desirable!

I think that your plugin with these options would be incredibly powerful and help your plugin be the most used cookie consent plugin out there!

Hope this is useful and many thanks!

Add a note to the Cookie Notice description in the plugin repository on wordpress.org that jQuery is a dependency

There is one thing with the Cookie Notice plugin that took me a while to figure out. When I've installed and activated it Cookie Notice should basically work out of the box and display a cookie notice right on page load. But it has not. The odd thing was that the markup of the cookie notice was showing but the display:nonewasn't removed. Then i realized that Cookie Notice requires jQuery. And if you are like me and have deregistered jquery on the front-end

if( !is_admin() ){
   wp_deregister_script( 'jquery' );
}

then you have no show of the notice. and i've noticed several issues on the plugin support forum stating that the plugin isn't showing like in my described case. might be cuz of the same reason.

Capabilities

Hi,

I've noticed that the 'manage_options' capability is hard-coded for displaying the menu in backend.

In some use cases, it would be desirable to assign a different capability.

Whilst that could be achieved by filtering the capability and that is relatively simple to implement.

However, the problem I have in my tests is that since Cookie Notice uses the options form to save, you would then get the "cheating, uh?" screen of death on save.

Any ideas if there is a way around this?

Bug: Not compatible with Slider Revolution / Revslider

When having a revslider-Slideshow sitting prominently at the start / top of the page, esp. the home page, the notice is not being displayed AT ALL!

Personally I guess its either an issue with the z-index, very late post-loading of the slideshow images, or even veeery late priority for the slideshow JS / CSS assets.

If you aint been stumbling over this issue before, I might even go as far and fix this issue myself (and drop a pull request onto you) ;)

Issue appears both with RevSlider 5.0, 5.3 and 5.4.

cu, w0lf.

Infinite reload loop

With enabled cookie acceptance when users scroll AND enabled site reload after cookie accept, the js-code starts to execute the cnHandleScroll function each time user scrolls down on the site below the number of pixels defined in OnScroll-setting, thus producing an infinite reload loop once user scrolled down below that level.

IMHO the binding $( window ).on( 'scroll', cnHandleScroll ); should only happen as long as 'cookie_notice_accepted' is not set. Once it is set, the scroll event should not be registered at all.

Nofollow Cookie links

I've found a serious issue in this plugin

The "Read more" button should use a rel="nofollow" attribute for the simple reason that the result page will be an external canonical most of the times and sometimes, a homemade with no useful info regarding content purposes (most of the times a copy/paste from another site, therefore a canonical candidate)

Maybe a button in the control panel to select this optinally in the future can be the most appropiate meanwhile, I think that the most prudent action is to introduce in cookie-notice.php it in the line 930:

. ( $options['see_more'] === 'yes' ? '<a rel="nofollow" href="'

Make keyboard accessible

Hello! 👋Just seen your plugin on http://www.theboardroomclimbing.com/ and discovered it wasn't very keyboard accessible. It's the last element in the DOM but it's visually the first thing in the page, so I'd expect the first tab of the keyboard to go to the Whatever button:

screen shot 2018-06-24 at 14 49 19

Currently have to tab through all of the links on the page before I'm able to dismiss the cookie notice.

Not too sure about the plugin internals, but would suggest attaching the cookie notice to the top of the DOM rather than the bottom, and/or applying tabindex="1" on the buttons to bring them up in the tab order.

Thanks for your time!

feature request: multisite settings page

some times we are the owners of all the sites of the multisite or we need to do the configuration. In my situation, education, we have 300 blogs where we do the administration of all of them. To have 300 settings page is a lot of work. Some plugins allow to do the settings in a multisite setting page or to have the same settings in all the sites of the multisite as RCP http://docs.restrictcontentpro.com/article/1584-using-restrict-content-pro-with-wordpress-multisite

it makes the process much more simple and fast. one settings page for all the 300 sites.

thanks

SameSite attribute default to Lax

Google changed how Chrome uses Cookies and now it is up to developers to make sure cookies are secure with the SameSite attribute. If you don't do this, than the cookies will be only accepted as a first party cookie.

Below is the attribute that needs to be added;

Set-Cookie: widget_session=abc123; SameSite=None; Secure

"Close" allows Tracking

Hi Overthere,
closing the Banner over "x" sets it to "Tracking Allowed". Default Behavior should be "No Tracking allowed"

Cookie text not readable on mobile devices

I tested the plugin on my mobile device and i noticed, that some of the text was cut at the right side.
Was playing around a little bit with the CSS and saw the issue at line 16 in the font.css: there you set the container with to 100% making the padding not work anymore (at least on the right side). So to fix this issue just erase this line.

Steps to reproduce:

  1. Set the cookie Text "Diese Website benutzt Cookies. Wenn du die Website weiter nutzt, gehen wir von deinem Einverständnis aus." (default for german)
  2. Go into your favorite browser and hit the debugger. Choose a mobile device or just decrease the viewport-with until the text gets floating.

After update privacy link takes button class

As per #28 buttons can take custom classes

However, the privacy policy page link can be either a normal text link or a button depending on another setting:

Screen Shot 2020-01-08 at 4 51 40 PM

It should not take the custom button class unless it actually is a button.

The default button styles already do this correctly.
Screen Shot 2020-01-08 at 4 52 49 PM

This was working correctly before the 1.2.49 update.

What that looks like when not expecting it:
Screen Shot 2020-01-08 at 4 47 46 PM

Before it was like this:
Screen Shot 2020-01-08 at 4 54 45 PM

Based on the re-ordering I'm guessing some other html changed so I'll have to change our styles regardless. Just thinking this likely is applying to someone else out there.

2 Privacy Policy Buttons Displayed

2 Privacy Policy buttons are being displayed, 1 as link, other as button. Also, when the Enable privacy policy link is unchecked, it displays a shortcode [cookies_policy_link].

chrome_MPiYt7K80M
chrome_YAAyucxLK0

The cookie bar breaks responsive compatibility

Hello,

Thanks for your plugin.
I got a lot of Google Search notification concerning mobile compatibility of my website.
These websites are perfectly responsive, but your plugin is breaking the compatibility.
I will send you a PR to handle that issue.
Cheers,
Jb

wp-super-cache integration needs refining

Upon plugin deactivation, 'cookie_notice_accepted' cookie remains in WP-Super-Cache's config. Needs to execute some do_action('wpsc_delete_cookie', 'cookie_notice_accepted'); at some point?

Corona bar text string not translated WPML

Seems like text string inside the corona bar even when string is translated inside wpml does not display the translation on front page, not sure if this is specific to my site or other users are experiencing same issue. any help would be much appreciated. thanks

__tcfapi

Hi there,

I've been asked the below request.

The tag cannot find the __tcfapi object from which to query the consent. Can you plese check that you are making the __tcfapi API calls according to your CMP?

Could you please let me know if it is possible to add the __tcfapi object with the cookie-notice plugin?

Thanks,
Jeff

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.