apply_filters( $custom_field_val, $custom_field_name )
- Type
- filter
- Category
- Site-Wide Language Information
- 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.
Arguments
- $custom_field_val
- Value contained within field that needs to be decoded
- $custom_field_name
- Name of the field that needs to be decoded
Example usage
Example
add_filter( 'wpml_decode_custom_field', 'my_decode_function', 10, 2 );
function my_decode_function( $custom_field_val, $custom_field_name ) {
if ( $custom_field_name === 'my-special-field' ) {
$custom_field_val = my_special_decoding_function( $custom_field_val );
}
return $custom_field_val;
}
Related hooks
wpml_footer_language_selector, wpml_add_language_form_field, wpml_ls_exclude_in_menu, wpml_is_rtl, wpml_alternate_hreflang, wpml_head_langs, wpml_must_translate_canonical_url, wpml_browser_redirect_language_params, wpml_active_languages, wpml_encode_custom_field