PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.1.0
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.1.0
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/fields/form-styling.php +15 -64 1.4.0 → 1.1.0 View file →
@@ -90,40 +90,36 @@
90 90 * @since 1.0.0
91 91 */
92 92 public static function get_defaults() {
93 93 return [
94 - 'bgType' => 'color',
95 - 'bgColor' => '',
96 - 'bgGradient' => 'linear-gradient(90deg,#FFC9B2 0%,#C7CBFF 100%)',
97 - 'bgImage' => '',
98 - 'bgImageId' => 0,
99 - 'bgImageSize' => 'cover',
100 - 'bgImagePosition' => 'center center',
101 - 'bgImageRepeat' => 'no-repeat',
94 + 'bgType' => 'color',
95 + 'bgColor' => '',
96 + 'bgGradient' => 'linear-gradient(90deg,#FFC9B2 0%,#C7CBFF 100%)',
97 + 'bgImage' => '',
98 + 'bgImageId' => 0,
99 + 'bgImageSize' => 'cover',
100 + 'bgImagePosition' => 'center center',
101 + 'bgImageRepeat' => 'no-repeat',
102 102 // Colors default to empty here so unset values fall through to the
103 103 // :root defaults in _variables.scss (the editor's STYLE_DEFAULTS seeds
104 104 // the actual hex values instead, only to populate the panel swatches).
105 - 'primaryColor' => '',
106 - 'textColor' => '',
107 - 'textOnPrimaryColor' => '',
108 - 'padding' => [
105 + 'primaryColor' => '',
106 + 'textColor' => '',
107 + 'textOnPrimaryColor' => '',
108 + 'padding' => [
109 109 'top' => '',
110 110 'right' => '',
111 111 'bottom' => '',
112 112 'left' => '',
113 113 ],
114 - 'borderRadius' => [
114 + 'borderRadius' => [
115 115 'top' => '',
116 116 'right' => '',
117 117 'bottom' => '',
118 118 'left' => '',
119 119 ],
120 - 'fieldSpacing' => 'medium',
121 - 'buttonAlignment' => 'justify',
122 - // When true the form renders without the SureDonation stylesheet and
123 - // inline CSS variables so the site's own CSS fully controls its
124 - // appearance (mirrors SureForms' disable_default_styles).
125 - 'disable_default_styles' => false,
120 + 'fieldSpacing' => 'medium',
121 + 'buttonAlignment' => 'justify',
126 122 ];
127 123 }
128 124
129 125 /**
@@ -191,52 +187,13 @@
191 187 $clean['borderRadius'] = self::sanitize_box( $decoded['borderRadius'] ?? [], $defaults['borderRadius'] );
192 188 $clean['fieldSpacing'] = in_array( $decoded['fieldSpacing'] ?? '', [ 'small', 'medium', 'large' ], true ) ? $decoded['fieldSpacing'] : 'medium';
193 189 $clean['buttonAlignment'] = in_array( $decoded['buttonAlignment'] ?? '', [ 'left', 'center', 'right', 'justify' ], true ) ? $decoded['buttonAlignment'] : 'justify';
194 190
195 - // Boolean flag, not a style value — must survive sanitization or an
196 - // editor save silently re-enables the default styling.
197 - $clean['disable_default_styles'] = ! empty( $decoded['disable_default_styles'] );
198 -
199 191 $encoded = wp_json_encode( $clean );
200 192 return is_string( $encoded ) ? $encoded : '';
201 193 }
202 194
203 195 /**
204 - * Check whether the form renders without SureDonation's default styling.
205 - *
206 - * When enabled the frontend stylesheet is not enqueued for the form and the
207 - * inline CSS-variable style attribute is omitted, so the site's own CSS
208 - * fully controls the form's appearance. The container is stamped with an
209 - * `sd-styling-none` marker class so custom CSS can target the state.
210 - *
211 - * @param int $form_id Form post ID.
212 - * @return bool True when default styling is disabled for the form.
213 - * @since 1.4.0
214 - */
215 - public static function is_default_styling_disabled( $form_id ) {
216 - $form_id = absint( $form_id );
217 - if ( ! $form_id ) {
218 - return false;
219 - }
220 -
221 - $settings = self::get_settings( $form_id );
222 - $disabled = ! empty( $settings['disable_default_styles'] );
223 -
224 - /**
225 - * Filters whether SureDonation's default frontend styling is disabled for a form.
226 - *
227 - * Lets themes/plugins toggle the unstyled mode programmatically, overriding
228 - * the stored per-form meta. Return true to render the form without the
229 - * SureDonation stylesheet and inline CSS variables.
230 - *
231 - * @param bool $disabled Whether default styling is disabled (from meta).
232 - * @param int $form_id Form post ID.
233 - * @since 1.4.0
234 - */
235 - return (bool) apply_filters( 'suredonation_disable_default_styles', $disabled, $form_id );
236 - }
237 -
238 - /**
239 196 * Build the inline CSS custom-property string for the form wrapper.
240 197 *
241 198 * Returns the CSS declarations only (no surrounding style attribute). The
242 199 * caller is expected to output the result via esc_attr() inside a style
@@ -246,14 +203,8 @@
246 203 * @return string CSS declarations, or '' when nothing is customized.
247 204 * @since 1.0.0
248 205 */
249 206 public static function get_style_attr( $form_id ) {
250 - // Unstyled mode: no inline CSS variables either — an inline style on the
251 - // container would override any site/custom CSS that themes the form.
252 - if ( self::is_default_styling_disabled( $form_id ) ) {
253 - return '';
254 - }
255 -
256 207 $settings = self::get_settings( $form_id );
257 208 $vars = [];
258 209
259 210 // Colors. Color-derived tints are emitted per-form so they track the