Thank you very much! Now I can use version 2.0 without getting any compiler error.
However, I found a strange bug: lloc\Msls\MslsOptions::create()->get_permalink($language)
seems to work for every language but en_US
.
For example:
de_DE: https://kaseto.com/de/download/ (correct)
fr_FR: https://kaseto.com/fr/telecharger/ (correct)
en_US: https://kaseto.com/ (wrong, should be https://kaseto.com/download/)
$blogs = lloc\Msls\MslsBlogCollection::instance()->get_objects();
if ($blogs)
{
$options = lloc\Msls\MslsOptions::create();
$currentID = lloc\Msls\MslsBlogCollection::instance()->get_current_blog_id();
usort($blogs, function($a, $b)
{
return strcmp($a->get_description(), $b->get_description());
}
);
echo '<ul>' . PHP_EOL;
foreach ($blogs as $blog)
{
if ($blog->userblog_id == $currentID)
{
echo '<li class="active"><a href="' . $options->get_current_link() . '" hreflang="' . $blog->get_alpha2() . '" rel="alternate">' . $blog->get_description(). '</a></li>' . PHP_EOL;
}
else
{
switch_to_blog($blog->userblog_id);
$language = $blog->get_language();
echo '<li><a href="' . $options->get_permalink($language) . '" hreflang="' . $blog->get_alpha2() . '" rel="alternate">' . $blog->get_description(). '</a></li>' . PHP_EOL;
restore_current_blog();
}
}
echo '</ul>' . PHP_EOL;
}