=== GeoLang for Block Editor ===
Contributors: nickdigitalprojects
Tags: multilingual, translation, language, block editor, language switcher, hreflang
Requires at least: 5.8
Tested up to: 7.1.2
Requires PHP: 7.4
Stable tag: 1.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

An advanced WordPress plugin for managing multilingual websites, optimized for the WordPress block editor.

== Description ==

GeoLang for Block Editor is a multilingual plugin designed specifically for the WordPress block editor. It allows you to create and manage translations for your posts, pages, custom post types, block templates, and template parts without leaving the WordPress admin interface.

**Requirements & Compatibility:**

* Requires the WordPress **block editor**. GeoLang is NOT compatible with content built in Elementor, Divi, WPBakery, or with the Classic Editor replacing the block editor — a warning notice is shown in the admin if one of them is detected
* Translating **posts, pages and custom post types** works on any theme that uses the block editor
* Translating **templates, template parts** (header, footer) and **navigation blocks** requires a block theme / Full Site Editing (FSE) environment

**Key Features:**

* **100% Block Editor Native**: Manage page and post translations directly from the block editor sidebar. Full support for Templates, Template Parts and Block Themes
* **Path-Based Routing**: Clean URL structure with /{lang}/ prefixes (e.g. /it/, /en/) for SEO-friendly multilingual URLs
* **90+ Languages**: Support for all major European, Asian, African and Middle Eastern languages, including right-to-left (Arabic, Hebrew, Persian, Urdu) — pick any combination in settings
* **Custom Post Types**: Full routing, translation and archive support for any public CPT (e.g. /en/portfolio/my-project/)
* **Localized Interface**: When a translated language is active, GeoLang switches the WordPress locale — dates, month names and theme strings (e.g. "Read more") are displayed in that language whenever a WordPress language pack is installed
* **Smart IP Detection**: Automatically redirect visitors to their local language using external APIs (ipapi.co, ipwho.is) or MaxMind local database
* **Switzerland-Aware Detection**: Unique canton-based language detection for Swiss visitors — Ticino gets Italian, Geneva gets French, Zurich gets German, and bilingual cantons (Bern, Fribourg, Valais) respect the browser's Accept-Language preference. Manual canton override is available in the IP Test panel
* **MaxMind Local Database (Pro — coming soon)**: Planned support for the GeoLite2 database locally, for unlimited, privacy-compliant IP detection with no API rate limits
* **Full Templates & Template Parts Translation**: Translate complete Site Editor templates (single post, page, archive) plus headers, footers and other template parts in Full Site Editing (FSE) themes
* **Language-Filtered Archives**: Category, tag, taxonomy, author, date and CPT archives — plus Query Loop blocks — only show content in the active language
* **Menu Translation**: Translate both classic WordPress menus and block editor navigation blocks
* **SEO Ready**: Full integration with Yoast SEO, Rank Math, and Core Sitemaps. Automatic hreflang tags and HTML lang attribute generation
* **Language Switcher**: Customizable frontend language selector with multiple styles, positions, and flag support
* **Post Duplicator**: Quickly create translation copies of your content
* **Lightning Fast**: Optimized for performance with no bloat — just efficient multilingual functionality

**Free vs Pro (coming soon):**

The Free version includes all essential multilingual features: block editor integration, IP detection (external APIs), SEO, templates and template parts, menu translation, and language switcher.

