Advanced cookie management and consent plugin for WordPress with automated scanning, policy management, and GDPR compliance features.
The Cookie Plugin is a comprehensive WordPress plugin designed to help website owners manage cookies, comply with privacy regulations (GDPR, CCPA), and provide transparent information to visitors about data collection practices.
- Automated Cookie Scanning: Automatically detects cookies on your website
- Cookie Policy Management: Generate and customize privacy policies
- Consent Management: Track and manage user consent preferences
- GDPR Compliance: Built-in compliance tools for European regulations
- Shortcodes: Easy integration with any page or post
- Admin Dashboard: Comprehensive management interface
- Upload the plugin files to
/wp-content/plugins/wp-cookie-plugin/ - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to Cookie Manager in your admin menu
- Run Cookie Scanner: Go to Cookie Manager → Scanner to automatically detect cookies on your site
- Configure Settings: Visit Cookie Manager → Settings to customize plugin behavior
- Create Policy: Use Cookie Manager → Policy to generate your cookie policy
- Add Consent Button: Use shortcodes to display consent management on your site
- Purpose: Automatically detect cookies on your website
- Usage: Click "Start Scan" to begin automated cookie detection
- Features:
- Scans multiple pages
- Identifies third-party services
- Categorizes cookies automatically
- Provides detailed reports
- General Settings: Configure plugin behavior and appearance
- Cookie Categories: Define and customize cookie categories
- Consent Settings: Configure consent banner and preferences
- Advanced Options: Database settings and performance options
- Templates: Choose from pre-built policy templates
- Customization: Edit policy content and styling
- Categories: Organize cookies by type and purpose
- Export: Generate PDF or HTML versions
- User Tracking: Monitor user consent decisions
- Analytics: View consent statistics and trends
- Compliance: Ensure regulatory compliance
- Reports: Generate detailed consent reports
The plugin provides several shortcodes for easy integration:
Display a list of cookies on any page:
[cm_cookie_list]
Options:
category: Filter by specific category (e.g.,[cm_cookie_list category="analytics"])show_description: Show/hide cookie descriptions (true/false)group_by_category: Group cookies by category (true/false)style: Display style (table,list,cards)
Display a consent management button:
[cm_consent_button]
Show when the policy was last updated:
[cm_last_updated]
Display current user's consent status:
[cm_consent_status]
The plugin automatically categorizes cookies into:
- Necessary: Essential for website functionality
- Analytics: Performance and usage tracking
- Marketing: Advertising and targeting
- Functional: Enhanced user experience
- Uncategorized: Requires manual classification
- Regular Scanning: Run cookie scans after making changes to your website
- Policy Updates: Keep your cookie policy current with any new cookies
- User Education: Use clear language to explain cookie purposes
- Consent Management: Respect user preferences and provide easy opt-out options
- Compliance: Regularly review and update for regulatory compliance
The Cookie Plugin follows a modular architecture with clear separation of concerns:
wp-cookie-plugin/
├── cookie-manager.php # Main plugin file
├── includes/ # Core classes
│ ├── class-cookie-scanner.php
│ ├── class-cookie-policy.php
│ ├── class-cookie-shortcodes.php
│ ├── class-printer.php
│ ├── ajax/ # AJAX handlers
│ └── admin-pages/ # Admin interface
├── assets/ # Frontend resources
│ ├── css/
│ └── js/
└── blocker.js # Cookie blocking functionality
- File:
cookie-manager.php - Purpose: Main plugin controller and initialization
- Key Methods:
getInstance(): Singleton pattern implementationinit(): Plugin initializationactivate(): Plugin activation hooksdeactivate(): Plugin deactivation hooks
- File:
includes/class-cookie-scanner.php - Purpose: Automated cookie detection and analysis
- Features:
- Multi-page scanning
- Third-party service identification
- Automatic categorization
- Performance optimization
- File:
includes/class-cookie-policy.php - Purpose: Policy generation and management
- Features:
- Template system
- Custom policy creation
- Category management
- Export functionality
- File:
includes/class-cookie-shortcodes.php - Purpose: Frontend display and integration
- Shortcodes:
[cm_cookie_list]: Display cookie information[cm_consent_button]: Consent management[cm_last_updated]: Policy update timestamp[cm_consent_status]: User consent status
CREATE TABLE wp_cm_cookies (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
category VARCHAR(100),
domain VARCHAR(255),
duration VARCHAR(100),
purpose TEXT,
display BOOLEAN DEFAULT 1,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);CREATE TABLE wp_cm_consent (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT,
session_id VARCHAR(255),
consent_data JSON,
ip_address VARCHAR(45),
user_agent TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);// Plugin lifecycle
do_action('cm_plugin_activated');
do_action('cm_plugin_deactivated');
// Cookie scanning
do_action('cm_before_scan', $scan_id);
do_action('cm_after_scan', $scan_id, $results);
do_action('cm_scan_error', $error_message);
// Consent management
do_action('cm_before_consent_log', $consent_data);
do_action('cm_after_consent_log', $consent_id);
do_action('cm_consent_updated', $user_id, $new_consent);
// Policy management
do_action('cm_policy_updated', $policy_id);
do_action('cm_policy_exported', $format, $file_path);// Cookie data
apply_filters('cm_cookie_data', $cookie_data, $context);
apply_filters('cm_cookie_categories', $categories);
apply_filters('cm_cookie_display', $display, $cookie_id);
// Policy content
apply_filters('cm_policy_content', $content, $template);
apply_filters('cm_policy_templates', $templates);
// Scanner configuration
apply_filters('cm_scanner_config', $config);
apply_filters('cm_scan_results', $results, $scan_id);// Save settings
wp_ajax_cm_save_settings
// Get settings
wp_ajax_cm_get_settings
// Reset settings
wp_ajax_cm_reset_settings// Save cookie
wp_ajax_cm_save_cookie
// Delete cookie
wp_ajax_cm_delete_cookie
// Get cookie
wp_ajax_cm_get_cookie// Start scan
wp_ajax_cm_start_scan
// Get scan progress
wp_ajax_cm_get_scan_progress
// Get scan results
wp_ajax_cm_get_scan_results
// Stop scan
wp_ajax_cm_stop_scan// Save policy
wp_ajax_cm_save_policy
// Get policy
wp_ajax_cm_get_policy
// Export policy
wp_ajax_cm_export_policy// Save consent
wp_ajax_cm_save_consent
// Get consent
wp_ajax_cm_get_consent
// Update consent
wp_ajax_cm_update_consentThe admin interface uses a modular JavaScript architecture:
- Base Classes: Common functionality and utilities
- Action Classes: Handle user interactions
- AJAX Classes: Manage server communication
- Modal Classes: Handle popup dialogs
- Progress Classes: Track operation progress
- Result Classes: Display operation results
- Cookie Blocker: Manages cookie consent and blocking
- Scanner: Frontend cookie detection
- Consent Management: User preference handling
add_filter('cm_cookie_categories', function($categories) {
$categories['custom_category'] = [
'name' => 'Custom Category',
'description' => 'Description of custom category',
'color' => '#ff0000'
];
return $categories;
});add_filter('cm_policy_templates', function($templates) {
$templates['custom_template'] = [
'name' => 'Custom Template',
'content' => 'Your custom policy content here...'
];
return $templates;
});add_filter('cm_scanner_config', function($config) {
$config['custom_rules'] = [
'custom_service' => [
'name' => 'Custom Service',
'patterns' => ['custom_cookie'],
'category' => 'custom_category'
]
];
return $config;
});- Database Optimization: Use indexes on frequently queried columns
- Caching: Implement object caching for policy and settings
- Scanning: Limit concurrent requests and implement timeouts
- Asset Loading: Load JavaScript and CSS only when needed
- Nonce Verification: All AJAX requests include nonce verification
- Capability Checks: Admin functions check user capabilities
- Data Sanitization: Input data is properly sanitized
- SQL Injection Prevention: Use prepared statements
# Run PHPUnit tests
vendor/bin/phpunit tests/
# Run specific test suite
vendor/bin/phpunit tests/ScannerTest.php# Run WordPress integration tests
vendor/bin/phpunit tests/integration/- Database optimization
- Asset minification
- Error logging configuration
- Performance monitoring
- Security audit
# Create release tag
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0
# Update version in plugin header
# Update changelog
# Test thoroughly before release- WordPress 5.0 or higher
- PHP 7.4 or higher
- MySQL 5.6 or higher (or MariaDB 10.1+)
- Download the plugin files
- Upload to
/wp-content/plugins/wp-cookie-plugin/ - Activate through WordPress admin
- Follow the setup wizard
- Run initial cookie scan
- Configure cookie categories
- Customize policy templates
- Set up consent management
- Test functionality
- Automated Cookie Detection: Intelligent scanning and categorization
- Policy Management: Customizable privacy policy templates
- Consent Tracking: Comprehensive user consent management
- GDPR Compliance: Built-in regulatory compliance tools
- Admin Dashboard: User-friendly management interface
- Shortcode Integration: Easy frontend implementation
- Export Functionality: PDF and HTML policy export
- Performance Optimization: Efficient scanning and processing
- Security Features: Secure data handling and access control
- GitHub Issues: Report bugs and feature requests
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
GPL v2 or later
Last updated: December 2024 Version: 1.0.4