نظرة عامة على المشكلة
عند استخدام WP User Manager لإضافة حقول مخصصة إلى الملفات الشخصية، قد تواجه المشكلة التالية: خيارات التحديد المتعدد للحقول المخصصة غير قابلة للترجمة في ترجمة النصوص في WPML.
حل بديل مؤقت
يُرجى التأكد من أخذ نسخة احتياطية كاملة لموقعك قبل المتابعة.
1. إصلاح إضافة الدمج (WPUM-WPML)
- افتح الملف …/wp-content/plugins/wpum-wpml/includes/class-wpum-wpml-fields.php.
- ابحث عن السطر 20.
- استبدل:PHP
add_action( 'update_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
- بـ:PHP
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.
- ابحث عن السطر 56.
- استبدل الدالة
get_formatted_output()بأكملها بـ:PHPpublic 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 ); }