Skip to content

Commit 8316c7d

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@60900 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b7b1441 commit 8316c7d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/wp-includes/link-template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4577,7 +4577,7 @@ function get_avatar_data( $id_or_email, $args = null ) {
45774577
}
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 {
45834583
$first = mb_substr( $name, 0, 1, 'UTF-8' );

0 commit comments

Comments
 (0)