Menu

Getting Started

Relevant source files

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.


Prerequisites

The Multisite Language Switcher requires a WordPress multisite installation. The plugin will not function on a standard single-site WordPress installation.

Multisite Network Requirements:

RequirementMinimum VersionNotes
WordPress6.1Multisite must be enabled
PHP7.4Required for plugin compatibility
Network TypeSubdomain or SubfolderBoth 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


Installation

Network Installation via WordPress Dashboard

  1. Navigate to Network Admin > Plugins > Add New Plugin
  2. Search for "Multisite Language Switcher"
  3. Click Install Now and then Network Activate

Manual Installation

  1. Download the plugin from the WordPress plugin directory
  2. Extract the archive to /wp-content/plugins/
  3. Navigate to Network Admin > Plugins
  4. Click Activate on the Multisite Language Switcher entry

Installation Workflow:

Sources: MultisiteLanguageSwitcher.php1-245 MslsPlugin.php34-100 MslsPlugin.php199-201


Initial Configuration

After installation, each blog in the multisite network must be configured individually to specify its language and display preferences.

Configuration Workflow

Sources: MslsAdmin.php128-151 MslsAdmin.php336-342 MslsAdmin.php252-269

Step 1: Access Plugin Settings

On each blog where you want to enable multilingual functionality:

  1. Switch to the blog's admin dashboard
  2. Navigate to Settings > Multisite Language Switcher
  3. The plugin checks if configuration is complete via MslsOptions::is_empty() MslsAdmin.php131

If the plugin is not configured, an admin notice is displayed by MslsAdmin::has_problems() MslsAdmin.php128-151

Step 2: Language Selection

The MslsAdmin class provides settings sections registered via MslsAdmin::register() MslsAdmin.php204-230:

Language Settings Section:

FieldDescriptionStorage
Blog LanguageWordPress 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

Step 3: Main Settings Configuration

Key Configuration Options:

SettingClass PropertyDescription
Display$options->displayIcon display mode (flag, text, or combination)
Admin Display$options->admin_displayAdmin interface icon type (flag or label)
Description$options->descriptionCustom blog description for language switcher
Sort Order$options->sort_by_descriptionSort 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

Step 4: Advanced Settings

The advanced settings section provides additional configuration options registered via MslsAdmin::advanced_section() MslsAdmin.php278-288:

SettingDefaultPurpose
AutocompleteOffEnable AJAX autocomplete for content linking
Reference UserFirst userUser whose blog access determines visible blogs
Exclude BlogOffHide this blog from language switcher output
Content ImportOffEnable 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

Step 5: Save Configuration

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


Blog Collection and Network Management

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:

PropertyTypeSource
userblog_idintWordPress blog ID
languagestringFrom get_blog_option(blog_id, 'WPLANG')
descriptionstringFrom msls option or language fallback

Sources: MslsBlog.php11-47 MslsBlogCollection.php331-339


Linking Content Across Languages

After configuring multiple blogs, you can link posts, pages, and custom post types across language versions.

Content Linking Workflow

Sources: MslsMetaBox.php56-81 MslsMetaBox.php232-248 MslsMain.php

Post/Page Linking Interface

The meta box is registered for post edit screens via MslsMetaBox::init() MslsMetaBox.php56-81:

Meta Box Components:

ComponentClassFilePurpose
Meta Box ContainerMslsMetaBoxMslsMetaBox.phpRenders language link inputs
AJAX SuggestionMslsMetaBox::suggest()MslsMetaBox.php:339-368Autocomplete search
Link StorageMslsOptionsPostMslsOptionsPost.phpStores post ID mappings
Save HandlerMslsMain::save()MslsMain.phpSaves translation links

Translation Link Storage Format:

Sources: MslsOptionsPost.php MslsOptions.php143-145 MslsLanguageArray.php

AJAX Autocomplete Feature

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


Displaying the Language Switcher

Once content is linked across languages, you can display the language switcher to visitors using multiple methods.

Display Methods Overview

Sources: MslsWidget.php MslsBlock.php MultisiteLanguageSwitcher.php79-82 MslsOutput.php34-90

Method 1: Template Function

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

Method 2: Widget

  1. Navigate to Appearance > Widgets
  2. Add the "Multisite Language Switcher" widget to a sidebar
  3. Configure the widget title (optional)

The widget class MslsWidget extends WP_Widget and is registered via MslsWidget::init() MslsPlugin.php47

Sources: MslsWidget.php MslsPlugin.php47

Method 3: Gutenberg Block

  1. In the block editor, click the "+" button
  2. Search for "Multisite Language Switcher"
  3. Insert the 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/

Method 4: Shortcode

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


Output Rendering Process

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

Context Switching Pattern

The plugin uses WordPress multisite functions to switch context when generating URLs:

FunctionPurposeLocation
switch_to_blog($blog_id)Change global WordPress context to target blogMslsOutput.php:53
restore_current_blog()Restore original blog contextMslsOutput.php:56, 63

This pattern ensures that permalinks and post data are fetched from the correct blog in the network.

Sources: MslsOutput.php53-64


Next Steps

After completing the basic setup:

  1. Configure Content Linking: See Content Linking Meta Boxes for detailed meta box usage
  2. Set Up Taxonomy Translations: See Taxonomy Management Interface for category and tag linking
  3. Customize Display Output: See Language Switcher Output for output customization options
  4. Enable SEO Features: See SEO and Alternate Links for hreflang configuration
  5. Use Content Import: See Content Import System for duplicating content across languages

For troubleshooting and advanced configuration, consult the Admin Interface documentation.

Sources: readme.txt23-40 README.md19-60