[WordPress] 外掛分享: WP Consent API

WordPress 外掛 WP Consent API 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「WP Consent API」是 2020-02-05 上架。
  • 目前有 100000 個安裝啟用數。
  • 上一次更新是 2025-03-31,距離現在已有 32 天。
  • 外掛最低要求 WordPress 5.0 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 5.6 以上。
  • 有 1 人給過評分。
  • 論壇上目前有 2 個提問,問題解答率 0%

外掛協作開發者

xkon | paapst | aurooba | pputzer | mujuonly | phpgeekdk | aahulsebos | markwolters | szepeviktor | rogierlankhorst | wordpressdotorg |

外掛標籤

api | consent | cookies | privacy | compliance |

內容簡介

WP Consent API 是一個外掛,可以標準化插件之間同意的同意類別溝通。它需要使用 Cookie 標語插件和至少一個支援 WP Consent API 的其他插件。

有了這個插件,所有支援的插件都可以使用同一組方法來讀取和註冊當前的同意類別,從而讓同意管理插件和其他插件共同工作,提高隱私法規的遵從性。

警告:該插件本身不會處理同意。這將向您顯示有多少沒有同意 API 支持的插件,並通過確保 Cookie 標語插件和設置 Cookie 或跟踪用戶數據的插件之間的平滑通信來改善您的遵從性。

這個插件解決了什麼問題?目前,同意管理插件可以阻止第三方服務(如 Facebook、Google 地圖、Twitter 等)。但如果 WordPress 插件放置了 PHP Cookie,同意管理插件無法阻止這一點。

其次,一些插件在客戶端的 JavaScript 文件中集成了跟踪代碼,一旦被阻止就會破壞站點。

或者,如果這樣的插件的 JavaScript 是縮小的,導致 URL 是無法識別的,那麼它也無法被自動阻止腳本所檢測到。

最後,阻止方法需要列出所有跟踪數據類型的 URL 列表。插件遵從的通用 API 可以極大地幫助網站管理員獲得符合要求的網站。

使用此 API 是否可以防止第三方服務跟踪用戶數據?主要是針對符合要求的第一方 Cookie 或 WordPress 插件的跟踪。如果這樣的插件觸發,例如 Facebook,使用此 API 將有所幫助。如果用戶嵌入了 Facebook iframe,需要一個阻止工具,最初禁用 iframe 和或腳本。

第三方腳本必須通過同意管理插件中的阻止功能進行阻止。在核心中這樣做將會導致過於侵入式,而且也不適用於所有用戶:僅在歐洲聯盟等選擇加入區域的訪問者中具有這樣的功能。這樣的功能還存在着破壞事情的風險。此外,阻止這些和顯示漂亮的占位符需要更加複雜的代碼,我認為這些都不應該成為 WordPress 核心的一部分,原因相同。

它是如何工作的?共有兩個指示器,告訴特定同意類別是否被同意,例如「行銷」:1)基於區域的同意類型,可以是選擇加入、選擇退出或其他可能的同意類型;2)訪問者的選擇:未設置、允許或拒絕。

同意類型是一個將過濾器「wp_get_consent_type」包裹的函數。如果沒有同意管理插件設置它,它將返回 false。這將導致所有同意類別都返回 true,允許在所有類別中設置 Cookie。

如果使用此篩選器設置為選擇加入,僅當訪問者的選擇值為「允許」時,類別才會返回 true。

如果基於區域的同意類型是選擇退出,它將在訪問者的選擇未設置或為「允許」時返回 true。

在客戶端,同意管理插件可以動態操作同意類型並設置多個 Cookie 類別。

插件可以使用鉤子來監聽更改或檢查給定類別的值。

某些其他東西可以通過過濾器進行擴展。

現有的整合包括:

- Complianz GDPR/CCPA
- Cookiebot

原文外掛簡介

WP Consent API is a plugin that standardizes the communication of accepted consent categories between plugins. It requires a cookie banner plugin and, at least, one other plugin that supports the WP Consent API.
With this plugin, all supporting plugins can use the same set of methods to read and register the current consent category, allowing consent management plugins and other plugins to work together, improving compliance with privacy laws.
WARNING: the plugin itself will not handle consent. It will show you how many plugins you have without Consent API support and will improve compliance on your site by ensuring smooth communication between cookie banner plugins and plugins that set cookies or track user data.
What problem does this plugin solve?
Currently, it is possible for a consent management plugin to block third-party services like Facebook, Google Maps, Twitter, etc. But if a WordPress plugin places a PHP cookie, a consent management plugin cannot prevent this.
Secondly, some plugins integrate the tracking code on the clientside in javascript files that, when blocked, break the site.
Or, if such a plugin’s javascript is minified, causing the URL to be unrecognizable and won’t get detected by an automatic blocking script.
Lastly, the blocking approach requires a list of all types of URL’s that tracks data. A generic API where plugins adhere to can greatly
facilitate a webmaster in getting a site compliant.
Does usage of this API prevent third-party services from tracking user data?
Primary this API is aimed at compliant first-party cookies or tracking by WordPress plugins. If such a plugin triggers, for example, Facebook,
usage of this API will be of help. If a user embeds a Facebook iframe, a blocking tool is needed that initially disables the iframe and or scripts.
Third-party scripts have to blocked by blocking functionality in a consent management plugin. To do this in core would be to intrusive, and is also not applicable to all users: only users with visitors from opt-in regions such as the European Union require such a feature. Such a feature also has a risk of breaking things. Additionally, blocking these and showing a nice placeholder requires even more sophisticated code, all of which should in my opinion not be part of WordPress core, for the same reasons.
How does it work?
There are two indicators that together tell if consent is given for a specific consent category, e.g., “marketing”:
1) the region based consent_type, which
can be opt-in, opt-out, or other possible consent_types;
2) and the visitor’s choice: not set, allow, or deny.
The consent_type is a function that wraps a filter, “wp_get_consent_type”. If there’s no consent management plugin to set it, it will return false. This will cause all consent categories to return true, allowing cookies to be set on all categories.
If opt-in is set using this filter, a category will only return true if the value of the visitor’s choice is “allow”.
If the region based consent_type is opt-out, it will return true if the visitor’s choice is not set or is “allow”.
Clientside, a consent management plugin can dynamically manipulate the consent type and set several cookie categories.
A plugin can use a hook to listen for changes or check the value of a given category.
Categories and most other stuff can be extended with a filter.
Existing integrations
Categorized, and sorted alphabetically
Example plugin

Example plugin. The plugin basically consists of a shortcode, with a div that shows a tracking or not tracking message. No actual tracking is done 🙂

Consent Management Providers

Beautiful Cookie Consent Banner.
Complianz GDPR/CCPA.
Consent Studio.
Cookiebot.
CookieHub.
CookieYes – Cookie Banner for Cookie Consent.
GDPR Cookie Compliance.
GDPR Cookie Consent Plugin – CCPA Ready.

Consent Requiring Plugins

AddToAny.
AFL UTM Tracker Plugin.
Burst Statistics.
Google Site Kit.
Pixel Manager for WooCommerce.
Woo.
WP Statistics.

Demo site
wpconsentapi.org
Below are the plugins used to set up the demo site:

Complianz
The example plugin

javascript, consent management plugin
//set consent type
window.wp_consent_type = 'optin'

//dispatch event when consent type is defined. This is useful if the region is detected server side, so the consent type is defined later during the pageload
let event = new CustomEvent('wp_consent_type_defined');
document.dispatchEvent( event );

//consent management plugin sets cookie when consent category value changes
wp_set_consent('marketing', 'allow');

javascript, tracking plugin
//listen to consent change event
document.addEventListener("wp_listen_for_consent_change", function (e) {
var changedConsentCategory = e.detail;
for (var key in changedConsentCategory) {
if (changedConsentCategory.hasOwnProperty(key)) {
if (key === 'marketing' && changedConsentCategory[key] === 'allow') {
console.log("just given consent, track user")
}
}
}
});

//basic implementation of consent check:
if (wp_has_consent('marketing')){
activateMarketing();
console.log("set marketing stuff now!");
} else {
console.log("No marketing stuff please!");
}

PHP
//declare compliance with consent level API
$plugin = plugin_basename( __FILE__ );
add_filter( "wp_consent_api_registered_{$plugin}", '__return_true' );

/**
* Example how a plugin can register cookies with the consent API
* These cookies can then be shown on the front-end, to the user, with wp_get_cookie_info()
*/

function my_wordpress_register_cookies(){
if ( function_exists( 'wp_add_cookie_info' ) ) {
wp_add_cookie_info( 'AMP_token', 'AMP', 'marketing', __( 'Session' ), __( 'Store a unique User ID.' ) );
}
}
add_action('plugins_loaded', 'my_wordpress_register_cookies');

if (wp_has_consent('marketing')){
//do marketing stuff
}

Any code suggestions? We’re on GitHub as well!

各版本下載點

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

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


1.0.4 | 1.0.5 | 1.0.6 | 1.0.7 | 1.0.8 | trunk |

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

  • Cookie Notice & Compliance for GDPR / CCPA 》Cookie Notice 提供簡單易定制的網站橫幅,以協助你的網站遵守歐盟 GDPR cookie 法律以及 CCPA 法規下的某些cookie同意要求,並與 Cookie Compliance 無縫集...。
  • Adapta RGPD 》Adapta RGPD is a tool that helps you create legal pages in Spanish, adapt your website to the GDPR, and comply with the Cookies Law in a clear and ...。
  • Cookies for Comments 》這個外掛將會在你的部落格 HTML 的原始碼中新增一個樣式表或圖片。當瀏覽器讀取該樣式表或圖片時,會放置一個 Cookie。如果有使用者在這之後留下評論,該 Coo...。
  • Asesor de Cookies RGPD para normativa europea 》, 欲取得更多資訊,請造訪 Web Artesanal 網站, , 此外掛的功能是在每個新使用者訪問網站時顯示訊息,告知使用者如果按下「接受」按鈕即表示同意在他們的網頁...。
  • WF Cookie Consent 》WF Cookie Consent 可以向使用者顯示網站使用 cookie 的明確訊息。, 這個外掛支援 Polylang 外掛和 WPML 外掛進行多語言安裝。它提供了各種設定選項,可控制...。
  • Italy Cookie Choices (for EU Cookie Law & Cookie Notice) 》Cookie法是世界上最愚蠢的法律之一。也許是由某些不真正了解網絡運作方式的人制定的。, Italy Cookie Choices讓您輕鬆遵守歐洲(和意大利)的Cookie法律,並...。
  • Cookies and Content Security Policy 》透過內容安全策略 (Content Security Policy),完全符合 GDPR 和 CCPA 的要求。, 透過設定內容安全策略,可以阻擋 cookies 和不需要的外部內容。前端將顯示模...。
  • Axeptio – Cookie Banner – GDPR Consent & Compliance with a friendly touch 》Axeptio 是一個獨特、多次被模仿的 cookie 同意小工具外掛程式,它將確保您獲得使用者同意並妥善告知他們的權利。, 非常容易安裝和配置,Axeptio 只需幾分鐘...。
  • Pressidium Cookie Consent 》。
  • Machete 》Machete是一個簡單的工具套件,可以盡可能節省資源來解決常見的WordPress煩惱。Machete並不適用於每一種使用情況,但若您使用Machete,會需要較少的外掛程式...。
  • Easy Cookie Law 》Easy Cookie Law 可以幫助您輕鬆遵守歐洲 Cookie 法。它會顯示可自訂的提示視窗,直到使用者同意或拒絕在您的網站使用 Cookie 為止。, 透過外掛菜單,您可以...。
  • Ilmenite Cookie Consent 》有許多 WordPress 的外掛可以對 Cookie 同意進行各種花俏的設定。我們並沒有真正喜歡且輕量化、開發者友善的外掛,因此我們創建了自己的外掛。, 這並不是為了...。
  • Cookie Law Bar 》這是一個簡單且輕量化的 cookie 法 WordPress 外掛程式,用於顯示你的網站使用 cookie 的相關資訊,非常適合實施歐盟的 cookie 法!, 線上示範:http://demo....。
  • Civic Cookie Control 》這個 WordPress 外掛可以簡化 Cookie Control 的實施和自定義過程,Cookie Control 是由 Civic UK 開發的一種機制,可以控制使用者在其電腦上同意使用 cookie...。
  • Flexible Cookies 》- 我們的免費外掛不僅讓您以專業且符合規範的方式顯示Cookie欄,還能掃描網站的Cookie並添加適當的類別。, - 您可以按照自己的需要自訂Cookie欄的外觀,使其...。

文章
Filter
Apply Filters
Mastodon