The Multisite Language Switcher (MSLS) is a WordPress plugin that enables multilingual content management across a WordPress multisite network. It allows site administrators to create and maintain translation relationships between posts, pages, taxonomies, and archives across different language-specific blogs within a single multisite installation.
This page provides a high-level introduction to the plugin's purpose, capabilities, and architecture. For detailed information about specific subsystems, see the child pages: Package Structure covers the codebase organization, Getting Started explains installation and initial configuration, and Core Architecture details the design patterns and technical implementation.
Sources: readme.txt1-13 MultisiteLanguageSwitcher.php1-32 README.md1-3
MSLS manages translation relationships in WordPress multisite installations where each language is hosted on a separate blog. The plugin does not perform automatic translation—instead, it provides the infrastructure to:
The plugin operates exclusively in multisite environments and requires at least two blogs configured with different language settings.
Sources: readme.txt13-17 MultisiteLanguageSwitcher.php8
| Requirement | Version |
|---|---|
| WordPress | ≥ 6.1 |
| PHP | ≥ 7.4 |
| Network Type | Multisite (subdomain or subdirectory) |
| Installation Type | Network-activated or per-blog activation |
Sources: readme.txt6-9 composer.json7-10
[sc_msls], [sc_msls_widget])msls_the_switcher(), msls_get_switcher())Sources: readme.txt30-37 README.md39-59
Diagram: Multisite Network Structure with Translation Links
Each blog in the network represents a different language. The plugin stores bidirectional translation relationships—if Blog 1's post 123 links to Blog 2's post 456, then Blog 2's post 456 also links back to Blog 1's post 123. This ensures consistency when switching between blogs.
Sources: readme.txt13-17
Translation relationships are stored as WordPress meta data:
wp_postmeta with keys like _msls_de_DE → post IDwp_termmeta with keys like _msls_de_DE → term IDThe MslsOptions hierarchy manages this data across different content types.
Sources: MultisiteLanguageSwitcher.php195-217
Diagram: Core System Components and Their Relationships
The plugin architecture follows a layered design:
MslsPlugin and MslsClimsls_get_switcher() provide template integrationMslsBlogCollection manage network-wide stateMslsOptions* classes handle database storageMslsOutput renders HTML for language switchersSources: MultisiteLanguageSwitcher.php43-245
Diagram: Plugin Initialization Sequence
The initialization process:
MSLS_PLUGIN_VERSION is already defined MultisiteLanguageSwitcher.php43MSLS_PLUGIN_VERSION, MSLS_PLUGIN_PATH, MSLS_PLUGIN__FILE__ MultisiteLanguageSwitcher.php44-46MslsPlugin::init() is called to register WordPress hooks MultisiteLanguageSwitcher.php243MslsCli::init() registers WP-CLI commands MultisiteLanguageSwitcher.php244The plugin uses lazy initialization—most components are instantiated only when needed via the MslsRegistry pattern.
Sources: MultisiteLanguageSwitcher.php34-245
The plugin exposes several global functions for theme and plugin integration:
| Function | Return Type | Purpose |
|---|---|---|
msls_the_switcher() | void | Outputs language switcher HTML |
msls_get_switcher() | string | Returns language switcher HTML |
msls_get_flag_url() | string | Returns flag icon URL for locale |
msls_get_blog_description() | string | Returns blog description for locale |
msls_get_permalink() | string | Returns translated post URL for locale |
| Function | Return Type | Purpose |
|---|---|---|
msls_blog() | MslsBlog|null | Returns blog object for locale |
msls_blog_collection() | MslsBlogCollection | Returns all network blogs |
msls_options() | MslsOptions | Returns plugin settings |
msls_content_types() | MslsContentTypes | Returns content type detector |
msls_post_type() | MslsPostType | Returns post type handler |
msls_taxonomy() | MslsTaxonomy | Returns taxonomy handler |
msls_output() | MslsOutput | Returns output generator |
| Function | Return Type | Purpose |
|---|---|---|
msls_get_post() | MslsOptionsPost | Returns post translation data |
msls_get_tax() | OptionsTaxInterface | Returns term translation data |
msls_get_query() | MslsOptionsQuery|null | Returns archive translation data |
Example Usage:
Sources: MultisiteLanguageSwitcher.php57-233 readme.txt37
The plugin stores configuration in several WordPress locations:
Stored in wp_options table with key msls:
_msls_de_DE, _msls_fr_FR_msls_de_DE, _msls_fr_FRSources: MultisiteLanguageSwitcher.php122-127 readme.txt28
The plugin provides extensive customization through WordPress filters and actions:
msls_get_output: Modify the output generator instancemsls_get_postlink: Customize post URLsmsls_content_import_log_writer: Custom import loggingmsls_supported_post_types: Add custom post type supportmsls_supported_taxonomies: Add custom taxonomy supportmsls_content_import_before_import: Hook before importmsls_content_import_after_import: Hook after importMSLS_REGISTER_ACTION: Register custom settingsFor comprehensive extension documentation, see Extension Points and Hooks.
Sources: MultisiteLanguageSwitcher.php57-62
The plugin uses a modern build system:
| Tool | Purpose |
|---|---|
| Composer | PHP dependency management and autoloading |
| npm | JavaScript toolchain and dependencies |
| uglify-js | JavaScript minification |
| lessc + clean-css | CSS compilation and minification |
| @wordpress/scripts | Gutenberg block building |
| PHPUnit | Unit testing |
| PHPStan | Static analysis |
| Playwright | End-to-end testing |
| PHP_CodeSniffer | Code standards enforcement |
The build process generates compiled assets in assets/ directory and is orchestrated through GitHub Actions for continuous integration and deployment to WordPress.org.
For details, see Build System and Asset Processing and CI/CD and Deployment.
Sources: composer.json1-93 README.md17
Sources: readme.txt23-38 README.md19-59
Refresh this wiki
This wiki was recently refreshed. Please wait 5 days to refresh again.