定制 imagewize/simple-cookie-consent 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

imagewize/simple-cookie-consent

最新稳定版本:v1.0.0-beta.2

Composer 安装命令:

composer require imagewize/simple-cookie-consent

包简介

Implements GDPR-compliant cookie consent functionality.

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
  • 📱 Fully responsive design
  • 🧩 Easy integration with WordPress

Installation

Method 1: Using WordPress Admin

  1. Download the plugin ZIP file from the releases page
  2. Go to your WordPress admin panel
  3. Navigate to Plugins > Add New > Upload Plugin
  4. Choose the downloaded ZIP file and click "Install Now"
  5. Activate the plugin

Method 2: Manual Installation

  1. Download the plugin ZIP file
  2. Extract the ZIP file
  3. Upload the extracted folder to your /wp-content/plugins/ directory
  4. Activate the plugin through the WordPress admin panel

Method 3: Build from Source

  1. Clone this repository
  2. Install dependencies:
    npm install
  3. Build the plugin:
    npx webpack
  4. Upload the plugin folder to your WordPress plugins directory

Method 4: Using Composer

You can also install the plugin using Composer:

composer require imagewize/simple-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 > Cookie Consent.

Configuration

You can customize the plugin through the admin interface:

  1. Navigate to Settings > Cookie Consent in your WordPress dashboard
  2. Configure the following settings:
    • Language and general behavior
    • Banner title and description
    • Button text and actions
    • Privacy policy link
    • Cookie categories and patterns (NEW!)

NEW: Cookie Categories Management

The plugin now 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
  • Analytics cookies: Optional tracking and analytics cookies

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.

Managing Third-party Cookies

The plugin automatically handles third-party cookies by:

  1. Preventing scripts from loading until consent is given
  2. Clearing cookies if consent is withdrawn

For detailed implementation guides, see the dev.md documentation file.

Dependencies

Development

To set up the development environment:

# Install dependencies
npm install

# Build for production
npx webpack

# Watch for changes
npx webpack --watch

License

This project is licensed under the MIT License - see the LICENSE file for details.

统计信息

  • 总下载量: 67
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-31