WPML
Trạng thái
Đang chờ nhà phát triển
Loại
Lỗi
Plugin/giao diện liên quan
WP User Manager
Thẻ chủ đề
Compatibility

Tổng quan về sự cố

Khi sử dụng WP User Manager để thêm các trường tùy chỉnh vào hồ sơ, bạn có thể gặp phải sự cố sau: các tùy chọn từ các trường tùy chỉnh chọn nhiều không thể dịch được trong Dịch chuỗi của WPML.

Giải pháp tạm thời

Vui lòng đảm bảo bạn có một bản sao lưu toàn bộ trang web của mình trước khi tiếp tục.

1. Sửa plugin tích hợp (WPUM-WPML)


  • Mở tệp …/wp-content/plugins/wpum-wpml/includes/class-wpum-wpml-fields.php.

  • Tìm dòng 20.

  • Thay thế:
    add_action( 'update_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
            


  • Bằng:
    add_action( 'updated_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
            

  • Sau đó, đi tới Người dùng > Trường tùy chỉnh, chỉnh sửa ít nhất một trong các tùy chọn của trường chọn nhiều, rồi điều hướng đến WPML > Dịch chuỗi để dịch các giá trị.

2. Sửa đầu ra trên giao diện người dùng trong WP User Manager


  • Mở tệp …/wp-content/plugins/wp-user-manager/includes/fields/types/class-wpum-field-multiselect.php.

  • Tìm dòng 56.

  • Thay thế toàn bộ hàm get_formatted_output() bằng:
    public function get_formatted_output( $field, $value ) {
    
        $stored_field_options = $field->get_meta( 'dropdown_options' );
        $stored_options       = array();
        $stored_index         = array();
    
        // Keep the plugin's own guard.
        if ( ! is_array( $stored_field_options ) ) {
            return '';
        }
    
        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();
    
        // Keep the plugin's (array) cast.
        foreach ( (array) $value as $user_stored_value ) {
            if ( ! isset( $stored_options[ $user_stored_value ] ) ) {
                continue;
            }
    
            $label = $stored_options[ $user_stored_value ];
            $index = isset( $stored_index[ $user_stored_value ] ) ? $stored_index[ $user_stored_value ] : 0;
    
            $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 );
    }
            

Tất cả lỗi đã ghi nhận