Test Failed
Push — master ( 40dee3...66e844 )
by Devin
55s
created
includes/class-give-db-donor-meta.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		/* @var WPDB $wpdb */
44 44
 		global $wpdb;
45 45
 
46
-		$wpdb->customermeta = $this->table_name = $wpdb->prefix . 'give_customermeta';
46
+		$wpdb->customermeta = $this->table_name = $wpdb->prefix.'give_customermeta';
47 47
 		$this->primary_key  = 'meta_id';
48 48
 		$this->version      = '1.0';
49 49
 
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 	 *
82 82
 	 * @return  mixed                 Will be an array if $single is false. Will be value of meta data field if $single is true.
83 83
 	 */
84
-	public function get_meta( $donor_id = 0, $meta_key = '', $single = false ) {
85
-		$donor_id = $this->sanitize_donor_id( $donor_id );
86
-		if ( false === $donor_id ) {
84
+	public function get_meta($donor_id = 0, $meta_key = '', $single = false) {
85
+		$donor_id = $this->sanitize_donor_id($donor_id);
86
+		if (false === $donor_id) {
87 87
 			return false;
88 88
 		}
89 89
 
90
-		return get_metadata( 'customer', $donor_id, $meta_key, $single );
90
+		return get_metadata('customer', $donor_id, $meta_key, $single);
91 91
 	}
92 92
 
93 93
 	/**
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return  bool                  False for failure. True for success.
107 107
 	 */
108
-	public function add_meta( $donor_id = 0, $meta_key = '', $meta_value, $unique = false ) {
109
-		$donor_id = $this->sanitize_donor_id( $donor_id );
110
-		if ( false === $donor_id ) {
108
+	public function add_meta($donor_id = 0, $meta_key = '', $meta_value, $unique = false) {
109
+		$donor_id = $this->sanitize_donor_id($donor_id);
110
+		if (false === $donor_id) {
111 111
 			return false;
112 112
 		}
113 113
 
114
-		return add_metadata( 'customer', $donor_id, $meta_key, $meta_value, $unique );
114
+		return add_metadata('customer', $donor_id, $meta_key, $meta_value, $unique);
115 115
 	}
116 116
 
117 117
 	/**
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return  bool                  False on failure, true if success.
136 136
 	 */
137
-	public function update_meta( $donor_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) {
138
-		$donor_id = $this->sanitize_donor_id( $donor_id );
139
-		if ( false === $donor_id ) {
137
+	public function update_meta($donor_id = 0, $meta_key = '', $meta_value, $prev_value = '') {
138
+		$donor_id = $this->sanitize_donor_id($donor_id);
139
+		if (false === $donor_id) {
140 140
 			return false;
141 141
 		}
142 142
 
143
-		return update_metadata( 'customer', $donor_id, $meta_key, $meta_value, $prev_value );
143
+		return update_metadata('customer', $donor_id, $meta_key, $meta_value, $prev_value);
144 144
 	}
145 145
 
146 146
 	/**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return  bool                  False for failure. True for success.
163 163
 	 */
164
-	public function delete_meta( $donor_id = 0, $meta_key = '', $meta_value = '' ) {
165
-		return delete_metadata( 'customer', $donor_id, $meta_key, $meta_value );
164
+	public function delete_meta($donor_id = 0, $meta_key = '', $meta_value = '') {
165
+		return delete_metadata('customer', $donor_id, $meta_key, $meta_value);
166 166
 	}
167 167
 
168 168
 	/**
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @return  bool  False for failure. True for success.
177 177
 	 */
178
-	public function delete_all_meta( $donor_id = 0 ) {
178
+	public function delete_all_meta($donor_id = 0) {
179 179
 		global $wpdb;
180
-		$wpdb->delete( $this->table_name, array( 'customer_id' => $donor_id ), array( '%d' ) );
180
+		$wpdb->delete($this->table_name, array('customer_id' => $donor_id), array('%d'));
181 181
 	}
182 182
 
183 183
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 */
191 191
 	public function create_table() {
192 192
 
193
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
193
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
194 194
 
195 195
 		$sql = "CREATE TABLE {$this->table_name} (
196 196
 			meta_id bigint(20) NOT NULL AUTO_INCREMENT,
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
 			KEY meta_key (meta_key)
203 203
 			) CHARACTER SET utf8 COLLATE utf8_general_ci;";
204 204
 
205
-		dbDelta( $sql );
205
+		dbDelta($sql);
206 206
 
207
-		update_option( $this->table_name . '_db_version', $this->version );
207
+		update_option($this->table_name.'_db_version', $this->version);
208 208
 	}
209 209
 
210 210
 	/**
@@ -217,23 +217,23 @@  discard block
 block discarded – undo
217 217
 	 *
218 218
 	 * @return int|bool                The normalized donor ID or false if it's found to not be valid.
219 219
 	 */
220
-	private function sanitize_donor_id( $donor_id ) {
221
-		if ( ! is_numeric( $donor_id ) ) {
220
+	private function sanitize_donor_id($donor_id) {
221
+		if ( ! is_numeric($donor_id)) {
222 222
 			return false;
223 223
 		}
224 224
 
225 225
 		$donor_id = (int) $donor_id;
226 226
 
227 227
 		// We were given a non positive number.
228
-		if ( absint( $donor_id ) !== $donor_id ) {
228
+		if (absint($donor_id) !== $donor_id) {
229 229
 			return false;
230 230
 		}
231 231
 
232
-		if ( empty( $donor_id ) ) {
232
+		if (empty($donor_id)) {
233 233
 			return false;
234 234
 		}
235 235
 
236
-		return absint( $donor_id );
236
+		return absint($donor_id);
237 237
 
238 238
 	}
239 239
 
Please login to merge, or discard this patch.
includes/process-donation.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -288,8 +288,8 @@
 block discarded – undo
288 288
 
289 289
 	// Check spam detect.
290 290
 	if ( isset( $_POST['action'] )
291
-	     && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) )
292
-	     && give_is_spam_donation()
291
+		 && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) )
292
+		 && give_is_spam_donation()
293 293
 	) {
294 294
 		give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) );
295 295
 	}
Please login to merge, or discard this patch.
Spacing   +253 added lines, -254 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_donation' );
33
+	do_action('give_pre_process_donation');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_donation_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array $_POST Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_donation_form_user( $valid_data );
58
+	$user = give_get_donation_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_donation_errors' );
67
+			do_action('give_ajax_donation_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	// If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	// After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		// Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,20 +97,19 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address'],
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ?
103
-		(float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) :
104
-		'0.00';
105
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ?
103
+		(float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00';
104
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
106 105
 
107 106
 	// Setup donation information
108 107
 	$donation_data = array(
109 108
 		'price'        => $price,
110 109
 		'purchase_key' => $purchase_key,
111 110
 		'user_email'   => $user['user_email'],
112
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
113
-		'user_info'    => stripslashes_deep( $user_info ),
111
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
112
+		'user_info'    => stripslashes_deep($user_info),
114 113
 		'post_data'    => $_POST,
115 114
 		'gateway'      => $valid_data['gateway'],
116 115
 		'card_info'    => $valid_data['cc_info'],
@@ -130,10 +129,10 @@  discard block
 block discarded – undo
130 129
 	 * @param array $user_info Array containing basic user information.
131 130
 	 * @param bool|array $valid_data Validate fields.
132 131
 	 */
133
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
132
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
134 133
 
135 134
 	// Sanity check for price
136
-	if ( ! $donation_data['price'] ) {
135
+	if ( ! $donation_data['price']) {
137 136
 		// Revert to manual
138 137
 		$donation_data['gateway'] = 'manual';
139 138
 		$_POST['give-gateway']    = 'manual';
@@ -144,27 +143,27 @@  discard block
 block discarded – undo
144 143
 	 *
145 144
 	 * @since 1.7
146 145
 	 */
147
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
146
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
148 147
 
149 148
 	// Setup the data we're storing in the donation session
150 149
 	$session_data = $donation_data;
151 150
 
152 151
 	// Make sure credit card numbers are never stored in sessions
153
-	unset( $session_data['card_info']['card_number'] );
154
-	unset( $session_data['post_data']['card_number'] );
152
+	unset($session_data['card_info']['card_number']);
153
+	unset($session_data['post_data']['card_number']);
155 154
 
156 155
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
157
-	give_set_purchase_session( $session_data );
156
+	give_set_purchase_session($session_data);
158 157
 
159 158
 	// Send info to the gateway for payment processing
160
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
159
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
161 160
 	give_die();
162 161
 
163 162
 }
164 163
 
165
-add_action( 'give_purchase', 'give_process_donation_form' );
166
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
167
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
164
+add_action('give_purchase', 'give_process_donation_form');
165
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
166
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
168 167
 
169 168
 
170 169
 /**
@@ -177,29 +176,29 @@  discard block
 block discarded – undo
177 176
  *
178 177
  * @return void
179 178
  */
180
-function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
179
+function give_check_logged_in_user_for_existing_email($valid_data, $post) {
181 180
 
182 181
 	// Verify that the email address belongs to this customer.
183
-	if ( is_user_logged_in() ) {
182
+	if (is_user_logged_in()) {
184 183
 
185 184
 		$submitted_email = $valid_data['logged_in_user']['user_email'];
186
-		$donor           = new Give_Donor( get_current_user_id(), true );
185
+		$donor           = new Give_Donor(get_current_user_id(), true);
187 186
 
188 187
 		// If this email address is not registered with this customer, see if it belongs to any other customer
189 188
 		if (
190 189
 			$submitted_email !== $donor->email
191
-			&& ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) )
190
+			&& (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails))
192 191
 		) {
193
-			$found_donor = new Give_Donor( $submitted_email );
192
+			$found_donor = new Give_Donor($submitted_email);
194 193
 
195
-			if ( $found_donor->id > 0 ) {
196
-				give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), $donor->email, $submitted_email ) );
194
+			if ($found_donor->id > 0) {
195
+				give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email));
197 196
 			}
198 197
 		}
199 198
 	}
200 199
 }
201 200
 
202
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 );
201
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2);
203 202
 
204 203
 /**
205 204
  * Process the checkout login form
@@ -209,49 +208,49 @@  discard block
 block discarded – undo
209 208
  * @return      void
210 209
  */
