Skip to content

Instantly share code, notes, and snippets.

@matheuswd
matheuswd / required-givewp-mailchimp.php
Created April 8, 2021 15:46
This codes makes the Mailchimp checkbox to be required by default. The user will not be able to donate without checking the newsletter checkbox.
<?php
function required_givewp_mailchimp() { ?>
<script>
jQuery("input[name=give_mailchimp_signup]").prop("required", true);
</script>
<?php }
add_action( 'give_donation_form_after_submit', 'required_givewp_mailchimp' );
@matheuswd
matheuswd / custom-text-below-title.php
Last active April 8, 2021 15:47
This code allows you to add some custom HTML below the GiveWP Form using the legacy template.
<?php
function custom_text_below_title() {
echo '<h2>my custom subtitle</h2>';
}
add_action( 'give_before_template_part', 'custom_text_below_title' );
<?php
function required_givewp_mailchimp() { ?>
<script>
jQuery("input[name=give_mailchimp_signup]").prop("required", true);
</script>
<?php }
add_action( 'give_donation_form_after_submit', 'required_givewp_mailchimp' );
@matheuswd
matheuswd / givewp-create-account-checked.php
Last active April 8, 2021 15:40
This code forces an account creation for GiveWP when account creation is enabled
<?php
function my_checked_create_account() { ?>
<script>
jQuery("input[name=give_create_account]").prop("checked", true);
</script>
<?php }
add_action( 'give_donation_form_after_submit', 'my_checked_create_account' );
@matheuswd
matheuswd / translate-periods.php
Last active April 8, 2021 15:40
A local translation snippet specifically for the Donor's choice checkbox. Change 'YOUR TEXT HERE' to your desired text.
<?php
/**
* A local translation snippet specifically for the Donor's choice checkbox. Change 'YOUR TEXT HERE' to your desired text.
*
* @param $translations
* @param $text
* @param $domain
*
* @return string
*/
@matheuswd
matheuswd / limit-zip-code-size.php
Created December 8, 2020 11:43
Limits the ZIP Code field for 5 digits only
<?php
function my_give_limit_zip_length() { ?>
<script>
let zipcodes = document.querySelectorAll('input#card_zip');
zipcodes.forEach(zipcode => zipcode.setAttribute('maxlength', 5));
</script>
<?php }
@matheuswd
matheuswd / change-givewp-text-recurring.php
Last active April 8, 2021 15:42
This code changes the _Make this donation_ string
<?php
function my_give_text_switcher( $translation, $text, $domain ) {
if ( 'give-recurring' === $domain ) {
switch ( $translation ) {
/*
* Changes the "Make this Donation [monthly/weekly/daily]" text for
* a donor's choice recurring checkbox.
*/
case 'Make this donation %1$s' :
$translation = __( 'Make this membership automatically renew %1$s', 'give' );
@matheuswd
matheuswd / implement-recaptcha-by-form.php
Last active April 8, 2021 15:42
This code allows you to implement reCAPTCHA by form
<?php
/**
* Implementing Google's ReCaptcha on specific GiveWP Forms
*
* To effectively use this snippet, please do the following:
* 1. Get your Google ReCAPTCHA API Key here: https://www.google.com/recaptcha/
* 2. In each function and action, replace "_myprefix_" with your own custom prefix
* 3. Put your "Secret Key" where it says "MYSECRETKEY" in the $recaptcha_secret_key string
* 4. Put your "Site Key" where it says "MYSITEKEY" in TWO areas below
*/
<?php
// Changes the format for the amount raised
function change_amount_raised_goal_decimal($form_currency) {
$income_format_args = array(
'sanitize' => false,
'currency' => $form_currency,
'decimal' => true,
);
}
@matheuswd
matheuswd / default-gift-aid-to-yes.php
Created September 10, 2020 19:58
Makes the Gift Aid checkbox to be checked by default
<?php
function gift_aid_default_checked() { ?>
<script>
jQuery("input[name=give_gift_aid_accept_term_condition]").prop("checked", true);
</script>
<?php }
add_action( 'give_donation_form_after_submit', 'gift_aid_default_checked' );