Skip to content

Instantly share code, notes, and snippets.

View New0's full-sized avatar

Nicolas Figueira New0

View GitHub Profile
@New0
New0 / caldera-label-left.css
Last active July 3, 2017 18:56
Caldera Forms label on left of input
/************* Modern version for browsers with flex support https://caniuse.com/#feat=flexbox ********************/
.caldera-grid .form-group {
display: flex;
}
.caldera-grid .form-group label {
width: 25%; /*Set to the width needed by the text of your label */
}
.caldera-grid .form-group > div{
width: 75%; /*Set to the width needed by the text of your input */
}
@New0
New0 / cf-description-above-input.css
Last active July 6, 2017 08:46
Use CSS flex to display the description field above the input filed in Caldera Forms (Flex support: https://caniuse.com/#feat=flexbox)
/** Add the class desc-above to the field **/
.form-group.cf-desc-above > div {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column-reverse;
flex-direction: column-reverse;
}
.caldera-grid .form-group.cf-desc-above .checkbox,
.caldera-grid .form-group.cf-desc-above .radio {
margin-top: -5px;
@New0
New0 / ds_affiliate_manager_action.php
Last active July 17, 2017 14:06
Send affiliate manager plugin information after Direct Stripe Payment ( UNTESTED )
function my_direct_stripe_payment_completed( $charge_id, $post_id, $button_id, $user_id ) {
$charge = \Stripe\Charge::retrieve($charge_id);
$user = get_user_by('id', $user_id);
WPAM_Logger::log_debug('Stripe Payments Integration – asp_stripe_payment_completed hook triggered.');
//Required Parameters
$amount = $charge->amount;
$purchaseAmount = number_format( $amount , '2' );//Sale Amount
$order_id = $charge->id;//Transaction ID
$buyer_email = $user->user_email;//Email address
@New0
New0 / ds_update_source.php
Last active August 12, 2017 20:40
WAIT FOR UPDATE TO 2.1.0 DIrect Stripe Update Customer's Card Number in Stripe
add_filter( 'ds_charge_action_payment', function( $action ) {
$action = '\Stripe\Customer::retrieve';
return $action;
}, 10);
add_filter( 'ds_charge_content_payment', function( $content, $token, $stripe_id ) {
@New0
New0 / ds-shortcode-in-template.php
Created August 17, 2017 14:09
Insertion of Direct Stripe shortcode in template files
//Allow the Direct Stripe assets to be enqueued in chosen pages
add_action( 'wp', function () {
global $post;
$shortcodePageSlugs = array(
'hello-world',
'second-page-slug'
);
if( $post )
@New0
New0 / keybase.md
Created August 27, 2017 16:56
Keybase.md

Keybase proof

I hereby claim:

  • I am new0 on github.
  • I am newo (https://keybase.io/newo) on keybase.
  • I have a public key whose fingerprint is 0CB0 252B D558 F443 6494 8D2F B6B1 6DAF 7034 C7CE

To claim this, I am signing this object:

@New0
New0 / direct_stripe_success_user_email_content.php
Created September 7, 2017 16:32
direct_stripe_success_user_email_content filter hook example
add_filter( 'direct_stripe_success_user_email_content', function( $message, $token, $amount, $currency, $email_address, $description, $user_id, $button_id){
$message = 'User ' . $email_address . ' have been charged ' . $amount . $currency . ' for ' . $description;
return $message;
}, 10, 8 );
@New0
New0 / hide-cf-label.css
Created September 11, 2017 18:25
Hide Caldera Forms options from a Checkbox field generated by/for setting Mailchimp Groups.
label[for="fld_1774775_1_0"] { /* Replace fld_1774775_1_0 with the actual label "for" parameter */
display: none;
}
@New0
New0 / ds_send_new_user_credentials.php
Created September 17, 2017 09:15
Send login credentials to user after sucessful Direct Stripe notification
add_action( 'direct_stripe_before_success_redirection', function( $chargeID, $post_id, $button_id, $user_id ) {
wp_new_user_notification( $user_id, null, 'both' );
}, 10, 4 );
@New0
New0 / DS-no-margins.css
Created September 28, 2017 16:14
Remove margin arround Direct Stripe button
.direct-stripe { margin: 0; }