Completed
Push — master ( ace9ba...1ffdfe )
by Ravinder
12s
created
includes/plugin-compatibility.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,6 +19,6 @@
 block discarded – undo
19 19
  * @return void
20 20
  */
21 21
 function give_disable_mandrill_nl2br() {
22
-	add_filter( 'mandrill_nl2br', '__return_false' );
22
+	add_filter('mandrill_nl2br', '__return_false');
23 23
 }
24
-add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br');
24
+add_action('give_email_send_before', 'give_disable_mandrill_nl2br');
Please login to merge, or discard this patch.
admin/reporting/tools/class-give-tools-recount-single-customer-stats.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -188,8 +188,8 @@
 block discarded – undo
188 188
 
189 189
 			$payment_ids = implode( ',', $payment_ids );
190 190
 			$customer->update( array( 'payment_ids'    => $payment_ids,
191
-			                          'purchase_count' => $purchase_count,
192
-			                          'purchase_value' => $pending_total
191
+									  'purchase_count' => $purchase_count,
192
+									  'purchase_value' => $pending_total
193 193
 			) );
194 194
 
195 195
 			$this->done    = true;
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -54,39 +54,39 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function get_data() {
56 56
 
57
-		$customer = new Give_Customer( $this->customer_id );
58
-		$payments = $this->get_stored_data( 'give_recount_customer_payments_' . $customer->id, array() );
57
+		$customer = new Give_Customer($this->customer_id);
58
+		$payments = $this->get_stored_data('give_recount_customer_payments_'.$customer->id, array());
59 59
 
60
-		$offset     = ( $this->step - 1 ) * $this->per_step;
61
-		$step_items = array_slice( $payments, $offset, $this->per_step );
60
+		$offset     = ($this->step - 1) * $this->per_step;
61
+		$step_items = array_slice($payments, $offset, $this->per_step);
62 62
 
63
-		if ( count( $step_items ) > 0 ) {
64
-			$pending_total = (float) $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 );
63
+		if (count($step_items) > 0) {
64
+			$pending_total = (float) $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0);
65 65
 			$step_total    = 0;
66 66
 
67
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $customer->id, array() );
67
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$customer->id, array());
68 68
 
69
-			foreach ( $step_items as $payment ) {
70
-				$payment = get_post( $payment->ID );
69
+			foreach ($step_items as $payment) {
70
+				$payment = get_post($payment->ID);
71 71
 
72
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
72
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
73 73
 
74
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $customer->id, array() );
74
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$customer->id, array());
75 75
 					$missing_payments[] = $payment->ID;
76
-					$this->store_data( 'give_stats_missing_payments' . $customer->id, $missing_payments );
76
+					$this->store_data('give_stats_missing_payments'.$customer->id, $missing_payments);
77 77
 
78 78
 					continue;
79 79
 				}
80 80
 
81 81
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
82
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
82
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
83 83
 
84
-				if ( true === $should_process_payment ) {
84
+				if (true === $should_process_payment) {
85 85
 
86 86
 					$found_payment_ids[] = $payment->ID;
87 87
 
88
-					if ( apply_filters( 'give_customer_recount_sholud_increase_value', true, $payment ) ) {
89
-						$payment_amount = give_get_payment_amount( $payment->ID );
88
+					if (apply_filters('give_customer_recount_sholud_increase_value', true, $payment)) {
89
+						$payment_amount = give_get_payment_amount($payment->ID);
90 90
 						$step_total += $payment_amount;
91 91
 					}
92 92
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 			}
96 96
 
97 97
 			$updated_total = $pending_total + $step_total;
98
-			$this->store_data( 'give_stats_customer_pending_total' . $customer->id, $updated_total );
99
-			$this->store_data( 'give_stats_found_payments_' . $customer->id, $found_payment_ids );
98
+			$this->store_data('give_stats_customer_pending_total'.$customer->id, $updated_total);
99
+			$this->store_data('give_stats_found_payments_'.$customer->id, $found_payment_ids);
100 100
 
101 101
 			return true;
102 102
 		}
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function get_percentage_complete() {
115 115
 
116
-		$payments = $this->get_stored_data( 'give_recount_customer_payments_' . $this->customer_id );
117
-		$total    = count( $payments );
116
+		$payments = $this->get_stored_data('give_recount_customer_payments_'.$this->customer_id);
117
+		$total    = count($payments);
118 118
 
119 119
 		$percentage = 100;
120 120
 
121
-		if ( $total > 0 ) {
122
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
121
+		if ($total > 0) {
122
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
123 123
 		}
124 124
 
125
-		if ( $percentage > 100 ) {
125
+		if ($percentage > 100) {
126 126
 			$percentage = 100;
127 127
 		}
128 128
 
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @param array $request The Form Data passed into the batch processing
138 138
 	 */
139
-	public function set_properties( $request ) {
140
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
139
+	public function set_properties($request) {
140
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
141 141
 	}
142 142
 
143 143
 	/**
@@ -148,62 +148,62 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	public function process_step() {
150 150
 
151
-		if ( ! $this->can_export() ) {
152
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
151
+		if ( ! $this->can_export()) {
152
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
153 153
 		}
154 154
 
155 155
 		$had_data = $this->get_data();
156 156
 
157
-		if ( $had_data ) {
157
+		if ($had_data) {
158 158
 			$this->done = false;
159 159
 
160 160
 			return true;
161 161
 		} else {
162
-			$customer    = new Give_Customer( $this->customer_id );
163
-			$payment_ids = get_option( 'give_stats_found_payments_' . $customer->id, array() );
164
-			$this->delete_data( 'give_stats_found_payments_' . $customer->id );
162
+			$customer    = new Give_Customer($this->customer_id);
163
+			$payment_ids = get_option('give_stats_found_payments_'.$customer->id, array());
164
+			$this->delete_data('give_stats_found_payments_'.$customer->id);
165 165
 
166
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $customer->id, array() ) );
166
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$customer->id, array()));
167 167
 
168 168
 			// Find non-existing payments (deleted) and total up the donation count
169 169
 			$purchase_count = 0;
170
-			foreach ( $payment_ids as $key => $payment_id ) {
171
-				if ( in_array( $payment_id, $removed_payments ) ) {
172
-					unset( $payment_ids[ $key ] );
170
+			foreach ($payment_ids as $key => $payment_id) {
171
+				if (in_array($payment_id, $removed_payments)) {
172
+					unset($payment_ids[$key]);
173 173
 					continue;
174 174
 				}
175 175
 
176
-				$payment = get_post( $payment_id );
177
-				if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) {
178
-					$purchase_count ++;
176
+				$payment = get_post($payment_id);
177
+				if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) {
178
+					$purchase_count++;
179 179
 				}
180 180
 			}
181 181
 
182
-			$this->delete_data( 'give_stats_missing_payments' . $customer->id );
182
+			$this->delete_data('give_stats_missing_payments'.$customer->id);
183 183
 
184
-			$pending_total = $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 );
185
-			$this->delete_data( 'give_stats_customer_pending_total' . $customer->id );
186
-			$this->delete_data( 'give_recount_customer_stats_' . $customer->id );
187
-			$this->delete_data( 'give_recount_customer_payments_' . $this->customer_id );
184
+			$pending_total = $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0);
185
+			$this->delete_data('give_stats_customer_pending_total'.$customer->id);
186
+			$this->delete_data('give_recount_customer_stats_'.$customer->id);
187
+			$this->delete_data('give_recount_customer_payments_'.$this->customer_id);
188 188
 
189
-			$payment_ids = implode( ',', $payment_ids );
190
-			$customer->update( array( 'payment_ids'    => $payment_ids,
189
+			$payment_ids = implode(',', $payment_ids);
190
+			$customer->update(array('payment_ids'    => $payment_ids,
191 191
 			                          'purchase_count' => $purchase_count,
192 192
 			                          'purchase_value' => $pending_total
193
-			) );
193
+			));
194 194
 
195 195
 			$this->done    = true;
196
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
196
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
197 197
 
198 198
 			return false;
199 199
 		}
200 200
 	}
201 201
 
202 202
 	public function headers() {
203
-		ignore_user_abort( true );
203
+		ignore_user_abort(true);
204 204
 
205
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
206
-			set_time_limit( 0 );
205
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
206
+			set_time_limit(0);
207 207
 		}
208 208
 	}
209 209
 
@@ -230,26 +230,26 @@  discard block
 block discarded – undo
230 230
 	 * @return void
231 231
 	 */
232 232
 	public function pre_fetch() {
233
-		if ( $this->step === 1 ) {
234
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
233
+		if ($this->step === 1) {
234
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
235 235
 
236 236
 			// Before we start, let's zero out the customer's data
237
-			$customer = new Give_Customer( $this->customer_id );
238
-			$customer->update( array( 'purchase_value' => give_format_amount( 0 ), 'purchase_count' => 0 ) );
237
+			$customer = new Give_Customer($this->customer_id);
238
+			$customer->update(array('purchase_value' => give_format_amount(0), 'purchase_count' => 0));
239 239
 
240
-			$attached_payment_ids = explode( ',', $customer->payment_ids );
240
+			$attached_payment_ids = explode(',', $customer->payment_ids);
241 241
 
242 242
 			$attached_args = array(
243 243
 				'post__in' => $attached_payment_ids,
244
-				'number'   => - 1,
244
+				'number'   => -1,
245 245
 				'status'   => $allowed_payment_status,
246 246
 			);
247 247
 
248
-			$attached_payments = give_get_payments( $attached_args );
248
+			$attached_payments = give_get_payments($attached_args);
249 249
 
250 250
 			$unattached_args = array(
251 251
 				'post__not_in' => $attached_payment_ids,
252
-				'number'       => - 1,
252
+				'number'       => -1,
253 253
 				'status'       => $allowed_payment_status,
254 254
 				'meta_query'   => array(
255 255
 					array(
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 				),
260 260
 			);
261 261
 
262
-			$unattached_payments = give_get_payments( $unattached_args );
262
+			$unattached_payments = give_get_payments($unattached_args);
263 263
 
264
-			$payments = array_merge( $attached_payments, $unattached_payments );
264
+			$payments = array_merge($attached_payments, $unattached_payments);
265 265
 
266
-			$this->store_data( 'give_recount_customer_payments_' . $customer->id, $payments );
266
+			$this->store_data('give_recount_customer_payments_'.$customer->id, $payments);
267 267
 		}
268 268
 	}
269 269
 
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return mixed       Returns the data from the database
278 278
 	 */
279
-	private function get_stored_data( $key ) {
279
+	private function get_stored_data($key) {
280 280
 		global $wpdb;
281
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
281
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
282 282
 
283
-		return empty( $value ) ? false : maybe_unserialize( $value );
283
+		return empty($value) ? false : maybe_unserialize($value);
284 284
 	}
285 285
 
286 286
 	/**
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return void
295 295
 	 */
296
-	private function store_data( $key, $value ) {
296
+	private function store_data($key, $value) {
297 297
 		global $wpdb;
298 298
 
299
-		$value = maybe_serialize( $value );
299
+		$value = maybe_serialize($value);
300 300
 
301 301
 		$data = array(
302 302
 			'option_name'  => $key,
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			'%s',
311 311
 		);
312 312
 
313
-		$wpdb->replace( $wpdb->options, $data, $formats );
313
+		$wpdb->replace($wpdb->options, $data, $formats);
314 314
 	}
315 315
 
316 316
 	/**
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @return void
324 324
 	 */
325
-	private function delete_data( $key ) {
325
+	private function delete_data($key) {
326 326
 		global $wpdb;
327
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
327
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
328 328
 	}
329 329
 
330 330
 }
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-login.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,16 +42,16 @@
 block discarded – undo
42 42
 				'minWidth' => 320,
43 43
 				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after login.', 'give' ),
44 44
 			),
45
-            array(
46
-                'type' => 'container',
47
-                'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ),
48
-            ),
49
-            array(
50
-                'type'     => 'textbox',
51
-                'name'     => 'logout-redirect',
52
-                'minWidth' => 320,
53
-                'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ),
54
-            ),
45
+			array(
46
+				'type' => 'container',
47
+				'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ),
48
+			),
49
+			array(
50
+				'type'     => 'textbox',
51
+				'name'     => 'logout-redirect',
52
+				'minWidth' => 320,
53
+				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ),
54
+			),
55 55
 		);
56 56
 	}
57 57
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 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
 
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function __construct() {
23 23
 
24
-		$this->shortcode['title'] = esc_html__( 'Login', 'give' );
25
-		$this->shortcode['label'] = esc_html__( 'Login', 'give' );
24
+		$this->shortcode['title'] = esc_html__('Login', 'give');
25
+		$this->shortcode['label'] = esc_html__('Login', 'give');
26 26
 
27
-		parent::__construct( 'give_login' );
27
+		parent::__construct('give_login');
28 28
 	}
29 29
 
30 30
 	/**
@@ -37,23 +37,23 @@  discard block
 block discarded – undo
37 37
 		return array(
38 38
 			array(
39 39
 				'type' => 'container',
40
-				'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Login Redirect URL (optional):', 'give' ) ),
40
+				'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Login Redirect URL (optional):', 'give')),
41 41
 			),
42 42
 			array(
43 43
 				'type'     => 'textbox',
44 44
 				'name'     => 'login-redirect',
45 45
 				'minWidth' => 320,
46
-				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after login.', 'give' ),
46
+				'tooltip'  => esc_attr__('Enter an URL here to redirect to after login.', 'give'),
47 47
 			),
48 48
             array(
49 49
                 'type' => 'container',
50
-                'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ),
50
+                'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Logout Redirect URL (optional):', 'give')),
51 51
             ),
52 52
             array(
53 53
                 'type'     => 'textbox',
54 54
                 'name'     => 'logout-redirect',
55 55
                 'minWidth' => 320,
56
-                'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ),
56
+                'tooltip'  => esc_attr__('Enter an URL here to redirect to after logout.', 'give'),
57 57
             ),
58 58
 		);
59 59
 	}
Please login to merge, or discard this patch.
includes/admin/shortcodes/abstract-shortcode-generator.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -248,8 +248,8 @@
 block discarded – undo
248 248
 
249 249
 			// do not reindex array!
250 250
 			$field['options'] = array(
251
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
252
-			                    ) + $field['options'];
251
+									'' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
252
+								) + $field['options'];
253 253
 
254 254
 			foreach ( $field['options'] as $value => $text ) {
255 255
 				$new_listbox['values'][] = array(
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @since 1.0
64 64
 	 */
65
-	public function __construct( $shortcode ) {
65
+	public function __construct($shortcode) {
66 66
 
67 67
 		$this->shortcode_tag = $shortcode;
68 68
 
69
-		add_action( 'admin_init', array( $this, 'init' ) );
69
+		add_action('admin_init', array($this, 'init'));
70 70
 
71 71
 	}
72 72
 
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	public function init() {
79 79
 
80
-		if ( $this->shortcode_tag ) {
80
+		if ($this->shortcode_tag) {
81 81
 
82
-			$this->self = get_class( $this );
82
+			$this->self = get_class($this);
83 83
 
84 84
 			$this->errors   = array();
85 85
 			$this->required = array();
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 			$fields = $this->get_fields();
89 89
 
90 90
 			$defaults = array(
91
-				'btn_close' => esc_html__( 'Close', 'give' ),
92
-				'btn_okay'  => esc_html__( 'Insert Shortcode', 'give' ),
91
+				'btn_close' => esc_html__('Close', 'give'),
92
+				'btn_okay'  => esc_html__('Insert Shortcode', 'give'),
93 93
 				'errors'    => $this->errors,
94 94
 				'fields'    => $fields,
95
-				'label'     => '[' . $this->shortcode_tag . ']',
95
+				'label'     => '['.$this->shortcode_tag.']',
96 96
 				'required'  => $this->required,
97
-				'title'     => esc_html__( 'Insert Shortcode', 'give' ),
97
+				'title'     => esc_html__('Insert Shortcode', 'give'),
98 98
 			);
99 99
 
100
-			if ( user_can_richedit() ) {
100
+			if (user_can_richedit()) {
101 101
 
102
-				Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults );
102
+				Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults);
103 103
 
104 104
 			}
105 105
 		}
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @since 1.0
130 130
 	 */
131
-	protected function generate_fields( $defined_fields ) {
131
+	protected function generate_fields($defined_fields) {
132 132
 
133 133
 		$fields = array();
134 134
 
135
-		if ( is_array( $defined_fields ) ) {
135
+		if (is_array($defined_fields)) {
136 136
 
137
-			foreach ( $defined_fields as $field ) {
137
+			foreach ($defined_fields as $field) {
138 138
 
139 139
 				$defaults = array(
140 140
 					'label'       => false,
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 					'type'        => '',
146 146
 				);
147 147
 
148
-				$field  = wp_parse_args( (array) $field, $defaults );
149
-				$method = 'generate_' . strtolower( $field['type'] );
148
+				$field  = wp_parse_args((array) $field, $defaults);
149
+				$method = 'generate_'.strtolower($field['type']);
150 150
 
151
-				if ( method_exists( $this, $method ) ) {
151
+				if (method_exists($this, $method)) {
152 152
 
153
-					$field = call_user_func( array( $this, $method ), $field );
153
+					$field = call_user_func(array($this, $method), $field);
154 154
 
155
-					if ( $field ) {
155
+					if ($field) {
156 156
 						$fields[] = $field;
157 157
 					}
158 158
 				}
@@ -172,22 +172,22 @@  discard block
 block discarded – undo
172 172
 	protected function get_fields() {
173 173
 
174 174
 		$defined_fields   = $this->define_fields();
175
-		$generated_fields = $this->generate_fields( $defined_fields );
175
+		$generated_fields = $this->generate_fields($defined_fields);
176 176
 
177 177
 		$errors = array();
178 178
 
179
-		if ( ! empty( $this->errors ) ) {
180
-			foreach ( $this->required as $name => $alert ) {
181
-				if ( false === array_search( $name, array_column( $generated_fields, 'name' ) ) ) {
179
+		if ( ! empty($this->errors)) {
180
+			foreach ($this->required as $name => $alert) {
181
+				if (false === array_search($name, array_column($generated_fields, 'name'))) {
182 182
 
183
-					$errors[] = $this->errors[ $name ];
183
+					$errors[] = $this->errors[$name];
184 184
 				}
185 185
 			}
186 186
 
187 187
 			$this->errors = $errors;
188 188
 		}
189 189
 
190
-		if ( ! empty( $errors ) ) {
190
+		if ( ! empty($errors)) {
191 191
 
192 192
 			return $errors;
193 193
 		}
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @since 1.0
206 206
 	 */
207
-	protected function generate_container( $field ) {
207
+	protected function generate_container($field) {
208 208
 
209
-		if ( array_key_exists( 'html', $field ) ) {
209
+		if (array_key_exists('html', $field)) {
210 210
 
211 211
 			return array(
212 212
 				'type' => $field['type'],
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @since 1.0
228 228
 	 */
229
-	protected function generate_listbox( $field ) {
229
+	protected function generate_listbox($field) {
230 230
 
231
-		$listbox = shortcode_atts( array(
231
+		$listbox = shortcode_atts(array(
232 232
 			'label'    => '',
233 233
 			'minWidth' => '',
234 234
 			'name'     => false,
@@ -236,27 +236,27 @@  discard block
 block discarded – undo
236 236
 			'type'     => '',
237 237
 			'value'    => '',
238 238
 			'classes'  => ''
239
-		), $field );
239
+		), $field);
240 240
 
241
-		if ( $this->validate( $field ) ) {
241
+		if ($this->validate($field)) {
242 242
 
243 243
 			$new_listbox = array();
244 244
 
245
-			foreach ( $listbox as $key => $value ) {
245
+			foreach ($listbox as $key => $value) {
246 246
 
247
-				if ( $key == 'value' && empty( $value ) ) {
248
-					$new_listbox[ $key ] = $listbox['name'];
249
-				} else if ( $value ) {
250
-					$new_listbox[ $key ] = $value;
247
+				if ($key == 'value' && empty($value)) {
248
+					$new_listbox[$key] = $listbox['name'];
249
+				} else if ($value) {
250
+					$new_listbox[$key] = $value;
251 251
 				}
252 252
 			}
253 253
 
254 254
 			// do not reindex array!
255 255
 			$field['options'] = array(
256
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
256
+				                    '' => ($field['placeholder'] ? $field['placeholder'] : esc_attr__('- Select -', 'give')),
257 257
 			                    ) + $field['options'];
258 258
 
259
-			foreach ( $field['options'] as $value => $text ) {
259
+			foreach ($field['options'] as $value => $text) {
260 260
 				$new_listbox['values'][] = array(
261 261
 					'text'  => $text,
262 262
 					'value' => $value,
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @since 1.0
280 280
 	 */
281
-	protected function generate_post( $field ) {
281
+	protected function generate_post($field) {
282 282
 
283 283
 		$args = array(
284 284
 			'post_type'      => 'post',
@@ -287,23 +287,23 @@  discard block
 block discarded – undo
287 287
 			'posts_per_page' => 30,
288 288
 		);
289 289
 
290
-		$args    = wp_parse_args( (array) $field['query_args'], $args );
291
-		$posts   = get_posts( $args );
290
+		$args    = wp_parse_args((array) $field['query_args'], $args);
291
+		$posts   = get_posts($args);
292 292
 		$options = array();
293 293
 
294
-		if ( $posts ) {
295
-			foreach ( $posts as $post ) {
296
-				$options[ absint( $post->ID ) ] = ( empty( $post->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $post->ID ) : $post->post_title );
294
+		if ($posts) {
295
+			foreach ($posts as $post) {
296
+				$options[absint($post->ID)] = (empty($post->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $post->ID) : $post->post_title);
297 297
 			}
298 298
 
299 299
 			$field['type']    = 'listbox';
300 300
 			$field['options'] = $options;
301 301
 
302
-			return $this->generate_listbox( $field );
302
+			return $this->generate_listbox($field);
303 303
 		}
304 304
 
305 305
 		// perform validation here before returning false
306
-		$this->validate( $field );
306
+		$this->validate($field);
307 307
 
308 308
 		return false;
309 309
 	}
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
 	 *
318 318
 	 * @since 1.0
319 319
 	 */
320
-	protected function generate_textbox( $field ) {
320
+	protected function generate_textbox($field) {
321 321
 
322
-		$textbox = shortcode_atts( array(
322
+		$textbox = shortcode_atts(array(
323 323
 			'label'     => '',
324 324
 			'maxLength' => '',
325 325
 			'minHeight' => '',
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 			'type'      => '',
331 331
 			'value'     => '',
332 332
 			'classes'   => ''
333
-		), $field );
333
+		), $field);
334 334
 
335
-		if ( $this->validate( $field ) ) {
336
-			return array_filter( $textbox, array( $this, 'return_textbox_value' ) );
335
+		if ($this->validate($field)) {
336
+			return array_filter($textbox, array($this, 'return_textbox_value'));
337 337
 		}
338 338
 
339 339
 		return false;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	 *
347 347
 	 * @return bool
348 348
 	 */
349
-	function return_textbox_value( $value ) {
349
+	function return_textbox_value($value) {
350 350
 		return $value !== '';
351 351
 	}
352 352
 
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	 *
363 363
 	 * @since 1.0
364 364
 	 */
365
-	protected function validate( $field ) {
365
+	protected function validate($field) {
366 366
 
367
-		extract( shortcode_atts(
367
+		extract(shortcode_atts(
368 368
 				array(
369 369
 					'name'     => false,
370 370
 					'required' => false,
@@ -372,36 +372,36 @@  discard block
 block discarded – undo
372 372
 				), $field )
373 373
 		);
374 374
 
375
-		if ( $name ) {
375
+		if ($name) {
376 376
 
377
-			if ( isset( $required['error'] ) ) {
377
+			if (isset($required['error'])) {
378 378
 
379 379
 				$error = array(
380 380
 					'type' => 'container',
381 381
 					'html' => $required['error'],
382 382
 				);
383 383
 
384
-				$this->errors[ $name ] = $this->generate_container( $error );
384
+				$this->errors[$name] = $this->generate_container($error);
385 385
 			}
386 386
 
387
-			if ( ! ! $required || is_array( $required ) ) {
387
+			if ( ! ! $required || is_array($required)) {
388 388
 
389
-				$alert = esc_html__( 'Some of the shortcode options are required.', 'give' );
389
+				$alert = esc_html__('Some of the shortcode options are required.', 'give');
390 390
 
391
-				if ( isset( $required['alert'] ) ) {
391
+				if (isset($required['alert'])) {
392 392
 
393 393
 					$alert = $required['alert'];
394 394
 
395
-				} else if ( ! empty( $label ) ) {
395
+				} else if ( ! empty($label)) {
396 396
 
397 397
 					$alert = sprintf(
398 398
 					/* translators: %s: option label */
399
-						esc_html__( 'The "%s" option is required.', 'give' ),
400
-						str_replace( ':', '', $label )
399
+						esc_html__('The "%s" option is required.', 'give'),
400
+						str_replace(':', '', $label)
401 401
 					);
402 402
 				}
403 403
 
404
-				$this->required[ $name ] = $alert;
404
+				$this->required[$name] = $alert;
405 405
 			}
406 406
 
407 407
 			return true;
Please login to merge, or discard this patch.
includes/class-give-db-customers.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -427,13 +427,13 @@  discard block
 block discarded – undo
427 427
 	 *
428 428
 	 * @since  1.0
429 429
 	 * @access public
430
-     *
431
-     * @param  array $args
432
-     *
433
-     * @return array|object|null Customers array or object. Null if not found.
430
+	 *
431
+	 * @param  array $args
432
+	 *
433
+	 * @return array|object|null Customers array or object. Null if not found.
434 434
 	 */
435 435
 	public function get_customers( $args = array() ) {
436
-        /* @var WPDB $wpdb */
436
+		/* @var WPDB $wpdb */
437 437
 		global $wpdb;
438 438
 
439 439
 		$defaults = array(
@@ -558,13 +558,13 @@  discard block
 block discarded – undo
558 558
 	 *
559 559
 	 * @since  1.0
560 560
 	 * @access public
561
-     *
562
-     * @param  array $args
563
-     *
564
-     * @return int         Total number of customers.
561
+	 *
562
+	 * @param  array $args
563
+	 *
564
+	 * @return int         Total number of customers.
565 565
 	 */
566 566
 	public function count( $args = array() ) {
567
-        /* @var WPDB $wpdb */
567
+		/* @var WPDB $wpdb */
568 568
 		global $wpdb;
569 569
 
570 570
 		$where = ' WHERE 1=1 ';
Please login to merge, or discard this patch.
Spacing   +133 added lines, -133 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
 
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_customers';
38
+		$this->table_name  = $wpdb->prefix.'give_customers';
39 39
 		$this->primary_key = 'id';
40 40
 		$this->version     = '1.0';
41 41
 		
42
-		add_action( 'profile_update', array( $this, 'update_customer_email_on_user_update' ), 10, 2 );
42
+		add_action('profile_update', array($this, 'update_customer_email_on_user_update'), 10, 2);
43 43
 
44 44
 	}
45 45
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			'purchase_value' => 0.00,
83 83
 			'purchase_count' => 0,
84 84
 			'notes'          => '',
85
-			'date_created'   => date( 'Y-m-d H:i:s' ),
85
+			'date_created'   => date('Y-m-d H:i:s'),
86 86
 		);
87 87
 	}
88 88
 
@@ -96,40 +96,40 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return int|bool
98 98
 	 */
99
-	public function add( $data = array() ) {
99
+	public function add($data = array()) {
100 100
 
101 101
 		$defaults = array(
102 102
 			'payment_ids' => ''
103 103
 		);
104 104
 
105
-		$args = wp_parse_args( $data, $defaults );
105
+		$args = wp_parse_args($data, $defaults);
106 106
 
107
-		if ( empty( $args['email'] ) ) {
107
+		if (empty($args['email'])) {
108 108
 			return false;
109 109
 		}
110 110
 
111
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
112
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
111
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
112
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
113 113
 		}
114 114
 
115
-		$customer = $this->get_customer_by( 'email', $args['email'] );
115
+		$customer = $this->get_customer_by('email', $args['email']);
116 116
 
117
-		if ( $customer ) {
117
+		if ($customer) {
118 118
 			// update an existing customer
119 119
 
120 120
 			// Update the payment IDs attached to the customer
121
-			if ( ! empty( $args['payment_ids'] ) ) {
121
+			if ( ! empty($args['payment_ids'])) {
122 122
 
123
-				if ( empty( $customer->payment_ids ) ) {
123
+				if (empty($customer->payment_ids)) {
124 124
 
125 125
 					$customer->payment_ids = $args['payment_ids'];
126 126
 
127 127
 				} else {
128 128
 
129
-					$existing_ids          = array_map( 'absint', explode( ',', $customer->payment_ids ) );
130
-					$payment_ids           = array_map( 'absint', explode( ',', $args['payment_ids'] ) );
131
-					$payment_ids           = array_merge( $payment_ids, $existing_ids );
132
-					$customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
129
+					$existing_ids          = array_map('absint', explode(',', $customer->payment_ids));
130
+					$payment_ids           = array_map('absint', explode(',', $args['payment_ids']));
131
+					$payment_ids           = array_merge($payment_ids, $existing_ids);
132
+					$customer->payment_ids = implode(',', array_unique(array_values($payment_ids)));
133 133
 
134 134
 				}
135 135
 
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 
138 138
 			}
139 139
 
140
-			$this->update( $customer->id, $args );
140
+			$this->update($customer->id, $args);
141 141
 
142 142
 			return $customer->id;
143 143
 
144 144
 		} else {
145 145
 
146
-			return $this->insert( $args, 'customer' );
146
+			return $this->insert($args, 'customer');
147 147
 
148 148
 		}
149 149
 
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
 	 *
163 163
 	 * @return bool|int
164 164
 	 */
165
-	public function delete( $_id_or_email = false ) {
165
+	public function delete($_id_or_email = false) {
166 166
 
167
-		if ( empty( $_id_or_email ) ) {
167
+		if (empty($_id_or_email)) {
168 168
 			return false;
169 169
 		}
170 170
 
171
-		$column   = is_email( $_id_or_email ) ? 'email' : 'id';
172
-		$customer = $this->get_customer_by( $column, $_id_or_email );
171
+		$column   = is_email($_id_or_email) ? 'email' : 'id';
172
+		$customer = $this->get_customer_by($column, $_id_or_email);
173 173
 
174
-		if ( $customer->id > 0 ) {
174
+		if ($customer->id > 0) {
175 175
 
176 176
 			global $wpdb;
177 177
 
178
-			return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) );
178
+			return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d'));
179 179
 
180 180
 		} else {
181 181
 			return false;
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
 	 *
195 195
 	 * @return bool          True is exists, false otherwise.
196 196
 	 */
197
-	public function exists( $value = '', $field = 'email' ) {
197
+	public function exists($value = '', $field = 'email') {
198 198
 		
199 199
 		$columns = $this->get_columns();
200
-		if ( ! array_key_exists( $field, $columns ) ) {
200
+		if ( ! array_key_exists($field, $columns)) {
201 201
 			return false;
202 202
 		}
203 203
 
204
-		return (bool) $this->get_column_by( 'id', $field, $value );
204
+		return (bool) $this->get_column_by('id', $field, $value);
205 205
 
206 206
 	}
207 207
 
@@ -216,16 +216,16 @@  discard block
 block discarded – undo
216 216
 	 *
217 217
 	 * @return bool
218 218
 	 */
219
-	public function attach_payment( $customer_id = 0, $payment_id = 0 ) {
219
+	public function attach_payment($customer_id = 0, $payment_id = 0) {
220 220
 
221
-		$customer = new Give_Customer( $customer_id );
221
+		$customer = new Give_Customer($customer_id);
222 222
 
223
-		if ( empty( $customer->id ) ) {
223
+		if (empty($customer->id)) {
224 224
 			return false;
225 225
 		}
226 226
 
227 227
 		// Attach the payment, but don't increment stats, as this function previously did not
228
-		return $customer->attach_payment( $payment_id, false );
228
+		return $customer->attach_payment($payment_id, false);
229 229
 
230 230
 	}
231 231
 
@@ -240,16 +240,16 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @return bool
242 242
 	 */
243
-	public function remove_payment( $customer_id = 0, $payment_id = 0 ) {
243
+	public function remove_payment($customer_id = 0, $payment_id = 0) {
244 244
 
245
-		$customer = new Give_Customer( $customer_id );
245
+		$customer = new Give_Customer($customer_id);
246 246
 
247
-		if ( ! $customer ) {
247
+		if ( ! $customer) {
248 248
 			return false;
249 249
 		}
250 250
 
251 251
 		// Remove the payment, but don't decrease stats, as this function previously did not
252
-		return $customer->remove_payment( $payment_id, false );
252
+		return $customer->remove_payment($payment_id, false);
253 253
 
254 254
 	}
255 255
 
@@ -263,18 +263,18 @@  discard block
 block discarded – undo
263 263
 	 *
264 264
 	 * @return bool
265 265
 	 */
266
-	public function increment_stats( $customer_id = 0, $amount = 0.00 ) {
266
+	public function increment_stats($customer_id = 0, $amount = 0.00) {
267 267
 
268
-		$customer = new Give_Customer( $customer_id );
268
+		$customer = new Give_Customer($customer_id);
269 269
 
270
-		if ( empty( $customer->id ) ) {
270
+		if (empty($customer->id)) {
271 271
 			return false;
272 272
 		}
273 273
 
274 274
 		$increased_count = $customer->increase_purchase_count();
275
-		$increased_value = $customer->increase_value( $amount );
275
+		$increased_value = $customer->increase_value($amount);
276 276
 
277
-		return ( $increased_count && $increased_value ) ? true : false;
277
+		return ($increased_count && $increased_value) ? true : false;
278 278
 
279 279
 	}
280 280
 
@@ -289,18 +289,18 @@  discard block
 block discarded – undo
289 289
 	 *
290 290
 	 * @return bool
291 291
 	 */
292
-	public function decrement_stats( $customer_id = 0, $amount = 0.00 ) {
292
+	public function decrement_stats($customer_id = 0, $amount = 0.00) {
293 293
 
294
-		$customer = new Give_Customer( $customer_id );
294
+		$customer = new Give_Customer($customer_id);
295 295
 
296
-		if ( ! $customer ) {
296
+		if ( ! $customer) {
297 297
 			return false;
298 298
 		}
299 299
 
300 300
 		$decreased_count = $customer->decrease_purchase_count();
301
-		$decreased_value = $customer->decrease_value( $amount );
301
+		$decreased_value = $customer->decrease_value($amount);
302 302
 
303
-		return ( $decreased_count && $decreased_value ) ? true : false;
303
+		return ($decreased_count && $decreased_value) ? true : false;
304 304
 
305 305
 	}
306 306
 
@@ -315,31 +315,31 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @return bool
317 317
 	 */
318
-	public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) {
318
+	public function update_customer_email_on_user_update($user_id = 0, $old_user_data) {
319 319
 
320
-		$customer = new Give_Customer( $user_id, true );
320
+		$customer = new Give_Customer($user_id, true);
321 321
 
322
-		if( ! $customer ) {
322
+		if ( ! $customer) {
323 323
 			return false;
324 324
 		}
325 325
 
326
-		$user = get_userdata( $user_id );
326
+		$user = get_userdata($user_id);
327 327
 
328
-		if( ! empty( $user ) && $user->user_email !== $customer->email ) {
328
+		if ( ! empty($user) && $user->user_email !== $customer->email) {
329 329
 
330
-			if( ! $this->get_customer_by( 'email', $user->user_email ) ) {
330
+			if ( ! $this->get_customer_by('email', $user->user_email)) {
331 331
 
332
-				$success = $this->update( $customer->id, array( 'email' => $user->user_email ) );
332
+				$success = $this->update($customer->id, array('email' => $user->user_email));
333 333
 
334
-				if( $success ) {
334
+				if ($success) {
335 335
 					// Update some payment meta if we need to
336
-					$payments_array = explode( ',', $customer->payment_ids );
336
+					$payments_array = explode(',', $customer->payment_ids);
337 337
 
338
-					if( ! empty( $payments_array ) ) {
338
+					if ( ! empty($payments_array)) {
339 339
 
340
-						foreach ( $payments_array as $payment_id ) {
340
+						foreach ($payments_array as $payment_id) {
341 341
 
342
-							give_update_payment_meta( $payment_id, 'email', $user->user_email );
342
+							give_update_payment_meta($payment_id, 'email', $user->user_email);
343 343
 
344 344
 						}
345 345
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 					 * @param  WP_User       $user     WordPress User object.
354 354
 					 * @param  Give_Customer $customer Give customer object.
355 355
 					 */
356
-					do_action( 'give_update_customer_email_on_user_update', $user, $customer );
356
+					do_action('give_update_customer_email_on_user_update', $user, $customer);
357 357
 
358 358
 				}
359 359
 
@@ -374,46 +374,46 @@  discard block
 block discarded – undo
374 374
 	 *
375 375
 	 * @return mixed         Upon success, an object of the customer. Upon failure, NULL
376 376
 	 */
377
-	public function get_customer_by( $field = 'id', $value = 0 ) {
377
+	public function get_customer_by($field = 'id', $value = 0) {
378 378
 		/* @var WPDB $wpdb */
379 379
 		global $wpdb;
380 380
 
381
-		if ( empty( $field ) || empty( $value ) ) {
381
+		if (empty($field) || empty($value)) {
382 382
 			return null;
383 383
 		}
384 384
 
385
-		if ( 'id' == $field || 'user_id' == $field ) {
385
+		if ('id' == $field || 'user_id' == $field) {
386 386
 			// Make sure the value is numeric to avoid casting objects, for example,
387 387
 			// to int 1.
388
-			if ( ! is_numeric( $value ) ) {
388
+			if ( ! is_numeric($value)) {
389 389
 				return false;
390 390
 			}
391 391
 
392
-			$value = intval( $value );
392
+			$value = intval($value);
393 393
 
394
-			if ( $value < 1 ) {
394
+			if ($value < 1) {
395 395
 				return false;
396 396
 			}
397 397
 
398
-		} elseif ( 'email' === $field ) {
398
+		} elseif ('email' === $field) {
399 399
 
400
-			if ( ! is_email( $value ) ) {
400
+			if ( ! is_email($value)) {
401 401
 				return false;
402 402
 			}
403 403
 
404
-			$value = trim( $value );
404
+			$value = trim($value);
405 405
 		}
406 406
 
407
-		if ( ! $value ) {
407
+		if ( ! $value) {
408 408
 			return false;
409 409
 		}
410 410
 
411
-		switch ( $field ) {
411
+		switch ($field) {
412 412
 			case 'id':
413 413
 				$db_field = 'id';
414 414
 				break;
415 415
 			case 'email':
416
-				$value    = sanitize_text_field( $value );
416
+				$value    = sanitize_text_field($value);
417 417
 				$db_field = 'email';
418 418
 				break;
419 419
 			case 'user_id':
@@ -423,15 +423,15 @@  discard block
 block discarded – undo
423 423
 				return false;
424 424
 		}
425 425
 
426
-		if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) {
426
+		if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) {
427 427
 
428 428
 			// Look for customer from an additional email
429
-			if( 'email' === $field ) {
429
+			if ('email' === $field) {
430 430
 				$meta_table  = Give()->customer_meta->table_name;
431
-				$customer_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value ) );
431
+				$customer_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value));
432 432
 
433
-				if( ! empty( $customer_id ) ) {
434
-					return $this->get( $customer_id );
433
+				if ( ! empty($customer_id)) {
434
+					return $this->get($customer_id);
435 435
  				}
436 436
  			}
437 437
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
      *
452 452
      * @return array|object|null Customers array or object. Null if not found.
453 453
 	 */
454
-	public function get_customers( $args = array() ) {
454
+	public function get_customers($args = array()) {
455 455
         /* @var WPDB $wpdb */
456 456
 		global $wpdb;
457 457
 
@@ -463,21 +463,21 @@  discard block
 block discarded – undo
463 463
 			'order'   => 'DESC'
464 464
 		);
465 465
 
466
-		$args = wp_parse_args( $args, $defaults );
466
+		$args = wp_parse_args($args, $defaults);
467 467
 
468
-		if ( $args['number'] < 1 ) {
468
+		if ($args['number'] < 1) {
469 469
 			$args['number'] = 999999999999;
470 470
 		}
471 471
 
472 472
 		$where = ' WHERE 1=1 ';
473 473
 
474 474
 		// specific customers
475
-		if ( ! empty( $args['id'] ) ) {
475
+		if ( ! empty($args['id'])) {
476 476
 
477
-			if ( is_array( $args['id'] ) ) {
478
-				$ids = implode( ',', array_map( 'intval', $args['id'] ) );
477
+			if (is_array($args['id'])) {
478
+				$ids = implode(',', array_map('intval', $args['id']));
479 479
 			} else {
480
-				$ids = intval( $args['id'] );
480
+				$ids = intval($args['id']);
481 481
 			}
482 482
 
483 483
 			$where .= " AND `id` IN( {$ids} ) ";
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 		}
486 486
 
487 487
 		// customers for specific user accounts
488
-		if ( ! empty( $args['user_id'] ) ) {
488
+		if ( ! empty($args['user_id'])) {
489 489
 
490
-			if ( is_array( $args['user_id'] ) ) {
491
-				$user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) );
490
+			if (is_array($args['user_id'])) {
491
+				$user_ids = implode(',', array_map('intval', $args['user_id']));
492 492
 			} else {
493
-				$user_ids = intval( $args['user_id'] );
493
+				$user_ids = intval($args['user_id']);
494 494
 			}
495 495
 
496 496
 			$where .= " AND `user_id` IN( {$user_ids} ) ";
@@ -498,41 +498,41 @@  discard block
 block discarded – undo
498 498
 		}
499 499
 
500 500
 		//specific customers by email
501
-		if( ! empty( $args['email'] ) ) {
501
+		if ( ! empty($args['email'])) {
502 502
 
503
-			if( is_array( $args['email'] ) ) {
503
+			if (is_array($args['email'])) {
504 504
 
505
-				$emails_count       = count( $args['email'] );
506
-				$emails_placeholder = array_fill( 0, $emails_count, '%s' );
507
-				$emails             = implode( ', ', $emails_placeholder );
505
+				$emails_count       = count($args['email']);
506
+				$emails_placeholder = array_fill(0, $emails_count, '%s');
507
+				$emails             = implode(', ', $emails_placeholder);
508 508
 
509
-				$where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] );
509
+				$where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']);
510 510
 			} else {
511
-				$where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] );
511
+				$where .= $wpdb->prepare(" AND `email` = %s ", $args['email']);
512 512
 			}
513 513
 		}
514 514
 
515 515
 		// specific customers by name
516
-		if( ! empty( $args['name'] ) ) {
517
-			$where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] );
516
+		if ( ! empty($args['name'])) {
517
+			$where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']);
518 518
 		}
519 519
 
520 520
 		// Customers created for a specific date or in a date range
521
-		if ( ! empty( $args['date'] ) ) {
521
+		if ( ! empty($args['date'])) {
522 522
 
523
-			if ( is_array( $args['date'] ) ) {
523
+			if (is_array($args['date'])) {
524 524
 
525
-				if ( ! empty( $args['date']['start'] ) ) {
525
+				if ( ! empty($args['date']['start'])) {
526 526
 
527
-					$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
527
+					$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
528 528
 
529 529
 					$where .= " AND `date_created` >= '{$start}'";
530 530
 
531 531
 				}
532 532
 
533
-				if ( ! empty( $args['date']['end'] ) ) {
533
+				if ( ! empty($args['date']['end'])) {
534 534
 
535
-					$end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
535
+					$end = date('Y-m-d H:i:s', strtotime($args['date']['end']));
536 536
 
537 537
 					$where .= " AND `date_created` <= '{$end}'";
538 538
 
@@ -540,31 +540,31 @@  discard block
 block discarded – undo
540 540
 
541 541
 			} else {
542 542
 
543
-				$year  = date( 'Y', strtotime( $args['date'] ) );
544
-				$month = date( 'm', strtotime( $args['date'] ) );
545
-				$day   = date( 'd', strtotime( $args['date'] ) );
543
+				$year  = date('Y', strtotime($args['date']));
544
+				$month = date('m', strtotime($args['date']));
545
+				$day   = date('d', strtotime($args['date']));
546 546
 
547 547
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
548 548
 			}
549 549
 
550 550
 		}
551 551
 
552
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby'];
552
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby'];
553 553
 
554
-		if ( 'purchase_value' == $args['orderby'] ) {
554
+		if ('purchase_value' == $args['orderby']) {
555 555
 			$args['orderby'] = 'purchase_value+0';
556 556
 		}
557 557
 
558
-		$cache_key = md5( 'give_customers_' . serialize( $args ) );
558
+		$cache_key = md5('give_customers_'.serialize($args));
559 559
 
560
-		$customers = wp_cache_get( $cache_key, 'customers' );
560
+		$customers = wp_cache_get($cache_key, 'customers');
561 561
 
562
-		$args['orderby'] = esc_sql( $args['orderby'] );
563
-		$args['order']   = esc_sql( $args['order'] );
562
+		$args['orderby'] = esc_sql($args['orderby']);
563
+		$args['order']   = esc_sql($args['order']);
564 564
 
565
-		if ( $customers === false ) {
566
-			$customers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) );
567
-			wp_cache_set( $cache_key, $customers, 'customers', 3600 );
565
+		if ($customers === false) {
566
+			$customers = $wpdb->get_results($wpdb->prepare("SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number'])));
567
+			wp_cache_set($cache_key, $customers, 'customers', 3600);
568 568
 		}
569 569
 
570 570
 		return $customers;
@@ -582,26 +582,26 @@  discard block
 block discarded – undo
582 582
      *
583 583
      * @return int         Total number of customers.
584 584
 	 */
585
-	public function count( $args = array() ) {
585
+	public function count($args = array()) {
586 586
         /* @var WPDB $wpdb */
587 587
 		global $wpdb;
588 588
 
589 589
 		$where = ' WHERE 1=1 ';
590 590
 
591
-		if ( ! empty( $args['date'] ) ) {
591
+		if ( ! empty($args['date'])) {
592 592
 
593
-			if ( is_array( $args['date'] ) ) {
593
+			if (is_array($args['date'])) {
594 594
 
595
-				$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
596
-				$end   = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
595
+				$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
596
+				$end   = date('Y-m-d H:i:s', strtotime($args['date']['end']));
597 597
 
598 598
 				$where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'";
599 599
 
600 600
 			} else {
601 601
 
602
-				$year  = date( 'Y', strtotime( $args['date'] ) );
603
-				$month = date( 'm', strtotime( $args['date'] ) );
604
-				$day   = date( 'd', strtotime( $args['date'] ) );
602
+				$year  = date('Y', strtotime($args['date']));
603
+				$month = date('m', strtotime($args['date']));
604
+				$day   = date('d', strtotime($args['date']));
605 605
 
606 606
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
607 607
 			}
@@ -609,16 +609,16 @@  discard block
 block discarded – undo
609 609
 		}
610 610
 
611 611
 
612
-		$cache_key = md5( 'give_customers_count' . serialize( $args ) );
612
+		$cache_key = md5('give_customers_count'.serialize($args));
613 613
 
614
-		$count = wp_cache_get( $cache_key, 'customers' );
614
+		$count = wp_cache_get($cache_key, 'customers');
615 615
 
616
-		if ( $count === false ) {
617
-			$count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" );
618
-			wp_cache_set( $cache_key, $count, 'customers', 3600 );
616
+		if ($count === false) {
617
+			$count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};");
618
+			wp_cache_set($cache_key, $count, 'customers', 3600);
619 619
 		}
620 620
 
621
-		return absint( $count );
621
+		return absint($count);
622 622
 
623 623
 	}
624 624
 
@@ -632,9 +632,9 @@  discard block
 block discarded – undo
632 632
 	 */
633 633
 	public function create_table() {
634 634
 
635
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
635
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
636 636
 
637
-		$sql = "CREATE TABLE " . $this->table_name . " (
637
+		$sql = "CREATE TABLE ".$this->table_name." (
638 638
 		id bigint(20) NOT NULL AUTO_INCREMENT,
639 639
 		user_id bigint(20) NOT NULL,
640 640
 		email varchar(50) NOT NULL,
@@ -649,9 +649,9 @@  discard block
 block discarded – undo
649 649
 		KEY user (user_id)
650 650
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
651 651
 
652
-		dbDelta( $sql );
652
+		dbDelta($sql);
653 653
 
654
-		update_option( $this->table_name . '_db_version', $this->version );
654
+		update_option($this->table_name.'_db_version', $this->version);
655 655
 	}
656 656
 	
657 657
 	/**
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
664 664
 	 */
665 665
 	public function installed() {
666
-		return $this->table_exists( $this->table_name );
666
+		return $this->table_exists($this->table_name);
667 667
 	}
668 668
 
669 669
 }
Please login to merge, or discard this patch.
includes/template-functions.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -45,22 +45,22 @@  discard block
 block discarded – undo
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47 47
 function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-    if ( ! empty( $args ) && is_array( $args ) ) {
49
-        extract( $args );
50
-    }
48
+	if ( ! empty( $args ) && is_array( $args ) ) {
49
+		extract( $args );
50
+	}
51 51
 
52
-    $template_names = array( $template_name . '.php' );
52
+	$template_names = array( $template_name . '.php' );
53 53
 
54
-    $located = give_locate_template( $template_names, $template_path, $default_path );
54
+	$located = give_locate_template( $template_names, $template_path, $default_path );
55 55
 
56
-    if ( ! file_exists( $located ) ) {
56
+	if ( ! file_exists( $located ) ) {
57 57
 		/* translators: %s: the template */
58
-        give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
59
-        return;
60
-    }
58
+		give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
59
+		return;
60
+	}
61 61
 
62
-    // Allow 3rd party plugin filter template file from their plugin.
63
-    $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
62
+	// Allow 3rd party plugin filter template file from their plugin.
63
+	$located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
64 64
 
65 65
 	/**
66 66
 	 * Fires in give template, before the file is included.
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 * @param string $located       Template file filter by 3rd party plugin.
75 75
 	 * @param array  $args          Passed arguments.
76 76
 	 */
77
-    do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
77
+	do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
78 78
 
79
-    include( $located );
79
+	include( $located );
80 80
 
81 81
 	/**
82 82
 	 * Fires in give template, after the file is included.
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param string $located       Template file filter by 3rd party plugin.
91 91
 	 * @param array  $args          Passed arguments.
92 92
 	 */
93
-    do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
93
+	do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
94 94
 }
95 95
 
96 96
 /**
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 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
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @return string
22 22
  */
23 23
 function give_get_templates_dir() {
24
-	return GIVE_PLUGIN_DIR . 'templates';
24
+	return GIVE_PLUGIN_DIR.'templates';
25 25
 }
26 26
 
27 27
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function give_get_templates_url() {
34
-	return GIVE_PLUGIN_URL . 'templates';
34
+	return GIVE_PLUGIN_URL.'templates';
35 35
 }
36 36
 
37 37
 /**
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
  * @param string $template_path Template file path. Default is empty.
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47
-function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-    if ( ! empty( $args ) && is_array( $args ) ) {
49
-        extract( $args );
47
+function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
48
+    if ( ! empty($args) && is_array($args)) {
49
+        extract($args);
50 50
     }
51 51
 
52
-    $template_names = array( $template_name . '.php' );
52
+    $template_names = array($template_name.'.php');
53 53
 
54
-    $located = give_locate_template( $template_names, $template_path, $default_path );
54
+    $located = give_locate_template($template_names, $template_path, $default_path);
55 55
 
56
-    if ( ! file_exists( $located ) ) {
56
+    if ( ! file_exists($located)) {
57 57
 		/* translators: %s: the template */
58
-        give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
58
+        give_output_error(sprintf(__('The %s template was not found.', 'give'), $located), true);
59 59
         return;
60 60
     }
61 61
 
62 62
     // Allow 3rd party plugin filter template file from their plugin.
63
-    $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
63
+    $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path);
64 64
 
65 65
 	/**
66 66
 	 * Fires in give template, before the file is included.
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 * @param string $located       Template file filter by 3rd party plugin.
75 75
 	 * @param array  $args          Passed arguments.
76 76
 	 */
77
-    do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
77
+    do_action('give_before_template_part', $template_name, $template_path, $located, $args);
78 78
 
79
-    include( $located );
79
+    include($located);
80 80
 
81 81
 	/**
82 82
 	 * Fires in give template, after the file is included.
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param string $located       Template file filter by 3rd party plugin.
91 91
 	 * @param array  $args          Passed arguments.
92 92
 	 */
93
-    do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
93
+    do_action('give_after_template_part', $template_name, $template_path, $located, $args);
94 94
 }
95 95
 
96 96
 /**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  *
107 107
  * @return string 
108 108
  */
109
-function give_get_template_part( $slug, $name = null, $load = true ) {
109
+function give_get_template_part($slug, $name = null, $load = true) {
110 110
 
111 111
 	/**
112 112
 	 * Fires in give template part, before the template part is retrieved.
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
 	 * @param string $slug Template part file slug {slug}.php.
119 119
 	 * @param string $name Template part file name {slug}-{name}.php.
120 120
 	 */
121
-	do_action( "get_template_part_{$slug}", $slug, $name );
121
+	do_action("get_template_part_{$slug}", $slug, $name);
122 122
 
123 123
 	// Setup possible parts
124 124
 	$templates = array();
125
-	if ( isset( $name ) ) {
126
-		$templates[] = $slug . '-' . $name . '.php';
125
+	if (isset($name)) {
126
+		$templates[] = $slug.'-'.$name.'.php';
127 127
 	}
128
-	$templates[] = $slug . '.php';
128
+	$templates[] = $slug.'.php';
129 129
 
130 130
 	// Allow template parts to be filtered
131
-	$templates = apply_filters( 'give_get_template_part', $templates, $slug, $name );
131
+	$templates = apply_filters('give_get_template_part', $templates, $slug, $name);
132 132
 
133 133
 	// Return the part that is found
134
-	return give_locate_template( $templates, $load, false );
134
+	return give_locate_template($templates, $load, false);
135 135
 }
136 136
 
137 137
 /**
@@ -152,37 +152,37 @@  discard block
 block discarded – undo
152 152
  *
153 153
  * @return string The template filename if one is located.
154 154
  */
155
-function give_locate_template( $template_names, $load = false, $require_once = true ) {
155
+function give_locate_template($template_names, $load = false, $require_once = true) {
156 156
 	// No file found yet
157 157
 	$located = false;
158 158
 
159 159
 	// Try to find a template file
160
-	foreach ( (array) $template_names as $template_name ) {
160
+	foreach ((array) $template_names as $template_name) {
161 161
 
162 162
 		// Continue if template is empty
163
-		if ( empty( $template_name ) ) {
163
+		if (empty($template_name)) {
164 164
 			continue;
165 165
 		}
166 166
 
167 167
 		// Trim off any slashes from the template name
168
-		$template_name = ltrim( $template_name, '/' );
168
+		$template_name = ltrim($template_name, '/');
169 169
 
170 170
 		// try locating this template file by looping through the template paths
171
-		foreach ( give_get_theme_template_paths() as $template_path ) {
171
+		foreach (give_get_theme_template_paths() as $template_path) {
172 172
 
173
-			if ( file_exists( $template_path . $template_name ) ) {
174
-				$located = $template_path . $template_name;
173
+			if (file_exists($template_path.$template_name)) {
174
+				$located = $template_path.$template_name;
175 175
 				break;
176 176
 			}
177 177
 		}
178 178
 
179
-		if ( $located ) {
179
+		if ($located) {
180 180
 			break;
181 181
 		}
182 182
 	}
183 183
 
184
-	if ( ( true == $load ) && ! empty( $located ) ) {
185
-		load_template( $located, $require_once );
184
+	if ((true == $load) && ! empty($located)) {
185
+		load_template($located, $require_once);
186 186
 	}
187 187
 
188 188
 	return $located;
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 	$template_dir = give_get_theme_template_dir_name();
200 200
 
201 201
 	$file_paths = array(
202
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
203
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
202
+		1   => trailingslashit(get_stylesheet_directory()).$template_dir,
203
+		10  => trailingslashit(get_template_directory()).$template_dir,
204 204
 		100 => give_get_templates_dir()
205 205
 	);
206 206
 
207
-	$file_paths = apply_filters( 'give_template_paths', $file_paths );
207
+	$file_paths = apply_filters('give_template_paths', $file_paths);
208 208
 
209 209
 	// sort the file paths based on priority
210
-	ksort( $file_paths, SORT_NUMERIC );
210
+	ksort($file_paths, SORT_NUMERIC);
211 211
 
212
-	return array_map( 'trailingslashit', $file_paths );
212
+	return array_map('trailingslashit', $file_paths);
213 213
 }
214 214
 
215 215
 /**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  * @return string
222 222
  */
223 223
 function give_get_theme_template_dir_name() {
224
-	return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) );
224
+	return trailingslashit(apply_filters('give_templates_dir', 'give'));
225 225
 }
226 226
 
227 227
 /**
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
  * @return void
232 232
  */
233 233
 function give_version_in_header() {
234
-	echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n";
234
+	echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n";
235 235
 }
236 236
 
237
-add_action( 'wp_head', 'give_version_in_header' );
237
+add_action('wp_head', 'give_version_in_header');
238 238
 
239 239
 /**
240 240
  * Determines if we're currently on the Donations History page.
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
  */
245 245
 function give_is_donation_history_page() {
246 246
 
247
-	$ret = is_page( give_get_option( 'history_page' ) );
247
+	$ret = is_page(give_get_option('history_page'));
248 248
 
249
-	return apply_filters( 'give_is_donation_history_page', $ret );
249
+	return apply_filters('give_is_donation_history_page', $ret);
250 250
 }
251 251
 
252 252
 /**
@@ -258,25 +258,25 @@  discard block
 block discarded – undo
258 258
  *
259 259
  * @return array Modified array of classes
260 260
  */
261
-function give_add_body_classes( $class ) {
261
+function give_add_body_classes($class) {
262 262
 	$classes = (array) $class;
263 263
 
264
-	if ( give_is_success_page() ) {
264
+	if (give_is_success_page()) {
265 265
 		$classes[] = 'give-success';
266 266
 		$classes[] = 'give-page';
267 267
 	}
268 268
 
269
-	if ( give_is_failed_transaction_page() ) {
269
+	if (give_is_failed_transaction_page()) {
270 270
 		$classes[] = 'give-failed-transaction';
271 271
 		$classes[] = 'give-page';
272 272
 	}
273 273
 
274
-	if ( give_is_donation_history_page() ) {
274
+	if (give_is_donation_history_page()) {
275 275
 		$classes[] = 'give-donation-history';
276 276
 		$classes[] = 'give-page';
277 277
 	}
278 278
 
279
-	if ( give_is_test_mode() ) {
279
+	if (give_is_test_mode()) {
280 280
 		$classes[] = 'give-test-mode';
281 281
 		$classes[] = 'give-page';
282 282
 	}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	//Theme-specific Classes used to prevent conflicts via CSS
285 285
 	$current_theme = wp_get_theme();
286 286
 
287
-	switch ( $current_theme->template ) {
287
+	switch ($current_theme->template) {
288 288
 
289 289
 		case 'Divi':
290 290
 			$classes[] = 'give-divi';
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 
299 299
 	}
300 300
 
301
-	return array_unique( $classes );
301
+	return array_unique($classes);
302 302
 }
303 303
 
304
-add_filter( 'body_class', 'give_add_body_classes' );
304
+add_filter('body_class', 'give_add_body_classes');
305 305
 
306 306
 
307 307
 /**
@@ -317,22 +317,22 @@  discard block
 block discarded – undo
317 317
  *
318 318
  * @return array
319 319
  */
320
-function give_add_post_class( $classes, $class = '', $post_id = '' ) {
321
-	if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) {
320
+function give_add_post_class($classes, $class = '', $post_id = '') {
321
+	if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) {
322 322
 		return $classes;
323 323
 	}
324 324
 
325 325
 	//@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc).
326 326
 
327
-	if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
328
-		unset( $classes[ $key ] );
327
+	if (false !== ($key = array_search('hentry', $classes))) {
328
+		unset($classes[$key]);
329 329
 	}
330 330
 
331 331
 	return $classes;
332 332
 }
333 333
 
334 334
 
335
-add_filter( 'post_class', 'give_add_post_class', 20, 3 );
335
+add_filter('post_class', 'give_add_post_class', 20, 3);
336 336
 
337 337
 /**
338 338
  * Get the placeholder image URL for forms etc
@@ -342,74 +342,74 @@  discard block
 block discarded – undo
342 342
  */
343 343
 function give_get_placeholder_img_src() {
344 344
 
345
-	$placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) );
345
+	$placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give'));
346 346
 
347
-	return apply_filters( 'give_placeholder_img_src', $placeholder_url );
347
+	return apply_filters('give_placeholder_img_src', $placeholder_url);
348 348
 }
349 349
 
350 350
 
351 351
 /**
352 352
  * Global
353 353
  */
354
-if ( ! function_exists( 'give_output_content_wrapper' ) ) {
354
+if ( ! function_exists('give_output_content_wrapper')) {
355 355
 
356 356
 	/**
357 357
 	 * Output the start of the page wrapper.
358 358
 	 */
359 359
 	function give_output_content_wrapper() {
360
-		give_get_template_part( 'global/wrapper-start' );
360
+		give_get_template_part('global/wrapper-start');
361 361
 	}
362 362
 }
363
-if ( ! function_exists( 'give_output_content_wrapper_end' ) ) {
363
+if ( ! function_exists('give_output_content_wrapper_end')) {
364 364
 
365 365
 	/**
366 366
 	 * Output the end of the page wrapper.
367 367
 	 */
368 368
 	function give_output_content_wrapper_end() {
369
-		give_get_template_part( 'global/wrapper-end' );
369
+		give_get_template_part('global/wrapper-end');
370 370
 	}
371 371
 }
372 372
 
373 373
 /**
374 374
  * Single Give Form
375 375
  */
376
-if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) {
376
+if ( ! function_exists('give_left_sidebar_pre_wrap')) {
377 377
 	function give_left_sidebar_pre_wrap() {
378
-		echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' );
378
+		echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">');
379 379
 	}
380 380
 }
381 381
 
382
-if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) {
382
+if ( ! function_exists('give_left_sidebar_post_wrap')) {
383 383
 	function give_left_sidebar_post_wrap() {
384
-		echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' );
384
+		echo apply_filters('give_left_sidebar_post_wrap', '</div>');
385 385
 	}
386 386
 }
387 387
 
388
-if ( ! function_exists( 'give_get_forms_sidebar' ) ) {
388
+if ( ! function_exists('give_get_forms_sidebar')) {
389 389
 	function give_get_forms_sidebar() {
390
-		give_get_template_part( 'single-give-form/sidebar' );
390
+		give_get_template_part('single-give-form/sidebar');
391 391
 	}
392 392
 }
393 393
 
394
-if ( ! function_exists( 'give_show_form_images' ) ) {
394
+if ( ! function_exists('give_show_form_images')) {
395 395
 
396 396
 	/**
397 397
 	 * Output the donation form featured image.
398 398
 	 */
399 399
 	function give_show_form_images() {
400
-		if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
401
-			give_get_template_part( 'single-give-form/featured-image' );
400
+		if (give_is_setting_enabled(give_get_option('form_featured_img'))) {
401
+			give_get_template_part('single-give-form/featured-image');
402 402
 		}
403 403
 	}
404 404
 }
405 405
 
406
-if ( ! function_exists( 'give_template_single_title' ) ) {
406
+if ( ! function_exists('give_template_single_title')) {
407 407
 
408 408
 	/**
409 409
 	 * Output the form title.
410 410
 	 */
411 411
 	function give_template_single_title() {
412
-		give_get_template_part( 'single-give-form/title' );
412
+		give_get_template_part('single-give-form/title');
413 413
 	}
414 414
 }
415 415
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
  * Conditional Functions
418 418
  */
419 419
 
420
-if ( ! function_exists( 'is_give_form' ) ) {
420
+if ( ! function_exists('is_give_form')) {
421 421
 
422 422
 	/**
423 423
 	 * is_give_form
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
 	 * @return bool
430 430
 	 */
431 431
 	function is_give_form() {
432
-		return is_singular( array( 'give_form' ) );
432
+		return is_singular(array('give_form'));
433 433
 	}
434 434
 }
435 435
 
436
-if ( ! function_exists( 'is_give_category' ) ) {
436
+if ( ! function_exists('is_give_category')) {
437 437
 
438 438
 	/**
439 439
 	 * is_give_category
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @return bool
450 450
 	 */
451
-	function is_give_category( $term = '' ) {
452
-		return is_tax( 'give_forms_category', $term );
451
+	function is_give_category($term = '') {
452
+		return is_tax('give_forms_category', $term);
453 453
 	}
454 454
 }
455 455
 
456
-if ( ! function_exists( 'is_give_tag' ) ) {
456
+if ( ! function_exists('is_give_tag')) {
457 457
 
458 458
 	/**
459 459
 	 * is_give_tag
@@ -468,12 +468,12 @@  discard block
 block discarded – undo
468 468
 	 *
469 469
 	 * @return bool
470 470
 	 */
471
-	function is_give_tag( $term = '' ) {
472
-		return is_tax( 'give_forms_tag', $term );
471
+	function is_give_tag($term = '') {
472
+		return is_tax('give_forms_tag', $term);
473 473
 	}
474 474
 }
475 475
 
476
-if ( ! function_exists( 'is_give_taxonomy' ) ) {
476
+if ( ! function_exists('is_give_taxonomy')) {
477 477
 
478 478
 	/**
479 479
 	 * is_give_taxonomy
@@ -485,6 +485,6 @@  discard block
 block discarded – undo
485 485
 	 * @return bool
486 486
 	 */
487 487
 	function is_give_taxonomy() {
488
-		return is_tax( get_object_taxonomies( 'give_form' ) );
488
+		return is_tax(get_object_taxonomies('give_form'));
489 489
 	}
490 490
 }
Please login to merge, or discard this patch.
includes/admin/dashboard-widgets.php 1 patch
Spacing   +32 added lines, -32 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
 
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
  * @return void
22 22
  */
23 23
 function give_register_dashboard_widgets() {
24
-	if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) {
25
-		wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' );
24
+	if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) {
25
+		wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget');
26 26
 	}
27 27
 }
28 28
 
29
-add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 );
29
+add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10);
30 30
 
31 31
 /**
32 32
  * Sales Summary Dashboard Widget
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  */
39 39
 function give_dashboard_sales_widget() {
40 40
 
41
-	if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) {
41
+	if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) {
42 42
 		return;
43 43
 	}
44 44
 	$stats = new Give_Payment_Stats; ?>
@@ -46,27 +46,27 @@  discard block
 block discarded – undo
46 46
 	<div class="give-dashboard-widget">
47 47
 
48 48
 		<div class="give-dashboard-today give-clearfix">
49
-			<h3 class="give-dashboard-date-today"><?php echo date( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3>
49
+			<h3 class="give-dashboard-date-today"><?php echo date(_x('F j, Y', 'dashboard widget', 'give')); ?></h3>
50 50
 
51 51
 			<p class="give-dashboard-happy-day"><?php
52 52
 				printf(
53 53
 				/* translators: %s: day of the week */
54
-					esc_html__( 'Happy %s!', 'give' ),
55
-					date( 'l', current_time( 'timestamp' ) )
54
+					esc_html__('Happy %s!', 'give'),
55
+					date('l', current_time('timestamp'))
56 56
 				);
57 57
 			?></p>
58 58
 
59 59
 			<p class="give-dashboard-today-earnings"><?php
60
-				$earnings_today = $stats->get_earnings( 0, 'today', false );
61
-				echo give_currency_filter( give_format_amount( $earnings_today ) );
60
+				$earnings_today = $stats->get_earnings(0, 'today', false);
61
+				echo give_currency_filter(give_format_amount($earnings_today));
62 62
 			?></p>
63 63
 
64 64
 			<p class="give-orders-today"><?php
65
-				$donations_today = $stats->get_sales( 0, 'today', false );
65
+				$donations_today = $stats->get_sales(0, 'today', false);
66 66
 				printf(
67 67
 					/* translators: %s: daily donation count */
68
-					esc_html__( '%s donations today', 'give' ),
69
-					give_format_amount( $donations_today, false )
68
+					esc_html__('%s donations today', 'give'),
69
+					give_format_amount($donations_today, false)
70 70
 				);
71 71
 			?></p>
72 72
 
@@ -76,34 +76,34 @@  discard block
 block discarded – undo
76 76
 		<table class="give-table-stats">
77 77
 			<thead style="display: none;">
78 78
 			<tr>
79
-				<th><?php esc_html_e( 'This Week', 'give' ); ?></th>
80
-				<th><?php esc_html_e( 'This Month', 'give' ); ?></th>
81
-				<th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th>
79
+				<th><?php esc_html_e('This Week', 'give'); ?></th>
80
+				<th><?php esc_html_e('This Month', 'give'); ?></th>
81
+				<th><?php esc_html_e('Past 30 Days', 'give'); ?></th>
82 82
 			</tr>
83 83
 			</thead>
84 84
 			<tbody>
85 85
 			<tr id="give-table-stats-tr-1">
86 86
 				<td>
87
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ) ) ); ?></p>
87
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'))); ?></p>
88 88
 
89
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Week', 'give' ); ?></p>
89
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('This Week', 'give'); ?></p>
90 90
 				</td>
91 91
 				<td>
92
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ); ?></p>
92
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'))); ?></p>
93 93
 
94
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Month', 'give' ); ?></p>
94
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('This Month', 'give'); ?></p>
95 95
 				</td>
96 96
 			</tr>
97 97
 			<tr id="give-table-stats-tr-2">
98 98
 				<td>
99
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ) ) ) ?></p>
99
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'))) ?></p>
100 100
 
101
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'Last Month', 'give' ); ?></p>
101
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('Last Month', 'give'); ?></p>
102 102
 				</td>
103 103
 				<td>
104
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ) ) ) ?></p>
104
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false))) ?></p>
105 105
 
106
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Year', 'give' ); ?></p>
106
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('This Year', 'give'); ?></p>
107 107
 				</td>
108 108
 			</tr>
109 109
 			</tbody>
@@ -123,23 +123,23 @@  discard block
 block discarded – undo
123 123
  *
124 124
  * @return array
125 125
  */
126
-function give_dashboard_at_a_glance_widget( $items ) {
127
-	$num_posts = wp_count_posts( 'give_forms' );
126
+function give_dashboard_at_a_glance_widget($items) {
127
+	$num_posts = wp_count_posts('give_forms');
128 128
 
129
-	if ( $num_posts && $num_posts->publish ) {
129
+	if ($num_posts && $num_posts->publish) {
130 130
 
131 131
 		$text = sprintf(
132 132
 			/* translators: %s: number of posts published */
133
-			_n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ),
133
+			_n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'),
134 134
 			$num_posts->publish
135 135
 		);
136 136
 
137
-		$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
137
+		$text = sprintf($text, number_format_i18n($num_posts->publish));
138 138
 
139
-		if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
139
+		if (current_user_can('edit_give_forms', get_current_user_id())) {
140 140
 			$text = sprintf(
141 141
 				'<a class="give-forms-count" href="%1$s">%2$s</a>',
142
-				admin_url( 'edit.php?post_type=give_forms' ),
142
+				admin_url('edit.php?post_type=give_forms'),
143 143
 				$text
144 144
 			);
145 145
 		} else {
@@ -155,4 +155,4 @@  discard block
 block discarded – undo
155 155
 	return $items;
156 156
 }
157 157
 
158
-add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 );
158
+add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1);
Please login to merge, or discard this patch.
includes/admin/customers/customers.php 1 patch
Spacing   +157 added lines, -157 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
 
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
  */
25 25
 function give_customers_page() {
26 26
 	$default_views  = give_customer_views();
27
-	$requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'customers';
28
-	if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) {
29
-		give_render_customer_view( $requested_view, $default_views );
27
+	$requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'customers';
28
+	if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) {
29
+		give_render_customer_view($requested_view, $default_views);
30 30
 	} else {
31 31
 		give_customers_list();
32 32
 	}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 	$views = array();
44 44
 
45
-	return apply_filters( 'give_customer_views', $views );
45
+	return apply_filters('give_customer_views', $views);
46 46
 
47 47
 }
48 48
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 	$tabs = array();
58 58
 
59
-	return apply_filters( 'give_customer_tabs', $tabs );
59
+	return apply_filters('give_customer_tabs', $tabs);
60 60
 
61 61
 }
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
  * @return void
68 68
  */
69 69
 function give_customers_list() {
70
-	include( dirname( __FILE__ ) . '/class-customer-table.php' );
70
+	include(dirname(__FILE__).'/class-customer-table.php');
71 71
 
72 72
 	$customers_table = new Give_Customer_Reports_Table();
73 73
 	$customers_table->prepare_items();
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 		 *
81 81
 		 * @since 1.0
82 82
 		 */
83
-		do_action( 'give_donors_table_top' );
83
+		do_action('give_donors_table_top');
84 84
 		?>
85
-		<form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>">
85
+		<form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>">
86 86
 			<?php
87
-			$customers_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' );
87
+			$customers_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors');
88 88
 			$customers_table->display();
89 89
 			?>
90 90
 			<input type="hidden" name="post_type" value="give_forms" />
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		 *
98 98
 		 * @since 1.0
99 99
 		 */
100
-		do_action( 'give_donors_table_bottom' );
100
+		do_action('give_donors_table_bottom');
101 101
 		?>
102 102
 	</div>
103 103
 	<?php
@@ -113,27 +113,27 @@  discard block
 block discarded – undo
113 113
  *
114 114
  * @return void
115 115
  */
116
-function give_render_customer_view( $view, $callbacks ) {
116
+function give_render_customer_view($view, $callbacks) {
117 117
 
118 118
 	$render = true;
119 119
 
120
-	$customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' );
120
+	$customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports');
121 121
 
122
-	if ( ! current_user_can( $customer_view_role ) ) {
123
-		give_set_error( 'give-no-access', esc_html__( 'You are not permitted to view this data.', 'give' ) );
122
+	if ( ! current_user_can($customer_view_role)) {
123
+		give_set_error('give-no-access', esc_html__('You are not permitted to view this data.', 'give'));
124 124
 		$render = false;
125 125
 	}
126 126
  
127
-	if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
128
-		give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) );
127
+	if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) {
128
+		give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give'));
129 129
 		$render = false;
130 130
 	}
131 131
 
132 132
 	$customer_id = (int) $_GET['id'];
133
-	$customer    = new Give_Customer( $customer_id );
133
+	$customer    = new Give_Customer($customer_id);
134 134
 
135
-	if ( empty( $customer->id ) ) {
136
-		give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) );
135
+	if (empty($customer->id)) {
136
+		give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give'));
137 137
 		$render = false;
138 138
 	}
139 139
 
@@ -142,34 +142,34 @@  discard block
 block discarded – undo
142 142
 
143 143
 	<div class='wrap'>
144 144
 
145
-		<?php if ( give_get_errors() ) : ?>
145
+		<?php if (give_get_errors()) : ?>
146 146
 			<div class="error settings-error">
147
-				<?php give_print_errors( 0 ); ?>
147
+				<?php give_print_errors(0); ?>
148 148
 			</div>
149 149
 		<?php endif; ?>
150 150
 
151
-		<h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1>
151
+		<h1 class="screen-reader-text"><?php esc_html_e('Donor', 'give'); ?></h1>
152 152
 
153
-		<?php if ( $customer && $render ) : ?>
153
+		<?php if ($customer && $render) : ?>
154 154
 
155 155
 			<h2 class="nav-tab-wrapper">
156 156
 			<?php
157
-			foreach ( $customer_tabs as $key => $tab ) :
157
+			foreach ($customer_tabs as $key => $tab) :
158 158
 				$active = $key === $view ? true : false;
159 159
 				$class = $active ? 'nav-tab nav-tab-active' : 'nav-tab';
160 160
 				printf(
161 161
 					'<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n",
162
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $customer->id ) ),
163
-					esc_attr( $class ),
164
-					sanitize_html_class( $tab['dashicon'] ),
165
-					esc_html( $tab['title'] )
162
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$customer->id)),
163
+					esc_attr($class),
164
+					sanitize_html_class($tab['dashicon']),
165
+					esc_html($tab['title'])
166 166
 				);
167 167
 			endforeach;
168 168
 			?>
169 169
 			</h2>
170 170
 
171 171
 			<div id="give-customer-card-wrapper">
172
-				<?php $callbacks[ $view ]( $customer ) ?>
172
+				<?php $callbacks[$view]($customer) ?>
173 173
 			</div>
174 174
 
175 175
 		<?php endif; ?>
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
  *
190 190
  * @return void
191 191
  */
192
-function give_customers_view( $customer ) {
192
+function give_customers_view($customer) {
193 193
 
194
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
194
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
195 195
 
196 196
 	/**
197 197
 	 * Fires in donor profile screen, above the donor card.
@@ -200,32 +200,32 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @param object $customer The customer object being displayed.
202 202
 	 */
203
-	do_action( 'give_donor_card_top', $customer );
203
+	do_action('give_donor_card_top', $customer);
204 204
 	?>
205 205
 
206 206
 	<div id="donor-summary" class="info-wrapper customer-section postbox">
207 207
 
208
-		<form id="edit-customer-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>">
208
+		<form id="edit-customer-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>">
209 209
 
210 210
 			<div class="customer-info">
211 211
 
212 212
 				<div class="donor-bio-header clearfix">
213 213
 
214 214
 					<div class="avatar-wrap left" id="customer-avatar">
215
-						<?php echo get_avatar( $customer->email ); ?>
215
+						<?php echo get_avatar($customer->email); ?>
216 216
 					</div>
217 217
 
218 218
 					<div id="customer-name-wrap" class="left">
219 219
 						<span class="customer-id">#<?php echo $customer->id; ?></span>
220
-						<span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $customer->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span>
220
+						<span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($customer->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span>
221 221
 						<span class="customer-name info-item editable"><span data-key="name"><?php echo $customer->name; ?></span></span>
222 222
 					</div>
223 223
 					<p class="customer-since info-item">
224
-						<?php esc_html_e( 'Donor since', 'give' ); ?>
225
-						<?php echo date_i18n( give_date_format(), strtotime( $customer->date_created ) ) ?>
224
+						<?php esc_html_e('Donor since', 'give'); ?>
225
+						<?php echo date_i18n(give_date_format(), strtotime($customer->date_created)) ?>
226 226
 					</p>
227
-					<?php if ( current_user_can( $customer_edit_role ) ): ?>
228
-						<a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a>
227
+					<?php if (current_user_can($customer_edit_role)): ?>
228
+						<a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a>
229 229
 					<?php endif; ?>
230 230
 				</div>
231 231
 				<!-- /donor-bio-header -->
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 					<table class="widefat">
236 236
 						<tbody>
237 237
 						<tr class="alternate">
238
-							<th scope="col"><label for="tablecell"><?php esc_html_e( 'User ID:', 'give' ); ?></label></th>
238
+							<th scope="col"><label for="tablecell"><?php esc_html_e('User ID:', 'give'); ?></label></th>
239 239
 							<td class="row-title">
240 240
 								<span class="customer-user-id info-item edit-item">
241 241
 									<?php
@@ -251,38 +251,38 @@  discard block
 block discarded – undo
251 251
 										'data'  => $data_atts,
252 252
 									);
253 253
 
254
-									if ( ! empty( $user_id ) ) {
255
-										$userdata           = get_userdata( $user_id );
254
+									if ( ! empty($user_id)) {
255
+										$userdata           = get_userdata($user_id);
256 256
 										$user_args['value'] = $userdata->user_login;
257 257
 									}
258 258
 
259
-									echo Give()->html->ajax_user_search( $user_args );
259
+									echo Give()->html->ajax_user_search($user_args);
260 260
 									?>
261 261
 									<input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php echo $customer->user_id; ?>" />
262 262
 								</span>
263 263
 			
264 264
 								<span class="customer-user-id info-item editable">
265
-									<?php if ( intval( $customer->user_id ) > 0 ) { ?>
265
+									<?php if (intval($customer->user_id) > 0) { ?>
266 266
 										<span data-key="user_id"><?php echo $customer->user_id; ?></span>
267 267
 									<?php } else { ?>
268
-										<span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span>
268
+										<span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span>
269 269
 									<?php } ?>
270
-									<?php if ( current_user_can( $customer_edit_role ) && intval( $customer->user_id ) > 0 ) { ?>
271
-										<span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this customer record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span>
270
+									<?php if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) { ?>
271
+										<span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e('Disconnects the current user ID from this customer record.', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span>
272 272
 									<?php } ?>
273 273
 								</span>
274 274
 							</td>
275 275
 						</tr>
276
-						<?php if ( isset( $customer->user_id ) && $customer->user_id > 0 ) : ?>
276
+						<?php if (isset($customer->user_id) && $customer->user_id > 0) : ?>
277 277
 
278 278
 							<tr>
279
-								<th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th>
279
+								<th scope="col"><?php esc_html_e('Address:', 'give'); ?></th>
280 280
 								<td class="row-title">
281 281
 
282 282
 									<div class="customer-address-wrapper">
283 283
 
284 284
 										<?php
285
-										$address  = get_user_meta( $customer->user_id, '_give_user_address', true );
285
+										$address  = get_user_meta($customer->user_id, '_give_user_address', true);
286 286
 										$defaults = array(
287 287
 											'line1'   => '',
288 288
 											'line2'   => '',
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
 											'zip'     => ''
293 293
 										);
294 294
 
295
-										$address = wp_parse_args( $address, $defaults );
295
+										$address = wp_parse_args($address, $defaults);
296 296
 										?>
297 297
 
298
-										<?php if ( ! empty( $address ) ) { ?>
298
+										<?php if ( ! empty($address)) { ?>
299 299
 											<span class="customer-address info-item editable">
300 300
 												<span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span>
301 301
 												<span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span>
@@ -306,43 +306,43 @@  discard block
 block discarded – undo
306 306
 											</span>
307 307
 										<?php } ?>
308 308
 										<span class="customer-address info-item edit-item">
309
-											<input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" />
310
-											<input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" />
311
-											<input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" />
309
+											<input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" />
310
+											<input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" />
311
+											<input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" />
312 312
 											<select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item">
313 313
 												<?php
314 314
 
315 315
 												$selected_country = $address['country'];
316 316
 
317 317
 												$countries = give_get_country_list();
318
-												foreach ( $countries as $country_code => $country ) {
319
-													echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>';
318
+												foreach ($countries as $country_code => $country) {
319
+													echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>';
320 320
 												}
321 321
 												?>
322 322
 											</select>
323 323
 											<?php
324 324
 											$selected_state = give_get_state();
325
-											$states         = give_get_states( $selected_country );
325
+											$states         = give_get_states($selected_country);
326 326
 
327
-											$selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state;
327
+											$selected_state = isset($address['state']) ? $address['state'] : $selected_state;
328 328
 
329
-											if ( ! empty( $states ) ) {
329
+											if ( ! empty($states)) {
330 330
 												?>
331 331
 												<select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item">
332 332
 													<?php
333
-													foreach ( $states as $state_code => $state ) {
334
-														echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>';
333
+													foreach ($states as $state_code => $state) {
334
+														echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>';
335 335
 													}
336 336
 													?>
337 337
 												</select>
338 338
 												<?php
339 339
 											} else {
340 340
 												?>
341
-												<input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>" />
341
+												<input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>" />
342 342
 												<?php
343 343
 											}
344 344
 											?>
345
-											<input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" />
345
+											<input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" />
346 346
 										</span>
347 347
 
348 348
 									</div>
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
 
359 359
 			<span id="customer-edit-actions" class="edit-item">
360 360
 				<input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $customer->id; ?>" />
361
-				<?php wp_nonce_field( 'edit-customer', '_wpnonce', false, true ); ?>
361
+				<?php wp_nonce_field('edit-customer', '_wpnonce', false, true); ?>
362 362
 				<input type="hidden" name="give_action" value="edit-customer" />
363
-				<input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" />
364
-				<a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
363
+				<input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" />
364
+				<a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a>
365 365
 			</span>
366 366
 
367 367
 		</form>
@@ -376,24 +376,24 @@  discard block
 block discarded – undo
376 376
 	 *
377 377
 	 * @param object $customer The customer object being displayed.
378 378
 	 */
379
-	do_action( 'give_donor_before_stats', $customer );
379
+	do_action('give_donor_before_stats', $customer);
380 380
 	?>
381 381
 
382 382
 	<div id="customer-stats-wrapper" class="customer-section postbox clear">
383 383
 		<ul>
384 384
 			<li>
385
-				<a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $customer->email ) ); ?>">
385
+				<a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($customer->email)); ?>">
386 386
 					<span class="dashicons dashicons-heart"></span>
387 387
 					<?php
388 388
 					//Completed Donations
389
-					$completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give' ), $customer->purchase_count );
390
-					echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $customer );
389
+					$completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give'), $customer->purchase_count);
390
+					echo apply_filters('give_donor_completed_donations', $completed_donations_text, $customer);
391 391
 					?>
392 392
 				</a>
393 393
 			</li>
394 394
 			<li>
395 395
 				<span class="dashicons dashicons-chart-area"></span>
396
-				<?php echo give_currency_filter( give_format_amount( $customer->purchase_value ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?>
396
+				<?php echo give_currency_filter(give_format_amount($customer->purchase_value)); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?>
397 397
 			</li>
398 398
 			<?php
399 399
 			/**
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 			 *
406 406
 			 * @param object $customer The customer object being displayed.
407 407
 			 */
408
-			do_action( 'give_donor_stats_list', $customer );
408
+			do_action('give_donor_stats_list', $customer);
409 409
 			?>
410 410
 		</ul>
411 411
 	</div>
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	 *
419 419
 	 * @param object $customer The customer object being displayed.
420 420
 	 */
421
-	do_action( 'give_donor_before_tables_wrapper', $customer );
421
+	do_action('give_donor_before_tables_wrapper', $customer);
422 422
 	?>
423 423
 
424 424
 	<div id="customer-tables-wrapper" class="customer-section">
@@ -431,40 +431,40 @@  discard block
 block discarded – undo
431 431
 		 *
432 432
 		 * @param object $customer The customer object being displayed.
433 433
 		 */
434
-		do_action( 'give_donor_before_tables', $customer );
434
+		do_action('give_donor_before_tables', $customer);
435 435
 		?>
436 436
 
437
-		<h3><?php _e( 'Donor Emails', 'give' ); ?></h3>
437
+		<h3><?php _e('Donor Emails', 'give'); ?></h3>
438 438
 
439 439
 		<table class="wp-list-table widefat striped emails">
440 440
 			<thead>
441 441
 				<tr>
442
-					<th><?php _e( 'Email', 'give' ); ?></th>
443
-					<th><?php _e( 'Actions', 'give' ); ?></th>
442
+					<th><?php _e('Email', 'give'); ?></th>
443
+					<th><?php _e('Actions', 'give'); ?></th>
444 444
 				</tr>
445 445
 			</thead>
446 446
 
447 447
 			<tbody>
448
-				<?php if ( ! empty( $customer->emails ) ) { ?>
448
+				<?php if ( ! empty($customer->emails)) { ?>
449 449
 
450
-					<?php foreach ( $customer->emails as $key => $email ) : ?>
450
+					<?php foreach ($customer->emails as $key => $email) : ?>
451 451
 						<tr data-key="<?php echo $key; ?>">
452 452
 							<td>
453 453
 								<?php echo $email; ?>
454
-								<?php if ( 'primary' === $key ) : ?>
454
+								<?php if ('primary' === $key) : ?>
455 455
 									<span class="dashicons dashicons-star-filled primary-email-icon"></span>
456 456
 								<?php endif; ?>
457 457
 							</td>
458 458
 							<td>
459
-								<?php if ( 'primary' !== $key ) : ?>
459
+								<?php if ('primary' !== $key) : ?>
460 460
 									<?php
461
-									$base_url    = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id );
462
-									$promote_url = wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email ), 'give_action' => 'set_donor_primary_email'), $base_url ), 'give-set-donor-primary-email' );
463
-									$remove_url  = wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email ), 'give_action' => 'remove_donor_email' ), $base_url ), 'give-remove-donor-email'      );
461
+									$base_url    = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id);
462
+									$promote_url = wp_nonce_url(add_query_arg(array('email' => rawurlencode($email), 'give_action' => 'set_donor_primary_email'), $base_url), 'give-set-donor-primary-email');
463
+									$remove_url  = wp_nonce_url(add_query_arg(array('email' => rawurlencode($email), 'give_action' => 'remove_donor_email'), $base_url), 'give-remove-donor-email');
464 464
 									?>
465
-									<a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a>
465
+									<a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a>
466 466
 									&nbsp;|&nbsp;
467
-									<a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a>
467
+									<a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a>
468 468
 								<?php endif; ?>
469 469
 							</td>
470 470
 						</tr>
@@ -474,56 +474,56 @@  discard block
 block discarded – undo
474 474
 						<td colspan="2" class="add-customer-email-td">
475 475
 							<div class="add-customer-email-wrapper">
476 476
 								<input type="hidden" name="customer-id" value="<?php echo $customer->id; ?>" />
477
-								<?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?>
478
-								<input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" />&nbsp;
479
-								<input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" />&nbsp;<label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label>
480
-								<button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e( 'Add Email', 'give' ); ?></button>
477
+								<?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?>
478
+								<input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" />&nbsp;
479
+								<input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" />&nbsp;<label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label>
480
+								<button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e('Add Email', 'give'); ?></button>
481 481
 								<span class="spinner"></span>
482 482
 							</div>
483 483
 							<div class="notice-wrap"></div>
484 484
 						</td>
485 485
 					</tr>
486 486
 				<?php } else { ?>
487
-					<tr><td colspan="2"><?php _e( 'No Emails Found', 'easy-digital-downloads' ); ?></td></tr>
487
+					<tr><td colspan="2"><?php _e('No Emails Found', 'easy-digital-downloads'); ?></td></tr>
488 488
 				<?php } ?>
489 489
 			</tbody>
490 490
 		</table>
491 491
 
492
-		<h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3>
492
+		<h3><?php esc_html_e('Recent Donations', 'give'); ?></h3>
493 493
 		<?php
494
-		$payment_ids = explode( ',', $customer->payment_ids );
495
-		$payments    = give_get_payments( array( 'post__in' => $payment_ids ) );
496
-		$payments    = array_slice( $payments, 0, 10 );
494
+		$payment_ids = explode(',', $customer->payment_ids);
495
+		$payments    = give_get_payments(array('post__in' => $payment_ids));
496
+		$payments    = array_slice($payments, 0, 10);
497 497
 		?>
498 498
 		<table class="wp-list-table widefat striped payments">
499 499
 			<thead>
500 500
 			<tr>
501
-				<th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th>
502
-				<th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th>
503
-				<th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th>
504
-				<th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th>
505
-				<th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th>
501
+				<th scope="col"><?php esc_html_e('ID', 'give'); ?></th>
502
+				<th scope="col"><?php esc_html_e('Amount', 'give'); ?></th>
503
+				<th scope="col"><?php esc_html_e('Date', 'give'); ?></th>
504
+				<th scope="col"><?php esc_html_e('Status', 'give'); ?></th>
505
+				<th scope="col"><?php esc_html_e('Actions', 'give'); ?></th>
506 506
 			</tr>
507 507
 			</thead>
508 508
 			<tbody>
509
-			<?php if ( ! empty( $payments ) ) { ?>
510
-				<?php foreach ( $payments as $payment ) : ?>
509
+			<?php if ( ! empty($payments)) { ?>
510
+				<?php foreach ($payments as $payment) : ?>
511 511
 					<tr>
512 512
 						<td><?php echo $payment->ID; ?></td>
513
-						<td><?php echo give_payment_amount( $payment->ID ); ?></td>
514
-						<td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td>
515
-						<td><?php echo give_get_payment_status( $payment, true ); ?></td>
513
+						<td><?php echo give_payment_amount($payment->ID); ?></td>
514
+						<td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td>
515
+						<td><?php echo give_get_payment_status($payment, true); ?></td>
516 516
 						<td>
517 517
 							<?php
518 518
 							printf(
519 519
 								'<a href="%1$s" aria-label="%2$s">%3$s</a>',
520
-								admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID ),
520
+								admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment->ID),
521 521
 								sprintf(
522 522
 									/* translators: %s: Donation ID */
523
-									esc_attr__( 'View Donation %s.', 'give' ),
523
+									esc_attr__('View Donation %s.', 'give'),
524 524
 									$payment->ID
525 525
 								),
526
-								esc_html__( 'View Donation', 'give' )
526
+								esc_html__('View Donation', 'give')
527 527
 							);
528 528
 							?>
529 529
 
@@ -538,46 +538,46 @@  discard block
 block discarded – undo
538 538
 							 * @param object $customer The customer object being displayed.
539 539
 							 * @param object $payment  The payment object being displayed.
540 540
 							 */
541
-							do_action( 'give_donor_recent_purchases_actions', $customer, $payment );
541
+							do_action('give_donor_recent_purchases_actions', $customer, $payment);
542 542
 							?>
543 543
 						</td>
544 544
 					</tr>
545 545
 				<?php endforeach; ?>
546 546
 			<?php } else { ?>
547 547
 				<tr>
548
-					<td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td>
548
+					<td colspan="5"><?php esc_html_e('No donations found.', 'give'); ?></td>
549 549
 				</tr>
550 550
 			<?php } ?>
551 551
 			</tbody>
552 552
 		</table>
553 553
 
554
-		<h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3>
554
+		<h3><?php esc_html_e('Completed Forms', 'give'); ?></h3>
555 555
 		<?php
556
-		$donations = give_get_users_completed_donations( $customer->email );
556
+		$donations = give_get_users_completed_donations($customer->email);
557 557
 		?>
558 558
 		<table class="wp-list-table widefat striped donations">
559 559
 			<thead>
560 560
 			<tr>
561
-				<th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th>
562
-				<th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th>
561
+				<th scope="col"><?php esc_html_e('Form', 'give'); ?></th>
562
+				<th scope="col" width="120px"><?php esc_html_e('Actions', 'give'); ?></th>
563 563
 			</tr>
564 564
 			</thead>
565 565
 			<tbody>
566
-			<?php if ( ! empty( $donations ) ) { ?>
567
-				<?php foreach ( $donations as $donation ) : ?>
566
+			<?php if ( ! empty($donations)) { ?>
567
+				<?php foreach ($donations as $donation) : ?>
568 568
 					<tr>
569 569
 						<td><?php echo $donation->post_title; ?></td>
570 570
 						<td>
571 571
 							<?php
572 572
 							printf(
573 573
 								'<a href="%1$s" aria-label="%2$s">%3$s</a>',
574
-								esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ),
574
+								esc_url(admin_url('post.php?action=edit&post='.$donation->ID)),
575 575
 								sprintf(
576 576
 									/* translators: %s: form name */
577
-									esc_attr__( 'View Form %s.', 'give' ),
577
+									esc_attr__('View Form %s.', 'give'),
578 578
 									$donation->post_title
579 579
 								),
580
-								esc_html__( 'View Form', 'give' )
580
+								esc_html__('View Form', 'give')
581 581
 							);
582 582
 							?>
583 583
 						</td>
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 				<?php endforeach; ?>
586 586
 			<?php } else { ?>
587 587
 				<tr>
588
-					<td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td>
588
+					<td colspan="2"><?php esc_html_e('No completed donations found.', 'give'); ?></td>
589 589
 				</tr>
590 590
 			<?php } ?>
591 591
 			</tbody>
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 		 *
600 600
 		 * @param object $customer The customer object being displayed.
601 601
 		 */
602
-		do_action( 'give_donor_after_tables', $customer );
602
+		do_action('give_donor_after_tables', $customer);
603 603
 		?>
604 604
 
605 605
 	</div>
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	 *
613 613
 	 * @param object $customer The customer object being displayed.
614 614
 	 */
615
-	do_action( 'give_donor_card_bottom', $customer );
615
+	do_action('give_donor_card_bottom', $customer);
616 616
 
617 617
 }
618 618
 
@@ -625,30 +625,30 @@  discard block
 block discarded – undo
625 625
  *
626 626
  * @return void
627 627
  */
628
-function give_customer_notes_view( $customer ) {
628
+function give_customer_notes_view($customer) {
629 629
 
630
-	$paged          = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1;
631
-	$paged          = absint( $paged );
630
+	$paged          = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1;
631
+	$paged          = absint($paged);
632 632
 	$note_count     = $customer->get_notes_count();
633
-	$per_page       = apply_filters( 'give_customer_notes_per_page', 20 );
634
-	$total_pages    = ceil( $note_count / $per_page );
635
-	$customer_notes = $customer->get_notes( $per_page, $paged );
633
+	$per_page       = apply_filters('give_customer_notes_per_page', 20);
634
+	$total_pages    = ceil($note_count / $per_page);
635
+	$customer_notes = $customer->get_notes($per_page, $paged);
636 636
 	?>
637 637
 
638 638
 	<div id="customer-notes-wrapper">
639 639
 		<div class="customer-notes-header">
640
-			<?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span>
640
+			<?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span>
641 641
 		</div>
642
-		<h3><?php esc_html_e( 'Notes', 'give' ); ?></h3>
642
+		<h3><?php esc_html_e('Notes', 'give'); ?></h3>
643 643
 
644
-		<?php if ( 1 == $paged ) : ?>
644
+		<?php if (1 == $paged) : ?>
645 645
 			<div style="display: block; margin-bottom: 55px;">
646
-				<form id="give-add-customer-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $customer->id ); ?>">
646
+				<form id="give-add-customer-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$customer->id); ?>">
647 647
 					<textarea id="customer-note" name="customer_note" class="customer-note-input" rows="10"></textarea>
648 648
 					<br />
649 649
 					<input type="hidden" id="customer-id" name="customer_id" value="<?php echo $customer->id; ?>" />
650 650
 					<input type="hidden" name="give_action" value="add-customer-note" />
651
-					<?php wp_nonce_field( 'add-customer-note', 'add_customer_note_nonce', true, true ); ?>
651
+					<?php wp_nonce_field('add-customer-note', 'add_customer_note_nonce', true, true); ?>
652 652
 					<input id="add-customer-note" class="right button-primary" type="submit" value="Add Note" />
653 653
 				</form>
654 654
 			</div>
@@ -663,26 +663,26 @@  discard block
 block discarded – undo
663 663
 			'show_all' => true
664 664
 		);
665 665
 
666
-		echo paginate_links( $pagination_args );
666
+		echo paginate_links($pagination_args);
667 667
 		?>
668 668
 
669 669
 		<div id="give-customer-notes" class="postbox">
670
-			<?php if ( count( $customer_notes ) > 0 ) { ?>
671
-				<?php foreach ( $customer_notes as $key => $note ) : ?>
670
+			<?php if (count($customer_notes) > 0) { ?>
671
+				<?php foreach ($customer_notes as $key => $note) : ?>
672 672
 					<div class="customer-note-wrapper dashboard-comment-wrap comment-item">
673 673
 					<span class="note-content-wrap">
674
-						<?php echo stripslashes( $note ); ?>
674
+						<?php echo stripslashes($note); ?>
675 675
 					</span>
676 676
 					</div>
677 677
 				<?php endforeach; ?>
678 678
 			<?php } else { ?>
679 679
 				<div class="give-no-customer-notes">
680
-					<?php esc_html_e( 'No donor notes found.', 'give' ); ?>
680
+					<?php esc_html_e('No donor notes found.', 'give'); ?>
681 681
 				</div>
682 682
 			<?php } ?>
683 683
 		</div>
684 684
 
685
-		<?php echo paginate_links( $pagination_args ); ?>
685
+		<?php echo paginate_links($pagination_args); ?>
686 686
 
687 687
 	</div>
688 688
 
@@ -698,9 +698,9 @@  discard block
 block discarded – undo
698 698
  *
699 699
  * @return void
700 700
  */
701
-function give_customers_delete_view( $customer ) {
701
+function give_customers_delete_view($customer) {
702 702
 
703
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
703
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
704 704
 
705 705
 	/**
706 706
 	 * Fires in donor delete screen, above the content.
@@ -709,15 +709,15 @@  discard block
 block discarded – undo
709 709
 	 *
710 710
 	 * @param object $customer The customer object being displayed.
711 711
 	 */
712
-	do_action( 'give_customer_delete_top', $customer );
712
+	do_action('give_customer_delete_top', $customer);
713 713
 	?>
714 714
 
715 715
 	<div class="info-wrapper customer-section">
716 716
 
717
-		<form id="delete-customer" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer->id ); ?>">
717
+		<form id="delete-customer" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer->id); ?>">
718 718
 
719 719
 			<div class="customer-notes-header">
720
-				<?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span>
720
+				<?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span>
721 721
 			</div>
722 722
 
723 723
 
@@ -725,16 +725,16 @@  discard block
 block discarded – undo
725 725
 
726 726
 				<span class="delete-customer-options">
727 727
 					<p>
728
-						<?php echo Give()->html->checkbox( array( 'name' => 'give-customer-delete-confirm' ) ); ?>
729
-						<label for="give-customer-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label>
728
+						<?php echo Give()->html->checkbox(array('name' => 'give-customer-delete-confirm')); ?>
729
+						<label for="give-customer-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label>
730 730
 					</p>
731 731
 
732 732
 					<p>
733
-						<?php echo Give()->html->checkbox( array(
733
+						<?php echo Give()->html->checkbox(array(
734 734
 							'name'    => 'give-customer-delete-records',
735
-							'options' => array( 'disabled' => true )
736
-						) ); ?>
737
-						<label for="give-customer-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label>
735
+							'options' => array('disabled' => true)
736
+						)); ?>
737
+						<label for="give-customer-delete-records"><?php esc_html_e('Delete all associated donations and records?', 'give'); ?></label>
738 738
 					</p>
739 739
 
740 740
 					<?php
@@ -747,16 +747,16 @@  discard block
 block discarded – undo
747 747
 					 *
748 748
 					 * @param object $customer The customer object being displayed.
749 749
 					 */
750
-					do_action( 'give_customer_delete_inputs', $customer );
750
+					do_action('give_customer_delete_inputs', $customer);
751 751
 					?>
752 752
 				</span>
753 753
 
754 754
 				<span id="customer-edit-actions">
755 755
 					<input type="hidden" name="customer_id" value="<?php echo $customer->id; ?>" />
756
-					<?php wp_nonce_field( 'delete-customer', '_wpnonce', false, true ); ?>
756
+					<?php wp_nonce_field('delete-customer', '_wpnonce', false, true); ?>
757 757
 					<input type="hidden" name="give_action" value="delete-customer" />
758
-					<input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" />
759
-					<a id="give-delete-customer-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
758
+					<input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" />
759
+					<a id="give-delete-customer-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a>
760 760
 				</span>
761 761
 
762 762
 			</div>
@@ -772,5 +772,5 @@  discard block
 block discarded – undo
772 772
 	 *
773 773
 	 * @param object $customer The customer object being displayed.
774 774
 	 */
775
-	do_action( 'give_customer_delete_bottom', $customer );
775
+	do_action('give_customer_delete_bottom', $customer);
776 776
 }
Please login to merge, or discard this patch.
includes/admin/payments/actions.php 1 patch
Spacing   +119 added lines, -119 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 = array_map( 'trim', $data['give-payment-address'][0] );
66
+	$address = array_map('trim', $data['give-payment-address'][0]);
67 67
 
68
-	$curr_total = give_sanitize_amount( $payment->total );
69
-	$new_total  = give_sanitize_amount( $data['give-payment-total'] );
70
-	$date       = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00';
68
+	$curr_total = give_sanitize_amount($payment->total);
69
+	$new_total  = give_sanitize_amount($data['give-payment-total']);
70
+	$date       = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00';
71 71
 
72
-	$curr_customer_id = sanitize_text_field( $data['give-current-customer'] );
73
-	$new_customer_id  = sanitize_text_field( $data['customer-id'] );
72
+	$curr_customer_id = sanitize_text_field($data['give-current-customer']);
73
+	$new_customer_id  = sanitize_text_field($data['customer-id']);
74 74
 
75 75
 	/**
76 76
 	 * Fires before updating edited donation.
@@ -79,98 +79,98 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param int $payment_id The ID of the payment.
81 81
 	 */
82
-	do_action( 'give_update_edited_purchase', $payment_id );
82
+	do_action('give_update_edited_purchase', $payment_id);
83 83
 
84 84
 	$payment->date = $date;
85 85
 	$updated       = $payment->save();
86 86
 
87
-	if ( 0 === $updated ) {
88
-		wp_die( esc_html__( 'Error Updating Donation.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
87
+	if (0 === $updated) {
88
+		wp_die(esc_html__('Error Updating Donation.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
89 89
 	}
90 90
 
91 91
 	$customer_changed = false;
92 92
 
93
-	if ( isset( $data['give-new-customer'] ) && $data['give-new-customer'] == '1' ) {
93
+	if (isset($data['give-new-customer']) && $data['give-new-customer'] == '1') {
94 94
 
95
-		$email = isset( $data['give-new-customer-email'] ) ? sanitize_text_field( $data['give-new-customer-email'] ) : '';
96
-		$names = isset( $data['give-new-customer-name'] ) ? sanitize_text_field( $data['give-new-customer-name'] ) : '';
95
+		$email = isset($data['give-new-customer-email']) ? sanitize_text_field($data['give-new-customer-email']) : '';
96
+		$names = isset($data['give-new-customer-name']) ? sanitize_text_field($data['give-new-customer-name']) : '';
97 97
 
98
-		if ( empty( $email ) || empty( $names ) ) {
99
-			wp_die( esc_html__( 'New Customers require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
98
+		if (empty($email) || empty($names)) {
99
+			wp_die(esc_html__('New Customers require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
100 100
 		}
101 101
 
102
-		$customer = new Give_Customer( $email );
103
-		if ( empty( $customer->id ) ) {
104
-			$customer_data = array( 'name' => $names, 'email' => $email );
105
-			$user_id       = email_exists( $email );
106
-			if ( false !== $user_id ) {
102
+		$customer = new Give_Customer($email);
103
+		if (empty($customer->id)) {
104
+			$customer_data = array('name' => $names, 'email' => $email);
105
+			$user_id       = email_exists($email);
106
+			if (false !== $user_id) {
107 107
 				$customer_data['user_id'] = $user_id;
108 108
 			}
109 109
 
110
-			if ( ! $customer->create( $customer_data ) ) {
110
+			if ( ! $customer->create($customer_data)) {
111 111
 				// Failed to crete the new donor, assume the previous donor.
112 112
 				$customer_changed = false;
113
-				$customer         = new Give_Customer( $curr_customer_id );
114
-				give_set_error( 'give-payment-new-customer-fail', esc_html__( 'Error creating new donor.', 'give' ) );
113
+				$customer         = new Give_Customer($curr_customer_id);
114
+				give_set_error('give-payment-new-customer-fail', esc_html__('Error creating new donor.', 'give'));
115 115
 			}
116 116
 		}
117 117
 
118 118
 		$new_customer_id = $customer->id;
119 119
 
120
-		$previous_customer = new Give_Customer( $curr_customer_id );
120
+		$previous_customer = new Give_Customer($curr_customer_id);
121 121
 
122 122
 		$customer_changed = true;
123 123
 
124
-	} elseif ( $curr_customer_id !== $new_customer_id ) {
124
+	} elseif ($curr_customer_id !== $new_customer_id) {
125 125
 
126
-		$customer = new Give_Customer( $new_customer_id );
126
+		$customer = new Give_Customer($new_customer_id);
127 127
 		$email    = $customer->email;
128 128
 		$names    = $customer->name;
129 129
 
130
-		$previous_customer = new Give_Customer( $curr_customer_id );
130
+		$previous_customer = new Give_Customer($curr_customer_id);
131 131
 
132 132
 		$customer_changed = true;
133 133
 
134 134
 	} else {
135 135
 
136
-		$customer = new Give_Customer( $curr_customer_id );
136
+		$customer = new Give_Customer($curr_customer_id);
137 137
 		$email    = $customer->email;
138 138
 		$names    = $customer->name;
139 139
 
140 140
 	}
141 141
 
142 142
 	// Setup first and last name from input values.
143
-	$names      = explode( ' ', $names );
144
-	$first_name = ! empty( $names[0] ) ? $names[0] : '';
143
+	$names      = explode(' ', $names);
144
+	$first_name = ! empty($names[0]) ? $names[0] : '';
145 145
 	$last_name  = '';
146
-	if ( ! empty( $names[1] ) ) {
147
-		unset( $names[0] );
148
-		$last_name = implode( ' ', $names );
146
+	if ( ! empty($names[1])) {
147
+		unset($names[0]);
148
+		$last_name = implode(' ', $names);
149 149
 	}
150 150
 
151
-	if ( $customer_changed ) {
151
+	if ($customer_changed) {
152 152
 
153 153
 		// Remove the stats and payment from the previous customer and attach it to the new customer.
154
-		$previous_customer->remove_payment( $payment_id, false );
155
-		$customer->attach_payment( $payment_id, false );
154
+		$previous_customer->remove_payment($payment_id, false);
155
+		$customer->attach_payment($payment_id, false);
156 156
 
157
-		if ( 'publish' == $status ) {
157
+		if ('publish' == $status) {
158 158
 
159 159
 			// Reduce previous user donation count and amount.
160 160
 			$previous_customer->decrease_purchase_count();
161
-			$previous_customer->decrease_value( $curr_total );
161
+			$previous_customer->decrease_value($curr_total);
162 162
 
163 163
 			// If donation was completed adjust stats of new customers.
164 164
 			$customer->increase_purchase_count();
165
-			$customer->increase_value( $new_total );
165
+			$customer->increase_value($new_total);
166 166
 		}
167 167
 
168 168
 		$payment->customer_id = $customer->id;
169 169
 	} else {
170 170
 
171
-		if ( 'publish' === $status ) {
171
+		if ('publish' === $status) {
172 172
 			// Update user donation stat.
173
-			$customer->update_donation_value( $curr_total, $new_total );
173
+			$customer->update_donation_value($curr_total, $new_total);
174 174
 		}
175 175
 	}
176 176
 
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
 	$payment->total      = $new_total;
184 184
 
185 185
 	// Check for payment notes.
186
-	if ( ! empty( $data['give-payment-note'] ) ) {
186
+	if ( ! empty($data['give-payment-note'])) {
187 187
 
188
-		$note = wp_kses( $data['give-payment-note'], array() );
189
-		give_insert_payment_note( $payment_id, $note );
188
+		$note = wp_kses($data['give-payment-note'], array());
189
+		give_insert_payment_note($payment_id, $note);
190 190
 
191 191
 	}
192 192
 
@@ -194,17 +194,17 @@  discard block
 block discarded – undo
194 194
 	$payment->status = $status;
195 195
 
196 196
 	// Adjust total store earnings if the payment total has been changed.
197
-	if ( $new_total !== $curr_total && 'publish' == $status ) {
197
+	if ($new_total !== $curr_total && 'publish' == $status) {
198 198
 
199
-		if ( $new_total > $curr_total ) {
199
+		if ($new_total > $curr_total) {
200 200
 			// Increase if our new total is higher.
201 201
 			$difference = $new_total - $curr_total;
202
-			give_increase_total_earnings( $difference );
202
+			give_increase_total_earnings($difference);
203 203
 
204
-		} elseif ( $curr_total > $new_total ) {
204
+		} elseif ($curr_total > $new_total) {
205 205
 			// Decrease if our new total is lower.
206 206
 			$difference = $curr_total - $new_total;
207
-			give_decrease_total_earnings( $difference );
207
+			give_decrease_total_earnings($difference);
208 208
 
209 209
 		}
210 210
 	}
@@ -212,16 +212,16 @@  discard block
 block discarded – undo
212 212
 	$payment->save();
213 213
 
214 214
 	// Get new give form ID.
215
-	$new_form_id     = absint( $data['forms'] );
216
-	$current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) );
215
+	$new_form_id     = absint($data['forms']);
216
+	$current_form_id = absint($payment->get_meta('_give_payment_form_id'));
217 217
 
218 218
 	// We are adding payment transfer code in last to remove any conflict with above functionality.
219 219
 	// For example: above code will automatically handle form stat (increase/decrease) when payment status changes.
220 220
 	// Check if user want to transfer current payment to new give form id.
221
-	if ( $new_form_id != $current_form_id ) {
221
+	if ($new_form_id != $current_form_id) {
222 222
 
223 223
 		// Get new give form title.
224
-		$new_form_title = get_the_title( $new_form_id );
224
+		$new_form_title = get_the_title($new_form_id);
225 225
 
226 226
 		// Update new give form data in payment data.
227 227
 		$payment_meta               = $payment->get_meta();
@@ -229,56 +229,56 @@  discard block
 block discarded – undo
229 229
 		$payment_meta['form_id']    = $new_form_id;
230 230
 
231 231
 		// Update price id post meta data for set donation form.
232
-		if ( ! give_has_variable_prices( $new_form_id ) ) {
232
+		if ( ! give_has_variable_prices($new_form_id)) {
233 233
 			$payment_meta['price_id'] = '';
234 234
 		}
235 235
 
236 236
 		// Update payment give form meta data.
237
-		$payment->update_meta( '_give_payment_form_id', $new_form_id );
238
-		$payment->update_meta( '_give_payment_form_title', $new_form_title );
239
-		$payment->update_meta( '_give_payment_meta', $payment_meta );
237
+		$payment->update_meta('_give_payment_form_id', $new_form_id);
238
+		$payment->update_meta('_give_payment_form_title', $new_form_title);
239
+		$payment->update_meta('_give_payment_meta', $payment_meta);
240 240
 
241 241
 		// Update price id payment metadata.
242
-		if ( ! give_has_variable_prices( $new_form_id ) ) {
243
-			$payment->update_meta( '_give_payment_price_id', '' );
242
+		if ( ! give_has_variable_prices($new_form_id)) {
243
+			$payment->update_meta('_give_payment_price_id', '');
244 244
 		}
245 245
 
246 246
 		// If donation was completed, adjust stats of forms.
247
-		if ( 'publish' == $status ) {
247
+		if ('publish' == $status) {
248 248
 
249 249
 			// Decrease sale of old give form. For other payment status.
250
-			$current_form = new Give_Donate_Form( $current_form_id );
250
+			$current_form = new Give_Donate_Form($current_form_id);
251 251
 			$current_form->decrease_sales();
252
-			$current_form->decrease_earnings( $curr_total );
252
+			$current_form->decrease_earnings($curr_total);
253 253
 
254 254
 			// Increase sale of new give form.
255
-			$new_form = new Give_Donate_Form( $new_form_id );
255
+			$new_form = new Give_Donate_Form($new_form_id);
256 256
 			$new_form->increase_sales();
257
-			$new_form->increase_earnings( $new_total );
257
+			$new_form->increase_earnings($new_total);
258 258
 		}
259 259
 
260 260
 		// Re setup payment to update new meta value in object.
261
-		$payment->update_payment_setup( $payment->ID );
261
+		$payment->update_payment_setup($payment->ID);
262 262
 	}
263 263
 
264 264
 	// Update price id if current form is variable form.
265
-	if ( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) {
265
+	if ( ! empty($data['give-variable-price']) && give_has_variable_prices($payment->form_id)) {
266 266
 
267 267
 		// Get payment meta data.
268 268
 		$payment_meta = $payment->get_meta();
269 269
 
270 270
 		// Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ).
271
-		$data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : '';
271
+		$data['give-variable-price'] = ('custom' === $data['give-variable-price']) ? 'custom' : (0 < $data['give-variable-price']) ? $data['give-variable-price'] : '';
272 272
 
273 273
 		// Update payment meta data.
274 274
 		$payment_meta['price_id'] = $data['give-variable-price'];
275 275
 
276 276
 		// Update payment give form meta data.
277
-		$payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] );
278
-		$payment->update_meta( '_give_payment_meta', $payment_meta );
277
+		$payment->update_meta('_give_payment_price_id', $data['give-variable-price']);
278
+		$payment->update_meta('_give_payment_meta', $payment_meta);
279 279
 
280 280
 		// Re setup payment to update new meta value in object.
281
-		$payment->update_payment_setup( $payment->ID );
281
+		$payment->update_payment_setup($payment->ID);
282 282
 	}
283 283
 
284 284
 	/**
@@ -288,13 +288,13 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @param int $payment_id The ID of the payment.
290 290
 	 */
291
-	do_action( 'give_updated_edited_purchase', $payment_id );
291
+	do_action('give_updated_edited_purchase', $payment_id);
292 292
 
293
-	wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id ) );
293
+	wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id='.$payment_id));
294 294
 	exit;
295 295
 }
296 296
 
297
-add_action( 'give_update_payment_details', 'give_update_payment_details' );
297
+add_action('give_update_payment_details', 'give_update_payment_details');
298 298
 
299 299
 /**
300 300
  * Trigger a Donation Deletion
@@ -305,48 +305,48 @@  discard block
 block discarded – undo
305 305
  *
306 306
  * @return void
307 307
  */
308
-function give_trigger_purchase_delete( $data ) {
309
-	if ( wp_verify_nonce( $data['_wpnonce'], 'give_donation_nonce' ) ) {
308
+function give_trigger_purchase_delete($data) {
309
+	if (wp_verify_nonce($data['_wpnonce'], 'give_donation_nonce')) {
310 310
 
311
-		$payment_id = absint( $data['purchase_id'] );
311
+		$payment_id = absint($data['purchase_id']);
312 312
 
313
-		if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
314
-			wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
313
+		if ( ! current_user_can('edit_give_payments', $payment_id)) {
314
+			wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
315 315
 		}
316 316
 
317
-		give_delete_purchase( $payment_id );
318
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted' ) );
317
+		give_delete_purchase($payment_id);
318
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted'));
319 319
 		give_die();
320 320
 	}
321 321
 }
322 322
 
323
-add_action( 'give_delete_payment', 'give_trigger_purchase_delete' );
323
+add_action('give_delete_payment', 'give_trigger_purchase_delete');
324 324
 
325 325
 /**
326 326
  * AJAX Store Donation Note
327 327
  */
328 328
 function give_ajax_store_payment_note() {
329 329
 
330
-	$payment_id = absint( $_POST['payment_id'] );
331
-	$note       = wp_kses( $_POST['note'], array() );
330
+	$payment_id = absint($_POST['payment_id']);
331
+	$note       = wp_kses($_POST['note'], array());
332 332
 
333
-	if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) {
334
-		wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
333
+	if ( ! current_user_can('edit_give_payments', $payment_id)) {
334
+		wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
335 335
 	}
336 336
 
337
-	if ( empty( $payment_id ) ) {
338
-		die( '-1' );
337
+	if (empty($payment_id)) {
338
+		die('-1');
339 339
 	}
340 340
 
341
-	if ( empty( $note ) ) {
342
-		die( '-1' );
341
+	if (empty($note)) {
342
+		die('-1');
343 343
 	}
344 344
 
345
-	$note_id = give_insert_payment_note( $payment_id, $note );
346
-	die( give_get_payment_note_html( $note_id ) );
345
+	$note_id = give_insert_payment_note($payment_id, $note);
346
+	die(give_get_payment_note_html($note_id));
347 347
 }
348 348
 
349
-add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' );
349
+add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note');
350 350
 
351 351
 /**
352 352
  * Triggers a donation note deletion without ajax
@@ -357,24 +357,24 @@  discard block
 block discarded – undo
357 357
  *
358 358
  * @return void
359 359
  */
360
-function give_trigger_payment_note_deletion( $data ) {
360
+function give_trigger_payment_note_deletion($data) {
361 361
 
362
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) {
362
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) {
363 363
 		return;
364 364
 	}
365 365
 
366
-	if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) {
367
-		wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
366
+	if ( ! current_user_can('edit_give_payments', $data['payment_id'])) {
367
+		wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
368 368
 	}
369 369
 
370
-	$edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=donation-note-deleted&id=' . absint( $data['payment_id'] ) );
370
+	$edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=donation-note-deleted&id='.absint($data['payment_id']));
371 371
 
372
-	give_delete_payment_note( $data['note_id'], $data['payment_id'] );
372
+	give_delete_payment_note($data['note_id'], $data['payment_id']);
373 373
 
374
-	wp_redirect( $edit_order_url );
374
+	wp_redirect($edit_order_url);
375 375
 }
376 376
 
377
-add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' );
377
+add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion');
378 378
 
379 379
 /**
380 380
  * Delete a payment note deletion with ajax
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
  */
386 386
 function give_ajax_delete_payment_note() {
387 387
 
388
-	if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) {
389
-		wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
388
+	if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) {
389
+		wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
390 390
 	}
391 391
 
392
-	if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) {
393
-		die( '1' );
392
+	if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) {
393
+		die('1');
394 394
 	} else {
395
-		die( '-1' );
395
+		die('-1');
396 396
 	}
397 397
 
398 398
 }
399 399
 
400
-add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' );
400
+add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note');
Please login to merge, or discard this patch.