Completed
Pull Request — master (#1749)
by Devin
06:21
created
includes/admin/tools/data/class-give-tools-delete-test-transactions.php 1 patch
Spacing   +51 added lines, -51 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
 
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 	public function get_data() {
56 56
 		global $wpdb;
57 57
 
58
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids' );
58
+		$items = $this->get_stored_data('give_temp_delete_test_ids');
59 59
 
60
-		if ( ! is_array( $items ) ) {
60
+		if ( ! is_array($items)) {
61 61
 			return false;
62 62
 		}
63 63
 
64
-		$offset     = ( $this->step - 1 ) * $this->per_step;
65
-		$step_items = array_slice( $items, $offset, $this->per_step );
64
+		$offset     = ($this->step - 1) * $this->per_step;
65
+		$step_items = array_slice($items, $offset, $this->per_step);
66 66
 
67
-		if ( $step_items ) {
67
+		if ($step_items) {
68 68
 
69 69
 			$step_ids = array(
70 70
 				'other' => array(),
71 71
 			);
72 72
 
73
-			foreach ( $step_items as $item ) {
73
+			foreach ($step_items as $item) {
74 74
 
75 75
 				$step_ids['other'][] = $item['id'];
76 76
 
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 
79 79
 			$sql = array();
80 80
 
81
-			foreach ( $step_ids as $type => $ids ) {
81
+			foreach ($step_ids as $type => $ids) {
82 82
 
83
-				if ( empty( $ids ) ) {
83
+				if (empty($ids)) {
84 84
 					continue;
85 85
 				}
86 86
 
87
-				$ids = implode( ',', $ids );
87
+				$ids = implode(',', $ids);
88 88
 
89
-				switch ( $type ) {
89
+				switch ($type) {
90 90
 					case 'other':
91 91
 						$sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)";
92 92
 						$sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)";
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 
98 98
 			}
99 99
 
100
-			if ( ! empty( $sql ) ) {
101
-				foreach ( $sql as $query ) {
102
-					$wpdb->query( $query );
100
+			if ( ! empty($sql)) {
101
+				foreach ($sql as $query) {
102
+					$wpdb->query($query);
103 103
 				}
104 104
 			}
105 105
 
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function get_percentage_complete() {
121 121
 
122
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids', false );
123
-		$total = count( $items );
122
+		$items = $this->get_stored_data('give_temp_delete_test_ids', false);
123
+		$total = count($items);
124 124
 
125 125
 		$percentage = 100;
126 126
 
127
-		if ( $total > 0 ) {
128
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
127
+		if ($total > 0) {
128
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
129 129
 		}
130 130
 
131
-		if ( $percentage > 100 ) {
131
+		if ($percentage > 100) {
132 132
 			$percentage = 100;
133 133
 		}
134 134
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @param array $request The Form Data passed into the batch processing
144 144
 	 */
145
-	public function set_properties( $request ) {
145
+	public function set_properties($request) {
146 146
 	}
147 147
 
148 148
 	/**
@@ -153,29 +153,29 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	public function process_step() {
155 155
 
156
-		if ( ! $this->can_export() ) {
157
-			wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
156
+		if ( ! $this->can_export()) {
157
+			wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403));
158 158
 		}
159 159
 
160 160
 		$had_data = $this->get_data();
161 161
 
162
-		if ( $had_data ) {
162
+		if ($had_data) {
163 163
 			$this->done = false;
164 164
 
165 165
 			return true;
166 166
 		} else {
167
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
168
-			Give_Cache::delete( Give_Cache::get_key('give_estimated_monthly_stats' ) );
167
+			update_option('give_earnings_total', give_get_total_earnings(true));
168
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
169 169
 
170
-			$this->delete_data( 'give_temp_delete_test_ids' );
170
+			$this->delete_data('give_temp_delete_test_ids');
171 171
 
172 172
 			// Reset the sequential order numbers
173
-			if ( give_get_option( 'enable_sequential' ) ) {
174
-				delete_option( 'give_last_payment_number' );
173
+			if (give_get_option('enable_sequential')) {
174
+				delete_option('give_last_payment_number');
175 175
 			}
176 176
 
177 177
 			$this->done    = true;
178
-			$this->message = __( 'Test transactions successfully deleted.', 'give' );
178
+			$this->message = __('Test transactions successfully deleted.', 'give');
179 179
 
180 180
 			return false;
181 181
 		}
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 	 * Headers
186 186
 	 */
187 187
 	public function headers() {
188
-		ignore_user_abort( true );
188
+		ignore_user_abort(true);
189 189
 
190
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
191
-			set_time_limit( 0 );
190
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
191
+			set_time_limit(0);
192 192
 		}
193 193
 	}
194 194
 
@@ -212,26 +212,26 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function pre_fetch() {
214 214
 
215
-		if ( $this->step == 1 ) {
216
-			$this->delete_data( 'give_temp_delete_test_ids' );
215
+		if ($this->step == 1) {
216
+			$this->delete_data('give_temp_delete_test_ids');
217 217
 		}
218 218
 
219
-		$items = get_option( 'give_temp_delete_test_ids', false );
219
+		$items = get_option('give_temp_delete_test_ids', false);
220 220
 
221
-		if ( false === $items ) {
221
+		if (false === $items) {
222 222
 			$items = array();
223 223
 
224
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
224
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
225 225
 				'post_type'      => 'give_payment',
226 226
 				'post_status'    => 'any',
227
-				'posts_per_page' => - 1,
227
+				'posts_per_page' => -1,
228 228
 				// ONLY TEST MODE TRANSACTIONS!!!
229 229
 				'meta_key'   => '_give_payment_mode',
230 230
 				'meta_value' => 'test'
231
-			) );
231
+			));
232 232
 
233
-			$posts = get_posts( $args );
234
-			foreach ( $posts as $post ) {
233
+			$posts = get_posts($args);
234
+			foreach ($posts as $post) {
235 235
 				$items[] = array(
236 236
 					'id'   => (int) $post->ID,
237 237
 					'type' => $post->post_type,
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 
241 241
 			// Allow filtering of items to remove with an unassociative array for each item.
242 242
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method.
243
-			$items = apply_filters( 'give_delete_test_items', $items );
243
+			$items = apply_filters('give_delete_test_items', $items);
244 244
 
245
-			$this->store_data( 'give_temp_delete_test_ids', $items );
245
+			$this->store_data('give_temp_delete_test_ids', $items);
246 246
 		}
247 247
 
248 248
 	}
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return mixed       Returns the data from the database
258 258
 	 */
259
-	private function get_stored_data( $key ) {
259
+	private function get_stored_data($key) {
260 260
 		global $wpdb;
261
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
261
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
262 262
 
263
-		return empty( $value ) ? false : maybe_unserialize( $value );
263
+		return empty($value) ? false : maybe_unserialize($value);
264 264
 	}
265 265
 
266 266
 	/**
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @return void
275 275
 	 */
276
-	private function store_data( $key, $value ) {
276
+	private function store_data($key, $value) {
277 277
 		global $wpdb;
278 278
 
279
-		$value = maybe_serialize( $value );
279
+		$value = maybe_serialize($value);
280 280
 
281 281
 		$data = array(
282 282
 			'option_name'  => $key,
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			'%s',
291 291
 		);
292 292
 
293
-		$wpdb->replace( $wpdb->options, $data, $formats );
293
+		$wpdb->replace($wpdb->options, $data, $formats);
294 294
 	}
295 295
 
296 296
 	/**
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @return void
304 304
 	 */
305
-	private function delete_data( $key ) {
305
+	private function delete_data($key) {
306 306
 		global $wpdb;
307
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
307
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
308 308
 	}
309 309
 
310 310
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-all-stats.php 1 patch
Spacing   +99 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
 
@@ -55,26 +55,26 @@  discard block
 block discarded – undo
55 55
 	public function get_data() {
56 56
 		global $give_logs, $wpdb;
57 57
 
58
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
59
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
60
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
61
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
58
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
59
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
60
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
61
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
62 62
 
63
-		if ( false === $totals ) {
63
+		if (false === $totals) {
64 64
 			$totals = array();
65 65
 		}
66 66
 
67
-		if ( false === $payment_items ) {
67
+		if (false === $payment_items) {
68 68
 			$payment_items = array();
69 69
 		}
70 70
 
71
-		if ( false === $processed_payments ) {
71
+		if (false === $processed_payments) {
72 72
 			$processed_payments = array();
73 73
 		}
74 74
 
75
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
75
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
76 76
 
77
-		$args = apply_filters( 'give_recount_form_stats_args', array(
77
+		$args = apply_filters('give_recount_form_stats_args', array(
78 78
 			'post_parent__in' => $all_forms,
79 79
 			'post_type'       => 'give_log',
80 80
 			'posts_per_page'  => $this->per_step,
@@ -82,73 +82,73 @@  discard block
 block discarded – undo
82 82
 			'paged'           => $this->step,
83 83
 			'log_type'        => 'sale',
84 84
 			'fields'          => 'ids',
85
-		) );
85
+		));
86 86
 
87
-		$log_ids = $give_logs->get_connected_logs( $args, 'sale' );
87
+		$log_ids = $give_logs->get_connected_logs($args, 'sale');
88 88
 
89
-		if ( $log_ids ) {
90
-			$log_ids = implode( ',', $log_ids );
89
+		if ($log_ids) {
90
+			$log_ids = implode(',', $log_ids);
91 91
 
92
-			$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
93
-			unset( $log_ids );
92
+			$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
93
+			unset($log_ids);
94 94
 
95
-			$payment_ids = implode( ',', $payment_ids );
96
-			$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
97
-			unset( $payment_ids );
95
+			$payment_ids = implode(',', $payment_ids);
96
+			$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
97
+			unset($payment_ids);
98 98
 
99 99
 			//Loop through payments
100
-			foreach ( $payments as $payment ) {
100
+			foreach ($payments as $payment) {
101 101
 
102 102
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
103
-				if ( in_array( $payment->ID, $processed_payments ) ) {
103
+				if (in_array($payment->ID, $processed_payments)) {
104 104
 					continue;
105 105
 				}
106 106
 
107 107
 				//Verify accepted status'
108
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
108
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
109 109
 					$processed_payments[] = $payment->ID;
110 110
 					continue;
111 111
 				}
112 112
 
113
-				$payment_item = $payment_items[ $payment->ID ];
113
+				$payment_item = $payment_items[$payment->ID];
114 114
 
115 115
 
116
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
116
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
117 117
 
118 118
 				//Must have a form ID
119
-				if ( empty( $form_id ) ) {
119
+				if (empty($form_id)) {
120 120
 					continue;
121 121
 				}
122 122
 
123 123
 				//Form ID must be within $all_forms array to be validated
124
-				if ( ! in_array( $form_id, $all_forms ) ) {
124
+				if ( ! in_array($form_id, $all_forms)) {
125 125
 					continue;
126 126
 				}
127 127
 
128 128
 				//If array key doesn't exist, create it
129
-				if ( ! array_key_exists( $form_id, $totals ) ) {
130
-					$totals[ $form_id ] = array(
129
+				if ( ! array_key_exists($form_id, $totals)) {
130
+					$totals[$form_id] = array(
131 131
 						'sales'    => (int) 0,
132 132
 						'earnings' => (float) 0,
133 133
 					);
134 134
 				}
135 135
 
136
-				$totals[ $form_id ]['sales'] ++;
137
-				$totals[ $form_id ]['earnings'] += $payment_item['price'];
136
+				$totals[$form_id]['sales']++;
137
+				$totals[$form_id]['earnings'] += $payment_item['price'];
138 138
 
139 139
 				$processed_payments[] = $payment->ID;
140 140
 
141 141
 			}
142 142
 
143
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
144
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
143
+			$this->store_data('give_temp_processed_payments', $processed_payments);
144
+			$this->store_data('give_temp_recount_all_stats', $totals);
145 145
 
146 146
 			return true;
147 147
 		}
148 148
 
149
-		foreach ( $totals as $key => $stats ) {
150
-			give_update_meta( $key, '_give_form_sales', $stats['sales'] );
151
-			give_update_meta( $key, '_give_form_earnings', $stats['earnings'] );
149
+		foreach ($totals as $key => $stats) {
150
+			give_update_meta($key, '_give_form_sales', $stats['sales']);
151
+			give_update_meta($key, '_give_form_earnings', $stats['earnings']);
152 152
 		}
153 153
 
154 154
 		return false;
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public function get_percentage_complete() {
165 165
 
166
-		$total = $this->get_stored_data( 'give_recount_all_total', false );
166
+		$total = $this->get_stored_data('give_recount_all_total', false);
167 167
 
168
-		if ( false === $total ) {
168
+		if (false === $total) {
169 169
 			$this->pre_fetch();
170
-			$total = $this->get_stored_data( 'give_recount_all_total', 0 );
170
+			$total = $this->get_stored_data('give_recount_all_total', 0);
171 171
 		}
172 172
 
173 173
 		$percentage = 100;
174 174
 
175
-		if ( $total > 0 ) {
176
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
175
+		if ($total > 0) {
176
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
177 177
 		}
178 178
 
179
-		if ( $percentage > 100 ) {
179
+		if ($percentage > 100) {
180 180
 			$percentage = 100;
181 181
 		}
182 182
 
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @param array $request The Form Data passed into the batch processing
192 192
 	 */
193
-	public function set_properties( $request ) {
194
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
193
+	public function set_properties($request) {
194
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
195 195
 	}
196 196
 
197 197
 	/**
@@ -202,34 +202,34 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	public function process_step() {
204 204
 
205
-		if ( ! $this->can_export() ) {
206
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
205
+		if ( ! $this->can_export()) {
206
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
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
-			$this->delete_data( 'give_recount_all_total' );
217
-			$this->delete_data( 'give_temp_recount_all_stats' );
218
-			$this->delete_data( 'give_temp_payment_items' );
219
-			$this->delete_data( 'give_temp_form_ids' );
220
-			$this->delete_data( 'give_temp_processed_payments' );
216
+			$this->delete_data('give_recount_all_total');
217
+			$this->delete_data('give_temp_recount_all_stats');
218
+			$this->delete_data('give_temp_payment_items');
219
+			$this->delete_data('give_temp_form_ids');
220
+			$this->delete_data('give_temp_processed_payments');
221 221
 			$this->done    = true;
222
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
222
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
223 223
 
224 224
 			return false;
225 225
 		}
226 226
 	}
227 227
 
228 228
 	public function headers() {
229
-		ignore_user_abort( true );
229
+		ignore_user_abort(true);
230 230
 
231
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
232
-			set_time_limit( 0 );
231
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
232
+			set_time_limit(0);
233 233
 		}
234 234
 	}
235 235
 
@@ -258,76 +258,76 @@  discard block
 block discarded – undo
258 258
 
259 259
 		global $give_logs, $wpdb;
260 260
 
261
-		if ( $this->step == 1 ) {
262
-			$this->delete_data( 'give_temp_recount_all_total' );
263
-			$this->delete_data( 'give_temp_recount_all_stats' );
264
-			$this->delete_data( 'give_temp_payment_items' );
265
-			$this->delete_data( 'give_temp_processed_payments' );
261
+		if ($this->step == 1) {
262
+			$this->delete_data('give_temp_recount_all_total');
263
+			$this->delete_data('give_temp_recount_all_stats');
264
+			$this->delete_data('give_temp_payment_items');
265
+			$this->delete_data('give_temp_processed_payments');
266 266
 		}
267 267
 
268
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
269
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
268
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
269
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
270 270
 
271
-		if ( false === $total ) {
271
+		if (false === $total) {
272 272
 			$total         = 0;
273
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
273
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
274 274
 
275
-			if ( false === $payment_items ) {
275
+			if (false === $payment_items) {
276 276
 				$payment_items = array();
277
-				$this->store_data( 'give_temp_payment_items', $payment_items );
277
+				$this->store_data('give_temp_payment_items', $payment_items);
278 278
 			}
279 279
 
280
-			$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
280
+			$all_forms = $this->get_stored_data('give_temp_form_ids');
281 281
 
282
-			if ( false === $all_forms ) {
282
+			if (false === $all_forms) {
283 283
 				$args = array(
284 284
 					'post_status'    => 'any',
285 285
 					'post_type'      => 'give_forms',
286
-					'posts_per_page' => - 1,
286
+					'posts_per_page' => -1,
287 287
 					'fields'         => 'ids',
288 288
 				);
289 289
 
290
-				$all_forms = get_posts( $args );
291
-				$this->store_data( 'give_temp_form_ids', $all_forms );
290
+				$all_forms = get_posts($args);
291
+				$this->store_data('give_temp_form_ids', $all_forms);
292 292
 			}
293 293
 
294
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
294
+			$args = apply_filters('give_recount_form_stats_total_args', array(
295 295
 				'post_parent__in' => $all_forms,
296 296
 				'post_type'       => 'give_log',
297 297
 				'post_status'     => 'publish',
298 298
 				'log_type'        => 'sale',
299 299
 				'fields'          => 'ids',
300 300
 				'nopaging'        => true,
301
-			) );
301
+			));
302 302
 
303
-			$all_logs = $give_logs->get_connected_logs( $args, 'sale' );
303
+			$all_logs = $give_logs->get_connected_logs($args, 'sale');
304 304
 
305
-			if ( $all_logs ) {
306
-				$log_ids     = implode( ',', $all_logs );
307
-				$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
308
-				unset( $log_ids );
305
+			if ($all_logs) {
306
+				$log_ids     = implode(',', $all_logs);
307
+				$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
308
+				unset($log_ids);
309 309
 
310
-				$payment_ids = implode( ',', $payment_ids );
311
-				$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
312
-				unset( $payment_ids );
310
+				$payment_ids = implode(',', $payment_ids);
311
+				$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
312
+				unset($payment_ids);
313 313
 
314
-				foreach ( $payments as $payment ) {
314
+				foreach ($payments as $payment) {
315 315
 
316
-					$payment = new Give_Payment( $payment->ID );
316
+					$payment = new Give_Payment($payment->ID);
317 317
 					$form_id = $payment->form_id;
318 318
 
319 319
 					//If for some reason somehow the form_ID isn't set check payment meta
320
-					if ( empty( $payment->form_id ) ) {
320
+					if (empty($payment->form_id)) {
321 321
 						$payment_meta = $payment->get_meta();
322
-						$form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
322
+						$form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
323 323
 					}
324 324
 
325
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
325
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
326 326
 						continue;
327 327
 					}
328 328
 
329
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
330
-						$payment_items[ $payment->ID ] = array(
329
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
330
+						$payment_items[$payment->ID] = array(
331 331
 							'id'         => $form_id,
332 332
 							'payment_id' => $payment->ID,
333 333
 							'price'      => $payment->total
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 
337 337
 				}
338 338
 
339
-				$total = count( $all_logs );
339
+				$total = count($all_logs);
340 340
 			}
341 341
 
342
-			$this->store_data( 'give_temp_payment_items', $payment_items );
343
-			$this->store_data( 'give_recount_all_total', $total );
342
+			$this->store_data('give_temp_payment_items', $payment_items);
343
+			$this->store_data('give_recount_all_total', $total);
344 344
 		}
345 345
 
346 346
 	}
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @return mixed       Returns the data from the database
356 356
 	 */
357
-	private function get_stored_data( $key ) {
357
+	private function get_stored_data($key) {
358 358
 		global $wpdb;
359
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
359
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
360 360
 
361
-		return empty( $value ) ? false : maybe_unserialize( $value );
361
+		return empty($value) ? false : maybe_unserialize($value);
362 362
 	}
363 363
 
364 364
 	/**
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return void
373 373
 	 */
374
-	private function store_data( $key, $value ) {
374
+	private function store_data($key, $value) {
375 375
 		global $wpdb;
376 376
 
377
-		$value = maybe_serialize( $value );
377
+		$value = maybe_serialize($value);
378 378
 
379 379
 		$data = array(
380 380
 			'option_name'  => $key,
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 			'%s',
389 389
 		);
390 390
 
391
-		$wpdb->replace( $wpdb->options, $data, $formats );
391
+		$wpdb->replace($wpdb->options, $data, $formats);
392 392
 	}
393 393
 
394 394
 	/**
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 	 *
401 401
 	 * @return void
402 402
 	 */
403
-	private function delete_data( $key ) {
403
+	private function delete_data($key) {
404 404
 		global $wpdb;
405
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
405
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
406 406
 	}
407 407
 
408 408
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/tools-actions.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  * @since  1.5
21 21
  */
22 22
 function give_register_batch_recount_export_classes() {
23
-	add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 );
23
+	add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1);
24 24
 }
25 25
 
26
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 );
26
+add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10);
27 27
 
28 28
 
29 29
 /**
@@ -35,31 +35,31 @@  discard block
 block discarded – undo
35 35
  *
36 36
  * @return void
37 37
  */
38
-function give_include_batch_export_class( $class ) {
39
-	switch ( $class ) {
38
+function give_include_batch_export_class($class) {
39
+	switch ($class) {
40 40
 
41 41
 		case 'Give_Tools_Delete_Test_Transactions':
42
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
42
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
43 43
 			break;
44 44
 
45 45
 		case 'Give_Tools_Recount_Customer_Stats':
46
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-customer-stats.php';
46
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-customer-stats.php';
47 47
 			break;
48 48
 
49 49
 		case 'Give_Tools_Reset_Stats':
50
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php';
50
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php';
51 51
 			break;
52 52
 
53 53
 		case 'Give_Tools_Recount_All_Stats':
54
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
54
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
55 55
 			break;
56 56
 
57 57
 		case 'Give_Tools_Recount_Form_Stats':
58
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
58
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
59 59
 			break;
60 60
 
61 61
 		case 'Give_Tools_Recount_Income':
62
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php';
62
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php';
63 63
 			break;
64 64
 	}
65 65
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-form-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
 
@@ -62,23 +62,23 @@  discard block
 block discarded – undo
62 62
 	public function get_data() {
63 63
 		global $give_logs, $wpdb;
64 64
 
65
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
65
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
66 66
 
67
-		if ( $this->step == 1 ) {
68
-			$this->delete_data( 'give_temp_recount_form_stats' );
67
+		if ($this->step == 1) {
68
+			$this->delete_data('give_temp_recount_form_stats');
69 69
 		}
70 70
 
71
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
71
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
72 72
 
73
-		if ( false === $totals ) {
73
+		if (false === $totals) {
74 74
 			$totals = array(
75 75
 				'earnings' => (float) 0,
76 76
 				'sales'    => 0,
77 77
 			);
78
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
78
+			$this->store_data('give_temp_recount_form_stats', $totals);
79 79
 		}
80 80
 
81
-		$args = apply_filters( 'give_recount_form_stats_args', array(
81
+		$args = apply_filters('give_recount_form_stats_args', array(
82 82
 			'post_parent'    => $this->form_id,
83 83
 			'post_type'      => 'give_log',
84 84
 			'posts_per_page' => $this->per_step,
@@ -86,49 +86,49 @@  discard block
 block discarded – undo
86 86
 			'paged'          => $this->step,
87 87
 			'log_type'       => 'sale',
88 88
 			'fields'         => 'ids',
89
-		) );
89
+		));
90 90
 
91
-		$log_ids              = $give_logs->get_connected_logs( $args, 'sale' );
91
+		$log_ids              = $give_logs->get_connected_logs($args, 'sale');
92 92
 		$this->_log_ids_debug = array();
93 93
 
94
-		if ( $log_ids ) {
95
-			$log_ids     = implode( ',', $log_ids );
96
-			$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
97
-			unset( $log_ids );
94
+		if ($log_ids) {
95
+			$log_ids     = implode(',', $log_ids);
96
+			$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
97
+			unset($log_ids);
98 98
 
99
-			$payment_ids = implode( ',', $payment_ids );
100
-			$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
101
-			unset( $payment_ids );
99
+			$payment_ids = implode(',', $payment_ids);
100
+			$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
101
+			unset($payment_ids);
102 102
 
103
-			foreach ( $payments as $payment ) {
103
+			foreach ($payments as $payment) {
104 104
 
105
-				$payment = new Give_Payment( $payment->ID );
105
+				$payment = new Give_Payment($payment->ID);
106 106
 
107 107
 				//Ensure acceptible status only
108
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
108
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
109 109
 					continue;
110 110
 				}
111 111
 
112 112
 				//Ensure only payments for this form are counted
113
-				if ( $payment->form_id != $this->form_id ) {
113
+				if ($payment->form_id != $this->form_id) {
114 114
 					continue;
115 115
 				}
116 116
 
117 117
 				$this->_log_ids_debug[] = $payment->ID;
118 118
 
119
-				$totals['sales'] ++;
119
+				$totals['sales']++;
120 120
 				$totals['earnings'] += $payment->total;
121 121
 
122 122
 			}
123 123
 
124
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
124
+			$this->store_data('give_temp_recount_form_stats', $totals);
125 125
 
126 126
 			return true;
127 127
 		}
128 128
 
129 129
 
130
-		give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
131
-		give_update_meta( $this->form_id, '_give_form_earnings', $totals['earnings'] );
130
+		give_update_meta($this->form_id, '_give_form_sales', $totals['sales']);
131
+		give_update_meta($this->form_id, '_give_form_earnings', $totals['earnings']);
132 132
 
133 133
 		return false;
134 134
 
@@ -143,54 +143,54 @@  discard block
 block discarded – undo
143 143
 	public function get_percentage_complete() {
144 144
 		global $give_logs, $wpdb;
145 145
 
146
-		if ( $this->step == 1 ) {
147
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
146
+		if ($this->step == 1) {
147
+			$this->delete_data('give_recount_total_'.$this->form_id);
148 148
 		}
149 149
 
150
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
151
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
150
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
151
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
152 152
 
153
-		if ( false === $total ) {
153
+		if (false === $total) {
154 154
 			$total = 0;
155
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
155
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
156 156
 				'post_parent' => $this->form_id,
157 157
 				'post_type'   => 'give_log',
158 158
 				'post_status' => 'publish',
159 159
 				'log_type'    => 'sale',
160 160
 				'fields'      => 'ids',
161 161
 				'nopaging'    => true,
162
-			) );
162
+			));
163 163
 
164
-			$log_ids = $give_logs->get_connected_logs( $args, 'sale' );
164
+			$log_ids = $give_logs->get_connected_logs($args, 'sale');
165 165
 
166
-			if ( $log_ids ) {
167
-				$log_ids     = implode( ',', $log_ids );
168
-				$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
169
-				unset( $log_ids );
166
+			if ($log_ids) {
167
+				$log_ids     = implode(',', $log_ids);
168
+				$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
169
+				unset($log_ids);
170 170
 
171
-				$payment_ids = implode( ',', $payment_ids );
172
-				$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
173
-				unset( $payment_ids );
171
+				$payment_ids = implode(',', $payment_ids);
172
+				$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
173
+				unset($payment_ids);
174 174
 
175
-				foreach ( $payments as $payment ) {
176
-					if ( in_array( $payment->post_status, $accepted_statuses ) ) {
175
+				foreach ($payments as $payment) {
176
+					if (in_array($payment->post_status, $accepted_statuses)) {
177 177
 						continue;
178 178
 					}
179 179
 
180
-					$total ++;
180
+					$total++;
181 181
 				}
182 182
 			}
183 183
 
184
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
184
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
185 185
 		}
186 186
 
187 187
 		$percentage = 100;
188 188
 
189
-		if ( $total > 0 ) {
190
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
189
+		if ($total > 0) {
190
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
191 191
 		}
192 192
 
193
-		if ( $percentage > 100 ) {
193
+		if ($percentage > 100) {
194 194
 			$percentage = 100;
195 195
 		}
196 196
 
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @param array $request The Form Data passed into the batch processing
206 206
 	 */
207
-	public function set_properties( $request ) {
208
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
207
+	public function set_properties($request) {
208
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
209 209
 	}
210 210
 
211 211
 	/**
@@ -216,31 +216,31 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	public function process_step() {
218 218
 
219
-		if ( ! $this->can_export() ) {
220
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
219
+		if ( ! $this->can_export()) {
220
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
221 221
 		}
222 222
 
223 223
 		$had_data = $this->get_data();
224 224
 
225
-		if ( $had_data ) {
225
+		if ($had_data) {
226 226
 			$this->done = false;
227 227
 
228 228
 			return true;
229 229
 		} else {
230
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
231
-			$this->delete_data( 'give_temp_recount_form_stats' );
230
+			$this->delete_data('give_recount_total_'.$this->form_id);
231
+			$this->delete_data('give_temp_recount_form_stats');
232 232
 			$this->done    = true;
233
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
233
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
234 234
 
235 235
 			return false;
236 236
 		}
237 237
 	}
238 238
 
239 239
 	public function headers() {
240
-		ignore_user_abort( true );
240
+		ignore_user_abort(true);
241 241
 
242
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
243
-			set_time_limit( 0 );
242
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
243
+			set_time_limit(0);
244 244
 		}
245 245
 	}
246 246
 
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 	 *
269 269
 	 * @return mixed       Returns the data from the database
270 270
 	 */
271
-	private function get_stored_data( $key ) {
271
+	private function get_stored_data($key) {
272 272
 		global $wpdb;
273
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
273
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
274 274
 
275
-		return empty( $value ) ? false : maybe_unserialize( $value );
275
+		return empty($value) ? false : maybe_unserialize($value);
276 276
 	}
277 277
 
278 278
 	/**
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @return void
287 287
 	 */
288
-	private function store_data( $key, $value ) {
288
+	private function store_data($key, $value) {
289 289
 		global $wpdb;
290 290
 
291
-		$value = maybe_serialize( $value );
291
+		$value = maybe_serialize($value);
292 292
 
293 293
 		$data = array(
294 294
 			'option_name'  => $key,
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 			'%s',
303 303
 		);
304 304
 
305
-		$wpdb->replace( $wpdb->options, $data, $formats );
305
+		$wpdb->replace($wpdb->options, $data, $formats);
306 306
 	}
307 307
 
308 308
 	/**
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @return void
316 316
 	 */
317
-	private function delete_data( $key ) {
317
+	private function delete_data($key) {
318 318
 		global $wpdb;
319
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
319
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
320 320
 	}
321 321
 
322 322
 }
Please login to merge, or discard this patch.
includes/admin/tools/class-settings-export.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Export' ) ) :
16
+if ( ! class_exists('Give_Settings_Export')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Export.
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 		 */
44 44
 		public function __construct() {
45 45
 			$this->id    = 'export';
46
-			$this->label = __( 'Export', 'give' );
46
+			$this->label = __('Export', 'give');
47 47
 
48
-			add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 );
49
-			add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) );
50
-			add_action( 'give_admin_field_tools_export', array( $this, 'render_export_field' ), 10, 2 );
48
+			add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20);
49
+			add_action("give-tools_settings_{$this->id}_page", array($this, 'output'));
50
+			add_action('give_admin_field_tools_export', array($this, 'render_export_field'), 10, 2);
51 51
 
52 52
 			// Do not use main donor for this tab.
53
-			if( give_get_current_setting_tab() === $this->id ) {
54
-				add_action( 'give-tools_open_form', '__return_empty_string' );
55
-				add_action( 'give-tools_close_form', '__return_empty_string' );
53
+			if (give_get_current_setting_tab() === $this->id) {
54
+				add_action('give-tools_open_form', '__return_empty_string');
55
+				add_action('give-tools_close_form', '__return_empty_string');
56 56
 			}
57 57
 		}
58 58
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		 * @param  array $pages Lst of pages.
64 64
 		 * @return array
65 65
 		 */
66
-		public function add_settings_page( $pages ) {
67
-			$pages[ $this->id ] = $this->label;
66
+		public function add_settings_page($pages) {
67
+			$pages[$this->id] = $this->label;
68 68
 
69 69
 			return $pages;
70 70
 		}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			 * @param  array $settings
87 87
 			 */
88 88
 			$settings = apply_filters(
89
-				'give_get_settings_' . $this->id,
89
+				'give_get_settings_'.$this->id,
90 90
 				array(
91 91
 					array(
92 92
 						'id'   => 'give_tools_export',
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 					),
96 96
 					array(
97 97
 						'id'   => 'export',
98
-						'name' => __( 'Export', 'give' ),
98
+						'name' => __('Export', 'give'),
99 99
 						'type' => 'tools_export',
100 100
 					),
101 101
 					array(
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		public function output() {
120 120
 			$settings = $this->get_settings();
121 121
 
122
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
122
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
123 123
 		}
124 124
 
125 125
 		/**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 		 * @param $field
132 132
 		 * @param $option_value
133 133
 		 */
134
-		public function render_export_field( $field, $option_value ) {
135
-			include_once( 'views/html-admin-page-exports.php' );
134
+		public function render_export_field($field, $option_value) {
135
+			include_once('views/html-admin-page-exports.php');
136 136
 		}
137 137
 	}
138 138
 
Please login to merge, or discard this patch.
includes/shortcodes.php 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 function give_donation_history() {
27 27
 
28 28
 	// If payment_key query arg exists, return receipt instead of donation history.
29
-	if ( isset( $_GET['payment_key'] ) ) {
29
+	if (isset($_GET['payment_key'])) {
30 30
 		ob_start();
31
-		echo give_receipt_shortcode( array() );
32
-		echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">&laquo; ' . __( 'Return to All Donations', 'give' ) . '</a>';
31
+		echo give_receipt_shortcode(array());
32
+		echo '<a href="'.esc_url(give_get_history_page_uri()).'">&laquo; '.__('Return to All Donations', 'give').'</a>';
33 33
 
34 34
 		return ob_get_clean();
35 35
 	}
36 36
 
37
-	$email_access = give_get_option( 'email_access' );
37
+	$email_access = give_get_option('email_access');
38 38
 
39 39
 	/**
40 40
 	 * Determine access
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	if (
46 46
 		is_user_logged_in() || false !== Give()->session->get_session_expiration()
47
-		|| ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists )
47
+		|| (give_is_setting_enabled($email_access) && Give()->email_access->token_exists)
48 48
 	) {
49 49
 		ob_start();
50
-		give_get_template_part( 'history', 'donations' );
50
+		give_get_template_part('history', 'donations');
51 51
 
52 52
 		return ob_get_clean();
53 53
 
54
-	} elseif ( give_is_setting_enabled( $email_access ) ) {
54
+	} elseif (give_is_setting_enabled($email_access)) {
55 55
 		// Is Email-based access enabled?
56 56
 		ob_start();
57
-		give_get_template_part( 'email', 'login-form' );
57
+		give_get_template_part('email', 'login-form');
58 58
 
59 59
 		return ob_get_clean();
60 60
 
61 61
 	} else {
62 62
 
63
-		$output = apply_filters( 'give_donation_history_nonuser_message', give_output_error( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) );
64
-		$output .= do_shortcode( '[give_login]' );
63
+		$output = apply_filters('give_donation_history_nonuser_message', give_output_error(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false));
64
+		$output .= do_shortcode('[give_login]');
65 65
 
66 66
 		return $output;
67 67
 	}
68 68
 }
69 69
 
70
-add_shortcode( 'donation_history', 'give_donation_history' );
70
+add_shortcode('donation_history', 'give_donation_history');
71 71
 
72 72
 /**
73 73
  * Donation Form Shortcode
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
  *
81 81
  * @return string
82 82
  */
83
-function give_form_shortcode( $atts ) {
84
-	$atts = shortcode_atts( array(
83
+function give_form_shortcode($atts) {
84
+	$atts = shortcode_atts(array(
85 85
 		'id'                    => '',
86 86
 		'show_title'            => true,
87 87
 		'show_goal'             => true,
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
 		'float_labels'          => '',
90 90
 		'display_style'         => '',
91 91
 		'continue_button_title' => '',
92
-	), $atts, 'give_form' );
92
+	), $atts, 'give_form');
93 93
 
94 94
 	// Convert string to bool.
95
-	$atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN );
96
-	$atts['show_goal']  = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN );
95
+	$atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN);
96
+	$atts['show_goal']  = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN);
97 97
 
98 98
 	//get the Give Form
99 99
 	ob_start();
100
-	give_get_donation_form( $atts );
100
+	give_get_donation_form($atts);
101 101
 	$final_output = ob_get_clean();
102 102
 
103
-	return apply_filters( 'give_donate_form', $final_output, $atts );
103
+	return apply_filters('give_donate_form', $final_output, $atts);
104 104
 }
105 105
 
106
-add_shortcode( 'give_form', 'give_form_shortcode' );
106
+add_shortcode('give_form', 'give_form_shortcode');
107 107
 
108 108
 /**
109 109
  * Donation Form Goal Shortcode.
@@ -116,37 +116,37 @@  discard block
 block discarded – undo
116 116
  *
117 117
  * @return string
118 118
  */
119
-function give_goal_shortcode( $atts ) {
120
-	$atts = shortcode_atts( array(
119
+function give_goal_shortcode($atts) {
120
+	$atts = shortcode_atts(array(
121 121
 		'id'        => '',
122 122
 		'show_text' => true,
123 123
 		'show_bar'  => true,
124
-	), $atts, 'give_goal' );
124
+	), $atts, 'give_goal');
125 125
 
126 126
 
127 127
 	//get the Give Form.
128 128
 	ob_start();
129 129
 
130 130
 	//Sanity check 1: ensure there is an ID Provided.
131
-	if ( empty( $atts['id'] ) ) {
132
-		give_output_error( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
131
+	if (empty($atts['id'])) {
132
+		give_output_error(__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
133 133
 	}
134 134
 
135 135
 	//Sanity check 2: Check the form even has Goals enabled.
136
-	if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) {
136
+	if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) {
137 137
 
138
-		give_output_error( __( 'The form does not have Goals enabled.', 'give' ), true );
138
+		give_output_error(__('The form does not have Goals enabled.', 'give'), true);
139 139
 	} else {
140 140
 		//Passed all sanity checks: output Goal.
141
-		give_show_goal_progress( $atts['id'], $atts );
141
+		give_show_goal_progress($atts['id'], $atts);
142 142
 	}
143 143
 
144 144
 	$final_output = ob_get_clean();
145 145
 
146
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
146
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
147 147
 }
148 148
 
149
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
149
+add_shortcode('give_goal', 'give_goal_shortcode');
150 150
 
151 151
 
152 152
 /**
@@ -163,22 +163,22 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return string
165 165
  */
166
-function give_login_form_shortcode( $atts ) {
167
-	$atts = shortcode_atts( array(
166
+function give_login_form_shortcode($atts) {
167
+	$atts = shortcode_atts(array(
168 168
 		// Add backward compatibility for redirect attribute.
169 169
 		'redirect' => '',
170 170
 
171 171
 		'login-redirect'  => '',
172 172
 		'logout-redirect' => '',
173
-	), $atts, 'give_login' );
173
+	), $atts, 'give_login');
174 174
 
175 175
 	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
176
-	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' );
176
+	$atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
177 177
 
178
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
178
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
179 179
 }
180 180
 
181
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
181
+add_shortcode('give_login', 'give_login_form_shortcode');
182 182
 
183 183
 /**
184 184
  * Register Shortcode.
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
  *
194 194
  * @return string
195 195
  */
196
-function give_register_form_shortcode( $atts ) {
197
-	$atts = shortcode_atts( array(
196
+function give_register_form_shortcode($atts) {
197
+	$atts = shortcode_atts(array(
198 198
 		'redirect' => '',
199
-	), $atts, 'give_register' );
199
+	), $atts, 'give_register');
200 200
 
201
-	return give_register_form( $atts['redirect'] );
201
+	return give_register_form($atts['redirect']);
202 202
 }
203 203
 
204
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
204
+add_shortcode('give_register', 'give_register_form_shortcode');
205 205
 
206 206
 /**
207 207
  * Receipt Shortcode.
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
  *
215 215
  * @return string
216 216
  */
217
-function give_receipt_shortcode( $atts ) {
217
+function give_receipt_shortcode($atts) {
218 218
 
219 219
 	global $give_receipt_args, $payment;
220 220
 
221
-	$give_receipt_args = shortcode_atts( array(
222
-		'error'          => __( 'You are missing the payment key to view this donation receipt.', 'give' ),
221
+	$give_receipt_args = shortcode_atts(array(
222
+		'error'          => __('You are missing the payment key to view this donation receipt.', 'give'),
223 223
 		'price'          => true,
224 224
 		'donor'          => true,
225 225
 		'date'           => true,
@@ -228,50 +228,50 @@  discard block
 block discarded – undo
228 228
 		'payment_id'     => true,
229 229
 		'payment_status' => false,
230 230
 		'status_notice'  => true,
231
-	), $atts, 'give_receipt' );
231
+	), $atts, 'give_receipt');
232 232
 
233 233
 	//set $session var
234 234
 	$session = give_get_purchase_session();
235 235
 
236 236
 	//set payment key var
237
-	if ( isset( $_GET['payment_key'] ) ) {
238
-		$payment_key = urldecode( $_GET['payment_key'] );
239
-	} elseif ( $session ) {
237
+	if (isset($_GET['payment_key'])) {
238
+		$payment_key = urldecode($_GET['payment_key']);
239
+	} elseif ($session) {
240 240
 		$payment_key = $session['purchase_key'];
241
-	} elseif ( $give_receipt_args['payment_key'] ) {
241
+	} elseif ($give_receipt_args['payment_key']) {
242 242
 		$payment_key = $give_receipt_args['payment_key'];
243 243
 	}
244 244
 
245
-	$email_access = give_get_option( 'email_access' );
245
+	$email_access = give_get_option('email_access');
246 246
 
247 247
 	// No payment_key found & Email Access is Turned on:
248
-	if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
248
+	if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
249 249
 
250 250
 		ob_start();
251 251
 
252
-		give_get_template_part( 'email-login-form' );
252
+		give_get_template_part('email-login-form');
253 253
 
254 254
 		return ob_get_clean();
255 255
 
256
-	} elseif ( ! isset( $payment_key ) ) {
256
+	} elseif ( ! isset($payment_key)) {
257 257
 
258
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
258
+		return give_output_error($give_receipt_args['error'], false, 'error');
259 259
 
260 260
 	}
261 261
 
262
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
263
-	$user_can_view = give_can_view_receipt( $payment_key );
262
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
263
+	$user_can_view = give_can_view_receipt($payment_key);
264 264
 
265 265
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
266
-	if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
266
+	if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
267 267
 
268 268
 		ob_start();
269 269
 
270
-		give_get_template_part( 'email-login-form' );
270
+		give_get_template_part('email-login-form');
271 271
 
272 272
 		return ob_get_clean();
273 273
 
274
-	} elseif ( ! $user_can_view ) {
274
+	} elseif ( ! $user_can_view) {
275 275
 
276 276
 		global $give_login_redirect;
277 277
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 
280 280
 		ob_start();
281 281
 
282
-		give_output_error( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) );
282
+		give_output_error(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give')));
283 283
 
284
-		give_get_template_part( 'shortcode', 'login' );
284
+		give_get_template_part('shortcode', 'login');
285 285
 
286 286
 		$login_form = ob_get_clean();
287 287
 
@@ -296,20 +296,20 @@  discard block
 block discarded – undo
296 296
 	 * or if user is logged in and the user can view sensitive shop data.
297 297
 	 *
298 298
 	 */
299
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
300
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
299
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
300
+		return give_output_error($give_receipt_args['error'], false, 'error');
301 301
 	}
302 302
 
303 303
 	ob_start();
304 304
 
305
-	give_get_template_part( 'shortcode', 'receipt' );
305
+	give_get_template_part('shortcode', 'receipt');
306 306
 
307 307
 	$display = ob_get_clean();
308 308
 
309 309
 	return $display;
310 310
 }
311 311
 
312
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
312
+add_shortcode('give_receipt', 'give_receipt_shortcode');
313 313
 
314 314
 /**
315 315
  * Profile Editor Shortcode.
@@ -328,18 +328,18 @@  discard block
 block discarded – undo
328 328
  *
329 329
  * @return string Output generated from the profile editor
330 330
  */
331
-function give_profile_editor_shortcode( $atts ) {
331
+function give_profile_editor_shortcode($atts) {
332 332
 
333 333
 	ob_start();
334 334
 
335
-	give_get_template_part( 'shortcode', 'profile-editor' );
335
+	give_get_template_part('shortcode', 'profile-editor');
336 336
 
337 337
 	$display = ob_get_clean();
338 338
 
339 339
 	return $display;
340 340
 }
341 341
 
342
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
342
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
343 343
 
344 344
 /**
345 345
  * Process Profile Updater Form.
@@ -352,30 +352,30 @@  discard block
 block discarded – undo
352 352
  *
353 353
  * @return bool
354 354
  */
355
-function give_process_profile_editor_updates( $data ) {
355
+function give_process_profile_editor_updates($data) {
356 356
 	// Profile field change request
357
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
357
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
358 358
 		return false;
359 359
 	}
360 360
 
361 361
 	// Nonce security
362
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
362
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
363 363
 		return false;
364 364
 	}
365 365
 
366 366
 	$user_id       = get_current_user_id();
367
-	$old_user_data = get_userdata( $user_id );
368
-
369
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
370
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
371
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
372
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
373
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
374
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
375
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
376
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
377
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
378
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
367
+	$old_user_data = get_userdata($user_id);
368
+
369
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
370
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
371
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
372
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
373
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
374
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
375
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
376
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
377
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
378
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
379 379
 
380 380
 	$userdata = array(
381 381
 		'ID'           => $user_id,
@@ -403,46 +403,46 @@  discard block
 block discarded – undo
403 403
 	 * @param int $user_id The ID of the user.
404 404
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
405 405
 	 */
406
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
406
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
407 407
 
408 408
 	// New password
409
-	if ( ! empty( $data['give_new_user_pass1'] ) ) {
410
-		if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) {
411
-			give_set_error( 'password_mismatch', __( 'The passwords you entered do not match. Please try again.', 'give' ) );
409
+	if ( ! empty($data['give_new_user_pass1'])) {
410
+		if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) {
411
+			give_set_error('password_mismatch', __('The passwords you entered do not match. Please try again.', 'give'));
412 412
 		} else {
413 413
 			$userdata['user_pass'] = $data['give_new_user_pass1'];
414 414
 		}
415 415
 	}
416 416
 
417
-	if ( empty( $email ) ) {
417
+	if (empty($email)) {
418 418
 		// Make sure email should not be empty.
419
-		give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) );
419
+		give_set_error('email_empty', __('The email you entered is empty.', 'give'));
420 420
 
421
-	} else if ( ! is_email( $email ) ) {
421
+	} else if ( ! is_email($email)) {
422 422
 		// Make sure email should be valid.
423
-		give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) );
423
+		give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give'));
424 424
 
425
-	} else if ( $email != $old_user_data->user_email ) {
425
+	} else if ($email != $old_user_data->user_email) {
426 426
 		// Make sure the new email doesn't belong to another user
427
-		if ( email_exists( $email ) ) {
428
-			give_set_error( 'email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
427
+		if (email_exists($email)) {
428
+			give_set_error('email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
429 429
 		}
430 430
 	}
431 431
 
432 432
 	// Check for errors
433 433
 	$errors = give_get_errors();
434 434
 
435
-	if ( $errors ) {
435
+	if ($errors) {
436 436
 		// Send back to the profile editor if there are errors
437
-		wp_redirect( $data['give_redirect'] );
437
+		wp_redirect($data['give_redirect']);
438 438
 		give_die();
439 439
 	}
440 440
 
441 441
 	// Update the user
442
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
443
-	$updated = wp_update_user( $userdata );
442
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
443
+	$updated = wp_update_user($userdata);
444 444
 
445
-	if ( $updated ) {
445
+	if ($updated) {
446 446
 
447 447
 		/**
448 448
 		 * Fires after updating user profile.
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
 		 * @param int $user_id The ID of the user.
453 453
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
454 454
 		 */
455
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
456
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
455
+		do_action('give_user_profile_updated', $user_id, $userdata);
456
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
457 457
 		give_die();
458 458
 	}
459 459
 
460 460
 	return false;
461 461
 }
462 462
 
463
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
463
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
Please login to merge, or discard this patch.
includes/class-give-roles.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
 		add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array(
90 90
 			'read'         => true,
91 91
 			'edit_posts'   => true,
92
-            'edit_pages'   => true,
92
+			'edit_pages'   => true,
93 93
 			'upload_files' => true,
94 94
 			'delete_posts' => false
95 95
 		) );
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @access public
36 36
 	 */
37 37
 	public function __construct() {
38
-		add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 );
38
+		add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4);
39 39
 	}
40 40
 
41 41
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @return void
50 50
 	 */
51 51
 	public function add_roles() {
52
-		add_role( 'give_manager', esc_html__( 'Give Manager', 'give' ), array(
52
+		add_role('give_manager', esc_html__('Give Manager', 'give'), array(
53 53
 			'read'                   => true,
54 54
 			'edit_posts'             => true,
55 55
 			'delete_posts'           => true,
@@ -78,21 +78,21 @@  discard block
 block discarded – undo
78 78
 			'publish_posts'          => true,
79 79
 			'read_private_pages'     => true,
80 80
 			'read_private_posts'     => true
81
-		) );
81
+		));
82 82
 
83
-		add_role( 'give_accountant', esc_html__( 'Give Accountant', 'give' ), array(
83
+		add_role('give_accountant', esc_html__('Give Accountant', 'give'), array(
84 84
 			'read'         => true,
85 85
 			'edit_posts'   => false,
86 86
 			'delete_posts' => false
87
-		) );
87
+		));
88 88
 
89
-		add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array(
89
+		add_role('give_worker', esc_html__('Give Worker', 'give'), array(
90 90
 			'read'         => true,
91 91
 			'edit_posts'   => true,
92 92
             'edit_pages'   => true,
93 93
 			'upload_files' => true,
94 94
 			'delete_posts' => false
95
-		) );
95
+		));
96 96
 
97 97
 	}
98 98
 
@@ -111,38 +111,38 @@  discard block
 block discarded – undo
111 111
 	public function add_caps() {
112 112
 		global $wp_roles;
113 113
 
114
-		if ( class_exists( 'WP_Roles' ) ) {
115
-			if ( ! isset( $wp_roles ) ) {
114
+		if (class_exists('WP_Roles')) {
115
+			if ( ! isset($wp_roles)) {
116 116
 				$wp_roles = new WP_Roles();
117 117
 			}
118 118
 		}
119 119
 
120
-		if ( is_object( $wp_roles ) ) {
121
-			$wp_roles->add_cap( 'give_manager', 'view_give_reports' );
122
-			$wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' );
123
-			$wp_roles->add_cap( 'give_manager', 'export_give_reports' );
124
-			$wp_roles->add_cap( 'give_manager', 'manage_give_settings' );
120
+		if (is_object($wp_roles)) {
121
+			$wp_roles->add_cap('give_manager', 'view_give_reports');
122
+			$wp_roles->add_cap('give_manager', 'view_give_sensitive_data');
123
+			$wp_roles->add_cap('give_manager', 'export_give_reports');
124
+			$wp_roles->add_cap('give_manager', 'manage_give_settings');
125 125
 
126
-			$wp_roles->add_cap( 'administrator', 'view_give_reports' );
127
-			$wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' );
128
-			$wp_roles->add_cap( 'administrator', 'export_give_reports' );
129
-			$wp_roles->add_cap( 'administrator', 'manage_give_settings' );
126
+			$wp_roles->add_cap('administrator', 'view_give_reports');
127
+			$wp_roles->add_cap('administrator', 'view_give_sensitive_data');
128
+			$wp_roles->add_cap('administrator', 'export_give_reports');
129
+			$wp_roles->add_cap('administrator', 'manage_give_settings');
130 130
 
131 131
 			// Add the main post type capabilities.
132 132
 			$capabilities = $this->get_core_caps();
133
-			foreach ( $capabilities as $cap_group ) {
134
-				foreach ( $cap_group as $cap ) {
135
-					$wp_roles->add_cap( 'administrator', $cap );
136
-					$wp_roles->add_cap( 'give_manager', $cap );
137
-					$wp_roles->add_cap( 'give_worker', $cap );
133
+			foreach ($capabilities as $cap_group) {
134
+				foreach ($cap_group as $cap) {
135
+					$wp_roles->add_cap('administrator', $cap);
136
+					$wp_roles->add_cap('give_manager', $cap);
137
+					$wp_roles->add_cap('give_worker', $cap);
138 138
 				}
139 139
 			}
140 140
 
141
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_forms' );
142
-			$wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' );
143
-			$wp_roles->add_cap( 'give_accountant', 'view_give_reports' );
144
-			$wp_roles->add_cap( 'give_accountant', 'export_give_reports' );
145
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_payments' );
141
+			$wp_roles->add_cap('give_accountant', 'edit_give_forms');
142
+			$wp_roles->add_cap('give_accountant', 'read_private_give_forms');
143
+			$wp_roles->add_cap('give_accountant', 'view_give_reports');
144
+			$wp_roles->add_cap('give_accountant', 'export_give_reports');
145
+			$wp_roles->add_cap('give_accountant', 'edit_give_payments');
146 146
 
147 147
 		}
148 148
 	}
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 	public function get_core_caps() {
161 161
 		$capabilities = array();
162 162
 
163
-		$capability_types = array( 'give_form', 'give_payment' );
163
+		$capability_types = array('give_form', 'give_payment');
164 164
 
165
-		foreach ( $capability_types as $capability_type ) {
166
-			$capabilities[ $capability_type ] = array(
165
+		foreach ($capability_types as $capability_type) {
166
+			$capabilities[$capability_type] = array(
167 167
 				// Post type.
168 168
 				"edit_{$capability_type}",
169 169
 				"read_{$capability_type}",
@@ -209,22 +209,22 @@  discard block
 block discarded – undo
209 209
 	 *
210 210
 	 * @return array  $caps    Meta capabilities.
211 211
 	 */
212
-	public function meta_caps( $caps, $cap, $user_id, $args ) {
212
+	public function meta_caps($caps, $cap, $user_id, $args) {
213 213
 
214
-		switch ( $cap ) {
214
+		switch ($cap) {
215 215
 
216 216
 			case 'view_give_form_stats' :
217 217
 
218
-				if ( empty( $args[0] ) ) {
218
+				if (empty($args[0])) {
219 219
 					break;
220 220
 				}
221 221
 
222
-				$form = get_post( $args[0] );
223
-				if ( empty( $form ) ) {
222
+				$form = get_post($args[0]);
223
+				if (empty($form)) {
224 224
 					break;
225 225
 				}
226 226
 
227
-				if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) {
227
+				if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) {
228 228
 					$caps = array();
229 229
 				}
230 230
 
@@ -251,41 +251,41 @@  discard block
 block discarded – undo
251 251
 
252 252
 		global $wp_roles;
253 253
 
254
-		if ( class_exists( 'WP_Roles' ) ) {
255
-			if ( ! isset( $wp_roles ) ) {
254
+		if (class_exists('WP_Roles')) {
255
+			if ( ! isset($wp_roles)) {
256 256
 				$wp_roles = new WP_Roles();
257 257
 			}
258 258
 		}
259 259
 
260
-		if ( is_object( $wp_roles ) ) {
260
+		if (is_object($wp_roles)) {
261 261
 			// Give Manager Capabilities.
262
-			$wp_roles->remove_cap( 'give_manager', 'view_give_reports' );
263
-			$wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' );
264
-			$wp_roles->remove_cap( 'give_manager', 'export_give_reports' );
265
-			$wp_roles->remove_cap( 'give_manager', 'manage_give_settings' );
262
+			$wp_roles->remove_cap('give_manager', 'view_give_reports');
263
+			$wp_roles->remove_cap('give_manager', 'view_give_sensitive_data');
264
+			$wp_roles->remove_cap('give_manager', 'export_give_reports');
265
+			$wp_roles->remove_cap('give_manager', 'manage_give_settings');
266 266
 
267 267
 			// Site Administrator Capabilities.
268
-			$wp_roles->remove_cap( 'administrator', 'view_give_reports' );
269
-			$wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' );
270
-			$wp_roles->remove_cap( 'administrator', 'export_give_reports' );
271
-			$wp_roles->remove_cap( 'administrator', 'manage_give_settings' );
268
+			$wp_roles->remove_cap('administrator', 'view_give_reports');
269
+			$wp_roles->remove_cap('administrator', 'view_give_sensitive_data');
270
+			$wp_roles->remove_cap('administrator', 'export_give_reports');
271
+			$wp_roles->remove_cap('administrator', 'manage_give_settings');
272 272
 
273 273
 			// Remove the Main Post Type Capabilities.
274 274
 			$capabilities = $this->get_core_caps();
275 275
 
276
-			foreach ( $capabilities as $cap_group ) {
277
-				foreach ( $cap_group as $cap ) {
278
-					$wp_roles->remove_cap( 'give_manager', $cap );
279
-					$wp_roles->remove_cap( 'administrator', $cap );
280
-					$wp_roles->remove_cap( 'give_worker', $cap );
276
+			foreach ($capabilities as $cap_group) {
277
+				foreach ($cap_group as $cap) {
278
+					$wp_roles->remove_cap('give_manager', $cap);
279
+					$wp_roles->remove_cap('administrator', $cap);
280
+					$wp_roles->remove_cap('give_worker', $cap);
281 281
 				}
282 282
 			}
283 283
 
284 284
 			/** Give Accountant Capabilities */
285
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' );
286
-			$wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' );
287
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_reports' );
288
-			$wp_roles->remove_cap( 'give_accountant', 'export_give_reports' );
285
+			$wp_roles->remove_cap('give_accountant', 'edit_give_forms');
286
+			$wp_roles->remove_cap('give_accountant', 'read_private_give_forms');
287
+			$wp_roles->remove_cap('give_accountant', 'view_give_reports');
288
+			$wp_roles->remove_cap('give_accountant', 'export_give_reports');
289 289
 
290 290
 		}
291 291
 	}
Please login to merge, or discard this patch.
includes/actions.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_get_actions() {
27 27
 
28
-	$_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null;
28
+	$_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null;
29 29
 
30 30
 	// Add backward compatibility to give-action param ( $_GET )
31
-	if(  empty( $_get_action ) ) {
32
-		$_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null;
31
+	if (empty($_get_action)) {
32
+		$_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null;
33 33
 	}
34 34
 
35
-	if ( isset( $_get_action ) ) {
35
+	if (isset($_get_action)) {
36 36
 		/**
37 37
 		 * Fires in WordPress init or admin init, when give_action is present in $_GET.
38 38
 		 *
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @param array $_GET Array of HTTP GET variables.
42 42
 		 */
43
-		do_action( "give_{$_get_action}", $_GET );
43
+		do_action("give_{$_get_action}", $_GET);
44 44
 	}
45 45
 
46 46
 }
47 47
 
48
-add_action( 'init', 'give_get_actions' );
48
+add_action('init', 'give_get_actions');
49 49
 
50 50
 /**
51 51
  * Hooks Give actions, when present in the $_POST super global. Every give_action
@@ -58,15 +58,15 @@  discard block
 block discarded – undo
58 58
  */
59 59
 function give_post_actions() {
60 60
 
61
-	$_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null;
61
+	$_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null;
62 62
 
63 63
 
64 64
 	// Add backward compatibility to give-action param ( $_POST )
65
-	if(  empty( $_post_action ) ) {
66
-		$_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null;
65
+	if (empty($_post_action)) {
66
+		$_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null;
67 67
 	}
68 68
 
69
-	if ( isset( $_post_action ) ) {
69
+	if (isset($_post_action)) {
70 70
 		/**
71 71
 		 * Fires in WordPress init or admin init, when give_action is present in $_POST.
72 72
 		 *
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 		 *
75 75
 		 * @param array $_POST Array of HTTP POST variables.
76 76
 		 */
77
-		do_action( "give_{$_post_action}", $_POST );
77
+		do_action("give_{$_post_action}", $_POST);
78 78
 	}
79 79
 
80 80
 }
81 81
 
82
-add_action( 'init', 'give_post_actions' );
82
+add_action('init', 'give_post_actions');
83 83
 
84 84
 /**
85 85
  * Connect WordPress user with Donor.
@@ -89,28 +89,28 @@  discard block
 block discarded – undo
89 89
  * @param  array $user_data User Data
90 90
  * @return void
91 91
  */
92
-function give_connect_donor_to_wpuser( $user_id, $user_data ){
92
+function give_connect_donor_to_wpuser($user_id, $user_data) {
93 93
 	/* @var Give_Customer $donor */
94
-	$donor = new Give_Customer( $user_data['user_email'] );
94
+	$donor = new Give_Customer($user_data['user_email']);
95 95
 
96 96
 	// Validate donor id and check if do nor is already connect to wp user or not.
97
-	if( $donor->id && ! $donor->user_id ) {
97
+	if ($donor->id && ! $donor->user_id) {
98 98
 
99 99
 		// Update donor user_id.
100
-		if( $donor->update( array( 'user_id' => $user_id ) ) ) {
101
-			$donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id );
102
-			$donor->add_note( $donor_note );
100
+		if ($donor->update(array('user_id' => $user_id))) {
101
+			$donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id);
102
+			$donor->add_note($donor_note);
103 103
 
104 104
 			// Update user_id meta in payments.
105
-			if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) {
106
-				foreach ( $donations as $donation  ) {
107
-					give_update_meta( $donation, '_give_payment_user_id', $user_id );
105
+			if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) {
106
+				foreach ($donations as $donation) {
107
+					give_update_meta($donation, '_give_payment_user_id', $user_id);
108 108
 				}
109 109
 			}
110 110
 		}
111 111
 	}
112 112
 }
113
-add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 );
113
+add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2);
114 114
 
115 115
 
116 116
 /**
@@ -124,24 +124,24 @@  discard block
 block discarded – undo
124 124
 function give_validate_license_when_site_migrated() {
125 125
 	// Store current site address if not already stored.
126 126
 	$homeurl = home_url();
127
-	if( ! get_option( 'give_site_address_before_migrate' ) ) {
127
+	if ( ! get_option('give_site_address_before_migrate')) {
128 128
 		// Update site address.
129
-		update_option( 'give_site_address_before_migrate', $homeurl );
129
+		update_option('give_site_address_before_migrate', $homeurl);
130 130
 
131 131
 		return;
132 132
 	}
133 133
 
134
-	if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) {
134
+	if ($homeurl !== get_option('give_site_address_before_migrate')) {
135 135
 		// Immediately run cron.
136
-		wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' );
136
+		wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated');
137 137
 
138 138
 		// Update site address.
139
-		update_option( 'give_site_address_before_migrate', home_url() );
139
+		update_option('give_site_address_before_migrate', home_url());
140 140
 	}
141 141
 
142 142
 }
143
-add_action( 'init', 'give_validate_license_when_site_migrated' );
144
-add_action( 'admin_init', 'give_validate_license_when_site_migrated' );
143
+add_action('init', 'give_validate_license_when_site_migrated');
144
+add_action('admin_init', 'give_validate_license_when_site_migrated');
145 145
 
146 146
 
147 147
 /**
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
  * @since 1.8
151 151
  * @param $data
152 152
  */
153
-function give_donor_batch_export_complete( $data ) {
153
+function give_donor_batch_export_complete($data) {
154 154
 	// Remove donor ids cache.
155
-	if(
156
-		isset( $data['class'] )
155
+	if (
156
+		isset($data['class'])
157 157
 		&& 'Give_Batch_Customers_Export' === $data['class']
158
-		&& ! empty( $data['forms'] )
159
-		&& isset( $data['give_export_option']['query_id'] )
158
+		&& ! empty($data['forms'])
159
+		&& isset($data['give_export_option']['query_id'])
160 160
 	) {
161
-		Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) );
161
+		Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id']));
162 162
 	}
163 163
 }
164
-add_action('give_file_export_complete', 'give_donor_batch_export_complete' );
164
+add_action('give_file_export_complete', 'give_donor_batch_export_complete');
165 165
 
166 166
 /**
167 167
  * Print css for wordpress setting pages.
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
 	/* @var WP_Screen $screen */
173 173
 	$screen = get_current_screen();
174 174
 
175
-	if( ! ( $screen instanceof WP_Screen ) ) {
175
+	if ( ! ($screen instanceof WP_Screen)) {
176 176
 		return false;
177 177
 	}
178 178
 
179
-	switch ( true ) {
180
-		case ( 'plugins' === $screen->base ):
179
+	switch (true) {
180
+		case ('plugins' === $screen->base):
181 181
 			?>
182 182
 			<style>
183 183
 				tr.active.update + tr.give-addon-notice-tr td{
@@ -210,4 +210,4 @@  discard block
 block discarded – undo
210 210
 			<?php
211 211
 	}
212 212
 }
213
-add_action( 'admin_head', 'give_admin_quick_css' );
213
+add_action('admin_head', 'give_admin_quick_css');
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @global     $wpdb
27 27
  * @return void
28 28
  */
29
-function give_install( $network_wide = false ) {
29
+function give_install($network_wide = false) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( is_multisite() && $network_wide ) {
33
+	if (is_multisite() && $network_wide) {
34 34
 
35
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
35
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
36 36
 
37
-			switch_to_blog( $blog_id );
37
+			switch_to_blog($blog_id);
38 38
 			give_run_install();
39 39
 			restore_current_blog();
40 40
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 }
50 50
 
51
-register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
51
+register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
52 52
 
53 53
 /**
54 54
  * Run the Give Install process.
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
 	give_setup_post_types();
65 65
 
66 66
 	// Clear the permalinks.
67
-	flush_rewrite_rules( false );
67
+	flush_rewrite_rules(false);
68 68
 
69 69
 	// Add Upgraded From Option.
70
-	$current_version = get_option( 'give_version' );
71
-	if ( $current_version ) {
72
-		update_option( 'give_version_upgraded_from', $current_version );
70
+	$current_version = get_option('give_version');
71
+	if ($current_version) {
72
+		update_option('give_version_upgraded_from', $current_version);
73 73
 	}
74 74
 
75 75
 	// Setup some default options.
76 76
 	$options = array();
77 77
 
78 78
 	// Checks if the Success Page option exists AND that the page exists.
79
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
79
+	if ( ! get_post(give_get_option('success_page'))) {
80 80
 
81 81
 		// Donation Confirmation (Success) Page
82 82
 		$success = wp_insert_post(
83 83
 			array(
84
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
84
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
85 85
 				'post_content'   => '[give_receipt]',
86 86
 				'post_status'    => 'publish',
87 87
 				'post_author'    => 1,
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	// Checks if the Failure Page option exists AND that the page exists.
98
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
98
+	if ( ! get_post(give_get_option('failure_page'))) {
99 99
 
100 100
 		// Failed Donation Page
101 101
 		$failed = wp_insert_post(
102 102
 			array(
103
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
104
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
103
+				'post_title'     => esc_html__('Donation Failed', 'give'),
104
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
105 105
 				'post_status'    => 'publish',
106 106
 				'post_author'    => 1,
107 107
 				'post_type'      => 'page',
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 
115 115
 	// Checks if the History Page option exists AND that the page exists.
116
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
116
+	if ( ! get_post(give_get_option('history_page'))) {
117 117
 		// Donation History Page
118 118
 		$history = wp_insert_post(
119 119
 			array(
120
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
120
+				'post_title'     => esc_html__('Donation History', 'give'),
121 121
 				'post_content'   => '[donation_history]',
122 122
 				'post_status'    => 'publish',
123 123
 				'post_author'    => 1,
@@ -130,23 +130,23 @@  discard block
 block discarded – undo
130 130
 	}
131 131
 
132 132
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
133
-	if ( empty( $current_version ) ) {
134
-		$options = array_merge( $options, give_get_default_settings() );
133
+	if (empty($current_version)) {
134
+		$options = array_merge($options, give_get_default_settings());
135 135
 	}
136 136
 
137 137
 	// Populate the default values.
138
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
138
+	update_option('give_settings', array_merge($give_options, $options));
139 139
 
140 140
 	/**
141 141
 	 * Run plugin upgrades.
142 142
 	 *
143 143
 	 * @since 1.8
144 144
 	 */
145
-	do_action( 'give_upgrades' );
145
+	do_action('give_upgrades');
146 146
 
147 147
 
148
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
149
-		update_option( 'give_version', GIVE_VERSION );
148
+	if (GIVE_VERSION !== get_option('give_version')) {
149
+		update_option('give_version', GIVE_VERSION);
150 150
 	}
151 151
 
152 152
 	// Create Give roles.
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	$roles->add_caps();
156 156
 
157 157
 	$api = new Give_API();
158
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
158
+	update_option('give_default_api_version', 'v'.$api->get_version());
159 159
 
160 160
 	// Create the customers databases.
161 161
 	@Give()->customers->create_table();
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 	Give()->session->use_php_sessions();
166 166
 
167 167
 	// Add a temporary option to note that Give pages have been created.
168
-	Give_Cache::set( '_give_installed', $options, 30, true );
168
+	Give_Cache::set('_give_installed', $options, 30, true);
169 169
 
170
-	if ( ! $current_version ) {
170
+	if ( ! $current_version) {
171 171
 
172
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
172
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
173 173
 
174 174
 		// When new upgrade routines are added, mark them as complete on fresh install.
175 175
 		$upgrade_routines = array(
@@ -180,22 +180,22 @@  discard block
 block discarded – undo
180 180
 			'v18_upgrades_form_metadata'
181 181
 		);
182 182
 
183
-		foreach ( $upgrade_routines as $upgrade ) {
184
-			give_set_upgrade_complete( $upgrade );
183
+		foreach ($upgrade_routines as $upgrade) {
184
+			give_set_upgrade_complete($upgrade);
185 185
 		}
186 186
 	}
187 187
 
188 188
 	// Bail if activating from network, or bulk.
189
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
189
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
190 190
 		return;
191 191
 	}
192 192
 
193 193
 	// Add the transient to redirect.
194
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
194
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
195 195
 
196 196
 }
197 197
 
198
-register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
198
+register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
199 199
 
200 200
 /**
201 201
  * Network Activated New Site Setup.
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
  * @param  int $site_id The Site ID.
212 212
  * @param  array $meta Blog Meta.
213 213
  */
214
-function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
214
+function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
215 215
 
216
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
216
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
217 217
 
218
-		switch_to_blog( $blog_id );
218
+		switch_to_blog($blog_id);
219 219
 		give_install();
220 220
 		restore_current_blog();
221 221
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 
224 224
 }
225 225
 
226
-add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 );
226
+add_action('wpmu_new_blog', 'on_create_blog', 10, 6);
227 227
 
228 228
 
229 229
 /**
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
  *
237 237
  * @return array          The tables to drop.
238 238
  */
239
-function give_wpmu_drop_tables( $tables, $blog_id ) {
239
+function give_wpmu_drop_tables($tables, $blog_id) {
240 240
 
241
-	switch_to_blog( $blog_id );
241
+	switch_to_blog($blog_id);
242 242
 	$customers_db     = new Give_DB_Customers();
243 243
 	$customer_meta_db = new Give_DB_Customer_Meta();
244 244
 
245
-	if ( $customers_db->installed() ) {
245
+	if ($customers_db->installed()) {
246 246
 		$tables[] = $customers_db->table_name;
247 247
 		$tables[] = $customer_meta_db->table_name;
248 248
 	}
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
 }
254 254
 
255
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
255
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
256 256
 
257 257
 /**
258 258
  * Post-installation
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
  */
265 265
 function give_after_install() {
266 266
 
267
-	if ( ! is_admin() ) {
267
+	if ( ! is_admin()) {
268 268
 		return;
269 269
 	}
270 270
 
271
-	$give_options     = Give_Cache::get( '_give_installed', true );
272
-	$give_table_check = get_option( '_give_table_check', false );
271
+	$give_options     = Give_Cache::get('_give_installed', true);
272
+	$give_table_check = get_option('_give_table_check', false);
273 273
 
274
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
274
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
275 275
 
276
-		if ( ! @Give()->customer_meta->installed() ) {
276
+		if ( ! @Give()->customer_meta->installed()) {
277 277
 
278 278
 			// Create the customer meta database
279 279
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
 		}
283 283
 
284
-		if ( ! @Give()->customers->installed() ) {
284
+		if ( ! @Give()->customers->installed()) {
285 285
 			// Create the customers database
286 286
 			// (this ensures it creates it on multisite instances where it is network activated).
287 287
 			@Give()->customers->create_table();
@@ -293,22 +293,22 @@  discard block
 block discarded – undo
293 293
 			 *
294 294
 			 * @param array $give_options Give plugin options.
295 295
 			 */
296
-			do_action( 'give_after_install', $give_options );
296
+			do_action('give_after_install', $give_options);
297 297
 		}
298 298
 
299
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
299
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
300 300
 
301 301
 	}
302 302
 
303 303
 	// Delete the transient
304
-	if ( false !== $give_options ) {
305
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
304
+	if (false !== $give_options) {
305
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
306 306
 	}
307 307
 
308 308
 
309 309
 }
310 310
 
311
-add_action( 'admin_init', 'give_after_install' );
311
+add_action('admin_init', 'give_after_install');
312 312
 
313 313
 
314 314
 /**
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
 
324 324
 	global $wp_roles;
325 325
 
326
-	if ( ! is_object( $wp_roles ) ) {
326
+	if ( ! is_object($wp_roles)) {
327 327
 		return;
328 328
 	}
329 329
 
330
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
330
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
331 331
 
332 332
 		// Create Give plugin roles
333 333
 		$roles = new Give_Roles();
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 
339 339
 }
340 340
 
341
-add_action( 'admin_init', 'give_install_roles_on_network' );
341
+add_action('admin_init', 'give_install_roles_on_network');
342 342
 
343 343
 /**
344 344
  * Default core setting values.
@@ -374,14 +374,14 @@  discard block
 block discarded – undo
374 374
 		'uninstall_on_delete'                         => 'disabled',
375 375
 		'the_content_filter'                          => 'enabled',
376 376
 		'scripts_footer'                              => 'disabled',
377
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
377
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
378 378
 		'agreement_text'                              => give_get_default_agreement_text(),
379 379
 
380 380
 		// Paypal IPN verification.
381 381
 		'paypal_verification'                         => 'enabled',
382 382
 
383 383
 		// Default is manual gateway.
384
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
384
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
385 385
 		'default_gateway'                             => 'manual',
386 386
 
387 387
 		// Offline gateway setup.
@@ -406,17 +406,17 @@  discard block
 block discarded – undo
406 406
  */
407 407
 function give_get_default_agreement_text() {
408 408
 
409
-	$org_name = get_bloginfo( 'name' );
409
+	$org_name = get_bloginfo('name');
410 410
 
411
-	$agreement = '<p>Acceptance of any contribution, gift or grant is at the discretion of the ' . $org_name . '. The  ' . $org_name . ' will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  ' . $org_name . '.</p>
411
+	$agreement = '<p>Acceptance of any contribution, gift or grant is at the discretion of the '.$org_name.'. The  '.$org_name.' will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  '.$org_name.'.</p>
412 412
 <p>No irrevocable gift, whether outright or life-income in character, will be accepted if under any reasonable set of circumstances the gift would jeopardize the donor’s financial security.</p>
413
-<p>The ' . $org_name . ' will refrain from providing advice about the tax or other treatment of gifts and will encourage donors to seek guidance from their own professional advisers to assist them in the process of making their donation.</p>
414
-<p>The ' . $org_name . ' will accept donations of cash or publicly traded securities. Gifts of in-kind services will be accepted at the discretion of the ' . $org_name . '.</p>
415
-<p>Certain other gifts, real property, personal property, in-kind gifts, non-liquid securities, and contributions whose sources are not transparent or whose use is restricted in some manner, must be reviewed prior to acceptance due to the special obligations raised or liabilities they may pose for ' . $org_name . '.</p>
416
-<p>The ' . $org_name . ' will provide acknowledgments to donors meeting tax requirements for property received by the charity as a gift. However, except for gifts of cash and publicly traded securities, no value shall be ascribed to any receipt or other form of substantiation of a gift received by ' . $org_name . '.</p>
417
-<p>The ' . $org_name . ' will respect the intent of the donor relating to gifts for restricted purposes and those relating to the desire to remain anonymous. With respect to anonymous gifts, the ' . $org_name . ' will restrict information about the donor to only those staff members with a need to know.</p>
418
-<p>The ' . $org_name . ' will not compensate, whether through commissions, finders\' fees, or other means, any third party for directing a gift or a donor to the ' . $org_name . '.</p>';
419
-
420
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
413
+<p>The ' . $org_name.' will refrain from providing advice about the tax or other treatment of gifts and will encourage donors to seek guidance from their own professional advisers to assist them in the process of making their donation.</p>
414
+<p>The ' . $org_name.' will accept donations of cash or publicly traded securities. Gifts of in-kind services will be accepted at the discretion of the '.$org_name.'.</p>
415
+<p>Certain other gifts, real property, personal property, in-kind gifts, non-liquid securities, and contributions whose sources are not transparent or whose use is restricted in some manner, must be reviewed prior to acceptance due to the special obligations raised or liabilities they may pose for ' . $org_name.'.</p>
416
+<p>The ' . $org_name.' will provide acknowledgments to donors meeting tax requirements for property received by the charity as a gift. However, except for gifts of cash and publicly traded securities, no value shall be ascribed to any receipt or other form of substantiation of a gift received by '.$org_name.'.</p>
417
+<p>The ' . $org_name.' will respect the intent of the donor relating to gifts for restricted purposes and those relating to the desire to remain anonymous. With respect to anonymous gifts, the '.$org_name.' will restrict information about the donor to only those staff members with a need to know.</p>
418
+<p>The ' . $org_name.' will not compensate, whether through commissions, finders\' fees, or other means, any third party for directing a gift or a donor to the '.$org_name.'.</p>';
419
+
420
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
421 421
 
422 422
 }
423 423
\ No newline at end of file
Please login to merge, or discard this patch.