Filter
wpml_current_language
On this page
Calls WPML's filter to get the active language code.
RestroPress applies this WPML filter with a null value to learn the current language. It is used when translating checkout and success page URLs, matching pages in other languages, and to remember the current language before an order email is rendered in the order's language. With no WPML callback attached it returns null. RestroPress also treats the presence of a callback on this hook as a sign that WPML is active.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$language | null | Default value passed to WPML. |
Return value#
string|null. The active language code, or null when unknown.
Example#
add_filter( 'wpml_current_language', 'my_current_language_fallback', 10, 1 );
function my_current_language_fallback( $language ) {
if ( null === $language ) {
$language = substr( determine_locale(), 0, 2 );
}
return $language;
}
Notes#
Fired from two places: rpress_wpml_get_current_language() and rpress_wpml_switch_language_for_order(). Because a callback on this hook makes RestroPress's WPML detection return true, adding one enables the WPML compatibility code.
Source#
Applied in:
includes/plugin-compatibility.php(line 231), inrpress_wpml_get_current_language()includes/plugin-compatibility.php(line 626), inrpress_wpml_switch_language_for_order()
