mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +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]. See #58206. git-svn-id: https://develop.svn.wordpress.org/trunk@56031 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1019,7 +1019,7 @@ function wp_specialchars_decode( $text, $quote_style = ENT_NOQUOTES ) {
|
||||
}
|
||||
|
||||
// Don't bother if there are no entities - saves a lot of processing.
|
||||
if ( strpos( $text, '&' ) === false ) {
|
||||
if ( ! str_contains( $text, '&' ) ) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
@@ -2474,7 +2474,7 @@ function convert_chars( $content, $deprecated = '' ) {
|
||||
_deprecated_argument( __FUNCTION__, '0.71' );
|
||||
}
|
||||
|
||||
if ( strpos( $content, '&' ) !== false ) {
|
||||
if ( str_contains( $content, '&' ) ) {
|
||||
$content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content );
|
||||
}
|
||||
|
||||
@@ -2525,7 +2525,7 @@ function convert_invalid_entities( $content ) {
|
||||
'Ÿ' => 'Ÿ',
|
||||
);
|
||||
|
||||
if ( strpos( $content, '' ) !== false ) {
|
||||
if ( str_contains( $content, '' ) ) {
|
||||
$content = strtr( $content, $wp_htmltranswinuni );
|
||||
}
|
||||
|
||||
@@ -5581,7 +5581,7 @@ function _sanitize_text_fields( $str, $keep_newlines = false ) {
|
||||
|
||||
$filtered = wp_check_invalid_utf8( $str );
|
||||
|
||||
if ( strpos( $filtered, '<' ) !== false ) {
|
||||
if ( str_contains( $filtered, '<' ) ) {
|
||||
$filtered = wp_pre_kses_less_than( $filtered );
|
||||
// This will strip extra whitespace for us.
|
||||
$filtered = wp_strip_all_tags( $filtered, false );
|
||||
@@ -6066,7 +6066,7 @@ function wp_staticize_emoji_for_email( $mail ) {
|
||||
}
|
||||
|
||||
foreach ( $headers as $header ) {
|
||||
if ( strpos( $header, ':' ) === false ) {
|
||||
if ( ! str_contains( $header, ':' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -6078,7 +6078,7 @@ function wp_staticize_emoji_for_email( $mail ) {
|
||||
$content = trim( $content );
|
||||
|
||||
if ( 'content-type' === strtolower( $name ) ) {
|
||||
if ( strpos( $content, ';' ) !== false ) {
|
||||
if ( str_contains( $content, ';' ) ) {
|
||||
list( $type, $charset ) = explode( ';', $content );
|
||||
$content_type = trim( $type );
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user