mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-23 16:01:37 +01:00
General: Introduce polyfill for str_contains()
added in PHP 8.0.
PHP 8.0 introduced a new function: `str_contains()`. It performs a case-sensitive check indicating if given substring (needle) is contained in the string to search in (haystack). This polyfill makes this function available for use in Core. Ref: * PHP RFC https://wiki.php.net/rfc/str_contains * PHP manual https://www.php.net/manual/en/function.str-contains.php Props ayeshrajans, costdev, desrosj, hellofromTonya, knutsp, pbearne. Fixes #49652. Built from https://develop.svn.wordpress.org/trunk@52039 git-svn-id: http://core.svn.wordpress.org/trunk@51631 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
10dc403b88
commit
87557c6260
@ -417,6 +417,24 @@ if ( ! function_exists( 'array_key_last' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'str_contains' ) ) {
|
||||
/**
|
||||
* Polyfill for `str_contains()` function added in PHP 8.0.
|
||||
*
|
||||
* Performs a case-sensitive check indicating if needle is
|
||||
* contained in haystack.
|
||||
*
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param string $haystack The string to search in.
|
||||
* @param string $needle The substring to search for in the haystack.
|
||||
* @return bool True if `$needle` is in `$haystack`, otherwise false.
|
||||
*/
|
||||
function str_contains( $haystack, $needle ) {
|
||||
return ( '' === $needle || false !== strpos( $haystack, $needle ) );
|
||||
}
|
||||
}
|
||||
|
||||
// IMAGETYPE_WEBP constant is only defined in PHP 7.1 or later.
|
||||
if ( ! defined( 'IMAGETYPE_WEBP' ) ) {
|
||||
define( 'IMAGETYPE_WEBP', 18 );
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.9-alpha-52038';
|
||||
$wp_version = '5.9-alpha-52039';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user