Closed
Description
Description
The plugin is exceptional when a multi-site setup has every sub-site representing a different language of the same content. However, when a multi-site has multiple actual content sub-sites, there are multiple places where the UI presents all sub-sites for selection that are not appropriate for use case such as:
- Post Edit Screen - Doc Sidebar for MLSwitcher - Separate drop-down per sub-site
- Post Lists Screen - Separate column per translation/potential translation
- Front-End Site - When Menu Settings/Theme Location defined
To Reproduce
- Create a multi-site network with 8 sub-sites (EN1, EN2, EN3, EN4, FR1, FR2, FR3, FR4)
Expected behaviour
- Provide an option under Multisite Language Switcher Options / Main Settings that lets each site be (optionally) associated to N number of sites. (multi-select field type)
- When this has been defined, anywhere that currently displays ALL sub-sites would only display the associated sub-sites.
- In reproduced example, EN1/FR1 would see each other, EN2/FR2, etc.
There is a code-based temporary solution possible through the msls_blog_collection_construct filter
add_filter( 'msls_blog_collection_construct', 'msls_sites_collection_restrictions' );
function msls_sites_collection_restrictions( $sites ) {
$restrict = true;
//Ensure front-end only are restricted.
if ( is_admin() && isset( $_GET['page'] ) ) {
$admin_path = strtolower( sanitize_text_field( $_GET['page'] ) );
if ( $admin_path === 'mslsadmin' ) {
$restruct = false;
}
}
if ( ! $restrict ) {
return $sites;
}
//Find out the current blog and let it's language counterpart be displayed.
//@TODO - Refactor this so the en/fr association is stored in site options.
$current_blog_id = get_current_blog_id();
switch ( $current_blog_id ) {
case 1:
$keep_blog_id = 2;
break;
case 2:
$keep_blog_id = 1;
break;
case 3:
$keep_blog_id = 4;
break;
case 4:
$keep_blog_id = 3;
break;
}
foreach ( $sites as $key => $site ) {
if ( $key !== $keep_blog_id && $key !== $current_blog_id ) {
unset( $sites[ $key ] );
}
}
return $sites;
}
Environment (please complete the following information):
- OS: Linux
- Browser: All
- PHP Version 7.2
- Plugin Version: 2.3 and 2.4.3
Metadata
Metadata
Assignees
Labels
No labels