This guide covers the installation, initial configuration, and basic usage of the Multisite Language Switcher plugin for WordPress multisite networks. It provides step-by-step instructions for setting up the plugin across multiple language blogs and creating your first multilingual content.
For detailed information about the admin interface settings, see Settings and Configuration Pages. For advanced content import features, see Content Import System. For SEO configuration, see SEO and Alternate Links.
The Multisite Language Switcher requires a WordPress multisite installation. The plugin will not function on a standard single-site WordPress installation.
Multisite Network Requirements:
Requirement | Minimum Version | Notes |
---|---|---|
WordPress | 6.1 | Multisite must be enabled |
PHP | 7.4 | Required for plugin compatibility |
Network Type | Subdomain or Subfolder | Both configurations are supported |
The plugin checks for multisite activation during initialization in MultisiteLanguageSwitcher.php39 and displays an admin notice if the multisite feature is not active MslsPlugin.php83-98
Sources: MultisiteLanguageSwitcher.php39 MslsPlugin.php34-100
Network Admin
> Plugins
> Add New Plugin
Install Now
and then Network Activate
/wp-content/plugins/
Network Admin
> Plugins
Activate
on the Multisite Language Switcher entryInstallation Workflow:
Sources: MultisiteLanguageSwitcher.php1-245 MslsPlugin.php34-100 MslsPlugin.php199-201
After installation, each blog in the multisite network must be configured individually to specify its language and display preferences.
Sources: MslsAdmin.php128-151 MslsAdmin.php336-342 MslsAdmin.php252-269
On each blog where you want to enable multilingual functionality:
Settings
> Multisite Language Switcher
MslsOptions::is_empty()
MslsAdmin.php131If the plugin is not configured, an admin notice is displayed by MslsAdmin::has_problems()
MslsAdmin.php128-151
The MslsAdmin
class provides settings sections registered via MslsAdmin::register()
MslsAdmin.php204-230:
Language Settings Section:
Field | Description | Storage |
---|---|---|
Blog Language | WordPress locale code (e.g., de_DE , fr_FR , en_US ) | Stored in WordPress option WPLANG |
The language selection dropdown is rendered by MslsAdmin::blog_language()
MslsAdmin.php336-342 and uses MslsOptions::get_available_languages()
MslsOptions.php361-385 to populate available languages from installed WordPress language packs.
Sources: MslsAdmin.php336-342 MslsOptions.php361-385 MslsAdmin.php466-474
Key Configuration Options:
Setting | Class Property | Description |
---|---|---|
Display | $options->display | Icon display mode (flag, text, or combination) |
Admin Display | $options->admin_display | Admin interface icon type (flag or label) |
Description | $options->description | Custom blog description for language switcher |
Sort Order | $options->sort_by_description | Sort languages by description or language code |
The main settings section is registered via MslsAdmin::main_section()
MslsAdmin.php252-269
Display Options Architecture:
Sources: MslsAdmin.php252-269 MslsOptions.php29 MslsAdminIcon.php14-66
The advanced settings section provides additional configuration options registered via MslsAdmin::advanced_section()
MslsAdmin.php278-288:
Setting | Default | Purpose |
---|---|---|
Autocomplete | Off | Enable AJAX autocomplete for content linking |
Reference User | First user | User whose blog access determines visible blogs |
Exclude Blog | Off | Hide this blog from language switcher output |
Content Import | Off | Enable content duplication features |
The reference user setting determines which blogs appear in the collection via MslsBlogCollection::get_blogs_of_reference_user()
MslsBlogCollection.php128-142
Sources: MslsAdmin.php278-288 MslsAdmin.php371-393 MslsBlogCollection.php128-142
Configuration is validated by MslsAdmin::validate()
MslsAdmin.php441-457 before being saved to the database. The blog language is saved separately to the WPLANG
option via the filter MslsAdmin::set_blog_language()
MslsAdmin.php466-474
Once multiple blogs are configured with different languages, the MslsBlogCollection
class manages the network of language blogs.
Blog Collection Architecture:
Sources: MslsBlogCollection.php50-96 MslsBlogCollection.php128-142 MslsBlogCollection.php243-256
MslsBlog Object Properties:
Each blog in the collection is represented by a MslsBlog
object MslsBlog.php11:
Property | Type | Source |
---|---|---|
userblog_id | int | WordPress blog ID |
language | string | From get_blog_option(blog_id, 'WPLANG') |
description | string | From msls option or language fallback |
Sources: MslsBlog.php11-47 MslsBlogCollection.php331-339
After configuring multiple blogs, you can link posts, pages, and custom post types across language versions.
Sources: MslsMetaBox.php56-81 MslsMetaBox.php232-248 MslsMain.php
The meta box is registered for post edit screens via MslsMetaBox::init()
MslsMetaBox.php56-81:
Meta Box Components:
Component | Class | File | Purpose |
---|---|---|---|
Meta Box Container | MslsMetaBox | MslsMetaBox.php | Renders language link inputs |
AJAX Suggestion | MslsMetaBox::suggest() | MslsMetaBox.php:339-368 | Autocomplete search |
Link Storage | MslsOptionsPost | MslsOptionsPost.php | Stores post ID mappings |
Save Handler | MslsMain::save() | MslsMain.php | Saves translation links |
Translation Link Storage Format:
Sources: MslsOptionsPost.php MslsOptions.php143-145 MslsLanguageArray.php
When autocomplete is enabled ($options->activate_autocomplete
), the meta box uses AJAX to search for posts:
Autocomplete Request Flow:
Sources: MslsMetaBox.php339-368 MslsPlugin.php79 src/msls.js
Once content is linked across languages, you can display the language switcher to visitors using multiple methods.
Sources: MslsWidget.php MslsBlock.php MultisiteLanguageSwitcher.php79-82 MslsOutput.php34-90
Add the language switcher directly to your theme template files:
The the_msls()
function is defined in MultisiteLanguageSwitcher.php79-82 and internally calls get_the_msls()
MultisiteLanguageSwitcher.php57-62
Function Call Chain:
Sources: MultisiteLanguageSwitcher.php57-82 MslsPlugin.php50 MslsOutput.php134-145
Appearance
> Widgets
The widget class MslsWidget
extends WP_Widget
and is registered via MslsWidget::init()
MslsPlugin.php47
Sources: MslsWidget.php MslsPlugin.php47
msls-widget-block
The block is registered via MslsBlock::init()
MslsPlugin.php44 and built using @wordpress/scripts
package.json
Sources: MslsBlock.php MslsPlugin.php44 src/msls-widget-block/
Insert [sc_msls]
in post content or [sc_msls_widget]
for widget-style output.
Shortcodes are registered via MslsShortCode::init()
MslsPlugin.php45
Sources: MslsShortCode.php MslsPlugin.php45 readme.txt35-36
All display methods ultimately use the MslsOutput
class to generate the HTML output.
Rendering Sequence:
Sources: MslsOutput.php34-90 MslsBlogCollection.php297-299 MslsOptions.php215-231
The plugin uses WordPress multisite functions to switch context when generating URLs:
Function | Purpose | Location |
---|---|---|
switch_to_blog($blog_id) | Change global WordPress context to target blog | MslsOutput.php:53 |
restore_current_blog() | Restore original blog context | MslsOutput.php:56, 63 |
This pattern ensures that permalinks and post data are fetched from the correct blog in the network.
Sources: MslsOutput.php53-64
After completing the basic setup:
For troubleshooting and advanced configuration, consult the Admin Interface documentation.
Sources: readme.txt23-40 README.md19-60
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.