=== EffortLess Multisite Language Switcher ===
Contributors:      domclic
Donate link: https://id7.dev/donate/?plugin=effortless-multisite-language-switcher
Tags:              multisite, language switcher, translation, network, multilingual
Requires at least: 6.2
Tested up to:      7.0
Requires PHP: 7.4
Stable tag:        1.1.9
License:           GPLv2 or later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

Adds a floating globe icon to WordPress Multisite to switch between different languages or subsites easily.

== Description ==

**EffortLess Multisite Language Switcher** is a lightweight plugin designed for WordPress Multisite networks.
It adds a floating globe icon on the frontend, allowing users to quickly switch between subsites — each typically representing a different language or locale.

The plugin detects each site's locale setting and displays an appropriate flag icon. Flags are automatically mapped using a JSON file and preloaded to enhance performance. Optimized caching ensures fast rendering of the switcher.

This plugin is ideal for multilingual networks using subdirectories or subdomains.

**Features:**
- Automatically detects and displays flags for each site in the network.
- Uses a floating, always-visible globe icon for an intuitive language switcher.
- Intelligently switches to equivalent pages/posts with matching slugs across language sites.
- Falls back to site homepage if equivalent page doesn't exist on target site.
- Option to hide the language switcher on all sites via network admin settings.
- Customizable switcher position (top-left, top-right, bottom-left, bottom-right) with adjusted top spacing.
- Flag menu appears below the switcher for top positions and above for bottom positions.
- Smart caching using WordPress transients for flag mappings and site lists.
- Fully compatible with subdirectory and subdomain multisite setups.
- Optimized for performance with minimal resource usage.

== Installation ==

1. Upload the plugin folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Ensure each subsite in your network has the proper `WPLANG` setting (via **Settings > General**).
4. Create pages/posts with matching slugs across language sites for automatic URL matching.
5. (Optional) Customize translations and flag mappings in `/assets/flags/` and `locales_flags.json`.
6. (Optional) Use the network admin settings to hide specific sites, hide the entire language switcher, or adjust its position.

== Frequently Asked Questions ==

= Does this plugin work on single-site WordPress installations? =
No. This plugin is designed exclusively for WordPress Multisite networks.

= How does it detect the language for each subsite? =
It uses the `WPLANG` setting from each site's options.

= How does the plugin match pages across different language sites? =
The plugin looks for pages/posts with the same slug (post name) on the target language site. For example, if you're viewing `/en/about-us/` and switch to French, it will try to load `/fr/about-us/`. If that page doesn't exist, it falls back to the homepage of the French site.

= Do I need to manually link pages together? =
No! As long as your pages/posts have the same slug across different language sites, the plugin will automatically find and link to them.

= Can I customize the flags or locales? =
Yes! Edit the `assets/flags/locales_flags.json` file to add or modify mappings.

= Are the flags hosted locally? =
Yes, all flag icons are SVG files stored in the plugin's `/assets/flags/1x1/` directory.

= Can I hide the language switcher completely? =
Yes, you can disable the language switcher for all sites using the option in the network admin settings.

= Can I change the position of the language switcher? =
Yes, you can select from top-left, top-right, bottom-left, or bottom-right positions in the network admin settings, with top positions adjusted for better spacing.

= What happens if a page doesn't exist in the target language? =
The plugin will automatically redirect to the homepage of the target language site.

== Screenshots ==

1. Floating globe icon in the bottom-right corner.
2. Language switcher with site flags.
3. JSON mapping file for locales to flag codes.
4. Network admin settings to hide specific sites, hide the entire switcher, or adjust its position.

== Changelog ==

= 1.1.9 =
* New: per-site overrides in Network Admin settings — set a custom flag icon and/or a custom URL for any site, so a flag (e.g. an EU flag) can link anywhere, including outside the network.

= 1.1.8 =
* Fix: update plugin name casing to EffortLess; add plugin identifier to donate link.

= 1.1.7 =
* Refactor: donate notice file kept as includes/class-donate-notice.php (preserves SVN file history); class remains Effortless_Donate_Notice.


= 1.1.6 =
* Fix: donate notice now correctly displays on Network Admin pages — screen ID normalization strips WordPress's -network/-user suffix before matching.


= 1.1.5 =
* Refactor: donate notice class renamed Donate_Notice → Effortless_Donate_Notice (WP-standard prefix); file renamed to class-effortless-donate-notice.php. No phpcs:ignore needed anywhere.


= 1.1.4 =
* Fix: donate notice now uses current_screen hook for reliable screen detection on single-site and multisite Network Admin pages.


= 1.1.3 =
* Improvement: added dismissible donate notice on the plugin settings screen.
* Improvement: added Donate link header field and includes/class-donate-notice.php.


= 1.1.1 =
* Fix an error with svn

= 1.1.0 =
* Refactored: Split monolithic ELMLS_Plugin class into separate focused classes (Flag_Resolver, Site_Data, Frontend, Admin)
* Improved maintainability with dependency injection pattern
* No functional changes — all existing features and hooks preserved

= 1.0.36 =
* Fixed missing world.svg fallback to use us.svg instead

= 1.0.35 =
* Fixed empty locale default to en_US for English sites

= 1.0.34 =
* Fixed flag menu position: top positions show below, bottom positions show above
* Simplified JavaScript (removed auto-positioning that caused issues)
* Flags menu now centered horizontally

= 1.0.33 =
* Auto-position flag menu based on available space (shows up if more space above, down if more space below)

