summaryrefslogtreecommitdiffstats
path: root/wp-includes/compat.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:57:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:57:26 +0000
commit30883c26bdceb9eaf32c8d4a1b0c1bce223b5226 (patch)
tree39a02e2aeb21ab5b7923c6f5757d66d55b708912 /wp-includes/compat.php
parentAdding upstream version 6.4.3+dfsg1. (diff)
downloadwordpress-30883c26bdceb9eaf32c8d4a1b0c1bce223b5226.tar.xz
wordpress-30883c26bdceb9eaf32c8d4a1b0c1bce223b5226.zip
Adding upstream version 6.5+dfsg1.upstream/6.5+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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 );
+}