=== Eco-Shield === Contributors: ssebuwufumoses, hanifahnabayinda Tags: youtube, privacy, webp, accessibility, gdpr, lazy load, shorts Requires at least: 6.5 Tested up to: 6.9 Requires PHP: 7.4 Stable tag: 1.2.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Boost PageSpeed, ensure GDPR compliance, and reduce carbon footprint by replacing YouTube & Vimeo embeds with locally hosted, native lazy-loaded WebP facades. == Description == **Eco-Shield** is the lightweight, "set-it-and-forget-it" solution for faster, greener, and more private WordPress sites. Standard YouTube and Vimeo embeds can destroy your PageSpeed scores. A single video embed often loads over 1.7MB of JavaScript and tracks your users before they even click play. **Eco-Shield fixes this automatically.** It replaces heavy external embeds with a **locally hosted, optimized WebP image**. The heavy video player (and its tracking cookies) is only loaded when your visitor explicitly clicks "Play." ### 🌟 New in Version 1.2.0 (The "Gold" Update) * **Native Lazy-Loading:** Now uses browser-native `` tags for instant LCP scores. * **YouTube Shorts Support:** Automatically detects `/shorts/` URLs and displays them in a sleek 9:16 vertical player. * **Smart Deep-Linking:** Timestamps (`t=1m30s`) and Playlists (`list=...`) now work perfectly. * **RSS & Email Safe:** Automatically converts videos into high-quality **clickable images** for newsletters (Gmail/Outlook compatible). * **Eco-Shield Impact Widget:** Track exactly how much bandwidth and CO2 you have saved directly from your Dashboard. * **Settings Page:** Toggle features on/off (Admin Bar, Notifications, Dashboard Widget). ### 🛡️ Comprehensive Protection Eco-Shield automatically detects and optimizes: * **YouTube Shorts:** (New!) Displays Shorts in vertical mode. * **Gutenberg Blocks:** Core YouTube and Vimeo blocks. * **Auto-Embeds (oEmbed):** Plain URLs pasted into the editor. * **Legacy Iframes:** Hard-coded iframes from YouTube and Vimeo. * **Widgets & Sidebars:** (New!) Protects videos in Sidebars and Custom HTML widgets. * **RSS Feeds:** (New!) Smart fallback ensures emails never show broken video players. ### ⚡ Why use Eco-Shield? * **🚀 Instant Speed Boost:** Drastically reduces page size (WebP images are often <20kb). * **🌱 Eco-Friendly:** Reduces data transfer and server energy usage. * **🔒 Privacy First (GDPR/DSGVO):** Zero cookies and Zero 3rd-party connections on initial load. * **♿ Accessible:** Built with screen readers, keyboard navigation, and ARIA labels in mind. * **⚡ Zero Configuration:** No confusing settings. Just activate it. == Installation == 1. Upload the `eco-shield.zip` file to the `/wp-content/plugins/` directory. 2. Activate the plugin through the 'Plugins' menu in WordPress. 3. **That's it!** Old and new videos are automatically protected. == Frequently Asked Questions == = How do I clear the thumbnail cache? = We added a new button to your top Admin Bar: **"Purge Eco-Shield"**. Clicking this will: 1. Delete all local WebP/JPG files. 2. Automatically trigger WP Rocket, LiteSpeed, or Autoptimize to clear their page cache. = Where are the images stored? = Images are stored locally in your uploads folder under `/eco-shield-thumbs/`. This ensures your site doesn't rely on external servers (YouTube/Vimeo) to load images, which is great for Privacy and SEO. = Does storing images locally use too much disk space? = No. The trade-off is massively in your favor. A single cached WebP thumbnail is ~30KB. The original YouTube embed is ~1.7MB. Hosting the tiny image locally is what allows your site to load instantly and remain GDPR compliant (by preventing Google from tracking users before they click play). = Is it compatible with RSS Emails? = Yes! Version 1.2.0 features a smart fallback that converts video embeds into high-quality, clickable static images for RSS feeds and email newsletters. This prevents the "broken iframe" issue common in Gmail and Outlook. = Is it compatible with caching plugins? = Yes. Fully compatible with WP Rocket, LiteSpeed, W3 Total Cache, and Autoptimize. == Screenshots == 1. The Click-to-Load Shield: Replaces heavy video iframes with a lightweight, static image that blocks tracking until the user clicks "Play". 2. Admin Toolbar: The new "Purge Eco-Shield" button for easy management. 3. Settings Page: Toggle features and view your impact stats. 4. Dashboard Widget: Track bandwidth and CO2 savings. == Changelog == = 1.2.0 = * **New:** Added **YouTube Shorts Support** (Detects /shorts/ and switches to vertical 9:16 player). * **New:** Added **RSS & Email Fallback** (Replaces videos with clickable images in feeds to prevent broken emails). * **New:** Added **Smart Deep-Linking** (Supports start time and playlist parameters). * **New:** Added **Native Lazy-Loading** (Switched to `` tags for faster LCP scores). * **New:** Added **Settings Page** (Settings -> Eco-Shield) to toggle features. * **New:** Added **Eco-Shield Impact** Dashboard Widget. * **New:** Added **Widget & Sidebar Protection**. * **New:** Added **Legacy Iframe Optimizer** (Optimizes old, hardcoded iframes). * **Improvement:** Full Internationalization (i18n) support. * **Improvement:** Added support for 'youtube-nocookie.com' domains. * **Improvement:** Database cleanup added to uninstall process. = 1.1.1 = * Improvement: Updated filesystem operations to adhere to strict WordPress.org coding standards. * Improvement: Fixed static analysis warnings regarding global prefixes and nonces. = 1.1.0 = * **New:** Local Thumbnail Caching (100% GDPR Compliance). * **New:** Automatic WebP Conversion Engine (Reduced image sizes by ~60%). * **New:** Admin Bar "Purge Cache" Button with modern SVG icon. * **New:** Added Accessibility support (Keyboard navigation + WCAG AA contrast colors). * **New:** Frontend Success Notifications (Toast message) when purging cache. * **New:** Added `uninstall.php` to clean up all files upon deletion. * **Fix:** Added RSS/Feed detection to prevent broken videos in Email Newsletters. * **Security:** Added directory browsing protection (`index.php`) to the cache folder. * **Compatibility:** Added auto-purge hooks for WP Rocket, LiteSpeed, and Autoptimize. = 1.0.1 = * Fix: Enable backend video previews for the block editor. = 1.0.0 = * Initial release.