[Plugin: Polylang] Tweak for better styling of flags
-
In include/core.php around line 847, you’ll find a foreach() which outputs the flag of a language as a list item.
Unfortunately, there is no ol or ul (un/ordered list) tag surrounding the li (list items), so you can’t style them as a group without affecting other list items in the current block.
This can be corrected by adding the li tag as a wrapper around the foreach, like this:
else { $output = ''; $output = '<ul class="polylangFlags">'; foreach ($this->get_languages_list(array('hide_empty' => $hide_if_empty)) as $language) { // hide current language if ($this->curlang->term_id == $language->term_id && $hide_current) ... bunch of stuff in the foreach loop ... $output .= sprintf("<li class='%s'><a hreflang='%s' href='%s'>%s</a></li>\n", $class, esc_attr($language->slug), esc_url($url), $show_flags && $show_names ? $flag.' '.$name : $flag.$name); } $output .= "</ul>"; }
This also allows the flag list to be specifically styled, by use of the class “polylangFlags”.
Of course, you can tweak this to your liking!
I hope it gets included in the next version, I do love this plugin! I’ll be using it heavily in my Talmud Wiki at https://www.talmud-wiki.org
Cheers,
David Szego
- The topic ‘[Plugin: Polylang] Tweak for better styling of flags’ is closed to new replies.