Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric Daams ericnicolaas

View GitHub Profile
@ericnicolaas
ericnicolaas / functions.php
Created Dec 10, 2020
Delete all pending donations in a date rnage
View functions.php
<?php
/**
* Adjust the before/after variables to limit the deletion to
* a specific date range. If you want to delete all, set a very
* early $before date (i.e. '2000-01-01').
*/
add_action( 'admin_init', function() {
$after = '2020-11-01';
$before = '2020-11-30';
$query = new Charitable_Donations_Query(
@ericnicolaas
ericnicolaas / functions.php
Created Sep 24, 2020
Include donation gateway as a donation field that can be used when subscribing someone
View functions.php
<?php
add_filter(
'charitable_newsletter_connect_provider_donation_fields',
function( $fields ) {
$fields['donation_gateway'] = 'Payment Gateway';
return $fields;
}
);
@ericnicolaas
ericnicolaas / style.css
Last active Oct 6, 2020
Add currency symbol in custom amount field
View style.css
.custom-donation-amount-wrapper::before {
content: "$";
display: block;
position: absolute;
bottom: .5em;
left: 1em;
color: #bbb;
padding: 6px 0 6px 7px;
font-size: 1em;
}
@ericnicolaas
ericnicolaas / functions.php
Last active Aug 11, 2020
Set PayPal descriptor to be parent campaign name
View functions.php
<?php
function ed_charitable_set_paypal_item_name( $args, $donation_id, $processor ) {
$donation = charitable_get_donation( $donation_id );
$campaign_id = current( $donation->get_campaign_donations() )->campaign_id;
$parent_id = wp_get_post_parent_id( $campaign_id );
$parent_title = get_the_title( $parent_id );
$paypaldescript = 'LETRGive - ' . $parent_title . ' - #106' . $donation_id;
$args['item_name'] = $paypaldescript;
return $args;
}
@ericnicolaas
ericnicolaas / footer.php
Last active Jul 20, 2020
Customized email footer
View footer.php
@ericnicolaas
ericnicolaas / functions.php
Last active Jun 23, 2020
Adding a custom file field to the campaign form
View functions.php
<?php
/**
* This function adds a custom text field to the campaign submission
* form, as well as the admin campaign editor, campaign emails, and
* campaign export.
*
* Note: This example requires Ambassadors 2+. For an example that worked
* on previous version, see the link below.
*
* @see https://github.com/Charitable/library/blob/master/extensions/ambassadors/legacy/add-text-field.php
@ericnicolaas
ericnicolaas / functions.php
Last active Jun 23, 2020
Adding a custom picture field to the campaign form
View functions.php
<?php
/**
* This function adds a custom text field to the campaign submission
* form, as well as the admin campaign editor, campaign emails, and
* campaign export.
*
* Note: This example requires Ambassadors 2+. For an example that worked
* on previous version, see the link below.
*
* @see https://github.com/Charitable/library/blob/master/extensions/ambassadors/legacy/add-text-field.php
@ericnicolaas
ericnicolaas / functions.php
Last active Jun 10, 2020
Apply Gift Aid to renewal donations
View functions.php
<?php
/**
* If the original recurring donation opted in to Gift Aid, apply Gift Aid for
* all renewals too.
*
* @param array $args Array of arguments to create donation.
* @return array
*/
function ed_charitable_apply_gift_aid_to_renewals( $args ) {
// Make sure this is a renewal.
View functions.php
<?php
$fields_api->register_field(
new Charitable_Campaign_Field(
'attendees',
[
'label' => 'Attendees',
'data_type' => 'meta',
'admin_form' => [
'required' => false,
'section' => 'hike-details',
@ericnicolaas
ericnicolaas / functions.php
Last active May 22, 2020
Add "Waiver Agreement" fields to campaign form on initial submission
View functions.php
<?php
add_filter(
'charitable_campaign_submission_fields',
function( $fields, $form ) {
$waiver_fields = array(
'legend' => 'Liability Waiver and Release',
'type' => 'fieldset',
'fields' => array(
'waiver' => array(
'type' => 'paragraph',
You can’t perform that action at this time.