- availability:
-
WPML Version: 4.1.0
- description:
-
Custom fields can be encoded in a format that WPML does not understand. Those fields have to be decoded and encoded before WPML can translate them. To achieve this, the wpml_decode_custom_field and wpml_encode_custom_field filters must be used. These filters can be used if there is additional custom encoding besides the ones already handled by WPML.
- type:
- filter
- category:
- Site-Wide Language Information
- parameters:
-
apply_filters( $custom_field_val, $custom_field_name )
- $custom_field_val
- Value contained within field that needs to be encoded
- $custom_field_name
- Name of the field that needs to be encoded
- hook example usage:
-
Example
123456789add_filter(
'wpml_encode_custom_field'
,
'my_encode_function'
, 10, 2 );
function
my_encode_function(
$custom_field_val
,
$custom_field_name
) {
if
(
$custom_field_name
===
'my-special-field'
) {
$custom_field_val
= my_special_encoding_function(
$custom_field_val
);
}
return
$custom_field_val
;
}