Support » Plugins and Hacks » Multisite Language Switcher » [Resolved] Order of flags/description

[Resolved] Order of flags/description

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


    You can sort the output by description. Look at the settings of the plugin: https://github.com/lloc/Multisite-Language-Switcher/wiki/Settings

    It is also possible to sort the output with a filter-function. Would this be more interesting for you?

    The filter solution interested me! πŸ˜€
    Because the description is displayed on the front-end.

    Thanks !

    Plugin Author Dennis Ploetner


    OK. As you know you can sort by description. A solution would be that you simply use numbers before the description for having the order you like. For example:

    1 english
    2 deutsch

    Then you can go to create a filter to hide these numbers from the output:

    function my_msls_output_get( $url, $link, $current ) {
        return sprintf(
            '<a href="%s" title="%s"%s>%s</a>',
            substr( $link->txt, 2),
            ( $current ? ' class="current"' : '' ),
    add_filter( 'msls_output_get', 'my_msls_output_get', 10, 3 );

    Thank you! It works.

    Suggestion: It would be nice, in a future update, to add functionality where you could drag and drop the different languages ​​to its own order. πŸ™‚

    Plugin Author Dennis Ploetner


    Yeah, there is still a lot to do. πŸ˜‰

    I think so. πŸ™‚

    Additional question:
    Is it possible to make the same filter on the description? (for substr)

    Plugin Author Dennis Ploetner


    $link is an object so this is not possibile in an easy way.

    The hard way do not scare me! πŸ™‚

    Plugin Author Dennis Ploetner


    This is not what I meant. It makes no sence to do it that way and the result would be equal. πŸ˜‰ Maybe if you can describe a little bit more what you want to do…

    At first I did not want to display the description (only the flag).
    But now, yes (flag + description).

    So I have:
    “1 FranΓ§ais”
    “2 English”
    “3 Deutsch”

    I want to delete the number (in the front-end) that I use to choose the order of the country.

    Plugin Author Dennis Ploetner


    To test MslsOutput, I tried this :

    $display = 0;
    $exists  = false;
    $obj     = new MslsOutput();
    foreach ( $obj->get( $display, $exists ) as $link ) {
    	echo $link->description;

    But it does not work. πŸ™
    This is because the object is in a “protected” mode.

    Plugin Author Dennis Ploetner


    You should print out the object to “test” it as in my example. You can create your own link object by extending MslsLink and returning an object of this type with a filter attached to msls_link_create.

    But this is a complete other story … please open a new thread for that.

    BTW MslsLink has just one property: $format_string but a method called get_description.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Resolved] Order of flags/description’ is closed to new replies.
Skip to toolbar