diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 9e9315dede..2b1dabcdae 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -3319,7 +3319,7 @@ function wp_ajax_send_attachment_to_editor() { } $url = empty( $attachment['url'] ) ? '' : $attachment['url']; - $rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $id ) == $url ); + $rel = ( str_contains( $url, 'attachment_id' ) || get_attachment_link( $id ) === $url ); remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' ); diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index a8e5f18a70..9c75c55d03 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -831,7 +831,7 @@ function media_upload_form_handler() { if ( ! empty( $attachment['url'] ) ) { $rel = ''; - if ( strpos( $attachment['url'], 'attachment_id' ) || get_attachment_link( $send_id ) == $attachment['url'] ) { + if ( str_contains( $attachment['url'], 'attachment_id' ) || get_attachment_link( $send_id ) === $attachment['url'] ) { $rel = " rel='attachment wp-att-" . esc_attr( $send_id ) . "'"; } @@ -1359,7 +1359,7 @@ function image_media_send_to_editor( $html, $attachment_id, $attachment ) { $align = ! empty( $attachment['align'] ) ? $attachment['align'] : 'none'; $size = ! empty( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; $alt = ! empty( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; - $rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $attachment_id ) === $url ); + $rel = ( str_contains( $url, 'attachment_id' ) || get_attachment_link( $attachment_id ) === $url ); return get_image_send_to_editor( $attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt ); } diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index f7fd51905e..a97b96af3f 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -571,7 +571,7 @@ final class _WP_Editors { if ( ! empty( $editor_styles ) ) { // Force urlencoding of commas. foreach ( $editor_styles as $key => $url ) { - if ( strpos( $url, ',' ) !== false ) { + if ( str_contains( $url, ',' ) ) { $editor_styles[ $key ] = str_replace( ',', '%2C', $url ); } } diff --git a/src/wp-includes/class-wp-rewrite.php b/src/wp-includes/class-wp-rewrite.php index 1963f21b0c..7580df0e24 100644 --- a/src/wp-includes/class-wp-rewrite.php +++ b/src/wp-includes/class-wp-rewrite.php @@ -1060,13 +1060,18 @@ class WP_Rewrite { * 2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and * minute all present). Set these flags now as we need them for the endpoints. */ - if ( strpos( $struct, '%postname%' ) !== false - || strpos( $struct, '%post_id%' ) !== false - || strpos( $struct, '%pagename%' ) !== false - || ( strpos( $struct, '%year%' ) !== false && strpos( $struct, '%monthnum%' ) !== false && strpos( $struct, '%day%' ) !== false && strpos( $struct, '%hour%' ) !== false && strpos( $struct, '%minute%' ) !== false && strpos( $struct, '%second%' ) !== false ) - ) { + if ( str_contains( $struct, '%postname%' ) + || str_contains( $struct, '%post_id%' ) + || str_contains( $struct, '%pagename%' ) + || ( str_contains( $struct, '%year%' ) + && str_contains( $struct, '%monthnum%' ) + && str_contains( $struct, '%day%' ) + && str_contains( $struct, '%hour%' ) + && str_contains( $struct, '%minute%' ) + && str_contains( $struct, '%second%' ) ) + ) { $post = true; - if ( strpos( $struct, '%pagename%' ) !== false ) { + if ( str_contains( $struct, '%pagename%' ) ) { $page = true; } } @@ -1074,7 +1079,7 @@ class WP_Rewrite { if ( ! $post ) { // For custom post types, we need to add on endpoints as well. foreach ( get_post_types( array( '_builtin' => false ) ) as $ptype ) { - if ( strpos( $struct, "%$ptype%" ) !== false ) { + if ( str_contains( $struct, "%$ptype%" ) ) { $post = true; // This is for page style attachment URLs. @@ -1555,7 +1560,7 @@ class WP_Rewrite { // Apache 1.3 does not support the reluctant (non-greedy) modifier. $match = str_replace( '.+?', '.+', $match ); - if ( strpos( $query, $this->index ) !== false ) { + if ( str_contains( $query, $this->index ) ) { $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; } else { $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n"; diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php index 4d0dddd3d5..8725f5b6d1 100644 --- a/src/wp-includes/class-wp-xmlrpc-server.php +++ b/src/wp-includes/class-wp-xmlrpc-server.php @@ -6990,7 +6990,7 @@ class wp_xmlrpc_server extends IXR_Server { $preg_target = preg_quote( $pagelinkedto, '|' ); foreach ( $p as $para ) { - if ( strpos( $para, $pagelinkedto ) !== false ) { // It exists, but is it a link? + if ( str_contains( $para, $pagelinkedto ) ) { // It exists, but is it a link? preg_match( '|]+?' . $preg_target . '[^>]*>([^>]+?)|', $para, $context ); // If the URL isn't in a link context, keep looking. diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 19abf905b6..956e8290e2 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -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 { diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 33fe2fc18d..56c3d94bf5 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -6104,7 +6104,7 @@ function wp_guess_url() { $script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] ); // The request is for the admin. - if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || str_contains( $_SERVER['REQUEST_URI'], 'wp-login.php' ) ) { + if ( str_contains( $_SERVER['REQUEST_URI'], 'wp-admin' ) || str_contains( $_SERVER['REQUEST_URI'], 'wp-login.php' ) ) { $path = preg_replace( '#/(wp-admin/?.*|wp-login\.php.*)#i', '', $_SERVER['REQUEST_URI'] ); // The request is for a file in ABSPATH. diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 24ea995c7b..a2b1029064 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -907,9 +907,11 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { } $url = true; - if ( strpos( $show, 'url' ) === false && - strpos( $show, 'directory' ) === false && - strpos( $show, 'home' ) === false ) { + + if ( ! str_contains( $show, 'url' ) + && ! str_contains( $show, 'directory' ) + && ! str_contains( $show, 'home' ) + ) { $url = false; } @@ -3738,7 +3740,7 @@ function user_can_richedit() { if ( $is_safari ) { $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && (int) $match[1] >= 534 ); } elseif ( $is_IE ) { - $wp_rich_edit = ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ) !== false ); + $wp_rich_edit = str_contains( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ); } elseif ( $is_gecko || $is_chrome || $is_edge || ( $is_opera && ! wp_is_mobile() ) ) { $wp_rich_edit = true; } diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 9d20aff3d7..00639bd447 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -73,14 +73,12 @@ function wp_fix_server_vars() { } // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests. - if ( isset( $_SERVER['SCRIPT_FILENAME'] ) - && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) === strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) - ) { + if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && str_ends_with( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) ) { $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; } // Fix for Dreamhost and other PHP as CGI hosts. - if ( isset( $_SERVER['SCRIPT_NAME'] ) && ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) ) { + if ( isset( $_SERVER['SCRIPT_NAME'] ) && str_contains( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) ) { unset( $_SERVER['PATH_INFO'] ); } diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 0cddaca4f5..2f3b5ec0c0 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -4059,9 +4059,10 @@ function wp_plupload_default_settings() { * but iOS 7.x has a bug that prevents uploading of videos when enabled. * See #29602. */ - if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false && - strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) { - + if ( wp_is_mobile() + && str_contains( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) + && str_contains( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) + ) { $defaults['multi_selection'] = false; } diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php index cc32c828ab..a984398fb1 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -1538,7 +1538,7 @@ class WP_REST_Server { $data['endpoints'][] = $endpoint_data; // For non-variable routes, generate links. - if ( strpos( $route, '{' ) === false ) { + if ( ! str_contains( $route, '{' ) ) { $data['_links'] = array( 'self' => array( array( diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index d1f91b1e20..cae96c2587 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -1111,7 +1111,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { foreach ( $disposition_header as $value ) { $value = trim( $value ); - if ( strpos( $value, ';' ) === false ) { + if ( ! str_contains( $value, ';' ) ) { continue; } @@ -1121,7 +1121,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { $attributes = array(); foreach ( $attr_parts as $part ) { - if ( strpos( $part, '=' ) === false ) { + if ( ! str_contains( $part, '=' ) ) { continue; }