CookieYes & YouTube
Manage YouTube embeds based on CookieYes consent
by Thomas McMahon · github.com/twistermc/youtube-cookieyes-wp · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/twistermc/youtube-cookieyes-wp/archive/refs/heads/main.zipReadme
CookieYes & YouTube Consent Manager
A WordPress plugin that manages YouTube video embeds based on CookieYes cookie consent settings. The plugin shows an overlay on YouTube videos when required cookie consents are not granted and allows users to easily update their consent preferences.
Currently only works with Elementor videos.
Features
- Integrates with CookieYes cookie consent management
- Blocks YouTube video loading until required consents are granted
- Shows a user-friendly overlay with consent information
- Supports both standard YouTube embeds and Elementor video widgets
- Automatically detects CookieYes consent changes
- Responsive design that works on all devices
Requirements
- WordPress 5.0 or higher
- CookieYes Cookie Consent Plugin
- Active cookie categories for:
- Functional
- Advertisement
- Elementor
Installation
- Upload the plugin files to the
/wp-content/plugins/cookieyes-youtubedirectory - Activate the plugin through the 'Plugins' screen in WordPress
- Ensure CookieYes is installed and configured with Functional and Advertisement cookie categories
Usage
The plugin works automatically with:
- Standard YouTube embeds using the
youtube-videoclass - Elementor YouTube video widgets
No additional configuration is required. Once activated, the plugin will:
- Check for required cookie consents (Functional and Advertisement)
- Show an overlay on YouTube videos if either consent is missing
- Allow users to update their consent preferences by clicking the overlay
- Automatically show videos once all required consents are granted
Customization
CSS Classes
The plugin provides the following CSS classes for styling:
.youtube-video /* Container for YouTube videos */
.youtube-consent-overlay /* Overlay shown when consent is needed */
You can customize the appearance by adding CSS rules to your theme.
Hooks
The plugin provides WordPress hooks for developers:
// Actions
do_action('cookieYes.youtube.consentGranted'); // Fired when consent is granted
do_action('cookieYes.youtube.consentDenied'); // Fired when consent is denied
// Events
'cookieyes_youtube_consent_granted' // Custom event when consent is granted
'cookieyes_youtube_consent_denied' // Custom event when consent is denied
Security
- Implements WordPress nonces for AJAX requests
- Uses Content Security Policy (CSP) headers
- Sanitizes all input and output
- Includes integrity checks for JavaScript files
License
This project is licensed under the GPL v2 or later - see the LICENSE file for details.
Support
Found a bug? Please create an issue in the GitHub repository.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Translations
The plugin comes with the following translations:
- English (default)
- Spanish (es_ES)
To add a new translation:
- Copy
languages/cookieyes-youtube.pottolanguages/cookieyes-youtube-{locale}.po - Edit the PO file with a translation editor like Poedit
- Generate the MO file
- Submit a pull request with both PO and MO files
Current translatable strings:
- Overlay message for required cookies
- Update preferences button text