|
/ Documentation /Developer Hooks & Events/ suredonation_disable_default_styles Filter Hook

suredonation_disable_default_styles Filter Hook

Overview

The suredonation_disable_default_styles filter allows developers to control whether SureDonation’s default front-end styles are loaded for a donation form.

When default styling is disabled:

  • SureDonation’s form stylesheet is not enqueued.
  • Inline CSS variables are not added to the form.
  • The site’s own CSS can fully control the donation form’s appearance.
  • The form container receives the sd-styling-none class.

This is useful when a theme or custom plugin already provides its own donation form styling.

When to Use This Filter

Use this filter when you need to:

  • Disable SureDonation’s default styling for all forms.
  • Disable styling for specific forms.
  • Apply custom CSS through your theme or plugin.
  • Avoid conflicts between SureDonation styles and existing site styles.
  • Programmatically control form styling without changing each form’s settings.

Filter Signature

apply_filters( 'suredonation_disable_default_styles', $disabled, $form_id);

Parameters

ParameterTypeDescription
$disabledboolWhether default SureDonation styling is disabled for the form.
$form_idintThe donation form post ID.

The $disabled value is initially read from the form’s disable_default_styles setting.

Return Value

Return a boolean value:

  • true disables SureDonation’s default styling.
  • false keeps SureDonation’s default styling enabled.

return true;

Basic Usage

add_filter( 'suredonation_disable_default_styles', 'your_custom_function', 10, 2);

function your_custom_function( $disabled, $form_id ) {

// Add your custom logic here.

return $disabled;

}

Example: Disable Default Styling for All Forms

If your theme provides styling for all SureDonation forms, you can disable the plugin’s default styles globally.

add_filter( 'suredonation_disable_default_styles', 'mysite_unstyle_all_forms', 10, 2);

function mysite_unstyle_all_forms( $disabled, $form_id ) {

return true;

}

Example: Disable Styling for a Specific Form

You can also target individual forms using the $form_id.

add_filter( 'suredonation_disable_default_styles', 'mysite_unstyle_specific_form', 10, 2 );

function mysite_unstyle_specific_form( $disabled, $form_id ) {

if ( 123 === $form_id ) {

return true;

}

return $disabled;

}

Replace 123 with the ID of the donation form you want to target.

Example: Keep Default Styling for One Form

If default styling is disabled globally but you want to keep it enabled for a specific form:

add_filter( 'suredonation_disable_default_styles', 'mysite_keep_form_styling', 10, 2);

function mysite_keep_form_styling( $disabled, $form_id ) {

if ( 123 === $form_id ) {

return false;

}

return $disabled;

}

Custom CSS Targeting

When default styling is disabled, SureDonation adds the following class to the form container:

sd-styling-none

You can target the form with custom CSS:

.sd-form-container.sd-styling-none {

/* Add your custom styles here. */

}

For example:

.sd-form-container.sd-styling-none .sd-submit-button {

width: 100%;

}

Styling Behavior

The filter controls whether SureDonation’s default styling is used during form rendering:

Form rendered

      â†“

Check disable_default_styles setting

      â†“

suredonation_disable_default_styles

      â†“

Is styling disabled?

   â†™          ↘

 Yes           No

 â†“             ↓

Skip CSS       Load default CSS

Skip inline    Apply CSS variables

CSS variables

 â†“

Add sd-styling-none

This filter is applied in:

Form_Styling::is_default_styling_disabled()

The filter runs each time a form is rendered. Keep the callback lightweight and avoid unnecessary database queries or other expensive operations.

When disabled, SureDonation does not enqueue its default form stylesheet or output the inline CSS-variable styling.

Related Hooks

  • suredonation_enqueue_form_frontend_scripts: Controls front-end scripts and assets loaded for SureDonation forms.
  • suredonation_allowed_form_html: Filters the allowed HTML output for donation forms.
Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Table of Contents
Scroll to Top