This document describes the directory layout, file organization, and namespace structure of the Multisite Language Switcher plugin codebase. For information about the plugin initialization and lifecycle, see Plugin Initialization and Lifecycle. For details on the build process, see Build System and Asset Processing.
The plugin follows WordPress plugin conventions with a single entry point file at the root and organized subdirectories for different asset types. PHP classes use PSR-4 autoloading under the lloc\Msls
namespace, with all class files located in the includes/
directory. The build system compiles source assets from src/
into production-ready files in js/
and css/
.
The repository is organized with the following top-level structure:
Sources: .gitignore1-21 package.json2-7 composer.json25-33
The main plugin file defines the plugin header and establishes the global environment:
File | Purpose | Key Elements |
---|---|---|
MultisiteLanguageSwitcher.php | Plugin entry point | Plugin headers (lines 1-32), autoloader (lines 34-36), constants (lines 43-46), public API functions (lines 57-245) |
Constants Defined:
MSLS_PLUGIN_VERSION
- Plugin version stringMSLS_PLUGIN_PATH
- Plugin basename for WordPressMSLS_PLUGIN__FILE__
- Absolute file pathSources: MultisiteLanguageSwitcher.php1-246
All PHP classes reside in the includes/
directory and use PSR-4 autoloading:
Namespace Mapping:
lloc\Msls\
→ includes/
lloc\Msls\Component\
→ includes/Component/
lloc\Msls\ContentImport\
→ includes/ContentImport/
lloc\Msls\Query\
→ includes/Query/
lloc\Msls\Map\
→ includes/Map/
Sources: composer.json25-28 MultisiteLanguageSwitcher.php34-36
The plugin separates source assets from built artifacts:
Build Commands:
Script | Command | Input | Output |
---|---|---|---|
uglify | uglifyjs src/msls.js > js/msls.js | src/msls.js | js/msls.js |
less | lessc css/msls.less css/msls.css --clean-css | css/msls.less | css/msls.css |
build-msls-block | wp-scripts build --webpack-src-dir=src/msls-widget-block --output-path=js/msls-widget-block | src/msls-widget-block/ | js/msls-widget-block/ |
build | Runs all three build commands | All sources | All outputs |
Sources: package.json2-7 .gitignore9-10
The plugin maintains two separate flag icon systems:
Generation Commands:
composer prepare
- Downloads translations.json
from WordPress.org APIcomposer flags-png
- Generates flags/flags.php
mapping filecomposer flags-svg
- Generates css/flags.php
mapping fileSources: composer.json43-45 MslsPlugin.php117-118
Tests are organized by type with separate configurations:
Directory | Purpose | Namespace |
---|---|---|
tests/phpunit/ | PHPUnit unit tests | lloc\MslsTests\ |
tests/playwright/ | End-to-end browser tests | N/A (JavaScript) |
tests/coverage/ | Code coverage reports | N/A (generated) |
Test Execution:
composer test
or vendor/bin/phpunit
composer coverage
(requires Xdebug)composer playwright
or npm run playwright
Sources: composer.json30-33 composer.json36-52 .gitignore16-19
The plugin uses two package managers:
Composer Dependencies (Production):
composer/installers
- WordPress plugin installerext-json
- JSON extension requirementComposer Dependencies (Development):
phpunit/phpunit
- Testing frameworkphpstan/phpstan
- Static analysissquizlabs/php_codesniffer
- Code style checkingbrain/monkey
- WordPress function mockingNPM Dependencies (Production):
uglify-js
- JavaScript minificationless
- LESS compilationless-plugin-clean-css
- CSS minificationNPM Dependencies (Development):
@wordpress/scripts
- WordPress block build tools@playwright/test
- End-to-end testingSources: composer.json7-24 package.json9-20 MultisiteLanguageSwitcher.php34-36 .gitignore13-20
Translation files follow WordPress internationalization standards:
Directory | Purpose | Files |
---|---|---|
languages/ | Translation templates and MO files | default.pot (template), *.po (translations), *.mo (compiled) |
Text Domain: multisite-language-switcher
(defined in plugin header)
Translation Loading: WordPress automatically loads translations from this directory based on the site locale.
Sources: languages/default.pot1-409 MultisiteLanguageSwitcher.php12
The repository root contains several configuration files:
File | Purpose | Related Command |
---|---|---|
composer.json | PHP dependencies, autoloading, scripts | composer install |
package.json | JavaScript dependencies, build scripts | npm install |
package-lock.json | Locked NPM dependency versions | Auto-generated |
phpunit.xml | PHPUnit configuration | composer test |
.gitignore | Git exclusions | N/A |
readme.txt | WordPress.org plugin readme | Displayed on plugin page |
README.md | GitHub repository readme | Displayed on GitHub |
Sources: composer.json1-94 package.json1-22 readme.txt1-132 README.md1-106
The codebase follows consistent naming patterns:
PHP Classes:
Msls{Name}.php
in includes/
directorylloc\Msls\{Name}
classMslsPlugin.php
, MslsOptions.php
, MslsBlogCollection.php
Subnamespace Classes:
includes/{Subnamespace}/{Name}.php
lloc\Msls\{Subnamespace}\{Name}
includes/Component/Input/Text.php
→ lloc\Msls\Component\Input\Text
Test Classes:
tests/phpunit/{Name}Test.php
lloc\MslsTests\{Name}Test
Test
suffixSources: composer.json25-33 includes/MslsPlugin.php1-3 includes/MslsAdmin.php1-3