Test Failed
Pull Request — master (#2823)
by Devin
05:06
created
includes/admin/tools/data/class-give-tools-recount-donor-stats.php 1 patch
Spacing   +37 added lines, -37 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
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	/**
49 49
 	 * Constructor.
50 50
 	 */
51
-	public function __construct( $_step = 1 ) {
52
-		parent::__construct( $_step );
51
+	public function __construct($_step = 1) {
52
+		parent::__construct($_step);
53 53
 
54 54
 		$this->is_writable = true;
55 55
 	}
@@ -66,32 +66,32 @@  discard block
 block discarded – undo
66 66
 
67 67
 		$args = array(
68 68
 			'number'  => $this->per_step,
69
-			'offset'  => $this->per_step * ( $this->step - 1 ),
69
+			'offset'  => $this->per_step * ($this->step - 1),
70 70
 			'orderby' => 'id',
71 71
 			'order'   => 'DESC',
72 72
 		);
73 73
 
74
-		$donors = Give()->donors->get_donors( $args );
74
+		$donors = Give()->donors->get_donors($args);
75 75
 
76
-		if ( $donors ) {
76
+		if ($donors) {
77 77
 
78
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
78
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
79 79
 
80
-			foreach ( $donors as $donor ) {
80
+			foreach ($donors as $donor) {
81 81
 
82
-				$attached_payment_ids = explode( ',', $donor->payment_ids );
82
+				$attached_payment_ids = explode(',', $donor->payment_ids);
83 83
 
84 84
 				$attached_args = array(
85 85
 					'post__in' => $attached_payment_ids,
86
-					'number'   => - 1,
86
+					'number'   => -1,
87 87
 					'status'   => $allowed_payment_status,
88 88
 				);
89 89
 
90
-				$attached_payments = (array) give_get_payments( $attached_args );
90
+				$attached_payments = (array) give_get_payments($attached_args);
91 91
 
92 92
 				$unattached_args = array(
93 93
 					'post__not_in' => $attached_payment_ids,
94
-					'number'       => - 1,
94
+					'number'       => -1,
95 95
 					'status'       => $allowed_payment_status,
96 96
 					'meta_query'   => array(
97 97
 						array(
@@ -102,29 +102,29 @@  discard block
 block discarded – undo
102 102
 					),
103 103
 				);
104 104
 
105
-				$unattached_payments = give_get_payments( $unattached_args );
105
+				$unattached_payments = give_get_payments($unattached_args);
106 106
 
107
-				$payments = array_merge( $attached_payments, $unattached_payments );
107
+				$payments = array_merge($attached_payments, $unattached_payments);
108 108
 
109 109
 				$purchase_value = 0.00;
110 110
 				$purchase_count = 0;
111 111
 				$payment_ids    = array();
112 112
 
113
-				if ( $payments ) {
113
+				if ($payments) {
114 114
 
115
-					foreach ( $payments as $payment ) {
115
+					foreach ($payments as $payment) {
116 116
 
117 117
 						$should_process_payment = 'publish' == $payment->post_status ? true : false;
118
-						$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
118
+						$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
119 119
 
120
-						if ( true === $should_process_payment ) {
120
+						if (true === $should_process_payment) {
121 121
 
122
-							if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
123
-								$purchase_value += (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
122
+							if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
123
+								$purchase_value += (float) give_donation_amount($payment->ID, array('type' => 'stats'));
124 124
 							}
125 125
 
126
-							if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
127
-								$purchase_count ++;
126
+							if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
127
+								$purchase_count++;
128 128
 							}
129 129
 						}
130 130
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 					}
133 133
 				}
134 134
 
135
-				$payment_ids = implode( ',', $payment_ids );
135
+				$payment_ids = implode(',', $payment_ids);
136 136
 
137 137
 				$donor_update_data = array(
138 138
 					'purchase_count' => $purchase_count,
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 					'payment_ids'    => $payment_ids,
141 141
 				);
142 142
 
143
-				$donor_instance = new Give_Donor( $donor->id );
144
-				$donor_instance->update( $donor_update_data );
143
+				$donor_instance = new Give_Donor($donor->id);
144
+				$donor_instance->update($donor_update_data);
145 145
 
146 146
 			}// End foreach().
147 147
 
@@ -161,21 +161,21 @@  discard block
 block discarded – undo
161 161
 	public function get_percentage_complete() {
162 162
 
163 163
 		$args = array(
164
-			'number'  => - 1,
164
+			'number'  => -1,
165 165
 			'orderby' => 'id',
166 166
 			'order'   => 'DESC',
167 167
 		);
168 168
 
169
-		$donors = Give()->donors->get_donors( $args );
170
-		$total     = count( $donors );
169
+		$donors = Give()->donors->get_donors($args);
170
+		$total = count($donors);
171 171
 
172 172
 		$percentage = 100;
173 173
 
174
-		if ( $total > 0 ) {
175
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
174
+		if ($total > 0) {
175
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
176 176
 		}
177 177
 
178
-		if ( $percentage > 100 ) {
178
+		if ($percentage > 100) {
179 179
 			$percentage = 100;
180 180
 		}
181 181
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @param array $request The Form Data passed into the batch processing
191 191
 	 */
192
-	public function set_properties( $request ) {
192
+	public function set_properties($request) {
193 193
 	}
194 194
 
195 195
 	/**
@@ -200,21 +200,21 @@  discard block
 block discarded – undo
200 200
 	 */
201 201
 	public function process_step() {
202 202
 
203
-		if ( ! $this->can_export() ) {
204
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array(
203
+		if ( ! $this->can_export()) {
204
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array(
205 205
 				'response' => 403,
206
-			) );
206
+			));
207 207
 		}
208 208
 
209 209
 		$had_data = $this->get_data();
210 210
 
211
-		if ( $had_data ) {
211
+		if ($had_data) {
212 212
 			$this->done = false;
213 213
 
214 214
 			return true;
215 215
 		} else {
216 216
 			$this->done    = true;
217
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
217
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
218 218
 
219 219
 			return false;
220 220
 		}
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-form-stats.php 1 patch
Spacing   +53 added lines, -53 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
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * Constructor.
55 55
 	 */
56
-	public function __construct( $_step = 1 ) {
57
-		parent::__construct( $_step );
56
+	public function __construct($_step = 1) {
57
+		parent::__construct($_step);
58 58
 
59 59
 		$this->is_writable = true;
60 60
 	}
@@ -69,59 +69,59 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function get_data() {
71 71
 
72
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
72
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
73 73
 
74
-		if ( $this->step == 1 ) {
75
-			$this->delete_data( 'give_temp_recount_form_stats' );
74
+		if ($this->step == 1) {
75
+			$this->delete_data('give_temp_recount_form_stats');
76 76
 		}
77 77
 
78
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
78
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
79 79
 
80
-		if ( false === $totals ) {
80
+		if (false === $totals) {
81 81
 			$totals = array(
82 82
 				'earnings' => (float) 0,
83 83
 				'sales'    => 0,
84 84
 			);
85
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
85
+			$this->store_data('give_temp_recount_form_stats', $totals);
86 86
 		}
87 87
 
88
-		$args = apply_filters( 'give_recount_form_stats_args', array(
88
+		$args = apply_filters('give_recount_form_stats_args', array(
89 89
 			'give_forms' => $this->form_id,
90 90
 			'number'     => $this->per_step,
91 91
 			'status'     => $accepted_statuses,
92 92
 			'paged'      => $this->step,
93 93
 			'fields'     => 'ids',
94
-		) );
94
+		));
95 95
 
96
-		$payments = new Give_Payments_Query( $args );
96
+		$payments = new Give_Payments_Query($args);
97 97
 		$payments = $payments->get_payments();
98 98
 
99
-		if ( $payments ) {
100
-			foreach ( $payments as $payment ) {
99
+		if ($payments) {
100
+			foreach ($payments as $payment) {
101 101
 
102 102
 				// Ensure acceptable status only.
103
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
103
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
104 104
 					continue;
105 105
 				}
106 106
 
107 107
 				// Ensure only payments for this form are counted.
108
-				if ( $payment->form_id != $this->form_id ) {
108
+				if ($payment->form_id != $this->form_id) {
109 109
 					continue;
110 110
 				}
111 111
 
112
-				$totals['sales'] ++;
112
+				$totals['sales']++;
113 113
 				$totals['earnings'] += $payment->total;
114 114
 
115 115
 			}
116 116
 
117
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
117
+			$this->store_data('give_temp_recount_form_stats', $totals);
118 118
 
119 119
 			return true;
120 120
 		}
121 121
 
122 122
 
123
-		give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
124
-		give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) );
123
+		give_update_meta($this->form_id, '_give_form_sales', $totals['sales']);
124
+		give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings']));
125 125
 
126 126
 		return false;
127 127
 	}
@@ -133,35 +133,35 @@  discard block
 block discarded – undo
133 133
 	 * @return int
134 134
 	 */
135 135
 	public function get_percentage_complete() {
136
-		if ( $this->step == 1 ) {
137
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
136
+		if ($this->step == 1) {
137
+			$this->delete_data('give_recount_total_'.$this->form_id);
138 138
 		}
139 139
 
140
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
141
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
140
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
141
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
142 142
 
143
-		if ( false === $total ) {
143
+		if (false === $total) {
144 144
 			$total = 0;
145
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
145
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
146 146
 				'give_forms' => $this->form_id,
147
-				'number'     => - 1,
147
+				'number'     => -1,
148 148
 				'status'     => $accepted_statuses,
149 149
 				'fields'     => 'ids',
150
-			) );
150
+			));
151 151
 
152
-			$payments = new Give_Payments_Query( $args );
153
-			$total    = count( $payments->get_payments() );
154
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
152
+			$payments = new Give_Payments_Query($args);
153
+			$total    = count($payments->get_payments());
154
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
155 155
 
156 156
 		}
157 157
 
158 158
 		$percentage = 100;
159 159
 
160
-		if ( $total > 0 ) {
161
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
160
+		if ($total > 0) {
161
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
162 162
 		}
163 163
 
164
-		if ( $percentage > 100 ) {
164
+		if ($percentage > 100) {
165 165
 			$percentage = 100;
166 166
 		}
167 167
 
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @param array $request The Form Data passed into the batch processing
177 177
 	 */
178
-	public function set_properties( $request ) {
179
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
178
+	public function set_properties($request) {
179
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
180 180
 	}
181 181
 
182 182
 	/**
@@ -187,21 +187,21 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	public function process_step() {
189 189
 
190
-		if ( ! $this->can_export() ) {
191
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
190
+		if ( ! $this->can_export()) {
191
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
192 192
 		}
193 193
 
194 194
 		$had_data = $this->get_data();
195 195
 
196
-		if ( $had_data ) {
196
+		if ($had_data) {
197 197
 			$this->done = false;
198 198
 
199 199
 			return true;
200 200
 		} else {
201
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
202
-			$this->delete_data( 'give_temp_recount_form_stats' );
201
+			$this->delete_data('give_recount_total_'.$this->form_id);
202
+			$this->delete_data('give_temp_recount_form_stats');
203 203
 			$this->done    = true;
204
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
204
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
205 205
 
206 206
 			return false;
207 207
 		}
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 	 *
236 236
 	 * @return mixed       Returns the data from the database
237 237
 	 */
238
-	private function get_stored_data( $key ) {
238
+	private function get_stored_data($key) {
239 239
 		global $wpdb;
240
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
240
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
241 241
 
242
-		if ( empty( $value ) ) {
242
+		if (empty($value)) {
243 243
 			return false;
244 244
 		}
245 245
 
246
-		$maybe_json = json_decode( $value );
247
-		if ( ! is_null( $maybe_json ) ) {
248
-			$value = json_decode( $value, true );
246
+		$maybe_json = json_decode($value);
247
+		if ( ! is_null($maybe_json)) {
248
+			$value = json_decode($value, true);
249 249
 		}
250 250
 
251 251
 		return $value;
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @return void
263 263
 	 */
264
-	private function store_data( $key, $value ) {
264
+	private function store_data($key, $value) {
265 265
 		global $wpdb;
266 266
 
267
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
267
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
268 268
 
269 269
 		$data = array(
270 270
 			'option_name'  => $key,
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 			'%s',
279 279
 		);
280 280
 
281
-		$wpdb->replace( $wpdb->options, $data, $formats );
281
+		$wpdb->replace($wpdb->options, $data, $formats);
282 282
 	}
283 283
 
284 284
 	/**
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
 	 *
291 291
 	 * @return void
292 292
 	 */
293
-	private function delete_data( $key ) {
293
+	private function delete_data($key) {
294 294
 		global $wpdb;
295
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
295
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
296 296
 	}
297 297
 
298 298
 }
299 299
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-income.php 1 patch
Spacing   +47 added lines, -47 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
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -61,49 +61,49 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function get_data() {
63 63
 
64
-		if ( $this->step == 1 ) {
65
-			$this->delete_data( 'give_temp_recount_earnings' );
64
+		if ($this->step == 1) {
65
+			$this->delete_data('give_temp_recount_earnings');
66 66
 		}
67 67
 
68
-		$total = get_option( 'give_temp_recount_earnings', false );
68
+		$total = get_option('give_temp_recount_earnings', false);
69 69
 
70
-		if ( false === $total ) {
70
+		if (false === $total) {
71 71
 			$total = (float) 0;
72
-			$this->store_data( 'give_temp_recount_earnings', $total );
72
+			$this->store_data('give_temp_recount_earnings', $total);
73 73
 		}
74 74
 
75
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
75
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
76 76
 
77
-		$args = apply_filters( 'give_recount_earnings_args', array(
77
+		$args = apply_filters('give_recount_earnings_args', array(
78 78
 			'number' => $this->per_step,
79 79
 			'page'   => $this->step,
80 80
 			'status' => $accepted_statuses,
81 81
 			'fields' => 'ids'
82
-		) );
82
+		));
83 83
 
84
-		$payments = give_get_payments( $args );
84
+		$payments = give_get_payments($args);
85 85
 
86
-		if ( ! empty( $payments ) ) {
86
+		if ( ! empty($payments)) {
87 87
 
88
-			foreach ( $payments as $payment ) {
88
+			foreach ($payments as $payment) {
89 89
 
90
-				$total += (float) give_donation_amount( $payment, array( 'type' => 'stats' ) );
90
+				$total += (float) give_donation_amount($payment, array('type' => 'stats'));
91 91
 
92 92
 			}
93 93
 
94
-			if ( $total < 0 ) {
94
+			if ($total < 0) {
95 95
 				$totals = 0;
96 96
 			}
97 97
 
98
-			$total = round( $total, give_get_price_decimals() );
98
+			$total = round($total, give_get_price_decimals());
99 99
 
100
-			$this->store_data( 'give_temp_recount_earnings', $total );
100
+			$this->store_data('give_temp_recount_earnings', $total);
101 101
 
102 102
 			return true;
103 103
 
104 104
 		}
105 105
 
106
-		update_option( 'give_earnings_total', $total );
106
+		update_option('give_earnings_total', $total);
107 107
 
108 108
 		return false;
109 109
 
@@ -117,25 +117,25 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function get_percentage_complete() {
119 119
 
120
-		$total = $this->get_stored_data( 'give_recount_earnings_total' );
120
+		$total = $this->get_stored_data('give_recount_earnings_total');
121 121
 
122
-		if ( false === $total ) {
123
-			$args = apply_filters( 'give_recount_earnings_total_args', array() );
122
+		if (false === $total) {
123
+			$args = apply_filters('give_recount_earnings_total_args', array());
124 124
 
125
-			$counts = give_count_payments( $args );
126
-			$total  = absint( $counts->publish );
127
-			$total  = apply_filters( 'give_recount_store_earnings_total', $total );
125
+			$counts = give_count_payments($args);
126
+			$total  = absint($counts->publish);
127
+			$total  = apply_filters('give_recount_store_earnings_total', $total);
128 128
 
129
-			$this->store_data( 'give_recount_earnings_total', $total );
129
+			$this->store_data('give_recount_earnings_total', $total);
130 130
 		}
131 131
 
132 132
 		$percentage = 100;
133 133
 
134
-		if ( $total > 0 ) {
135
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
134
+		if ($total > 0) {
135
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
136 136
 		}
137 137
 
138
-		if ( $percentage > 100 ) {
138
+		if ($percentage > 100) {
139 139
 			$percentage = 100;
140 140
 		}
141 141
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param array $request The Form Data passed into the batch processing
151 151
 	 */
152
-	public function set_properties( $request ) {
152
+	public function set_properties($request) {
153 153
 	}
154 154
 
155 155
 	/**
@@ -160,21 +160,21 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function process_step() {
162 162
 
163
-		if ( ! $this->can_export() ) {
164
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
163
+		if ( ! $this->can_export()) {
164
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
165 165
 		}
166 166
 
167 167
 		$had_data = $this->get_data();
168 168
 
169
-		if ( $had_data ) {
169
+		if ($had_data) {
170 170
 			$this->done = false;
171 171
 
172 172
 			return true;
173 173
 		} else {
174
-			$this->delete_data( 'give_recount_earnings_total' );
175
-			$this->delete_data( 'give_temp_recount_earnings' );
174
+			$this->delete_data('give_recount_earnings_total');
175
+			$this->delete_data('give_temp_recount_earnings');
176 176
 			$this->done    = true;
177
-			$this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' );
177
+			$this->message = esc_html__('Income stats have been successfully recounted.', 'give');
178 178
 
179 179
 			return false;
180 180
 		}
@@ -211,17 +211,17 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @return mixed       Returns the data from the database
213 213
 	 */
214
-	private function get_stored_data( $key ) {
214
+	private function get_stored_data($key) {
215 215
 		global $wpdb;
216
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
216
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
217 217
 
218
-		if ( empty( $value ) ) {
218
+		if (empty($value)) {
219 219
 			return false;
220 220
 		}
221 221
 
222
-		$maybe_json = json_decode( $value );
223
-		if ( ! is_null( $maybe_json ) ) {
224
-			$value = json_decode( $value, true );
222
+		$maybe_json = json_decode($value);
223
+		if ( ! is_null($maybe_json)) {
224
+			$value = json_decode($value, true);
225 225
 		}
226 226
 
227 227
 		return $value;
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return void
239 239
 	 */
240
-	private function store_data( $key, $value ) {
240
+	private function store_data($key, $value) {
241 241
 		global $wpdb;
242 242
 
243
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
243
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
244 244
 
245 245
 		$data = array(
246 246
 			'option_name'  => $key,
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 			'%s',
255 255
 		);
256 256
 
257
-		$wpdb->replace( $wpdb->options, $data, $formats );
257
+		$wpdb->replace($wpdb->options, $data, $formats);
258 258
 	}
259 259
 
260 260
 	/**
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return void
268 268
 	 */
269
-	private function delete_data( $key ) {
269
+	private function delete_data($key) {
270 270
 		global $wpdb;
271
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
271
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
272 272
 	}
273 273
 
274 274
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-test-transactions.php 1 patch
Spacing   +48 added lines, -48 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
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -62,20 +62,20 @@  discard block
 block discarded – undo
62 62
 	 * @return array|bool $data The data for the CSV file
63 63
 	 */
64 64
 	public function get_data() {
65
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids' );
65
+		$items = $this->get_stored_data('give_temp_delete_test_ids');
66 66
 
67
-		if ( ! is_array( $items ) ) {
67
+		if ( ! is_array($items)) {
68 68
 			return false;
69 69
 		}
70 70
 
71
-		$offset     = ( $this->step - 1 ) * $this->per_step;
72
-		$step_items = array_slice( $items, $offset, $this->per_step );
73
-		$meta_table = __give_v20_bc_table_details( 'payment' );
71
+		$offset     = ($this->step - 1) * $this->per_step;
72
+		$step_items = array_slice($items, $offset, $this->per_step);
73
+		$meta_table = __give_v20_bc_table_details('payment');
74 74
 
75
-		if ( $step_items ) {
76
-			foreach ( $step_items as $item ) {
75
+		if ($step_items) {
76
+			foreach ($step_items as $item) {
77 77
 				// Delete the main payment.
78
-				give_delete_donation( absint( $item['id'] ) );
78
+				give_delete_donation(absint($item['id']));
79 79
 			}
80 80
 			return true;
81 81
 		}
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function get_percentage_complete() {
93 93
 
94
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids', false );
95
-		$total = count( $items );
94
+		$items = $this->get_stored_data('give_temp_delete_test_ids', false);
95
+		$total = count($items);
96 96
 
97 97
 		$percentage = 100;
98 98
 
99
-		if ( $total > 0 ) {
100
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
99
+		if ($total > 0) {
100
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
101 101
 		}
102 102
 
103
-		if ( $percentage > 100 ) {
103
+		if ($percentage > 100) {
104 104
 			$percentage = 100;
105 105
 		}
106 106
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @param array $request The Form Data passed into the batch processing
116 116
 	 */
117
-	public function set_properties( $request ) {
117
+	public function set_properties($request) {
118 118
 	}
119 119
 
120 120
 	/**
@@ -125,29 +125,29 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function process_step() {
127 127
 
128
-		if ( ! $this->can_export() ) {
129
-			wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
128
+		if ( ! $this->can_export()) {
129
+			wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403));
130 130
 		}
131 131
 
132 132
 		$had_data = $this->get_data();
133 133
 
134
-		if ( $had_data ) {
134
+		if ($had_data) {
135 135
 			$this->done = false;
136 136
 
137 137
 			return true;
138 138
 		} else {
139
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
140
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
139
+			update_option('give_earnings_total', give_get_total_earnings(true));
140
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
141 141
 
142
-			$this->delete_data( 'give_temp_delete_test_ids' );
142
+			$this->delete_data('give_temp_delete_test_ids');
143 143
 
144 144
 			// Reset the sequential order numbers
145
-			if ( give_get_option( 'enable_sequential' ) ) {
146
-				delete_option( 'give_last_payment_number' );
145
+			if (give_get_option('enable_sequential')) {
146
+				delete_option('give_last_payment_number');
147 147
 			}
148 148
 
149 149
 			$this->done    = true;
150
-			$this->message = __( 'Test transactions successfully deleted.', 'give' );
150
+			$this->message = __('Test transactions successfully deleted.', 'give');
151 151
 
152 152
 			return false;
153 153
 		}
@@ -180,27 +180,27 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	public function pre_fetch() {
182 182
 
183
-		if ( $this->step == 1 ) {
184
-			$this->delete_data( 'give_temp_delete_test_ids' );
183
+		if ($this->step == 1) {
184
+			$this->delete_data('give_temp_delete_test_ids');
185 185
 		}
186 186
 
187
-		$items = get_option( 'give_temp_delete_test_ids', false );
187
+		$items = get_option('give_temp_delete_test_ids', false);
188 188
 
189
-		if ( false === $items ) {
189
+		if (false === $items) {
190 190
 			$items = array();
191 191
 
192
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
192
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
193 193
 				'post_status' => 'any',
194
-				'number'      => - 1,
194
+				'number'      => -1,
195 195
 				'meta_key'    => '_give_payment_mode',
196 196
 				'meta_value'  => 'test'
197
-			) );
197
+			));
198 198
 
199
-			$posts    = new Give_Payments_Query( $args );
199
+			$posts    = new Give_Payments_Query($args);
200 200
 			$payments = $posts->get_payments();
201 201
 
202 202
 			/* @var Give_Payment $payment */
203
-			foreach ( $payments as $payment ) {
203
+			foreach ($payments as $payment) {
204 204
 				$items[] = array(
205 205
 					'id'   => (int) $payment->ID,
206 206
 					'type' => 'give_payment',
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
 			
210 210
 			// Allow filtering of items to remove with an unassociative array for each item.
211 211
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method.
212
-			$items = apply_filters( 'give_delete_test_items', $items );
212
+			$items = apply_filters('give_delete_test_items', $items);
213 213
 
214
-			$this->store_data( 'give_temp_delete_test_ids', $items );
214
+			$this->store_data('give_temp_delete_test_ids', $items);
215 215
 		}
216 216
 
217 217
 	}
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 * @return mixed       Returns the data from the database
227 227
 	 */
228
-	private function get_stored_data( $key ) {
228
+	private function get_stored_data($key) {
229 229
 		global $wpdb;
230
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
230
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
231 231
 
232
-		if ( empty( $value ) ) {
232
+		if (empty($value)) {
233 233
 			return false;
234 234
 		}
235 235
 
236
-		$maybe_json = json_decode( $value );
237
-		if ( ! is_null( $maybe_json ) ) {
238
-			$value = json_decode( $value, true );
236
+		$maybe_json = json_decode($value);
237
+		if ( ! is_null($maybe_json)) {
238
+			$value = json_decode($value, true);
239 239
 		}
240 240
 
241 241
 		return $value;
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return void
253 253
 	 */
254
-	private function store_data( $key, $value ) {
254
+	private function store_data($key, $value) {
255 255
 		global $wpdb;
256 256
 
257
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
257
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
258 258
 
259 259
 		$data = array(
260 260
 			'option_name'  => $key,
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 			'%s',
269 269
 		);
270 270
 
271
-		$wpdb->replace( $wpdb->options, $data, $formats );
271
+		$wpdb->replace($wpdb->options, $data, $formats);
272 272
 	}
273 273
 
274 274
 	/**
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @return void
282 282
 	 */
283
-	private function delete_data( $key ) {
283
+	private function delete_data($key) {
284 284
 		global $wpdb;
285
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
285
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
286 286
 	}
287 287
 
288 288
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-all-stats.php 1 patch
Spacing   +97 added lines, -99 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
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	/**
74 74
 	 * Constructor.
75 75
 	 */
76
-	public function __construct( $_step = 1 ) {
77
-		parent::__construct( $_step );
76
+	public function __construct($_step = 1) {
77
+		parent::__construct($_step);
78 78
 
79 79
 		$this->is_writable = true;
80 80
 	}
@@ -89,108 +89,106 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function get_data() {
91 91
 
92
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
93
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
94
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
95
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
92
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
93
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
94
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
95
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
96 96
 
97
-		if ( false === $totals ) {
97
+		if (false === $totals) {
98 98
 			$totals = array();
99 99
 		}
100 100
 
101
-		if ( false === $payment_items ) {
101
+		if (false === $payment_items) {
102 102
 			$payment_items = array();
103 103
 		}
104 104
 
105
-		if ( false === $processed_payments ) {
105
+		if (false === $processed_payments) {
106 106
 			$processed_payments = array();
107 107
 		}
108 108
 
109
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
109
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
110 110
 
111
-		$payments = $this->get_stored_data( 'give_temp_all_payments_data' );
111
+		$payments = $this->get_stored_data('give_temp_all_payments_data');
112 112
 
113
-		if ( empty( $payments ) ) {
114
-			$args = apply_filters( 'give_recount_form_stats_args', array(
113
+		if (empty($payments)) {
114
+			$args = apply_filters('give_recount_form_stats_args', array(
115 115
 				'give_forms' => $all_forms,
116 116
 				'number'     => $this->per_step,
117 117
 				'status'     => $accepted_statuses,
118 118
 				'paged'      => $this->step,
119 119
 				'output'     => 'give_payments',
120
-			) );
120
+			));
121 121
 
122
-			$payments_query = new Give_Payments_Query( $args );
122
+			$payments_query = new Give_Payments_Query($args);
123 123
 			$payments       = $payments_query->get_payments();
124 124
 		}
125 125
 
126
-		if ( ! empty( $payments ) ) {
126
+		if ( ! empty($payments)) {
127 127
 
128 128
 			//Loop through payments
129
-			foreach ( $payments as $payment ) {
129
+			foreach ($payments as $payment) {
130 130
 
131
-				$payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) );
132
-				$payment = new Give_Payment( $payment_id );
131
+				$payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false));
132
+				$payment = new Give_Payment($payment_id);
133 133
 
134 134
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
135
-				if ( in_array( $payment->ID, $processed_payments ) ) {
135
+				if (in_array($payment->ID, $processed_payments)) {
136 136
 					continue;
137 137
 				}
138 138
 
139 139
 				// Verify accepted status.
140
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
140
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
141 141
 					$processed_payments[] = $payment->ID;
142 142
 					continue;
143 143
 				}
144 144
 
145
-				$payment_item = $payment_items[ $payment->ID ];
145
+				$payment_item = $payment_items[$payment->ID];
146 146
 
147
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
147
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
148 148
 
149 149
 				// Must have a form ID.
150
-				if ( empty( $form_id ) ) {
150
+				if (empty($form_id)) {
151 151
 					continue;
152 152
 				}
153 153
 
154 154
 				// Form ID must be within $all_forms array to be validated.
155
-				if ( ! in_array( $form_id, $all_forms ) ) {
155
+				if ( ! in_array($form_id, $all_forms)) {
156 156
 					continue;
157 157
 				}
158 158
 
159 159
 				// Set Sales count
160
-				$totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ?
161
-					++ $totals[ $form_id ]['sales'] :
162
-					1;
160
+				$totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ?
161
+					++$totals[$form_id]['sales'] : 1;
163 162
 
164 163
 				// Set Total Earnings
165
-				$totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ?
166
-					( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) :
167
-					$payment_item['price'];
164
+				$totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ?
165
+					($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price'];
168 166
 
169 167
 				$processed_payments[] = $payment->ID;
170 168
 			}
171 169
 
172 170
 			// Get the list of form ids which does not contain any payment record.
173
-			$remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) );
174
-			foreach ( $remaining_form_ids as $form_id ) {
171
+			$remaining_form_ids = array_diff($all_forms, array_keys($totals));
172
+			foreach ($remaining_form_ids as $form_id) {
175 173
 				//If array key doesn't exist, create it
176
-				if ( ! array_key_exists( $form_id, $totals ) ) {
177
-					$totals[ $form_id ] = array(
174
+				if ( ! array_key_exists($form_id, $totals)) {
175
+					$totals[$form_id] = array(
178 176
 						'sales'    => (int) 0,
179 177
 						'earnings' => (float) 0,
180 178
 					);
181 179
 				}
182 180
 			}
183 181
 
184
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
185
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
182
+			$this->store_data('give_temp_processed_payments', $processed_payments);
183
+			$this->store_data('give_temp_recount_all_stats', $totals);
186 184
 
187 185
 			return true;
188 186
 		}
189 187
 
190 188
 
191
-		foreach ( $totals as $key => $stats ) {
192
-			give_update_meta( $key, '_give_form_sales', $stats['sales'] );
193
-			give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) );
189
+		foreach ($totals as $key => $stats) {
190
+			give_update_meta($key, '_give_form_sales', $stats['sales']);
191
+			give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings']));
194 192
 		}
195 193
 
196 194
 		return false;
@@ -205,20 +203,20 @@  discard block
 block discarded – undo
205 203
 	 */
206 204
 	public function get_percentage_complete() {
207 205
 
208
-		$total = $this->get_stored_data( 'give_recount_all_total' );
206
+		$total = $this->get_stored_data('give_recount_all_total');
209 207
 
210
-		if ( false === $total ) {
208
+		if (false === $total) {
211 209
 			$this->pre_fetch();
212
-			$total = $this->get_stored_data( 'give_recount_all_total' );
210
+			$total = $this->get_stored_data('give_recount_all_total');
213 211
 		}
214 212
 
215 213
 		$percentage = 100;
216 214
 
217
-		if ( $total > 0 ) {
218
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
215
+		if ($total > 0) {
216
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
219 217
 		}
220 218
 
221
-		if ( $percentage > 100 ) {
219
+		if ($percentage > 100) {
222 220
 			$percentage = 100;
223 221
 		}
224 222
 
@@ -232,8 +230,8 @@  discard block
 block discarded – undo
232 230
 	 *
233 231
 	 * @param array $request The Form Data passed into the batch processing
234 232
 	 */
235
-	public function set_properties( $request ) {
236
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
233
+	public function set_properties($request) {
234
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
237 235
 	}
238 236
 
239 237
 	/**
@@ -244,25 +242,25 @@  discard block
 block discarded – undo
244 242
 	 */
245 243
 	public function process_step() {
246 244
 
247
-		if ( ! $this->can_export() ) {
248
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
245
+		if ( ! $this->can_export()) {
246
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
249 247
 		}
250 248
 
251 249
 		$had_data = $this->get_data();
252 250
 
253
-		if ( $had_data ) {
251
+		if ($had_data) {
254 252
 			$this->done = false;
255 253
 
256 254
 			return true;
257 255
 		} else {
258
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
259
-			$this->delete_data( 'give_recount_all_total' );
260
-			$this->delete_data( 'give_temp_recount_all_stats' );
261
-			$this->delete_data( 'give_temp_payment_items' );
262
-			$this->delete_data( 'give_temp_form_ids' );
263
-			$this->delete_data( 'give_temp_processed_payments' );
256
+			$this->delete_data('give_recount_total_'.$this->form_id);
257
+			$this->delete_data('give_recount_all_total');
258
+			$this->delete_data('give_temp_recount_all_stats');
259
+			$this->delete_data('give_temp_payment_items');
260
+			$this->delete_data('give_temp_form_ids');
261
+			$this->delete_data('give_temp_processed_payments');
264 262
 			$this->done    = true;
265
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
263
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
266 264
 
267 265
 			return false;
268 266
 		}
@@ -298,70 +296,70 @@  discard block
 block discarded – undo
298 296
 	 */
299 297
 	public function pre_fetch() {
300 298
 
301
-		if ( 1 == $this->step ) {
302
-			$this->delete_data( 'give_temp_recount_all_total' );
303
-			$this->delete_data( 'give_temp_recount_all_stats' );
304
-			$this->delete_data( 'give_temp_payment_items' );
305
-			$this->delete_data( 'give_temp_processed_payments' );
306
-			$this->delete_data( 'give_temp_all_payments_data' );
299
+		if (1 == $this->step) {
300
+			$this->delete_data('give_temp_recount_all_total');
301
+			$this->delete_data('give_temp_recount_all_stats');
302
+			$this->delete_data('give_temp_payment_items');
303
+			$this->delete_data('give_temp_processed_payments');
304
+			$this->delete_data('give_temp_all_payments_data');
307 305
 		}
308 306
 
309
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
310
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
307
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
308
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
311 309
 
312
-		if ( false === $total ) {
310
+		if (false === $total) {
313 311
 
314
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
312
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
315 313
 
316
-			if ( false === $payment_items ) {
314
+			if (false === $payment_items) {
317 315
 				$payment_items = array();
318
-				$this->store_data( 'give_temp_payment_items', $payment_items );
316
+				$this->store_data('give_temp_payment_items', $payment_items);
319 317
 			}
320 318
 
321 319
 			$args = array(
322 320
 				'post_status'    => 'publish',
323 321
 				'post_type'      => 'give_forms',
324
-				'posts_per_page' => - 1,
322
+				'posts_per_page' => -1,
325 323
 				'fields'         => 'ids',
326 324
 			);
327 325
 
328
-			$all_forms = get_posts( $args );
326
+			$all_forms = get_posts($args);
329 327
 
330
-			$this->store_data( 'give_temp_form_ids', $all_forms );
328
+			$this->store_data('give_temp_form_ids', $all_forms);
331 329
 
332
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
330
+			$args = apply_filters('give_recount_form_stats_total_args', array(
333 331
 				'give_forms' => $all_forms,
334 332
 				'number'     => $this->per_step,
335 333
 				'status'     => $accepted_statuses,
336 334
 				'page'       => $this->step,
337 335
 				'output'     => 'payments',
338
-			) );
336
+			));
339 337
 
340
-			$payments_query = new Give_Payments_Query( $args );
338
+			$payments_query = new Give_Payments_Query($args);
341 339
 			$payments       = $payments_query->get_payments();
342 340
 
343
-			$total = wp_count_posts( 'give_payment' )->publish;
341
+			$total = wp_count_posts('give_payment')->publish;
344 342
 
345
-			$this->store_data( 'give_temp_all_payments_data', $payments );
343
+			$this->store_data('give_temp_all_payments_data', $payments);
346 344
 
347
-			if ( $payments ) {
345
+			if ($payments) {
348 346
 
349
-				foreach ( $payments as $payment ) {
347
+				foreach ($payments as $payment) {
350 348
 
351 349
 					$form_id = $payment->form_id;
352 350
 
353 351
 					//If for some reason somehow the form_ID isn't set check payment meta
354
-					if ( empty( $payment->form_id ) ) {
352
+					if (empty($payment->form_id)) {
355 353
 						$payment_meta = $payment->get_meta();
356
-						$form_id      = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
354
+						$form_id      = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
357 355
 					}
358 356
 
359
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
357
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
360 358
 						continue;
361 359
 					}
362 360
 
363
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
364
-						$payment_items[ $payment->ID ] = array(
361
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
362
+						$payment_items[$payment->ID] = array(
365 363
 							'id'         => $form_id,
366 364
 							'payment_id' => $payment->ID,
367 365
 							'price'      => $payment->total,
@@ -369,8 +367,8 @@  discard block
 block discarded – undo
369 367
 					}
370 368
 				}
371 369
 			}
372
-			$this->store_data( 'give_temp_payment_items', $payment_items );
373
-			$this->store_data( 'give_recount_all_total', $total );
370
+			$this->store_data('give_temp_payment_items', $payment_items);
371
+			$this->store_data('give_recount_all_total', $total);
374 372
 		}
375 373
 
376 374
 	}
@@ -384,17 +382,17 @@  discard block
 block discarded – undo
384 382
 	 *
385 383
 	 * @return mixed       Returns the data from the database
386 384
 	 */
387
-	private function get_stored_data( $key ) {
385
+	private function get_stored_data($key) {
388 386
 		global $wpdb;
389
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
390
-		if ( empty( $value ) ) {
387
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
388
+		if (empty($value)) {
391 389
 			return false;
392 390
 		}
393 391
 
394
-		$maybe_json = json_decode( $value );
392
+		$maybe_json = json_decode($value);
395 393
 
396
-		if ( ! is_null( $maybe_json ) ) {
397
-			$value = json_decode( $value, true );
394
+		if ( ! is_null($maybe_json)) {
395
+			$value = json_decode($value, true);
398 396
 		}
399 397
 
400 398
 		return $value;
@@ -410,10 +408,10 @@  discard block
 block discarded – undo
410 408
 	 *
411 409
 	 * @return void
412 410
 	 */
413
-	private function store_data( $key, $value ) {
411
+	private function store_data($key, $value) {
414 412
 		global $wpdb;
415 413
 
416
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
414
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
417 415
 
418 416
 		$data = array(
419 417
 			'option_name'  => $key,
@@ -427,7 +425,7 @@  discard block
 block discarded – undo
427 425
 			'%s',
428 426
 		);
429 427
 
430
-		$wpdb->replace( $wpdb->options, $data, $formats );
428
+		$wpdb->replace($wpdb->options, $data, $formats);
431 429
 	}
432 430
 
433 431
 	/**
@@ -439,9 +437,9 @@  discard block
 block discarded – undo
439 437
 	 *
440 438
 	 * @return void
441 439
 	 */
442
-	private function delete_data( $key ) {
440
+	private function delete_data($key) {
443 441
 		global $wpdb;
444
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
442
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
445 443
 	}
446 444
 
447 445
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-single-donor-stats.php 1 patch
Spacing   +73 added lines, -73 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
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -62,40 +62,40 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function get_data() {
64 64
 
65
-		$donor    = new Give_Donor( $this->customer_id );
66
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id );
65
+		$donor    = new Give_Donor($this->customer_id);
66
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id);
67 67
 
68
-		$offset     = ( $this->step - 1 ) * $this->per_step;
69
-		$step_items = array_slice( $payments, $offset, $this->per_step );
68
+		$offset     = ($this->step - 1) * $this->per_step;
69
+		$step_items = array_slice($payments, $offset, $this->per_step);
70 70
 
71
-		if ( count( $step_items ) > 0 ) {
72
-			$pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
71
+		if (count($step_items) > 0) {
72
+			$pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
73 73
 			$step_total    = 0;
74 74
 
75
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id );
75
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id);
76 76
 
77
-			foreach ( $step_items as $payment ) {
78
-				$payment = get_post( $payment->ID );
77
+			foreach ($step_items as $payment) {
78
+				$payment = get_post($payment->ID);
79 79
 
80
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
80
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
81 81
 
82
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id );
82
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$donor->id);
83 83
 					$missing_payments[] = $payment->ID;
84
-					$this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments );
84
+					$this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments);
85 85
 
86 86
 					continue;
87 87
 				}
88 88
 
89 89
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
90
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
90
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
91 91
 
92
-				if ( true === $should_process_payment ) {
92
+				if (true === $should_process_payment) {
93 93
 
94 94
 					$found_payment_ids[] = $payment->ID;
95 95
 
96
-					if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
97
-						$payment_amount = (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
98
-						$step_total     += $payment_amount;
96
+					if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
97
+						$payment_amount = (float) give_donation_amount($payment->ID, array('type' => 'stats'));
98
+						$step_total += $payment_amount;
99 99
 					}
100 100
 
101 101
 				}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 			}
104 104
 
105 105
 			$updated_total = $pending_total + $step_total;
106
-			$this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total );
107
-			$this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids );
106
+			$this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total);
107
+			$this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids);
108 108
 
109 109
 			return true;
110 110
 		}
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function get_percentage_complete() {
123 123
 
124
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id );
125
-		$total    = count( $payments );
124
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id);
125
+		$total    = count($payments);
126 126
 
127 127
 		$percentage = 100;
128 128
 
129
-		if ( $total > 0 ) {
130
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
129
+		if ($total > 0) {
130
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
131 131
 		}
132 132
 
133
-		if ( $percentage > 100 ) {
133
+		if ($percentage > 100) {
134 134
 			$percentage = 100;
135 135
 		}
136 136
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @param array $request The Form Data passed into the batch processing
146 146
 	 */
147
-	public function set_properties( $request ) {
148
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
147
+	public function set_properties($request) {
148
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
149 149
 	}
150 150
 
151 151
 	/**
@@ -156,53 +156,53 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function process_step() {
158 158
 
159
-		if ( ! $this->can_export() ) {
160
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
159
+		if ( ! $this->can_export()) {
160
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
161 161
 		}
162 162
 
163 163
 		$had_data = $this->get_data();
164 164
 
165
-		if ( $had_data ) {
165
+		if ($had_data) {
166 166
 			$this->done = false;
167 167
 
168 168
 			return true;
169 169
 		} else {
170
-			$donor       = new Give_Donor( $this->customer_id );
171
-			$payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() );
172
-			$this->delete_data( 'give_stats_found_payments_' . $donor->id );
170
+			$donor       = new Give_Donor($this->customer_id);
171
+			$payment_ids = get_option('give_stats_found_payments_'.$donor->id, array());
172
+			$this->delete_data('give_stats_found_payments_'.$donor->id);
173 173
 
174
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) );
174
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array()));
175 175
 
176 176
 			// Find non-existing payments (deleted) and total up the donation count
177 177
 			$purchase_count = 0;
178
-			foreach ( $payment_ids as $key => $payment_id ) {
179
-				if ( in_array( $payment_id, $removed_payments ) ) {
180
-					unset( $payment_ids[ $key ] );
178
+			foreach ($payment_ids as $key => $payment_id) {
179
+				if (in_array($payment_id, $removed_payments)) {
180
+					unset($payment_ids[$key]);
181 181
 					continue;
182 182
 				}
183 183
 
184
-				$payment = get_post( $payment_id );
185
-				if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
186
-					$purchase_count ++;
184
+				$payment = get_post($payment_id);
185
+				if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
186
+					$purchase_count++;
187 187
 				}
188 188
 			}
189 189
 
190
-			$this->delete_data( 'give_stats_missing_payments' . $donor->id );
190
+			$this->delete_data('give_stats_missing_payments'.$donor->id);
191 191
 
192
-			$pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
193
-			$this->delete_data( 'give_stats_donor_pending_total' . $donor->id );
194
-			$this->delete_data( 'give_recount_donor_stats_' . $donor->id );
195
-			$this->delete_data( 'give_recount_donor_payments_' . $this->customer_id );
192
+			$pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
193
+			$this->delete_data('give_stats_donor_pending_total'.$donor->id);
194
+			$this->delete_data('give_recount_donor_stats_'.$donor->id);
195
+			$this->delete_data('give_recount_donor_payments_'.$this->customer_id);
196 196
 
197
-			$payment_ids = implode( ',', $payment_ids );
198
-			$donor->update( array(
197
+			$payment_ids = implode(',', $payment_ids);
198
+			$donor->update(array(
199 199
 				'payment_ids'    => $payment_ids,
200 200
 				'purchase_count' => $purchase_count,
201 201
 				'purchase_value' => $pending_total,
202
-			) );
202
+			));
203 203
 
204 204
 			$this->done    = true;
205
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
205
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
206 206
 
207 207
 			return false;
208 208
 		}
@@ -235,26 +235,26 @@  discard block
 block discarded – undo
235 235
 	 * @return void
236 236
 	 */
237 237
 	public function pre_fetch() {
238
-		if ( $this->step === 1 ) {
239
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
238
+		if ($this->step === 1) {
239
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
240 240
 
241 241
 			// Before we start, let's zero out the customer's data
242
-			$donor = new Give_Donor( $this->customer_id );
243
-			$donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) );
242
+			$donor = new Give_Donor($this->customer_id);
243
+			$donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0));
244 244
 
245
-			$attached_payment_ids = explode( ',', $donor->payment_ids );
245
+			$attached_payment_ids = explode(',', $donor->payment_ids);
246 246
 
247 247
 			$attached_args = array(
248 248
 				'post__in' => $attached_payment_ids,
249
-				'number'   => - 1,
249
+				'number'   => -1,
250 250
 				'status'   => $allowed_payment_status,
251 251
 			);
252 252
 
253
-			$attached_payments = give_get_payments( $attached_args );
253
+			$attached_payments = give_get_payments($attached_args);
254 254
 
255 255
 			$unattached_args = array(
256 256
 				'post__not_in' => $attached_payment_ids,
257
-				'number'       => - 1,
257
+				'number'       => -1,
258 258
 				'status'       => $allowed_payment_status,
259 259
 				'meta_query'   => array(
260 260
 					array(
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 				),
265 265
 			);
266 266
 
267
-			$unattached_payments = give_get_payments( $unattached_args );
267
+			$unattached_payments = give_get_payments($unattached_args);
268 268
 
269
-			$payments = array_merge( $attached_payments, $unattached_payments );
269
+			$payments = array_merge($attached_payments, $unattached_payments);
270 270
 
271
-			$this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments );
271
+			$this->store_data('give_recount_donor_payments_'.$donor->id, $payments);
272 272
 		}
273 273
 	}
274 274
 
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return mixed       Returns the data from the database
283 283
 	 */
284
-	private function get_stored_data( $key ) {
284
+	private function get_stored_data($key) {
285 285
 		global $wpdb;
286
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
286
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
287 287
 
288
-		if ( empty( $value ) ) {
288
+		if (empty($value)) {
289 289
 			return false;
290 290
 		}
291 291
 
292
-		$maybe_json = json_decode( $value );
293
-		if ( ! is_null( $maybe_json ) ) {
294
-			$value = json_decode( $value, true );
292
+		$maybe_json = json_decode($value);
293
+		if ( ! is_null($maybe_json)) {
294
+			$value = json_decode($value, true);
295 295
 		}
296 296
 
297 297
 		return $value;
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 *
308 308
 	 * @return void
309 309
 	 */
310
-	private function store_data( $key, $value ) {
310
+	private function store_data($key, $value) {
311 311
 		global $wpdb;
312 312
 
313
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
313
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
314 314
 
315 315
 		$data = array(
316 316
 			'option_name'  => $key,
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			'%s',
325 325
 		);
326 326
 
327
-		$wpdb->replace( $wpdb->options, $data, $formats );
327
+		$wpdb->replace($wpdb->options, $data, $formats);
328 328
 	}
329 329
 
330 330
 	/**
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @return void
338 338
 	 */
339
-	private function delete_data( $key ) {
339
+	private function delete_data($key) {
340 340
 		global $wpdb;
341
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
341
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
342 342
 	}
343 343
 
344 344
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-reset-stats.php 1 patch
Spacing   +66 added lines, -66 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
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * Constructor.
51 51
 	 */
52
-	public function __construct( $_step = 1 ) {
53
-		parent::__construct( $_step );
52
+	public function __construct($_step = 1) {
53
+		parent::__construct($_step);
54 54
 
55 55
 		$this->is_writable = true;
56 56
 	}
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
 	public function get_data() {
68 68
 		global $wpdb;
69 69
 
70
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
70
+		$items = $this->get_stored_data('give_temp_reset_ids');
71 71
 
72
-		if ( ! is_array( $items ) ) {
72
+		if ( ! is_array($items)) {
73 73
 			return false;
74 74
 		}
75 75
 
76
-		$offset     = ( $this->step - 1 ) * $this->per_step;
77
-		$step_items = array_slice( $items, $offset, $this->per_step );
76
+		$offset     = ($this->step - 1) * $this->per_step;
77
+		$step_items = array_slice($items, $offset, $this->per_step);
78 78
 
79
-		if ( $step_items ) {
79
+		if ($step_items) {
80 80
 
81 81
 			$step_ids = array(
82 82
 				'customers' => array(),
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 				'other'     => array(),
85 85
 			);
86 86
 
87
-			foreach ( $step_items as $item ) {
87
+			foreach ($step_items as $item) {
88 88
 
89
-				switch ( $item['type'] ) {
89
+				switch ($item['type']) {
90 90
 					case 'customer':
91 91
 						$step_ids['customers'][] = $item['id'];
92 92
 						break;
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
 						$step_ids['give_forms'][] = $item['id'];
95 95
 						break;
96 96
 					default:
97
-						$item_type                = apply_filters( 'give_reset_item_type', 'other', $item );
98
-						$step_ids[ $item_type ][] = $item['id'];
97
+						$item_type                = apply_filters('give_reset_item_type', 'other', $item);
98
+						$step_ids[$item_type][] = $item['id'];
99 99
 						break;
100 100
 				}
101 101
 			}
102 102
 
103 103
 			$sql = array();
104
-			$meta_table = __give_v20_bc_table_details('form' );
104
+			$meta_table = __give_v20_bc_table_details('form');
105 105
 
106
-			foreach ( $step_ids as $type => $ids ) {
106
+			foreach ($step_ids as $type => $ids) {
107 107
 
108
-				if ( empty( $ids ) ) {
108
+				if (empty($ids)) {
109 109
 					continue;
110 110
 				}
111 111
 
112
-				$ids = implode( ',', $ids );
112
+				$ids = implode(',', $ids);
113 113
 
114
-				switch ( $type ) {
114
+				switch ($type) {
115 115
 					case 'customers':
116 116
 						$sql[]           = "DELETE FROM $wpdb->donors WHERE id IN ($ids)";
117 117
 						$table_name      = $wpdb->donors;
@@ -131,16 +131,16 @@  discard block
 block discarded – undo
131 131
 						break;
132 132
 				}
133 133
 
134
-				if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) {
134
+				if ( ! in_array($type, array('customers', 'forms', 'other'))) {
135 135
 					// Allows other types of custom post types to filter on their own post_type
136 136
 					// and add items to the query list, for the IDs found in their post type.
137
-					$sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids );
137
+					$sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids);
138 138
 				}
139 139
 			}
140 140
 
141
-			if ( ! empty( $sql ) ) {
142
-				foreach ( $sql as $query ) {
143
-					$wpdb->query( $query );
141
+			if ( ! empty($sql)) {
142
+				foreach ($sql as $query) {
143
+					$wpdb->query($query);
144 144
 				}
145 145
 			}
146 146
 
@@ -160,16 +160,16 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_percentage_complete() {
162 162
 
163
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
164
-		$total = count( $items );
163
+		$items = $this->get_stored_data('give_temp_reset_ids');
164
+		$total = count($items);
165 165
 
166 166
 		$percentage = 100;
167 167
 
168
-		if ( $total > 0 ) {
169
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
168
+		if ($total > 0) {
169
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
170 170
 		}
171 171
 
172
-		if ( $percentage > 100 ) {
172
+		if ($percentage > 100) {
173 173
 			$percentage = 100;
174 174
 		}
175 175
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @param array $request The Form Data passed into the batch processing.
185 185
 	 */
186
-	public function set_properties( $request ) {
186
+	public function set_properties($request) {
187 187
 	}
188 188
 
189 189
 	/**
@@ -194,31 +194,31 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function process_step() {
196 196
 
197
-		if ( ! $this->can_export() ) {
198
-			wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array(
197
+		if ( ! $this->can_export()) {
198
+			wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array(
199 199
 				'response' => 403,
200
-			) );
200
+			));
201 201
 		}
202 202
 
203 203
 		$had_data = $this->get_data();
204 204
 
205
-		if ( $had_data ) {
205
+		if ($had_data) {
206 206
 			$this->done = false;
207 207
 
208 208
 			return true;
209 209
 		} else {
210
-			update_option( 'give_earnings_total', 0 );
211
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
210
+			update_option('give_earnings_total', 0);
211
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
212 212
 
213
-			$this->delete_data( 'give_temp_reset_ids' );
213
+			$this->delete_data('give_temp_reset_ids');
214 214
 
215 215
 			// Reset the sequential order numbers
216
-			if ( give_get_option( 'enable_sequential' ) ) {
217
-				delete_option( 'give_last_payment_number' );
216
+			if (give_get_option('enable_sequential')) {
217
+				delete_option('give_last_payment_number');
218 218
 			}
219 219
 
220 220
 			$this->done    = true;
221
-			$this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' );
221
+			$this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give');
222 222
 
223 223
 			return false;
224 224
 		}
@@ -251,26 +251,26 @@  discard block
 block discarded – undo
251 251
 	 */
252 252
 	public function pre_fetch() {
253 253
 
254
-		if ( $this->step == 1 ) {
255
-			$this->delete_data( 'give_temp_reset_ids' );
254
+		if ($this->step == 1) {
255
+			$this->delete_data('give_temp_reset_ids');
256 256
 		}
257 257
 
258
-		$items = get_option( 'give_temp_reset_ids', false );
258
+		$items = get_option('give_temp_reset_ids', false);
259 259
 
260
-		if ( false === $items ) {
260
+		if (false === $items) {
261 261
 			$items = array();
262 262
 
263
-			$give_types_for_reset = array( 'give_forms', 'give_payment' );
264
-			$give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset );
263
+			$give_types_for_reset = array('give_forms', 'give_payment');
264
+			$give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset);
265 265
 
266
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
266
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
267 267
 				'post_type'      => $give_types_for_reset,
268 268
 				'post_status'    => 'any',
269
-				'posts_per_page' => - 1,
270
-			) );
269
+				'posts_per_page' => -1,
270
+			));
271 271
 
272
-			$posts = get_posts( $args );
273
-			foreach ( $posts as $post ) {
272
+			$posts = get_posts($args);
273
+			foreach ($posts as $post) {
274 274
 				$items[] = array(
275 275
 					'id'   => (int) $post->ID,
276 276
 					'type' => $post->post_type,
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 			}
279 279
 
280 280
 			$donor_args = array(
281
-				'number' => - 1,
281
+				'number' => -1,
282 282
 			);
283
-			$donors     = Give()->donors->get_donors( $donor_args );
284
-			foreach ( $donors as $donor ) {
283
+			$donors     = Give()->donors->get_donors($donor_args);
284
+			foreach ($donors as $donor) {
285 285
 				$items[] = array(
286 286
 					'id'   => (int) $donor->id,
287 287
 					'type' => 'customer',
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
 
291 291
 			// Allow filtering of items to remove with an unassociative array for each item
292 292
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
293
-			$items = apply_filters( 'give_reset_items', $items );
293
+			$items = apply_filters('give_reset_items', $items);
294 294
 
295
-			$this->store_data( 'give_temp_reset_ids', $items );
295
+			$this->store_data('give_temp_reset_ids', $items);
296 296
 		}// End if().
297 297
 
298 298
 	}
@@ -306,17 +306,17 @@  discard block
 block discarded – undo
306 306
 	 *
307 307
 	 * @return mixed       Returns the data from the database.
308 308
 	 */
309
-	private function get_stored_data( $key ) {
309
+	private function get_stored_data($key) {
310 310
 		global $wpdb;
311
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
311
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
312 312
 
313
-		if ( empty( $value ) ) {
313
+		if (empty($value)) {
314 314
 			return false;
315 315
 		}
316 316
 
317
-		$maybe_json = json_decode( $value );
318
-		if ( ! is_null( $maybe_json ) ) {
319
-			$value = json_decode( $value, true );
317
+		$maybe_json = json_decode($value);
318
+		if ( ! is_null($maybe_json)) {
319
+			$value = json_decode($value, true);
320 320
 		}
321 321
 
322 322
 		return $value;
@@ -332,10 +332,10 @@  discard block
 block discarded – undo
332 332
 	 *
333 333
 	 * @return void
334 334
 	 */
335
-	private function store_data( $key, $value ) {
335
+	private function store_data($key, $value) {
336 336
 		global $wpdb;
337 337
 
338
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
338
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
339 339
 
340 340
 		$data = array(
341 341
 			'option_name'  => $key,
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 			'%s',
350 350
 		);
351 351
 
352
-		$wpdb->replace( $wpdb->options, $data, $formats );
352
+		$wpdb->replace($wpdb->options, $data, $formats);
353 353
 	}
354 354
 
355 355
 	/**
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
 	 *
362 362
 	 * @return void
363 363
 	 */
364
-	private function delete_data( $key ) {
364
+	private function delete_data($key) {
365 365
 		global $wpdb;
366
-		$wpdb->delete( $wpdb->options, array(
366
+		$wpdb->delete($wpdb->options, array(
367 367
 			'option_name' => $key,
368
-		) );
368
+		));
369 369
 	}
370 370
 
371 371
 }
372 372
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/payments/payments-history.php 1 patch
Spacing   +23 added lines, -23 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,10 +24,10 @@  discard block
 block discarded – undo
24 24
  * @return      void
25 25
 */
26 26
 function give_payment_history_page() {
27
-	if ( isset( $_GET['view'] ) && 'view-payment-details' == $_GET['view'] ) {
28
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-payment-details.php';
27
+	if (isset($_GET['view']) && 'view-payment-details' == $_GET['view']) {
28
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-payment-details.php';
29 29
 	} else {
30
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php';
30
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php';
31 31
 		$payments_table = new Give_Payment_History_Table();
32 32
 		$payments_table->prepare_items();
33 33
 	?>
@@ -41,23 +41,23 @@  discard block
 block discarded – undo
41 41
 		 *
42 42
 		 * @since 1.7
43 43
 		 */
44
-		do_action( 'give_payments_page_top' );
44
+		do_action('give_payments_page_top');
45 45
 		?>
46 46
 		<hr class="wp-header-end">
47 47
 
48
-		<form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>">
48
+		<form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>">
49 49
 			<input type="hidden" name="post_type" value="give_forms" />
50 50
 			<input type="hidden" name="page" value="give-payment-history" />
51 51
 			<?php $payments_table->views() ?>
52 52
 			<?php $payments_table->advanced_filters(); ?>
53 53
 		</form>
54 54
 
55
-		<form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>">
55
+		<form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>">
56 56
 			<input type="hidden" name="post_type" value="give_forms" />
57 57
 			<input type="hidden" name="page" value="give-payment-history" />
58 58
 			<?php
59
-			if ( ! empty( $_GET['donor'] ) ) {
60
-				echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $_GET['donor'] ) );
59
+			if ( ! empty($_GET['donor'])) {
60
+				echo sprintf('<input type="hidden" name="donor" value="%s"/>', absint($_GET['donor']));
61 61
 			}
62 62
 
63 63
 			$payments_table->display();
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		 *
71 71
 		 * @since 1.7
72 72
 		 */
73
-		do_action( 'give_payments_page_bottom' );
73
+		do_action('give_payments_page_bottom');
74 74
 		?>
75 75
 
76 76
 	</div>
@@ -87,29 +87,29 @@  discard block
 block discarded – undo
87 87
  * @param $title
88 88
  * @return string
89 89
  */
90
-function give_view_order_details_title( $admin_title, $title ) {
90
+function give_view_order_details_title($admin_title, $title) {
91 91
 
92
-	if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) {
92
+	if ('give_forms_page_give-payment-history' != get_current_screen()->base) {
93 93
 		return $admin_title;
94 94
 	}
95 95
 
96
-	if( ! isset( $_GET['give-action'] ) ) {
96
+	if ( ! isset($_GET['give-action'])) {
97 97
 		return $admin_title;
98 98
 	}
99 99
 
100
-	switch( $_GET['give-action'] ) :
100
+	switch ($_GET['give-action']) :
101 101
 
102 102
 		case 'view-payment-details' :
103 103
 			$title = sprintf(
104 104
 				/* translators: %s: admin title */
105
-				esc_html__( 'View Donation Details - %s', 'give' ),
105
+				esc_html__('View Donation Details - %s', 'give'),
106 106
 				$admin_title
107 107
 			);
108 108
 			break;
109 109
 		case 'edit-payment' :
110 110
 			$title = sprintf(
111 111
 				/* translators: %s: admin title */
112
-				esc_html__( 'Edit Donation - %s', 'give' ),
112
+				esc_html__('Edit Donation - %s', 'give'),
113 113
 				$admin_title
114 114
 			);
115 115
 			break;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
 	return $title;
122 122
 }
123
-add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 );
123
+add_filter('admin_title', 'give_view_order_details_title', 10, 2);
124 124
 
125 125
 /**
126 126
  * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen.
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
  * @param $context
133 133
  * @return string
134 134
  */
135
-function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) {
135
+function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) {
136 136
 
137
-	$post = get_post( $post_id );
137
+	$post = get_post($post_id);
138 138
 
139
-	if( ! $post ) {
139
+	if ( ! $post) {
140 140
 		return $url;
141 141
 	}
142 142
 
143
-	if( 'give_payment' != $post->post_type ) {
143
+	if ('give_payment' != $post->post_type) {
144 144
 		return $url;
145 145
 	}
146 146
 
147
-	$url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $post_id );
147
+	$url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$post_id);
148 148
 
149 149
 	return $url;
150 150
 }
151
-add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 );
151
+add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3);
Please login to merge, or discard this patch.
includes/template-functions.php 1 patch
Spacing   +89 added lines, -89 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,24 +44,24 @@  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 52
 	$template_names = "{$template_name}.php";
53 53
 
54
-	$located = give_get_locate_template( $template_names, $template_path, $default_path );
54
+	$located = give_get_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()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
58
+		Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true);
59 59
 
60 60
 		return;
61 61
 	}
62 62
 
63 63
 	// Allow 3rd party plugin filter template file from their plugin.
64
-	$located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
64
+	$located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path);
65 65
 
66 66
 	/**
67 67
 	 * Fires in give template, before the file is included.
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 * @param string $located       Template file filter by 3rd party plugin.
76 76
 	 * @param array  $args          Passed arguments.
77 77
 	 */
78
-	do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
78
+	do_action('give_before_template_part', $template_name, $template_path, $located, $args);
79 79
 
80
-	include( $located );
80
+	include($located);
81 81
 
82 82
 	/**
83 83
 	 * Fires in give template, after the file is included.
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param string $located       Template file filter by 3rd party plugin.
92 92
 	 * @param array  $args          Passed arguments.
93 93
 	 */
94
-	do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
94
+	do_action('give_after_template_part', $template_name, $template_path, $located, $args);
95 95
 }
96 96
 
97 97
 /**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
  *
108 108
  * @return string
109 109
  */
110
-function give_get_template_part( $slug, $name = null, $load = true ) {
110
+function give_get_template_part($slug, $name = null, $load = true) {
111 111
 
112 112
 	/**
113 113
 	 * Fires in give template part, before the template part is retrieved.
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 	 * @param string $slug Template part file slug {slug}.php.
120 120
 	 * @param string $name Template part file name {slug}-{name}.php.
121 121
 	 */
122
-	do_action( "get_template_part_{$slug}", $slug, $name );
122
+	do_action("get_template_part_{$slug}", $slug, $name);
123 123
 
124 124
 	// Setup possible parts
125 125
 	$templates = array();
126
-	if ( isset( $name ) ) {
127
-		$templates[] = $slug . '-' . $name . '.php';
126
+	if (isset($name)) {
127
+		$templates[] = $slug.'-'.$name.'.php';
128 128
 	}
129
-	$templates[] = $slug . '.php';
129
+	$templates[] = $slug.'.php';
130 130
 
131 131
 	// Allow template parts to be filtered
132
-	$templates = apply_filters( 'give_get_template_part', $templates, $slug, $name );
132
+	$templates = apply_filters('give_get_template_part', $templates, $slug, $name);
133 133
 
134 134
 	// Return the part that is found
135
-	return give_locate_template( $templates, $load, false );
135
+	return give_locate_template($templates, $load, false);
136 136
 }
137 137
 
138 138
 /**
@@ -153,37 +153,37 @@  discard block
 block discarded – undo
153 153
  *
154 154
  * @return string The template filename if one is located.
155 155
  */
156
-function give_locate_template( $template_names, $load = false, $require_once = true ) {
156
+function give_locate_template($template_names, $load = false, $require_once = true) {
157 157
 	// No file found yet
158 158
 	$located = false;
159 159
 
160 160
 	// Try to find a template file
161
-	foreach ( (array) $template_names as $template_name ) {
161
+	foreach ((array) $template_names as $template_name) {
162 162
 
163 163
 		// Continue if template is empty
164
-		if ( empty( $template_name ) ) {
164
+		if (empty($template_name)) {
165 165
 			continue;
166 166
 		}
167 167
 
168 168
 		// Trim off any slashes from the template name
169
-		$template_name = ltrim( $template_name, '/' );
169
+		$template_name = ltrim($template_name, '/');
170 170
 
171 171
 		// try locating this template file by looping through the template paths
172
-		foreach ( give_get_theme_template_paths() as $template_path ) {
172
+		foreach (give_get_theme_template_paths() as $template_path) {
173 173
 
174
-			if ( file_exists( $template_path . $template_name ) ) {
175
-				$located = $template_path . $template_name;
174
+			if (file_exists($template_path.$template_name)) {
175
+				$located = $template_path.$template_name;
176 176
 				break;
177 177
 			}
178 178
 		}
179 179
 
180
-		if ( $located ) {
180
+		if ($located) {
181 181
 			break;
182 182
 		}
183 183
 	}
184 184
 
185
-	if ( ( true == $load ) && ! empty( $located ) ) {
186
-		load_template( $located, $require_once );
185
+	if ((true == $load) && ! empty($located)) {
186
+		load_template($located, $require_once);
187 187
 	}
188 188
 
189 189
 	return $located;
@@ -207,26 +207,26 @@  discard block
 block discarded – undo
207 207
  *
208 208
  * @return string
209 209
  */
210
-function give_get_locate_template( $template_name, $template_path = '', $default_path = '' ) {
211
-	if ( ! $template_path ) {
212
-		$template_path = give_get_theme_template_dir_name() . '/';
210
+function give_get_locate_template($template_name, $template_path = '', $default_path = '') {
211
+	if ( ! $template_path) {
212
+		$template_path = give_get_theme_template_dir_name().'/';
213 213
 	}
214 214
 
215
-	if ( ! $default_path ) {
216
-		$default_path = GIVE_PLUGIN_DIR . 'templates/';
215
+	if ( ! $default_path) {
216
+		$default_path = GIVE_PLUGIN_DIR.'templates/';
217 217
 	}
218 218
 
219 219
 	// Look within passed path within the theme - this is priority.
220 220
 	$template = locate_template(
221 221
 		array(
222
-			trailingslashit( $template_path ) . $template_name,
222
+			trailingslashit($template_path).$template_name,
223 223
 			$template_name,
224 224
 		)
225 225
 	);
226 226
 
227 227
 	// Get default template/
228
-	if ( ! $template ) {
229
-		$template = $default_path . $template_name;
228
+	if ( ! $template) {
229
+		$template = $default_path.$template_name;
230 230
 	}
231 231
 
232 232
 	/**
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 *
235 235
 	 * @since 2.0.3
236 236
 	 */
237
-	return apply_filters( 'give_get_locate_template', $template, $template_name, $template_path );
237
+	return apply_filters('give_get_locate_template', $template, $template_name, $template_path);
238 238
 }
239 239
 
240 240
 /**
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
 	$template_dir = give_get_theme_template_dir_name();
249 249
 
250 250
 	$file_paths = array(
251
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
252
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
251
+		1   => trailingslashit(get_stylesheet_directory()).$template_dir,
252
+		10  => trailingslashit(get_template_directory()).$template_dir,
253 253
 		100 => give_get_templates_dir(),
254 254
 	);
255 255
 
256
-	$file_paths = apply_filters( 'give_template_paths', $file_paths );
256
+	$file_paths = apply_filters('give_template_paths', $file_paths);
257 257
 
258 258
 	// sort the file paths based on priority
259
-	ksort( $file_paths, SORT_NUMERIC );
259
+	ksort($file_paths, SORT_NUMERIC);
260 260
 
261
-	return array_map( 'trailingslashit', $file_paths );
261
+	return array_map('trailingslashit', $file_paths);
262 262
 }
263 263
 
264 264
 /**
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
  * @return string
271 271
  */
272 272
 function give_get_theme_template_dir_name() {
273
-	return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) );
273
+	return trailingslashit(apply_filters('give_templates_dir', 'give'));
274 274
 }
275 275
 
276 276
 /**
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
  * @return void
281 281
  */
282 282
 function give_version_in_header() {
283
-	echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n";
283
+	echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n";
284 284
 }
285 285
 
286
-add_action( 'wp_head', 'give_version_in_header' );
286
+add_action('wp_head', 'give_version_in_header');
287 287
 
288 288
 /**
289 289
  * Determines if we're currently on the Donations History page.
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
  */
294 294
 function give_is_donation_history_page() {
295 295
 
296
-	$ret = is_page( give_get_option( 'history_page' ) );
296
+	$ret = is_page(give_get_option('history_page'));
297 297
 
298
-	return apply_filters( 'give_is_donation_history_page', $ret );
298
+	return apply_filters('give_is_donation_history_page', $ret);
299 299
 }
300 300
 
301 301
 /**
@@ -307,25 +307,25 @@  discard block
 block discarded – undo
307 307
  *
308 308
  * @return array Modified array of classes
309 309
  */
310
-function give_add_body_classes( $class ) {
310
+function give_add_body_classes($class) {
311 311
 	$classes = (array) $class;
312 312
 
313
-	if ( give_is_success_page() ) {
313
+	if (give_is_success_page()) {
314 314
 		$classes[] = 'give-success';
315 315
 		$classes[] = 'give-page';
316 316
 	}
317 317
 
318
-	if ( give_is_failed_transaction_page() ) {
318
+	if (give_is_failed_transaction_page()) {
319 319
 		$classes[] = 'give-failed-transaction';
320 320
 		$classes[] = 'give-page';
321 321
 	}
322 322
 
323
-	if ( give_is_donation_history_page() ) {
323
+	if (give_is_donation_history_page()) {
324 324
 		$classes[] = 'give-donation-history';
325 325
 		$classes[] = 'give-page';
326 326
 	}
327 327
 
328
-	if ( give_is_test_mode() ) {
328
+	if (give_is_test_mode()) {
329 329
 		$classes[] = 'give-test-mode';
330 330
 		$classes[] = 'give-page';
331 331
 	}
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	/* @var WP_Theme $current_theme */
335 335
 	$current_theme = wp_get_theme();
336 336
 
337
-	switch ( $current_theme->get_template() ) {
337
+	switch ($current_theme->get_template()) {
338 338
 
339 339
 		case 'Divi':
340 340
 			$classes[] = 'give-divi';
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 
352 352
 	}
353 353
 
354
-	return array_unique( $classes );
354
+	return array_unique($classes);
355 355
 }
356 356
 
357
-add_filter( 'body_class', 'give_add_body_classes' );
357
+add_filter('body_class', 'give_add_body_classes');
358 358
 
359 359
 
360 360
 /**
@@ -370,22 +370,22 @@  discard block
 block discarded – undo
370 370
  *
371 371
  * @return array
372 372
  */
373
-function give_add_post_class( $classes, $class = '', $post_id = '' ) {
374
-	if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) {
373
+function give_add_post_class($classes, $class = '', $post_id = '') {
374
+	if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) {
375 375
 		return $classes;
376 376
 	}
377 377
 
378 378
 	//@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc).
379 379
 
380
-	if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
381
-		unset( $classes[ $key ] );
380
+	if (false !== ($key = array_search('hentry', $classes))) {
381
+		unset($classes[$key]);
382 382
 	}
383 383
 
384 384
 	return $classes;
385 385
 }
386 386
 
387 387
 
388
-add_filter( 'post_class', 'give_add_post_class', 20, 3 );
388
+add_filter('post_class', 'give_add_post_class', 20, 3);
389 389
 
390 390
 /**
391 391
  * Get the placeholder image URL for forms etc
@@ -395,74 +395,74 @@  discard block
 block discarded – undo
395 395
  */
396 396
 function give_get_placeholder_img_src() {
397 397
 
398
-	$placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) );
398
+	$placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give'));
399 399
 
400
-	return apply_filters( 'give_placeholder_img_src', $placeholder_url );
400
+	return apply_filters('give_placeholder_img_src', $placeholder_url);
401 401
 }
402 402
 
403 403
 
404 404
 /**
405 405
  * Global
406 406
  */
407
-if ( ! function_exists( 'give_output_content_wrapper' ) ) {
407
+if ( ! function_exists('give_output_content_wrapper')) {
408 408
 
409 409
 	/**
410 410
 	 * Output the start of the page wrapper.
411 411
 	 */
412 412
 	function give_output_content_wrapper() {
413
-		give_get_template_part( 'global/wrapper-start' );
413
+		give_get_template_part('global/wrapper-start');
414 414
 	}
415 415
 }
416
-if ( ! function_exists( 'give_output_content_wrapper_end' ) ) {
416
+if ( ! function_exists('give_output_content_wrapper_end')) {
417 417
 
418 418
 	/**
419 419
 	 * Output the end of the page wrapper.
420 420
 	 */
421 421
 	function give_output_content_wrapper_end() {
422
-		give_get_template_part( 'global/wrapper-end' );
422
+		give_get_template_part('global/wrapper-end');
423 423
 	}
424 424
 }
425 425
 
426 426
 /**
427 427
  * Single Give Form
428 428
  */
429
-if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) {
429
+if ( ! function_exists('give_left_sidebar_pre_wrap')) {
430 430
 	function give_left_sidebar_pre_wrap() {
431
-		echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' );
431
+		echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">');
432 432
 	}
433 433
 }
434 434
 
435
-if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) {
435
+if ( ! function_exists('give_left_sidebar_post_wrap')) {
436 436
 	function give_left_sidebar_post_wrap() {
437
-		echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' );
437
+		echo apply_filters('give_left_sidebar_post_wrap', '</div>');
438 438
 	}
439 439
 }
440 440
 
441
-if ( ! function_exists( 'give_get_forms_sidebar' ) ) {
441
+if ( ! function_exists('give_get_forms_sidebar')) {
442 442
 	function give_get_forms_sidebar() {
443
-		give_get_template_part( 'single-give-form/sidebar' );
443
+		give_get_template_part('single-give-form/sidebar');
444 444
 	}
445 445
 }
446 446
 
447
-if ( ! function_exists( 'give_show_form_images' ) ) {
447
+if ( ! function_exists('give_show_form_images')) {
448 448
 
449 449
 	/**
450 450
 	 * Output the donation form featured image.
451 451
 	 */
452 452
 	function give_show_form_images() {
453
-		if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
454
-			give_get_template_part( 'single-give-form/featured-image' );
453
+		if (give_is_setting_enabled(give_get_option('form_featured_img'))) {
454
+			give_get_template_part('single-give-form/featured-image');
455 455
 		}
456 456
 	}
457 457
 }
458 458
 
459
-if ( ! function_exists( 'give_template_single_title' ) ) {
459
+if ( ! function_exists('give_template_single_title')) {
460 460
 
461 461
 	/**
462 462
 	 * Output the form title.
463 463
 	 */
464 464
 	function give_template_single_title() {
465
-		give_get_template_part( 'single-give-form/title' );
465
+		give_get_template_part('single-give-form/title');
466 466
 	}
467 467
 }
468 468
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
  * Conditional Functions
471 471
  */
472 472
 
473
-if ( ! function_exists( 'is_give_form' ) ) {
473
+if ( ! function_exists('is_give_form')) {
474 474
 
475 475
 	/**
476 476
 	 * is_give_form
@@ -482,11 +482,11 @@  discard block
 block discarded – undo
482 482
 	 * @return bool
483 483
 	 */
484 484
 	function is_give_form() {
485
-		return is_singular( array( 'give_form' ) );
485
+		return is_singular(array('give_form'));
486 486
 	}
487 487
 }
488 488
 
489
-if ( ! function_exists( 'is_give_category' ) ) {
489
+if ( ! function_exists('is_give_category')) {
490 490
 
491 491
 	/**
492 492
 	 * is_give_category
@@ -501,12 +501,12 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @return bool
503 503
 	 */
504
-	function is_give_category( $term = '' ) {
505
-		return is_tax( 'give_forms_category', $term );
504
+	function is_give_category($term = '') {
505
+		return is_tax('give_forms_category', $term);
506 506
 	}
507 507
 }
508 508
 
509
-if ( ! function_exists( 'is_give_tag' ) ) {
509
+if ( ! function_exists('is_give_tag')) {
510 510
 
511 511
 	/**
512 512
 	 * is_give_tag
@@ -521,12 +521,12 @@  discard block
 block discarded – undo
521 521
 	 *
522 522
 	 * @return bool
523 523
 	 */
524
-	function is_give_tag( $term = '' ) {
525
-		return is_tax( 'give_forms_tag', $term );
524
+	function is_give_tag($term = '') {
525
+		return is_tax('give_forms_tag', $term);
526 526
 	}
527 527
 }
528 528
 
529
-if ( ! function_exists( 'is_give_taxonomy' ) ) {
529
+if ( ! function_exists('is_give_taxonomy')) {
530 530
 
531 531
 	/**
532 532
 	 * is_give_taxonomy
@@ -538,6 +538,6 @@  discard block
 block discarded – undo
538 538
 	 * @return bool
539 539
 	 */
540 540
 	function is_give_taxonomy() {
541
-		return is_tax( get_object_taxonomies( 'give_form' ) );
541
+		return is_tax(get_object_taxonomies('give_form'));
542 542
 	}
543 543
 }
Please login to merge, or discard this patch.