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
This commit is contained in:
Sergey Biryukov 2023-06-22 14:36:26 +00:00
parent b916b71dde
commit 1ce5dc7444
101 changed files with 253 additions and 253 deletions

View File

@ -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();

View File

@ -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 );
}

View File

@ -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;
}

View File

@ -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 );
}

View File

@ -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 );

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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 );
}

View File

@ -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;
}

View File

@ -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, '*' );
}

View File

@ -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' );
}

View File

@ -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;
}

View File

@ -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(

View File

@ -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 );

View File

@ -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}";

View File

@ -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]) )

View File

@ -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;
}

View File

@ -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 );
}
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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 = '<strong>' . __( 'Permalink:' ) . "</strong>\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 {

View File

@ -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 = '<a href="' . esc_url( $value ) . '">' . esc_html( $value ) . '</a>';
}

View File

@ -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 );

View File

@ -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" ), '<title>Genericons</title>' )
&& str_contains( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' )
) {
$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' );
}
);

View File

@ -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;
}

View File

@ -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', __( '<strong>Error:</strong> Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) );
}

View File

@ -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;
}

View File

@ -143,7 +143,7 @@ if ( ! empty( $messages ) ) {
}
}
if ( strpos( $option->option_value, "\n" ) !== false ) {
if ( str_contains( $option->option_value, "\n" ) ) {
?>
<tr class="form-field">
<th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>" class="code"><?php echo esc_html( $option->option_name ); ?></label></th>

View File

@ -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 ) );

View File

@ -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 = '';
}

View File

@ -400,7 +400,7 @@ foreach ( (array) $options as $option ) :
<tr>
<th scope="row"><label for="<?php echo $name; ?>"><?php echo esc_html( $option->option_name ); ?></label></th>
<td>
<?php if ( strpos( $value, "\n" ) !== false ) : ?>
<?php if ( str_contains( $value, "\n" ) ) : ?>
<textarea class="<?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" cols="30" rows="5"><?php echo esc_textarea( $value ); ?></textarea>
<?php else : ?>
<input class="regular-text <?php echo $class; ?>" type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $value ); ?>"<?php disabled( $disabled, true ); ?> />

View File

@ -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'], '<!-- wp:paragraph -->' ) ) {
if ( ! str_contains( $_POST['content'], '<!-- wp:paragraph -->' ) ) {
$_POST['content'] = sprintf(
'<!-- wp:paragraph -->%s<!-- /wp:paragraph -->',
str_replace( array( "\r\n", "\r", "\n" ), '<br />', $_POST['content'] )

View File

@ -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 );
}
}

View File

@ -211,7 +211,7 @@ switch ( $action ) {
<?php else : ?>
<p><strong><?php _e( 'User updated.' ); ?></strong></p>
<?php endif; ?>
<?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
<?php if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
<p><a href="<?php echo esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e( '&larr; Go to Users' ); ?></a></p>
<?php endif; ?>
</div>

View File

@ -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' ) ) {

View File

@ -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'];

View File

@ -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, '</span>' . twentyseventeen_get_svg( array( 'icon' => esc_attr( $value ) ) ), $item_output );
}
}

View File

@ -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' ) );
}

View File

@ -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' ) );
}
?>

View File

@ -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';
}
?>

View File

