The Configuration and Options System manages all plugin settings and translation relationship data across the WordPress multisite network. This system handles two distinct categories of data:
wp_optionswp_postmeta, wp_termmeta, and object cacheFor information about how translation links are established and maintained, see Translation Linking System. For details about admin UI components, see Settings and Configuration Pages.
Sources: includes/MslsOptions.php1-432 includes/MslsAdmin.php1-485
The options system uses an inheritance hierarchy where MslsOptions serves as the base class with specialized subclasses for different content contexts:
Class Responsibilities:
| Class | Purpose | Storage Location |
|---|---|---|
MslsOptions | Base settings class for global plugin configuration | wp_options table with key msls |
MslsOptionsPost | Translation links for posts/pages | wp_postmeta with key msls_{post_id} |
MslsOptionsTax | Translation links for taxonomies | wp_termmeta with key msls_term_{term_id} |
MslsOptionsTaxTerm | Specialized handling for post tags | wp_termmeta with tag base rewriting |
MslsOptionsTaxTermCategory | Specialized handling for categories | wp_termmeta with category base rewriting |
MslsOptionsQuery | Archive query options (dates, authors, post types) | WordPress object cache |
Sources: includes/MslsOptions.php29-432 includes/MslsOptionsPost.php10-56 includes/MslsOptionsTax.php10-132 includes/MslsOptionsQuery.php10-85
Options are stored using WordPress's native storage APIs with different mechanisms based on content type:
Storage Implementation Details:
The get_option_name() method constructs unique keys using prefixes and separators:
msls (no separator, no args)msls_{post_id} (separator: _)msls_term_{term_id} (separator: _term_)The save() method includes/MslsOptions.php170-178 implements atomic updates:
delete()set()add_option() with autoload flagThe autoload property controls WordPress option loading behavior:
true for MslsOptions (loaded on every request)false for MslsOptionsPost and MslsOptionsTax (loaded on-demand)Sources: includes/MslsOptions.php83-107 includes/MslsOptions.php139-147 includes/MslsOptions.php170-185
The MslsOptions::create() factory method includes/MslsOptions.php83-107 determines the appropriate options class based on request context:
Context Detection Methods:
| Method | Condition | Returns |
|---|---|---|
is_main_page() | is_front_page() || is_search() || is_404() | MslsOptions |
is_tax_page() | is_category() || is_tag() || is_tax() | MslsOptionsTax::create() |
is_query_page() | is_date() || is_author() || is_post_type_archive() | MslsOptionsQuery::create() |
Sources: includes/MslsOptions.php83-107 includes/MslsOptions.php114-134 includes/MslsOptionsTax.php24-40 includes/MslsOptionsQuery.php44-64
MslsAdmin includes/MslsAdmin.php27-484 provides the administrative UI for configuring plugin settings. It registers settings sections, fields, and handles validation.
Settings Section Map:
| Section ID | Title | Method | Fields |
|---|---|---|---|
language_section | Language Settings | language_section() | blog_language |
main_section | Main Settings | main_section() | display, admin_display, sort_by_description, output_current_blog, only_with_translation, description, before_output, after_output, before_item, after_item, content_filter, content_priority |
advanced_section | Advanced Settings | advanced_section() | activate_autocomplete, image_url, reference_user, exclude_current_blog, activate_content_import |
rewrites_section | Rewrites Settings | rewrites_section() | rewrite_{post_type} (dynamic based on registered post types) |
Magic Method Pattern:
The __call() method includes/MslsAdmin.php96-130 dynamically renders form fields based on method name:
$checkboxes array at includes/MslsAdmin.php103-117rewrite_ at includes/MslsAdmin.php98-100Sources: includes/MslsAdmin.php43-68 includes/MslsAdmin.php213-239 includes/MslsAdmin.php248-316 includes/MslsAdmin.php450-466
The MslsOptions class exposes configuration properties via magic methods (__get/__set):
| Property | Type | Purpose | Default |
|---|---|---|---|
display | int | Link display mode (flag/label/flag+label) | 0 |
admin_display | string | Admin icon type (flag or label) | flag |
before_output | string | HTML before language switcher list | '' |
after_output | string | HTML after language switcher list | '' |
before_item | string | HTML before each language link | '' |
after_item | string | HTML after each language link | '' |
description | string | Custom blog description | '' |
image_url | string | Custom flag images URL | '' |
| Property | Type | Purpose |
|---|---|---|
activate_autocomplete | bool | Enable AJAX autocomplete in meta boxes |
activate_content_import | bool | Enable content import functionality |
sort_by_description | bool | Sort languages by description instead of code |
exclude_current_blog | bool | Exclude this blog from output |
only_with_translation | bool | Show only links with translations |
output_current_blog | bool | Display link to current language |
content_filter | bool | Add translation hints to content |
| Property | Type | Purpose |
|---|---|---|
reference_user | int | User ID whose blogs are used for collection |
content_priority | int | Priority for content filter hook (1-100) |
with_front | bool | Use permalink front base in URLs |
Language Detection:
The get_available_languages() method includes/MslsOptions.php363-387 returns available WordPress language packs:
en_US as defaultget_available_languages() WordPress functionformat_code_lang()msls_options_get_available_languages filterSources: includes/MslsOptions.php29-73 includes/MslsOptions.php363-387
Each options subclass implements get_postlink() and get_current_link() methods to generate URLs for translation links:
URL Processing Pipeline:
check_url filter applied at includes/MslsOptionsPost.php43 includes/MslsOptionsTax.php94msls_get_postlink hook applied for customizationmsls_options_get_permalink for last-minute modificationshome_url('/') if URL is emptyBlog Slug Handling:
The check_for_blog_slug() method includes/MslsOptions.php397-422 addresses subdomain installs with permalinks:
with_front settingSources: includes/MslsOptions.php217-233 includes/MslsOptionsPost.php26-46 includes/MslsOptionsTax.php87-97 includes/MslsOptionsQuery.php73-84
Taxonomy and post type options handle custom rewrite bases to ensure URLs remain consistent across blogs:
Rewrite Handling Flow:
get_tax_query() retrieves the queried taxonomy name includes/MslsOptionsTax.php68-78handle_rewrite() checks if taxonomy uses front base includes/MslsOptionsTax.php55-61check_base() compares defined vs. configured bases includes/MslsOptionsTaxTerm.php37-53Special Cases:
MslsOptionsTaxTerm with tag_base option includes/MslsOptionsTaxTerm.php12-13MslsOptionsTaxTermCategory with category_base optionSources: includes/MslsOptionsTax.php55-78 includes/MslsOptionsTaxTerm.php23-73
The options system integrates with plugin initialization and cleanup:
Initialization Sequence:
MslsPlugin::init() includes/MslsPlugin.php34-100 checks for multisiteMslsAdmin::init() includes/MslsAdmin.php43-68 registers settings pageadd_options_page() with capability checkCleanup Process:
The cleanup() method includes/MslsPlugin.php239-246 removes all plugin data:
msls option from wp_optionsCleanupOptionsQuery to remove all post/term metaSources: includes/MslsPlugin.php34-100 includes/MslsAdmin.php43-68 includes/MslsPlugin.php211-246
The options system provides several extension points:
| Filter Hook | Location | Purpose |
|---|---|---|
msls_admin_caps | includes/MslsAdmin.php57 | Override required capability for settings access |
msls_admin_validate | includes/MslsAdmin.php458 | Filter settings before validation |
msls_options_get_available_languages | includes/MslsOptions.php380-383 | Customize available language list |
msls_options_get_flag_url | includes/MslsOptions.php341 | Override flag images directory |
msls_options_get_flag_icon | includes/MslsOptions.php353 | Customize flag icon filename |
msls_options_get_permalink | includes/MslsOptions.php226-230 | Filter final permalink output |
| Action Hook | Location | Purpose |
|---|---|---|
MSLS_REGISTER_ACTION | includes/MslsAdmin.php238 | Add custom settings sections (value: msls_admin_register) |
MSLS_ACTION_PREFIX . {section} | includes/MslsAdmin.php337 | Add fields to specific section (e.g., msls_admin_language_section) |
Example: Adding Custom Settings Section
Sources: includes/MslsAdmin.php29-31 includes/MslsAdmin.php213-239 includes/MslsOptions.php217-233
Refresh this wiki
This wiki was recently refreshed. Please wait 6 days to refresh again.