Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom plugin to filter Direct Stripe button markup
<?php
/*
* Plugin Name: Direct Stripe Custom Button
*/
//Set Styles settings not to use custom or Stripe styles
//Filters added in Direct Stripe 2.1.5 ( List of Actions and filters https://newo.me/direct-stripe-actions-and-filters-hooks/ )
add_filter('direct_stripe_div_before', function( $div, $button_id, $class ){
if( $button_id !== 'MyButtonID'){ //Set a Button ID in the Button Settings to target only this Button
return $div;
}
$div = '<div class="thrv_wrapper thrv-button ' . $class .'" data-css="tve-u-16446cb2f5e" data-tcb_hover_state_parent="" data-button-style="rounded">';
return $div;
}, 10, 3);
add_filter('direct_stripe_button', function( $button, $instance, $button_id, $class ){
if( $button_id !== 'MyButtonID'){ //Set a Button ID in the Button Settings to target only this Button
return $button;
}
$button = '<span class="tcb-button-texts"><span data-id="' . $instance .'" class="tcb-button-text thrv-inline-text ' . $class .'" data-css="tve-u-16446c6de11">Sign Me Up!</span></span>';
return $button;
}, 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment