imagewize/simple-cookie-consent
Composer 安装命令:
composer require imagewize/simple-cookie-consent
包简介
GDPR-compliant cookie consent banner with category management and floating preferences toggle.
README 文档
README
A lightweight plugin that implements GDPR-compliant cookie consent functionality for WordPress websites using the vanilla-cookieconsent library.
Features
- 🚀 Lightweight and fast
- 🌐 Multi-language support
- 🎨 Customizable appearance
- 🔒 GDPR-compliant cookie management
- 🔁 Floating preferences toggle button — lets users revisit consent choices at any time
- 📱 Fully responsive design
- 🧩 Easy integration with WordPress
Installation
Method 1: Using WordPress Admin
- Download the plugin ZIP file from the releases page
- Go to your WordPress admin panel
- Navigate to Plugins > Add New > Upload Plugin
- Choose the downloaded ZIP file and click "Install Now"
- Activate the plugin
Method 2: Manual Installation
- Download the plugin ZIP file
- Extract the ZIP file
- Upload the extracted folder to your
/wp-content/plugins/directory - Activate the plugin through the WordPress admin panel
Method 3: Using Composer
You can also install the plugin using Composer:
composer require imagewize/warder-cookie-consent
Usage
After activation, the cookie consent banner will automatically appear on your website. Configure the settings from the WordPress admin panel at Settings > Warder Consent.
Configuration
You can customize the plugin through the admin interface:
- Navigate to Settings > Warder Consent in your WordPress dashboard
- Configure the following settings:
- Language and general behavior
- Banner title and description
- Button text and actions
- Privacy policy link
- Cookie categories and patterns (NEW!)
Preferences Toggle Button
A floating cookie icon button is rendered in the page footer, giving visitors a persistent way to reopen the preferences modal and change their consent choices at any time.
- Enable/disable the button via the "Preferences Toggle Button" checkbox in General Settings
- Position it in any corner: Bottom Right (default), Bottom Left, Top Right, Top Left
- The button only appears when the plugin is enabled and the toggle option is active
Cookie Categories Management
The plugin allows you to manage cookie categories and patterns directly through the admin interface:
- Add new cookie categories like Marketing or Preferences
- Define specific cookies to block within each category
- Use regular expressions to match multiple cookies with similar names
- Automatically clear cookies when consent is withdrawn
This means you can easily configure which cookies to block and when to allow them, all without editing any code.
Cookie Categories
The default configuration includes:
- Necessary cookies: Always enabled, required for basic website functionality. Pre-populated with WordPress core cookies (
wordpress_logged_in_*,wordpress_sec_*,wordpress_test_cookie,wp-settings-*) and WooCommerce session & cart cookies (wp_woocommerce_session_*,woocommerce_cart_hash,woocommerce_items_in_cart,woocommerce_recently_viewed). - Analytics cookies: Optional tracking and analytics cookies, pre-populated with patterns for Google Analytics (
/^_ga/,_gid,_gat), Matomo (/^_pk_/,/^mtm_/), and SourceBuster (/^sbjs_/).
Plausible Analytics is cookieless by design, so it needs no patterns here — there are no cookies to clear.
Usage Examples
Blocking Google Analytics Until Consent
Add your Google Analytics script with the data-category attribute:
<script type="text/plain" data-category="analytics"> // Your Google Analytics code here </script>
The script won't execute until the visitor accepts analytics cookies.
Blocking Matomo Until Consent
Gate the Matomo tracking snippet the same way:
<script type="text/plain" data-category="analytics"> var _paq = window._paq = window._paq || []; // Your Matomo tracking code here </script>
The matching /^_pk_/ and /^mtm_/ patterns in the analytics category clear Matomo's cookies if consent is later withdrawn.
Automatic Script Blocking
The plugin automatically blocks a set of known WordPress script handles before analytics consent is given — no data-category attributes needed on those scripts. The built-in list covers:
| Script handle | Script |
|---|---|
sourcebuster-js |
WooCommerce SourceBuster (sets sbjs_* cookies) |
wc-order-attribution |
WooCommerce order attribution |
To add more scripts, use the warder_blocked_scripts filter:
add_filter( 'warder_blocked_scripts', function( $scripts ) { $scripts['my-tracking-script'] = 'analytics'; return $scripts; } );
Common examples
// Slimstat Analytics $scripts['wp_slimstat'] = 'analytics'; // MonsterInsights $scripts['monsterinsights-frontend'] = 'analytics';
Managing Third-party Cookies
The plugin automatically handles third-party cookies by:
- Preventing scripts from loading until consent is given
- Clearing cookies if consent is withdrawn
For detailed implementation guides, see docs/dev.md.
Contributing
Want to build from source, set up a development environment, or submit changes? See
CONTRIBUTING.md. For a deeper technical reference, see
docs/dev.md.
License
This project is licensed under GPLv2 or later - see the LICENSE file for details.
imagewize/simple-cookie-consent 适用场景与选型建议
imagewize/simple-cookie-consent 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 172 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 03 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「wordpress」 「cookie」 「cookie consent」 「consent」 「gdpr」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 imagewize/simple-cookie-consent 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 imagewize/simple-cookie-consent 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 imagewize/simple-cookie-consent 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Add a configurable cookie consent banner to the website.
Popup component for Nette Framework
Cookie Consent is a lightweight JavaScript plugin for alerting users about the use of cookies on your website.
Plugin for YOURLS. Default tools to use in some laemmi plugins
A plugin that stores Google Analytics utm_parameter query string to a client cookies
统计信息
- 总下载量: 172
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2025-03-31