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.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 1.7.0.9 All 211 releases
← All changes | includes/public/class-charitable-public.php +99 -89 1.7.0 → 1.8.13 View file →
@@ -3,9 +3,9 @@
3 3 * Charitable Public class.
4 4 *
5 5 * @package Charitable/Classes/Charitable_Public
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.0.0
10 10 * @version 1.6.60
11 11 */
@@ -69,15 +69,10 @@
69 69 *
70 70 * @return void
71 71 */
72 72 public function setup_scripts() {
73 - if ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) {
74 - $suffix = '';
75 - $version = '';
76 - } else {
77 - $suffix = '.min';
78 - $version = charitable()->get_version();
79 - }
73 + $min = charitable_get_min_suffix();
74 + $version = charitable()->get_version();
80 75
81 76 $assets_dir = charitable()->get_path( 'assets', false );
82 77
83 78 /* Main Charitable script. */
@@ -127,28 +122,29 @@
127 122 */
128 123 $vars = apply_filters(
129 124 'charitable_javascript_vars',
130 125 array(
131 - 'ajaxurl' => admin_url( 'admin-ajax.php' ),
132 - 'loading_gif' => $assets_dir . 'images/charitable-loading.gif',
133 - 'country' => charitable_get_option( 'country' ),
134 - 'currency' => charitable_get_currency(),
135 - 'currency_symbol' => $currency->get_currency_symbol(),
136 - 'currency_format_num_decimals' => esc_attr( $currency->get_decimals() ),
137 - 'currency_format_decimal_sep' => esc_attr( $currency->get_decimal_separator() ),
138 - 'currency_format_thousand_sep' => esc_attr( $currency->get_thousands_separator() ),
139 - 'currency_format' => esc_attr( $currency->get_accounting_js_format() ), // For accounting.js.
140 - 'minimum_donation' => $minimum,
141 - 'maximum_donation' => $maximum,
142 - 'permit_0_donation' => $permit_0_donation,
143 - 'error_invalid_amount' => $amount_msg,
144 - 'error_max_exceeded' => $max_exceeded_msg,
145 - 'error_required_fields' => __( 'Please fill out all required fields.', 'charitable' ),
146 - 'error_unknown' => __( 'Your donation could not be processed. Please reload the page and try again.', 'charitable' ),
147 - 'error_invalid_cc_number' => __( 'The credit card passed is not valid.', 'charitable' ),
148 - 'error_invalid_cc_expiry' => __( 'The credit card expiry date is not valid.', 'charitable' ),
149 - 'version' => charitable()->get_version(),
150 - 'test_mode' => (int) charitable_get_option( 'test_mode' ),
126 + 'ajaxurl' => admin_url( 'admin-ajax.php' ),
127 + 'loading_gif' => $assets_dir . 'images/charitable-loading.gif',
128 + 'country' => charitable_get_option( 'country' ),
129 + 'currency' => charitable_get_currency(),
130 + 'currency_symbol' => $currency->get_currency_symbol(),
131 + 'currency_format_num_decimals' => esc_attr( $currency->get_decimals() ),
132 + 'currency_format_decimal_sep' => esc_attr( $currency->get_decimal_separator() ),
133 + 'currency_format_thousand_sep' => esc_attr( $currency->get_thousands_separator() ),
134 + 'currency_format' => esc_attr( $currency->get_accounting_js_format() ), // For accounting.js.
135 + 'minimum_donation' => $minimum,
136 + 'maximum_donation' => $maximum,
137 + 'permit_0_donation' => $permit_0_donation,
138 + 'error_invalid_amount' => $amount_msg,
139 + 'error_max_exceeded' => $max_exceeded_msg,
140 + 'error_required_fields' => __( 'Please fill out all required fields.', 'charitable' ),
141 + 'error_unknown' => __( 'Your donation could not be processed. Please reload the page and try again.', 'charitable' ),
142 + 'error_invalid_cc_number' => __( 'The credit card passed is not valid.', 'charitable' ),
143 + 'error_invalid_cc_expiry' => __( 'The credit card expiry date is not valid.', 'charitable' ),
144 + 'version' => charitable()->get_version(),
145 + 'test_mode' => (int) charitable_get_option( 'test_mode' ),
146 + 'error_notice_donation_display' => esc_attr( charitable_get_option( 'donation_form_notices_display' ) ),
151 147 )
152 148 );
153 149
154 150 /* Accounting.js */
@@ -153,9 +149,9 @@
153 149
154 150 /* Accounting.js */
155 151 wp_register_script(
156 152 'accounting',
157 - $assets_dir . 'js/libraries/accounting' . $suffix . '.js',
153 + $assets_dir . 'js/libraries/accounting' . $min . '.js',
158 154 array( 'jquery' ),
159 155 $version,
160 156 true
161 157 );
@@ -167,9 +163,9 @@
167 163 }
168 164
169 165 wp_register_script(
170 166 'charitable-script',
171 - $assets_dir . 'js/charitable' . $suffix . '.js',
167 + $assets_dir . 'js/charitable' . $min . '.js',
172 168 $deps,
173 169 $version,
174 170 true
175 171 );
@@ -182,9 +178,9 @@
182 178
183 179 /* Credit card validation */
184 180 wp_register_script(
185 181 'charitable-credit-card',
186 - $assets_dir . 'js/charitable-credit-card' . $suffix . '.js',
182 + $assets_dir . 'js/charitable-credit-card' . $min . '.js',
187 183 array( 'charitable-script' ),
188 184 $version,
189 185 true
190 186 );
@@ -191,9 +187,9 @@
191 187
192 188 /* URL sanitizer. */
193 189 wp_register_script(
194 190 'charitable-url-sanitizer',
195 - $assets_dir . 'js/charitable-url-sanitizer' . $suffix . '.js',
191 + $assets_dir . 'js/charitable-url-sanitizer' . $min . '.js',
196 192 array( 'jquery' ),
197 193 $version,
198 194 true
199 195 );
@@ -200,9 +196,9 @@
200 196
201 197 /* General forms scripts. */
202 198 wp_register_script(
203 199 'charitable-forms',
204 - $assets_dir . 'js/charitable-forms' . $suffix . '.js',
200 + $assets_dir . 'js/charitable-forms' . $min . '.js',
205 201 array( 'jquery' ),
206 202 $version,
207 203 true
208 204 );
@@ -209,9 +205,9 @@
209 205
210 206 /* Main styles */
211 207 wp_register_style(
212 208 'charitable-styles',
213 - $assets_dir . 'css/charitable' . $suffix . '.css',
209 + $assets_dir . 'css/charitable' . $min . '.css',
214 210 array(),
215 211 $version
216 212 );
217 213
@@ -216,14 +212,17 @@
216 212 );
217 213
218 214 wp_enqueue_style( 'charitable-styles' );
219 215
216 + // 1.8.4.5
217 + wp_enqueue_style( 'dashicons' );
218 +
220 219 /* Lean Modal is registered but NOT enqueued yet. */
221 220 if ( 'modal' == charitable_get_option( 'donation_form_display', 'separate_page' ) ) {
222 221
223 222 wp_register_script(
224 223 'lean-modal',
225 - $assets_dir . 'js/libraries/leanModal' . $suffix . '.js',
224 + $assets_dir . 'js/libraries/leanModal' . $min . '.js',
226 225 array( 'jquery' ),
227 226 $version
228 227 );
229 228
@@ -228,9 +227,9 @@
228 227 );
229 228
230 229 wp_register_style(
231 230 'lean-modal-css',
232 - $assets_dir . 'css/modal' . $suffix . '.css',
231 + $assets_dir . 'css/modal' . $min . '.css',
233 232 array(),
234 233 $version
235 234 );
236 235
@@ -237,9 +236,9 @@
237 236 }
238 237
239 238 wp_register_style(
240 239 'charitable-datepicker',
241 - $assets_dir . 'css/charitable-datepicker' . $suffix . '.css',
240 + $assets_dir . 'css/charitable-datepicker' . $min . '.css',
242 241 array(),
243 242 $version
244 243 );
245 244
@@ -253,9 +252,9 @@
253 252 );
254 253
255 254 wp_register_script(
256 255 'charitable-plup-fields',
257 - $assets_dir . 'js/charitable-plupload-fields' . $suffix . '.js',
256 + $assets_dir . 'js/charitable-plupload-fields' . $min . '.js',
258 257 array( 'jquery-ui-sortable', 'wp-ajax-response', 'plupload-all' ),
259 258 $version,
260 259 true
261 260 );
@@ -267,77 +266,88 @@
267 266 );
268 267
269 268 wp_register_style(
270 269 'charitable-plup-styles',
271 - $assets_dir . 'css/charitable-plupload-fields' . $suffix . '.css',
270 + $assets_dir . 'css/charitable-plupload-fields' . $min . '.css',
272 271 array(),
273 272 $version
274 273 );
275 274
275 + if ( charitable()->load_core_stripe() && class_exists( 'Charitable_Gateway_Stripe_AM' ) ) :
276 276
277 - if ( charitable()->load_core_stripe() ) :
277 + $gateway = new Charitable_Gateway_Stripe_AM();
278 + $keys = $gateway->get_keys();
279 + $settings = get_option( 'charitable_settings' );
278 280
279 - $gateway = new Charitable_Gateway_Stripe_AM;
280 - $keys = $gateway->get_keys();
281 + // If there is no public key, skip loading Stripe scripts but continue.
282 + if ( isset( $keys['public_key'] ) && ! empty( $keys['public_key'] ) ) {
281 283
282 - $stripe_vars = array(
283 - 'key' => $keys['public_key'],
284 - 'currency' => charitable_get_currency(),
285 - 'site_name' => get_option( 'blogname' ),
286 - 'zero_decimal' => Charitable_Gateway_Stripe_AM::is_zero_decimal_currency(),
287 - );
284 + $cc_fields_format = ( ! empty( $settings['gateways_stripe']['cc_fields_format'] ) && '' !== $settings['gateways_stripe']['cc_fields_format'] ) ? $settings['gateways_stripe']['cc_fields_format'] : '';
288 285
289 - /* Register Stripe JS script. */
290 - wp_register_script(
291 - 'stripe-v3',
292 - 'https://js.stripe.com/v3/',
293 - array(),
294 - $version,
295 - true
296 - );
286 + $stripe_vars = array(
287 + 'key' => $keys['public_key'],
288 + 'currency' => charitable_get_currency(),
289 + 'site_name' => get_option( 'blogname' ),
290 + 'zero_decimal' => Charitable_Gateway_Stripe_AM::is_zero_decimal_currency(),
291 + 'cc_fields_format' => esc_attr( $cc_fields_format ),
292 + );
297 293
298 - $dependencies = array( 'charitable-script', 'stripe-v3', 'jquery' );
294 + /* Register Stripe JS script. */
295 + wp_register_script(
296 + 'stripe-v3',
297 + 'https://js.stripe.com/v3/',
298 + array(),
299 + $version,
300 + true
301 + );
299 302
300 - // if ( charitable_get_option( array( 'gateways_stripe', 'enable_stripe_checkout' ) ) ) {
301 - // $stripe_vars['mode'] = 'checkout';
302 - // } else {
303 - $stripe_vars['mode'] = 'payment-intents';
304 - // }
303 + $dependencies = array( 'charitable-script', 'stripe-v3', 'jquery' );
305 304
306 - wp_register_script(
307 - 'charitable-stripe',
308 - $assets_dir . 'js/stripe/charitable-stripe' . $suffix . '.js',
309 - $dependencies,
310 - $version,
311 - true
312 - );
305 + if ( charitable_get_option( array( 'gateways_stripe', 'enable_stripe_checkout' ) ) ) {
306 + $stripe_vars['mode'] = 'checkout';
307 + } else {
308 + $stripe_vars['mode'] = 'payment-intents';
309 + }
313 310
314 - wp_localize_script(
315 - 'charitable-stripe',
316 - 'CHARITABLE_STRIPE_VARS',
317 - $stripe_vars
318 - );
311 + wp_register_script(
312 + 'charitable-stripe',
313 + $assets_dir . 'js/stripe/charitable-stripe' . $min . '.js',
314 + $dependencies,
315 + $version,
316 + true
317 + );
319 318
320 - if ( 'payment-intents' == $stripe_vars['mode'] ) {
321 - /**
322 - * Prevent the Stripe script from loading site-wide.
323 - *
324 - * @since 1.4.3
325 - *
326 - * @param boolean $load Whether to load the scripts sitewide. Defaults to true.
327 - */
328 - if ( apply_filters( 'charitable_stripe_load_stripe_scripts_sitewide', true ) ) {
329 - wp_enqueue_script( 'stripe-v3' );
319 + wp_localize_script(
320 + 'charitable-stripe',
321 + 'CHARITABLE_STRIPE_VARS',
322 + $stripe_vars
323 + );
324 +
325 + if ( 'payment-intents' == $stripe_vars['mode'] ) {
326 + /**
327 + * Prevent the Stripe script from loading site-wide.
328 + *
329 + * @since 1.4.3
330 + *
331 + * @param boolean $load Whether to load the scripts sitewide. Defaults to true.
332 + */
333 + if ( apply_filters( 'charitable_stripe_load_stripe_scripts_sitewide', true ) ) {
334 + wp_enqueue_script( 'stripe-v3' );
335 + }
330 336 }
331 337 }
332 338
333 339 endif;
334 340
335 -
336 -
337 -
338 -
339 -
341 + /* General forms scripts. */
342 + wp_register_script(
343 + 'charitable-frontend-v2',
344 + $assets_dir . 'js/charitable-frontend' . $min . '.js',
345 + array( 'jquery' ),
346 + $version,
347 + true
348 + );
349 + wp_enqueue_script( 'charitable-frontend-v2' );
340 350 }
341 351
342 352 /**
343 353 * Conditionally load the donation form scripts if we're viewing the donation form.