Add a PayPal Donation Button

Welcome mkmcst community Forum Web programming WordPress Random wordpress Add a PayPal Donation Button

Viewing 0 reply threads
  • Author
    Posts
    • #8858
      Michael Mc
      Keymaster
      @mkmcst
      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');
Viewing 0 reply threads
  • You must be logged in to reply to this topic.