• Resolved Martin

    (@siredward)


    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?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    msls_head() was a filter function for the WordPress hook wp_head. I guess functions like that are not to use directly. I will check this anyway!

    Thread Starter Martin

    (@siredward)

    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" />
    Plugin Author Dennis Ploetner

    (@realloc)

    OK, I’m working on it. In the meanwhile … please check if your theme calls wp_head(); in header.php.

    Thread Starter Martin

    (@siredward)

    Yes, I just migrated from msls_head() to wp_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 used wp_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 MslsBlogCollection and MslsOptions. Which classes can I use instead in version 2.0?

    Plugin Author Dennis Ploetner

    (@realloc)

    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
    Thread Starter Martin

    (@siredward)

    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;	
    }
    Plugin Author Dennis Ploetner

    (@realloc)

    Is this a page?

    Thread Starter Martin

    (@siredward)

    Yes, it is a page: https://kaseto.com/de/download/

    • This reply was modified 5 years, 11 months ago by Martin. Reason: Added link to the page
    Plugin Author Dennis Ploetner

    (@realloc)

    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

    Thread Starter Martin

    (@siredward)

    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 5 years, 11 months ago by Martin.
    Thread Starter Martin

    (@siredward)

    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!

    Plugin Author Dennis Ploetner

    (@realloc)

    Thanks for your help!!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Replacement for msls_head() in version 2.0’ is closed to new replies.