Bỏ qua điều hướng

Open

Reported for: BuddyPress Multilingual 1.7.0

Topic Tags: Compatibility

Overview of the issue

There’s an inconsistency in the alphabetical sorting of translated taxonomy fields on the BuddyBoss profile pages. While the default language fields are sorted correctly, the translated fields do not maintain this order.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open …/wp-content/plugins/buddyboss-platform/bp-xprofile/classes/class-bp-xprofile-field-type-selectbox.php file.
  • Inside BP_XProfile_Field_Type_Selectbox::edit_field_options_html(), replace the following line:
    1
    echo $html;
  • With:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    // 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;

Để lại phản hồi

Vui lòng bám sát chủ đề và tôn trọng người khác. Nếu bạn cần trợ giúp với các vấn đề không liên quan đến bài đăng này, hãy sử dụng Diễn đàn Hỗ trợ của chúng tôi để bắt đầu trò chuyện hoặc gửi yêu cầu hỗ trợ.

Bạn có thể sử dụng các thẻ sau:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>