[Contribution] Undocumented filter pll_the_languages_args
-
Hey Chouby!
One more time, thank for your awesome work ??
I’ve had a task today to add a language switcher to WordPress menu, but the client wanted it to show language code instead of name, like:
Home | About | Contact | DE
instead of
Home | About | Contact | Deutsch
I don’t want to complicate things, and if Polylang provides a standard language switcher for the nav_menus, let’s use it. None of the methods discussed in other topics here worked for this case, so I went to study the code. There’s an undocumented filter
pll_the_languages_args
in PLL_Switcher->the_languages() (see here) which perfectly fits for this purpose. Here’s a piece of code that might be useful for others:/** * Display languages as slugs instead of full name. * * @param $args array Merged array of defaults and user settings for language selector * * @return array Modified array of arguments */ function pss_language_as_slug( $args ) { $args['display_names_as'] = 'slug'; return $args; } add_filter( 'pll_the_languages_args', 'pss_language_as_slug', 10, 1 );
It would be nice to document it in filters section on Polylang docs website.
- The topic ‘[Contribution] Undocumented filter pll_the_languages_args’ is closed to new replies.