summaryrefslogtreecommitdiffstats
path: root/wp-includes/compat.php
diff options
context:
space:
mode:
Diffstat (limited to 'wp-includes/compat.php')
-rw-r--r--wp-includes/compat.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/wp-includes/compat.php b/wp-includes/compat.php
index 5bfdbc2..95c4af4 100644
--- a/wp-includes/compat.php
+++ b/wp-includes/compat.php
@@ -420,6 +420,38 @@ if ( ! function_exists( 'array_key_last' ) ) {
}
}
+if ( ! function_exists( 'array_is_list' ) ) {
+ /**
+ * Polyfill for `array_is_list()` function added in PHP 8.1.
+ *
+ * Determines if the given array is a list.
+ *
+ * An array is considered a list if its keys consist of consecutive numbers from 0 to count($array)-1.
+ *
+ * @see https://github.com/symfony/polyfill-php81/tree/main
+ *
+ * @since 6.5.0
+ *
+ * @param array<mixed> $arr The array being evaluated.
+ * @return bool True if array is a list, false otherwise.
+ */
+ function array_is_list( $arr ) {
+ if ( ( array() === $arr ) || ( array_values( $arr ) === $arr ) ) {
+ return true;
+ }
+
+ $next_key = -1;
+
+ foreach ( $arr 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.
@@ -497,3 +529,13 @@ if ( ! defined( 'IMAGETYPE_WEBP' ) ) {
if ( ! defined( 'IMG_WEBP' ) ) {
define( 'IMG_WEBP', IMAGETYPE_WEBP );
}
+
+// IMAGETYPE_AVIF constant is only defined in PHP 8.x or later.
+if ( ! defined( 'IMAGETYPE_AVIF' ) ) {
+ define( 'IMAGETYPE_AVIF', 19 );
+}
+
+// IMG_AVIF constant is only defined in PHP 8.x or later.
+if ( ! defined( 'IMG_AVIF' ) ) {
+ define( 'IMG_AVIF', IMAGETYPE_AVIF );
+}