PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.11.3
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.11.3
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-my-donations-shortcode.php

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

118 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * My Donations shortcode class.
4 *
5 * @package Charitable/Shortcodes/My Donations
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.4.0
10 * @version 1.6.45
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if ( ! class_exists( 'Charitable_My_Donations_Shortcode' ) ) :
19
20 /**
21 * Charitable_My_Donations_Shortcode class.
22 *
23 * @since 1.4.0
24 */
25 class Charitable_My_Donations_Shortcode {
26
27 /**
28 * The callback method for the campaigns shortcode.
29 *
30 * This receives the user-defined attributes and passes the logic off to the class.
31 *
32 * @since 1.4.0
33 *
34 * @param array $atts User-defined shortcode attributes.
35 * @return string
36 */
37 public static function display( $atts ) {
38 $defaults = array(
39 'hide_login' => false,
40 );
41
42 $args = shortcode_atts( $defaults, $atts, 'charitable_my_donations' );
43
44 ob_start();
45
46 /* If the user is logged out, show the login form. */
47 if ( ! is_user_logged_in() ) {
48
49 if ( false === $args['hide_login'] ) {
50 $args['redirect'] = charitable_get_current_url();
51
52 echo Charitable_Login_Shortcode::display( $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
53 }
54
55 return ob_get_clean();
56 }
57
58 /* If the user is logged in, show the my donations template. */
59 $user = charitable_get_user( get_current_user_id(), true );
60 $donor_id = $user->get_donor_id();
61
62 if ( false === $donor_id ) {
63 $donations = array();
64 $query_args = array();
65 } else {
66 $query_args = array(
67 'output' => 'posts',
68 'orderby' => 'date',
69 'order' => 'DESC',
70 'number' => -1,
71 'donor_id' => $donor_id,
72 );
73
74 if ( ! $user->is_verified() ) {
75 $query_args['user_id'] = $user->ID;
76
77 if ( array_key_exists( 'charitable_action', $_GET ) && 'verify_email' === $_GET['charitable_action'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
78 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display/routing parameter
79 $redirect = array_key_exists( 'redirect_url', $_GET ) ? esc_url_raw( wp_unslash( $_GET['redirect_url'] ) ) : false;
80 $message = sprintf(
81 /* translators: %s: email verification link */
82 __( 'We have sent you an email to confirm your email address. Haven\'t received the email? <a href="%s">Click here to send it again.</a>', 'charitable' ),
83 esc_url_raw( charitable_get_email_verification_link( $user, $redirect, true ) )
84 );
85 } else {
86 $message = sprintf(
87 /* translators: %s: email verification link */
88 __( '<a href="%s">Confirm your email address</a> to access your full donation history.', 'charitable' ),
89 esc_url( charitable_get_email_verification_link( $user, charitable_get_current_url(), true ) )
90 );
91 }
92
93 charitable_get_notices()->add_error( $message );
94 }
95
96 $donations = new Charitable_Donations_Query( $query_args );
97 }
98
99 $args['donations'] = $donations;
100 $args['user'] = $user;
101
102 charitable_template( 'shortcodes/my-donations.php', $args );
103
104 /**
105 * Filter the output of the shortcode.
106 *
107 * @since 1.4.0
108 *
109 * @param string $output The default output.
110 * @param array $args The view arguments.
111 * @param array $args The query arguments.
112 */
113 return apply_filters( 'charitable_my_donations_shortcode', ob_get_clean(), $args, $query_args );
114 }
115 }
116
117 endif;
118