| 1 |
<?php |
| 2 |
if ( ! function_exists( 'str_contains' ) ) { |
| 3 |
/** |
| 4 |
* Polyfill for `str_contains()` function added in PHP 8.0. since WP 5.9.0 |
| 5 |
* |
| 6 |
* Performs a case-sensitive check indicating if needle is |
| 7 |
* contained in haystack. |
| 8 |
* |
| 9 |
* @param string $haystack The string to search in. |
| 10 |
* @param string $needle The substring to search for in the haystack. |
| 11 |
* @return bool True if `$needle` is in `$haystack`, otherwise false. |
| 12 |
*@since 1.0.0 |
| 13 |
* |
| 14 |
*/ |
| 15 |
function str_contains(string $haystack, string $needle ): bool |
| 16 |
{ |
| 17 |
return ( '' === $needle || false !== strpos( $haystack, $needle ) ); |
| 18 |
} |
| 19 |
} |