Add PayPal Donate button to your Wordpress Website


/ Published in: PHP
Save to your folder(s)

Add this snippet to the functions.php to add 'Donate' Button on your Wordpress Website.


Copy this code and paste it in your HTML
  1. // paypal donate button
  2. function cwc_donate_shortcode( $atts ) {
  3. extract(shortcode_atts(array(
  4. 'text' => 'Make a donation',
  5. 'account' => 'REPLACE ME',
  6. 'for' => '',
  7. ), $atts));
  8.  
  9. global $post;
  10.  
  11. if (!$for) $for = str_replace(" ","+",$post->post_title);
  12.  
  13. return '<a class="donateLink" href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business='.$account.'&item_name=Donation+for+'.$for.'">'.$text.'</a>';
  14.  
  15. }
  16. add_shortcode('donate', 'cwc_donate_shortcode');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.