PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.6.1
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.6.1
1.6.1 1.6.0 1.5.1 1.5.0 1.4.0 1.3.0 trunk 0.0.1 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0
← All changes | inc/shortcodes/donation-form.php +22 -6 1.0.0 → 1.6.1 View file →
@@ -10,8 +10,9 @@
10 10
11 11 namespace SureDonation\Inc\Shortcodes;
12 12
13 13 use SureDonation\Inc\Fields\Form_Renderer;
14 +use SureDonation\Inc\Fields\Form_Styling;
14 15 use SureDonation\Inc\Helper;
15 16 use SureDonation\Inc\Post_Types\Donation_Form as Donation_Form_CPT;
16 17 use SureDonation\Inc\Traits\Get_Instance;
17 18
@@ -105,10 +106,16 @@
105 106 * @return void
106 107 * @since 0.0.1
107 108 */
108 109 private function enqueue_assets( $form_id, $form ) {
109 - // Enqueue the shared compiled frontend stylesheet (same handle the block uses).
110 - wp_enqueue_style( 'suredonation-donation-form' );
110 + // Enqueue the shared compiled frontend stylesheet (same handle the block
111 + // uses). Skipped when the form has default styling disabled — the site's
112 + // own CSS then controls the appearance. Scripts are always loaded so
113 + // payment and validation keep working. The enqueue is additive across
114 + // forms on a page, so a styled form still loads the stylesheet.
115 + if ( ! Form_Styling::is_default_styling_disabled( $form_id ) ) {
116 + wp_enqueue_style( 'suredonation-donation-form' );
117 + }
111 118
112 119 // Enqueue frontend script (registered globally in Assets\Register).
113 120 wp_enqueue_script( 'suredonation-form-frontend' );
114 121
@@ -118,12 +125,21 @@
118 125 'suredonationPayment',
119 126 Helper::get_form_payment_settings( $form_id )
120 127 );
121 128
129 + // Expose the resolved validation messages so client-side validation
130 + // mirrors the server's configured messages (matches the block render).
131 + wp_localize_script(
132 + 'suredonation-form-frontend',
133 + 'suredonationValidationMessages',
134 + \SureDonation\Inc\Field_Validation::get_resolved_validation_messages()
135 + );
136 +
122 137 // Enqueue Stripe.js if Stripe is configured.
123 138 $this->maybe_enqueue_stripe();
124 139
125 - // Allow payment gateway extensions to enqueue their scripts (e.g., PayPal SDK).
140 + // Allow payment gateway extensions to enqueue their scripts and localize
141 + // their frontend configuration (see the action's docblock in block.php).
126 142 do_action( 'suredonation_enqueue_form_frontend_scripts', $form_id, $form->post_content );
127 143 }
128 144
129 145 /**
@@ -136,11 +152,11 @@
136 152 if ( ! class_exists( 'SureDonation\Inc\Payments\Stripe\Stripe_Helper' ) ) {
137 153 return;
138 154 }
139 155
140 - $publishable_key = \SureDonation\Inc\Payments\Stripe\Stripe_Helper::get_stripe_publishable_key();
141 -
142 - if ( ! empty( $publishable_key ) ) {
156 + // Load Stripe.js when any connected account exists; the per-form
157 + // publishable key is passed to the frontend via the payment block markup.
158 + if ( \SureDonation\Inc\Payments\Stripe\Stripe_Helper::is_stripe_connected() ) {
143 159 wp_enqueue_script(
144 160 'stripe-js',
145 161 'https://js.stripe.com/v3/',
146 162 [],