Skip to content

Instantly share code, notes, and snippets.

View New0's full-sized avatar

Nico Figueira Mahe New0

View GitHub Profile
@New0
New0 / ds-plan-based-on-donation-amount.php
Last active January 9, 2019 12:02
Subscribe a user to a plan based on a donation amount with Direct Stripe.
<?php
/*
* Plugin Name: DS custom code
* Description: Create subscriptions based on donation amount
* Author: Nicolas Figueira
* Version: 0.0.1
*
* To use this as a plugin :
* – Edit the code with the css ID you set for your button
* – Zip the file
@New0
New0 / ds-disable-gutenberg-block.php
Last active January 19, 2019 17:48
Example use of filter to disable the Gutenberg block of Direct Stripe
<?php
/**
* Plugin Name: Disable Direct Stripe Gutenberg Block
* Description: Disable Direct Stripe Gutenberg Block
* Version: 1.0.0
* Author: Nicolas Figueira
* Author URI: https://newo.me
*
* This can be loaded as a plugin -> Download ZIP and from the WordPress adin go to Plugins -> Add Plugin and Click the Upload Plugin button to upload this zip and activate the plugin
*
@New0
New0 / cf-disabled-options.php
Last active January 27, 2019 15:01
Caldera Forms. Add disabled attribute to options in Checkbox, Dropdown and Select 2 fields
<?php
//Example of how to use a Disabled attribute for options in Checkbox, dropdown or select 2 fields
add_filter( 'caldera_forms_render_get_field', function( $field ) {
if( 'fld_4425558' === $field[ 'ID' ] ){ //Field ID => 'fld_4425558'
$field[ 'config' ][ 'option' ]['opt1996332']['disabled'] = true; // Option ID => 'opt1996332'
} else if( 'fld_7668742' === $field[ 'ID' ] ){ //Field ID => 'fld_7668742'
$field[ 'config' ][ 'option' ]['opt3137985']['disabled'] = true; // Option ID => 'opt3137985'
} else if( 'fld_381620' === $field[ 'ID' ] ){ //Field ID => 'fld_381620'
$field[ 'config' ][ 'option' ]['opt1172954']['disabled'] = true; // Option ID => 'opt1172954'
}
@New0
New0 / ds-input-coupon.php
Last active May 23, 2019 10:18
Draft for Direct Stripe input coupons field
<?php
/*
* Plugin Name: Direct Stripe input coupons
* Author: Nicolas Figueira
* Description: Allow users to use promotional coupons with Direct Stripe
* Version: 0.0.1
* Text Domain: ds-coupons
*
* This is not production ready
* It will add an input field for coupon with CSS ID button_with_coupon
@New0
New0 / ds-currency-code.php
Last active February 28, 2019 08:50
Add currency code after Direct Stripe donation input field
<?php
/*
* Plugin Name: DS currency code
* Description: Add currency code after Direct Stripe donation input field
* Version: 0.0.1
* Author: Nicolas Figueira
* Author URI: https://newo.me
*/
add_filter( 'direct_stripe_donation_input', function( $direct_stripe_donation_input, $instance, $button_id ) {
if( $button_id === 'euros-button' ){ // Edit with the CSS ID of button in euros
@New0
New0 / ds-charge-metadata.php
Last active March 6, 2019 14:15
Add metadata parameter to Direct Stripe charge
<?php
/*
* Add metadata parameter to the Direct Stripe button
*/
add_action( 'direct_stripe_charge_data', function($data, $user, $token, $button_id) {
$data[] = array(
"metadata" => array(
"key" => "value"
)
@New0
New0 / ds-spinner.php
Last active March 9, 2019 17:09
Change Direct Stripe spinner animation
<?php
/* Custom Direct Stripe spinner animation */
add_filter( 'direct_stripe_processing_transaction_spinner', function( $html, $begin, $end, $text, $dots, $instance){
return '<div id="loadingDS-' . $instance . '" class="loadingDS-container loader" style="display:none;"></div>';
}, 10, 6);
@New0
New0 / ds-cross-border-classification.php
Last active March 31, 2019 09:52
Add-on for Direct Stripe in order to declare the Cross Border Classification as metadata in payments and subscriptions
<?php
/*
* Plugin Name: DS Cross Border Classification
* Author: Nicolas Figueira
* Author URI: https://newo.me
* Description: Declare Cross Border Classification during Direct Stripe transactions
* Plugin URI: https://gist.github.com/New0/69100a1d6ba749c0e15d03cef9a4481b/edit
* Version: 1.0.0
*/
function ds_cbc($data, $user, $token, $button_id) {
@New0
New0 / cf-entries-as-user-meta-data.php
Created June 11, 2019 11:07
Save CF new form entries as user meta data and display a list of these entries linked to a modal form filled with entry
<?php
/*
* Plugin Name: CF entries as user meta data
* Description: Save entries as USER metadata, display list of entries for a user to see / edit them
* Author: New0
*/
/**
* On form submit, associate new entries to USER
*/
<?php
/**
* Change Caldera Forms Stripe Payment Amount
*/
add_filter( 'cf_stripe_charge_args', function( $args, $config, $form ){
//change charge amounts to $10. Amount is in cents.
$args[ 'amount' ] = 1000;
return $args;
}, 10, 4 );