- This topic has 0 replies, 1 voice, and was last updated 5 months, 3 weeks ago by .
Viewing 0 reply threads
Viewing 0 reply threads
- You must be logged in to reply to this topic.
Welcome › mkmcst community Forum › Web programming › WordPress › Random wordpress › Add a PayPal Donation Button
function paypal_donation_shortcode($atts) {
// Extract the attributes
$atts = shortcode_atts(
array(
'business' => 'your-paypal-email@example.com',
'amount' => '0',
'currency_code' => 'USD',
),
$atts,
'paypal_donation'
);
// Build the HTML form string
$output = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_donations" />
<input type="hidden" name="business" value="' . esc_html($atts['business']) . '" />
<input type="hidden" name="amount" value="' . esc_html($atts['amount']) . '" />
<input type="hidden" name="currency_code" value="' . esc_html($atts['currency_code']) . '" />
<input type="submit" value="Donate" />
</form>';
// Return the HTML form
return $output;
}
add_shortcode('paypal_donation', 'paypal_donation_shortcode');