Code Modernization: Use `str_contains()` in a few more places.

`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.

This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.

Follow-up to [55988], [56021], [56031].

See #58206.
Built from https://develop.svn.wordpress.org/trunk@56032


git-svn-id: http://core.svn.wordpress.org/trunk@55544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-06-26 10:44:23 +00:00
parent ad16732d27
commit 28e2911898
3 changed files with 6 additions and 6 deletions

View File

@ -105,7 +105,7 @@ function wp_initial_constants() {
// non-concatenated scripts and stylesheets.
if ( ! defined( 'SCRIPT_DEBUG' ) ) {
if ( ! empty( $wp_version ) ) {
$develop_src = false !== strpos( $wp_version, '-src' );
$develop_src = str_contains( $wp_version, '-src' );
} else {
$develop_src = false;
}

View File

@ -1505,11 +1505,11 @@ function wp_convert_hr_to_bytes( $value ) {
$value = strtolower( trim( $value ) );
$bytes = (int) $value;
if ( false !== strpos( $value, 'g' ) ) {
if ( str_contains( $value, 'g' ) ) {
$bytes *= GB_IN_BYTES;
} elseif ( false !== strpos( $value, 'm' ) ) {
} elseif ( str_contains( $value, 'm' ) ) {
$bytes *= MB_IN_BYTES;
} elseif ( false !== strpos( $value, 'k' ) ) {
} elseif ( str_contains( $value, 'k' ) ) {
$bytes *= KB_IN_BYTES;
}
@ -1788,7 +1788,7 @@ function wp_is_xml_request() {
if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) {
foreach ( $accepted as $type ) {
if ( false !== strpos( $_SERVER['HTTP_ACCEPT'], $type ) ) {
if ( str_contains( $_SERVER['HTTP_ACCEPT'], $type ) ) {
return true;
}
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-alpha-56031';
$wp_version = '6.3-alpha-56032';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.