@ -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 {

View File

@ -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( '<div class="nav-links">', '<div class="nav-links"><span class="prev page-numbers placeholder" aria-hidden="true">' . $prev_text . '</span>', $posts_pagination );
}
// If we're not outputting the next page link, append a placeholder with `visibility: hidden` to take its place.
if ( strpos( $posts_pagination, 'next page-numbers' ) === false ) {
if ( ! str_contains( $posts_pagination, 'next page-numbers' ) ) {
$posts_pagination = str_replace( '</div>', '<span class="next page-numbers placeholder" aria-hidden="true">' . $next_text . '</span></div>', $posts_pagination );
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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,

View File

@ -583,7 +583,7 @@ function has_blocks( $post = null ) {
$post = $wp_post->post_content;
}
return false !== strpos( (string) $post, '<!-- wp:' );
return str_contains( (string) $post, '<!-- wp:' );
}
/**
@ -619,12 +619,12 @@ function has_block( $block_name, $post = null ) {
* This matches behavior for WordPress 5.0.0 - 5.3.0 in matching blocks by
* their serialized names.
*/
if ( false === strpos( $block_name, '/' ) ) {
if ( ! str_contains( $block_name, '/' ) ) {
$block_name = 'core/' . $block_name;
}
// Test for existence of block by its fully qualified name.
$has_block = false !== strpos( $post, '<!-- wp:' . $block_name . ' ' );
$has_block = str_contains( $post, '<!-- wp:' . $block_name . ' ' );
if ( ! $has_block ) {
/*
@ -633,7 +633,7 @@ function has_block( $block_name, $post = null ) {
*/
$serialized_block_name = strip_core_block_namespace( $block_name );
if ( $serialized_block_name !== $block_name ) {
$has_block = false !== strpos( $post, '<!-- wp:' . $serialized_block_name . ' ' );
$has_block = str_contains( $post, '<!-- wp:' . $serialized_block_name . ' ' );
}
}

View File

@ -389,7 +389,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
}
}
}
} elseif ( is_single() && strpos( $wp_rewrite->permalink_structure, '%category%' ) !== false ) {
} elseif ( is_single() && str_contains( $wp_rewrite->permalink_structure, '%category%' ) ) {
$category_name = get_query_var( 'category_name' );
if ( $category_name ) {
@ -518,7 +518,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
if ( ! empty( $addl_path )
&& $wp_rewrite->using_index_permalinks()
&& strpos( $redirect['path'], '/' . $wp_rewrite->index . '/' ) === false
&& ! str_contains( $redirect['path'], '/' . $wp_rewrite->index . '/' )
) {
$redirect['path'] = trailingslashit( $redirect['path'] ) . $wp_rewrite->index . '/';
}
@ -737,7 +737,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
}
// Hex-encoded octets are case-insensitive.
if ( false !== strpos( $requested_url, '%' ) ) {
if ( str_contains( $requested_url, '%' ) ) {
if ( ! function_exists( 'lowercase_octets' ) ) {
/**
* Converts the first hex-encoded octet match to lowercase.

View File

@ -677,7 +677,7 @@ class WP_Comment_Query {
// If no date-related order is available, use the date from the first available clause.
if ( ! $comment_id_order ) {
foreach ( $orderby_array as $orderby_clause ) {
if ( false !== strpos( 'ASC', $orderby_clause ) ) {
if ( str_contains( 'ASC', $orderby_clause ) ) {
$comment_id_order = 'ASC';
} else {
$comment_id_order = 'DESC';

View File

@ -3610,7 +3610,7 @@ final class WP_Customize_Manager {
*/
$revisions = wp_get_post_revisions( $changeset_post_id, array( 'check_enabled' => false ) );
foreach ( $revisions as $revision ) {
if ( false !== strpos( $revision->post_name, "{$changeset_post_id}-autosave" ) ) {
if ( str_contains( $revision->post_name, "{$changeset_post_id}-autosave" ) ) {
$wpdb->update(
$wpdb->posts,
array(

View File

@ -494,7 +494,7 @@ class WP_Date_Query {
);
// Attempt to detect a table prefix.
if ( false === strpos( $column, '.' ) ) {
if ( ! str_contains( $column, '.' ) ) {
/**
* Filters the list of valid date query columns.
*

View File

@ -106,7 +106,7 @@ final class _WP_Editors {
self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() );
if ( self::$this_tinymce ) {
if ( false !== strpos( $editor_id, '[' ) ) {
if ( str_contains( $editor_id, '[' ) ) {
self::$this_tinymce = false;
_deprecated_argument( 'wp_editor()', '3.9.0', 'TinyMCE editor IDs cannot have brackets.' );
}
@ -1484,7 +1484,7 @@ final class _WP_Editors {
continue;
}
if ( false !== strpos( $value, '&' ) ) {
if ( str_contains( $value, '&' ) ) {
$mce_translation[ $key ] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8' );
}
}

View File

@ -209,7 +209,7 @@ class WP_HTTP_Proxy {
if ( null === $bypass_hosts ) {
$bypass_hosts = preg_split( '|,\s*|', WP_PROXY_BYPASS_HOSTS );
if ( false !== strpos( WP_PROXY_BYPASS_HOSTS, '*' ) ) {
if ( str_contains( WP_PROXY_BYPASS_HOSTS, '*' ) ) {
$wildcard_regex = array();
foreach ( $bypass_hosts as $host ) {
$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );

View File

@ -721,7 +721,7 @@ class WP_Http {
* In this case, determine the final HTTP header and parse from there.
*/
for ( $i = count( $headers ) - 1; $i >= 0; $i-- ) {
if ( ! empty( $headers[ $i ] ) && false === strpos( $headers[ $i ], ':' ) ) {
if ( ! empty( $headers[ $i ] ) && ! str_contains( $headers[ $i ], ':' ) ) {
$headers = array_splice( $headers, $i );
break;
}
@ -734,7 +734,7 @@ class WP_Http {
continue;
}
if ( false === strpos( $tempheader, ':' ) ) {
if ( ! str_contains( $tempheader, ':' ) ) {
$stack = explode( ' ', $tempheader, 3 );
$stack[] = '';
list( , $response['code'], $response['message']) = $stack;
@ -905,7 +905,7 @@ class WP_Http {
if ( null === $accessible_hosts ) {
$accessible_hosts = preg_split( '|,\s*|', WP_ACCESSIBLE_HOSTS );
if ( false !== strpos( WP_ACCESSIBLE_HOSTS, '*' ) ) {
if ( str_contains( WP_ACCESSIBLE_HOSTS, '*' ) ) {
$wildcard_regex = array();
foreach ( $accessible_hosts as $host ) {
$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
@ -1096,7 +1096,7 @@ class WP_Http {
return 4;
}
if ( false !== strpos( $maybe_ip, ':' ) && preg_match( '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim( $maybe_ip, ' []' ) ) ) {
if ( str_contains( $maybe_ip, ':' ) && preg_match( '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim( $maybe_ip, ' []' ) ) ) {
return 6;
}

View File

@ -374,7 +374,7 @@ class WP_Meta_Query {
* If any JOINs are LEFT JOINs (as in the case of NOT EXISTS), then all JOINs should
* be LEFT. Otherwise posts with no metadata will be excluded from results.
*/
if ( false !== strpos( $sql['join'], 'LEFT JOIN' ) ) {
if ( str_contains( $sql['join'], 'LEFT JOIN' ) ) {
$sql['join'] = str_replace( 'INNER JOIN', 'LEFT JOIN', $sql['join'] );
}

View File

@ -754,7 +754,7 @@ class WP_oEmbed {
* @return string Possibly modified $html
*/
public function _strip_newlines( $html, $data, $url ) {
if ( false === strpos( $html, "\n" ) ) {
if ( ! str_contains( $html, "\n" ) ) {
return $html;
}

View File

@ -737,7 +737,7 @@ final class WP_Post_Type {
remove_rewrite_tag( "%$this->name%" );
remove_permastruct( $this->name );
foreach ( $wp_rewrite->extra_rules_top as $regex => $query ) {
if ( false !== strpos( $query, "index.php?post_type=$this->name" ) ) {
if ( str_contains( $query, "index.php?post_type=$this->name" ) ) {
unset( $wp_rewrite->extra_rules_top[ $regex ] );
}
}

View File

@ -1015,7 +1015,7 @@ class WP_Query {
$this->is_admin = true;
}
if ( false !== strpos( $qv['feed'], 'comments-' ) ) {
if ( str_contains( $qv['feed'], 'comments-' ) ) {
$qv['feed'] = str_replace( 'comments-', '', $qv['feed'] );
$qv['withcomments'] = 1;
}
@ -1185,7 +1185,7 @@ class WP_Query {
$term = implode( ',', $term );
}
if ( strpos( $term, '+' ) !== false ) {
if ( str_contains( $term, '+' ) ) {
$terms = preg_split( '/[+]+/', $term );
foreach ( $terms as $term ) {
$tax_query[] = array_merge(
@ -1298,7 +1298,7 @@ class WP_Query {
// Tag stuff.
if ( '' !== $q['tag'] && ! $this->is_singular && $this->query_vars_changed ) {
if ( strpos( $q['tag'], ',' ) !== false ) {
if ( str_contains( $q['tag'], ',' ) ) {
$tags = preg_split( '/[,\r\n\t ]+/', $q['tag'] );
foreach ( (array) $tags as $tag ) {
$tag = sanitize_term_field( 'slug', $tag, 0, 'post_tag', 'db' );
@ -2354,7 +2354,7 @@ class WP_Query {
// Author stuff for nice URLs.
if ( '' !== $q['author_name'] ) {
if ( strpos( $q['author_name'], '/' ) !== false ) {
if ( str_contains( $q['author_name'], '/' ) ) {
$q['author_name'] = explode( '/', $q['author_name'] );
if ( $q['author_name'][ count( $q['author_name'] ) - 1 ] ) {
$q['author_name'] = $q['author_name'][ count( $q['author_name'] ) - 1 ]; // No trailing slash.
@ -4754,7 +4754,7 @@ class WP_Query {
}
$content = $post->post_content;
if ( false !== strpos( $content, '<!--nextpage-->' ) ) {
if ( str_contains( $content, '<!--nextpage-->' ) ) {
$content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content );
$content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content );
$content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content );

View File

@ -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;

View File

@ -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 ) . '%';

View File

@ -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' );

View File

@ -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 ) );
}
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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"',
'',

View File

@ -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;

View File

@ -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;
}

View File

@ -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 = '<br />', $between = '
$output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
if ( $row->link_image != null && $show_images ) {
if ( strpos($row->link_image, 'http') !== false )
if ( str_contains( $row->link_image, 'http' ) )
$output .= "<img src=\"$row->link_image\" $alt $title />";
else // If it's a relative path.
$output .= "<img src=\"" . get_option('siteurl') . "$row->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 );
}

View File

@ -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 = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>";
@ -605,7 +605,7 @@ function prep_atom_text_construct( $data ) {
}
}
if ( strpos( $data, ']]>' ) === false ) {
if ( ! str_contains( $data, ']]>' ) ) {
return array( 'html', "<![CDATA[$data]]>" );
} else {
return array( 'html', htmlspecialchars( $data ) );

View File

@ -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, '<pre' ) !== false ) {
if ( str_contains( $text, '<pre' ) ) {
$text_parts = explode( '</pre>', $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" => ' <!-- wpnl --> ' ) );
// Collapse line breaks before and after <option> elements so they don't get autop'd.
if ( strpos( $text, '<option' ) !== false ) {
if ( str_contains( $text, '<option' ) ) {
$text = preg_replace( '|\s*<option|', '<option', $text );
$text = preg_replace( '|</option>\s*|', '</option>', $text );
}
@ -507,7 +507,7 @@ function wpautop( $text, $br = true ) {
* Collapse line breaks inside <object> elements, before <param> and <embed> elements
* so they don't get autop'd.
*/
if ( strpos( $text, '</object>' ) !== false ) {
if ( str_contains( $text, '</object>' ) ) {
$text = preg_replace( '|(<object[^>]*>)\s*|', '$1', $text );
$text = preg_replace( '|\s*</object>|', '</object>', $text );
$text = preg_replace( '%\s*(</?(?:param|embed)[^>]*>)\s*%', '$1', $text );
@ -517,14 +517,14 @@ function wpautop( $text, $br = true ) {
* Collapse line breaks inside <audio> and <video> elements,
* before and after <source> and <track> elements.
*/
if ( strpos( $text, '<source' ) !== false || strpos( $text, '<track' ) !== false ) {
if ( str_contains( $text, '<source' ) || str_contains( $text, '<track' ) ) {
$text = preg_replace( '%([<\[](?:audio|video)[^>\]]*[>\]])\s*%', '$1', $text );
$text = preg_replace( '%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $text );
$text = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $text );
}
// Collapse line breaks before and after <figcaption> elements.
if ( strpos( $text, '<figcaption' ) !== false ) {
if ( str_contains( $text, '<figcaption' ) ) {
$text = preg_replace( '|\s*(<figcaption[^>]*>)|', '$1', $text );
$text = preg_replace( '|</figcaption>\s*|', '</figcaption>', $text );
}
@ -593,7 +593,7 @@ function wpautop( $text, $br = true ) {
}
// Restore newlines in all elements.
if ( false !== strpos( $text, '<!-- wpnl -->' ) ) {
if ( str_contains( $text, '<!-- wpnl -->' ) ) {
$text = str_replace( array( ' <!-- wpnl --> ', '<!-- wpnl -->' ), "\n", $text );
}
@ -763,7 +763,7 @@ function wp_replace_in_html_tags( $haystack, $replace_pairs ) {
// Loop through delimiters (elements) only.
for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) {
if ( false !== strpos( $textarr[ $i ], $needle ) ) {
if ( str_contains( $textarr[ $i ], $needle ) ) {
$textarr[ $i ] = str_replace( $needle, $replace, $textarr[ $i ] );
$changed = true;
}
@ -775,7 +775,7 @@ function wp_replace_in_html_tags( $haystack, $replace_pairs ) {
// Loop through delimiters (elements) only.
for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) {
foreach ( $needles as $needle ) {
if ( false !== strpos( $textarr[ $i ], $needle ) ) {
if ( str_contains( $textarr[ $i ], $needle ) ) {
$textarr[ $i ] = strtr( $textarr[ $i ], $replace_pairs );
$changed = true;
// After one strtr() break out of the foreach loop and look at next element.
@ -2055,7 +2055,7 @@ function sanitize_file_name( $filename ) {
$filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
$filename = trim( $filename, '.-_' );
if ( false === strpos( $filename, '.' ) ) {
if ( ! str_contains( $filename, '.' ) ) {
$mime_types = wp_get_mime_types();
$filetype = wp_check_filetype( 'test.' . $filename, $mime_types );
if ( $filetype['ext'] === $filename ) {
@ -4475,7 +4475,7 @@ function esc_url( $url, $protocols = null, $_context = 'display' ) {
$url = str_replace( "'", '&#039;', $url );
}
if ( ( false !== strpos( $url, '[' ) ) || ( false !== strpos( $url, ']' ) ) ) {
if ( ( str_contains( $url, '[' ) ) || ( str_contains( $url, ']' ) ) ) {
$parsed = wp_parse_url( $url );
$front = '';
@ -5143,7 +5143,7 @@ function wp_pre_kses_less_than( $content ) {
* @return string The text returned after esc_html if needed.
*/
function wp_pre_kses_less_than_callback( $matches ) {
if ( false === strpos( $matches[0], '>' ) ) {
if ( ! str_contains( $matches[0], '>' ) ) {
return esc_html( $matches[0] );
}
return $matches[0];
@ -5932,7 +5932,7 @@ function wp_encode_emoji( $content ) {
foreach ( $emoji as $emojum ) {
$emoji_char = html_entity_decode( $emojum );
if ( false !== strpos( $content, $emoji_char ) ) {
if ( str_contains( $content, $emoji_char ) ) {
$content = preg_replace( "/$emoji_char/", $emojum, $content );
}
}
@ -5949,7 +5949,7 @@ function wp_encode_emoji( $content ) {
* @return string The encoded content.
*/
function wp_staticize_emoji( $text ) {
if ( false === strpos( $text, '&#x' ) ) {
if ( ! str_contains( $text, '&#x' ) ) {
if ( ( function_exists( 'mb_check_encoding' ) && mb_check_encoding( $text, 'ASCII' ) ) || ! preg_match( '/[^\x00-\x7F]/', $text ) ) {
// The text doesn't contain anything that might be emoji, so we can return early.
return $text;
@ -5968,7 +5968,7 @@ function wp_staticize_emoji( $text ) {
// Quickly narrow down the list of emoji that might be in the text and need replacing.
$possible_emoji = array();
foreach ( $emoji as $emojum ) {
if ( false !== strpos( $text, $emojum ) ) {
if ( str_contains( $text, $emojum ) ) {
$possible_emoji[ $emojum ] = html_entity_decode( $emojum );
}
}
@ -6006,9 +6006,9 @@ function wp_staticize_emoji( $text ) {
}
// If it's not a tag and not in ignore block.
if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] && false !== strpos( $content, '&#x' ) ) {
if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] && str_contains( $content, '&#x' ) ) {
foreach ( $possible_emoji as $emojum => $emoji_char ) {
if ( false === strpos( $content, $emojum ) ) {
if ( ! str_contains( $content, $emojum ) ) {
continue;
}

View File

@ -708,7 +708,7 @@ function is_serialized( $data, $strict = true ) {
if ( '"' !== substr( $data, -2, 1 ) ) {
return false;
}
} elseif ( false === strpos( $data, '"' ) ) {
} elseif ( ! str_contains( $data, '"' ) ) {
return false;
}
// Or else fall through.
@ -1158,10 +1158,10 @@ function add_query_arg( ...$args ) {
$protocol = '';
}
if ( strpos( $uri, '?' ) !== false ) {
if ( str_contains( $uri, '?' ) ) {
list( $base, $query ) = explode( '?', $uri, 2 );
$base .= '?';
} elseif ( $protocol || strpos( $uri, '=' ) === false ) {
} elseif ( $protocol || ! str_contains( $uri, '=' ) ) {
$base = $uri . '?';
$query = '';
} else {
@ -2054,7 +2054,7 @@ function wp_mkdir_p( $target ) {
}
// Do not allow path traversals.
if ( false !== strpos( $target, '../' ) || false !== strpos( $target, '..' . DIRECTORY_SEPARATOR ) ) {
if ( str_contains( $target, '../' ) || str_contains( $target, '..' . DIRECTORY_SEPARATOR ) ) {
return false;
}
@ -2641,7 +2641,7 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
$count = 10000;
// The (resized) image files would have name and extension, and will be in the uploads dir.
if ( $name && $ext && @is_dir( $dir ) && false !== strpos( $dir, $upload_dir['basedir'] ) ) {
if ( $name && $ext && @is_dir( $dir ) && str_contains( $dir, $upload_dir['basedir'] ) ) {
/**
* Filters the file list used for calculating a unique filename for a newly added file.
*
@ -4656,7 +4656,7 @@ function _mce_set_direction( $mce_init ) {
$mce_init['directionality'] = 'rtl';
$mce_init['rtl_ui'] = true;
if ( ! empty( $mce_init['plugins'] ) && strpos( $mce_init['plugins'], 'directionality' ) === false ) {
if ( ! empty( $mce_init['plugins'] ) && ! str_contains( $mce_init['plugins'], 'directionality' ) ) {
$mce_init['plugins'] .= ',directionality';
}
@ -5968,13 +5968,13 @@ function apache_mod_loaded( $mod, $default_value = false ) {
if ( empty( $loaded_mods )
&& function_exists( 'phpinfo' )
&& false === strpos( ini_get( 'disable_functions' ), 'phpinfo' )
&& ! str_contains( ini_get( 'disable_functions' ), 'phpinfo' )
) {
ob_start();
phpinfo( INFO_MODULES );
$phpinfo = ob_get_clean();
if ( false !== strpos( $phpinfo, $mod ) ) {
if ( str_contains( $phpinfo, $mod ) ) {
return true;
}
}
@ -6049,7 +6049,7 @@ function validate_file( $file, $allowed_files = array() ) {
}
// `../` which does not occur at the end of the path is not allowed:
if ( false !== strpos( $file, '../' ) && '../' !== mb_substr( $file, -3, 3 ) ) {
if ( str_contains( $file, '../' ) && '../' !== mb_substr( $file, -3, 3 ) ) {
return 1;
}
@ -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 || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) {
if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || 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.
@ -6113,12 +6113,12 @@ function wp_guess_url() {
$path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] );
} else {
if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) {
if ( str_contains( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) {
// Request is hitting a file inside ABSPATH.
$directory = str_replace( ABSPATH, '', $script_filename_dir );
// Strip off the subdirectory, and any file/query params.
$path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '', $_SERVER['REQUEST_URI'] );
} elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) {
} elseif ( str_contains( $abspath_fix, $script_filename_dir ) ) {
// Request is hitting a file above ABSPATH.
$subdirectory = substr( $abspath_fix, strpos( $abspath_fix, $script_filename_dir ) + strlen( $script_filename_dir ) );
// Strip off any file/query params from the path, appending the subdirectory to the installation.
@ -7104,9 +7104,9 @@ function _device_can_upload() {
$ua = $_SERVER['HTTP_USER_AGENT'];
if ( strpos( $ua, 'iPhone' ) !== false
|| strpos( $ua, 'iPad' ) !== false
|| strpos( $ua, 'iPod' ) !== false ) {
if ( str_contains( $ua, 'iPhone' )
|| str_contains( $ua, 'iPad' )
|| str_contains( $ua, 'iPod' ) ) {
return preg_match( '#OS ([\d_]+) like Mac OS X#', $ua, $version ) && version_compare( $version[1], '6', '>=' );
}
@ -8510,8 +8510,8 @@ function clean_dirsize_cache( $path ) {
}
if (
strpos( $path, '/' ) === false &&
strpos( $path, '\\' ) === false
! str_contains( $path, '/' ) &&
! str_contains( $path, '\\' )
) {
unset( $directory_cache[ $path ] );
set_transient( 'dirsize_cache', $directory_cache );

View File

@ -4021,7 +4021,7 @@ function wp_get_code_editor_settings( $args ) {
if ( 'application/x-patch' === $type || 'text/x-patch' === $type ) {
$type = 'text/x-diff';
}
} elseif ( isset( $args['file'] ) && false !== strpos( basename( $args['file'] ), '.' ) ) {
} elseif ( isset( $args['file'] ) && str_contains( basename( $args['file'] ), '.' ) ) {
$extension = strtolower( pathinfo( $args['file'], PATHINFO_EXTENSION ) );
foreach ( wp_get_mime_types() as $exts => $mime ) {
if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
@ -4157,7 +4157,7 @@ function wp_get_code_editor_settings( $args ) {
'matchBrackets' => true,
)
);
} elseif ( false !== strpos( $type, 'json' ) ) {
} elseif ( str_contains( $type, 'json' ) ) {
$settings['codemirror'] = array_merge(
$settings['codemirror'],
array(
@ -4174,7 +4174,7 @@ function wp_get_code_editor_settings( $args ) {
} else {
$settings['codemirror']['mode']['json'] = true;
}
} elseif ( false !== strpos( $type, 'jsx' ) ) {
} elseif ( str_contains( $type, 'jsx' ) ) {
$settings['codemirror'] = array_merge(
$settings['codemirror'],
array(
@ -4220,7 +4220,7 @@ function wp_get_code_editor_settings( $args ) {
'matchBrackets' => true,
)
);
} elseif ( false !== strpos( $type, 'xml' ) ) {
} elseif ( str_contains( $type, 'xml' ) ) {
$settings['codemirror'] = array_merge(
$settings['codemirror'],
array(

View File

@ -371,7 +371,7 @@ function wp_add_global_styles_for_blocks() {
array_filter(
$metadata['path'],
function ( $item ) {
if ( strpos( $item, 'core/' ) !== false ) {
if ( str_contains( $item, 'core/' ) ) {
return true;
}
return false;

View File

@ -205,14 +205,14 @@ function wp_is_local_html_output( $html ) {
// 1. Check if HTML includes the site's Really Simple Discovery link.
if ( has_action( 'wp_head', 'rsd_link' ) ) {
$pattern = preg_replace( '#^https?:(?=//)#', '', esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ) ); // See rsd_link().
return false !== strpos( $html, $pattern );
return str_contains( $html, $pattern );
}
// 2. Check if HTML includes the site's REST API link.
if ( has_action( 'wp_head', 'rest_output_link_wp_head' ) ) {
// Try both HTTPS and HTTP since the URL depends on context.
$pattern = preg_replace( '#^https?:(?=//)#', '', esc_url( get_rest_url() ) ); // See rest_output_link_wp_head().
return false !== strpos( $html, $pattern );
return str_contains( $html, $pattern );
}
// Otherwise the result cannot be determined.

View File

@ -2499,7 +2499,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) {
$gradient_attr = false;
$is_custom_var = false;
if ( strpos( $css_item, ':' ) === false ) {
if ( ! str_contains( $css_item, ':' ) ) {
$found = true;
} else {
$parts = explode( ':', $css_item, 2 );

View File

@ -496,7 +496,7 @@ function get_attachment_link( $post = null, $leavename = false ) {
$parentlink = get_permalink( $post->post_parent );
}
if ( is_numeric( $post->post_name ) || false !== strpos( get_option( 'permalink_structure' ), '%category%' ) ) {
if ( is_numeric( $post->post_name ) || str_contains( get_option( 'permalink_structure' ), '%category%' ) ) {
$name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker.
} else {
$name = $post->post_name;
@ -692,7 +692,7 @@ function get_feed_link( $feed = '' ) {
$permalink = $wp_rewrite->get_feed_permastruct();
if ( $permalink ) {
if ( false !== strpos( $feed, 'comments_' ) ) {
if ( str_contains( $feed, 'comments_' ) ) {
$feed = str_replace( 'comments_', '', $feed );
$permalink = $wp_rewrite->get_comment_feed_permastruct();
}
@ -709,7 +709,7 @@ function get_feed_link( $feed = '' ) {
$feed = get_default_feed();
}
if ( false !== strpos( $feed, 'comments_' ) ) {
if ( str_contains( $feed, 'comments_' ) ) {
$feed = str_replace( 'comments_', 'comments-', $feed );
}
@ -1820,7 +1820,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) {
// Back-compat, $excluded_terms used to be $excluded_categories with IDs separated by " and ".
if ( false !== strpos( $excluded_terms, ' and ' ) ) {
if ( str_contains( $excluded_terms, ' and ' ) ) {
_deprecated_argument(
__FUNCTION__,
'3.3.0',

View File

@ -1168,7 +1168,7 @@ function _wp_get_attachment_relative_path( $file ) {
return '';
}
if ( false !== strpos( $dirname, 'wp-content/uploads' ) ) {
if ( str_contains( $dirname, 'wp-content/uploads' ) ) {
// Get the directory name relative to the upload directory (back compat for pre-2.7 uploads).
$dirname = substr( $dirname, strpos( $dirname, 'wp-content/uploads' ) + 18 );
$dirname = ltrim( $dirname, '/' );
@ -1373,7 +1373,7 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac
}
// If the file name is part of the `src`, we've confirmed a match.
if ( ! $src_matched && false !== strpos( $image_src, $dirname . $image['file'] ) ) {
if ( ! $src_matched && str_contains( $image_src, $dirname . $image['file'] ) ) {
$src_matched = true;
$is_src = true;
}
@ -1625,7 +1625,7 @@ function wp_image_src_get_dimensions( $image_src, $image_meta, $attachment_id =
// Is it a full size image?
if (
isset( $image_meta['file'] ) &&
strpos( $image_src, wp_basename( $image_meta['file'] ) ) !== false
str_contains( $image_src, wp_basename( $image_meta['file'] ) )
) {
$dimensions = array(
(int) $image_meta['width'],
@ -1693,7 +1693,7 @@ function wp_image_add_srcset_and_sizes( $image, $image_meta, $attachment_id ) {
// Bail early if an image has been inserted and later edited.
if ( preg_match( '/-e[0-9]{13}/', $image_meta['file'], $img_edit_hash ) &&
strpos( wp_basename( $image_src ), $img_edit_hash[0] ) === false ) {
! str_contains( wp_basename( $image_src ), $img_edit_hash[0] ) ) {
return $image;
}
@ -1848,17 +1848,17 @@ function wp_filter_content_tags( $content, $context = null ) {
$attachment_id = $images[ $match[0] ];
// Add 'width' and 'height' attributes if applicable.
if ( $attachment_id > 0 && false === strpos( $filtered_image, ' width=' ) && false === strpos( $filtered_image, ' height=' ) ) {
if ( $attachment_id > 0 && ! str_contains( $filtered_image, ' width=' ) && ! str_contains( $filtered_image, ' height=' ) ) {
$filtered_image = wp_img_tag_add_width_and_height_attr( $filtered_image, $context, $attachment_id );
}
// Add 'srcset' and 'sizes' attributes if applicable.
if ( $attachment_id > 0 && false === strpos( $filtered_image, ' srcset=' ) ) {
if ( $attachment_id > 0 && ! str_contains( $filtered_image, ' srcset=' ) ) {
$filtered_image = wp_img_tag_add_srcset_and_sizes_attr( $filtered_image, $context, $attachment_id );
}
// Add 'loading' attribute if applicable.
if ( $add_img_loading_attr && false === strpos( $filtered_image, ' loading=' ) ) {
if ( $add_img_loading_attr && ! str_contains( $filtered_image, ' loading=' ) ) {
$filtered_image = wp_img_tag_add_loading_attr( $filtered_image, $context );
}
@ -1894,7 +1894,7 @@ function wp_filter_content_tags( $content, $context = null ) {
$filtered_iframe = $match[0];
// Add 'loading' attribute if applicable.
if ( $add_iframe_loading_attr && false === strpos( $filtered_iframe, ' loading=' ) ) {
if ( $add_iframe_loading_attr && ! str_contains( $filtered_iframe, ' loading=' ) ) {
$filtered_iframe = wp_iframe_tag_add_loading_attr( $filtered_iframe, $context );
}
@ -1928,7 +1928,7 @@ function wp_img_tag_add_loading_attr( $image, $context ) {
$value = wp_get_loading_attr_default( $context );
// Images should have source and dimension attributes for the `loading` attribute to be added.
if ( false === strpos( $image, ' src="' ) || false === strpos( $image, ' width="' ) || false === strpos( $image, ' height="' ) ) {
if ( ! str_contains( $image, ' src="' ) || ! str_contains( $image, ' width="' ) || ! str_contains( $image, ' height="' ) ) {
return $image;
}
@ -1979,7 +1979,7 @@ function wp_img_tag_add_loading_attr( $image, $context ) {
function wp_img_tag_add_decoding_attr( $image, $context ) {
// Only apply the decoding attribute to images that have a src attribute that
// starts with a double quote, ensuring escaped JSON is also excluded.
if ( false === strpos( $image, ' src="' ) ) {
if ( ! str_contains( $image, ' src="' ) ) {
return $image;
}
@ -2097,7 +2097,7 @@ function wp_img_tag_add_srcset_and_sizes_attr( $image, $context, $attachment_id
function wp_iframe_tag_add_loading_attr( $iframe, $context ) {
// Iframes with fallback content (see `wp_filter_oembed_result()`) should not be lazy-loaded because they are
// visually hidden initially.
if ( false !== strpos( $iframe, ' data-secret="' ) ) {
if ( str_contains( $iframe, ' data-secret="' ) ) {
return $iframe;
}
@ -2106,7 +2106,7 @@ function wp_iframe_tag_add_loading_attr( $iframe, $context ) {
$value = wp_get_loading_attr_default( $context );
// Iframes should have source and dimension attributes for the `loading` attribute to be added.
if ( false === strpos( $iframe, ' src="' ) || false === strpos( $iframe, ' width="' ) || false === strpos( $iframe, ' height="' ) ) {
if ( ! str_contains( $iframe, ' src="' ) || ! str_contains( $iframe, ' width="' ) || ! str_contains( $iframe, ' height="' ) ) {
return $iframe;
}
@ -2259,7 +2259,7 @@ function img_caption_shortcode( $attr, $content = '' ) {
$content = $matches[1];
$attr['caption'] = trim( $matches[2] );
}
} elseif ( strpos( $attr['caption'], '<' ) !== false ) {
} elseif ( str_contains( $attr['caption'], '<' ) ) {
$attr['caption'] = wp_kses( $attr['caption'], 'post' );
}
@ -3524,7 +3524,7 @@ function wp_video_shortcode( $attr, $content = '' ) {
}
if ( ! empty( $content ) ) {
if ( false !== strpos( $content, "\n" ) ) {
if ( str_contains( $content, "\n" ) ) {
$content = str_replace( array( "\r\n", "\n", "\t" ), '', $content );
}
$html .= trim( $content );
@ -3729,14 +3729,14 @@ function get_attachment_taxonomies( $attachment, $output = 'names' ) {
$objects = array( 'attachment' );
if ( false !== strpos( $filename, '.' ) ) {
if ( str_contains( $filename, '.' ) ) {
$objects[] = 'attachment:' . substr( $filename, strrpos( $filename, '.' ) + 1 );
}
if ( ! empty( $attachment->post_mime_type ) ) {
$objects[] = 'attachment:' . $attachment->post_mime_type;
if ( false !== strpos( $attachment->post_mime_type, '/' ) ) {
if ( str_contains( $attachment->post_mime_type, '/' ) ) {
foreach ( explode( '/', $attachment->post_mime_type ) as $token ) {
if ( ! empty( $token ) ) {
$objects[] = "attachment:$token";
@ -4030,7 +4030,7 @@ function wp_plupload_default_settings() {
$wp_scripts = wp_scripts();
$data = $wp_scripts->get_data( 'wp-plupload', 'data' );
if ( $data && false !== strpos( $data, '_wpPluploadSettings' ) ) {
if ( $data && str_contains( $data, '_wpPluploadSettings' ) ) {
return;
}
@ -4175,7 +4175,7 @@ function wp_prepare_attachment_for_js( $attachment ) {
}
$meta = wp_get_attachment_metadata( $attachment->ID );
if ( false !== strpos( $attachment->post_mime_type, '/' ) ) {
if ( str_contains( $attachment->post_mime_type, '/' ) ) {
list( $type, $subtype ) = explode( '/', $attachment->post_mime_type );
} else {
list( $type, $subtype ) = array( $attachment->post_mime_type, '' );

View File

@ -317,8 +317,8 @@ function wpmu_admin_do_redirect( $url = '' ) {
function wpmu_admin_redirect_add_updated_param( $url = '' ) {
_deprecated_function( __FUNCTION__, '3.3.0', 'add_query_arg()' );
if ( strpos( $url, 'updated=true' ) === false ) {
if ( strpos( $url, '?' ) === false )
if ( ! str_contains( $url, 'updated=true' ) ) {
if ( ! str_contains( $url, '?' ) )
return $url . '?updated=true';
else
return $url . '&updated=true';

View File

@ -41,7 +41,7 @@ if ( $mime['type'] ) {
}
header( 'Content-Type: ' . $mimetype ); // Always send this.
if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) {
if ( ! str_contains( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) {
header( 'Content-Length: ' . filesize( $file ) );
}

View File

@ -1992,7 +1992,7 @@ function check_upload_mimes( $mimes ) {
$site_mimes = array();
foreach ( $site_exts as $ext ) {
foreach ( $mimes as $ext_pattern => $mime ) {
if ( '' !== $ext && false !== strpos( $ext_pattern, $ext ) ) {
if ( '' !== $ext && str_contains( $ext_pattern, $ext ) ) {
$site_mimes[ $ext_pattern ] = $mime;
}
}
@ -2165,7 +2165,7 @@ function maybe_redirect_404() {
* @since MU (3.0.0)
*/
function maybe_add_existing_user_to_blog() {
if ( false === strpos( $_SERVER['REQUEST_URI'], '/newbloguser/' ) ) {
if ( ! str_contains( $_SERVER['REQUEST_URI'], '/newbloguser/' ) ) {
return;
}

View File

@ -279,7 +279,7 @@ if ( ! function_exists( 'wp_mail' ) ) :
if ( ! empty( $tempheaders ) ) {
// Iterate through the raw headers.
foreach ( (array) $tempheaders as $header ) {
if ( strpos( $header, ':' ) === false ) {
if ( ! str_contains( $header, ':' ) ) {
if ( false !== stripos( $header, 'boundary=' ) ) {
$parts = preg_split( '/boundary=/i', trim( $header ) );
$boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
@ -315,7 +315,7 @@ if ( ! function_exists( 'wp_mail' ) ) :
}
break;
case 'content-type':
if ( strpos( $content, ';' ) !== false ) {
if ( str_contains( $content, ';' ) ) {
list( $type, $charset_content ) = explode( ';', $content );
$content_type = trim( $type );
if ( false !== stripos( $charset_content, 'charset=' ) ) {
@ -1186,7 +1186,7 @@ if ( ! function_exists( 'auth_redirect' ) ) :
$secure = apply_filters( 'secure_auth_redirect', $secure );
// If https is required and request is http, redirect.
if ( $secure && ! is_ssl() && false !== strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) ) {
if ( $secure && ! is_ssl() && str_contains( $_SERVER['REQUEST_URI'], 'wp-admin' ) ) {
if ( str_starts_with( $_SERVER['REQUEST_URI'], 'http' ) ) {
wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
exit;
@ -1217,7 +1217,7 @@ if ( ! function_exists( 'auth_redirect' ) ) :
do_action( 'auth_redirect', $user_id );
// If the user wants ssl but the session is not ssl, redirect.
if ( ! $secure && get_user_option( 'use_ssl', $user_id ) && false !== strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) ) {
if ( ! $secure && get_user_option( 'use_ssl', $user_id ) && str_contains( $_SERVER['REQUEST_URI'], 'wp-admin' ) ) {
if ( str_starts_with( $_SERVER['REQUEST_URI'], 'http' ) ) {
wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
exit;

View File

@ -128,7 +128,7 @@ if ( ! class_exists( 'PO', false ) ) :
$po = $quote . implode( "{$slash}n{$quote}{$newline}{$quote}", explode( $newline, $input_string ) ) . $quote;
// Add empty string on first line for readbility.
if ( false !== strpos( $input_string, $newline ) &&
if ( str_contains( $input_string, $newline ) &&
( substr_count( $input_string, $newline ) > 1 || substr( $input_string, -strlen( $newline ) ) !== $newline ) ) {
$po = "$quote$quote$newline$po";
}

View File

@ -343,7 +343,7 @@ function get_the_content( $more_link_text = null, $strip_teaser = false, $post =
$content = array( $content );
}
if ( false !== strpos( $_post->post_content, '<!--noteaser-->' ) && ( ! $elements['multipage'] || 1 == $elements['page'] ) ) {
if ( str_contains( $_post->post_content, '<!--noteaser-->' ) && ( ! $elements['multipage'] || 1 == $elements['page'] ) ) {
$strip_teaser = true;
}

View File

@ -2774,7 +2774,7 @@ function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) {
}
$prefixed = false;
if ( false !== strpos( $field, 'post_' ) ) {
if ( str_contains( $field, 'post_' ) ) {
$prefixed = true;
$field_no_prefix = str_replace( 'post_', '', $field );
}
@ -3273,7 +3273,7 @@ function wp_match_mime_types( $wildcard_mime_types, $real_mime_types ) {
$patternses[][ $type ] = "^$regex$";
if ( false === strpos( $mime, '/' ) ) {
if ( ! str_contains( $mime, '/' ) ) {
$patternses[][ $type ] = "^$regex/";
$patternses[][ $type ] = $regex;
}
@ -3330,7 +3330,7 @@ function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) {
$mime_pattern = "$mime_group/$mime_subgroup";
} else {
$mime_pattern = preg_replace( '/[^-*.a-zA-Z0-9]/', '', $mime_type );
if ( false === strpos( $mime_pattern, '*' ) ) {
if ( ! str_contains( $mime_pattern, '*' ) ) {
$mime_pattern .= '/*';
}
}
@ -3341,7 +3341,7 @@ function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) {
return '';
}
if ( false !== strpos( $mime_pattern, '%' ) ) {
if ( str_contains( $mime_pattern, '%' ) ) {
$wheres[] = empty( $table_alias ) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'";
} else {
$wheres[] = empty( $table_alias ) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'";
@ -6124,10 +6124,10 @@ function get_pages( $args = array() ) {
* @return bool True on success, false on failure.
*/
function is_local_attachment( $url ) {
if ( strpos( $url, home_url() ) === false ) {
if ( ! str_contains( $url, home_url() ) ) {
return false;
}
if ( strpos( $url, home_url( '/?attachment_id=' ) ) !== false ) {
if ( str_contains( $url, home_url( '/?attachment_id=' ) ) ) {
return true;
}
@ -6510,7 +6510,7 @@ function wp_get_attachment_url( $attachment_id = 0 ) {
if ( str_starts_with( $file, $uploads['basedir'] ) ) {
// Replace file location with url location.
$url = str_replace( $uploads['basedir'], $uploads['baseurl'], $file );
} elseif ( false !== strpos( $file, 'wp-content/uploads' ) ) {
} elseif ( str_contains( $file, 'wp-content/uploads' ) ) {
// Get the directory name relative to the basedir (back compat for pre-2.7 uploads).
$url = trailingslashit( $uploads['baseurl'] . '/' . _wp_get_attachment_relative_path( $file ) ) . wp_basename( $file );
} else {

View File

@ -311,7 +311,7 @@ class WP_REST_Request implements ArrayAccess {
}
$value = strtolower( $value );
if ( false === strpos( $value, '/' ) ) {
if ( ! str_contains( $value, '/' ) ) {
return null;
}

View File

@ -304,7 +304,7 @@ class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller {
$revisions = wp_get_post_revisions( $parent_id, array( 'check_enabled' => false ) );
foreach ( $revisions as $revision ) {
if ( false !== strpos( $revision->post_name, "{$parent_id}-autosave" ) ) {
if ( str_contains( $revision->post_name, "{$parent_id}-autosave" ) ) {
$data = $this->prepare_item_for_response( $revision, $request );
$response[] = $this->prepare_response_for_collection( $data );
}

View File

@ -298,7 +298,7 @@ class WP_REST_Plugins_Controller extends WP_REST_Controller {
);
if ( is_wp_error( $api ) ) {
if ( false !== strpos( $api->get_error_message(), 'Plugin not found.' ) ) {
if ( str_contains( $api->get_error_message(), 'Plugin not found.' ) ) {
$api->add_data( array( 'status' => 404 ) );
} else {
$api->add_data( array( 'status' => 500 ) );
@ -809,7 +809,7 @@ class WP_REST_Plugins_Controller extends WP_REST_Controller {
$matched_search = false;
foreach ( $item as $field ) {
if ( is_string( $field ) && false !== strpos( strip_tags( $field ), $search ) ) {
if ( is_string( $field ) && str_contains( strip_tags( $field ), $search ) ) {
$matched_search = true;
break;
}

View File

@ -1305,7 +1305,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
);
}
if ( false !== strpos( $password, '\\' ) ) {
if ( str_contains( $password, '\\' ) ) {
return new WP_Error(
'rest_user_invalid_password',
sprintf(

View File

@ -138,7 +138,7 @@ function wp_save_post_revision( $post_id ) {
if ( $revisions ) {
// Grab the latest revision, but not an autosave.
foreach ( $revisions as $revision ) {
if ( false !== strpos( $revision->post_name, "{$revision->post_parent}-revision" ) ) {
if ( str_contains( $revision->post_name, "{$revision->post_parent}-revision" ) ) {
$latest_revision = $revision;
break;
}
@ -223,7 +223,7 @@ function wp_save_post_revision( $post_id ) {
$revisions = array_slice( $revisions, 0, $delete );
for ( $i = 0; isset( $revisions[ $i ] ); $i++ ) {
if ( false !== strpos( $revisions[ $i ]->post_name, 'autosave' ) ) {
if ( str_contains( $revisions[ $i ]->post_name, 'autosave' ) ) {
continue;
}
@ -313,7 +313,7 @@ function wp_is_post_autosave( $post ) {
return false;
}
if ( false !== strpos( $post->post_name, "{$post->post_parent}-autosave" ) ) {
if ( str_contains( $post->post_name, "{$post->post_parent}-autosave" ) ) {
return (int) $post->post_parent;
}

View File

@ -542,12 +542,12 @@ function url_to_postid( $url ) {
$url = set_url_scheme( $url, $scheme );
// Add 'www.' if it is absent and should be there.
if ( false !== strpos( home_url(), '://www.' ) && false === strpos( $url, '://www.' ) ) {
if ( str_contains( home_url(), '://www.' ) && ! str_contains( $url, '://www.' ) ) {
$url = str_replace( '://', '://www.', $url );
}
// Strip 'www.' if it is present and shouldn't be.
if ( false === strpos( home_url(), '://www.' ) ) {
if ( ! str_contains( home_url(), '://www.' ) ) {
$url = str_replace( '://www.', '://', $url );
}
@ -572,7 +572,7 @@ function url_to_postid( $url ) {
$url = str_replace( $wp_rewrite->index . '/', '', $url );
}
if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) {
if ( str_contains( trailingslashit( $url ), home_url( '/' ) ) ) {
// Chop off http://domain.com/[path].
$url = str_replace( home_url(), '', $url );
} else {

View File

@ -651,7 +651,7 @@ function wp_scripts_get_suffix( $type = '' ) {
// Include an unmodified $wp_version.
require ABSPATH . WPINC . '/version.php';
$develop_src = false !== strpos( $wp_version, '-src' );
$develop_src = str_contains( $wp_version, '-src' );
if ( ! defined( 'SCRIPT_DEBUG' ) ) {
define( 'SCRIPT_DEBUG', $develop_src );
@ -1480,7 +1480,7 @@ function wp_default_styles( $styles ) {
require ABSPATH . WPINC . '/version.php';
if ( ! defined( 'SCRIPT_DEBUG' ) ) {
define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) );
define( 'SCRIPT_DEBUG', str_contains( $wp_version, '-src' ) );
}
$guessurl = site_url();

View File

@ -147,7 +147,7 @@ function shortcode_exists( $tag ) {
* @return bool Whether the passed content contains the given shortcode.
*/
function has_shortcode( $content, $tag ) {
if ( false === strpos( $content, '[' ) ) {
if ( ! str_contains( $content, '[' ) ) {
return false;
}
@ -205,7 +205,7 @@ function apply_shortcodes( $content, $ignore_html = false ) {
function do_shortcode( $content, $ignore_html = false ) {
global $shortcode_tags;
if ( false === strpos( $content, '[' ) ) {
if ( ! str_contains( $content, '[' ) ) {
return $content;
}
@ -412,8 +412,8 @@ function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) {
continue;
}
$noopen = false === strpos( $element, '[' );
$noclose = false === strpos( $element, ']' );
$noopen = ! str_contains( $element, '[' );
$noclose = ! str_contains( $element, ']' );
if ( $noopen || $noclose ) {
// This element does not contain shortcodes.
if ( $noopen xor $noclose ) {
@ -559,7 +559,7 @@ function shortcode_parse_atts( $text ) {
// Reject any unclosed HTML elements.
foreach ( $atts as &$value ) {
if ( false !== strpos( $value, '<' ) ) {
if ( str_contains( $value, '<' ) ) {
if ( 1 !== preg_match( '/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value ) ) {
$value = '';
}
@ -634,7 +634,7 @@ function shortcode_atts( $pairs, $atts, $shortcode = '' ) {
function strip_shortcodes( $content ) {
global $shortcode_tags;
if ( false === strpos( $content, '[' ) ) {
if ( ! str_contains( $content, '[' ) ) {
return $content;
}

View File

@ -662,7 +662,7 @@ function get_attachment_template() {
$templates = array();
if ( $attachment ) {
if ( false !== strpos( $attachment->post_mime_type, '/' ) ) {
if ( str_contains( $attachment->post_mime_type, '/' ) ) {
list( $type, $subtype ) = explode( '/', $attachment->post_mime_type );
} else {
list( $type, $subtype ) = array( $attachment->post_mime_type, '' );

View File

@ -1765,7 +1765,7 @@ function sanitize_user_field( $field, $value, $user_id, $context ) {
return $value;
}
$prefixed = false !== strpos( $field, 'user_' );
$prefixed = str_contains( $field, 'user_' );
if ( 'edit' === $context ) {
if ( $prefixed ) {
@ -2989,7 +2989,7 @@ function check_password_reset_key( $key, $login ) {
*/
$expiration_duration = apply_filters( 'password_reset_expiration', DAY_IN_SECONDS );
if ( false !== strpos( $user->user_activation_key, ':' ) ) {
if ( str_contains( $user->user_activation_key, ':' ) ) {
list( $pass_request_time, $pass_key ) = explode( ':', $user->user_activation_key, 2 );
$expiration_time = $pass_request_time + $expiration_duration;
} else {

View File

@ -65,9 +65,9 @@ $is_iphone = false;
$is_edge = false;
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Lynx' ) !== false ) {
if ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Lynx' ) ) {
$is_lynx = true;
} elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Edg' ) !== false ) {
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Edg' ) ) {
$is_edge = true;
} elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chrome' ) !== false ) {
if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chromeframe' ) !== false ) {
@ -89,15 +89,15 @@ if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
}
} elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'safari' ) !== false ) {
$is_safari = true;
} elseif ( ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident' ) !== false ) && strpos( $_SERVER['HTTP_USER_AGENT'], 'Win' ) !== false ) {
} elseif ( ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) || str_contains( $_SERVER['HTTP_USER_AGENT'], 'Trident' ) ) && str_contains( $_SERVER['HTTP_USER_AGENT'], 'Win' ) ) {
$is_winIE = true;
} elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false && strpos( $_SERVER['HTTP_USER_AGENT'], 'Mac' ) !== false ) {
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) && str_contains( $_SERVER['HTTP_USER_AGENT'], 'Mac' ) ) {
$is_macIE = true;
} elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Gecko' ) !== false ) {
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Gecko' ) ) {
$is_gecko = true;
} elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera' ) !== false ) {
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Opera' ) ) {
$is_opera = true;
} elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Nav' ) !== false && strpos( $_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.' ) !== false ) {
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Nav' ) && str_contains( $_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.' ) ) {
$is_NS4 = true;
}
}
@ -115,21 +115,21 @@ $is_IE = ( $is_macIE || $is_winIE );
*
* @global bool $is_apache
*/
$is_apache = ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) !== false || strpos( $_SERVER['SERVER_SOFTWARE'], 'LiteSpeed' ) !== false );
$is_apache = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) || str_contains( $_SERVER['SERVER_SOFTWARE'], 'LiteSpeed' ) );
/**
* Whether the server software is Nginx or something else
*
* @global bool $is_nginx
*/
$is_nginx = ( strpos( $_SERVER['SERVER_SOFTWARE'], 'nginx' ) !== false );
$is_nginx = ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'nginx' ) );
/**
* Whether the server software is IIS or something else
*
* @global bool $is_IIS
*/
$is_IIS = ! $is_apache && ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) !== false || strpos( $_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer' ) !== false );
$is_IIS = ! $is_apache && ( str_contains( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) || str_contains( $_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer' ) );
/**
* Whether the server software is IIS 7.X or greater
@ -148,13 +148,13 @@ $is_iis7 = $is_IIS && (int) substr( $_SERVER['SERVER_SOFTWARE'], strpos( $_SERVE
function wp_is_mobile() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
$is_mobile = false;
} elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Mobile' ) !== false // Many mobile devices (all iPhone, iPad, etc.)
|| strpos( $_SERVER['HTTP_USER_AGENT'], 'Android' ) !== false
|| strpos( $_SERVER['HTTP_USER_AGENT'], 'Silk/' ) !== false
|| strpos( $_SERVER['HTTP_USER_AGENT'], 'Kindle' ) !== false
|| strpos( $_SERVER['HTTP_USER_AGENT'], 'BlackBerry' ) !== false
|| strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mini' ) !== false
|| strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mobi' ) !== false ) {
} elseif ( str_contains( $_SERVER['HTTP_USER_AGENT'], 'Mobile' ) // Many mobile devices (all iPhone, iPad, etc.)
|| str_contains( $_SERVER['HTTP_USER_AGENT'], 'Android' )
|| str_contains( $_SERVER['HTTP_USER_AGENT'], 'Silk/' )
|| str_contains( $_SERVER['HTTP_USER_AGENT'], 'Kindle' )
|| str_contains( $_SERVER['HTTP_USER_AGENT'], 'BlackBerry' )
|| str_contains( $_SERVER['HTTP_USER_AGENT'], 'Opera Mini' )
|| str_contains( $_SERVER['HTTP_USER_AGENT'], 'Opera Mobi' ) ) {
$is_mobile = true;
} else {
$is_mobile = false;

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-alpha-55987';
$wp_version = '6.3-alpha-55988';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -101,7 +101,7 @@ class WP_Widget_Text extends WP_Widget {
}
$wpautop = ! empty( $instance['filter'] );
$has_line_breaks = ( false !== strpos( trim( $instance['text'] ), "\n" ) );
$has_line_breaks = ( str_contains( trim( $instance['text'] ), "\n" ) );
// If auto-paragraphs are not enabled and there are line breaks, then ensure legacy mode.
if ( ! $wpautop && $has_line_breaks ) {
@ -109,7 +109,7 @@ class WP_Widget_Text extends WP_Widget {
}
// If an HTML comment is present, assume legacy mode.
if ( false !== strpos( $instance['text'], '<!--' ) ) {
if ( str_contains( $instance['text'], '<!--' ) ) {
return true;
}

View File

@ -69,7 +69,7 @@ if ( file_exists( ABSPATH . 'wp-config.php' ) ) {
$path = wp_guess_url() . '/wp-admin/setup-config.php';
// Redirect to setup-config.php.
if ( false === strpos( $_SERVER['REQUEST_URI'], 'setup-config' ) ) {
if ( ! str_contains( $_SERVER['REQUEST_URI'], 'setup-config' ) ) {
header( 'Location: ' . $path );
exit;
}

View File

@ -1229,7 +1229,7 @@ switch ( $action ) {
if ( isset( $_REQUEST['redirect_to'] ) ) {
$redirect_to = $_REQUEST['redirect_to'];
// Redirect to HTTPS if user wants SSL.
if ( $secure_cookie && false !== strpos( $redirect_to, 'wp-admin' ) ) {
if ( $secure_cookie && str_contains( $redirect_to, 'wp-admin' ) ) {
$redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to );
}
} else {
@ -1366,7 +1366,7 @@ switch ( $action ) {
$errors->add( 'updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what&#8217;s new.' ), 'message' );
} elseif ( WP_Recovery_Mode_Link_Service::LOGIN_ACTION_ENTERED === $action ) {
$errors->add( 'enter_recovery_mode', __( 'Recovery Mode Initialized. Please log in to continue.' ), 'message' );
} elseif ( isset( $_GET['redirect_to'] ) && false !== strpos( $_GET['redirect_to'], 'wp-admin/authorize-application.php' ) ) {
} elseif ( isset( $_GET['redirect_to'] ) && str_contains( $_GET['redirect_to'], 'wp-admin/authorize-application.php' ) ) {
$query_component = wp_parse_url( $_GET['redirect_to'], PHP_URL_QUERY );
$query = array();
if ( $query_component ) {

View File

@ -107,7 +107,7 @@ for ( $i = 1; $i <= $count; $i++ ) {
$content_transfer_encoding = explode( ';', $content_transfer_encoding );
$content_transfer_encoding = $content_transfer_encoding[0];
}
if ( ( 'multipart/alternative' === $content_type ) && ( false !== strpos( $line, 'boundary="' ) ) && ( '' === $boundary ) ) {
if ( ( 'multipart/alternative' === $content_type ) && ( str_contains( $line, 'boundary="' ) ) && ( '' === $boundary ) ) {
$boundary = trim( $line );
$boundary = explode( '"', $boundary );
$boundary = $boundary[1];

Some files were not shown because too many files have changed in this diff Show More