mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@56032 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user