modified file w3-total-cache
This commit is contained in:
@ -47,3 +47,53 @@ if ( ! function_exists( 'is_countable' ) ) {
|
||||
return is_array( $value ) || $value instanceof \Countable;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Polyfill for `array_is_list()` function added in PHP 7.3.
|
||||
*
|
||||
* @param array $array The array to check.
|
||||
*
|
||||
* @return bool True if `$array` is a list, otherwise false.
|
||||
*/
|
||||
if ( ! function_exists( 'array_is_list' ) ) {
|
||||
function array_is_list( $array ) {
|
||||
if ( ! is_array( $array ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( array_values( $array ) === $array ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$next_key = -1;
|
||||
|
||||
foreach ( $array as $k => $v ) {
|
||||
if ( ++$next_key !== $k ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* @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 ) {
|
||||
if ( '' === $needle ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false !== strpos( $haystack, $needle );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user