=== Vizou Bling ===
Author: Dana Whittle
Author URI: https://vizou.com
Requires PHP: 8.0
Requires at least: 6.0
Tested up to: 7.0
Stable tag: 1.0.0
License: GPLv2 or later

Lightweight bilingual (English/French) content switching for custom themed sites: cookie- and URL-based language detection, ACF field groups for translated content, and cache-safe client-side language/tab switching.

This plugin was created for personal use in developing custom themes and not intended for the WordPress.org repository, although it passes testing for important criteria (such as security).

== Description ==

Vizou Bling moves the bilingual "language switcher" logic that previously lived in a custom theme's functions.php and ACF field-group files into its own plugin, so:

* The French/English field groups no longer clutter the theme.
* The plugin can be dropped into any Vizou-built site that needs the same English/French pattern, without copy-pasting functions.php blocks.
* The ACF field-group admin list stays clean — the field groups are hidden from Custom Fields > Field Groups (they're still fully usable on the Page/Post edit screen; only the separate list view is hidden, since local/PHP-registered groups aren't editable there anyway).

**What it does:**

* Reads a `?lang=en` or `?lang=fr` URL parameter and stores the visitor's choice in a `site-language` cookie (30-day expiry by default).
* Appends `?lang=fr` to page/post/archive permalinks when the visitor is currently browsing in French.
* Registers "French" ACF field groups (`french_page` on Pages, `french_post` on Posts) with `title` / `content` (and `excerpt`, for posts) sub-fields.
* Provides `vizou_bling_current_language()` for templates to check the active language instead of reading `$_COOKIE` directly.
* Provides `vizou_bling_string()` for visitor-facing text (the language switcher label, "read more" default) with a three-layer override: Settings page value → built-in default → `vizou_bling_string` filter for one-off template overrides.
* Enqueues three small scripts (`jquery.cookie.js`, `langswitch.js`, `tab-navigation.js`) that handle instant client-side language switching and hash-based tab navigation, for templates that opt into that markup convention.
* Adds a single **Vizou Bling** page under **Settings**, with Settings and Help as tabs on that one screen — Settings for the four visitor-facing text fields, Help for a template guide covering how to wire up bilingual content in theme templates.

**What it does not do:**

Render your template markup. This plugin provides the data layer and switching mechanism — the actual page layout (how bilingual content is arranged, whether tabs are used, what CSS classes are involved) stays in the theme, where it belongs. See the Help tab for the minimal pattern a template needs.

== Requirements ==

* WordPress 6.0+
* Advanced Custom Fields — free or Pro, either works. The plugin checks for `acf_add_local_field_group()` at runtime and shows an admin notice if ACF isn't active.

== Installation ==

1. Upload the `vizou-bling` folder to `/wp-content/plugins/`.
2. Activate through the Plugins screen in WordPress.
3. Visit **Settings > Vizou Bling** to optionally customize the switcher label and "read more" defaults (Settings tab), or switch to the Help tab for guidance on wiring up bilingual content in theme templates.
4. If migrating from a theme-based version of this same logic (an earlier functions.php implementation), remove the old `handle_language_parameter()` / permalink filter functions and the old ACF field-group registration file from the theme, and update `wp_enqueue_script()` calls or template code that reference the old script handles or read `$_COOKIE['site-language']` directly.

== A note on caching ==

This plugin has been used in production behind Cloudflare. The cookie- and URL-based detection is safe under page caching as long as templates avoid branching server-side on the current language for cached page output — see the Help tab's "A note on caching" section for the reasoning and the recommended pattern (render both languages, let JavaScript toggle visibility).

== Forking for a different language pair ==

This plugin is deliberately not built as a generic multi-language system — it assumes exactly one secondary language, hardcoded as a language pair (English + one other). If a future site needs a different second language (Spanish, for example), the intended approach is to duplicate this plugin folder and edit `includes/language-config.php`, which centralizes every language-specific value: the language code, display label, ACF field names, month names for date formatting, and default strings. That file is designed to be the only one that needs editing for a fork; everywhere else in the plugin reads from its constants and functions rather than hardcoding French-specific values. Note that CSS class names and JS selectors referencing `fr` literally in a theme's own stylesheet would still need a manual find-and-replace in that theme — this plugin only controls its own code, not the theme's CSS.

== File structure ==

`vizou-bling.php` — bootstrap: plugin header, constants, file includes, ACF dependency check.

`includes/language-config.php` — the fork point. Language code, display label, ACF field names, month-name formatting, and `vizou_bling_string()`'s defaults all live here.

`includes/language-handler.php` — cookie/URL detection, the permalink filter, and the template-facing helper functions (`vizou_bling_current_language()`, `vizou_bling_is_secondary_language()`, `vizou_bling_format_date()`).

`includes/acf-fields.php` — registers the two field groups.

`includes/assets.php` — enqueues the three scripts and localizes config/strings to `langswitch.js`.

`admin/menu.php` — hides the Custom Fields admin list entry, registers the single "Vizou Bling" page under Settings, and renders the shared tab wrapper (Settings / Help) that delegates to the two content functions below.

`admin/settings-page.php` — registers the four text-field settings and renders the Settings tab's form content.

`admin/help-page.php` — renders the Help tab's template guide content.

`assets/js/jquery.cookie.js` — third-party cookie library (unmodified), MIT licensed.

`assets/js/langswitch.js` — client-side language switching, tab visibility, and internal-link rewriting.

`assets/js/tab-navigation.js` — hash-based tab activation on page load and browser back/forward.

== Changelog ==

= 1.0.0 =
* Initial release. Extracted from theme-based implementation into a standalone plugin: ACF field groups, cookie/URL language handling, a tabbed Settings/Help page under Settings, and the three supporting scripts.