Skip to:
Content

bbPress.org

Changeset 7364


Ignore:
Timestamp:
11/17/2025 05:00:49 AM (3 months ago)
Author:
johnjamesjacoby
Message:

Component - Users: Support wp_is_valid_utf8() for UTF-8 display names.

This commit adds support for a new function, introduced in WordPress 6.9, to work around UTF-8 deprecations in PHP8.4.

In trunk, for 2.7.

See #2141.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/formatting.php

    r7360 r7364  
    811811    $retval = $display_name;
    812812
    813     // Use the mbstring library if possible
    814     if ( function_exists( 'mb_check_encoding' ) && ! mb_check_encoding( $display_name, 'UTF-8' ) ) {
     813    // WordPress 6.9 and higher
     814    if ( function_exists( 'wp_is_valid_utf8' ) && ! wp_is_valid_utf8( $display_name ) ) {
     815        $retval = _wp_utf8_encode_fallback( $display_name );
     816
     817    // Fallback to mbstring library if extension is loaded
     818    } elseif ( function_exists( 'mb_check_encoding' ) && ! mb_check_encoding( $display_name, 'UTF-8' ) ) {
    815819        $retval = mb_convert_encoding( $display_name, 'UTF-8', 'ISO-8859-1' );
    816820
    817     // Fallback to function that (deprecated in PHP8.2)
     821    // Fallback to deprecated WordPress & PHP functions
    818822    } elseif ( seems_utf8( $display_name ) === false ) {
    819823        $retval = utf8_encode( $display_name ); // phpcs:ignore
Note: See TracChangeset for help on using the changeset viewer.