Skip to content

Instantly share code, notes, and snippets.

@rickalday
rickalday / give_export_gift_aid.php
Created March 15, 2025 01:47
Export Gift Aid data in Donation History Export Tool
<?php
function give_export_gift_aid() {
?>
<li>
<label for="give-export-payment-gift_aid">
<input type="checkbox" checked name="give_give_donations_export_option[gift_aid]" id="give-export-gift_aid"><?php _e( 'Gift Aid', 'give' ); ?>
</label>
</li>
<?php
@rickalday
rickalday / set_specific_country_state.php
Created March 14, 2025 16:59
Limit Billing Address Block to specific country and state
add_filter('give_countries', 'my_custom_give_countries');
function my_custom_give_countries() {
$countries = array(
'CA' => esc_html__( 'Canada', 'give' ),
);
return $countries;
}
<?php
@rickalday
rickalday / make_comment_required.php
Created March 11, 2025 20:18
Make the Commens block field required in GiveWP forms
<?php
add_action('givewp_donation_form_schema', function($form) {
$comment = $form->getNodeByName('comment');
// if the comment field is not found, return
if (!$comment) {
return;
}
// require field
$comment->required(true);
@rickalday
rickalday / unrequire_billing_block_fields.php
Created March 11, 2025 19:47
Unrequire billing address block field for US in GiveWP visual builder forms
<?php
add_filter('give_get_country_locale', 'give_custom_requirements');
function give_custom_requirements() {
$countries = array(
'US' => [
'state' => [
'required' => false,
],
'address1' => [
@rickalday
rickalday / give_export_profile_id.php
Created February 12, 2025 00:11
Adds a new checkbox in the Donation History Export that includes the subscription profile ID
<?php
function give_export_profile_id() {
?>
<li>
<label for="give-export-payment-subscription_profile_id">
<input type="checkbox" checked name="give_give_donations_export_option[subscription_profile_id]" id="give-export-subscription_profile_id"><?php _e( 'Subscripton Profile ID', 'give' ); ?>
</label>
</li>
@rickalday
rickalday / givewp_pdf_full_address_tag.php
Created February 11, 2025 23:41
New {address} tag for PDF Receipts that outputs the full state name
<php
function givewp_pdf_full_address_tag( $template_content, $args ) {
$buyer_info = give_get_payment_meta_user_info( $args['donation_id'] );
$address = isset( $buyer_info['address'] ) ? $buyer_info['address'] : '';
$address_data = [];
@rickalday
rickalday / givewp-export-donor-custom-field-data.php
Created January 21, 2025 22:10
Include custom field data from donor metadata in GiveWP's donation history export
<?php
/**
* This function sets the column header in the generated CSV file for the custom field. Add an if statement for each aditional field.
*/
function givewp_custom_columns_name( $cols ) {
if ( isset( $cols['givewp_employer'] ) ) {
$cols['givewp_employer'] = __( 'Employer', 'give' );
}
@rickalday
rickalday / givewp-export-subscription-id.php
Last active January 15, 2025 18:43
GiveWP Export Subscription ID
<?php
function givewp_subscription_columns_name( $cols ) {
if ( isset( $cols['givewp_subscription_id'] ) ) {
$cols['givewp_subscription_id'] = __( 'Subscription ID', 'give' );
}
return $cols;
}
<table id="fresh_blue" class="fresh_blue" style="margin: 0;padding: 0;color: #333;height: 100%;background-color: #f8f8f8;max-height: 100%;min-height: 100%" border="0" width="100%">
<tbody>
<tr>
<td width="100%">
<table style="margin: 0;padding: 0" border="0" width="100%">
<tbody>
<tr>
<td style="font-family: Helvetica;background-color: #5b50f1;font-size: 14px;color: #fff;font-style: italic;line-height: 40px;text-align:center" align="center" valign="middle" width="100%"></td>
</tr>
</tbody>
@rickalday
rickalday / givewp-dark-light.php
Last active January 8, 2025 17:01
Add a light/dark toggle button to a GiveWP form
<?php
add_action('givewp_donation_form_schema', static function (Give\Framework\FieldsAPI\DonationForm $form) {
$field = Give\Framework\FieldsAPI\HTML::make('YourFieldName')
->html('<button
type="button"
data-theme-toggle
aria-label="Change to light theme"
>Change to light theme</button>
');