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 / charitable-functions.php
Created June 20, 2022 02:10
Giving Hand theme overriding form fields.
<?php
add_filter( 'charitable_donation_form_fields', 'givinghand_charitable_donation_form_fields', 10, 2 );
function givinghand_charitable_donation_form_fields( $fields, $object ) {
$fields['donation_fields']['legend'] = '<h4>'. esc_html__( 'How Much Would you like to Donate?', 'givinghand' ) .'</h4>';
$fields['user_fields']['legend'] = '<h4>'. esc_html__( 'Billing Information', 'givinghand' ) .'</h4>';
return $fields;
}
@ericnicolaas
ericnicolaas / form-donation.php
Created June 17, 2022 06:59
Giving Hand fixed donation form
<?php
/**
* The template used to display the default form.
*
* @author Studio 164a
* @package Charitable/Templates/Donation Form
* @since 1.0.0
* @version 1.3.0
*/
@ericnicolaas
ericnicolaas / functions.php
Created May 26, 2022 02:18
Add donor comments for donations where the comments were not added correctly
<?php
function ed_add_missing_comment( $donation_id ) {
$comment = get_post_meta( $donation_id, 'donor_comment', true );
if ( empty( $comment ) ) {
return;
}
$donation = charitable_get_donation($donation_id );
$donor = $donation->get_donor();
@ericnicolaas
ericnicolaas / script.js
Created March 25, 2022 06:38
Customize the card field in Charitable Stripe using the Style object
window.Charitable.Hooks.addFilter( 'stripeCardElementOptions', 'myCustom', () => {
return {
style: {
base: {
iconColor: '#c4f0ff',
color: '#444',
fontWeight: '500',
fontFamily: 'Roboto, Open Sans, Segoe UI, sans-serif',
fontSize: '16px',
fontSmoothing: 'antialiased',
@ericnicolaas
ericnicolaas / if-locale.php
Created March 24, 2022 03:44
Add a shortcode you can use to display different text based on the current locale.
<?php
/**
* This adds a new shortcode you can use to display different
* text based on the current locale.
*/
add_shortcode( 'if_locale', function( $atts, $content ) {
$defaults = array(
'language' => '',
);
@ericnicolaas
ericnicolaas / form-donation.php
Created March 1, 2022 08:01
Charity Home theme donation form override
<?php
/**
* This template will override the default donation form theme template in Charity Home,
* which does not fully support all Charitable extensions.
*/
if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly
$form = $view_args['form'];
$user_fields = $form->get_user_fields();
@ericnicolaas
ericnicolaas / single-campaign.php
Last active January 18, 2022 22:57
Custom single campaign template for Loveus with the Fundraise button
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package loveus
*/
get_header();
$campaign = charitable_get_current_campaign();
@ericnicolaas
ericnicolaas / functions.php
Created November 3, 2021 06:31
Create a new campaign programatically
add_action(
'admin_init',
function() {
return charitable_create_campaign(
array(
'title' => 'My new campaign',
'content' => 'Extended content about this campaign',
'creator' => get_current_user_id(),
'status' => 'draft',
'parent' => 541,
@ericnicolaas
ericnicolaas / functions.php
Last active September 3, 2021 01:33
Add columns to Gift Aid export
add_filter(
'charitable_giftaid_export_row',
function( $row ) {
return array(
'donation_id' => $row['donation_id'] ?? '',
'title' => $row['title'] ?? '',
'first_name' => $row['first_name'] ?? '',
'last_name' => $row['last_name'] ?? '',
'house_number' => $row['house_number'] ?? '',
'postcode' => $row['postcode'] ?? '',
@ericnicolaas
ericnicolaas / custom-script.js
Last active April 30, 2021 00:04
Extend Charitable using jQuery Events
CHARITABLE = window.CHARITABLE || {};
( function( $ ) {
var $body = $( 'body' );
/**
* Do something when a donation form loads.
*
* @since 1.0.0