Skip to content

Instantly share code, notes, and snippets.

View ericnicolaas's full-sized avatar
🎯
Focusing

Eric Daams ericnicolaas

🎯
Focusing
View GitHub Profile
@ericnicolaas
ericnicolaas / donate-button-amount.js
Created February 15, 2021 07:41
Show the donation amount in the donate button
(function($){
$('body').on('charitable:form:total:changed', function(event, helper) {
helper.form.find('.donate-button').text('Donate ' + helper.format_amount(helper.get_amount(), CHARITABLE_VARS.currency_symbol));
});
})(jQuery);
@ericnicolaas
ericnicolaas / functions.php
Created December 10, 2020 07:28
Delete all pending donations in a date rnage
<?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 / style.css
Last active October 6, 2020 07:13
Add currency symbol in custom amount field
.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
Created September 24, 2020 08:26
Include donation gateway as a donation field that can be used when subscribing someone
<?php
add_filter(
'charitable_newsletter_connect_provider_donation_fields',
function( $fields ) {
$fields['donation_gateway'] = 'Payment Gateway';
return $fields;
}
);
@ericnicolaas
ericnicolaas / functions.php
Last active August 11, 2020 08:36
Set PayPal descriptor to be parent campaign name
<?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 July 20, 2020 05:08
Customized email footer
@ericnicolaas
ericnicolaas / functions.php
Last active June 23, 2020 08:41
Adding a custom file field to the campaign form
<?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 June 23, 2020 08:31
Adding a custom picture field to the campaign form
<?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 June 10, 2020 03:16
Apply Gift Aid to renewal donations
<?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.
@ericnicolaas
ericnicolaas / functions.php
Last active June 5, 2020 12:49
Attendee fields
<?php
$fields_api->register_field(
new Charitable_Campaign_Field(
'attendees',
[
'label' => 'Attendees',
'data_type' => 'meta',
'admin_form' => [
'required' => false,
'section' => 'hike-details',