From 33de4cb0855a9b74e37e69a39736b4f61cac3852 Mon Sep 17 00:00:00 2001 From: Champ Camba Date: Sat, 28 Jan 2017 19:10:13 +0800 Subject: [PATCH] Fix select/multi-select field options translation --- core/um-filters-fields.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core/um-filters-fields.php b/core/um-filters-fields.php index cf52de0e..3db502c1 100644 --- a/core/um-filters-fields.php +++ b/core/um-filters-fields.php @@ -430,5 +430,32 @@ return $value; } + /** + * Apply textdomain in select/multi-select options + * @param $value string + * @param $type string + * @param $data array + * @return $value string + * @uses hook filters: um_profile_field_filter_hook__select, um_profile_field_filter_hook__multiselect + */ + add_filter('um_profile_field_filter_hook__select','um_profile_field__select_translate', 10, 2); + add_filter('um_profile_field_filter_hook__multiselect','um_profile_field__select_translate', 10, 2); + function um_profile_field__select_translate( $value, $data ){ + + if( empty( $value ) ) return $value; + + $options = explode(", ", $value ); + $arr_options = array(); + if( is_array( $options ) ){ + foreach ( $options as $item ) { + $arr_options[] = __( $item, 'ultimatemember' ); + } + } + + $value = implode(", ", $arr_options); + + return $value; + } +