=== Font Optimization for Google Fonts - Optimize Fonts of Your WordPress Website ===
Contributors:      rinkuyadav999
Tags:              google fonts, font optimization, performance, gdpr, page speed
Requires at least: 5.6
Tested up to:      7.0
Requires PHP:      7.4
Stable tag:        1.0
License:           GPL-2.0+
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

The complete font optimization for Google Fonts plugin — boost page speed, fix render-blocking fonts, and self-host for GDPR compliance.

== Description ==

**LBC Font Optimization for Google Fonts** is the all-in-one WordPress plugin for complete font optimization for Google Fonts. It automatically detects, intercepts, and optimizes every Google Fonts request made by your theme and plugins — improving Core Web Vitals, PageSpeed Insights scores, and privacy compliance without any manual code changes.

Whether your goal is a faster website, better Lighthouse scores, or GDPR/DSGVO compliance, this plugin gives you full control over how Google Fonts are loaded on your WordPress site.

= ⚡ Key Features =

* **Preconnect & DNS Prefetch** — Adds `<link rel="preconnect">` and `<link rel="dns-prefetch">` hints for Google Fonts domains, cutting connection latency before a single font byte is requested.
* **font-display Control** — Automatically appends `display=swap` (or your preferred value) to every Google Fonts URL, eliminating invisible text (FOIT) and improving Cumulative Layout Shift (CLS).
* **Async (Non-Blocking) Loading** — Converts Google Fonts `<link>` tags to the `rel="preload"` + `onload` pattern so fonts never block page rendering. A `<noscript>` fallback ensures compatibility with all browsers.
* **Combine Font Requests** — Merges multiple separate Google Fonts API calls into a single HTTP request, reducing round-trips and speeding up font delivery.
* **Local Font Self-Hosting** — Downloads font CSS and WOFF2 files from Google and serves them directly from your own server. Eliminates all external Google requests — the gold standard for GDPR/DSGVO compliance.
* **Remove Google Fonts** — Completely dequeues all Google Fonts from your site. Pair with Local Hosting to keep fonts displaying while blocking the external Google request entirely.
* **Font Detector** — Automatically scans and identifies which themes or plugins are loading Google Fonts, displaying them in a clear admin dashboard table.
* **Exclusion Controls** — Granularly skip optimizations for logged-in users, specific pages (by URL path), or individual style handles.
* **Modern Admin UI** — Clean, tabbed settings page with toggle switches, real-time diagnostics, and a one-click cache-clear tool.

= 🚀 Why Font Optimization for Google Fonts Matters =

Google Fonts are used on millions of WordPress sites — but they come with a hidden performance cost. Each external font request adds connection overhead, and Google Fonts stylesheets are among the most common render-blocking resources flagged by Google PageSpeed Insights, GTmetrix, and Lighthouse.

Beyond performance, loading fonts from Google's servers means visitor IP addresses are sent to Google's infrastructure, raising privacy concerns under GDPR (EU), DSGVO (Germany), and similar regulations.

**LBC Font Optimization for Google Fonts** solves both problems automatically:

* ✅ Faster page loads and better Core Web Vitals scores
* ✅ Higher PageSpeed Insights / Lighthouse ratings
* ✅ Full GDPR/DSGVO compliance via local self-hosting
* ✅ Zero manual code changes required
* ✅ Works with any theme, page builder, or plugin

== Installation ==

== Installation ==

= Option 1: Install via WordPress Dashboard (Recommended) =

1. Navigate to **Dashboard → Plugins → Add New**.
2. Search for **LBC Font Optimization for Google Fonts**.
3. Click **Install Now**, and then click **Activate**.

= Option 2: Upload via WordPress Dashboard =

1. Download the plugin ZIP from the official repository: https://wordpress.org/plugins/lbc-font-optimization-for-google-fonts
2. Go to **Dashboard → Plugins → Add New → Upload Plugin**.
3. Select the downloaded ZIP file and click **Install Now**.
4. Click **Activate Plugin**.

= Option 3: Upload via FTP =

1. Upload the `lbc-font-optimization-for-google-fonts` folder to `/wp-content/plugins/`, or install directly via **Plugins → Add New** in your WordPress dashboard.
2. Activate the plugin through the **Plugins** menu.
3. Navigate to **LBC Google Fonts** in your admin sidebar to configure your font optimization settings.

**Recommended quick-start:** Enable **Preconnect**, **font-display: swap**, and **Async Loading** for an immediate performance boost. Then enable **Local Self-Hosting** to achieve full GDPR compliance.

== Frequently Asked Questions ==

= Will this plugin work with my theme and page builder? =

Yes. The plugin hooks into WordPress's native style enqueue system (`wp_enqueue_style()`). It works seamlessly with any theme, page builder (Elementor, Divi, Beaver Builder, etc.), or plugin that loads Google Fonts the standard WordPress way.

= Is Local Self-Hosting enough for GDPR compliance? =

