PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
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 1.7.0.9 All 211 releases
← All changes | includes/forms/class-charitable-donation-amount-form.php +48 -8 1.7.0.3 → 1.8.13 View file →
@@ -3,9 +3,9 @@
3 3 * Donation amount form model class.
4 4 *
5 5 * @package Charitable/Classes/Charitable_Donation_Amount_Form
6 6 * @author David Bisset
7 - * @copyright Copyright (c) 2022, WP Charitable LLC
7 + * @copyright Copyright (c) 2023, WP Charitable LLC
8 8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9 * @since 1.0.0
10 10 * @version 1.5.0
11 11 */
@@ -24,23 +24,39 @@
24 24 */
25 25 class Charitable_Donation_Amount_Form extends Charitable_Donation_Form implements Charitable_Donation_Form_Interface {
26 26
27 27 /**
28 + * The current campaign.
29 + *
30 + * @since 1.0.0
31 + *
28 32 * @var Charitable_Campaign
29 33 */
30 34 protected $campaign;
31 35
32 36 /**
37 + * Form fields.
38 + *
39 + * @since 1.0.0
40 + *
33 41 * @var array
34 42 */
35 43 protected $form_fields;
36 44
37 45 /**
46 + * Nonce action.
47 + *
48 + * @since 1.0.0
49 + *
38 50 * @var string
39 51 */
40 52 protected $nonce_action = 'charitable_donation_amount';
41 53
42 54 /**
55 + * Nonce name.
56 + *
57 + * @since 1.0.0
58 + *
43 59 * @var string
44 60 */
45 61 protected $nonce_name = '_charitable_donation_amount_nonce';
46 62
@@ -46,8 +62,10 @@
46 62
47 63 /**
48 64 * Action to be executed upon form submission.
49 65 *
66 + * @since 1.0.0
67 + *
50 68 * @var string
51 69 */
52 70 protected $form_action = 'make_donation_streamlined';
53 71
@@ -115,9 +133,10 @@
115 133
116 134 /**
117 135 * Redirect to payment form after submission.
118 136 *
119 - * @since 1.0.0
137 + * @since 1.0.0
138 + * @version 1.8.8.6
120 139 *
121 140 * @param int $campaign_id The campaign we are donating to.
122 141 * @param int $amount The donation amount.
123 142 * @return void
@@ -128,17 +147,37 @@
128 147 }
129 148
130 149 $redirect_url = charitable_get_permalink( 'campaign_donation_page', array( 'campaign_id' => $campaign_id ) );
131 150
132 - if ( 'same_page' == charitable_get_option( 'donation_form_display', 'separate_page' ) ) {
151 + if ( 'same_page' == charitable_get_option( 'donation_form_display', 'separate_page' ) ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
133 152 $redirect_url .= '#charitable-donation-form';
134 153 }
135 154
136 155 $redirect_url = apply_filters( 'charitable_donation_amount_form_redirect', $redirect_url, $campaign_id, $amount );
137 156
138 - wp_redirect( esc_url_raw( $redirect_url ) );
157 + // Check if URL is external and add to allowed hosts if needed.
158 + $parsed_url = wp_parse_url( $redirect_url );
159 + if ( ! empty( $parsed_url['host'] ) ) {
160 + $redirect_host = $parsed_url['host'];
161 + $site_host = wp_parse_url( home_url(), PHP_URL_HOST );
139 162
140 - die();
163 + // If redirecting to external host, add it to allowed redirect hosts.
164 + if ( $redirect_host !== $site_host ) {
165 + add_filter(
166 + 'allowed_redirect_hosts',
167 + function( $hosts ) use ( $redirect_host ) {
168 + if ( ! in_array( $redirect_host, $hosts, true ) ) {
169 + $hosts[] = $redirect_host;
170 + }
171 + return $hosts;
172 + }
173 + );
174 + }
175 + }
176 +
177 + wp_safe_redirect( esc_url_raw( $redirect_url ) );
178 +
179 + exit();
141 180 }
142 181
143 182 /**
144 183 * Render the donation form.
@@ -160,11 +199,12 @@
160 199
161 200 charitable_template(
162 201 'donation-form/form-donation.php',
163 202 array(
164 - 'campaign' => $this->get_campaign(),
165 - 'form' => $this,
166 - 'form_id' => 'charitable-donation-amount-form',
203 + 'campaign' => $this->get_campaign(),
204 + 'form_template' => $this->get_form_template(),
205 + 'form' => $this,
206 + 'form_id' => 'charitable-donation-amount-form',
167 207 )
168 208 );
169 209 }
170 210 }