Skip to content
Docs
Get RestroPress

Filter

wpml_element_language_code

Updated
On this page

Calls WPML's filter to get the language code of an order.

RestroPress applies this WPML filter in rpress_wpml_get_payment_language() to find which language an order was placed in, so emails can be rendered in that language. The element is described by an array with 'element_id' (the payment ID) and 'element_type' ('post_rpress_payment'). When the filter returns an empty value, RestroPress falls back to the wpml_language and _order_language post meta.

Parameters#

ParameterTypeDescription
$language_codenullDefault value passed to WPML.
$argsarrayArray with 'element_id' (payment ID) and 'element_type' ('post_rpress_payment').

Return value#

string|null. The language code of the order, or null.

Example#

add_filter( 'wpml_element_language_code', 'my_order_language_code', 10, 2 );
function my_order_language_code( $language_code, $args ) {
	if ( null === $language_code && 'post_rpress_payment' === $args['element_type'] ) {
		$language_code = get_post_meta( $args['element_id'], '_my_order_lang', true );
	}
	return $language_code ? $language_code : null;
}

Source#

Applied in:

  • includes/plugin-compatibility.php (line 486), in rpress_wpml_get_payment_language()

See also#

Was this page helpful?