Code Modernization: Use str_starts_with() and str_ends_with() in a few more places.

`str_starts_with()` and `str_ends_with()` were introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins or ends with the given substring (needle).

WordPress core includes a polyfill for these functions on PHP < 8.0 as of WordPress 5.9.

Follow-up to [55990], [56014].

See #58220.

git-svn-id: https://develop.svn.wordpress.org/trunk@56019 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2023-06-24 16:48:25 +00:00
parent d932659aba
commit c226fa18f0
5 changed files with 6 additions and 7 deletions

View File

@@ -401,13 +401,12 @@ function is_email_address_unsafe( $user_email ) {
continue;
}
if ( $email_domain == $banned_domain ) {
if ( $email_domain === $banned_domain ) {
$is_email_address_unsafe = true;
break;
}
$dotted_domain = ".$banned_domain";
if ( substr( $normalized_email, -strlen( $dotted_domain ) ) === $dotted_domain ) {
if ( str_ends_with( $normalized_email, ".$banned_domain" ) ) {
$is_email_address_unsafe = true;
break;
}