外掛說明
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.
License
This plugin is released under the GPLv2 or later.
You can use it freely in commercial or personal projects.
安裝方式
- Upload the plugin folder to the
/wp-content/plugins/directory. - Activate the plugin through the ‘Plugins’ menu in WordPress.
- Ensure each subsite in your network has the proper
WPLANGsetting (via Settings > General). - Create pages/posts with matching slugs across language sites for automatic URL matching.
- (Optional) Customize translations and flag mappings in
/assets/flags/andlocales_flags.json. - (Optional) Use the network admin settings to hide specific sites, hide the entire language switcher, or adjust its position.
常見問題集
-
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
WPLANGsetting 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.jsonfile 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.
使用者評論
參與者及開發者
變更記錄
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.
