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 / gist:e08425a5738bb1858b82
Last active February 3, 2016 23:30
Create select field in Charitable
$fields[ 'national_id_number' ] = array(
'label' => __( 'National ID Number', 'your-namespace' ),
'type' => 'select',
'options' => array(
'val1' => __( 'Label 1', 'your-namespace' ),
'val2' => __( 'Label 2', 'your-namespace' )
),
'priority' => 24,
'value' => $form->get_user_value( 'donor_national_id_number' ),
'required' => true,
@ericnicolaas
ericnicolaas / gist:4d3c6d684b8e543b250e
Created February 8, 2016 11:35
Change "length" field label in campaign submission form
<?php
function ed_change_length_label( $fields ) {
$fields[ 'length' ][ 'label' ] = __( 'Length (# of days)', 'your-namespace' );
return $fields;
}
add_filter( 'charitable_campaign_submission_campaign_fields', 'ed_change_length_label' );
@ericnicolaas
ericnicolaas / gist:2bd145e9d3ca7a293a0d
Last active February 20, 2016 01:54
Fix a bug in Charitable 1.3.1 that causes comments to be disabled on all post types
function ed_charitable_disable_comments( $open, $post_id ) {
/* If open is already false, just hit return. */
if ( ! $open ) {
return $open;
}
if ( charitable_is_page( 'campaign_donation_page' )
|| charitable_is_page( 'campaign_widget_page' )
|| charitable_is_page( 'donation_receipt_page' )
|| charitable_is_page( 'donation_processing_page' ) ) {
<?php
/**
* Collect the donor's Dedication wishes in the donation form.
*
* @param array[] $fields
* @param Charitable_Donation_Form $form
* @return array[]
*/
function ed_collect_dedication( $fields, Charitable_Donation_Form $form ) {
@ericnicolaas
ericnicolaas / submit-campaign-buttons.php
Created February 25, 2016 22:14
Remove Save & Preview button from Ambassadors campaign submission form
<?php
if ( ! $form->is_final_page() ) {
return $form->get_page_submit_button();
}
if ( false === $form->get_campaign() || 'draft' == $form->get_campaign()->post_status ) {
$primary_text = apply_filters( 'charitable_ambassadors_form_submission_buttons_primary_new_text', __( 'Submit Campaign', 'charitable-ambassadors' ), $form );
}
else {
@ericnicolaas
ericnicolaas / gist:34145222159f6525f6e5
Created March 7, 2016 12:07
Fix a bug where emails are not sent in certain cases in Charitable 1.3.3
function ed_set_correct_email_headers( $headers, $email ) {
$from_address = charitable_get_option( 'email_from_email', get_option('admin_email') );
$headers = "From: {$email->get_from_name()} <{$from_address}>\r\n";
$headers .= "Reply-To: {$from_address}\r\n";
$headers .= "Content-Type: {$email->get_content_type()}; charset=utf-8\r\n";
return $headers;
}
@ericnicolaas
ericnicolaas / charitable-new-campaign-notification.php
Last active March 16, 2016 07:08
Send New Campaign Notification
<?php
/**
* Plugin Name: Charitable - Send New Campaign Notificaiton
* Plugin URI: https://gist.github.com/ericnicolaas/de776cdd17e3ee333fe5/edit
* Description: Correctly send the New Campaign Notification email after a campaign is submitted.
* Version: 0.1
* Author: WP Charitable
* Author URI: https://wpcharitable.com/
*/
class Charitable_Ambassadors_Email_New_Campaign extends Charitable_Email {
/**
* @var string
*/
CONST ID = 'new_campaign';
...
//////////////////////
// Find this:
class Charitable_Ambassadors_Email_New_Campaign extends Charitable_Email {
/**
* @var string
*/
CONST ID = 'new_campaign';
@ericnicolaas
ericnicolaas / gist:545ed821040d5b77883b
Created March 16, 2016 04:49
Responsive styling for [campaigns] shortcode in Charitable
@media only screen and (max-width: 800px) {
.campaign-loop.campaign-grid .campaign.hentry {
width: 100% !important;
}
}