Replacement for msls_head() in version 2.0
-
The update from version 1.0.8 to 1.2 breaks my theme. It seems that the function msls_head() is missing. Is there any replacement for msls_head()? Are there any further changes I should be aware of?
-
msls_head()was a filter function for the WordPress hookwp_head. I guess functions like that are not to use directly. I will check this anyway!My theme calls
msls_head()to generate the alternative links in the header:<link rel="alternate" hreflang="de" href="https://kaseto.com/de/" title="Deutsch" /> <link rel="alternate" hreflang="fr" href="https://kaseto.com/fr/" title="Français" /> <link rel="alternate" hreflang="it" href="https://kaseto.com/it/" title="Italiano" /> <link rel="alternate" hreflang="ru" href="https://kaseto.com/ru/" title="Русский" /> <link rel="alternate" hreflang="en" href="https://kaseto.com/" title="English" />OK, I’m working on it. In the meanwhile … please check if your theme calls
wp_head();in header.php.Yes, I just migrated from
msls_head()towp_head(). It works with both versions (1.0.8 and 2.0), but I get much more header entries than I want. I haven’t usedwp_head()before, because WordPress outputs much header entries that I neither need nor want.My next problem is that some of my theme functions use
MslsBlogCollectionandMslsOptions. Which classes can I use instead in version 2.0?You can still use these Classes with their namespaces …
$options = lloc\Msls\MslsOptions::instance(); \\ the options instance $options = lloc\Msls\MslsOptions::create(); \\ the options factory $collection = lloc\Msls\MslsBlogCollection::instance(); \\ the blog collection instance-
This reply was modified 7 years, 6 months ago by
Dennis Ploetner.
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 buten_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; }Is this a page?
Yes, it is a page: https://kaseto.com/de/download/
-
This reply was modified 7 years, 6 months ago by
Martin. Reason: Added link to the page
I hopefully find a solution to this problem. Version 2.0.3 will be available very soon.
It is already available at Github: https://github.com/lloc/Multisite-Language-Switcher
Thank you very much! Your commit 5975b69 looks very promising. I’m going to test version 2.0.3 as soon as it is available.
-
This reply was modified 7 years, 5 months ago by
Martin.
I have just noticed that version 2.0.3 is already available. Now the multisite language switcher works perfectly on my website. Thank you very much for your great work!
Thanks for your help!!
-
This reply was modified 7 years, 6 months ago by
The topic ‘Replacement for msls_head() in version 2.0’ is closed to new replies.