211 210
 function give_process_form_login() {
212
-	$is_ajax = isset( $_POST['give_ajax'] );
211
+	$is_ajax = isset($_POST['give_ajax']);
213 212
 
214 213
 	$user_data = give_donation_form_validate_user_login();
215 214
 
216
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
217
-		if ( $is_ajax ) {
215
+	if (give_get_errors() || $user_data['user_id'] < 1) {
216
+		if ($is_ajax) {
218 217
 			/**
219 218
 			 * Fires when AJAX sends back errors from the donation form.
220 219
 			 *
221 220
 			 * @since 1.0
222 221
 			 */
223 222
 			ob_start();
224
-			do_action( 'give_ajax_donation_errors' );
223
+			do_action('give_ajax_donation_errors');
225 224
 			$message = ob_get_contents();
226 225
 			ob_end_clean();
227
-			wp_send_json_error( $message );
226
+			wp_send_json_error($message);
228 227
 		} else {
229
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
228
+			wp_redirect($_SERVER['HTTP_REFERER']);
230 229
 			exit;
231 230
 		}
232 231
 	}
233 232
 
234
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
233
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
235 234
 
236
-	if ( $is_ajax ) {
235
+	if ($is_ajax) {
237 236
 		$message = Give()->notices->print_frontend_notice(
238 237
 			sprintf(
239 238
 			/* translators: %s: user first name */
240
-				esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ),
241
-				( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login']
239
+				esc_html__('Welcome %s! You have successfully logged into your account.', 'give'),
240
+				( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login']
242 241
 			),
243 242
 			false,
244 243
 			'success'
245 244
 		);
246 245
 
247
-		wp_send_json_success( $message );
246
+		wp_send_json_success($message);
248 247
 	} else {
249
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
248
+		wp_redirect($_SERVER['HTTP_REFERER']);
250 249
 	}
251 250
 }
252 251
 
253
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
254
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
252
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
253
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
255 254
 
256 255
 /**
257 256
  * Donation Form Validate Fields.
@@ -263,63 +262,63 @@  discard block
 block discarded – undo
263 262
 function give_donation_form_validate_fields() {
264 263
 
265 264
 	// Check if there is $_POST
266
-	if ( empty( $_POST ) ) {
265
+	if (empty($_POST)) {
267 266
 		return false;
268 267
 	}
269 268
 
270
-	$form_id = ! empty( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
269
+	$form_id = ! empty($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
271 270
 
272 271
 	// Start an array to collect valid data
273 272
 	$valid_data = array(
274 273
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here)
275
-		'need_new_user'    => false,     // New user flag
276
-		'need_user_login'  => false,     // Login user flag
277
-		'logged_user_data' => array(),   // Logged user collected data
278
-		'new_user_data'    => array(),   // New user collected data
279
-		'login_user_data'  => array(),   // Login user collected data
280
-		'guest_user_data'  => array(),   // Guest user collected data
281
-		'cc_info'          => give_donation_form_validate_cc(),// Credit card info
274
+		'need_new_user'    => false, // New user flag
275
+		'need_user_login'  => false, // Login user flag
276
+		'logged_user_data' => array(), // Logged user collected data
277
+		'new_user_data'    => array(), // New user collected data
278
+		'login_user_data'  => array(), // Login user collected data
279
+		'guest_user_data'  => array(), // Guest user collected data
280
+		'cc_info'          => give_donation_form_validate_cc(), // Credit card info
282 281
 	);
283 282
 
284 283
 	// Validate Honeypot First
285
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
286
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
284
+	if ( ! empty($_POST['give-honeypot'])) {
285
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
287 286
 	}
288 287
 
289 288
 	// Check spam detect.
290
-	if ( isset( $_POST['action'] )
291
-	     && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) )
289
+	if (isset($_POST['action'])
290
+	     && give_is_setting_enabled(give_get_option('akismet_spam_protection'))
292 291
 	     && give_is_spam_donation()
293 292
 	) {
294
-		give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) );
293
+		give_set_error('invalid_donation', __('This donation has been flagged as spam. Please try again.', 'give'));
295 294
 	}
296 295
 
297 296
 	// Validate agree to terms
298
-	if ( give_is_terms_enabled( $form_id ) ) {
297
+	if (give_is_terms_enabled($form_id)) {
299 298
 		give_donation_form_validate_agree_to_terms();
300 299
 	}
301 300
 
302 301
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
303 302
 	// If registration form username field is empty that means donor do not want to registration instead want guest checkout.
304 303
 	if (
305
-		! give_logged_in_only( $form_id )
306
-		&& isset( $_POST['give-purchase-var'] )
304
+		! give_logged_in_only($form_id)
305
+		&& isset($_POST['give-purchase-var'])
307 306
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
308
-		&& empty( $_POST['give_user_login'] )
307
+		&& empty($_POST['give_user_login'])
309 308
 	) {
310
-		unset( $_POST['give-purchase-var'] );
309
+		unset($_POST['give-purchase-var']);
311 310
 	}
312 311
 
313
-	if ( is_user_logged_in() ) {
312
+	if (is_user_logged_in()) {
314 313
 		// Collect logged in user data.
315 314
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
316
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
315
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
317 316
 		// Set new user registration as required.
318 317
 		$valid_data['need_new_user'] = true;
319 318
 		// Validate new user data.
320 319
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
321 320
 		// Check if login validation is needed.
322
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
321
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
323 322
 		// Set user login as required.
324 323
 		$valid_data['need_user_login'] = true;
325 324
 		// Validate users login info.
@@ -343,14 +342,14 @@  discard block
 block discarded – undo
343 342
 function give_is_spam_donation() {
344 343
 	$spam = false;
345 344
 
346
-	$user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
345
+	$user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
347 346
 
348
-	if ( strlen( $user_agent ) < 2 ) {
347
+	if (strlen($user_agent) < 2) {
349 348
 		$spam = true;
350 349
 	}
351 350
 
352 351
 	// Allow developer to customized Akismet spam detect API call and it's response.
353
-	return apply_filters( 'give_spam', $spam );
352
+	return apply_filters('give_spam', $spam);
354 353
 }
355 354
 
356 355
 /**
@@ -364,41 +363,41 @@  discard block
 block discarded – undo
364 363
  */
365 364
 function give_donation_form_validate_gateway() {
366 365
 
367
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
368
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
369
-	$gateway = give_get_default_gateway( $form_id );
366
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
367
+	$amount  = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0;
368
+	$gateway = give_get_default_gateway($form_id);
370 369
 
371 370
 	// Check if a gateway value is present.
372
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
371
+	if ( ! empty($_REQUEST['give-gateway'])) {
373 372
 
374
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
373
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
375 374
 
376 375
 		// Is amount being donated in LIVE mode 0.00? If so, error:
377
-		if ( $amount == 0 && ! give_is_test_mode() ) {
376
+		if ($amount == 0 && ! give_is_test_mode()) {
378 377
 
379
-			give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
378
+			give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
380 379
 
381 380
 		} // End if().
382
-		elseif ( ! give_verify_minimum_price() ) {
381
+		elseif ( ! give_verify_minimum_price()) {
383 382
 			// translators: %s: minimum donation amount.
384 383
 			give_set_error(
385 384
 				'invalid_donation_minimum',
386 385
 				sprintf(
387 386
 				/* translators: %s: minimum donation amount */
388
-					__( 'This form has a minimum donation amount of %s.', 'give' ),
389
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) )
387
+					__('This form has a minimum donation amount of %s.', 'give'),
388
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false)))
390 389
 				)
391 390
 			);
392 391
 
393 392
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
394
-		elseif ( $amount == 0 && give_is_test_mode() ) {
393
+		elseif ($amount == 0 && give_is_test_mode()) {
395 394
 
396 395
 			$gateway = 'manual';
397 396
 
398 397
 		} //Check if this gateway is active.
399
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
398
+		elseif ( ! give_is_gateway_active($gateway)) {
400 399
 
401
-			give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
400
+			give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
402 401
 
403 402
 		}
404 403
 	}
@@ -416,21 +415,21 @@  discard block
 block discarded – undo
416 415
  */
417 416
 function give_verify_minimum_price() {
418 417
 
419
-	$amount          = give_maybe_sanitize_amount( $_REQUEST['give-amount'] );
420
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
421
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null;
422
-	$variable_prices = give_has_variable_prices( $form_id );
418
+	$amount          = give_maybe_sanitize_amount($_REQUEST['give-amount']);
419
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
420
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null;
421
+	$variable_prices = give_has_variable_prices($form_id);
423 422
 
424
-	if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) {
423
+	if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) {
425 424
 
426
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
425
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
427 426
 
428
-		if ( $price_level_amount == $amount ) {
427
+		if ($price_level_amount == $amount) {
429 428
 			return true;
430 429
 		}
431 430
 	}
432 431
 
433
-	if ( give_get_form_minimum_price( $form_id ) > $amount ) {
432
+	if (give_get_form_minimum_price($form_id) > $amount) {
434 433
 		return false;
435 434
 	}
436 435
 
@@ -446,9 +445,9 @@  discard block
 block discarded – undo
446 445
  */
447 446
 function give_donation_form_validate_agree_to_terms() {
448 447
 	// Validate agree to terms.
449
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
448
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
450 449
 		// User did not agree.
451
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
450
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
452 451
 	}
453 452
 }
454 453
 
@@ -462,59 +461,59 @@  discard block
 block discarded – undo
462 461
  *
463 462
  * @return      array
464 463
  */
465
-function give_get_required_fields( $form_id ) {
464
+function give_get_required_fields($form_id) {
466 465
 
467
-	$payment_mode = give_get_chosen_gateway( $form_id );
466
+	$payment_mode = give_get_chosen_gateway($form_id);
468 467
 
469 468
 	$required_fields = array(
470 469
 		'give_email' => array(
471 470
 			'error_id'      => 'invalid_email',
472
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
471
+			'error_message' => __('Please enter a valid email address.', 'give'),
473 472
 		),
474 473
 		'give_first' => array(
475 474
 			'error_id'      => 'invalid_first_name',
476
-			'error_message' => __( 'Please enter your first name.', 'give' ),
475
+			'error_message' => __('Please enter your first name.', 'give'),
477 476
 		),
478 477
 	);
479 478
 
480
-	$require_address = give_require_billing_address( $payment_mode );
479
+	$require_address = give_require_billing_address($payment_mode);
481 480
 
482
-	if ( $require_address ) {
483
-		$required_fields['card_address']    = array(
481
+	if ($require_address) {
482
+		$required_fields['card_address'] = array(
484 483
 			'error_id'      => 'invalid_card_address',
485
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
484
+			'error_message' => __('Please enter your primary billing address.', 'give'),
486 485
 		);
487
-		$required_fields['card_zip']        = array(
486
+		$required_fields['card_zip'] = array(
488 487
 			'error_id'      => 'invalid_zip_code',
489
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
488
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
490 489
 		);
491
-		$required_fields['card_city']       = array(
490
+		$required_fields['card_city'] = array(
492 491
 			'error_id'      => 'invalid_city',
493
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
492
+			'error_message' => __('Please enter your billing city.', 'give'),
494 493
 		);
495 494
 		$required_fields['billing_country'] = array(
496 495
 			'error_id'      => 'invalid_country',
497
-			'error_message' => __( 'Please select your billing country.', 'give' ),
496
+			'error_message' => __('Please select your billing country.', 'give'),
498 497
 		);
499 498
 
500 499
 
501 500
 		$required_fields['card_state'] = array(
502 501
 			'error_id'      => 'invalid_state',
503
-			'error_message' => __( 'Please enter billing state / province / County.', 'give' ),
502
+			'error_message' => __('Please enter billing state / province / County.', 'give'),
504 503
 		);
505 504
 
506 505
 		// Check if billing country alredy exists.
507
-		if ( ! empty( $_POST['billing_country'] ) ) {
506
+		if ( ! empty($_POST['billing_country'])) {
508 507
 			// Get the value from $_POST.
509
-			$country = sanitize_text_field( $_POST['billing_country'] );
508
+			$country = sanitize_text_field($_POST['billing_country']);
510 509
 
511 510
 			// Get the country list that does not required any states init.
512 511
 			$states_country = give_states_not_required_country_list();
513 512
 
514 513
 			// Check if states is empty or not.
515
-			if ( array_key_exists( $country, $states_country ) ) {
514
+			if (array_key_exists($country, $states_country)) {
516 515
 				// If states is empty remove the required feilds of state in billing cart.
517
-				unset( $required_fields['card_state'] );
516
+				unset($required_fields['card_state']);
518 517
 			}
519 518
 		}
520 519
 	}
@@ -524,7 +523,7 @@  discard block
 block discarded – undo
524 523
 	 *
525 524
 	 * @since 1.7
526 525
 	 */
527
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
526
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
528 527
 
529 528
 	return $required_fields;
530 529
 
@@ -539,16 +538,16 @@  discard block
 block discarded – undo
539 538
  *
540 539
  * @return bool
541 540
  */
542
-function give_require_billing_address( $payment_mode ) {
541
+function give_require_billing_address($payment_mode) {
543 542
 
544 543
 	$return = false;
545 544
 
546
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
545
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
547 546
 		$return = true;
548 547
 	}
549 548
 
550 549
 	// Let payment gateways and other extensions determine if address fields should be required.
551
-	return apply_filters( 'give_require_billing_address', $return );
550
+	return apply_filters('give_require_billing_address', $return);
552 551
 
553 552
 }
554 553
 
@@ -562,42 +561,42 @@  discard block
 block discarded – undo
562 561
 function give_donation_form_validate_logged_in_user() {
563 562
 	global $user_ID;
564 563
 
565
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
564
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
566 565
 
567 566
 	// Start empty array to collect valid user data.
568 567
 	$valid_user_data = array(
569 568
 		// Assume there will be errors.
570
-		'user_id' => - 1,
569
+		'user_id' => -1,
571 570
 	);
572 571
 
573 572
 	// Verify there is a user_ID.
574
-	if ( $user_ID > 0 ) {
573
+	if ($user_ID > 0) {
575 574
 		// Get the logged in user data.
576
-		$user_data = get_userdata( $user_ID );
575
+		$user_data = get_userdata($user_ID);
577 576
 
578 577
 		// Loop through required fields and show error messages.
579
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
580
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
581
-				give_set_error( $value['error_id'], $value['error_message'] );
578
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
579
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
580
+				give_set_error($value['error_id'], $value['error_message']);
582 581
 			}
583 582
 		}
584 583
 
585 584
 		// Verify data.
586
-		if ( $user_data ) {
585
+		if ($user_data) {
587 586
 			// Collected logged in user data.
588 587
 			$valid_user_data = array(
589 588
 				'user_id'    => $user_ID,
590
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
591
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
592
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
589
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
590
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
591
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
593 592
 			);
594 593
 
595
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
596
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
594
+			if ( ! is_email($valid_user_data['user_email'])) {
595
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
597 596
 			}
598 597
 		} else {
599 598
 			// Set invalid user error.
600
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
599
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
601 600
 		}
602 601
 	}
603 602
 
@@ -616,7 +615,7 @@  discard block
 block discarded – undo
616 615
 	// Default user data.
617 616
 	$default_user_data = array(
618 617
 		'give-form-id'           => '',
619
-		'user_id'                => - 1, // Assume there will be errors.
618
+		'user_id'                => -1, // Assume there will be errors.
620 619
 		'user_first'             => '',
621 620
 		'user_last'              => '',
622 621
 		'give_user_login'        => false,
@@ -626,14 +625,14 @@  discard block
 block discarded – undo
626 625
 	);
627 626
 
628 627
 	// Get user data.
629
-	$user_data            = wp_parse_args( give_clean( $_POST ), $default_user_data );
628
+	$user_data            = wp_parse_args(give_clean($_POST), $default_user_data);
630 629
 	$registering_new_user = false;
631
-	$form_id              = absint( $user_data['give-form-id'] );
630
+	$form_id              = absint($user_data['give-form-id']);
632 631
 
633 632
 	// Start an empty array to collect valid user data.
634 633
 	$valid_user_data = array(
635 634
 		// Assume there will be errors.
636
-		'user_id'    => - 1,
635
+		'user_id'    => -1,
637 636
 
638 637
 		// Get first name.
639 638
 		'user_first' => $user_data['give_first'],
@@ -643,25 +642,25 @@  discard block
 block discarded – undo
643 642
 	);
644 643
 
645 644
 	// Loop through required fields and show error messages.
646
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
647
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
648
-			give_set_error( $value['error_id'], $value['error_message'] );
645
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
646
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
647
+			give_set_error($value['error_id'], $value['error_message']);
649 648
 		}
650 649
 	}
651 650
 
652 651
 	// Check if we have an username to register.
653
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
652
+	if (give_validate_username($user_data['give_user_login'])) {
654 653
 		$registering_new_user          = true;
655 654
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
656 655
 	}
657 656
 
658 657
 	// Check if we have an email to verify.
659
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
658
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
660 659
 		$valid_user_data['user_email'] = $user_data['give_email'];
661 660
 	}
662 661
 
663 662
 	// Check password.
664
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
663
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
665 664
 		// All is good to go.
666 665
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
667 666
 	}
@@ -681,36 +680,36 @@  discard block
 block discarded – undo
681 680
 	// Start an array to collect valid user data.
682 681
 	$valid_user_data = array(
683 682
 		// Assume there will be errors.
684
-		'user_id' => - 1,
683
+		'user_id' => -1,
685 684
 	);
686 685
 
687 686
 	// Username.
688
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
689
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
687
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
688
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
690 689
 
691 690
 		return $valid_user_data;
692 691
 	}
693 692
 
694 693
 	// Get the user by login.
695
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
694
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
696 695
 
697 696
 	// Check if user exists.
698
-	if ( $user_data ) {
697
+	if ($user_data) {
699 698
 		// Get password.
700
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
699
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
701 700
 
702 701
 		// Check user_pass.
703
-		if ( $user_pass ) {
702
+		if ($user_pass) {
704 703
 			// Check if password is valid.
705
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
704
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
706 705
 				// Incorrect password.
707 706
 				give_set_error(
708 707
 					'password_incorrect',
709 708
 					sprintf(
710 709
 						'%1$s <a href="%2$s">%3$s</a>',
711
-						__( 'The password you entered is incorrect.', 'give' ),
712
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
713
-						__( 'Reset Password', 'give' )
710
+						__('The password you entered is incorrect.', 'give'),
711
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
712
+						__('Reset Password', 'give')
714 713
 					)
715 714
 				);
716 715
 				// All is correct.
@@ -728,11 +727,11 @@  discard block
 block discarded – undo
728 727
 			}
729 728
 		} else {
730 729
 			// Empty password.
731
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
730
+			give_set_error('password_empty', __('Enter a password.', 'give'));
732 731
 		}
733 732
 	} else {
734 733
 		// No username.
735
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
734
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
736 735
 	}// End if().
737 736
 
738 737
 	return $valid_user_data;
@@ -747,7 +746,7 @@  discard block
 block discarded – undo
747 746
  */
748 747
 function give_donation_form_validate_guest_user() {
749 748
 
750
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
749
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
751 750
 
752 751
 	// Start an array to collect valid user data.
753 752
 	$valid_user_data = array(
@@ -756,38 +755,38 @@  discard block
 block discarded – undo
756 755
 	);
757 756
 
758 757
 	// Show error message if user must be logged in.
759
-	if ( give_logged_in_only( $form_id ) ) {
760
-		give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) );
758
+	if (give_logged_in_only($form_id)) {
759
+		give_set_error('logged_in_only', __('You must be logged in to donate.', 'give'));
761 760
 	}
762 761
 
763 762
 	// Get the guest email.
764
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
763
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
765 764
 
766 765
 	// Check email.
767
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
766
+	if ($guest_email && strlen($guest_email) > 0) {
768 767
 		// Validate email.
769
-		if ( ! is_email( $guest_email ) ) {
768
+		if ( ! is_email($guest_email)) {
770 769
 			// Invalid email.
771
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
770
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
772 771
 		} else {
773 772
 			// All is good to go.
774 773
 			$valid_user_data['user_email'] = $guest_email;
775 774
 
776 775
 			// Get user_id from donor if exist.
777
-			$donor = new Give_Donor( $guest_email );
778
-			if ( $donor->id && $donor->user_id ) {
776
+			$donor = new Give_Donor($guest_email);
777
+			if ($donor->id && $donor->user_id) {
779 778
 				$valid_user_data['user_id'] = $donor->user_id;
780 779
 			}
781 780
 		}
782 781
 	} else {
783 782
 		// No email.
784
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
783
+		give_set_error('email_empty', __('Enter an email.', 'give'));
785 784
 	}
786 785
 
787 786
 	// Loop through required fields and show error messages.
788
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
789
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
790
-			give_set_error( $value['error_id'], $value['error_message'] );
787
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
788
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
789
+			give_set_error($value['error_id'], $value['error_message']);
791 790
 		}
792 791
 	}
793 792
 
@@ -803,36 +802,36 @@  discard block
 block discarded – undo
803 802
  * @since   1.0
804 803
  * @return  integer
805 804
  */
806
-function give_register_and_login_new_user( $user_data = array() ) {
805
+function give_register_and_login_new_user($user_data = array()) {
807 806
 	// Verify the array.
808
-	if ( empty( $user_data ) ) {
809
-		return - 1;
807
+	if (empty($user_data)) {
808
+		return -1;
810 809
 	}
811 810
 
812
-	if ( give_get_errors() ) {
813
-		return - 1;
811
+	if (give_get_errors()) {
812
+		return -1;
814 813
 	}
815 814
 
816
-	$user_args = apply_filters( 'give_insert_user_args', array(
817
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
818
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
819
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
820
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
821
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
822
-		'user_registered' => date( 'Y-m-d H:i:s' ),
823
-		'role'            => give_get_option( 'donor_default_user_role', 'give_donor' ),
824
-	), $user_data );
815
+	$user_args = apply_filters('give_insert_user_args', array(
816
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
817
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
818
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
819
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
820
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
821
+		'user_registered' => date('Y-m-d H:i:s'),
822
+		'role'            => give_get_option('donor_default_user_role', 'give_donor'),
823
+	), $user_data);
825 824
 
826 825
 	// Insert new user.
827
-	$user_id = wp_insert_user( $user_args );
826
+	$user_id = wp_insert_user($user_args);
828 827
 
829 828
 	// Validate inserted user.
830
-	if ( is_wp_error( $user_id ) ) {
831
-		return - 1;
829
+	if (is_wp_error($user_id)) {
830
+		return -1;
832 831
 	}
833 832
 
834 833
 	// Allow themes and plugins to filter the user data.
835
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
834
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
836 835
 
837 836
 	/**
838 837
 	 * Fires after inserting user.
@@ -842,7 +841,7 @@  discard block
 block discarded – undo
842 841
 	 * @param int $user_id User id.
843 842
 	 * @param array $user_data Array containing user data.
844 843
 	 */
845
-	do_action( 'give_insert_user', $user_id, $user_data );
844
+	do_action('give_insert_user', $user_id, $user_data);
846 845
 
847 846
 	/**
848 847
 	 * Filter allow user to alter if user when to login or not when user is register for the first time.
@@ -851,9 +850,9 @@  discard block
 block discarded – undo
851 850
 	 *
852 851
 	 * return bool True if login with registration and False if only want to register.
853 852
 	 */
854
-	if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) {
853
+	if (true === (bool) apply_filters('give_log_user_in_on_register', true)) {
855 854
 		// Login new user.
856
-		give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
855
+		give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
857 856
 	}
858 857
 
859 858
 	// Return user id.
@@ -869,27 +868,27 @@  discard block
 block discarded – undo
869 868
  * @since   1.0
870 869
  * @return  array|bool
871 870
  */
872
-function give_get_donation_form_user( $valid_data = array() ) {
871
+function give_get_donation_form_user($valid_data = array()) {
873 872
 
874 873
 	// Initialize user.
875 874
 	$user    = false;
876
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
875
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
877 876
 
878
-	if ( $is_ajax ) {
877
+	if ($is_ajax) {
879 878
 		// Do not create or login the user during the ajax submission (check for errors only).
880 879
 		return true;
881
-	} elseif ( is_user_logged_in() ) {
880
+	} elseif (is_user_logged_in()) {
882 881
 		// Set the valid user as the logged in collected data.
883 882
 		$user = $valid_data['logged_in_user'];
884
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
883
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
885 884
 		// New user registration.
886
-		if ( $valid_data['need_new_user'] === true ) {
885
+		if ($valid_data['need_new_user'] === true) {
887 886
 			// Set user.
888 887
 			$user = $valid_data['new_user_data'];
889 888
 			// Register and login new user.
890
-			$user['user_id'] = give_register_and_login_new_user( $user );
889
+			$user['user_id'] = give_register_and_login_new_user($user);
891 890
 			// User login
892
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
891
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
893 892
 
894 893
 			/**
895 894
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -901,48 +900,48 @@  discard block
 block discarded – undo
901 900
 			// Set user.
902 901
 			$user = $valid_data['login_user_data'];
903 902
 			// Login user.
904
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
903
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
905 904
 		}
906 905
 	}
907 906
 
908 907
 	// Check guest checkout.
909
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
908
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
910 909
 		// Set user
911 910
 		$user = $valid_data['guest_user_data'];
912 911
 	}
913 912
 
914 913
 	// Verify we have an user.
915
-	if ( false === $user || empty( $user ) ) {
914
+	if (false === $user || empty($user)) {
916 915
 		// Return false.
917 916
 		return false;
918 917
 	}
919 918
 
920 919
 	// Get user first name.
921
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
922
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
920
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
921
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
923 922
 	}
924 923
 
925 924
 	// Get user last name.
926
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
927
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
925
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
926
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
928 927
 	}
929 928
 
930 929
 	// Get the user's billing address details.
931 930
 	$user['address']            = array();
932
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false;
933
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false;
934
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false;
935
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false;
936
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false;
937
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false;
938
-
939
-	if ( empty( $user['address']['country'] ) ) {
931
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false;
932
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false;
933
+	$user['address']['city']    = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false;
934
+	$user['address']['state']   = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false;
935
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false;
936
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false;
937
+
938
+	if (empty($user['address']['country'])) {
940 939
 		$user['address'] = false;
941 940
 	} // End if().
942 941
 
943
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
942
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
944 943
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return donation.
945
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
944
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
946 945
 	}
947 946
 
948 947
 	// Return valid user.
@@ -961,16 +960,16 @@  discard block
 block discarded – undo
961 960
 	$card_data = give_get_donation_cc_info();
962 961
 
963 962
 	// Validate the card zip.
964
-	if ( ! empty( $card_data['card_zip'] ) ) {
965
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
966
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
963
+	if ( ! empty($card_data['card_zip'])) {
964
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
965
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
967 966
 		}
968 967
 	}
969 968
 
970 969
 	// Ensure no spaces.
971
-	if ( ! empty( $card_data['card_number'] ) ) {
972
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
973
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
970
+	if ( ! empty($card_data['card_number'])) {
971
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
972
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
974 973
 	}
975 974
 
976 975
 	// This should validate card numbers at some point too.
@@ -987,17 +986,17 @@  discard block
 block discarded – undo
987 986
 function give_get_donation_cc_info() {
988 987
 
989 988
 	$cc_info                   = array();
990
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
991
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
992
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
993
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
994
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
995
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
996
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
997
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
998
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
999
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
1000
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
989
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
990
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
991
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
992
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
993
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
994
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
995
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
996
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
997
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
998
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
999
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
1001 1000
 
1002 1001
 	// Return cc info.
1003 1002
 	return $cc_info;
@@ -1013,14 +1012,14 @@  discard block
 block discarded – undo
1013 1012
  *
1014 1013
  * @return bool|mixed
1015 1014
  */
1016
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
1015
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
1017 1016
 	$ret = false;
1018 1017
 
1019
-	if ( empty( $zip ) || empty( $country_code ) ) {
1018
+	if (empty($zip) || empty($country_code)) {
1020 1019
 		return $ret;
1021 1020
 	}
1022 1021
 
1023
-	$country_code = strtoupper( $country_code );
1022
+	$country_code = strtoupper($country_code);
1024 1023
 
1025 1024
 	$zip_regex = array(
1026 1025
 		'AD' => 'AD\d{3}',
@@ -1180,11 +1179,11 @@  discard block
 block discarded – undo
1180 1179
 		'ZM' => '\d{5}',
1181 1180
 	);
1182 1181
 
1183
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1182
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1184 1183
 		$ret = true;
1185 1184
 	}
1186 1185
 
1187
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1186
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1188 1187
 }
1189 1188
 
1190 1189
 
@@ -1198,33 +1197,33 @@  discard block
 block discarded – undo
1198 1197
  *
1199 1198
  * @return bool
1200 1199
  */
1201
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1200
+function give_validate_multi_donation_form_level($valid_data, $data) {
1202 1201
 	/* @var Give_Donate_Form $form */
1203
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1202
+	$form = new Give_Donate_Form($data['give-form-id']);
1204 1203
 
1205 1204
 	$donation_level_matched = false;
1206 1205
 
1207
-	if ( $form->is_multi_type_donation_form() ) {
1206
+	if ($form->is_multi_type_donation_form()) {
1208 1207
 
1209 1208
 		// Bailout.
1210
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1209
+		if ( ! ($variable_prices = $form->get_prices())) {
1211 1210
 			return false;
1212 1211
 		}
1213 1212
 
1214 1213
 		// Sanitize donation amount.
1215
-		$data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] );
1214
+		$data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']);
1216 1215
 
1217
-		if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) {
1216
+		if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) {
1218 1217
 			return true;
1219 1218
 		}
1220 1219
 
1221 1220
 		// Find correct donation level from all donation levels.
1222
-		foreach ( $variable_prices as $variable_price ) {
1221
+		foreach ($variable_prices as $variable_price) {
1223 1222
 			// Sanitize level amount.
1224
-			$variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] );
1223
+			$variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']);
1225 1224
 
1226 1225
 			// Set first match donation level ID.
1227
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1226
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1228 1227
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1229 1228
 				$donation_level_matched = true;
1230 1229
 				break;
@@ -1235,19 +1234,19 @@  discard block
 block discarded – undo
1235 1234
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1236 1235
 		if (
1237 1236
 			! $donation_level_matched
1238
-			&& ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1237
+			&& (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true)))
1239 1238
 		) {
1240 1239
 			// Sanitize custom minimum amount.
1241
-			$custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) );
1240
+			$custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true));
1242 1241
 
1243
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1242
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1244 1243
 				$_POST['give-price-id'] = 'custom';
1245 1244
 				$donation_level_matched = true;
1246 1245
 			}
1247 1246
 		}
1248 1247
 	}// End if().
1249 1248
 
1250
-	return ( $donation_level_matched ? true : false );
1249
+	return ($donation_level_matched ? true : false);
1251 1250
 }
1252 1251
 
1253
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1252
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @global     $wpdb
27 27
  * @return void
28 28
  */
29
-function give_install( $network_wide = false ) {
29
+function give_install($network_wide = false) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( is_multisite() && $network_wide ) {
33
+	if (is_multisite() && $network_wide) {
34 34
 
35
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
35
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
36 36
 
37
-			switch_to_blog( $blog_id );
37
+			switch_to_blog($blog_id);
38 38
 			give_run_install();
39 39
 			restore_current_blog();
40 40
 
@@ -61,31 +61,31 @@  discard block
 block discarded – undo
61 61
 	give_setup_post_types();
62 62
 
63 63
 	// Add Upgraded From Option.
64
-	$current_version = get_option( 'give_version' );
65
-	if ( $current_version ) {
66
-		update_option( 'give_version_upgraded_from', $current_version );
64
+	$current_version = get_option('give_version');
65
+	if ($current_version) {
66
+		update_option('give_version_upgraded_from', $current_version);
67 67
 	}
68 68
 
69 69
 	// Setup some default options.
70 70
 	$options = array();
71 71
 
72 72
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
73
-	if ( empty( $current_version ) ) {
74
-		$options = array_merge( $options, give_get_default_settings() );
73
+	if (empty($current_version)) {
74
+		$options = array_merge($options, give_get_default_settings());
75 75
 	}
76 76
 
77 77
 	// Populate the default values.
78
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
78
+	update_option('give_settings', array_merge($give_options, $options));
79 79
 
80 80
 	/**
81 81
 	 * Run plugin upgrades.
82 82
 	 *
83 83
 	 * @since 1.8
84 84
 	 */
85
-	do_action( 'give_upgrades' );
85
+	do_action('give_upgrades');
86 86
 
87
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
88
-		update_option( 'give_version', GIVE_VERSION );
87
+	if (GIVE_VERSION !== get_option('give_version')) {
88
+		update_option('give_version', GIVE_VERSION);
89 89
 	}
90 90
 
91 91
 	// Create Give roles.
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	// Set api version, end point and refresh permalink.
97 97
 	$api = new Give_API();
98 98
 	$api->add_endpoint();
99
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
99
+	update_option('give_default_api_version', 'v'.$api->get_version());
100 100
 
101 101
 	flush_rewrite_rules();
102 102
 
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 	$give_sessions->use_php_sessions();
106 106
 
107 107
 	// Add a temporary option to note that Give pages have been created.
108
-	Give_Cache::set( '_give_installed', $options, 30, true );
108
+	Give_Cache::set('_give_installed', $options, 30, true);
109 109
 
110
-	if ( ! $current_version ) {
110
+	if ( ! $current_version) {
111 111
 
112
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
112
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
113 113
 
114 114
 		// When new upgrade routines are added, mark them as complete on fresh install.
115 115
 		$upgrade_routines = array(
@@ -125,18 +125,18 @@  discard block
 block discarded – undo
125 125
 			'v1813_update_donor_user_roles'
126 126
 		);
127 127
 
128
-		foreach ( $upgrade_routines as $upgrade ) {
129
-			give_set_upgrade_complete( $upgrade );
128
+		foreach ($upgrade_routines as $upgrade) {
129
+			give_set_upgrade_complete($upgrade);
130 130
 		}
131 131
 	}
132 132
 
133 133
 	// Bail if activating from network, or bulk.
134
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
134
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
135 135
 		return;
136 136
 	}
137 137
 
138 138
 	// Add the transient to redirect.
139
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
139
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
140 140
 }
141 141
 
142 142
 /**
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
  * @param  int $site_id The Site ID.
154 154
  * @param  array $meta Blog Meta.
155 155
  */
156
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
156
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
157 157
 
158
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
158
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
159 159
 
160
-		switch_to_blog( $blog_id );
160
+		switch_to_blog($blog_id);
161 161
 		give_install();
162 162
 		restore_current_blog();
163 163
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
 }
167 167
 
168
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
168
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
169 169
 
170 170
 
171 171
 /**
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
  *
179 179
  * @return array          The tables to drop.
180 180
  */
181
-function give_wpmu_drop_tables( $tables, $blog_id ) {
181
+function give_wpmu_drop_tables($tables, $blog_id) {
182 182
 
183
-	switch_to_blog( $blog_id );
183
+	switch_to_blog($blog_id);
184 184
 	$donors_db     = new Give_DB_Donors();
185 185
 	$donor_meta_db = new Give_DB_Donor_Meta();
186 186
 
187
-	if ( $donors_db->installed() ) {
187
+	if ($donors_db->installed()) {
188 188
 		$tables[] = $donors_db->table_name;
189 189
 		$tables[] = $donor_meta_db->table_name;
190 190
 	}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
 }
196 196
 
197
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
197
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
198 198
 
199 199
 /**
200 200
  * Post-installation
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
  */
207 207
 function give_after_install() {
208 208
 
209
-	if ( ! is_admin() ) {
209
+	if ( ! is_admin()) {
210 210
 		return;
211 211
 	}
212 212
 
213
-	$give_options     = Give_Cache::get( '_give_installed', true );
214
-	$give_table_check = get_option( '_give_table_check', false );
213
+	$give_options     = Give_Cache::get('_give_installed', true);
214
+	$give_table_check = get_option('_give_table_check', false);
215 215
 
216
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
216
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
217 217
 
218
-		if ( ! @Give()->donor_meta->installed() ) {
218
+		if ( ! @Give()->donor_meta->installed()) {
219 219
 
220 220
 			// Create the donor meta database.
221 221
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 		}
225 225
 
226
-		if ( ! @Give()->donors->installed() ) {
226
+		if ( ! @Give()->donors->installed()) {
227 227
 			// Create the donor database.
228 228
 			// (this ensures it creates it on multisite instances where it is network activated).
229 229
 			@Give()->donors->create_table();
@@ -235,22 +235,22 @@  discard block
 block discarded – undo
235 235
 			 *
236 236
 			 * @param array $give_options Give plugin options.
237 237
 			 */
238
-			do_action( 'give_after_install', $give_options );
238
+			do_action('give_after_install', $give_options);
239 239
 		}
240 240
 
241
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
241
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
242 242
 
243 243
 	}
244 244
 
245 245
 	// Delete the transient
246
-	if ( false !== $give_options ) {
247
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
246
+	if (false !== $give_options) {
247
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
248 248
 	}
249 249
 
250 250
 
251 251
 }
252 252
 
253
-add_action( 'admin_init', 'give_after_install' );
253
+add_action('admin_init', 'give_after_install');
254 254
 
255 255
 
256 256
 /**
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
 
266 266
 	global $wp_roles;
267 267
 
268
-	if ( ! is_object( $wp_roles ) ) {
268
+	if ( ! is_object($wp_roles)) {
269 269
 		return;
270 270
 	}
271 271
 
272
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
272
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
273 273
 
274 274
 		// Create Give plugin roles
275 275
 		$roles = new Give_Roles();
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
 }
282 282
 
283
-add_action( 'admin_init', 'give_install_roles_on_network' );
283
+add_action('admin_init', 'give_install_roles_on_network');
284 284
 
285 285
 /**
286 286
  * Default core setting values.
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
 		'uninstall_on_delete'                         => 'disabled',
319 319
 		'the_content_filter'                          => 'enabled',
320 320
 		'scripts_footer'                              => 'disabled',
321
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
321
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
322 322
 		'agreement_text'                              => give_get_default_agreement_text(),
323 323
 
324 324
 		// Paypal IPN verification.
325 325
 		'paypal_verification'                         => 'enabled',
326 326
 
327 327
 		// Default is manual gateway.
328
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
328
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
329 329
 		'default_gateway'                             => 'manual',
330 330
 
331 331
 		// Offline gateway setup.
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
  */
354 354
 function give_get_default_agreement_text() {
355 355
 
356
-	$org_name = get_bloginfo( 'name' );
356
+	$org_name = get_bloginfo('name');
357 357
 
358 358
 	$agreement = sprintf(
359 359
 		'<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The  %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  %1$s.</p>
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 		$org_name
368 368
 	);
369 369
 
370
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
370
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
371 371
 }
372 372
 
373 373
 
@@ -376,22 +376,22 @@  discard block
 block discarded – undo
376 376
  *
377 377
  * @since 1.8.11
378 378
  */
379
-function give_create_pages(){
379
+function give_create_pages() {
380 380
 
381 381
 	// Bailout if pages already created.
382
-	if( get_option( 'give_install_pages_created') ) {
382
+	if (get_option('give_install_pages_created')) {
383 383
 		return false;
384 384
 	}
385 385
 
386 386
 	$options = array();
387 387
 
388 388
 	// Checks if the Success Page option exists AND that the page exists.
389
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
389
+	if ( ! get_post(give_get_option('success_page'))) {
390 390
 
391 391
 		// Donation Confirmation (Success) Page
392 392
 		$success = wp_insert_post(
393 393
 			array(
394
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
394
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
395 395
 				'post_content'   => '[give_receipt]',
396 396
 				'post_status'    => 'publish',
397 397
 				'post_author'    => 1,
@@ -405,13 +405,13 @@  discard block
 block discarded – undo
405 405
 	}
406 406
 
407 407
 	// Checks if the Failure Page option exists AND that the page exists.
408
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
408
+	if ( ! get_post(give_get_option('failure_page'))) {
409 409
 
410 410
 		// Failed Donation Page
411 411
 		$failed = wp_insert_post(
412 412
 			array(
413
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
414
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
413
+				'post_title'     => esc_html__('Donation Failed', 'give'),
414
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
415 415
 				'post_status'    => 'publish',
416 416
 				'post_author'    => 1,
417 417
 				'post_type'      => 'page',
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
 	}
424 424
 
425 425
 	// Checks if the History Page option exists AND that the page exists.
426
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
426
+	if ( ! get_post(give_get_option('history_page'))) {
427 427
 		// Donation History Page
428 428
 		$history = wp_insert_post(
429 429
 			array(
430
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
430
+				'post_title'     => esc_html__('Donation History', 'give'),
431 431
 				'post_content'   => '[donation_history]',
432 432
 				'post_status'    => 'publish',
433 433
 				'post_author'    => 1,
@@ -439,10 +439,10 @@  discard block
 block discarded – undo
439 439
 		$options['history_page'] = $history;
440 440
 	}
441 441
 
442
-	if( ! empty( $options ) ) {
443
-		update_option( 'give_settings', array_merge( give_get_settings(), $options ) );
442
+	if ( ! empty($options)) {
443
+		update_option('give_settings', array_merge(give_get_settings(), $options));
444 444
 	}
445 445
 
446
-	add_option( 'give_install_pages_created', 1, '', 'no' );
446
+	add_option('give_install_pages_created', 1, '', 'no');
447 447
 }
448
-add_action( 'admin_init', 'give_create_pages', -1 );
448
+add_action('admin_init', 'give_create_pages', -1);
Please login to merge, or discard this patch.
includes/admin/payments/actions.php 1 patch
Spacing   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,52 +25,52 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * @return      void
27 27
  */
28
-function give_update_payment_details( $data ) {
28
+function give_update_payment_details($data) {
29 29
 
30
-	if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) {
31
-		wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) {
31
+		wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	check_admin_referer( 'give_update_payment_details_nonce' );
34
+	check_admin_referer('give_update_payment_details_nonce');
35 35
 
36 36
 	// Retrieve the payment ID.
37
-	$payment_id = absint( $data['give_payment_id'] );
37
+	$payment_id = absint($data['give_payment_id']);
38 38
 
39 39
 	/* @var Give_Payment $payment */
40
-	$payment = new Give_Payment( $payment_id );
40
+	$payment = new Give_Payment($payment_id);
41 41
 
42 42
 	// Retrieve existing payment meta.
43 43
 	$meta      = $payment->get_meta();
44 44
 	$user_info = $payment->user_info;
45 45
 
46 46
 	$status = $data['give-payment-status'];
47
-	$date   = sanitize_text_field( $data['give-payment-date'] );
48
-	$hour   = sanitize_text_field( $data['give-payment-time-hour'] );
47
+	$date   = sanitize_text_field($data['give-payment-date']);
48
+	$hour   = sanitize_text_field($data['give-payment-time-hour']);
49 49
 
50 50
 	// Restrict to our high and low.
51
-	if ( $hour > 23 ) {
51
+	if ($hour > 23) {
52 52
 		$hour = 23;
53
-	} elseif ( $hour < 0 ) {
53
+	} elseif ($hour < 0) {
54 54
 		$hour = 00;
55 55
 	}
56 56
 
57
-	$minute = sanitize_text_field( $data['give-payment-time-min'] );
57
+	$minute = sanitize_text_field($data['give-payment-time-min']);
58 58
 
59 59
 	// Restrict to our high and low.
60
-	if ( $minute > 59 ) {
60
+	if ($minute > 59) {
61 61
 		$minute = 59;
62
-	} elseif ( $minute < 0 ) {
62
+	} elseif ($minute < 0) {
63 63
 		$minute = 00;
64 64
 	}
65 65
 
66
-	$address = give_clean( $data['give-payment-address'][0] );
66
+	$address = give_clean($data['give-payment-address'][0]);
67 67
 
68 68
 	$curr_total = $payment->total;
69
-	$new_total  = give_maybe_sanitize_amount( $data['give-payment-total'] );
70
-	$date       = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00';
69
+	$new_total  = give_maybe_sanitize_amount($data['give-payment-total']);
70
+	$date       = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00';
71 71
 
72
-	$curr_donor_id = sanitize_text_field( $data['give-current-donor'] );
73
-	$new_donor_id  = sanitize_text_field( $data['donor-id'] );
72
+	$curr_donor_id = sanitize_text_field($data['give-current-donor']);
73
+	$new_donor_id  = sanitize_text_field($data['donor-id']);
74 74
 
75 75
 	/**
76 76
 	 * Fires before updating edited donation.
@@ -80,98 +80,98 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param int $payment_id The ID of the payment.
82 82
 	 */
83
-	do_action( 'give_update_edited_donation', $payment_id );
83
+	do_action('give_update_edited_donation', $payment_id);
84 84
 
85 85
 	$payment->date = $date;
86 86
 	$updated       = $payment->save();
87 87
 
88
-	if ( 0 === $updated ) {
89
-		wp_die( esc_html__( 'Error Updating Donation.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
88
+	if (0 === $updated) {
89
+		wp_die(esc_html__('Error Updating Donation.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
90 90
 	}
91 91
 
92 92
 	$donor_changed = false;
93 93
 
94
-	if ( isset( $data['give-new-donor'] ) && $data['give-new-donor'] == '1' ) {
94
+	if (isset($data['give-new-donor']) && $data['give-new-donor'] == '1') {
95 95
 
96
-		$email = isset( $data['give-new-donor-email'] ) ? sanitize_text_field( $data['give-new-donor-email'] ) : '';
97
-		$names = isset( $data['give-new-donor-name'] ) ? sanitize_text_field( $data['give-new-donor-name'] ) : '';
96
+		$email = isset($data['give-new-donor-email']) ? sanitize_text_field($data['give-new-donor-email']) : '';
97
+		$names = isset($data['give-new-donor-name']) ? sanitize_text_field($data['give-new-donor-name']) : '';
98 98
 
99
-		if ( empty( $email ) || empty( $names ) ) {
100
-			wp_die( esc_html__( 'New donors require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
99
+		if (empty($email) || empty($names)) {
100
+			wp_die(esc_html__('New donors require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
101 101
 		}
102 102
 
103
-		$donor = new Give_Donor( $email );
104
-		if ( empty( $donor->id ) ) {
105
-			$donor_data = array( 'name' => $names, 'email' => $email );
106
-			$user_id       = email_exists( $email );
107
-			if ( false !== $user_id ) {
103
+		$donor = new Give_Donor($email);
104
+		if (empty($donor->id)) {
105
+			$donor_data = array('name' => $names, 'email' => $email);
106
+			$user_id = email_exists($email);
107
+			if (false !== $user_id) {
108 108
 				$donor_data['user_id'] = $user_id;
109 109
 			}
110 110
 
111
-			if ( ! $donor->create( $donor_data ) ) {
111
+			if ( ! $donor->create($donor_data)) {
112 112
 				// Failed to crete the new donor, assume the previous donor.
113 113
 				$donor_changed = false;
114
-				$donor         = new Give_Donor( $curr_donor_id );
115
-				give_set_error( 'give-payment-new-donor-fail', __( 'Error creating new donor.', 'give' ) );
114
+				$donor         = new Give_Donor($curr_donor_id);
115
+				give_set_error('give-payment-new-donor-fail', __('Error creating new donor.', 'give'));
116 116
 			}
117 117
 		}
118 118
 
119 119
 		$new_donor_id = $donor->id;
120 120
 
121
-		$previous_donor = new Give_Donor( $curr_donor_id );
121
+		$previous_donor = new Give_Donor($curr_donor_id);
122 122
 
123 123
 		$donor_changed = true;
124 124
 
125
-	} elseif ( $curr_donor_id !== $new_donor_id ) {
125
+	} elseif ($curr_donor_id !== $new_donor_id) {
126 126
 
127
-		$donor = new Give_Donor( $new_donor_id );
127
+		$donor = new Give_Donor($new_donor_id);
128 128
 		$email    = $donor->email;
129 129
 		$names    = $donor->name;
130 130
 
131
-		$previous_donor = new Give_Donor( $curr_donor_id );
131
+		$previous_donor = new Give_Donor($curr_donor_id);
132 132
 
133 133
 		$donor_changed = true;
134 134
 
135 135
 	} else {
136 136
 
137
-		$donor = new Give_Donor( $curr_donor_id );
137
+		$donor = new Give_Donor($curr_donor_id);
138 138
 		$email    = $donor->email;
139 139
 		$names    = $donor->name;
140 140
 
141 141
 	}
142 142
 
143 143
 	// Setup first and last name from input values.
144
-	$names      = explode( ' ', $names );
145
-	$first_name = ! empty( $names[0] ) ? $names[0] : '';
144
+	$names      = explode(' ', $names);
145
+	$first_name = ! empty($names[0]) ? $names[0] : '';
146 146
 	$last_name  = '';
147
-	if ( ! empty( $names[1] ) ) {
148
-		unset( $names[0] );
149
-		$last_name = implode( ' ', $names );
147
+	if ( ! empty($names[1])) {
148
+		unset($names[0]);
149
+		$last_name = implode(' ', $names);
150 150
 	}
151 151
 
152
-	if ( $donor_changed ) {
152
+	if ($donor_changed) {
153 153
 
154 154
 		// Remove the stats and payment from the previous donor and attach it to the new donor.
155
-		$previous_donor->remove_payment( $payment_id, false );
156
-		$donor->attach_payment( $payment_id, false );
155
+		$previous_donor->remove_payment($payment_id, false);
156
+		$donor->attach_payment($payment_id, false);
157 157
 
158
-		if ( 'publish' == $status ) {
158
+		if ('publish' == $status) {
159 159
 
160 160
 			// Reduce previous user donation count and amount.
161 161
 			$previous_donor->decrease_donation_count();
162
-			$previous_donor->decrease_value( $curr_total );
162
+			$previous_donor->decrease_value($curr_total);
163 163
 
164 164
 			// If donation was completed adjust stats of new donors.
165 165
 			$donor->increase_purchase_count();
166
-			$donor->increase_value( $new_total );
166
+			$donor->increase_value($new_total);
167 167
 		}
168 168
 
169 169
 		$payment->customer_id = $donor->id;
170 170
 	} else {
171 171
 
172
-		if ( 'publish' === $status ) {
172
+		if ('publish' === $status) {
173 173
 			// Update user donation stat.
174
-			$donor->update_donation_value( $curr_total, $new_total );
174
+			$donor->update_donation_value($curr_total, $new_total);
175 175
 		}
176 176
 	}
177 177
 
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 	$payment->total      = $new_total;
185 185
 
186 186
 	// Check for payment notes.
187
-	if ( ! empty( $data['give-payment-note'] ) ) {
187
+	if ( ! empty($data['give-payment-note'])) {
188 188
 
189
-		$note = wp_kses( $data['give-payment-note'], array() );
190
-		give_insert_payment_note( $payment_id, $note );
189
+		$note = wp_kses($data['give-payment-note'], array());
190
+		give_insert_payment_note($payment_id, $note);
191 191
 
192 192
 	}
193 193
 
@@ -195,17 +195,17 @@  discard block
 block discarded – undo
195 195
 	$payment->status = $status;
196 196
 
197 197
 	// Adjust total store earnings if the payment total has been changed.
198
-	if ( $new_total !== $curr_total && 'publish' == $status ) {
198
+	if ($new_total !== $curr_total && 'publish' == $status) {
199 199
 
200
-		if ( $new_total > $curr_total ) {
200
+		if ($new_total > $curr_total) {
201 201
 			// Increase if our new total is higher.
202 202
 			$difference = $new_total - $curr_total;
203
-			give_increase_total_earnings( $difference );
203
+			give_increase_total_earnings($difference);
204 204
 
205
-		} elseif ( $curr_total > $new_total ) {
205
+		} elseif ($curr_total > $new_total) {
206 206
 			// Decrease if our new total is lower.
207 207
 			$difference = $curr_total - $new_total;
208
-			give_decrease_total_earnings( $difference );
208
+			give_decrease_total_earnings($difference);
209 209
 
210 210
 		}
211 211
 	}
@@ -213,16 +213,16 @@  discard block
 block discarded – undo
213 213
 	$payment->save();
214 214
 
215 215
 	// Get new give form ID.
216
-	$new_form_id     = absint( $data['give-payment-form-select'] );
217
-	$current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) );
216
+	$new_form_id     = absint($data['give-payment-form-select']);
217
+	$current_form_id = absint($payment->get_meta('_give_payment_form_id'));
218 218
 
219 219
 	// We are adding payment transfer code in last to remove any conflict with above functionality.
220 220
 	// For example: above code will automatically handle form stat (increase/decrease) when payment status changes.
221 221
 	// Check if user want to transfer current payment to new give form id.
222
-	if ( $new_form_id != $current_form_id ) {
222
+	if ($new_form_id != $current_form_id) {
223 223
 
224 224
 		// Get new give form title.
225
-		$new_form_title = get_the_title( $new_form_id );
225
+		$new_form_title = get_the_title($new_form_id);
226 226
 
227 227
 		// Update new give form data in payment data.
228 228
 		$payment_meta               = $payment->get_meta();
@@ -230,43 +230,43 @@  discard block
 block discarded – undo
230 230
 		$payment_meta['form_id']    = $new_form_id;
231 231
 
232 232
 		// Update price id post meta data for set donation form.
233
-		if ( ! give_has_variable_prices( $new_form_id ) ) {
233
+		if ( ! give_has_variable_prices($new_form_id)) {
234 234
 			$payment_meta['price_id'] = '';
235 235
 		}
236 236
 
237 237
 		// Update payment give form meta data.
238
-		$payment->update_meta( '_give_payment_form_id', $new_form_id );
239
-		$payment->update_meta( '_give_payment_form_title', $new_form_title );
240
-		$payment->update_meta( '_give_payment_meta', $payment_meta );
238
+		$payment->update_meta('_give_payment_form_id', $new_form_id);
239
+		$payment->update_meta('_give_payment_form_title', $new_form_title);
240
+		$payment->update_meta('_give_payment_meta', $payment_meta);
241 241
 
242 242
 		// Update price id payment metadata.
243
-		if ( ! give_has_variable_prices( $new_form_id ) ) {
244
-			$payment->update_meta( '_give_payment_price_id', '' );
243
+		if ( ! give_has_variable_prices($new_form_id)) {
244
+			$payment->update_meta('_give_payment_price_id', '');
245 245
 		}
246 246
 
247 247
 		// If donation was completed, adjust stats of forms.
248
-		if ( 'publish' == $status ) {
248
+		if ('publish' == $status) {
249 249
 
250 250
 			// Decrease sale of old give form. For other payment status.
251
-			$current_form = new Give_Donate_Form( $current_form_id );
251
+			$current_form = new Give_Donate_Form($current_form_id);
252 252
 			$current_form->decrease_sales();
253
-			$current_form->decrease_earnings( $curr_total );
253
+			$current_form->decrease_earnings($curr_total);
254 254
 
255 255
 			// Increase sale of new give form.
256
-			$new_form = new Give_Donate_Form( $new_form_id );
256
+			$new_form = new Give_Donate_Form($new_form_id);
257 257
 			$new_form->increase_sales();
258
-			$new_form->increase_earnings( $new_total );
258
+			$new_form->increase_earnings($new_total);
259 259
 		}
260 260
 
261 261
 		// Re setup payment to update new meta value in object.
262
-		$payment->update_payment_setup( $payment->ID );
262
+		$payment->update_payment_setup($payment->ID);
263 263
 	}
264 264
 
265 265
 	// Update price id if current form is variable form.
266 266
 	/* @var Give_Donate_Form $form */
267
-	$form = new Give_Donate_Form( $payment->form_id );
267
+	$form = new Give_Donate_Form($payment->form_id);
268 268
 
269
-	if ( isset( $data['give-variable-price'] ) && $form->has_variable_prices() ) {
269
+	if (isset($data['give-variable-price']) && $form->has_variable_prices()) {
270 270
 
271 271
 		// Get payment meta data.
272 272
 		$payment_meta = $payment->get_meta();
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 		$price_id = '';
276 276
 
277 277
 		// Get price info
278
-		if( 0 <= $data['give-variable-price'] ) {
279
-			foreach ( $form->prices as $variable_price ) {
280
-				if( $new_total === give_maybe_sanitize_amount( $variable_price['_give_amount'] ) ) {
278
+		if (0 <= $data['give-variable-price']) {
279
+			foreach ($form->prices as $variable_price) {
280
+				if ($new_total === give_maybe_sanitize_amount($variable_price['_give_amount'])) {
281 281
 					$price_info = $variable_price;
282 282
 					break;
283 283
 				}
@@ -285,15 +285,15 @@  discard block
 block discarded – undo
285 285
 		}
286 286
 
287 287
 		// Set price id.
288
-		if( ! empty( $price_info ) ) {
288
+		if ( ! empty($price_info)) {
289 289
 			$price_id = $data['give-variable-price'];
290 290
 
291
-			if( $data['give-variable-price'] !== $price_info['_give_id']['level_id'] ) {
291
+			if ($data['give-variable-price'] !== $price_info['_give_id']['level_id']) {
292 292
 				// Set price id to amount match.
293 293
 				$price_id = $price_info['_give_id']['level_id'];
294 294
 			}
295 295
 
296
-		} elseif( $form->is_custom_price_mode() ){
296
+		} elseif ($form->is_custom_price_mode()) {
297 297
 			$price_id = 'custom';
298 298
 		}
299 299
 
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
 		$payment_meta['price_id'] = $price_id;
302 302
 
303 303
 		// Update payment give form meta data.
304
-		$payment->update_meta( '_give_payment_price_id', $price_id );
305
-		$payment->update_meta( '_give_payment_meta', $payment_meta );
304
+		$payment->update_meta('_give_payment_price_id', $price_id);
305
+		$payment->update_meta('_give_payment_meta', $payment_meta);
306 306
 
307 307
 		// Re setup payment to update new meta value in object.
308
-		$payment->update_payment_setup( $payment->ID );
308
+		$payment->update_payment_setup($payment->ID);
309 309
 	}
310 310
 
311 311
 	/**
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @param int $payment_id The ID of the payment.
318 318
 	 */
319
-	do_action( 'give_updated_edited_donation', $payment_id );
319
+	do_action('give_updated_edited_donation', $payment_id);
320 320
 
321
-	wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=payment-updated&id=' . $payment_id ) );
321
+	wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=payment-updated&id='.$payment_id));
322 322
 	exit;
323 323
 }
324 324
 
325
-add_action( 'give_update_payment_details', 'give_update_payment_details' );
325
+add_action('give_update_payment_details', 'give_update_payment_details');
326 326
 
327 327
 /**
328 328
  * Trigger a Donation Deletion.
@@ -333,48 +333,48 @@  discard block
 block discarded – undo
333 333
  *
334 334
  * @return void
335 335
  */
336
-function give_trigger_donation_delete( $data ) {
337
-	if ( wp_verify_nonce( $data['_wpnonce'], 'give_donation_nonce' ) ) {
336
+function give_trigger_donation_delete($data) {
337
+	if (wp_verify_nonce($data['_wpnonce'], 'give_donation_nonce')) {
338 338
 
339
-		$payment_id = absint( $data['purchase_id'] );
339
+		$payment_id = absint($data['purchase_id']);
340 340
 
341
-		if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
342
-			wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
341
+		if ( ! current_user_can('edit_give_payments', $payment_id)) {
342
+			wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
343 343
 		}
344 344
 
345
-		give_delete_donation( $payment_id );
346
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted' ) );
345
+		give_delete_donation($payment_id);
346
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted'));
347 347
 		give_die();
348 348
 	}
349 349
 }
350 350
 
351
-add_action( 'give_delete_payment', 'give_trigger_donation_delete' );
351
+add_action('give_delete_payment', 'give_trigger_donation_delete');
352 352
 
353 353
 /**
354 354
  * AJAX Store Donation Note
355 355
  */
356 356
 function give_ajax_store_payment_note() {
357 357
 
358
-	$payment_id = absint( $_POST['payment_id'] );
359
-	$note       = wp_kses( $_POST['note'], array() );
358
+	$payment_id = absint($_POST['payment_id']);
359
+	$note       = wp_kses($_POST['note'], array());
360 360
 
361
-	if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
362
-		wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
361
+	if ( ! current_user_can('edit_give_payments', $payment_id)) {
362
+		wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403));
363 363
 	}
364 364
 
365
-	if ( empty( $payment_id ) ) {
366
-		die( '-1' );
365
+	if (empty($payment_id)) {
366
+		die('-1');
367 367
 	}
368 368
 
369
-	if ( empty( $note ) ) {
370
-		die( '-1' );
369
+	if (empty($note)) {
370
+		die('-1');
371 371
 	}
372 372
 
373
-	$note_id = give_insert_payment_note( $payment_id, $note );
374
-	die( give_get_payment_note_html( $note_id ) );
373
+	$note_id = give_insert_payment_note($payment_id, $note);
374
+	die(give_get_payment_note_html($note_id));
375 375
 }
376 376
 
377
-add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' );
377
+add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note');
378 378
 
379 379
 /**
380 380
  * Triggers a donation note deletion without ajax
@@ -385,24 +385,24 @@  discard block
 block discarded – undo
385 385
  *
386 386
  * @return void
387 387
  */
388
-function give_trigger_payment_note_deletion( $data ) {
388
+function give_trigger_payment_note_deletion($data) {
389 389
 
390
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) {
390
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) {
391 391
 		return;
392 392
 	}
393 393
 
394
-	if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) {
395
-		wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
394
+	if ( ! current_user_can('edit_give_payments', $data['payment_id'])) {
395
+		wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
396 396
 	}
397 397
 
398
-	$edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=donation-note-deleted&id=' . absint( $data['payment_id'] ) );
398
+	$edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=donation-note-deleted&id='.absint($data['payment_id']));
399 399
 
400
-	give_delete_payment_note( $data['note_id'], $data['payment_id'] );
400
+	give_delete_payment_note($data['note_id'], $data['payment_id']);
401 401
 
402
-	wp_redirect( $edit_order_url );
402
+	wp_redirect($edit_order_url);
403 403
 }
404 404
 
405
-add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' );
405
+add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion');
406 406
 
407 407
 /**
408 408
  * Delete a payment note deletion with ajax
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
  */
414 414
 function give_ajax_delete_payment_note() {
415 415
 
416
-	if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) {
417
-		wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
416
+	if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) {
417
+		wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
418 418
 	}
419 419
 
420
-	if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) {
421
-		die( '1' );
420
+	if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) {
421
+		die('1');
422 422
 	} else {
423
-		die( '-1' );
423
+		die('-1');
424 424
 	}
425 425
 
426 426
 }
427 427
 
428
-add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' );
428
+add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note');
Please login to merge, or discard this patch.
includes/emails/functions.php 1 patch
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_email_donation_receipt( $payment_id, $admin_notice = true ) {
29
+function give_email_donation_receipt($payment_id, $admin_notice = true) {
30 30
 
31
-	$payment_data = give_get_payment_meta( $payment_id );
31
+	$payment_data = give_get_payment_meta($payment_id);
32 32
 
33
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
33
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
34 34
 
35 35
 	/**
36 36
 	 * Filters the from name.
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @since 1.0
42 42
 	 */
43
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
43
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
44 44
 
45
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
45
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
46 46
 
47 47
 	/**
48 48
 	 * Filters the from email.
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @since 1.0
54 54
 	 */
55
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
55
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
56 56
 
57
-	$to_email = give_get_payment_user_email( $payment_id );
57
+	$to_email = give_get_payment_user_email($payment_id);
58 58
 
59
-	$subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) );
59
+	$subject = give_get_option('donation_subject', __('Donation Receipt', 'give'));
60 60
 
61 61
 	/**
62 62
 	 * Filters the donation email receipt subject.
63 63
 	 *
64 64
 	 * @since 1.0
65 65
 	 */
66
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
67
-	$subject = give_do_email_tags( $subject, $payment_id );
66
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id);
67
+	$subject = give_do_email_tags($subject, $payment_id);
68 68
 
69 69
 	/**
70 70
 	 * Filters the donation email receipt attachments. By default, there is no attachment but plugins can hook in to provide one more multiple for the donor. Examples would be a printable ticket or PDF receipt.
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @since 1.0
76 76
 	 */
77
-	$attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data );
78
-	$message     = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id );
77
+	$attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data);
78
+	$message     = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id);
79 79
 
80 80
 	$emails = Give()->emails;
81 81
 
82
-	$emails->__set( 'from_name', $from_name );
83
-	$emails->__set( 'from_email', $from_email );
84
-	$emails->__set( 'heading', __( 'Donation Receipt', 'give' ) );
82
+	$emails->__set('from_name', $from_name);
83
+	$emails->__set('from_email', $from_email);
84
+	$emails->__set('heading', __('Donation Receipt', 'give'));
85 85
 
86 86
 	/**
87 87
 	 * Filters the donation receipt's email headers.
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @since 1.0
93 93
 	 */
94
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
95
-	$emails->__set( 'headers', $headers );
94
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
95
+	$emails->__set('headers', $headers);
96 96
 
97 97
 	//Send the donation receipt.
98
-	$emails->send( $to_email, $subject, $message, $attachments );
98
+	$emails->send($to_email, $subject, $message, $attachments);
99 99
 
100 100
 	//If admin notifications are on, send the admin notice.
101
-	if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) {
101
+	if ($admin_notice && ! give_admin_notices_disabled($payment_id)) {
102 102
 		/**
103 103
 		 * Fires in the donation email receipt.
104 104
 		 *
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		 * @param int   $payment_id   Payment id.
110 110
 		 * @param mixed $payment_data Payment meta data.
111 111
 		 */
112
-		do_action( 'give_admin_donation_email', $payment_id, $payment_data );
112
+		do_action('give_admin_donation_email', $payment_id, $payment_data);
113 113
 	}
114 114
 }
115 115
 
@@ -122,41 +122,41 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function give_email_test_donation_receipt() {
124 124
 
125
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
125
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
126 126
 
127 127
 	/**
128 128
 	 * Filters the from name.
129 129
 	 *
130 130
 	 * @since 1.7
131 131
 	 */
132
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() );
132
+	$from_name = apply_filters('give_donation_from_name', $from_name, 0, array());
133 133
 
134
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
134
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
135 135
 
136 136
 	/**
137 137
 	 * Filters the from email.
138 138
 	 *
139 139
 	 * @since 1.7
140 140
 	 */
141
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() );
141
+	$from_email = apply_filters('give_donation_from_address', $from_email, 0, array());
142 142
 
143
-	$subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) );
144
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 );
145
-	$subject = give_do_email_tags( $subject, 0 );
143
+	$subject = give_get_option('donation_subject', __('Donation Receipt', 'give'));
144
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0);
145
+	$subject = give_do_email_tags($subject, 0);
146 146
 
147
-	$attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() );
147
+	$attachments = apply_filters('give_receipt_attachments', array(), 0, array());
148 148
 
149
-	$message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
149
+	$message = give_email_preview_template_tags(give_get_email_body_content(0, array()));
150 150
 
151 151
 	$emails = Give()->emails;
152
-	$emails->__set( 'from_name', $from_name );
153
-	$emails->__set( 'from_email', $from_email );
154
-	$emails->__set( 'heading', __( 'Donation Receipt', 'give' ) );
152
+	$emails->__set('from_name', $from_name);
153
+	$emails->__set('from_email', $from_email);
154
+	$emails->__set('heading', __('Donation Receipt', 'give'));
155 155
 
156
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() );
157
-	$emails->__set( 'headers', $headers );
156
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array());
157
+	$emails->__set('headers', $headers);
158 158
 
159
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
159
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
160 160
 
161 161
 }
162 162
 
@@ -170,49 +170,49 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return void
172 172
  */
173
-function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) {
173
+function give_admin_email_notice($payment_id = 0, $payment_data = array()) {
174 174
 
175
-	$payment_id = absint( $payment_id );
175
+	$payment_id = absint($payment_id);
176 176
 
177
-	if ( empty( $payment_id ) ) {
177
+	if (empty($payment_id)) {
178 178
 		return;
179 179
 	}
180 180
 
181
-	if ( ! give_get_payment_by( 'id', $payment_id ) ) {
181
+	if ( ! give_get_payment_by('id', $payment_id)) {
182 182
 		return;
183 183
 	}
184 184
 
185
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
185
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
186 186
 
187 187
 	/**
188 188
 	 * Filters the from name.
189 189
 	 *
190 190
 	 * @since 1.0
191 191
 	 */
192
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
192
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
193 193
 
194
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
194
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
195 195
 
196 196
 	/**
197 197
 	 * Filters the from email.
198 198
 	 *
199 199
 	 * @since 1.0
200 200
 	 */
201
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
201
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
202 202
 
203 203
 	/* translators: %s: payment id */
204
-	$subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) );
204
+	$subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id));
205 205
 
206 206
 	/**
207 207
 	 * Filters the donation notification subject.
208 208
 	 *
209 209
 	 * @since 1.0
210 210
 	 */
211
-	$subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id );
212
-	$subject = give_do_email_tags( $subject, $payment_id );
211
+	$subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id);
212
+	$subject = give_do_email_tags($subject, $payment_id);
213 213
 
214
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
215
-	$headers .= "Reply-To: " . $from_email . "\r\n";
214
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
215
+	$headers .= "Reply-To: ".$from_email."\r\n";
216 216
 	//$headers  .= "MIME-Version: 1.0\r\n";
217 217
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
218 218
 
@@ -221,28 +221,28 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @since 1.0
223 223
 	 */
224
-	$headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data );
224
+	$headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data);
225 225
 
226 226
 	/**
227 227
 	 * Filters the donation notification email attachments. By default, there is no attachment but plugins can hook in to provide one more multiple.
228 228
 	 *
229 229
 	 * @since 1.0
230 230
 	 */
231
-	$attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data );
231
+	$attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data);
232 232
 
233
-	$message = give_get_donation_notification_body_content( $payment_id, $payment_data );
233
+	$message = give_get_donation_notification_body_content($payment_id, $payment_data);
234 234
 
235 235
 	$emails = Give()->emails;
236
-	$emails->__set( 'from_name', $from_name );
237
-	$emails->__set( 'from_email', $from_email );
238
-	$emails->__set( 'headers', $headers );
239
-	$emails->__set( 'heading', __( 'New Donation!', 'give' ) );
236
+	$emails->__set('from_name', $from_name);
237
+	$emails->__set('from_email', $from_email);
238
+	$emails->__set('headers', $headers);
239
+	$emails->__set('heading', __('New Donation!', 'give'));
240 240
 
241
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
241
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
242 242
 
243 243
 }
244 244
 
245
-add_action( 'give_admin_donation_email', 'give_admin_email_notice', 10, 2 );
245
+add_action('give_admin_donation_email', 'give_admin_email_notice', 10, 2);
246 246
 
247 247
 /**
248 248
  * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings).
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
  */
253 253
 function give_get_admin_notice_emails() {
254 254
 
255
-	$email_option = give_get_option( 'admin_notice_emails' );
255
+	$email_option = give_get_option('admin_notice_emails');
256 256
 
257
-	$emails = ! empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' );
258
-	$emails = give_clean( explode( "\n", $emails ) );
257
+	$emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email');
258
+	$emails = give_clean(explode("\n", $emails));
259 259
 
260
-	return apply_filters( 'give_admin_notice_emails', $emails );
260
+	return apply_filters('give_admin_notice_emails', $emails);
261 261
 }
262 262
 
263 263
 /**
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return mixed
271 271
  */
272
-function give_admin_notices_disabled( $payment_id = 0 ) {
272
+function give_admin_notices_disabled($payment_id = 0) {
273 273
 
274 274
 	return apply_filters(
275 275
 		'give_admin_notices_disabled',
276
-		! give_is_setting_enabled( give_get_option( 'admin_notices' ) ),
276
+		! give_is_setting_enabled(give_get_option('admin_notices')),
277 277
 		$payment_id
278 278
 	);
279 279
 }
@@ -288,19 +288,19 @@  discard block
 block discarded – undo
288 288
  */
289 289
 function give_get_default_donation_notification_email() {
290 290
 
291
-	$default_email_body = __( 'Hi there,', 'give' ) . "\n\n";
292
-	$default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n";
293
-	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n";
294
-	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
295
-	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
296
-	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n";
297
-	$default_email_body .= __( 'Thank you,', 'give' ) . "\n\n";
298
-	$default_email_body .= '{sitename}' . "\n";
291
+	$default_email_body = __('Hi there,', 'give')."\n\n";
292
+	$default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n";
293
+	$default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n";
294
+	$default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n";
295
+	$default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n";
296
+	$default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n";
297
+	$default_email_body .= __('Thank you,', 'give')."\n\n";
298
+	$default_email_body .= '{sitename}'."\n";
299 299
 
300
-	$custom_message = give_get_option( 'donation_notification' );
301
-	$message        = ! empty( $custom_message ) ? $custom_message : $default_email_body;
300
+	$custom_message = give_get_option('donation_notification');
301
+	$message        = ! empty($custom_message) ? $custom_message : $default_email_body;
302 302
 
303
-	return apply_filters( 'give_default_donation_notification_email', $message );
303
+	return apply_filters('give_default_donation_notification_email', $message);
304 304
 }
305 305
 
306 306
 
@@ -314,25 +314,25 @@  discard block
 block discarded – undo
314 314
  */
315 315
 function give_get_default_donation_receipt_email() {
316 316
 
317
-	$default_email_body = __( 'Dear', 'give' ) . " {name},\n\n";
318
-	$default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
319
-	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
320
-	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
321
-	$default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n";
322
-	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
323
-	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n";
324
-	$default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n";
325
-	$default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n";
326
-	$default_email_body .= '{receipt_link}' . "\n\n";
317
+	$default_email_body = __('Dear', 'give')." {name},\n\n";
318
+	$default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n";
319
+	$default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n";
320
+	$default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n";
321
+	$default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n";
322
+	$default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n";
323
+	$default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n";
324
+	$default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n";
325
+	$default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n";
326
+	$default_email_body .= '{receipt_link}'."\n\n";
327 327
 	$default_email_body .= "\n\n";
328
-	$default_email_body .= __( 'Sincerely,', 'give' ) . "\n";
329
-	$default_email_body .= '{sitename}' . "\n";
328
+	$default_email_body .= __('Sincerely,', 'give')."\n";
329
+	$default_email_body .= '{sitename}'."\n";
330 330
 
331
-	$custom_message = give_get_option( 'donation_receipt' );
331
+	$custom_message = give_get_option('donation_receipt');
332 332
 
333
-	$message = ! empty( $custom_message ) ? $custom_message : $default_email_body;
333
+	$message = ! empty($custom_message) ? $custom_message : $default_email_body;
334 334
 
335
-	return apply_filters( 'give_default_donation_receipt_email', $message );
335
+	return apply_filters('give_default_donation_receipt_email', $message);
336 336
 }
337 337
 
338 338
 /**
@@ -345,22 +345,22 @@  discard block
 block discarded – undo
345 345
  *
346 346
  * @return array $email_names
347 347
  */
348
-function give_get_email_names( $user_info, $payment = false ) {
348
+function give_get_email_names($user_info, $payment = false) {
349 349
 	$email_names = array();
350 350
 
351
-	if ( is_a( $payment, 'Give_Payment' ) ) {
351
+	if (is_a($payment, 'Give_Payment')) {
352 352
 
353
-		if ( $payment->user_id > 0 ) {
353
+		if ($payment->user_id > 0) {
354 354
 
355
-			$user_data               = get_userdata( $payment->user_id );
355
+			$user_data               = get_userdata($payment->user_id);
356 356
 			$email_names['name']     = $payment->first_name;
357
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
357
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
358 358
 			$email_names['username'] = $user_data->user_login;
359 359
 
360
-		} elseif ( ! empty( $payment->first_name ) ) {
360
+		} elseif ( ! empty($payment->first_name)) {
361 361
 
362 362
 			$email_names['name']     = $payment->first_name;
363
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
363
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
364 364
 			$email_names['username'] = $payment->first_name;
365 365
 
366 366
 		} else {
@@ -373,30 +373,30 @@  discard block
 block discarded – undo
373 373
 	} else {
374 374
 
375 375
 		// Support for old serialized data.
376
-		if ( is_serialized( $user_info ) ) {
376
+		if (is_serialized($user_info)) {
377 377
 
378 378
 			// Security check.
379
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
380
-			if ( ! empty( $matches ) ) {
379
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
380
+			if ( ! empty($matches)) {
381 381
 				return array(
382 382
 					'name'     => '',
383 383
 					'fullname' => '',
384 384
 					'username' => '',
385 385
 				);
386 386
 			} else {
387
-				$user_info = maybe_unserialize( $user_info );
387
+				$user_info = maybe_unserialize($user_info);
388 388
 			}
389 389
 
390 390
 		}
391 391
 
392
-		if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
393
-			$user_data               = get_userdata( $user_info['id'] );
392
+		if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) {
393
+			$user_data               = get_userdata($user_info['id']);
394 394
 			$email_names['name']     = $user_info['first_name'];
395
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
395
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
396 396
 			$email_names['username'] = $user_data->user_login;
397
-		} elseif ( isset( $user_info['first_name'] ) ) {
397
+		} elseif (isset($user_info['first_name'])) {
398 398
 			$email_names['name']     = $user_info['first_name'];
399
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
399
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
400 400
 			$email_names['username'] = $user_info['first_name'];
401 401
 		} else {
402 402
 			$email_names['name']     = $user_info['email'];
@@ -416,37 +416,37 @@  discard block
 block discarded – undo
416 416
  *
417 417
  * @since 1.8.14
418 418
  */
419
-function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) {
419
+function give_admin_email_user_donor_disconnection($user_id, $donor_id) {
420 420
 
421
-	$user_id  = absint( $user_id );
422
-	$donor_id = absint( $donor_id );
421
+	$user_id  = absint($user_id);
422
+	$donor_id = absint($donor_id);
423 423
 
424 424
 	// Bail Out, if user id doesn't exists.
425
-	if ( empty( $user_id ) ) {
425
+	if (empty($user_id)) {
426 426
 		return;
427 427
 	}
428 428
 
429 429
 	// Bail Out, if donor id doesn't exists.
430
-	if ( empty( $donor_id ) ) {
430
+	if (empty($donor_id)) {
431 431
 		return;
432 432
 	}
433 433
 
434
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
434
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
435 435
 
436
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
436
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
437 437
 
438 438
 	/* translators: %s: payment id */
439
-	$subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' );
439
+	$subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give');
440 440
 
441 441
 	/**
442 442
 	 * Filters the Donor-User Disconnection notification subject.
443 443
 	 *
444 444
 	 * @since 1.8.14
445 445
 	 */
446
-	$subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) );
446
+	$subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject));
447 447
 
448
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
449
-	$headers .= "Reply-To: " . $from_email . "\r\n";
448
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
449
+	$headers .= "Reply-To: ".$from_email."\r\n";
450 450
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
451 451
 
452 452
 	/**
@@ -454,25 +454,25 @@  discard block
 block discarded – undo
454 454
 	 *
455 455
 	 * @since 1.8.14
456 456
 	 */
457
-	$headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers );
457
+	$headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers);
458 458
 
459
-	$message = __( 'Hi Admin,', 'give' ) . "\n\n";
460
-	$message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n";
461
-	$message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n";
459
+	$message = __('Hi Admin,', 'give')."\n\n";
460
+	$message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n";
461
+	$message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n";
462 462
 	$message .= sprintf(
463 463
 		'<a href="%1$s">%2$s</a>',
464
-		esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ),
465
-		__( 'Reconnect User', 'give' ) . "\n\n"
464
+		esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-message=reconnect-user'),
465
+		__('Reconnect User', 'give')."\n\n"
466 466
 	);
467
-	$message .= __( 'Thank you,', 'give' ) . "\n\n";
468
-	$message .= '{sitename}' . "\n";
467
+	$message .= __('Thank you,', 'give')."\n\n";
468
+	$message .= '{sitename}'."\n";
469 469
 
470 470
 	$emails = Give()->emails;
471
-	$emails->__set( 'from_name', $from_name );
472
-	$emails->__set( 'from_email', $from_email );
473
-	$emails->__set( 'headers', $headers );
474
-	$emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) );
471
+	$emails->__set('from_name', $from_name);
472
+	$emails->__set('from_email', $from_email);
473
+	$emails->__set('headers', $headers);
474
+	$emails->__set('heading', __('User - Donor Profile Disconnection', 'give'));
475 475
 
476
-	$emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) );
476
+	$emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message));
477 477
 
478 478
 }
Please login to merge, or discard this patch.
includes/class-notices.php 1 patch
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
 	 * @since 1.0
54 54
 	 */
55 55
 	public function __construct() {
56
-		add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 );
57
-		add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) );
56
+		add_action('admin_notices', array($this, 'render_admin_notices'), 999);
57
+		add_action('give_dismiss_notices', array($this, 'dismiss_notices'));
58 58
 
59
-		add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 );
60
-		add_action( 'give_donation_form_before_personal_info', array( $this, 'render_frontend_notices' ) );
61
-		add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) );
59
+		add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999);
60
+		add_action('give_donation_form_before_personal_info', array($this, 'render_frontend_notices'));
61
+		add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices'));
62 62
 
63 63
 		/**
64 64
 		 * Backward compatibility for deprecated params.
65 65
 		 *
66 66
 		 * @since 1.8.14
67 67
 		 */
68
-		add_filter( 'give_register_notice_args', array( $this, 'bc_deprecated_params' ) );
69
-		add_filter( 'give_frontend_errors_args', array( $this, 'bc_deprecated_params' ) );
70
-		add_filter( 'give_frontend_notice_args', array( $this, 'bc_deprecated_params' ) );
68
+		add_filter('give_register_notice_args', array($this, 'bc_deprecated_params'));
69
+		add_filter('give_frontend_errors_args', array($this, 'bc_deprecated_params'));
70
+		add_filter('give_frontend_notice_args', array($this, 'bc_deprecated_params'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return array
82 82
 	 */
83
-	public function bc_deprecated_params( $args ) {
83
+	public function bc_deprecated_params($args) {
84 84
 		/**
85 85
 		 *  Param: auto_dismissible
86 86
 		 *  deprecated in 1.8.14
87 87
 		 *
88 88
 		 *  Check if auto_dismissible is set and it true then unset and change dismissible parameter value to auto
89 89
 		 */
90
-		if ( isset( $args['auto_dismissible'] ) ) {
91
-			if ( ! empty( $args['auto_dismissible'] ) ) {
90
+		if (isset($args['auto_dismissible'])) {
91
+			if ( ! empty($args['auto_dismissible'])) {
92 92
 				$args['dismissible'] = 'auto';
93 93
 			}
94 94
 			// unset auto_dismissible as it has been deprecated.
95
-			unset( $args['auto_dismissible'] );
95
+			unset($args['auto_dismissible']);
96 96
 		}
97 97
 
98 98
 		return $args;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return bool
110 110
 	 */
111
-	public function register_notice( $notice_args ) {
111
+	public function register_notice($notice_args) {
112 112
 		// Bailout.
113
-		if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) {
113
+		if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) {
114 114
 			return false;
115 115
 		}
116 116
 
@@ -148,39 +148,39 @@  discard block
 block discarded – undo
148 148
 		 *
149 149
 		 * @since 1.8.14
150 150
 		 */
151
-		$notice_args = apply_filters( 'give_register_notice_args', $notice_args );
151
+		$notice_args = apply_filters('give_register_notice_args', $notice_args);
152 152
 
153 153
 		// Set extra dismiss links if any.
154
-		if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) {
154
+		if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) {
155 155
 
156
-			preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link );
156
+			preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link);
157 157
 
158
-			if ( ! empty( $extra_notice_dismiss_link ) ) {
159
-				$extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 );
160
-				foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) {
158
+			if ( ! empty($extra_notice_dismiss_link)) {
159
+				$extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3);
160
+				foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) {
161 161
 					// Create array og key ==> value by parsing query string created after renaming data attributes.
162
-					$data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array(
162
+					$data_attribute_query_str = str_replace(array('data-', '-', '"'), array(
163 163
 						'',
164 164
 						'_',
165 165
 						'',
166
-					), implode( '&', $extra_notice_dismiss_link ) );
166
+					), implode('&', $extra_notice_dismiss_link));
167 167
 
168
-					$notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str );
168
+					$notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str);
169 169
 				}
170 170
 			}
171 171
 		}
172 172
 
173 173
 
174
-		self::$notices[ $notice_args['id'] ] = $notice_args;
174
+		self::$notices[$notice_args['id']] = $notice_args;
175 175
 
176 176
 		// Auto set show param if not already set.
177
-		if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) {
178
-			self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true;
177
+		if ( ! isset(self::$notices[$notice_args['id']]['show'])) {
178
+			self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true;
179 179
 		}
180 180
 
181 181
 		// Auto set time interval for shortly.
182
-		if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) {
183
-			self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS;
182
+		if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) {
183
+			self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS;
184 184
 		}
185 185
 
186 186
 		return true;
@@ -194,44 +194,44 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function render_admin_notices() {
196 196
 		// Bailout.
197
-		if ( empty( self::$notices ) ) {
197
+		if (empty(self::$notices)) {
198 198
 			return;
199 199
 		}
200 200
 
201 201
 		$output = '';
202 202
 
203
-		foreach ( self::$notices as $notice_id => $notice ) {
203
+		foreach (self::$notices as $notice_id => $notice) {
204 204
 			// Check flag set to true to show notice.
205
-			if ( ! $notice['show'] ) {
205
+			if ( ! $notice['show']) {
206 206
 				continue;
207 207
 			}
208 208
 
209 209
 			// Check if notice dismissible or not.
210
-			if ( ! self::$has_auto_dismissible_notice ) {
211
-				self::$has_auto_dismissible_notice = ( 'auto' === $notice['dismissible'] );
210
+			if ( ! self::$has_auto_dismissible_notice) {
211
+				self::$has_auto_dismissible_notice = ('auto' === $notice['dismissible']);
212 212
 			}
213 213
 
214 214
 			// Check if notice dismissible or not.
215
-			if ( ! self::$has_dismiss_interval_notice ) {
215
+			if ( ! self::$has_dismiss_interval_notice) {
216 216
 				self::$has_dismiss_interval_notice = $notice['dismiss_interval'];
217 217
 			}
218 218
 
219
-			$css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] );
219
+			$css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']);
220 220
 
221
-			$css_class = 'give-notice notice ' . ( empty( $notice['dismissible'] ) ? 'non' : 'is' ) . "-dismissible {$notice['type']} notice-{$notice['type']}";
222
-			$output    .= sprintf(
223
-				'<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">' . " \n",
221
+			$css_class = 'give-notice notice '.(empty($notice['dismissible']) ? 'non' : 'is')."-dismissible {$notice['type']} notice-{$notice['type']}";
222
+			$output .= sprintf(
223
+				'<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">'." \n",
224 224
 				$css_id,
225 225
 				$css_class,
226
-				give_clean( $notice['dismissible'] ),
226
+				give_clean($notice['dismissible']),
227 227
 				$notice['dismissible_type'],
228 228
 				$notice['dismiss_interval'],
229 229
 				$notice['id'],
230
-				empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ),
230
+				empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"),
231 231
 				$notice['dismiss_interval_time']
232 232
 			);
233 233
 
234
-			$output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" );
234
+			$output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>");
235 235
 			$output .= "</div> \n";
236 236
 		}
237 237
 
@@ -249,18 +249,18 @@  discard block
 block discarded – undo
249 249
 	 *
250 250
 	 * @param int $form_id
251 251
 	 */
252
-	public function render_frontend_notices( $form_id = 0 ) {
252
+	public function render_frontend_notices($form_id = 0) {
253 253
 		$errors = give_get_errors();
254 254
 
255
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0;
255
+		$request_form_id = isset($_REQUEST['form-id']) ? absint($_REQUEST['form-id']) : 0;
256 256
 
257 257
 		// Sanity checks first: Ensure that gateway returned errors display on the appropriate form.
258
-		if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
258
+		if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) {
259 259
 			return;
260 260
 		}
261 261
 
262
-		if ( $errors ) {
263
-			self::print_frontend_errors( $errors );
262
+		if ($errors) {
263
+			self::print_frontend_errors($errors);
264 264
 
265 265
 			give_clear_errors();
266 266
 		}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 * @access private
274 274
 	 */
275 275
 	private function print_js() {
276
-		if ( self::$has_auto_dismissible_notice ) :
276
+		if (self::$has_auto_dismissible_notice) :
277 277
 			?>
278 278
 			<script>
279 279
 				jQuery(document).ready(function () {
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 			<?php
290 290
 		endif;
291 291
 
292
-		if ( self::$has_dismiss_interval_notice ) :
292
+		if (self::$has_dismiss_interval_notice) :
293 293
 			?>
294 294
 			<script>
295 295
 				jQuery(document).ready(function () {
@@ -368,29 +368,29 @@  discard block
 block discarded – undo
368 368
 	 * @access public
369 369
 	 */
370 370
 	public function dismiss_notices() {
371
-		$_post     = give_clean( $_POST );
372
-		$notice_id = esc_attr( $_post['notice_id'] );
371
+		$_post     = give_clean($_POST);
372
+		$notice_id = esc_attr($_post['notice_id']);
373 373
 
374 374
 		// Bailout.
375 375
 		if (
376
-			empty( $notice_id ) ||
377
-			empty( $_post['dismissible_type'] ) ||
378
-			empty( $_post['dismiss_interval'] ) ||
379
-			! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' )
376
+			empty($notice_id) ||
377
+			empty($_post['dismissible_type']) ||
378
+			empty($_post['dismiss_interval']) ||
379
+			! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce')
380 380
 		) {
381 381
 			wp_send_json_error();
382 382
 		}
383 383
 
384
-		$notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] );
385
-		if ( 'user' === $_post['dismissible_type'] ) {
384
+		$notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']);
385
+		if ('user' === $_post['dismissible_type']) {
386 386
 			$current_user = wp_get_current_user();
387
-			$notice_key   = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID );
387
+			$notice_key   = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID);
388 388
 		}
389 389
 
390
-		$notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null;
390
+		$notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null;
391 391
 
392 392
 		// Save option to hide notice.
393
-		Give_Cache::set( $notice_key, true, $notice_dismiss_time, true );
393
+		Give_Cache::set($notice_key, true, $notice_dismiss_time, true);
394 394
 
395 395
 		wp_send_json_success();
396 396
 	}
@@ -408,18 +408,18 @@  discard block
 block discarded – undo
408 408
 	 *
409 409
 	 * @return string
410 410
 	 */
411
-	public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) {
411
+	public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) {
412 412
 		$notice_key = "_give_notice_{$notice_id}";
413 413
 
414
-		if ( ! empty( $dismiss_interval ) ) {
414
+		if ( ! empty($dismiss_interval)) {
415 415
 			$notice_key .= "_{$dismiss_interval}";
416 416
 		}
417 417
 
418
-		if ( $user_id ) {
418
+		if ($user_id) {
419 419
 			$notice_key .= "_{$user_id}";
420 420
 		}
421 421
 
422
-		$notice_key = sanitize_key( $notice_key );
422
+		$notice_key = sanitize_key($notice_key);
423 423
 
424 424
 		return $notice_key;
425 425
 	}
@@ -432,11 +432,11 @@  discard block
 block discarded – undo
432 432
 	 *
433 433
 	 * @return string
434 434
 	 */
435
-	public function get_dismiss_link( $notice_args ) {
435
+	public function get_dismiss_link($notice_args) {
436 436
 		$notice_args = wp_parse_args(
437 437
 			$notice_args,
438 438
 			array(
439
-				'title'                 => __( 'Click here', 'give' ),
439
+				'title'                 => __('Click here', 'give'),
440 440
 				'dismissible_type'      => '',
441 441
 				'dismiss_interval'      => '',
442 442
 				'dismiss_interval_time' => null,
@@ -463,31 +463,31 @@  discard block
 block discarded – undo
463 463
 	 *
464 464
 	 * @return bool|null
465 465
 	 */
466
-	public function is_notice_dismissed( $notice ) {
467
-		$notice_key          = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] );
466
+	public function is_notice_dismissed($notice) {
467
+		$notice_key          = $this->get_notice_key($notice['id'], $notice['dismiss_interval']);
468 468
 		$is_notice_dismissed = false;
469 469
 
470
-		if ( 'user' === $notice['dismissible_type'] ) {
470
+		if ('user' === $notice['dismissible_type']) {
471 471
 			$current_user = wp_get_current_user();
472
-			$notice_key   = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID );
472
+			$notice_key   = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID);
473 473
 		}
474 474
 
475
-		$notice_data = Give_Cache::get( $notice_key, true );
475
+		$notice_data = Give_Cache::get($notice_key, true);
476 476
 
477 477
 		// Find notice dismiss link status if notice has extra dismissible links.
478
-		if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) {
478
+		if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) {
479 479
 
480
-			foreach ( $notice['extra_links'] as $extra_link ) {
481
-				$new_notice_data = wp_parse_args( $extra_link, $notice );
482
-				unset( $new_notice_data['extra_links'] );
480
+			foreach ($notice['extra_links'] as $extra_link) {
481
+				$new_notice_data = wp_parse_args($extra_link, $notice);
482
+				unset($new_notice_data['extra_links']);
483 483
 
484
-				if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) {
484
+				if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) {
485 485
 					return $is_notice_dismissed;
486 486
 				}
487 487
 			}
488 488
 		}
489 489
 
490
-		$is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data );
490
+		$is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data);
491 491
 
492 492
 		return $is_notice_dismissed;
493 493
 	}
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @param array $errors
503 503
 	 */
504
-	public static function print_frontend_errors( $errors ) {
504
+	public static function print_frontend_errors($errors) {
505 505
 		// Bailout.
506
-		if ( ! $errors ) {
506
+		if ( ! $errors) {
507 507
 			return;
508 508
 		}
509 509
 
@@ -518,37 +518,37 @@  discard block
 block discarded – undo
518 518
 		);
519 519
 
520 520
 		// Note: we will remove give_errors class in future.
521
-		$classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) );
521
+		$classes = apply_filters('give_error_class', array('give_notices', 'give_errors'));
522 522
 
523
-		echo sprintf( '<div class="%s">', implode( ' ', $classes ) );
523
+		echo sprintf('<div class="%s">', implode(' ', $classes));
524 524
 
525 525
 		// Loop error codes and display errors.
526
-		foreach ( $errors as $error_id => $error ) {
526
+		foreach ($errors as $error_id => $error) {
527 527
 			// Backward compatibility v<1.8.11
528
-			if ( is_string( $error ) ) {
528
+			if (is_string($error)) {
529 529
 				$error = array(
530 530
 					'message'     => $error,
531 531
 					'notice_args' => array(),
532 532
 				);
533 533
 			}
534 534
 
535
-			$notice_args = wp_parse_args( $error['notice_args'], $default_notice_args );
535
+			$notice_args = wp_parse_args($error['notice_args'], $default_notice_args);
536 536
 
537 537
 			/**
538 538
 			 * Filter to modify Frontend Errors args before errors is display.
539 539
 			 *
540 540
 			 * @since 1.8.14
541 541
 			 */
542
-			$notice_args = apply_filters( 'give_frontend_errors_args', $notice_args );
542
+			$notice_args = apply_filters('give_frontend_errors_args', $notice_args);
543 543
 
544 544
 			echo sprintf(
545 545
 				'<div class="give_error give_notice" id="give_error_%1$s" data-dismissible="%2$s" data-dismiss-interval="%3$d">
546 546
 						<p><strong>%4$s</strong>: %5$s</p>
547 547
 					</div>',
548 548
 				$error_id,
549
-				give_clean( $notice_args['dismissible'] ),
550
-				absint( $notice_args['dismiss_interval'] ),
551
-				esc_html__( 'Error', 'give' ),
549
+				give_clean($notice_args['dismissible']),
550
+				absint($notice_args['dismiss_interval']),
551
+				esc_html__('Error', 'give'),
552 552
 				$error['message']
553 553
 			);
554 554
 		}
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 	 *
571 571
 	 * @return  string
572 572
 	 */
573
-	public static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) {
574
-		if ( empty( $message ) ) {
573
+	public static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) {
574
+		if (empty($message)) {
575 575
 			return '';
576 576
 		}
577 577
 
@@ -585,14 +585,14 @@  discard block
 block discarded – undo
585 585
 			'dismiss_interval' => 5000,
586 586
 		);
587 587
 
588
-		$notice_args = wp_parse_args( $notice_args, $default_notice_args );
588
+		$notice_args = wp_parse_args($notice_args, $default_notice_args);
589 589
 
590 590
 		/**
591 591
 		 * Filter to modify Frontend notice args before notices is display.
592 592
 		 *
593 593
 		 * @since 1.8.14
594 594
 		 */
595
-		$notice_args = apply_filters( 'give_frontend_notice_args', $notice_args );
595
+		$notice_args = apply_filters('give_frontend_notice_args', $notice_args);
596 596
 
597 597
 		// Note: we will remove give_errors class in future.
598 598
 		$error = sprintf(
@@ -602,12 +602,12 @@  discard block
 block discarded – undo
602 602
 				</p>
603 603
 			</div>',
604 604
 			$notice_type,
605
-			give_clean( $notice_args['dismissible'] ),
606
-			absint( $notice_args['dismiss_interval'] ),
605
+			give_clean($notice_args['dismissible']),
606
+			absint($notice_args['dismiss_interval']),
607 607
 			$message
608 608
 		);
609 609
 
610
-		if ( ! $echo ) {
610
+		if ( ! $echo) {
611 611
 			return $error;
612 612
 		}
613 613
 
Please login to merge, or discard this patch.