PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 All 257 releases
← All changes | includes/admin/emails/class-new-offline-donation-email.php +48 -32 2.3.0 → 4.18.0 View file →
@@ -5,9 +5,9 @@
5 5 * This class handles all email notification settings.
6 6 *
7 7 * @package Give
8 8 * @subpackage Classes/Emails
9 - * @copyright Copyright (c) 2016, WordImpress
9 + * @copyright Copyright (c) 2016, GiveWP
10 10 * @license https://opensource.org/licenses/gpl-license GNU Public License
11 11 * @since 2.0
12 12 */
13 13
@@ -37,30 +37,32 @@
37 37 public function init() {
38 38 // Initialize empty payment.
39 39 $this->payment = new Give_Payment( 0 );
40 40
41 - $this->load( array(
42 - 'id' => 'new-offline-donation',
43 - 'label' => __( 'New Offline Donation', 'give' ),
44 - 'description' => __( 'Sent to designated recipient(s) for a new (pending) offline donation.', 'give' ),
45 - 'has_recipient_field' => true,
46 - 'notification_status' => give_is_gateway_active( 'offline' ) ? 'enabled' : 'disabled',
47 - 'notification_status_editable' => false,
48 - 'preview_email_tags_values' => array(
49 - 'payment_method' => esc_html__( 'Offline', 'give' ),
50 - ),
51 - 'default_email_subject' => $this->get_default_email_subject(),
52 - 'default_email_message' => ( false !== give_get_option( 'new-offline-donation_email_message' ) ) ? give_get_option( 'new-offline-donation_email_message' ) : give_get_default_donation_notification_email(),
53 - 'default_email_header' => __( 'New Offline Donation!', 'give' ),
54 - 'notices' => array(
55 - 'non-notification-status-editable' => sprintf(
56 - '%1$s <a href="%2$s">%3$s &raquo;</a>',
57 - __( 'This notification is automatically toggled based on whether the gateway is enabled or not.', 'give' ),
58 - esc_url( admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=offline-donations') ),
59 - __( 'Edit Setting', 'give' )
60 - )
61 - ),
62 - ) );
41 + $this->load(
42 + array(
43 + 'id' => 'new-offline-donation',
44 + 'label' => __( 'New Offline Donation', 'give' ),
45 + 'description' => __( 'Sent to designated recipient(s) for a new (pending) offline donation.', 'give' ),
46 + 'has_recipient_field' => true,
47 + 'notification_status' => give_is_gateway_active( 'offline' ) ? 'enabled' : 'disabled',
48 + 'notification_status_editable' => false,
49 + 'preview_email_tags_values' => array(
50 + 'payment_method' => esc_html__( 'Offline', 'give' ),
51 + ),
52 + 'default_email_subject' => $this->get_default_email_subject(),
53 + 'default_email_message' => ( false !== give_get_option( 'new-offline-donation_email_message' ) ) ? give_get_option( 'new-offline-donation_email_message' ) : $this->get_default_email_message(),
54 + 'default_email_header' => __( 'New Offline Donation!', 'give' ),
55 + 'notices' => array(
56 + 'non-notification-status-editable' => sprintf(
57 + '%1$s <a href="%2$s">%3$s &raquo;</a>',
58 + __( 'This notification is automatically toggled based on whether the gateway is enabled or not.', 'give' ),
59 + esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=offline-donations' ) ),
60 + __( 'Edit Setting', 'give' )
61 + ),
62 + ),
63 + )
64 + );
63 65
64 66 add_action( 'give_insert_payment', array( $this, 'setup_email_notification' ) );
65 67 add_action( 'give_save_settings_give_settings', array( $this, 'set_notification_status' ), 10, 2 );
66 68 }
@@ -105,9 +107,9 @@
105 107 *
106 108 * @return string
107 109 */
108 110 public function get_default_email_message() {
109 - $message = __( 'Dear Admin,', 'give' ) . "\n\n";
111 + $message = __( 'Dear Admin,', 'give' ) . "\n\n";
110 112 $message .= __( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' ';
111 113 $message .= __( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n";
112 114
113 115 $message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
@@ -114,9 +116,9 @@
114 116 $message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n";
115 117
116 118 $message .= sprintf(
117 119 '<a href="%1$s">%2$s</a>',
118 - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $this->payment->ID ),
120 + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $this->payment->ID ),
119 121 __( 'Click Here to View and/or Update Donation Details', 'give' )
120 122 ) . "\n\n";
121 123
122 124 /**
@@ -243,8 +245,9 @@
243 245
244 246 /**
245 247 * Setup email notification.
246 248 *
249 + * @since 4.18.0 Check the gateway from meta before loading the legacy payment object.
247 250 * @since 2.0
248 251 * @access public
249 252 *
250 253 * @param int $payment_id
@@ -249,13 +252,24 @@
249 252 *
250 253 * @param int $payment_id
251 254 */
252 255 public function setup_email_notification( $payment_id ) {
256 + // Exit if not donation was not with offline donation. Checked from meta first so every
257 + // non-offline donation does not pay for building a Give_Payment on insert.
258 + if ( 'offline' !== give_get_payment_gateway( $payment_id ) ) {
259 + return;
260 + }
261 +
253 262 $this->payment = new Give_Payment( $payment_id );
254 263
255 - // Exit if not donation was not with offline donation.
256 - if ( 'offline' !== $this->payment->gateway ) {
257 - return;
264 + if ( ! $this->payment->ID ) {
265 + wp_die(
266 + esc_html__( 'Cheatin&#8217; uh?', 'give' ),
267 + esc_html__( 'Error', 'give' ),
268 + array(
269 + 'response' => 400,
270 + )
271 + );
258 272 }
259 273
260 274 // Set email data.
261 275 $this->setup_email_data();
@@ -260,11 +274,13 @@
260 274 // Set email data.
261 275 $this->setup_email_data();
262 276
263 277 // Send email.
264 - $this->send_email_notification( array(
265 - 'payment_id' => $this->payment->ID,
266 - ) );
278 + $this->send_email_notification(
279 + array(
280 + 'payment_id' => $this->payment->ID,
281 + )
282 + );
267 283 }
268 284
269 285 /**
270 286 * Set notification status
@@ -302,9 +318,9 @@
302 318 * @return array
303 319 */
304 320 public function add_metabox_setting_field( $settings, $form_id ) {
305 321
306 - if ( in_array( 'offline', array_keys( give_get_enabled_payment_gateways($form_id) ) ) ) {
322 + if ( in_array( 'offline', array_keys( give_get_enabled_payment_gateways( $form_id ) ) ) ) {
307 323 $settings[] = array(
308 324 'id' => $this->config['id'],
309 325 'title' => $this->config['label'],
310 326 'fields' => $this->get_setting_fields( $form_id ),