# charitable/1.8.11.3/includes/shortcodes/class-charitable-donate-button-shortcode.php

Charitable – Donation &amp; Fundraising Platform (Donation Forms, Recurring Donations &amp; Fundraising Campaigns), version 1.8.11.3. 72 lines.

- Page: https://pluginprobe.com/plugins/charitable/1.8.11.3/code/includes/shortcodes/class-charitable-donate-button-shortcode.php
- Raw: https://pluginprobe.com/plugins/charitable/1.8.11.3/raw/includes/shortcodes/class-charitable-donate-button-shortcode.php
- Modified: 2026-03-27T02:08:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/charitable/1.8.11.3/code/includes/shortcodes/class-charitable-donate-button-shortcode.php#L10-L20`.

```php
<?php
/**
 * Donate Button shortcode class.
 *
 * @package   Charitable/Shortcodes/Donate_Button
 * @author    David Bisset
 * @copyright Copyright (c) 2023, WP Charitable LLC
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since     1.8.2
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'Charitable_Donate_Button_Shortcode' ) ) :

	/**
	 * Charitable_Donate_Button_Shortcode class.
	 *
	 * @since 1.8.2
	 */
	class Charitable_Donate_Button_Shortcode {

		/**
		 * The callback method for the doante button shortcode.
		 *
		 * This receives the user-defined attributes and passes the logic off to the class.
		 *
		 * @since  1.8.2
		 * @version 1.8.10.2
		 *
		 * @param  array $atts User-defined shortcode attributes.
		 * @return string
		 */
		public static function display( $atts = array() ) {
			$defaults = array(
				'url'      => charitable_get_current_url(),
				'label'    => __( 'Donate', 'charitable' ),
				'type'     => 'button', // can also be 'link'.
				'css'      => 'charitable-button',
				'new_tab'  => false,
				'campaign' => 0,
			);

			if ( isset( $atts['campaign'] ) ) {
				$campaign_id = (int) $atts['campaign'];
				if ( $campaign_id > 0 ) {
					$atts['url'] = charitable_get_permalink( 'campaign_donation', array( 'campaign_id' => $campaign_id ) );
				}
			}

			$args = shortcode_atts( $defaults, $atts, 'charitable_donate_button' );

			ob_start();

			charitable_template( 'shortcodes/donate-button.php', $args );

			/**
			 * Filter the output of the login shortcode.
			 *
			 * @since 1.8.2
			 *
			 * @param string $content Shortcode output.
			 */
			return apply_filters( 'charitable_donate_button_shortcode', ob_get_clean() );
		}
	}

endif;

```
