PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
← All changes | includes/compat/charitable-compat-functions.php +183 -12 1.6.7 → 1.8.13 View file →
@@ -2,17 +2,41 @@
2 2 /**
3 3 * Functions to improve compatibility.
4 4 *
5 5 * @package Charitable/Functions/Compatibility
6 - * @author Eric Daams
7 - * @copyright Copyright (c) 2018, Studio 164a
6 + * @author David Bisset
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 - * @version 1.5.0
10 + * @version 1.6.48
11 11 */
12 12
13 -if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit;
15 +}
14 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 +
15 39 /**
16 40 * Load plugin compatibility files on plugins_loaded hook.
17 41 *
18 42 * @since 1.5.0
@@ -22,28 +46,175 @@
22 46 function charitable_load_compat_functions() {
23 47 $includes_path = charitable()->get_path( 'includes' );
24 48
25 49 /* WP Super Cache */
26 - if ( function_exists( 'wp_super_cache_text_domain' ) ) {
27 - require_once( $includes_path . 'compat/charitable-wp-super-cache-compat-functions.php' );
50 + if ( function_exists( 'wpsupercache_activate' ) ) {
51 + require_once $includes_path . 'compat/charitable-wp-super-cache-compat-functions.php';
28 52 }
29 53
30 54 /* W3TC */
31 55 if ( defined( 'W3TC' ) && W3TC ) {
32 - require_once( $includes_path . 'compat/charitable-w3tc-compat-functions.php' );
56 + require_once $includes_path . 'compat/charitable-w3tc-compat-functions.php';
33 57 }
34 58
35 59 /* WP Rocket */
36 60 if ( defined( 'WP_ROCKET_VERSION' ) ) {
37 - require_once( $includes_path . 'compat/charitable-wp-rocket-compat-functions.php' );
61 + require_once $includes_path . 'compat/charitable-wp-rocket-compat-functions.php';
38 62 }
39 63
40 64 /* WP Fastest Cache */
41 65 if ( class_exists( 'WpFastestCache' ) ) {
42 - require_once( $includes_path . 'compat/charitable-wp-fastest-cache-compat-functions.php' );
66 + require_once $includes_path . 'compat/charitable-wp-fastest-cache-compat-functions.php';
43 67 }
44 68
45 - /* Yoast SEO */
46 - if ( defined( 'WPSEO_VERSION' ) ) {
47 - require_once( $includes_path . 'compat/charitable-wpseo-compat-functions.php' );
69 + /* Litespeed Cache */
70 + if ( class_exists( 'LiteSpeed_Cache' ) ) {
71 + require_once $includes_path . 'compat/charitablespeed-cache-compat-functions.php';
48 72 }
73 +
74 + /* Twenty Seventeen */
75 + if ( 'twentyseventeen' == wp_get_theme()->stylesheet ) {
76 + require_once $includes_path . 'compat/charitable-twentyseventeen-compat-functions.php';
77 + }
78 +
79 + /* Ultimate Member */
80 + if ( class_exists( 'UM' ) ) {
81 + require_once $includes_path . 'compat/charitable-ultimate-member-compat-functions.php';
82 + }
83 +
84 + /* GDPR Cookie Compliance */
85 + if ( function_exists( 'gdpr_cookie_is_accepted' ) ) {
86 + require_once $includes_path . 'compat/charitable-gdpr-cookie-compliance-compat-functions.php';
87 + }
88 +
89 + /* WooCommerce */
90 + if ( defined( 'WC_PLUGIN_FILE' ) ) {
91 + require_once $includes_path . 'compat/charitable-woocommerce-compat-functions.php';
92 + }
93 +
94 + /* Polylang */
95 + if ( defined( 'POLYLANG_VERSION' ) ) {
96 + new Charitable_Polylang_Compat();
97 + }
98 +
99 + /* WPML */
100 + if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
101 + new Charitable_WPML_Compat();
102 + }
103 +
104 + /* Weglot */
105 + if ( defined( 'WEGLOT_VERSION' ) ) {
106 + new Charitable_Weglot_Compat();
107 + }
108 +
109 + /* TranslatePress */
110 + if ( class_exists( 'TRP_Translate_Press' ) ) {
111 + new Charitable_Translatepress_Compat();
112 + }
113 +
114 + /* Permalink Manager */
115 + if ( defined( 'PERMALINK_MANAGER_PLUGIN_NAME' ) ) {
116 + require_once $includes_path . 'compat/charitable-permalink-manager-compat-functions.php';
117 + }
49 118 }
119 +
120 +/**
121 + * Add custom styles for certain themes.
122 + *
123 + * @since 1.6.29
124 + *
125 + * @return void
126 + */
127 +function charitable_compat_styles() {
128 + $styles = include 'styles/inline-styles.php';
129 +
130 + foreach ( $styles as $stylesheet => $custom_styles ) {
131 + wp_add_inline_style( $stylesheet, $custom_styles );
132 + }
133 +}
134 +
135 +add_action( 'wp_enqueue_scripts', 'charitable_compat_styles', 20 );
136 +
137 +/**
138 + * Change the default accent colour based on the current theme.
139 + *
140 + * @since 1.6.29
141 + *
142 + * @param string $colour The default accent colour.
143 + * @return string
144 + */
145 +function charitable_compat_theme_highlight_colour( $colour ) {
146 + $colours = include 'styles/highlight-colours.php';
147 + $stylesheet = strtolower( wp_get_theme()->stylesheet );
148 +
149 + if ( 'twentytwenty' === $stylesheet && function_exists( 'twentytwenty_get_color_for_area' ) ) {
150 + return sanitize_hex_color( twentytwenty_get_color_for_area( 'content', 'accent' ) );
151 + }
152 +
153 + if ( 'divi' === $stylesheet && function_exists( 'et_get_option' ) ) {
154 + $stylesheet = 'divi-' . et_get_option( 'color_schemes', 'none' );
155 + }
156 +
157 + if ( array_key_exists( $stylesheet, $colours ) ) {
158 + return $colours[ $stylesheet ];
159 + }
160 +
161 + /* Return default colour. */
162 + return $colour;
163 +}
164 +
165 +add_filter( 'charitable_default_highlight_colour', 'charitable_compat_theme_highlight_colour' );
166 +
167 +/**
168 + * Add button classes depending on the theme.
169 + *
170 + * @since 1.6.29
171 + *
172 + * @param array $classes The classes to add to the button by default.
173 + * @param string $button The specific button we're showing.
174 + * @return array
175 + */
176 +function charitable_compat_button_classes( $classes, $button ) {
177 + switch ( strtolower( wp_get_theme()->template ) ) {
178 + case 'divi':
179 + $classes[] = 'et_pb_button';
180 + break;
181 + }
182 +
183 + return $classes;
184 +}
185 +
186 +add_filter( 'charitable_button_class', 'charitable_compat_button_classes', 10, 2 );
187 +
188 +/**
189 + * Enable locale functions in Charitable based on presence of other plugins.
190 + *
191 + * @since 1.6.43
192 + *
193 + * @param boolean $locale_enabled Whether to enable locale functions.
194 + * @return boolean
195 + */
196 +function charitable_compat_load_locale_functions( $locale_enabled ) {
197 + /* We've already enabled locale functions. */
198 + if ( $locale_enabled ) {
199 + return $locale_enabled;
200 + }
201 +
202 + /* Polylang */
203 + if ( defined( 'POLYLANG_VERSION' ) ) {
204 + return true;
205 + }
206 +
207 + /* TranslatePress */
208 + if ( class_exists( 'TRP_Translate_Press' ) ) {
209 + return true;
210 + }
211 +
212 + /* Weglot */
213 + if ( defined( 'WEGLOT_VERSION' ) ) {
214 + return true;
215 + }
216 +
217 + return $locale_enabled;
218 +}
219 +
220 +add_filter( 'charitable_enable_locale_functions', 'charitable_compat_load_locale_functions' );