GeoLang Pro is currently in development and not yet available. Planned Pro features include:
* MaxMind local database for unlimited, privacy-compliant IP detection
* Machine Translation with DeepL (bring-your-own-key)
* Bulk operations for posts, pages, and menus
* Advanced language redirect (cookie → browser → IP → default)
* Import/Export translations (CSV & JSON)
* Advanced revisions with block-level comparison
* Paid Memberships Pro integration
* Priority email support

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/geolang-for-block-editor` directory, or install the plugin directly through the WordPress plugins screen.
2. Activate the plugin through the 'Plugins' screen in WordPress
3. Navigate to Settings > GeoLang to configure your languages and detection settings

== Frequently Asked Questions ==

= Does this plugin work with the Classic Editor or page builders? =

No. GeoLang requires the WordPress block editor and is not compatible with content built in Elementor, Divi, WPBakery, or sites where the Classic Editor fully replaces the block editor. Template, template-part and navigation translation additionally require a block theme (FSE). A warning notice is shown in the admin when an incompatible builder is detected.

= Does IP detection work with page caching, VPNs, or Cloudflare? =

IP detection runs on the server on the visitor's first page load. A few notes:

* **Page caching**: aggressive full-page caches (WP Super Cache, LiteSpeed Cache, Cloudflare APO, etc.) may serve a cached page before detection runs, or cache one language for everyone. If you enable IP detection, exclude the homepage and other unprefixed entry URLs from the page cache, or verify your cache is compatible with per-language variations.
* **VPNs / travel**: visitors using a VPN or browsing from abroad will be detected by their IP location. They can always override the detected language with the language selector — their choice is remembered in a cookie.
* **Proxies / CDNs**: for security, GeoLang only trusts forwarding headers (X-Forwarded-For) when the connecting IP is a trusted proxy. If your site sits behind a reverse proxy or CDN, add its IPs/ranges to the `geolang_trusted_proxies` filter or the `trusted_proxies` option.

= How does IP-based language detection work? =

The Free version uses external APIs (ipapi.co, ipwho.is) to detect the visitor's location and automatically switch to the appropriate language. GeoLang Pro (in development) will add support for a local MaxMind GeoLite2 database for unlimited, privacy-compliant detection with no API rate limits.

= Can I translate navigation menus? =

Yes, GeoLang supports translation of both classic WordPress menus and block editor navigation blocks (Full Site Editing).

= How does Switzerland canton-based detection work? =

Switzerland has four official languages (German, French, Italian, Romansh) distributed across 26 cantons. Unlike most plugins that default all Swiss visitors to German, GeoLang detects the visitor's canton from the IP geolocation API and assigns the correct language:

* Ticino (TI) → Italian
* Geneva (GE), Vaud (VD), Neuchâtel (NE), Jura (JU) → French
* Zurich (ZH), Lucerne (LU), Basel, etc. → German
* Bern (BE) → German or French based on browser preference
* Fribourg (FR), Valais (VS) → French or German based on browser preference
* Grisons (GR) → Romansh, Italian, or German based on browser preference

You can also manually override the canton from the IP Test panel in the admin settings for testing purposes.

= Does this plugin support multilingual SEO? =

Yes, GeoLang automatically generates hreflang tags and HTML lang attributes. It also integrates with RankMath and Yoast SEO for multilingual sitemaps.

= What are the differences between Free and Pro versions? =

The Free version includes all core multilingual features: block editor integration, path-based routing, IP detection (external APIs), Switzerland canton-aware detection, SEO (hreflang, sitemaps, Yoast, Rank Math), template parts and menu translation, language switcher, and post duplicator. GeoLang Pro is currently in development (not yet available) and will add MaxMind local database, machine translation with DeepL, bulk operations, advanced redirect, import/export, advanced revisions, Paid Memberships Pro integration, and priority support.

== Screenshots ==

1. GeoLang Dashboard and plugin status
2. Template Parts translation and linking interface
3. General settings and language configuration
4. Menu Translator interface
5. IP Detection settings page

== Changelog ==

= 1.2.0 =
* Added full template (wp_template) translation support: the GeoLang sidebar now works when editing complete Site Editor templates, not just template parts — translated templates are served automatically on localized pages
* Added per-language WordPress locale switching: dates, month names and theme/plugin strings (e.g. "Read more") now appear in the active language when a WordPress language pack is installed
* Fixed geo-IP redirects being cached permanently: detection redirects now use 302 (temporary) and send no-cache headers instead of cacheable 301s
* Fixed taxonomy, category, tag, author, date and CPT archives mixing all languages: archives now show only posts in the current language
* Fixed Query Loop blocks with custom queries showing all languages mixed — they now follow the same language filter
* Hardened client IP detection: X-Forwarded-For and similar headers are only trusted from whitelisted proxies/CDNs (geolang_trusted_proxies filter), preventing language spoofing
* Added admin warning notice when an incompatible editor is detected (Elementor, Divi, WPBakery, Classic Editor)
* Improved readme: clarified block editor / block theme requirements and page-cache notes for IP detection

= 1.1.0 =
* Expanded language support from 10 to 90+ real languages (Europe, Asia, Africa, Middle East, Pacific), including right-to-left languages
* Added 91 flag images for the language switcher; missing flags gracefully fall back to the language name (no broken images)
* Greatly expanded IP-based country-to-language detection (~150 countries), with Accept-Language-aware handling for multilingual countries (Belgium, Luxembourg, India, Nigeria, South Africa, Central Asia, and more)
* Added full SEO locale map (hreflang / og:locale) for all supported languages
* Language column now appears in post and custom post type list tables, not only pages
* Fixed translations metabox "content not found" validation for custom post types
* Fixed translated URLs for custom post types with a rewrite base: /{lang}/{cpt-base}/{slug}/ (e.g. /en/portfolio/my-project/) instead of a flat /{lang}/{slug}/
* Fixed language switcher links for custom post types (previously skipped non-page translations)
* Fixed rewrite rules being flushed on every page load (performance)
* Fixed template part edit link opening a non-existent Site Editor ID: the real theme//slug composite ID is now resolved from the server instead of guessed
* Fixed translated template parts missing the wp_theme / template-part-area terms (which made the Site Editor show "element not found")
* Fixed empty language dropdown in the Menu Translation panel (missing admin-ajax nonce) and sidebar create/check calls failing silently in the Site Editor
* Added an in-editor "How to translate" guide panel and a dashboard help card

= 1.0.1 =
* Added option to disable automatic navigation menu translation
* Fixed mobile navigation menu button (hamburger) when menu translation is active
* Preserved Gutenberg data-wp-* and aria-* attributes in navigation and template part rendering

= 1.0.0 =
* Initial release
* WordPress block editor integration
* IP-based language detection via external APIs
* Template parts translation for FSE
* SEO helpers (hreflang, lang attribute)
* Sitemap support for RankMath and Yoast
* Foundation revision system
* Language switcher with customizable styles
* Post duplicator for quick translation creation

== Upgrade Notice ==

= 1.2.0 =
Feature and bug fix release: full Site Editor template translation, geo redirects no longer cached permanently, archives and Query Loop blocks no longer mix languages, per-language locale switching, hardened IP detection, and a compatibility warning for non-block editors.

= 1.1.0 =
Feature release: 90+ supported languages with flags, expanded IP detection, full SEO locale coverage, and language column for all post types.

= 1.0.1 =
Bug fix release: adds an option to disable automatic menu translation and fixes mobile navigation menu rendering.

= 1.0.0 =
Initial release of GeoLang for Block Editor.

== External Services ==

This plugin optionally uses third-party IP geolocation APIs to detect the visitor's language based on their IP address. This feature is disabled by default and can be enabled in the IP Detection settings.

= ipapi.co =

* **What it is**: A free IP geolocation API that returns country and language information based on the visitor's IP address.
* **What data is sent**: The visitor's IP address is sent to `https://ipapi.co/{ip}/json/` when IP detection is enabled and the visitor has no language cookie set.
* **When**: Only on the first page load when IP detection is active and no language preference cookie exists.
* **Terms of Service**: https://ipapi.co/terms/
* **Privacy Policy**: https://ipapi.co/privacy/

= ipwho.is =

* **What it is**: A free IP geolocation API that returns country and language information based on the visitor's IP address.
* **What data is sent**: The visitor's IP address is sent to `https://ipwho.is/{ip}` when IP detection is enabled and the visitor has no language cookie set.
* **When**: Only on the first page load when IP detection is active and no language preference cookie exists.
* **Terms of Service**: https://ipwhois.io/terms
* **Privacy Policy**: https://ipwhois.io/privacy

== Credits ==

Plugin developed by Nick Digital Projects.

== License ==

This plugin is licensed under the GPLv2 or later.

== License URI ==

https://www.gnu.org/licenses/gpl-2.0.html
