Simple Custom Settings Fields for Give WP Donations Plugin

My previous post about Give was an intro to building a payment gateway for the plugin. If you’ve built extensions for Give or are starting to then you’ve probably run into the settings fields API for adding a variety of inputs. The options are limited and there are often times a need for custom fields.

As you add settings to an array they will be displayed in the same order in a Give formatted html table. It appears they were using CMB2 but have since deprecated it. I’m not 100% sure but there are remnants of it in the plugin.

Creating A Custom Field

Within the output_fields function I mentioned above there is a switch statement on the field type. This goes through all the type options default in Give and outputs the field content based on type. After all the case type options the default is a sweet do_action( ‘give_admin_field_’ . $value[‘type’], $value, $option_value ); This is how you do what you want to do with a custom field.

One thing I really needed when building an extension was a way to have inter-woven sub headers for form options. I could not find a way to just output a title. The type field title that’s default to Give outputs the top of a table with it as it’s meant to be, that’s right, at the top lol.

Let’s start with an example of creating a simple sub title output.

Remember, the form settings fields are all in a table so you need to use a table row to output your field. Now we can add this subtitle between fields by using: