WPML
Trạng thái
Đã được giải quyết bởi nhà phát triển
Được báo cáo cho
WPML Multilingual for BuddyPress and BuddyBoss 1.7.0
Plugin/giao diện liên quan
BuddyBoss Platform
Thẻ chủ đề
Compatibility

Tổng quan về lỗi

Có sự không nhất quán trong việc sắp xếp theo thứ tự bảng chữ cái của các trường phân loại đã được dịch trên các trang hồ sơ BuddyBoss. Trong khi các trường ở ngôn ngữ mặc định được sắp xếp chính xác, các trường đã được dịch lại không duy trì thứ tự này.

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

Đảm bảo bạn có một bản sao lưu toàn bộ trang web trước khi tiếp tục.


  • Mở tệp …/wp-content/plugins/buddyboss-platform/bp-xprofile/classes/class-bp-xprofile-field-type-selectbox.php.

  • Bên trong BP_XProfile_Field_Type_Selectbox::edit_field_options_html(), thay thế dòng sau:
    echo $html;

  • Bằng:
    // WPML Workaround for compsupp-7514
    if ( class_exists('Sitepress') && apply_filters('wpml_default_language', NULL ) != apply_filters( 'wpml_current_language', NULL ) ) {
    	// Match all options
    	preg_match_all('/<option(.*?)>(.*?)<\/option>/s', $html, $matches, PREG_SET_ORDER);
    
    	// Extract the options into an array
    	$optionsArray = [];
    	foreach ($matches as $match) {
    		$optionsArray[] = [
    			'full' => $match[0],
    			'attributes' => $match[1],
    			'text' => $match[2],
    		];
    	}
    
    	// Sort the array by the 'text' element
    	usort($optionsArray, function($a, $b) {
    		return strcmp($a['text'], $b['text']);
    	});
    
    	// Rebuild the HTML string
    	$sortedHtml = '';
    	foreach ($optionsArray as $option) {
    		$sortedHtml .= sprintf('<option%s>%s</option>', $option['attributes'], $option['text']);
    	}
    
    	$html = $sortedHtml;
    }
    
    echo $html;

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