Shortcodes

[perflocale_switcher]

Displays the language switcher. See Language Switcher for full documentation.

[perflocale_language]

Outputs information about the current language.

Attributes

AttributeValuesDefaultDescription
formatslug, locale, name, native_name, display_name, flagnameWhat to output

Format Values

FormatExample OutputDescription
slugfr2-3 letter language code
localefr_FRFull WordPress locale
nameFrenchEnglish language name
native_nameFrançaisName in the language itself
display_nameFrench (Français)English name with native in parentheses
flag🇫🇷Flag emoji

Examples

Current language: [perflocale_language]
→ "Current language: French"

Code: [perflocale_language format="slug"]
→ "Code: fr"

Locale: [perflocale_language format="locale"]
→ "Locale: fr_FR"

[perflocale_language format="native_name"]
→ "Français"

[perflocale_language format="display_name"]
→ "French (Français)"

[perflocale_language format="flag"]
→ "🇫🇷"

Use Cases

  • Show current language in a header or footer
  • Display language info in widgets
  • Dynamic page titles: Welcome - [perflocale_language format="native_name"]

[perflocale_if]

Shows or hides its enclosed content based on the visitor’s current language. Same behaviour is also available as a Gutenberg block and as a PHP helper - all three share a single core predicate so they can’t drift apart.

Attributes

AttributeValuesDescription
langsComma-separated language slugs - e.g. fr,deShow the enclosed content only in these languages.
not_langsComma-separated language slugs - e.g. en,frInverse: show everywhere except these languages. Takes precedence over langs when both are set.

Examples

[perflocale_if langs="fr,de"]
	Shown only to French and German visitors.
[/perflocale_if]

[perflocale_if not_langs="en"]
	Shown to every visitor except those browsing the English version.
[/perflocale_if]

[perflocale_if langs="fr"]
	<a href="/fr/promo/">Voir la promo</a>
[/perflocale_if]

Nested shortcodes and blocks inside the enclosed content are resolved normally. When no visitor language is resolved the block hides (fail-closed) to avoid leaking content into the wrong locale during edge-case detection failures.

Gutenberg block

Search “Show If Language” in the block inserter. The block exposes the same two options as the shortcode - a multi-select of active languages and an “Invert” toggle - and supports inner blocks of any kind.

PHP helper

For theme templates, use the helper directly:

<?php if ( perflocale_if_language( [ 'fr', 'de' ] ) ) : ?>
	<div class="banner">Offre spéciale locale</div>
<?php endif; ?>

// Invert: show everywhere EXCEPT these languages.
<?php if ( perflocale_if_language( [ 'en' ], true ) ) : ?>
	...
<?php endif; ?>

// Accepts a single slug, comma-separated string, or array:
perflocale_if_language( 'fr' );
perflocale_if_language( 'fr,de' );
perflocale_if_language( [ 'fr', 'de' ] );

Notes

  • Language slugs are matched against the active languages configured under Languages.
  • Evaluation is a single in_array() plus a cached current-language lookup - zero database I/O per call.
  • If langs and not_langs are both set, not_langs wins (the shortcode treats that as an inversion request).