PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.11.1
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.11.1
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / shortcodes / class-charitable-donate-button-shortcode.php

class-charitable-donate-button-shortcode.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.11.1, at includes/shortcodes/class-charitable-donate-button-shortcode.php

72 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Donate Button shortcode class.
4 *
5 * @package Charitable/Shortcodes/Donate_Button
6 * @author David Bisset
7 * @copyright Copyright (c) 2023, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.8.2
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Charitable_Donate_Button_Shortcode' ) ) :
18
19 /**
20 * Charitable_Donate_Button_Shortcode class.
21 *
22 * @since 1.8.2
23 */
24 class Charitable_Donate_Button_Shortcode {
25
26 /**
27 * The callback method for the doante button shortcode.
28 *
29 * This receives the user-defined attributes and passes the logic off to the class.
30 *
31 * @since 1.8.2
32 * @version 1.8.10.2
33 *
34 * @param array $atts User-defined shortcode attributes.
35 * @return string
36 */
37 public static function display( $atts = array() ) {
38 $defaults = array(
39 'url' => charitable_get_current_url(),
40 'label' => __( 'Donate', 'charitable' ),
41 'type' => 'button', // can also be 'link'.
42 'css' => 'charitable-button',
43 'new_tab' => false,
44 'campaign' => 0,
45 );
46
47 if ( isset( $atts['campaign'] ) ) {
48 $campaign_id = (int) $atts['campaign'];
49 if ( $campaign_id > 0 ) {
50 $atts['url'] = charitable_get_permalink( 'campaign_donation', array( 'campaign_id' => $campaign_id ) );
51 }
52 }
53
54 $args = shortcode_atts( $defaults, $atts, 'charitable_donate_button' );
55
56 ob_start();
57
58 charitable_template( 'shortcodes/donate-button.php', $args );
59
60 /**
61 * Filter the output of the login shortcode.
62 *
63 * @since 1.8.2
64 *
65 * @param string $content Shortcode output.
66 */
67 return apply_filters( 'charitable_donate_button_shortcode', ob_get_clean() );
68 }
69 }
70
71 endif;
72