- 상태
- 개발자 대기 중
- 관련 플러그인/테마
- WP User Manager
- 주제 태그
- Compatibility
문제 개요
WP User Manager를 사용하여 프로필에 사용자 정의 필드를 추가할 때 다음과 같은 문제가 발생할 수 있습니다: 사용자 정의 필드의 다중 선택 옵션이 WPML의 문자열 번역에서 번역되지 않습니다.
임시 해결 방법
진행하기 전에 사이트의 전체 사이트 백업이 있는지 확인하세요.
1. 통합 플러그인(WPUM-WPML) 수정
- …/wp-content/plugins/wpum-wpml/includes/class-wpum-wpml-fields.php 파일을 여세요.
- 20번째 줄을 찾으세요.
- 변경 전:
add_action( 'update_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
- 변경 후:
add_action( 'updated_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
- 그 후, 사용자 > 사용자 정의 필드로 이동하여 다중 선택 필드 옵션 중 하나 이상을 편집한 다음, WPML > 문자열 번역으로 이동하여 값을 번역하세요.
2. WP User Manager에서 프런트엔드 출력 수정
- …/wp-content/plugins/wp-user-manager/includes/fields/types/class-wpum-field-multiselect.php 파일을 여세요.
- 해당 줄을 찾으세요.
- 전체
get_formatted_output()함수를 다음으로 교체하세요:
public function get_formatted_output( $field, $value ) { $stored_field_options = $field->get_meta( 'dropdown_options' ); $stored_options = array(); $stored_index = array(); // Build lookup maps: value => label and value => original index foreach ( $stored_field_options as $key => $stored_option ) { $val = isset( $stored_option['value'] ) ? $stored_option['value'] : $key; $lbl = isset( $stored_option['label'] ) ? $stored_option['label'] : ''; $stored_options[ $val ] = $lbl; $stored_index[ $val ] = $key; } $values = array(); foreach ( $value as $user_stored_value ) { if ( ! isset( $stored_options[ $user_stored_value ] ) ) { continue; } $label = $stored_options[ $user_stored_value ]; // Determine original index for this option so we can match textdomain package $index = isset( $stored_index[ $user_stored_value ] ) ? $stored_index[ $user_stored_value ] : 0; // Translation via WPML. $translated_label = apply_filters( 'wpml_translate_single_string', $label, 'wpum-fields-wpum-field-' . $field->get_ID(), 'wpum-field-dropdown_options_' . $index ); $values[] = $translated_label; } return implode( ', ', $values ); }