= 1.0.32 =
* Added custom position option (X/Y coordinates) in settings page
* Added JavaScript toggle for custom position fields

= 1.0.31 =
* Added custom flag mapping setting in network admin
* Added shortcode [elmls_switcher] with position parameter
* Fixed shortcode assets loading

= 1.0.30 =
* Added filters for extensibility: elmls_flag_mapping, elmls_switcher_position, elmls_sites
* Added duplicate elmls_switcher_position filter fix

= 1.0.29 =
* Performance: Added object caching support for flag mapping
* Performance: Reduced database queries by batch-fetching site locales using get_blog_details()
* Performance: Added versioned transient keys to auto-invalidate cache on plugin updates
* Performance: Optimized settings page with batch fetching

= 1.0.28 =
* Added missing Estonian locale (et) mapping
* Fixed en_GB flag (was uk, now gb)
* Fixed sq_XK and sr_XK flags (was ko, now xk)

= 1.0.27 =
* Fixed Vietnam flag not showing

= 1.0.26 =
* Fixed Latvia flag not showing

= 1.0.25 =
* Fixed JavaScript click handling to allow natural link navigation.
* Removed unnecessary event handlers that were preventing flag clicks.
* Improved outside-click detection for better menu behavior.
* Enhanced cache-busting with version update.

= 1.0.24 =
* Added intelligent page/post matching across language sites by slug.
* Plugin now automatically switches to equivalent pages with matching slugs on target sites.
* Falls back to site homepage if equivalent page doesn't exist.
* Improved URL handling for better cross-site navigation.
* Enhanced user experience with seamless language switching on specific pages.

= 1.0.23 =
* Refined CSS integration to ensure flag menu appears below the switcher for top positions and above for bottom positions, aligning with style.css.

= 1.0.22 =
* Improved CSS for flag menu positioning with explicit z-index and spacing; fixed JavaScript typo in timeout clearing.

= 1.0.21 =
* Updated JavaScript to ensure flag menu positioning compatibility (below for top positions, above for bottom positions).

= 1.0.20 =
* Flag menu now appears below the language switcher for top positions and above for bottom positions.

= 1.0.19 =
* Adjusted top positioning of language switcher (top-left, top-right) to be further from the top edge for better spacing.

= 1.0.18 =
* Added option to select language switcher position (top-left, top-right, bottom-left, bottom-right) via network admin settings.

= 1.0.17 =
* Added option to hide the language switcher on all sites via network admin settings.

= 1.0.16 =
* Settings only available on multisite admin dashboard.

= 1.0.15 =
* Added checkbox to choose visible languages.

= 1.0.14 =
* Fixed PHPCS errors: Renamed file to class-elmls-plugin.php, added @package tag.
* Conditionalized error_log calls to reduce debug log clutter.
* Justified file_get_contents for local file usage.

= 1.0.13 =
* Fixed PHPCS errors: Added docblocks, renamed file to class-elmls-plugin.php, removed short ternaries, and conditionalized debug logs.
* Improved code compliance with WordPress coding standards.
* Optimized flag rendering with explicit logic.

= 1.0.12 =
* Optimized performance: Added transient caching for flag URLs and site queries.
* Improved flag rendering speed by simplifying image handling.
* Fixed debug log clutter by conditionalizing error_log calls with WP_DEBUG.
* Enhanced JavaScript for faster UI initialization.

= 1.0.11 =
* Fixed issue showing duplicate flags.

= 0.3.0 =
* Initial public release.
* Added JSON-based flag mapping.
* Implemented transient caching for site listing.
* Included floating icon rendering logic.

== Upgrade Notice ==

= 1.1.1 =
* Fix an error with svn

= 1.0.27 =
* Fixed Vietnam flag not showing

= 1.0.26 =
* Fixed Latvia flag not showing

= 1.0.25 =
* Critical fix: Resolved JavaScript click handling issue that prevented language switching. Update recommended for all users.

= 1.0.24 =
* Major enhancement: Plugin now intelligently switches to equivalent pages/posts across language sites. If you have pages with matching slugs on different language sites, they will now be automatically linked!

= 1.0.23 =
* Refined CSS integration to ensure flag menu appears below the switcher for top positions and above for bottom positions, aligning with style.css.

= 1.0.22 =
* Improved CSS for flag menu positioning with explicit z-index and spacing; fixed JavaScript typo in timeout clearing.

= 1.0.21 =
* Updated JavaScript to ensure flag menu positioning compatibility (below for top positions, above for bottom positions).

= 1.0.20 =
* Flag menu now appears below the language switcher for top positions and above for bottom positions.

= 1.0.19 =
* Adjusted top positioning of language switcher (top-left, top-right) to be further from the top edge for better spacing.

= 1.0.18 =
* Added option to select language switcher position (top-left, top-right, bottom-left, bottom-right) via network admin settings.

= 1.0.17 =
* Added option to hide the language switcher on all sites via network admin settings.

= 1.0.16 =
* Settings only available on multisite admin dashboard.

= 1.0.15 =
* Added checkbox to choose visible languages on multisite admin dashboard.

= 1.0.14 =
* Fixed PHPCS errors: Renamed file to class-elmls-plugin.php, added @package tag.
* Conditionalized error_log calls to reduce debug log clutter.
* Justified file_get_contents for local file usage.

== License ==

This plugin is released under the GPLv2 or later.
You can use it freely in commercial or personal projects.
