- 状态
- 已由作者解决
- 报告针对
- 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;