Skip to content

Instantly share code, notes, and snippets.

View alexwcoleman's full-sized avatar

Alex Coleman alexwcoleman

View GitHub Profile
@alexwcoleman
alexwcoleman / google-msf.php
Created September 7, 2023 17:22
Google Fonts in GiveWP Multi Step Form
<?php
/**
* The multi-Step form template and the donor dashboard load in an iframe, which prevents theme styles from interfering with their styles.
* To style them, use this PHP snippet to add inline styles. Replace lines 16-26 with your custom styles.
*/
function override_iframe_template_styles_with_inline_styles_google() {
wp_enqueue_style( 'give-google-fonts', 'https://fonts.googleapis.com/css2?family=Nunito:wght@200&display=swap', false );
@alexwcoleman
alexwcoleman / shortcode-donor-wall.php
Created August 29, 2023 21:14
First name only in the GiveWP donor wall shortcode
<?php
/**
* This template is used to display the donation grid with [give_donor_wall]
*/
// Exit if accessed directly.
if (!defined('ABSPATH')) {
exit;
}
@alexwcoleman
alexwcoleman / add-wp-user.php
Created August 1, 2023 22:10
Add WP User via PHP
<?php
// Create an mu-plugins/ directory in your site’s wp-content/ directory.
// Create a new file in the wp-content/mu-plugins/ directory you created and name it anything you want. Something like create-admin-user.php would work nicely.
// Copy this code snippet and paste it into the file you just created:
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
@alexwcoleman
alexwcoleman / stripe-pass-custom-meta-for-payments.php
Created June 30, 2023 21:13 — forked from rickalday/stripe-pass-custom-meta-for-payments.php
Pass custom field data to Stripe when payment is processed.
<?php
function give_stripe_custom_payment_meta( $charge_args ) {
// Sanitize the input posted data to the form.
$posted_data = give_clean( filter_input_array( INPUT_POST ) );
//Uncomment the followign line to print the $posted_data array to the error log
//error_log(print_r($posted_data, TRUE));
//Get form ID
@alexwcoleman
alexwcoleman / donor-dashboard-hide-adress-update.css
Last active November 18, 2022 15:45
Hiding GiveWP Donor Dashboard Adress Update
.give-donor-dashboard-desktop-layout__tab-content .give-donor-dashboard-avatar-control ~ .give-donor-dashboard-button ~ .give-donor-dashboard-heading,
.give-donor-dashboard-desktop-layout__tab-content .give-donor-dashboard-avatar-control ~ .give-donor-dashboard-button ~ .give-donor-dashboard-divider,
.give-donor-dashboard-desktop-layout__tab-content .give-donor-dashboard-avatar-control ~ .give-donor-dashboard-button ~ .give-donor-dashboard-select-control,
.give-donor-dashboard-desktop-layout__tab-content .give-donor-dashboard-avatar-control ~ .give-donor-dashboard-button ~ .give-donor-dashboard-text-control,
.give-donor-dashboard-desktop-layout__tab-content .give-donor-dashboard-avatar-control ~ .give-donor-dashboard-button ~ .give-donor-dashboard-field-row,
.give-donor-dashboard-desktop-layout__tab-content .give-donor-dashboard-avatar-control ~ .give-donor-dashboard-button ~ .give-donor-dashboard-button
{
display: none;
}
@alexwcoleman
alexwcoleman / more-donors.php
Created October 21, 2022 21:13
GiveWP: More donors in the Donor List at Donation >> Donors
<?php
/*
* Customize the number of Donations listed in the Donations screen
*
*/
add_filter('give_donor_table_query', 'custom_donation_list_num', 30, 1);
@alexwcoleman
alexwcoleman / custom_pdf_tag_donor_title.php
Created September 7, 2022 19:05 — forked from matheuswd/custom_pdf_tag_donor_title.php
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 );
@alexwcoleman
alexwcoleman / givewp-add-heart-to-recurring-option.php
Created August 24, 2022 16:04 — forked from jessedmatlock/givewp-add-heart-to-recurring-option.php
GiveWP - add a heart SVG icon to recurring option box that animates when a recurring donation is selected
// Inject an SVG icon (heart) into recurring selection box via JS
function override_givewp_js() {
if( ! is_admin() ) { ?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$('.give-btn.advance-btn').on('click', function(){
if( $('.give-recurring-donors-choice').length ){
$('.give-recurring-donors-choice').append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 255.96 256" data-inject-url="http://vertex2022.local/wp-content/themes/vertex-ranch-2022/assets/img/icons/solid/love.svg" class="svg-inject icon-svg icon-svg-sm solid-mono text-red me-4 mb-5 mb-md-0"><path class="fill-primary" d="M96 186.67A90.77 90.77 0 01186.63 96a89.82 89.82 0 0138.9 8.9 64.28 64.28 0 00-95.3-86L120 29.15l-10.28-10.27a64.21 64.21 0 00-90.93 0 64.56 64.56 0 000 91.06L96 187.28z"></path><path class="fill-secondary" d="M186.63 117.33A69.34 69.34 0 10256 186.67a69.41 69.41 0 00-69.37-69.34zm30.19 55.73l-30.54 37.32a8.06 8.06 0 01-5.92 3h-.27a8 8 0 01-5.84-2.53l-17.46-18.67a8 8 0 0111.7-10.95l11.2
@alexwcoleman
alexwcoleman / change-filename-prefix.php
Last active June 9, 2022 17:31 — forked from rickalday/change-filename-prefix.php
Changes the 'Receipt-' prefix of the pdf receipt filename. You can include additional information from the donation too.
function my_give_pdf_receipt_filename_changer() {
// Define required variables.
$newname = 'Test-';
$get_data = give_clean( filter_input_array( INPUT_GET ) );
$donation_id = give_get_donation_id_by_key( $get_data['_give_hash'] );
$payment_meta = give_get_payment_meta( $donation_id );
/* Possible values
$payment_meta[_give_donation_company];
@alexwcoleman
alexwcoleman / use-remote-media.php
Created June 3, 2020 21:45 — forked from kingkool68/use-remote-media.php
Check if a local file exists in the WordPress media library and if it doesn't exist, replace the URL with a different URL. Helpful when working with a local site that doesn't have all of the media downloaded as the production site. See https://localwp.com/community/t/proxying-requests-to-wp-content-uploads-to-a-production-site/15701
<?php
// Put this in wp-config.php and replace https://example.com/ with the URL of the production site.
define( 'RH_USE_REMOTE_MEDIA_URL', 'https://example.com/' );
// Put the rest of this in functions.php or a custom plugin or somewhere else.
if ( defined( 'RH_USE_REMOTE_MEDIA_URL' ) && ! empty( RH_USE_REMOTE_MEDIA_URL ) ) {
add_filter( 'wp_get_attachment_image_src', 'filter_wp_get_attachment_image_src' );
add_filter( 'wp_calculate_image_srcset', 'filter_wp_calculate_image_srcset' );
add_filter( 'wp_get_attachment_url', 'filter_wp_get_attachment_url' );
}