WPML
ステータス
開発者により解決済み
報告対象
WPML Multilingual for BuddyPress and BuddyBoss 1.7.0
関連するプラグイン/テーマ
BuddyBoss Platform
トピックタグ
Compatibility

問題の概要

BuddyBossのプロフィールページで、翻訳されたタクソノミーフィールドのアルファベット順の並べ替えに一貫性がありません。デフォルト言語のフィールドは正しく並べ替えられますが、翻訳されたフィールドではこの順序が維持されません。

回避策

続行する前に、サイトの完全なバックアップを必ず作成してください。


  • …/wp-content/plugins/buddyboss-platform/bp-xprofile/classes/class-bp-xprofile-field-type-selectbox.phpファイルを開きます。

  • BP_XProfile_Field_Type_Selectbox::edit_field_options_html()内の以下の行を:
    echo $html;

  • 次のように置き換えます。
    // 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;

すべての既知の問題 →