mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-02 11:21:57 +01: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. 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:
parent
ad16732d27
commit
28e2911898
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user