← All changes
|
includes/compat/charitable-compat-functions.php
+24
-2
1.7.0.11
→
1.8.13
View file →
| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | * Functions to improve compatibility. |
| 4 | 4 | * |
| 5 | 5 | * @package Charitable/Functions/Compatibility |
| 6 | 6 | * @author David Bisset |
| 7 | - * @copyright Copyright (c) 2022, WP Charitable LLC | |
| 7 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 9 | * @since 1.5.0 |
| 10 | 10 | * @version 1.6.48 |
| 11 | 11 | */ |
| @@ -13,8 +13,30 @@ | ||
| 13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | +if ( ! function_exists( 'array_is_list' ) ) { | |
| 18 | + /** | |
| 19 | + * Polyfill for array_is_list() (PHP 8.1+; WordPress core polyfills it from 6.5). | |
| 20 | + * | |
| 21 | + * Charitable's minimum supported WordPress version is 5.9, so on sites running | |
| 22 | + * WordPress 5.9–6.4 with PHP < 8.1 this function is otherwise undefined. The | |
| 23 | + * bundled Square SDK relies on it. | |
| 24 | + * | |
| 25 | + * @since 1.8.12 | |
| 26 | + * | |
| 27 | + * @param array $arr The array being evaluated. | |
| 28 | + * @return bool True if the array is a list, false otherwise. | |
| 29 | + */ | |
| 30 | + function array_is_list( array $arr ) { | |
| 31 | + if ( array() === $arr ) { | |
| 32 | + return true; | |
| 33 | + } | |
| 34 | + | |
| 35 | + return array_keys( $arr ) === range( 0, count( $arr ) - 1 ); | |
| 36 | + } | |
| 37 | +} | |
| 38 | + | |
| 17 | 39 | /** |
| 18 | 40 | * Load plugin compatibility files on plugins_loaded hook. |
| 19 | 41 | * |
| 20 | 42 | * @since 1.5.0 |
| @@ -45,9 +67,9 @@ | ||
| 45 | 67 | } |
| 46 | 68 | |
| 47 | 69 | /* Litespeed Cache */ |
| 48 | 70 | if ( class_exists( 'LiteSpeed_Cache' ) ) { |
| 49 | - require_once $includes_path . 'compat/charitable-litespeed-cache-compat-functions.php'; | |
| 71 | + require_once $includes_path . 'compat/charitablespeed-cache-compat-functions.php'; | |
| 50 | 72 | } |
| 51 | 73 | |
| 52 | 74 | /* Twenty Seventeen */ |
| 53 | 75 | if ( 'twentyseventeen' == wp_get_theme()->stylesheet ) { |