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 / donors.php
Last active November 7, 2015 20:53
Charitable donor widget with organisation & website
<?php
/**
* This template lets you override the Donors widget output in Charitable, by adding the donor
* name and organisation to the widget.
*
* Save it to yourtheme/charitable/widgets/donors.php
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@ericnicolaas
ericnicolaas / charitable-custom-styles-cache-delete.php
Created December 3, 2015 02:40
Delete custom styles cache in Charitable -- for testing purposes
/**
* Add custom styles to the <head> section.
*
* This is used on the wp_head action.
*
* @return void
* @since 1.2.0
*/
function charitable_template_custom_styles() {
if ( ! apply_filters( 'charitable_add_custom_styles', true ) ) {
@ericnicolaas
ericnicolaas / shortcode-profile.php
Created December 3, 2015 11:52
Save custom profile fields.
<?php
/**
* Process shortcode submission.
*
* @since Astoundify Crowdfunding 0.8
*
* @return void
*/
function atcf_shortcode_profile_info_process() {
global $edd_options, $post;
@ericnicolaas
ericnicolaas / Responsive threaded comments
Last active December 18, 2015 16:29
This is a tidy little setup for responsive threaded comments. The class names here reflect a standard Wordpress comment form, but you can tailor them to your needs. The use case for this is when your comments feature the commenter's avatar on the left, which is an explicit width (in this case, 70px). On larger windows, we want the threaded comme…
/*
The baseline. This will be applied to any browser that does not
support calc, and any browser that is smaller than 800px wide
*/
.comments-list,
.comment {
width: 100%;
}
.comments-section .children {
@ericnicolaas
ericnicolaas / Charitable-Roadmap.php
Last active December 30, 2015 23:50
Charitable Roadmap - what happened in 2015 and what's to come in 2016.
<?php
/**
* After more than a year in development, we finally
* launched Charitable on August 19.
*
* @see https://www.wpcharitable.com/charitable-now-available-on-wordpress-org/
*/
did_action( 'charitable_launch' );
/**
@ericnicolaas
ericnicolaas / function.php
Created December 31, 2015 03:10
Add Charitable profile fields to admin user profiles
<?php
function pp_add_user_profile_fields( $user ) {
$skip = array( 'first_name', 'last_name', 'user_email', 'description' );
$switch_keys = array(
'address' => 'donor_address',
'address_2' => 'donor_address_2',
'city' => 'donor_city',
'state' => 'donor_state',
@ericnicolaas
ericnicolaas / gist:ace81509b63edaaa1caa
Created January 6, 2016 00:34
Appthemer Crowdfunding - Automatically approve campaigns
/**
* This function will automatically set the status of a newly
* submitted campaign to 'publish'.
*/
function franklin_auto_approve_campaign( $campaign, $submitted, $status ) {
if ( 'pending' == $status ) {
wp_update_post( array(
'ID' => $campaign,
'post_status' => 'publish'
@ericnicolaas
ericnicolaas / gist:cfbd71a12a116eda5be3
Created January 28, 2016 07:13
4-column campaign grid
.campaign-grid-4 .campaign {
width: 23.5%;
}
.campaign-grid-4 .campaign:nth-child(4n+4) {
margin-right: 0;
}
@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' );