Skip to content

Instantly share code, notes, and snippets.

@matheuswd
matheuswd / change_font_to_roboto.php
Last active October 21, 2022 12:33
It changes the font of the multi-step donation form to Roboto.
<?php
function change_font_to_Roboto() {
wp_add_inline_style(
/**
* Below, use give-sequoia-template-css to style the multi-step donation form
* or use give-donor-dashboards-app to style the donor dashboard
*/
'give-sequoia-template-css',
'
@import url("https://fonts.googleapis.com/css?family=Roboto");
@matheuswd
matheuswd / custom_pdf_tag_donor_title.php
Created September 7, 2022 11:02
Creates the {donor_title} tag for the GiveWP PDF Receipt
<?php
function custom_pdf_tag_donor_title( $template_content, $args ) {
$donor_title = isset( $args['buyer_info']['title'] ) && $args['buyer_info']['title'] !== '' ? $args['buyer_info']['title'] : __('', 'give');
$template_content = str_replace( '{donor_title}', $donor_title, $template_content );
return $template_content;
}
add_filter( 'give_pdf_compiled_template_content', 'custom_pdf_tag_donor_title', 999, 2 );
@matheuswd
matheuswd / givewp_hide_gift_aid_warnings.php
Created August 24, 2022 11:53
Hide the Gift Aid Warning when the country is not the UK and the currency is not Pounds
<?php
function givewp_hide_gift_aid_warnings($notice_args) {
if( $notice_args['id'] == 'gift-aid-currency-notice' || $notice_args['id'] == 'gift-aid-country-notice' ) {
$notice_args['show'] = false;
}
return $notice_args;
}
add_filter( 'give_register_notice_args', 'givewp_hide_gift_aid_warnings' );
@matheuswd
matheuswd / change-givewp-thank-you-message-globally.php
Created January 17, 2022 18:43
Change the thank you message for GiveWP Multi-step Donation Form
<?php
add_action('give_new_receipt', function($receipt) {
$receipt->message = "<a href=\"https://google.com\" target=\"_blank\">This is my custom message for all my forms</a>";
});
@matheuswd
matheuswd / stripe_custom_description.php
Last active June 9, 2021 15:14
Custom Description
<?php
// Make sure to use the legacy donation form to visualize the data
function stripe_custom_description($data) {
$posted_data = give_clean( filter_input_array( INPUT_POST ) );
print_r($posted_data);
die;
return 'My custom description here, ' . $data . ' ' . $posted_data;
}
@matheuswd
matheuswd / custom_pdf_receipt_last_name.php
Created May 31, 2021 19:09
Adds the last name tag - {donor_last_name} - to the GiveWP PDF Receipts add-on
<?php
function custom_pdf_receipt_last_name( $template_content, $args ) {
$donor_last_name = isset( $args['payment_meta']['user_info']['last_name'] ) && $args['payment_meta']['user_info']['last_name'] !== '' ? $args['payment_meta']['user_info']['last_name'] : __('Not found', 'give');
$template_content = str_replace( '{donor_last_name}', $donor_last_name, $template_content );
return $template_content;
}
add_filter( 'give_pdf_compiled_template_content', 'custom_pdf_receipt_last_name', 999, 2 );
@matheuswd
matheuswd / give_add_gift_aid_status_pdf_tag.php
Created May 18, 2021 15:25
Adds the {gift_aid_status} tag to the PDF Receipt
<?php
function give_add_gift_aid_status_pdf_tag( $template_content, $args ) {
// during testing, uncomment the next line to see a full printed array of the possible args that you can query
// var_dump("<pre>".print_r($args,true)."</pre>");
$gift_aid_status = isset( $args['payment_meta']['_give_gift_aid_accept_term_condition'] ) && $args['payment_meta']['_give_gift_aid_accept_term_condition'] == 'on' ? 'Yes' : 'No';
$template_content = str_replace( '{gift_aid_status}', $gift_aid_status, $template_content );
return $template_content;
}
@matheuswd
matheuswd / prefill-donations.sh
Created April 9, 2021 16:02
Possible commands for the GiveWP CLI
#!/usr/bin/env bash
wp give ascii
wp give details
wp give forms --id=103
wp plugin install give --activate
wp give test-donation-form --count=10 --template=random --set-goal=true --set-terms=true
wp give test-donors --count=100
wp give test-donations --count=500 --status=random --total-revenue=100000 --start-date=2020-11-22 --params=donation_currency=USD
@matheuswd
matheuswd / all-post-meta-for-givewp.php
Last active April 9, 2021 23:25
Outputs all post meta for a payment in GiveWP
/**
* TESTING: Outputs all post meta
*
* This section outputs all the custom fields for your reference
* Just set the $testing variable to true
*/
$testing = true;
if ( $testing == true ) {