Yes. When Local Font Self-Hosting is enabled, all font files are downloaded to your server and served locally. No requests are made to Google's servers from your visitors' browsers, which satisfies the most common GDPR/DSGVO guidance regarding third-party font requests.

= What is the difference between "Remove Google Fonts" and "Local Self-Hosting"? =

"Remove Google Fonts" simply dequeues all Google Fonts from your site — fonts will no longer display unless you have local copies. "Local Self-Hosting" downloads the fonts to your server first. For the best result, enable **Local Self-Hosting** first, then enable **Remove** to block the external Google request while keeping your fonts fully functional.

= Does it support both Google Fonts CSS API v1 and v2? =

Yes. Both API versions are fully supported — CSS API v1 (`fonts.googleapis.com/css?family=`) and CSS API v2 (`fonts.googleapis.com/css2?family=`) — including combining requests and local self-hosting for both.

= Where are locally hosted font files stored? =

Font files are saved inside `wp-content/uploads/lbc-gfo-fonts/` by default. You can change the directory from the Local Hosting settings tab.

= Will this slow down my admin dashboard? =

No. All font optimizations apply only to the public-facing frontend. The only admin-side activity is a lightweight connectivity check (once every 5 minutes, cached via WordPress transients) performed on the plugin settings page.

= Does it affect fonts loaded by plugins like WooCommerce or Elementor? =

Yes. The plugin detects and optimizes Google Fonts loaded by any theme or plugin, not just your active theme. Use the built-in **Font Detector** in the Tools & Diagnostics tab to see exactly what is being loaded and from where.

== Screenshots ==

1. Dashboard: Plugin settings page

== External Services ==

This plugin may connect to Google's font infrastructure under the specific conditions described below. No personal data is ever collected or transmitted. Connections only occur when specific features are enabled by the site administrator.

= 1. Google Fonts CSS API (fonts.googleapis.com) =

**What it is:** Delivers font stylesheet files that describe which font files to load.

**When a connection is made:** Only when **Local Font Self-Hosting** is enabled. On the first page load (and when the cache expires), the plugin fetches the Google Fonts CSS stylesheet server-side (via PHP — not the visitor's browser) to identify and download the referenced font files.

**What is sent:** The Google Fonts URL originally enqueued by your theme or plugin (e.g. `https://fonts.googleapis.com/css2?family=Roboto`). A standard Chrome User-Agent string is sent to ensure Google returns WOFF2 files. No visitor IP addresses or personal data are forwarded.

**Who initiates it:** Your WordPress server — not your site visitors' browsers.

= 2. Google Static Fonts CDN (fonts.gstatic.com) =

**What it is:** Google's static file server that hosts the actual WOFF2/WOFF font binary files.

**When a connection is made:** Only when **Local Font Self-Hosting** is enabled, immediately after the CSS is fetched. Each referenced font file is downloaded server-side and saved to your `wp-content/uploads/` directory. After that, all fonts are served entirely from your own server.

**What is sent:** HTTP GET requests for individual font file URLs. A Chrome User-Agent string is sent. No personal data is included.

**Who initiates it:** Your WordPress server — not your site visitors' browsers.

= 3. Google Fonts Connectivity Check (fonts.googleapis.com) =

**What it is:** A lightweight availability test to confirm Google Fonts servers are reachable from your server.

**When a connection is made:** Only on the plugin's admin settings page, at most once every 5 minutes (result is cached in a WordPress transient). Never triggered on the public frontend.

**What is sent:** A simple HTTP GET request to `https://fonts.googleapis.com`. No personal data, font information, or visitor data is sent.

**Who initiates it:** Your WordPress server, triggered only when an administrator views the plugin settings page.

= Google's Legal Documents =

* Google Fonts Terms of Service: https://developers.google.com/terms
* Google Privacy Policy: https://policies.google.com/privacy
* Google Fonts Privacy FAQ: https://developers.google.com/fonts/faq/privacy

**Note:** Once Local Font Self-Hosting is enabled and fonts have been downloaded, all font requests by your site visitors are served from your own server. No Google connections are made for site visitors.

== Changelog ==

= 1.0 =
* Initial release of LBC Font Optimization for Google Fonts.
* Preconnect & DNS-prefetch injection for Google Fonts domains.
* font-display parameter injection (swap, fallback, optional, block, auto).
* Async non-blocking font loading with `<noscript>` fallback.
* Combine multiple Google Fonts requests into a single URL (CSS API v1 & v2).
* Local font self-hosting: download CSS + WOFF2 files and serve from uploads directory.
* Remove / disable all Google Fonts from the site.
* Google Fonts detector with admin dashboard overview table.
* Exclusion controls: logged-in users, URL paths, style handles.
* Modern tabbed admin UI with AJAX-powered cache-clear.

== Upgrade Notice ==

= 1.0 =
Initial release — no upgrade steps required.
