Last active
June 26, 2019 09:31
-
-
Save JRyven/53d6282949098b4cc95669e4f9a40cf0 to your computer and use it in GitHub Desktop.
Use a nicer button to place PayPal donation buttons on your site.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* * | |
* Simple PayPal Button Shortcode | |
* @Jryven boilingpotmeida.com | |
* | |
* Use: | |
* Get a PayPal provided donation button. | |
* Find the line: <input type="hidden" name="hosted_button_id" value="**************"> | |
* Enter the code within the value parameter into the shortcode via the id parameter | |
* Enter the text for the button into the shortcode via the text parameter | |
* [paypal id="**************" text="Button Text"] | |
* */ | |
add_shortcode( 'paypal', 'paypal_custom_donate_button' ); | |
function paypal_custom_donate_button($atts) { | |
$a = shortcode_atts( | |
array( | |
'id' => '', | |
'text' => 'Donate', | |
), | |
$atts | |
); | |
return' | |
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> | |
<input type="hidden" name="cmd" value="_s-xclick"> | |
<input type="hidden" name="hosted_button_id" value="'.$atts['id'].'"> | |
<input type="submit" border="0" name="submit" value="'.$atts['text'].'"> | |
</form> | |
'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment