[WordPress] 外掛分享: Cookie consent for developers

WordPress 外掛 Cookie consent for developers 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Cookie consent for developers」是 2018-10-30 上架。
  • 目前有 40 個安裝啟用數。
  • 上一次更新是 2024-11-13,距離現在已有 171 天。
  • 外掛最低要求 WordPress 4.9.6 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 5.6.0 以上。
  • 有 1 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

lovor |

外掛標籤

GDPR | PECR | cookie | cookie law | eu cookie law |

內容簡介

此外掛主要是針對開發人員而設計,但任何具備 HTML 和 JavaScript 知識的 WordPress 使用者也能使用它。此外掛實現了歐盟相關法令所要求的處理 Cookie 的邏輯,並且在這裡說明。 此外,還有 歐洲聯盟網頁和 歐盟委員會網頁,說明有關 Cookie 和管制其使用的法規的基本事項。

v1.7.1
在「更多了解」頁面上未顯示問題彈出。

! 新增 !

v1.6.0
新增「拒絕」按鈕,其重要性與「接受」按鈕相同。僅在管理員部分的相關欄位加入一些文字時才會啟用。對於「了解更多」鏈接也是如此。

新增 JavaScript 事件cookiesAnswered,當 Cookie 狀態得到解決(無論是按下「接受」還是「拒絕」按鈕)時,此事件會在 document 物件上觸發。

新增多語言功能,與每個多語言外掛兼容。只需在語言標籤中包裝信息(檢查 html 標籤的 lang 屬性,但不使用 - 而使用 _)。例如,意大利語句應為:[it_IT] Il nostro sito web utilizza cookie per garantire… [/it_IT] 語言短碼具有與常規 WordPress 短碼相同的語法,每個具有語言屬性的開始標籤都應該有一個結束標籤。您可以將語言標籤放入外掛的前四個上部欄位中,關於文字和頁面 ID。其他欄位不接受語言短碼。

此外掛同時被更新以使用SameSite Cookie指令,預設設置為 SameSite=Lax。

通過正確使用,您可以使您的網站符合 GDPR 和 PECR 標準。基本原則是使用者必須清楚地知道網頁使用的 Cookie(甚至來自外部服務-網頁),並且應給使用者選擇是否接受這些 Cookie。例外是不標識計算機(沒有唯一識別符)且為正確頁面運作必需的 Cookie,例如記住網路商店的購物籃。

為什麼我要使用此特定的外掛?

因為它沒有多餘的膨脹,不使用額外的 CSS、JavaScript 或其他文件在前端。它提供了平滑的集成和最小的占用空間;所有代碼和 HTML 都放在頁面的內部。

該外掛特別精心製作,以在使用者同意之前不允許任何意外的 Cookie 放置,您可以通過在背景中的指定表單欄位中放置正確的代碼來控制。

該外掛注重簡潔,這也讓開發人員自由地按照其喜好和需要進行自訂。它被設計為適用於高速緩存;這意味著它每次都提供相同版本的頁面,無論使用者選擇是否拒絕 Cookie 使用,接受 Cookies 或尚未決定。此外掛已在「Cache Enabler」插件上進行測試,但它也應與其他緩存插件和技術一起運作。唯一的例外是 YouTube 影片,其 URL 在後台被替換,有效地使其成為不同的緩存插件頁面。然而,這是必要的,因為如果使用者已決定拒絕 Cookie,則此 YouTube 代碼不應該放置任何 Cookie,因此 URL 交換不能在頁面加載後完成。

使用方法

在標準菜單項目「設置」中的管理員面板上有一個名為「開發人員 Cookie 同意」的設置頁面。

原文外掛簡介

This plugin is intended primarily for developers, although any WordPress user with knowledge of HTML and JavaScript can use it. The plugin implements the logic of dealing with cookies as required by EU regulation and explained here. There is also This European Union page and this European Comission page which explain basic things about cookies and legislation which regulates their usage.
Multilingual capabilities, compatible with each and every multilingual plugin. Simply wrap messages in language tags (check lang attribute of html tag, however, use _ instead of -). For example, Italian language sentence should be: [it_IT]Il nostro sito web utilizza cookie per garantire…[/it_IT] The language shortcodes have the same syntax like regular WordPress shortcodes, each opening tag with language attribute inside should have a closing tag. >ou can put language tags in first four upper fields of plugin regarding texts and page ID. Other fields do not accept language shortcodes.
Javascript event cookiesAnswered fires on document object when cookie status is resolved, either on pressing ‘Accept’ or ‘Decline’ button.
The plugin is also updated to use SameSite cookie directive with default setting SameSite=Lax.
With proper use, you can make your website GDPR and PECR compliant. The basic principles are that user must be clearly informed about cookies that you use on a webpage (even from external services – web pages), and that user should be given a choice to decide if he wants to accept these cookies. The exception are cookies that do not identify computer (without unique identificator) and which are necessary for proper page functioning, like remembering shopping basket in an online store.
Why should I use this particular plugin?
Because it is free from bloatware, no additional CSS, JavaScript or other files are used in frontend. It offers smooth integration with minimal footprint; all code and HTML is placed inline in HTML of the page.
Plugin is particularly crafted to not allow any unwanted cookie placement before user consents, you control that by placing proper code in designated form fields in background.
The stress of the plugin is on simplicity, which also gives developers open hands to do customizations as preferred and needed. It is made to be cache – friendly; it means that it offers the same version of the page each time, no matter if user chose to opt-out of cookie usage, accepted cookies or has not yet decided. Plugin has been tested on “Cache Enabler” plugin, but it should work with other caching plugins and technologies as well. Only exception is YouTube videos which URL’s are replaced in situ in the backend, effectively making it a little different page for the caching plugin. However, this is necessary, since this YouTube code should not place any cookies if user has decided to opt-out, therefore URL exchange could not be done after the page loads.
How to use
There is a setup page titled “Cookie consent for developers” on admin panel in standard menu item ‘Settings’. It is important to understand how plugin works, and that you should divide JavaScript that places cookies into “working horse” part, which places cookies and does other things and part which starts that “working horse”.
On the plugin settings page, you should give short information about cookies or other similar technologies (from now on I will refer simple as “cookies”, although that also refers to local storage, session storage, …) used and ID of the page which tells user more about use of such technologies. This info shows as info window and is customizable via CSS. Two examples, css_example1.css and css_example2.css are given to show different styling of this info window (or ribbon). The “learn more” page (whose ID is given) should also provide mechanism to choose between allowing only necessary cookies or allowing all cookies. More about this page later.
Then you have to enter code in the header and footer, which places cookies and the code that calls that code, separately. In this way, the code that places cookies is executed only when user allows.
Finally, you can enter opt-out code, which will block functions which place cookies if user decides not to use them.
There is also possibility to enter custom code which will run on window load event (when page fully loads) which you can use to add special effects to info window or anything else you wish.
Learn more page
On learn more page (you have to build it yourself) you should explain about the cookies and their usage in simple and understandable way to general public. The information about all cookies on your web and their purpose should be given (including third-party).
Important: Two buttons (or links) should also be given on this page, with id’s: btnAcceptCookies and btnRefuseCookies (without apostrophes). These buttons shall be used to enable user to choose if cookies will be used or not (except necessary ones).
Styling
You can use two provided styles, or (very likely) do your own styling. If you choose option “Not used” in the settings, you should put custom CSS in theme or other styling CSS file, while if you choose “Custom CSS file”, you should provide separate CSS file.
This separate CSS file should be named ccfd_custom.css and should be placed in the root of your theme directory, or you can use filter named ccfd_custom_css_name to provide custom string for your CSS file. The same full path, like for wp_enqueue_style should be given.
Live examples of two given styles you can see on pages Učiliste Altius or Blog školskog muzeja.
Ideally, you should put styling in your main theme stylesheet, or however you find more appropriate.
YouTube
The plugin has special function for YouTube. If user decides to opt-out from cookies, all YouTube URL-s will be replaced with youtube-nocookie versions. This will also work for shortened URL’s like https://youtu.be. In this way, YouTube videos will still function, but they will not use cookies.
Languages
English and Croatian so far.
Warning
This plugin enables entering of javascript for admin users. Do not install it if you do not trust your admins, because malicious code can be entered by them.
However, many plugins and even WordPress itself has access to development scripts, be it PHP or javascript, so this is nothing extraordinary.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Cookie consent for developers」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 1.1 | 1.2 | 1.3 | 1.4 | 1.4.1 | 1.5.1 | 1.5.2 | 1.6.0 | 1.7.0 | 1.7.1 | trunk |

延伸相關外掛(你可能也想知道)

文章
Filter
Apply Filters
Mastodon