$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 ); } } if ( ! function_exists( 'wp_is_serving_rest_request' ) ) { /** * Polyfill for `wp_is_serving_rest_request()` function added in WordPress 6.5. * * @see https://developer.wordpress.org/reference/functions/wp_is_serving_rest_request/ * * @return bool True if it's a WordPress REST API request, false otherwise. */ function wp_is_serving_rest_request() { return defined( 'REST_REQUEST' ) && REST_REQUEST; } }