From 1ce5dc7444eae8cf284f2118b085ad98603a754a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 22 Jun 2023 14:36:26 +0000 Subject: [PATCH] Code Modernization: Replace usage of `strpos()` with `str_contains()`. `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 [52039], [52040], [52326], [55703], [55710], [55987]. Props Soean, spacedmonkey, costdev, dingo_d, azaozz, mikeschroder, flixos90, peterwilsoncc, SergeyBiryukov. Fixes #58206. Built from https://develop.svn.wordpress.org/trunk@55988 git-svn-id: http://core.svn.wordpress.org/trunk@55500 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/comment.php | 2 +- wp-admin/edit.php | 2 +- wp-admin/includes/ajax-actions.php | 4 +- .../class-automatic-upgrader-skin.php | 2 +- .../includes/class-bulk-upgrader-skin.php | 2 +- wp-admin/includes/class-core-upgrader.php | 6 +-- .../includes/class-custom-image-header.php | 6 +-- wp-admin/includes/class-ftp.php | 2 +- .../includes/class-wp-ajax-upgrader-skin.php | 2 +- .../includes/class-wp-automatic-updater.php | 6 +-- .../includes/class-wp-ms-sites-list-table.php | 2 +- .../class-wp-plugin-install-list-table.php | 2 +- .../class-wp-site-health-auto-updates.php | 4 +- wp-admin/includes/class-wp-site-health.php | 4 +- wp-admin/includes/class-wp-upgrader-skin.php | 2 +- wp-admin/includes/credits.php | 2 +- wp-admin/includes/deprecated.php | 2 +- wp-admin/includes/file.php | 4 +- wp-admin/includes/media.php | 6 +-- wp-admin/includes/misc.php | 8 ++-- wp-admin/includes/plugin.php | 4 +- wp-admin/includes/post.php | 6 +-- wp-admin/includes/privacy-tools.php | 2 +- wp-admin/includes/template.php | 2 +- wp-admin/includes/update-core.php | 6 +-- wp-admin/includes/upgrade.php | 6 +-- wp-admin/includes/user.php | 2 +- wp-admin/menu-header.php | 2 +- wp-admin/network/site-settings.php | 2 +- wp-admin/network/themes.php | 2 +- wp-admin/options-general.php | 2 +- wp-admin/options.php | 2 +- wp-admin/post.php | 6 +-- wp-admin/upload.php | 2 +- wp-admin/user-edit.php | 2 +- wp-admin/user-new.php | 2 +- wp-admin/widgets-form.php | 2 +- .../twentyseventeen/inc/icon-functions.php | 2 +- .../template-parts/post/content-audio.php | 2 +- .../template-parts/post/content-video.php | 2 +- wp-content/themes/twentytwenty/comments.php | 2 +- wp-content/themes/twentytwenty/functions.php | 2 +- .../template-parts/pagination.php | 4 +- .../inc/template-functions.php | 2 +- wp-includes/block-supports/duotone.php | 4 +- wp-includes/block-template.php | 2 +- wp-includes/blocks.php | 8 ++-- wp-includes/canonical.php | 6 +-- wp-includes/class-wp-comment-query.php | 2 +- wp-includes/class-wp-customize-manager.php | 2 +- wp-includes/class-wp-date-query.php | 2 +- wp-includes/class-wp-editor.php | 4 +- wp-includes/class-wp-http-proxy.php | 2 +- wp-includes/class-wp-http.php | 8 ++-- wp-includes/class-wp-meta-query.php | 2 +- wp-includes/class-wp-oembed.php | 2 +- wp-includes/class-wp-post-type.php | 2 +- wp-includes/class-wp-query.php | 10 ++--- wp-includes/class-wp-rewrite.php | 4 +- wp-includes/class-wp-site-query.php | 2 +- wp-includes/class-wp-user-query.php | 2 +- wp-includes/class-wp-xmlrpc-server.php | 2 +- wp-includes/class-wp.php | 8 ++-- wp-includes/class-wpdb.php | 4 +- wp-includes/comment-template.php | 6 +-- wp-includes/comment.php | 2 +- wp-includes/cron.php | 2 +- wp-includes/deprecated.php | 6 +-- wp-includes/feed.php | 8 ++-- wp-includes/formatting.php | 42 +++++++++---------- wp-includes/functions.php | 34 +++++++-------- wp-includes/general-template.php | 8 ++-- wp-includes/global-styles-and-settings.php | 2 +- wp-includes/https-detection.php | 4 +- wp-includes/kses.php | 2 +- wp-includes/link-template.php | 8 ++-- wp-includes/media.php | 36 ++++++++-------- wp-includes/ms-deprecated.php | 4 +- wp-includes/ms-files.php | 2 +- wp-includes/ms-functions.php | 4 +- wp-includes/pluggable.php | 8 ++-- wp-includes/pomo/po.php | 2 +- wp-includes/post-template.php | 2 +- wp-includes/post.php | 14 +++---- .../rest-api/class-wp-rest-request.php | 2 +- .../class-wp-rest-autosaves-controller.php | 2 +- .../class-wp-rest-plugins-controller.php | 4 +- .../class-wp-rest-users-controller.php | 2 +- wp-includes/revision.php | 6 +-- wp-includes/rewrite.php | 6 +-- wp-includes/script-loader.php | 4 +- wp-includes/shortcodes.php | 12 +++--- wp-includes/template.php | 2 +- wp-includes/user.php | 4 +- wp-includes/vars.php | 34 +++++++-------- wp-includes/version.php | 2 +- wp-includes/widgets/class-wp-widget-text.php | 4 +- wp-load.php | 2 +- wp-login.php | 4 +- wp-mail.php | 2 +- wp-trackback.php | 2 +- 101 files changed, 253 insertions(+), 253 deletions(-) diff --git a/wp-admin/comment.php b/wp-admin/comment.php index 17f85a093a..ccb72c0910 100644 --- a/wp-admin/comment.php +++ b/wp-admin/comment.php @@ -282,7 +282,7 @@ switch ( $action ) { comment_footer_die( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); } - if ( wp_get_referer() && ! $noredir && false === strpos( wp_get_referer(), 'comment.php' ) ) { + if ( wp_get_referer() && ! $noredir && ! str_contains( wp_get_referer(), 'comment.php' ) ) { $redir = wp_get_referer(); } elseif ( wp_get_original_referer() && ! $noredir ) { $redir = wp_get_original_referer(); diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 7361aa1d40..c2a2b6990c 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -81,7 +81,7 @@ if ( $doaction ) { $sendback = admin_url( $parent_file ); } $sendback = add_query_arg( 'paged', $pagenum, $sendback ); - if ( strpos( $sendback, 'post.php' ) !== false ) { + if ( str_contains( $sendback, 'post.php' ) ) { $sendback = admin_url( $post_new_file ); } diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index b993271ab4..ad48c2f3b4 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -126,7 +126,7 @@ function wp_ajax_ajax_tag_search() { $search = str_replace( $comma, ',', $search ); } - if ( false !== strpos( $search, ',' ) ) { + if ( str_contains( $search, ',' ) ) { $search = explode( ',', $search ); $search = $search[ count( $search ) - 1 ]; } @@ -2306,7 +2306,7 @@ function wp_ajax_widgets_order() { $val = explode( ',', $val ); foreach ( $val as $k => $v ) { - if ( strpos( $v, 'widget-' ) === false ) { + if ( ! str_contains( $v, 'widget-' ) ) { continue; } diff --git a/wp-admin/includes/class-automatic-upgrader-skin.php b/wp-admin/includes/class-automatic-upgrader-skin.php index 15ea79f5f4..4fee6205fc 100644 --- a/wp-admin/includes/class-automatic-upgrader-skin.php +++ b/wp-admin/includes/class-automatic-upgrader-skin.php @@ -84,7 +84,7 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { $string = $this->upgrader->strings[ $string ]; } - if ( strpos( $string, '%' ) !== false ) { + if ( str_contains( $string, '%' ) ) { if ( ! empty( $args ) ) { $string = vsprintf( $string, $args ); } diff --git a/wp-admin/includes/class-bulk-upgrader-skin.php b/wp-admin/includes/class-bulk-upgrader-skin.php index 2b85c67cb7..71a779c594 100644 --- a/wp-admin/includes/class-bulk-upgrader-skin.php +++ b/wp-admin/includes/class-bulk-upgrader-skin.php @@ -59,7 +59,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { $feedback = $this->upgrader->strings[ $feedback ]; } - if ( strpos( $feedback, '%' ) !== false ) { + if ( str_contains( $feedback, '%' ) ) { if ( $args ) { $args = array_map( 'strip_tags', $args ); $args = array_map( 'esc_html', $args ); diff --git a/wp-admin/includes/class-core-upgrader.php b/wp-admin/includes/class-core-upgrader.php index 59d1bc791e..138f904e22 100644 --- a/wp-admin/includes/class-core-upgrader.php +++ b/wp-admin/includes/class-core-upgrader.php @@ -181,9 +181,9 @@ class Core_Upgrader extends WP_Upgrader { * mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full. * do_rollback allows for update_core() to trigger a rollback if needed. */ - if ( false !== strpos( $error_code, 'do_rollback' ) ) { + if ( str_contains( $error_code, 'do_rollback' ) ) { $try_rollback = true; - } elseif ( false !== strpos( $error_code, '__copy_dir' ) ) { + } elseif ( str_contains( $error_code, '__copy_dir' ) ) { $try_rollback = true; } elseif ( 'disk_full' === $error_code ) { $try_rollback = true; @@ -323,7 +323,7 @@ class Core_Upgrader extends WP_Upgrader { } // Don't claim we can update on update-core.php if we have a non-critical failure logged. - if ( $wp_version === $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) { + if ( $wp_version === $failure_data['current'] && str_contains( $offered_ver, '.1.next.minor' ) ) { return false; } diff --git a/wp-admin/includes/class-custom-image-header.php b/wp-admin/includes/class-custom-image-header.php index 582afd3cfd..f1361440fa 100644 --- a/wp-admin/includes/class-custom-image-header.php +++ b/wp-admin/includes/class-custom-image-header.php @@ -369,7 +369,7 @@ class Custom_Image_Header { $default_color = ''; if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { $default_color = get_theme_support( 'custom-header', 'default-text-color' ); - if ( $default_color && false === strpos( $default_color, '#' ) ) { + if ( $default_color && ! str_contains( $default_color, '#' ) ) { $default_color = '#' . $default_color; } } @@ -768,7 +768,7 @@ class Custom_Image_Header { $default_color = ''; if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { $default_color = get_theme_support( 'custom-header', 'default-text-color' ); - if ( $default_color && false === strpos( $default_color, '#' ) ) { + if ( $default_color && ! str_contains( $default_color, '#' ) ) { $default_color = '#' . $default_color; } } @@ -776,7 +776,7 @@ class Custom_Image_Header { $default_color_attr = $default_color ? ' data-default-color="' . esc_attr( $default_color ) . '"' : ''; $header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support( 'custom-header', 'default-text-color' ); - if ( $header_textcolor && false === strpos( $header_textcolor, '#' ) ) { + if ( $header_textcolor && ! str_contains( $header_textcolor, '#' ) ) { $header_textcolor = '#' . $header_textcolor; } diff --git a/wp-admin/includes/class-ftp.php b/wp-admin/includes/class-ftp.php index 07cb936de1..7658a0bc96 100644 --- a/wp-admin/includes/class-ftp.php +++ b/wp-admin/includes/class-ftp.php @@ -797,7 +797,7 @@ class ftp_base { $chunks=explode(';',$pattern); foreach($chunks as $pattern) { $escape=array('$','^','.','{','}','(',')','[',']','|'); - while(strpos($pattern,'**')!==false) + while(str_contains($pattern,'**')) $pattern=str_replace('**','*',$pattern); foreach($escape as $probe) $pattern=str_replace($probe,"\\$probe",$pattern); diff --git a/wp-admin/includes/class-wp-ajax-upgrader-skin.php b/wp-admin/includes/class-wp-ajax-upgrader-skin.php index a3b2f9aaef..1ac8e31b43 100644 --- a/wp-admin/includes/class-wp-ajax-upgrader-skin.php +++ b/wp-admin/includes/class-wp-ajax-upgrader-skin.php @@ -118,7 +118,7 @@ class WP_Ajax_Upgrader_Skin extends Automatic_Upgrader_Skin { $string = $this->upgrader->strings[ $string ]; } - if ( false !== strpos( $string, '%' ) ) { + if ( str_contains( $string, '%' ) ) { if ( ! empty( $args ) ) { $string = vsprintf( $string, $args ); } diff --git a/wp-admin/includes/class-wp-automatic-updater.php b/wp-admin/includes/class-wp-automatic-updater.php index 42b9c96508..b782898950 100644 --- a/wp-admin/includes/class-wp-automatic-updater.php +++ b/wp-admin/includes/class-wp-automatic-updater.php @@ -582,7 +582,7 @@ class WP_Automatic_Updater { // Send debugging email to admin for all development installations. if ( ! empty( $this->update_results ) ) { - $development_version = false !== strpos( get_bloginfo( 'version' ), '-' ); + $development_version = str_contains( get_bloginfo( 'version' ), '-' ); /** * Filters whether to send a debugging email for each automatic background update. @@ -640,13 +640,13 @@ class WP_Automatic_Updater { // Any of these WP_Error codes are critical failures, as in they occurred after we started to copy core files. // We should not try to perform a background update again until there is a successful one-click update performed by the user. $critical = false; - if ( 'disk_full' === $error_code || false !== strpos( $error_code, '__copy_dir' ) ) { + if ( 'disk_full' === $error_code || str_contains( $error_code, '__copy_dir' ) ) { $critical = true; } elseif ( 'rollback_was_required' === $error_code && is_wp_error( $result->get_error_data()->rollback ) ) { // A rollback is only critical if it failed too. $critical = true; $rollback_result = $result->get_error_data()->rollback; - } elseif ( false !== strpos( $error_code, 'do_rollback' ) ) { + } elseif ( str_contains( $error_code, 'do_rollback' ) ) { $critical = true; } diff --git a/wp-admin/includes/class-wp-ms-sites-list-table.php b/wp-admin/includes/class-wp-ms-sites-list-table.php index 1359687235..4e54862185 100644 --- a/wp-admin/includes/class-wp-ms-sites-list-table.php +++ b/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -81,7 +81,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table { $s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : ''; $wild = ''; - if ( false !== strpos( $s, '*' ) ) { + if ( str_contains( $s, '*' ) ) { $wild = '*'; $s = trim( $s, '*' ); } diff --git a/wp-admin/includes/class-wp-plugin-install-list-table.php b/wp-admin/includes/class-wp-plugin-install-list-table.php index 7aa8df975b..0a1efba9ca 100644 --- a/wp-admin/includes/class-wp-plugin-install-list-table.php +++ b/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -105,7 +105,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { $tabs['search'] = __( 'Search Results' ); } - if ( 'beta' === $tab || false !== strpos( get_bloginfo( 'version' ), '-' ) ) { + if ( 'beta' === $tab || str_contains( get_bloginfo( 'version' ), '-' ) ) { $tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' ); } diff --git a/wp-admin/includes/class-wp-site-health-auto-updates.php b/wp-admin/includes/class-wp-site-health-auto-updates.php index 541bbd1f23..15b382ceb8 100644 --- a/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -332,7 +332,7 @@ class WP_Site_Health_Auto_Updates { } $checksums = get_core_checksums( $wp_version, 'en_US' ); - $dev = ( false !== strpos( $wp_version, '-' ) ); + $dev = ( str_contains( $wp_version, '-' ) ); // Get the last stable version's files and test against that. if ( ! $checksums && $dev ) { $checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' ); @@ -396,7 +396,7 @@ class WP_Site_Health_Auto_Updates { public function test_accepts_dev_updates() { require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z // Only for dev versions. - if ( false === strpos( $wp_version, '-' ) ) { + if ( ! str_contains( $wp_version, '-' ) ) { return false; } diff --git a/wp-admin/includes/class-wp-site-health.php b/wp-admin/includes/class-wp-site-health.php index 2a91be3f60..4631f98d10 100644 --- a/wp-admin/includes/class-wp-site-health.php +++ b/wp-admin/includes/class-wp-site-health.php @@ -1366,7 +1366,7 @@ class WP_Site_Health { * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server. * mysqlnd has supported utf8mb4 since 5.0.9. */ - if ( false !== strpos( $mysql_client_version, 'mysqlnd' ) ) { + if ( str_contains( $mysql_client_version, 'mysqlnd' ) ) { $mysql_client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $mysql_client_version ); if ( version_compare( $mysql_client_version, '5.0.9', '<' ) ) { $result['status'] = 'recommended'; @@ -3335,7 +3335,7 @@ class WP_Site_Health { public function get_page_cache_headers() { $cache_hit_callback = static function ( $header_value ) { - return false !== strpos( strtolower( $header_value ), 'hit' ); + return str_contains( strtolower( $header_value ), 'hit' ); }; $cache_headers = array( diff --git a/wp-admin/includes/class-wp-upgrader-skin.php b/wp-admin/includes/class-wp-upgrader-skin.php index c7be61d951..598724f61c 100644 --- a/wp-admin/includes/class-wp-upgrader-skin.php +++ b/wp-admin/includes/class-wp-upgrader-skin.php @@ -197,7 +197,7 @@ class WP_Upgrader_Skin { $feedback = $this->upgrader->strings[ $feedback ]; } - if ( strpos( $feedback, '%' ) !== false ) { + if ( str_contains( $feedback, '%' ) ) { if ( $args ) { $args = array_map( 'strip_tags', $args ); $args = array_map( 'esc_html', $args ); diff --git a/wp-admin/includes/credits.php b/wp-admin/includes/credits.php index 5af26f2f42..907ee93c0b 100644 --- a/wp-admin/includes/credits.php +++ b/wp-admin/includes/credits.php @@ -32,7 +32,7 @@ function wp_credits( $version = '', $locale = '' ) { $results = get_site_transient( 'wordpress_credits_' . $locale ); if ( ! is_array( $results ) - || false !== strpos( $version, '-' ) + || str_contains( $version, '-' ) || ( isset( $results['data']['version'] ) && ! str_starts_with( $version, $results['data']['version'] ) ) ) { $url = "http://api.wordpress.org/core/credits/1.1/?version={$version}&locale={$locale}"; diff --git a/wp-admin/includes/deprecated.php b/wp-admin/includes/deprecated.php index 04f7208422..63aa7f7fa0 100644 --- a/wp-admin/includes/deprecated.php +++ b/wp-admin/includes/deprecated.php @@ -1376,7 +1376,7 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) { } // Eliminate some common badly formed plugin descriptions. - while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) ) + while ( ( null !== $item_key = array_rand($items) ) && str_contains( $items[$item_key]->get_description(), 'Plugin Name:' ) ) unset($items[$item_key]); if ( !isset($items[$item_key]) ) diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index caa71d325b..562fece43e 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -1693,7 +1693,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) { continue; } - if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, skip it. + if ( ! str_contains( $dir, $to ) ) { // If the directory is not within the working directory, skip it. continue; } @@ -1834,7 +1834,7 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) { continue; } - if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, skip it. + if ( ! str_contains( $dir, $to ) ) { // If the directory is not within the working directory, skip it. continue; } diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index ea3c856782..8313c0235d 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -2183,8 +2183,8 @@ function media_upload_form( $errors = null ) { */ if ( wp_is_mobile() && - strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false && - strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false + str_contains( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) && + str_contains( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) ) { $plupload_init['multi_selection'] = false; } @@ -3850,7 +3850,7 @@ function wp_media_attach_action( $parent_id, $action = 'attach' ) { $referer = wp_get_referer(); if ( $referer ) { - if ( false !== strpos( $referer, 'upload.php' ) ) { + if ( str_contains( $referer, 'upload.php' ) ) { $location = remove_query_arg( array( 'attached', 'detach' ), $referer ); } } diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 1493e0e998..7922e8c270 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -76,7 +76,7 @@ function extract_from_markers( $filename, $marker ) { $state = false; foreach ( $markerdata as $markerline ) { - if ( false !== strpos( $markerline, '# END ' . $marker ) ) { + if ( str_contains( $markerline, '# END ' . $marker ) ) { $state = false; } @@ -88,7 +88,7 @@ function extract_from_markers( $filename, $marker ) { $result[] = $markerline; } - if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) { + if ( str_contains( $markerline, '# BEGIN ' . $marker ) ) { $state = true; } } @@ -194,10 +194,10 @@ Any changes to the directives between these markers will be overwritten.' $found_end_marker = false; foreach ( $lines as $line ) { - if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) { + if ( ! $found_marker && str_contains( $line, $start_marker ) ) { $found_marker = true; continue; - } elseif ( ! $found_end_marker && false !== strpos( $line, $end_marker ) ) { + } elseif ( ! $found_end_marker && str_contains( $line, $end_marker ) ) { $found_end_marker = true; continue; } diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 3084312da5..49b574ec4b 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -102,7 +102,7 @@ function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { // If no text domain is defined fall back to the plugin slug. if ( ! $plugin_data['TextDomain'] ) { $plugin_slug = dirname( plugin_basename( $plugin_file ) ); - if ( '.' !== $plugin_slug && false === strpos( $plugin_slug, '/' ) ) { + if ( '.' !== $plugin_slug && ! str_contains( $plugin_slug, '/' ) ) { $plugin_data['TextDomain'] = $plugin_slug; } } @@ -1935,7 +1935,7 @@ function get_admin_page_parent( $parent_page = '' ) { $parent_file = $parent_page; return $parent_page; } elseif ( empty( $typenow ) && $pagenow === $submenu_array[2] - && ( empty( $parent_file ) || false === strpos( $parent_file, '?' ) ) + && ( empty( $parent_file ) || ! str_contains( $parent_file, '?' ) ) ) { $parent_file = $parent_page; return $parent_page; diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 93cd9a7db5..70f792f5f1 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1125,7 +1125,7 @@ function _fix_attachment_links( $post ) { $url_id = (int) $url_match[2]; $rel_id = (int) $rel_match[1]; - if ( ! $url_id || ! $rel_id || $url_id != $rel_id || strpos( $url_match[0], $site_url ) === false ) { + if ( ! $url_id || ! $rel_id || $url_id != $rel_id || ! str_contains( $url_match[0], $site_url ) ) { continue; } @@ -1515,7 +1515,7 @@ function get_sample_permalink_html( $post, $new_title = null, $new_slug = null ) } // Permalinks without a post/page name placeholder don't have anything to edit. - if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) { + if ( ! str_contains( $permalink, '%postname%' ) && ! str_contains( $permalink, '%pagename%' ) ) { $return = '' . __( 'Permalink:' ) . "\n"; if ( false !== $view_link ) { @@ -1755,7 +1755,7 @@ function _admin_notice_post_locked() { } $sendback = wp_get_referer(); - if ( $locked && $sendback && false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) { + if ( $locked && $sendback && ! str_contains( $sendback, 'post.php' ) && ! str_contains( $sendback, 'post-new.php' ) ) { $sendback_text = __( 'Go back' ); } else { diff --git a/wp-admin/includes/privacy-tools.php b/wp-admin/includes/privacy-tools.php index 0c38c71ef0..c5d7c9a97f 100644 --- a/wp-admin/includes/privacy-tools.php +++ b/wp-admin/includes/privacy-tools.php @@ -275,7 +275,7 @@ function wp_privacy_generate_personal_data_export_group_html( $group_data, $grou foreach ( (array) $group_item_data as $group_item_datum ) { $value = $group_item_datum['value']; // If it looks like a link, make it a link. - if ( false === strpos( $value, ' ' ) && ( str_starts_with( $value, 'http://' ) || str_starts_with( $value, 'https://' ) ) ) { + if ( ! str_contains( $value, ' ' ) && ( str_starts_with( $value, 'http://' ) || str_starts_with( $value, 'https://' ) ) ) { $value = '' . esc_html( $value ) . ''; } diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index da8c363571..791fe8253a 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1240,7 +1240,7 @@ function _get_plugin_from_callback( $callback ) { try { if ( is_array( $callback ) ) { $reflection = new ReflectionMethod( $callback[0], $callback[1] ); - } elseif ( is_string( $callback ) && false !== strpos( $callback, '::' ) ) { + } elseif ( is_string( $callback ) && str_contains( $callback, '::' ) ) { $reflection = new ReflectionMethod( $callback ); } else { $reflection = new ReflectionFunction( $callback ); diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php index 3c3510c6d6..506836ed5b 100644 --- a/wp-admin/includes/update-core.php +++ b/wp-admin/includes/update-core.php @@ -1140,7 +1140,7 @@ function update_core( $from, $to ) { $php_version = PHP_VERSION; $mysql_version = $wpdb->db_version(); $old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from. - $development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // A dash in the version indicates a development release. + $development_build = ( str_contains( $old_wp_version . $wp_version, '-' ) ); // A dash in the version indicates a development release. $php_compat = version_compare( $php_version, $required_php_version, '>=' ); if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) { @@ -1764,7 +1764,7 @@ function _upgrade_422_find_genericons_files_in_folder( $directory ) { $files = array(); if ( file_exists( "{$directory}example.html" ) - && false !== strpos( file_get_contents( "{$directory}example.html" ), 'Genericons' ) + && str_contains( file_get_contents( "{$directory}example.html" ), 'Genericons' ) ) { $files[] = "{$directory}example.html"; } @@ -1774,7 +1774,7 @@ function _upgrade_422_find_genericons_files_in_folder( $directory ) { $dirs, static function( $dir ) { // Skip any node_modules directories. - return false === strpos( $dir, 'node_modules' ); + return ! str_contains( $dir, 'node_modules' ); } ); diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 9ef205ed0f..dd31820057 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -1842,7 +1842,7 @@ function upgrade_350() { if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { $meta_keys = array(); foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) { - if ( false !== strpos( $name, '-' ) ) { + if ( str_contains( $name, '-' ) ) { $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; } } @@ -3247,7 +3247,7 @@ function make_site_theme_from_oldschool( $theme_name, $template ) { // Check to make sure it's not a new index. if ( 'index.php' === $oldfile ) { $index = implode( '', file( "$oldpath/$oldfile" ) ); - if ( strpos( $index, 'WP_USE_THEMES' ) !== false ) { + if ( str_contains( $index, 'WP_USE_THEMES' ) ) { if ( ! copy( "$default_dir/$oldfile", "$site_dir/$newfile" ) ) { return false; } @@ -3364,7 +3364,7 @@ function make_site_theme_from_default( $theme_name, $template ) { foreach ( $stylelines as $line ) { foreach ( $headers as $header => $value ) { - if ( strpos( $line, $header ) !== false ) { + if ( str_contains( $line, $header ) ) { $line = $header . ' ' . $value; break; } diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index 47458553d7..1d2d919348 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -174,7 +174,7 @@ function edit_user( $user_id = 0 ) { } // Check for "\" in password. - if ( false !== strpos( wp_unslash( $pass1 ), '\\' ) ) { + if ( str_contains( wp_unslash( $pass1 ), '\\' ) ) { $errors->add( 'pass', __( 'Error: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) ); } diff --git a/wp-admin/menu-header.php b/wp-admin/menu-header.php index 290d6d1813..8409ced14c 100644 --- a/wp-admin/menu-header.php +++ b/wp-admin/menu-header.php @@ -112,7 +112,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { $img_style = ''; $img_class = ' dashicons-before'; - if ( false !== strpos( $class, 'wp-menu-separator' ) ) { + if ( str_contains( $class, 'wp-menu-separator' ) ) { $is_separator = true; } diff --git a/wp-admin/network/site-settings.php b/wp-admin/network/site-settings.php index 7425c1bb8f..c8cef03466 100644 --- a/wp-admin/network/site-settings.php +++ b/wp-admin/network/site-settings.php @@ -143,7 +143,7 @@ if ( ! empty( $messages ) ) { } } - if ( strpos( $option->option_value, "\n" ) !== false ) { + if ( str_contains( $option->option_value, "\n" ) ) { ?> diff --git a/wp-admin/network/themes.php b/wp-admin/network/themes.php index 86747337d5..1ad21e9738 100644 --- a/wp-admin/network/themes.php +++ b/wp-admin/network/themes.php @@ -39,7 +39,7 @@ if ( $action ) { case 'enable': check_admin_referer( 'enable-theme_' . $_GET['theme'] ); WP_Theme::network_enable_theme( $_GET['theme'] ); - if ( false === strpos( $referer, '/network/themes.php' ) ) { + if ( ! str_contains( $referer, '/network/themes.php' ) ) { wp_redirect( network_admin_url( 'themes.php?enabled=1' ) ); } else { wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) ); diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index 5642b461be..58ef903608 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -236,7 +236,7 @@ $tzstring = get_option( 'timezone_string' ); $check_zone_info = true; // Remove old Etc mappings. Fallback to gmt_offset. -if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) { +if ( str_contains( $tzstring, 'Etc/GMT' ) ) { $tzstring = ''; } diff --git a/wp-admin/options.php b/wp-admin/options.php index d434e7b974..df872f4731 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -400,7 +400,7 @@ foreach ( (array) $options as $option ) : - + /> diff --git a/wp-admin/post.php b/wp-admin/post.php index 95a63dfa27..17875cb3e5 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -55,8 +55,8 @@ if ( isset( $_POST['deletepost'] ) ) { $sendback = wp_get_referer(); if ( ! $sendback || - false !== strpos( $sendback, 'post.php' ) || - false !== strpos( $sendback, 'post-new.php' ) ) { + str_contains( $sendback, 'post.php' ) || + str_contains( $sendback, 'post-new.php' ) ) { if ( 'attachment' === $post_type ) { $sendback = admin_url( 'upload.php' ); } else { @@ -97,7 +97,7 @@ switch ( $action ) { $_POST['ping_status'] = get_default_comment_status( $post->post_type, 'pingback' ); // Wrap Quick Draft content in the Paragraph block. - if ( false === strpos( $_POST['content'], '' ) ) { + if ( ! str_contains( $_POST['content'], '' ) ) { $_POST['content'] = sprintf( '%s', str_replace( array( "\r\n", "\r", "\n" ), '
', $_POST['content'] ) diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 08c6241107..29a8c4de8d 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -263,7 +263,7 @@ if ( $doaction ) { $location = 'upload.php'; $referer = wp_get_referer(); if ( $referer ) { - if ( false !== strpos( $referer, 'upload.php' ) ) { + if ( str_contains( $referer, 'upload.php' ) ) { $location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer ); } } diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php index d17574ce76..dd7309cac0 100644 --- a/wp-admin/user-edit.php +++ b/wp-admin/user-edit.php @@ -211,7 +211,7 @@ switch ( $action ) {

- +

diff --git a/wp-admin/user-new.php b/wp-admin/user-new.php index a1bf974237..5c8f71c311 100644 --- a/wp-admin/user-new.php +++ b/wp-admin/user-new.php @@ -34,7 +34,7 @@ if ( isset( $_REQUEST['action'] ) && 'adduser' === $_REQUEST['action'] ) { $user_details = null; $user_email = wp_unslash( $_REQUEST['email'] ); - if ( false !== strpos( $user_email, '@' ) ) { + if ( str_contains( $user_email, '@' ) ) { $user_details = get_user_by( 'email', $user_email ); } else { if ( current_user_can( 'manage_network_users' ) ) { diff --git a/wp-admin/widgets-form.php b/wp-admin/widgets-form.php index e6f4fc3979..4b544b6342 100644 --- a/wp-admin/widgets-form.php +++ b/wp-admin/widgets-form.php @@ -450,7 +450,7 @@ do_action( 'widgets_admin_page' ); $theme_sidebars = array(); foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) { - if ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) { + if ( str_contains( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' === substr( $sidebar, 0, 16 ) ) { $wrap_class = 'widgets-holder-wrap'; if ( ! empty( $registered_sidebar['class'] ) ) { $wrap_class .= ' ' . $registered_sidebar['class']; diff --git a/wp-content/themes/twentyseventeen/inc/icon-functions.php b/wp-content/themes/twentyseventeen/inc/icon-functions.php index 82a1ebedcc..b25428fb1d 100644 --- a/wp-content/themes/twentyseventeen/inc/icon-functions.php +++ b/wp-content/themes/twentyseventeen/inc/icon-functions.php @@ -130,7 +130,7 @@ function twentyseventeen_nav_menu_social_icons( $item_output, $item, $depth, $ar // Change SVG icon inside social links menu if there is supported URL. if ( 'social' === $args->theme_location ) { foreach ( $social_icons as $attr => $value ) { - if ( false !== strpos( $item_output, $attr ) ) { + if ( str_contains( $item_output, $attr ) ) { $item_output = str_replace( $args->link_after, '' . twentyseventeen_get_svg( array( 'icon' => esc_attr( $value ) ) ), $item_output ); } } diff --git a/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php b/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php index eea60e6c7c..d50ce9f66a 100644 --- a/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php +++ b/wp-content/themes/twentyseventeen/template-parts/post/content-audio.php @@ -46,7 +46,7 @@ $audio = false; // Only get audio from the content if a playlist isn't present. - if ( false === strpos( $content, 'wp-playlist-script' ) ) { + if ( ! str_contains( $content, 'wp-playlist-script' ) ) { $audio = get_media_embedded_in_content( $content, array( 'audio' ) ); } diff --git a/wp-content/themes/twentyseventeen/template-parts/post/content-video.php b/wp-content/themes/twentyseventeen/template-parts/post/content-video.php index fd7865db92..a5c387e767 100644 --- a/wp-content/themes/twentyseventeen/template-parts/post/content-video.php +++ b/wp-content/themes/twentyseventeen/template-parts/post/content-video.php @@ -46,7 +46,7 @@ $video = false; // Only get video from the content if a playlist isn't present. - if ( false === strpos( $content, 'wp-playlist-script' ) ) { + if ( ! str_contains( $content, 'wp-playlist-script' ) ) { $video = get_media_embedded_in_content( $content, array( 'video', 'object', 'embed', 'iframe' ) ); } ?> diff --git a/wp-content/themes/twentytwenty/comments.php b/wp-content/themes/twentytwenty/comments.php index 91a3198eed..c4ef803cba 100644 --- a/wp-content/themes/twentytwenty/comments.php +++ b/wp-content/themes/twentytwenty/comments.php @@ -80,7 +80,7 @@ if ( $comments ) { $pagination_classes = ''; // If we're only showing the "Next" link, add a class indicating so. - if ( false === strpos( $comment_pagination, 'prev page-numbers' ) ) { + if ( ! str_contains( $comment_pagination, 'prev page-numbers' ) ) { $pagination_classes = ' only-next'; } ?> diff --git a/wp-content/themes/twentytwenty/functions.php b/wp-content/themes/twentytwenty/functions.php index 65085df485..9fd2818ae7 100644 --- a/wp-content/themes/twentytwenty/functions.php +++ b/wp-content/themes/twentytwenty/functions.php @@ -316,7 +316,7 @@ function twentytwenty_get_custom_logo( $html ) { ); // Add a style attribute with the height, or append the height to the style attribute if the style attribute already exists. - if ( strpos( $html, ' style=' ) === false ) { + if ( ! str_contains( $html, ' style=' ) ) { $search[] = '/(src=)/'; $replace[] = "style=\"height: {$logo_height}px;\" src="; } else { diff --git a/wp-content/themes/twentytwenty/template-parts/pagination.php b/wp-content/themes/twentytwenty/template-parts/pagination.php index 8973447ad6..036b6fd6f4 100644 --- a/wp-content/themes/twentytwenty/template-parts/pagination.php +++ b/wp-content/themes/twentytwenty/template-parts/pagination.php @@ -37,12 +37,12 @@ $posts_pagination = get_the_posts_pagination( ); // If we're not outputting the previous page link, prepend a placeholder with `visibility: hidden` to take its place. -if ( strpos( $posts_pagination, 'prev page-numbers' ) === false ) { +if ( ! str_contains( $posts_pagination, 'prev page-numbers' ) ) { $posts_pagination = str_replace( '', $posts_pagination ); } diff --git a/wp-content/themes/twentytwentyone/inc/template-functions.php b/wp-content/themes/twentytwentyone/inc/template-functions.php index d0d385d3ba..a862dfac14 100644 --- a/wp-content/themes/twentytwentyone/inc/template-functions.php +++ b/wp-content/themes/twentytwentyone/inc/template-functions.php @@ -445,7 +445,7 @@ function twenty_twenty_one_get_attachment_image_attributes( $attr, $attachment, return $attr; } - if ( isset( $attr['class'] ) && false !== strpos( $attr['class'], 'custom-logo' ) ) { + if ( isset( $attr['class'] ) && str_contains( $attr['class'], 'custom-logo' ) ) { return $attr; } diff --git a/wp-includes/block-supports/duotone.php b/wp-includes/block-supports/duotone.php index 489f9fdeb3..429eeee051 100644 --- a/wp-includes/block-supports/duotone.php +++ b/wp-includes/block-supports/duotone.php @@ -48,14 +48,14 @@ * @return float Value in the range [0, 1]. */ function wp_tinycolor_bound01( $n, $max ) { - if ( 'string' === gettype( $n ) && false !== strpos( $n, '.' ) && 1 === (float) $n ) { + if ( 'string' === gettype( $n ) && str_contains( $n, '.' ) && 1 === (float) $n ) { $n = '100%'; } $n = min( $max, max( 0, (float) $n ) ); // Automatically convert percentage into number. - if ( 'string' === gettype( $n ) && false !== strpos( $n, '%' ) ) { + if ( 'string' === gettype( $n ) && str_contains( $n, '%' ) ) { $n = (int) ( $n * $max ) / 100; } diff --git a/wp-includes/block-template.php b/wp-includes/block-template.php index a65283cbe7..b3b1eecd49 100644 --- a/wp-includes/block-template.php +++ b/wp-includes/block-template.php @@ -166,7 +166,7 @@ function resolve_block_template( $template_type, $template_hierarchy, $fallback_ // Is the active theme a child theme, and is the PHP fallback template part of it? if ( str_starts_with( $fallback_template, $theme_base_path ) && - strpos( $fallback_template, $parent_theme_base_path ) === false + ! str_contains( $fallback_template, $parent_theme_base_path ) ) { $fallback_template_slug = substr( $fallback_template, diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 729c789683..9b1884c660 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -583,7 +583,7 @@ function has_blocks( $post = null ) { $post = $wp_post->post_content; } - return false !== strpos( (string) $post, '' ) ) { + if ( str_contains( $content, '' ) ) { $content = str_replace( "\n\n", '', $content ); $content = str_replace( "\n", '', $content ); $content = str_replace( "\n", '', $content ); diff --git a/wp-includes/class-wp-rewrite.php b/wp-includes/class-wp-rewrite.php index 1f42f838bc..35598c3d80 100644 --- a/wp-includes/class-wp-rewrite.php +++ b/wp-includes/class-wp-rewrite.php @@ -509,7 +509,7 @@ class WP_Rewrite { $date_endian = ''; foreach ( $endians as $endian ) { - if ( false !== strpos( $this->permalink_structure, $endian ) ) { + if ( str_contains( $this->permalink_structure, $endian ) ) { $date_endian = $endian; break; } @@ -1660,7 +1660,7 @@ class WP_Rewrite { $external = false; $query = add_query_arg( $query, 'index.php' ); } else { - $index = false === strpos( $query, '?' ) ? strlen( $query ) : strpos( $query, '?' ); + $index = ! str_contains( $query, '?' ) ? strlen( $query ) : strpos( $query, '?' ); $front = substr( $query, 0, $index ); $external = $front != $this->index; diff --git a/wp-includes/class-wp-site-query.php b/wp-includes/class-wp-site-query.php index 6435ac02e1..6598866162 100644 --- a/wp-includes/class-wp-site-query.php +++ b/wp-includes/class-wp-site-query.php @@ -753,7 +753,7 @@ class WP_Site_Query { protected function get_search_sql( $search, $columns ) { global $wpdb; - if ( false !== strpos( $search, '*' ) ) { + if ( str_contains( $search, '*' ) ) { $like = '%' . implode( '%', array_map( array( $wpdb, 'esc_like' ), explode( '*', $search ) ) ) . '%'; } else { $like = '%' . $wpdb->esc_like( $search ) . '%'; diff --git a/wp-includes/class-wp-user-query.php b/wp-includes/class-wp-user-query.php index 60190ac838..4f56ca940e 100644 --- a/wp-includes/class-wp-user-query.php +++ b/wp-includes/class-wp-user-query.php @@ -713,7 +713,7 @@ class WP_User_Query { $search_columns = array_intersect( $qv['search_columns'], array( 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename', 'display_name' ) ); } if ( ! $search_columns ) { - if ( false !== strpos( $search, '@' ) ) { + if ( str_contains( $search, '@' ) ) { $search_columns = array( 'user_email' ); } elseif ( is_numeric( $search ) ) { $search_columns = array( 'user_login', 'ID' ); diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index 96961d0620..4d0dddd3d5 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -5691,7 +5691,7 @@ class wp_xmlrpc_server extends IXR_Server { $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" ); if ( is_array( $attachments ) ) { foreach ( $attachments as $file ) { - if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) { + if ( ! empty( $file->guid ) && str_contains( $post_content, $file->guid ) ) { $wpdb->update( $wpdb->posts, array( 'post_parent' => $post_id ), array( 'ID' => $file->ID ) ); } } diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index f669b670ff..0660c50553 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -274,10 +274,10 @@ class WP { } // If req_uri is empty or if it is a request for ourself, unset error. - if ( empty( $requested_path ) || $requested_file == $self || strpos( $_SERVER['PHP_SELF'], 'wp-admin/' ) !== false ) { + if ( empty( $requested_path ) || $requested_file == $self || str_contains( $_SERVER['PHP_SELF'], 'wp-admin/' ) ) { unset( $error, $_GET['error'] ); - if ( isset( $perma_query_vars ) && strpos( $_SERVER['PHP_SELF'], 'wp-admin/' ) !== false ) { + if ( isset( $perma_query_vars ) && str_contains( $_SERVER['PHP_SELF'], 'wp-admin/' ) ) { unset( $perma_query_vars ); } @@ -455,7 +455,7 @@ class WP { // We're showing a feed, so WP is indeed the only thing that last changed. if ( ! empty( $this->query_vars['withcomments'] ) - || false !== strpos( $this->query_vars['feed'], 'comments-' ) + || str_contains( $this->query_vars['feed'], 'comments-' ) || ( empty( $this->query_vars['withoutcomments'] ) && ( ! empty( $this->query_vars['p'] ) || ! empty( $this->query_vars['name'] ) @@ -720,7 +720,7 @@ class WP { // Check for paged content that exceeds the max number of pages. if ( $post && ! empty( $this->query_vars['page'] ) ) { // Check if content is actually intended to be paged. - if ( false !== strpos( $post->post_content, $next ) ) { + if ( str_contains( $post->post_content, $next ) ) { $page = trim( $this->query_vars['page'], '/' ); $content_found = (int) $page <= ( substr_count( $post->post_content, $next ) + 1 ); } else { diff --git a/wp-includes/class-wpdb.php b/wp-includes/class-wpdb.php index d5ed464e0b..6ea7403bf1 100644 --- a/wp-includes/class-wpdb.php +++ b/wp-includes/class-wpdb.php @@ -1497,7 +1497,7 @@ class wpdb { } // This is not meant to be foolproof -- but it will catch obviously incorrect usage. - if ( strpos( $query, '%' ) === false ) { + if ( ! str_contains( $query, '%' ) ) { wp_load_translations_early(); _doing_it_wrong( 'wpdb::prepare', @@ -4068,7 +4068,7 @@ class wpdb { * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server. * mysqlnd has supported utf8mb4 since 5.0.9. */ - if ( false !== strpos( $client_version, 'mysqlnd' ) ) { + if ( str_contains( $client_version, 'mysqlnd' ) ) { $client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $client_version ); return version_compare( $client_version, '5.0.9', '>=' ); } else { diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 514f65acbf..3027cc606b 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -970,13 +970,13 @@ function get_comments_number_text( $zero = false, $one = false, $more = false, $ $text = trim( strip_tags( $text ), '% ' ); // Replace '% Comments' with a proper plural form. - if ( $text && ! preg_match( '/[0-9]+/', $text ) && false !== strpos( $more, '%' ) ) { + if ( $text && ! preg_match( '/[0-9]+/', $text ) && str_contains( $more, '%' ) ) { /* translators: %s: Number of comments. */ $new_text = _n( '%s Comment', '%s Comments', $comments_number ); $new_text = trim( sprintf( $new_text, '' ) ); $more = str_replace( $text, $new_text, $more ); - if ( false === strpos( $more, '%' ) ) { + if ( ! str_contains( $more, '%' ) ) { $more = '% ' . $more; } } @@ -2651,7 +2651,7 @@ function comment_form( $args = array(), $post = null ) { $args = array_merge( $defaults, $args ); // Remove `aria-describedby` from the email field if there's no associated description. - if ( isset( $args['fields']['email'] ) && false === strpos( $args['comment_notes_before'], 'id="email-notes"' ) ) { + if ( isset( $args['fields']['email'] ) && ! str_contains( $args['comment_notes_before'], 'id="email-notes"' ) ) { $args['fields']['email'] = str_replace( ' aria-describedby="email-notes"', '', diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 5d87da2890..b732f83ad4 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -136,7 +136,7 @@ function check_comment( $author, $email, $url, $comment, $user_ip, $user_agent, $ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE comment_author = %s AND comment_author_email = %s and comment_approved = '1' LIMIT 1", $author, $email ) ); } if ( ( 1 == $ok_to_comment ) && - ( empty( $mod_keys ) || false === strpos( $email, $mod_keys ) ) ) { + ( empty( $mod_keys ) || ! str_contains( $email, $mod_keys ) ) ) { return true; } else { return false; diff --git a/wp-includes/cron.php b/wp-includes/cron.php index 663f819ab0..b5db6a4c69 100644 --- a/wp-includes/cron.php +++ b/wp-includes/cron.php @@ -974,7 +974,7 @@ function wp_cron() { */ function _wp_cron() { // Prevent infinite loops caused by lack of wp-cron.php. - if ( strpos( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) !== false || ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ) { + if ( str_contains( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) || ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ) { return 0; } diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index ca760ff786..35c0d3094f 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -889,7 +889,7 @@ function permalink_single_rss($deprecated = '') { function wp_get_links($args = '') { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); - if ( strpos( $args, '=' ) === false ) { + if ( ! str_contains( $args, '=' ) ) { $cat_id = $args; $args = add_query_arg( 'category', $cat_id, $args ); } @@ -995,7 +995,7 @@ function get_links($category = -1, $before = '', $after = '
', $between = ' $output .= ''; if ( $row->link_image != null && $show_images ) { - if ( strpos($row->link_image, 'http') !== false ) + if ( str_contains( $row->link_image, 'http' ) ) $output .= "link_image\" $alt $title />"; else // If it's a relative path. $output .= "link_image\" $alt $title />"; @@ -4484,7 +4484,7 @@ function wp_typography_get_css_variable_inline_style( $attributes, $feature, $cs } // If we don't have a preset CSS variable, we'll assume it's a regular CSS value. - if ( strpos( $style_value, "var:preset|{$css_property}|" ) === false ) { + if ( ! str_contains( $style_value, "var:preset|{$css_property}|" ) ) { return sprintf( '%s:%s;', $css_property, $style_value ); } diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 7b91cbb70b..e737b34d0e 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -448,7 +448,7 @@ function the_category_rss( $type = null ) { */ function html_type_rss() { $type = get_bloginfo( 'html_type' ); - if ( strpos( $type, 'xhtml' ) !== false ) { + if ( str_contains( $type, 'xhtml' ) ) { $type = 'xhtml'; } else { $type = 'html'; @@ -580,7 +580,7 @@ function atom_enclosure() { * @return array array(type, value) */ function prep_atom_text_construct( $data ) { - if ( strpos( $data, '<' ) === false && strpos( $data, '&' ) === false ) { + if ( ! str_contains( $data, '<' ) && ! str_contains( $data, '&' ) ) { return array( 'text', $data ); } @@ -597,7 +597,7 @@ function prep_atom_text_construct( $data ) { unset( $parser ); if ( ! $code ) { - if ( strpos( $data, '<' ) === false ) { + if ( ! str_contains( $data, '<' ) ) { return array( 'text', $data ); } else { $data = "
$data
"; @@ -605,7 +605,7 @@ function prep_atom_text_construct( $data ) { } } - if ( strpos( $data, ']]>' ) === false ) { + if ( ! str_contains( $data, ']]>' ) ) { return array( 'html', "" ); } else { return array( 'html', htmlspecialchars( $data ) ); diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 9ea2b9f8fa..0782af0d2a 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -272,18 +272,18 @@ function wptexturize( $text, $reset = false ) { $curl = str_replace( $static_characters, $static_replacements, $curl ); - if ( false !== strpos( $curl, "'" ) ) { + if ( str_contains( $curl, "'" ) ) { $curl = preg_replace( $dynamic_characters['apos'], $dynamic_replacements['apos'], $curl ); $curl = wptexturize_primes( $curl, "'", $prime, $open_sq_flag, $closing_single_quote ); $curl = str_replace( $apos_flag, $apos, $curl ); $curl = str_replace( $open_sq_flag, $opening_single_quote, $curl ); } - if ( false !== strpos( $curl, '"' ) ) { + if ( str_contains( $curl, '"' ) ) { $curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl ); $curl = wptexturize_primes( $curl, '"', $double_prime, $open_q_flag, $closing_quote ); $curl = str_replace( $open_q_flag, $opening_quote, $curl ); } - if ( false !== strpos( $curl, '-' ) ) { + if ( str_contains( $curl, '-' ) ) { $curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl ); } @@ -326,7 +326,7 @@ function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quo $sentences = explode( $open_quote, $haystack ); foreach ( $sentences as $key => &$sentence ) { - if ( false === strpos( $sentence, $needle ) ) { + if ( ! str_contains( $sentence, $needle ) ) { continue; } elseif ( 0 !== $key && 0 === substr_count( $sentence, $close_quote ) ) { $sentence = preg_replace( $quote_pattern, $flag, $sentence, -1, $count ); @@ -362,7 +362,7 @@ function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quo $sentence = preg_replace( $prime_pattern, $prime, $sentence ); $sentence = preg_replace( $quote_pattern, $close_quote, $sentence ); } - if ( '"' === $needle && false !== strpos( $sentence, '"' ) ) { + if ( '"' === $needle && str_contains( $sentence, '"' ) ) { $sentence = str_replace( '"', $close_quote, $sentence ); } } @@ -453,7 +453,7 @@ function wpautop( $text, $br = true ) { * Pre tags shouldn't be touched by autop. * Replace pre tags with placeholders and bring them back after autop. */ - if ( strpos( $text, '', $text ); $last_part = array_pop( $text_parts ); $text = ''; @@ -498,7 +498,7 @@ function wpautop( $text, $br = true ) { $text = wp_replace_in_html_tags( $text, array( "\n" => ' ' ) ); // Collapse line breaks before and after ', $text ); } @@ -507,7 +507,7 @@ function wpautop( $text, $br = true ) { * Collapse line breaks inside elements, before and elements * so they don't get autop'd. */ - if ( strpos( $text, '' ) !== false ) { + if ( str_contains( $text, '' ) ) { $text = preg_replace( '|(]*>)\s*|', '$1', $text ); $text = preg_replace( '|\s*|', '', $text ); $text = preg_replace( '%\s*(]*>)\s*%', '$1', $text ); @@ -517,14 +517,14 @@ function wpautop( $text, $br = true ) { * Collapse line breaks inside