PHPackages                             lwplugins/lw-cookie - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lwplugins/lw-cookie

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

lwplugins/lw-cookie
===================

GDPR-compliant cookie consent banner for WordPress

v1.6.5(1mo ago)7771GPL-2.0-or-laterPHPPHP &gt;=8.1CI passing

Since Feb 5Pushed 1mo agoCompare

[ Source](https://github.com/lwplugins/lw-cookie)[ Packagist](https://packagist.org/packages/lwplugins/lw-cookie)[ Fund](https://sinann.io/)[ RSS](/packages/lwplugins-lw-cookie/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (30)Used By (0)

LW Cookie
=========

[](#lw-cookie)

GDPR-compliant cookie consent banner for WordPress - minimal footprint, full compliance.

[![PHP Version](https://camo.githubusercontent.com/7535257ca228724c93658bd52583d4e47a9bab02c356abf6e54c1d575f2151e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e737667)](https://php.net)[![WordPress Version](https://camo.githubusercontent.com/f1989d6cd7139e0ba03c225b1eb47980a7ec6ba2a2b489beb9c01881be322852/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f576f726450726573732d362e302532422d626c75652e737667)](https://wordpress.org)[![License](https://camo.githubusercontent.com/77e900ae34f8da9ccccc42662fce61a94ab07ddbfe3f7d066178e824f3673dbd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c25323076322d626c75652e737667)](https://www.gnu.org/licenses/gpl-2.0.html)

[![LW Cookie Settings](.github/screenshot.png)](.github/screenshot.png)

Features
--------

[](#features)

### GDPR Compliance

[](#gdpr-compliance)

- **Opt-in by default** - All optional categories are OFF until user consents
- **Granular category selection** - Necessary, Functional, Analytics, Marketing
- **Consent logging** - Timestamp and policy version for compliance proof
- **Policy version tracking** - Automatic re-consent on policy changes
- **Anonymized IP logging** - GDPR-compliant data storage

### Cookie Banner

[](#cookie-banner)

- Customizable position (top, bottom, modal)
- Customizable layout (full-width bar, floating box)
- Customizable colors and border radius
- Accept All / Reject All / Customize buttons
- Floating button for easy access to preferences

### Script Blocking

[](#script-blocking)

Automatic blocking of known tracking scripts until consent:

- Google Analytics / Google Tag Manager
- Facebook Pixel
- Hotjar
- LinkedIn Insight Tag
- Twitter/X Pixel
- TikTok Pixel
- Microsoft Clarity
- Pinterest Tag
- Snapchat Pixel

### Content Blocking

[](#content-blocking)

Block third-party embeds until consent is given:

- YouTube videos
- Vimeo videos
- Google Maps
- Other iframes

### Cookie Scanner

[](#cookie-scanner)

Detect cookies on your website:

- Server-side scanning (detects HttpOnly cookies)
- Deep scan with remote headless browser
- Cookie Database API integration (2000+ known cookies)
- Automatic cookie enrichment with provider, purpose, duration

### Google Consent Mode v2

[](#google-consent-mode-v2)

- Built-in support for Google Consent Mode v2
- Loads at highest priority (before any tracking script)
- EEA region-specific defaults
- Required for Google Ads and Analytics in the EU
- Automatic consent signal updates

### Meta Pixel (Facebook) Support

[](#meta-pixel-facebook-support)

- Automatic `fbq('consent', 'revoke/grant')` API calls
- Works with existing Facebook Pixel implementations

### Third-Party Plugin Integration

[](#third-party-plugin-integration)

- **dataLayer.push** events for GTM triggers (`lw_cookie_consent_update`)
- **WordPress filters** for querying consent state
- **Script blocking override** filter for plugin compatibility

### WP-CLI Support

[](#wp-cli-support)

Full command-line management:

```
wp lw-cookie settings list              # List all settings
wp lw-cookie settings set enabled true  # Change settings
wp lw-cookie stats                      # View consent statistics
wp lw-cookie export --format=csv        # Export consent logs
wp lw-cookie clear-logs --older-than=365 # Clean up old logs
```

Installation
------------

[](#installation)

### Via Composer (Recommended)

[](#via-composer-recommended)

```
composer require lwplugins/lw-cookie
```

### Manual Installation

[](#manual-installation)

1. Download the latest release
2. Upload the `lw-cookie` folder to `/wp-content/plugins/`
3. Activate the plugin through the 'Plugins' menu
4. Go to **LW Plugins → Cookie** to configure

Configuration
-------------

[](#configuration)

Navigate to **LW Plugins → Cookie** in your WordPress admin to access settings:

TabDescription**General**Enable/disable, privacy policy page, policy version**Appearance**Position, layout, colors, border radius**Categories**Customize category names and descriptions**Texts**Banner title, message, and button labels**Advanced**Consent duration, script blocking, Google Consent ModeCookie Categories
-----------------

[](#cookie-categories)

CategoryRequiredDescription**Necessary**YesEssential cookies for website function**Functional**NoEnhanced functionality and personalization**Analytics**NoVisitor analytics and statistics**Marketing**NoAdvertising and remarketingJavaScript API
--------------

[](#javascript-api)

```
// Accept all cookies
LWCookie.acceptAll();

// Reject all optional cookies
LWCookie.rejectAll();

// Open preferences modal
LWCookie.openPreferences();

// Get current consent state
const consent = LWCookie.getConsent();
// { necessary: true, functional: false, analytics: false, marketing: false }

// Check if category is allowed
if (LWCookie.isAllowed('analytics')) {
    // Load analytics scripts
}

// Listen for consent changes
window.addEventListener('lwCookieConsent', function(e) {
    console.log('Categories:', e.detail.categories);
    console.log('Action:', e.detail.action);
});

// Delete all cookies (for "forget me" functionality)
LWCookie.deleteAllCookies();
```

WordPress Hooks (PHP)
---------------------

[](#wordpress-hooks-php)

For third-party plugin integration:

```
// Get all consent categories
$categories = apply_filters( 'lw_cookie_consent_categories', [] );
// ['necessary' => true, 'functional' => false, 'analytics' => true, 'marketing' => false]

// Check if user has given any consent
$has_consent = apply_filters( 'lw_cookie_has_consent', false );

// Check if specific category is allowed
$analytics_ok = apply_filters( 'lw_cookie_is_category_allowed', false, 'analytics' );

// Prevent blocking specific scripts (e.g., if your plugin handles consent)
add_filter( 'lw_cookie_should_block_script', function( $should_block, $handle, $src, $category ) {
    if ( $handle === 'my-plugin-pixel' ) {
        return false; // Don't block, I handle consent myself
    }
    return $should_block;
}, 10, 4 );
```

GTM Integration
---------------

[](#gtm-integration)

The plugin pushes events to dataLayer for GTM triggers:

```
// Fired on every consent change
{
    event: 'lw_cookie_consent_update',
    lw_cookie_consent: {
        necessary: true,
        functional: true,
        analytics: true,
        marketing: false
    },
    lw_cookie_action: 'customize' // or 'accept_all', 'reject_all'
}
```

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- WordPress 6.0 or higher

Documentation
-------------

[](#documentation)

Full documentation is available in the [docs](docs/) folder:

- [Settings Documentation](docs/settings.md)

Part of LW Plugins
------------------

[](#part-of-lw-plugins)

LW Cookie is part of the [LW Plugins](https://github.com/lwplugins) family - lightweight WordPress plugins with minimal footprint and maximum impact.

PluginDescription[LW SEO](https://github.com/lwplugins/lw-seo)Essential SEO features without the bloat[LW Disable](https://github.com/lwplugins/lw-disable)Disable WordPress features like comments[LW Site Manager](https://github.com/lwplugins/lw-site-manager)Site maintenance via AI/REST[LW Memberships](https://github.com/lwplugins/lw-memberships)Lightweight membership system[LW LMS](https://github.com/lwplugins/lw-lms)Courses, lessons, and progress tracking**LW Cookie**GDPR-compliant cookie consentLicense
-------

[](#license)

GPL-2.0-or-later. See [LICENSE](https://www.gnu.org/licenses/gpl-2.0.html) for details.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Sponsor
-------

[](#sponsor)

[ ![Sinann](https://camo.githubusercontent.com/08cb3e29f7e91a32ff084d73f5e4c33b6ac8f3508f20dfe040357e9a94c5952b/68747470733a2f2f73696e616e6e2e696f2f66617669636f6e2e737667)](https://sinann.io/)Supported by [Sinann](https://sinann.io/)

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

29

Last Release

58d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/56bc0e3c885c56236e52eaed12997aa4fbaf0645299acf0092a8cc5b887d65b0?d=identicon)[trueqap](/maintainers/trueqap)

---

Top Contributors

[![trueqap](https://avatars.githubusercontent.com/u/32407751?v=4)](https://github.com/trueqap "trueqap (44 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/lwplugins-lw-cookie/health.svg)

```
[![Health](https://phpackages.com/badges/lwplugins-lw-cookie/health.svg)](https://phpackages.com/packages/lwplugins-lw-cookie)
```

###  Alternatives

[rainlab/blog-plugin

Blog plugin for October CMS

17257.7k](/packages/rainlab-blog-plugin)[rainlab/builder-plugin

Builder plugin for October CMS

17147.2k1](/packages/rainlab-builder-plugin)[pfefferle/wordpress-activitypub

The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.

5671.4k1](/packages/pfefferle-wordpress-activitypub)[civicrm/civicrm-drupal-8

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

18238.1k2](/packages/civicrm-civicrm-drupal-8)[mediawiki/semantic-glossary

A terminology markup extension with a Semantic MediaWiki back-end

1352.4k](/packages/mediawiki-semantic-glossary)[humanmade/lottie-lite

A lightweight Lottie Animations Extension for WordPress

374.3k](/packages/humanmade-lottie-lite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
