Make WordPress Core

Changeset 60900


Ignore:
Timestamp:
10/04/2025 06:41:11 PM (5 weeks ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Use str_contains() in get_avatar_data().

str_contains() was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).

WordPress core includes a polyfill for str_contains() on PHP < 8.0 as of WordPress 5.9.

Follow-up to [52039], [55988], [56245], [60897].

Props TobiasBg.
See #63087.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r60897 r60900  
    45784578
    45794579        if ( '' !== $name ) {
    4580             if ( false === strpos( $name, ' ' ) || preg_match( '/\p{Han}|\p{Hiragana}|\p{Katakana}|\p{Hangul}/u', $name ) ) {
     4580            if ( ! str_contains( $name, ' ' ) || preg_match( '/\p{Han}|\p{Hiragana}|\p{Katakana}|\p{Hangul}/u', $name ) ) {
    45814581                $initials = mb_substr( $name, 0, min( 2, mb_strlen( $name, 'UTF-8' ) ), 'UTF-8' );
    45824582            } else {
Note: See TracChangeset for help on using the changeset viewer.