Test Failed
Pull Request — master (#3256)
by Devin
07:52 queued 10s
created
templates/shortcode-login.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@  discard block
 block discarded – undo
4 4
  */
5 5
 
6 6
 
7
-if ( ! is_user_logged_in() ) {
7
+if ( ! is_user_logged_in()) {
8 8
 
9
-	if ( ! empty( $_GET['payment_key'] ) ) {
10
-		$give_login_redirect = add_query_arg( 'payment_key', give_clean( $_GET['payment_key'] ) , give_get_history_page_uri() );
9
+	if ( ! empty($_GET['payment_key'])) {
10
+		$give_login_redirect = add_query_arg('payment_key', give_clean($_GET['payment_key']), give_get_history_page_uri());
11 11
 	}
12 12
 
13 13
 	// Show any error messages after form submission
14
-	Give()->notices->render_frontend_notices( 0 ); ?>
14
+	Give()->notices->render_frontend_notices(0); ?>
15 15
 	<form id="give-login-form" class="give-form" action="" method="post">
16 16
 		<fieldset>
17
-			<legend><?php _e( 'Log into Your Account', 'give' ); ?></legend>
17
+			<legend><?php _e('Log into Your Account', 'give'); ?></legend>
18 18
 			<?php
19 19
 			/**
20 20
 			 * Fires in the login shortcode, before the login fields.
@@ -23,27 +23,27 @@  discard block
 block discarded – undo
23 23
 			 *
24 24
 			 * @since 1.0
25 25
 			 */
26
-			do_action( 'give_login_fields_before' );
26
+			do_action('give_login_fields_before');
27 27
 			?>
28 28
 			<div class="give-login-username give-login">
29
-				<label for="give_user_login"><?php _e( 'Username', 'give' ); ?></label>
29
+				<label for="give_user_login"><?php _e('Username', 'give'); ?></label>
30 30
 				<input name="give_user_login" id="give_user_login" class="give-required give-input" type="text" required aria-required="true" />
31 31
 			</div>
32 32
 
33 33
 			<div class="give-login-password give-login">
34
-				<label for="give_user_pass"><?php _e( 'Password', 'give' ); ?></label>
34
+				<label for="give_user_pass"><?php _e('Password', 'give'); ?></label>
35 35
 				<input name="give_user_pass" id="give_user_pass" class="give-password give-required give-input" type="password" required aria-required="true" />
36 36
 			</div>
37 37
 
38 38
 			<div class="give-login-submit give-login">
39
-				<input type="hidden" name="give_login_redirect" value="<?php echo esc_url( $give_login_redirect ); ?>" />
40
-				<input type="hidden" name="give_login_nonce" value="<?php echo wp_create_nonce( 'give-login-nonce' ); ?>" />
39
+				<input type="hidden" name="give_login_redirect" value="<?php echo esc_url($give_login_redirect); ?>" />
40
+				<input type="hidden" name="give_login_nonce" value="<?php echo wp_create_nonce('give-login-nonce'); ?>" />
41 41
 				<input type="hidden" name="give_action" value="user_login" />
42
-				<input id="give_login_submit" type="submit" class="give_submit" value="<?php _e( 'Log In', 'give' ); ?>" />
42
+				<input id="give_login_submit" type="submit" class="give_submit" value="<?php _e('Log In', 'give'); ?>" />
43 43
 			</div>
44 44
 
45 45
 			<div class="give-lost-password give-login">
46
-				<a href="<?php echo wp_lostpassword_url(); ?>"><?php _e( 'Reset Password', 'give' ); ?></a>
46
+				<a href="<?php echo wp_lostpassword_url(); ?>"><?php _e('Reset Password', 'give'); ?></a>
47 47
 			</div>
48 48
 			<?php
49 49
 			/**
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 			 *
54 54
 			 * @since 1.0
55 55
 			 */
56
-			do_action( 'give_login_fields_after' );
56
+			do_action('give_login_fields_after');
57 57
 			?>
58 58
 		</fieldset>
59 59
 	</form>
60
-<?php } elseif( isset( $_GET['give-login-success'] ) && true === (bool) $_GET['give-login-success'] ) { ?>
61
-	<?php Give()->notices->print_frontend_notice( apply_filters('give_successful_login_message', __( 'Login successful. Welcome!', 'give' )), true, 'success' ); ?>
60
+<?php } elseif (isset($_GET['give-login-success']) && true === (bool) $_GET['give-login-success']) { ?>
61
+	<?php Give()->notices->print_frontend_notice(apply_filters('give_successful_login_message', __('Login successful. Welcome!', 'give')), true, 'success'); ?>
62 62
 <?php } else { ?>
63
-	<?php Give()->notices->print_frontend_notice( apply_filters('give_already_logged_in_message', sprintf( __( 'You are already logged in to the site. <a href="%s">Click here</a> to logout.', 'give' ), esc_url( $give_logout_redirect ) ) ), true, 'warning' ); ?>
63
+	<?php Give()->notices->print_frontend_notice(apply_filters('give_already_logged_in_message', sprintf(__('You are already logged in to the site. <a href="%s">Click here</a> to logout.', 'give'), esc_url($give_logout_redirect))), true, 'warning'); ?>
64 64
 <?php } ?>
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-db-logs.php 1 patch
Spacing   +71 added lines, -73 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
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_logs';
38
+		$this->table_name  = $wpdb->prefix.'give_logs';
39 39
 		$this->primary_key = 'ID';
40 40
 		$this->version     = '1.0';
41 41
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @return array  Default column values.
74 74
 	 */
75 75
 	public function get_column_defaults() {
76
-		$log_create_date     = current_time( 'mysql', 0 );
77
-		$log_create_date_gmt = get_gmt_from_date( $log_create_date );
76
+		$log_create_date     = current_time('mysql', 0);
77
+		$log_create_date_gmt = get_gmt_from_date($log_create_date);
78 78
 
79 79
 		return array(
80 80
 			'ID'           => 0,
@@ -97,39 +97,39 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return bool|int
99 99
 	 */
100
-	public function add( $data = array() ) {
100
+	public function add($data = array()) {
101 101
 		// Valid table columns.
102
-		$table_columns = array_keys( $this->get_columns() );
102
+		$table_columns = array_keys($this->get_columns());
103 103
 
104 104
 		// Filter data.
105
-		foreach ( $data as $table_column => $column_data ) {
106
-			if ( ! in_array( $table_column, $table_columns ) ) {
107
-				unset( $data[ $table_column ] );
105
+		foreach ($data as $table_column => $column_data) {
106
+			if ( ! in_array($table_column, $table_columns)) {
107
+				unset($data[$table_column]);
108 108
 			}
109 109
 		}
110 110
 
111 111
 		// Set default values.
112
-		$current_log_data = wp_parse_args( $data, $this->get_column_defaults() );
112
+		$current_log_data = wp_parse_args($data, $this->get_column_defaults());
113 113
 
114 114
 		// Log parent should be an int.
115
-		$current_log_data['log_parent'] = absint( $current_log_data['log_parent'] );
115
+		$current_log_data['log_parent'] = absint($current_log_data['log_parent']);
116 116
 
117 117
 		// Get log.
118
-		$existing_log = $this->get_log_by( $current_log_data['ID'] );
118
+		$existing_log = $this->get_log_by($current_log_data['ID']);
119 119
 
120 120
 		// Update an existing log.
121
-		if ( $existing_log ) {
121
+		if ($existing_log) {
122 122
 
123 123
 			// Create new log data from existing and new log data.
124
-			$current_log_data = array_merge( $current_log_data, $existing_log );
124
+			$current_log_data = array_merge($current_log_data, $existing_log);
125 125
 
126 126
 			// Update log data.
127
-			$this->update( $current_log_data['ID'], $current_log_data );
127
+			$this->update($current_log_data['ID'], $current_log_data);
128 128
 
129 129
 			$log_id = $current_log_data['ID'];
130 130
 
131 131
 		} else {
132
-			$log_id = $this->insert( $current_log_data, 'log' );
132
+			$log_id = $this->insert($current_log_data, 'log');
133 133
 		}
134 134
 
135 135
 		return $log_id;
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return bool|null|array
149 149
 	 */
150
-	public function get_log_by( $log_id = 0, $by = 'id' ) {
150
+	public function get_log_by($log_id = 0, $by = 'id') {
151 151
 		/* @var WPDB $wpdb */
152 152
 		global $wpdb;
153 153
 		$log = null;
154 154
 
155 155
 		// Make sure $log_id is int.
156
-		$log_id = absint( $log_id );
156
+		$log_id = absint($log_id);
157 157
 
158 158
 		// Bailout.
159
-		if ( empty( $log_id ) ) {
159
+		if (empty($log_id)) {
160 160
 			return null;
161 161
 		}
162 162
 
163
-		switch ( $by ) {
163
+		switch ($by) {
164 164
 			case 'id':
165 165
 				$log = $wpdb->get_row(
166 166
 					$wpdb->prepare(
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 				break;
173 173
 
174 174
 			default:
175
-				$log = apply_filters( "give_get_log_by_{$by}", $log, $log_id );
175
+				$log = apply_filters("give_get_log_by_{$by}", $log, $log_id);
176 176
 		}
177 177
 
178 178
 		return $log;
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return mixed
190 190
 	 */
191
-	public function get_logs( $args = array() ) {
191
+	public function get_logs($args = array()) {
192 192
 		global $wpdb;
193
-		$sql_query = $this->get_sql( $args );
193
+		$sql_query = $this->get_sql($args);
194 194
 		
195 195
 		// Get log.
196
-		if ( ! ( $logs = Give_Cache::get( 'give_logs', true, $sql_query ) ) ) {
197
-			$logs = $wpdb->get_results( $sql_query );
198
-			Give_Cache::set( 'give_logs', $logs, 3600, true, $sql_query );
196
+		if ( ! ($logs = Give_Cache::get('give_logs', true, $sql_query))) {
197
+			$logs = $wpdb->get_results($sql_query);
198
+			Give_Cache::set('give_logs', $logs, 3600, true, $sql_query);
199 199
 		}
200 200
 
201 201
 		return $logs;
@@ -212,21 +212,21 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return int
214 214
 	 */
215
-	public function count( $args = array() ) {
215
+	public function count($args = array()) {
216 216
 		/* @var WPDB $wpdb */
217 217
 		global $wpdb;
218 218
 		$args['number'] = - 1;
219 219
 		$args['fields'] = 'ID';
220 220
 		$args['count']  = true;
221 221
 
222
-		$sql_query = $this->get_sql( $args );
222
+		$sql_query = $this->get_sql($args);
223 223
 
224
-		if ( ! ( $count = Give_Cache::get( 'give_logs_count', true, $sql_query ) ) ) {
225
-			$count = $wpdb->get_var( $sql_query );
226
-			Give_Cache::set( 'give_logs_count', $count, 3600, true, $args );
224
+		if ( ! ($count = Give_Cache::get('give_logs_count', true, $sql_query))) {
225
+			$count = $wpdb->get_var($sql_query);
226
+			Give_Cache::set('give_logs_count', $count, 3600, true, $args);
227 227
 		}
228 228
 		
229
-		return absint( $count );
229
+		return absint($count);
230 230
 	}
231 231
 
232 232
 	/**
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
         PRIMARY KEY  (ID)
253 253
         ) {$charset_collate};";
254 254
 
255
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
256
-		dbDelta( $sql );
255
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
256
+		dbDelta($sql);
257 257
 
258
-		update_option( $this->table_name . '_db_version', $this->version );
258
+		update_option($this->table_name.'_db_version', $this->version);
259 259
 	}
260 260
 
261 261
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 * @return string
271 271
 	 */
272
-	public function get_sql( $args = array() ) {
272
+	public function get_sql($args = array()) {
273 273
 		/* @var WPDB $wpdb */
274 274
 		global $wpdb;
275 275
 
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
 			'count'   => false,
284 284
 		);
285 285
 
286
-		$args = wp_parse_args( $args, $defaults );
286
+		$args = wp_parse_args($args, $defaults);
287 287
 
288 288
 		// validate params.
289
-		$this->validate_params( $args );
289
+		$this->validate_params($args);
290 290
 
291
-		if ( $args['number'] < 1 ) {
291
+		if ($args['number'] < 1) {
292 292
 			$args['number'] = 99999999999;
293 293
 		}
294 294
 
@@ -296,78 +296,78 @@  discard block
 block discarded – undo
296 296
 		$where = '';
297 297
 
298 298
 		// Get sql query for meta.
299
-		if ( ! empty( $args['meta_query'] ) ) {
300
-			$meta_query_object = new WP_Meta_Query( $args['meta_query'] );
301
-			$meta_query        = $meta_query_object->get_sql( 'log', $this->table_name, 'id' );
302
-			$where             = implode( '', $meta_query );
299
+		if ( ! empty($args['meta_query'])) {
300
+			$meta_query_object = new WP_Meta_Query($args['meta_query']);
301
+			$meta_query        = $meta_query_object->get_sql('log', $this->table_name, 'id');
302
+			$where             = implode('', $meta_query);
303 303
 		}
304 304
 
305 305
 		$where .= ' WHERE 1=1 ';
306 306
 
307 307
 		// Set offset.
308
-		if ( empty( $args['offset'] ) && ( 0 < $args['paged'] ) ) {
309
-			$args['offset'] = $args['number'] * ( $args['paged'] - 1 );
308
+		if (empty($args['offset']) && (0 < $args['paged'])) {
309
+			$args['offset'] = $args['number'] * ($args['paged'] - 1);
310 310
 		}
311 311
 
312 312
 		// Set fields.
313 313
 		$fields = "{$this->table_name}.*";
314
-		if ( is_string( $args['fields'] ) && ( 'all' !== $args['fields'] ) ) {
314
+		if (is_string($args['fields']) && ('all' !== $args['fields'])) {
315 315
 			$fields = "{$this->table_name}.{$args['fields']}";
316 316
 		}
317 317
 
318 318
 		// Set count.
319
-		if ( $args['count'] ) {
319
+		if ($args['count']) {
320 320
 			$fields = "COUNT({$fields})";
321 321
 		}
322 322
 
323 323
 		// Specific logs.
324
-		if ( ! empty( $args['ID'] ) ) {
324
+		if ( ! empty($args['ID'])) {
325 325
 
326
-			if ( ! is_array( $args['ID'] ) ) {
327
-				$args['ID'] = explode( ',', $args['ID'] );
326
+			if ( ! is_array($args['ID'])) {
327
+				$args['ID'] = explode(',', $args['ID']);
328 328
 			}
329
-			$log_ids = implode( ',', array_map( 'intval', $args['ID'] ) );
329
+			$log_ids = implode(',', array_map('intval', $args['ID']));
330 330
 
331 331
 			$where .= " AND {$this->table_name}.ID IN( {$log_ids} ) ";
332 332
 		}
333 333
 
334 334
 		// Logs created for a specific date or in a date range
335
-		if ( ! empty( $args['date_query'] ) ) {
336
-			$date_query_object = new WP_Date_Query( $args['date_query'], "{$this->table_name}.log_date" );
337
-			$where             .= $date_query_object->get_sql();
335
+		if ( ! empty($args['date_query'])) {
336
+			$date_query_object = new WP_Date_Query($args['date_query'], "{$this->table_name}.log_date");
337
+			$where .= $date_query_object->get_sql();
338 338
 		}
339 339
 
340 340
 		// Logs create for specific parent.
341
-		if ( ! empty( $args['log_parent'] ) ) {
342
-			if ( ! is_array( $args['log_parent'] ) ) {
343
-				$args['log_parent'] = explode( ',', $args['log_parent'] );
341
+		if ( ! empty($args['log_parent'])) {
342
+			if ( ! is_array($args['log_parent'])) {
343
+				$args['log_parent'] = explode(',', $args['log_parent']);
344 344
 			}
345
-			$parent_ids = implode( ',', array_map( 'intval', $args['log_parent'] ) );
345
+			$parent_ids = implode(',', array_map('intval', $args['log_parent']));
346 346
 
347 347
 			$where .= " AND {$this->table_name}.log_parent IN( {$parent_ids} ) ";
348 348
 		}
349 349
 
350 350
 		// Logs create for specific type.
351 351
 		// is_array check is for backward compatibility.
352
-		if ( ! empty( $args['log_type'] ) && ! is_array( $args['log_type'] ) ) {
353
-			if ( ! is_array( $args['log_type'] ) ) {
354
-				$args['log_type'] = explode( ',', $args['log_type'] );
352
+		if ( ! empty($args['log_type']) && ! is_array($args['log_type'])) {
353
+			if ( ! is_array($args['log_type'])) {
354
+				$args['log_type'] = explode(',', $args['log_type']);
355 355
 			}
356 356
 
357
-			$log_types = implode( '\',\'', array_map( 'trim', $args['log_type'] ) );
357
+			$log_types = implode('\',\'', array_map('trim', $args['log_type']));
358 358
 
359 359
 			$where .= " AND {$this->table_name}.log_type IN( '{$log_types}' ) ";
360 360
 		}
361 361
 
362
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'log_date' : $args['orderby'];
362
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'log_date' : $args['orderby'];
363 363
 
364
-		$args['orderby'] = esc_sql( $args['orderby'] );
365
-		$args['order']   = esc_sql( $args['order'] );
364
+		$args['orderby'] = esc_sql($args['orderby']);
365
+		$args['order']   = esc_sql($args['order']);
366 366
 
367 367
 		return $wpdb->prepare(
368 368
 			"SELECT {$fields} FROM {$this->table_name} {$where} ORDER BY {$this->table_name}.{$args['orderby']} {$args['order']} LIMIT %d,%d;",
369
-			absint( $args['offset'] ),
370
-			absint( $args['number'] )
369
+			absint($args['offset']),
370
+			absint($args['number'])
371 371
 		);
372 372
 	}
373 373
 
@@ -382,13 +382,11 @@  discard block
 block discarded – undo
382 382
 	 *
383 383
 	 * @return mixed
384 384
 	 */
385
-	private function validate_params( &$args ) {
385
+	private function validate_params(&$args) {
386 386
 		// fields params
387 387
 		$args['fields'] = 'ids' === $args['fields'] ?
388
-			'ID' :
389
-			$args['fields'];
390
-		$args['fields'] = array_key_exists( $args['fields'], $this->get_columns() ) ?
391
-			$args['fields'] :
392
-			'all';
388
+			'ID' : $args['fields'];
389
+		$args['fields'] = array_key_exists($args['fields'], $this->get_columns()) ?
390
+			$args['fields'] : 'all';
393 391
 	}
394 392
 }
Please login to merge, or discard this patch.
includes/donors/class-give-donors-query.php 1 patch
Spacing   +53 added lines, -54 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
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param  $args array The array of arguments that can be passed in and used for setting up this payment query.
88 88
 	 */
89
-	public function __construct( $args = array() ) {
89
+	public function __construct($args = array()) {
90 90
 		$defaults = array(
91 91
 			'number'     => 20,
92 92
 			'offset'     => 0,
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			// 'form'       => array(),
105 105
 		);
106 106
 
107
-		$this->args = wp_parse_args( $args, $defaults );
107
+		$this->args = wp_parse_args($args, $defaults);
108 108
 		$this->table_name      = Give()->donors->table_name;
109 109
 		$this->meta_table_name = Give()->donor_meta->table_name;
110 110
 		$this->meta_type       = Give()->donor_meta->meta_type;
@@ -146,21 +146,21 @@  discard block
 block discarded – undo
146 146
 		 *
147 147
 		 * @param Give_Donors_Query $this Donors query object.
148 148
 		 */
149
-		do_action( 'give_pre_get_donors', $this );
149
+		do_action('give_pre_get_donors', $this);
150 150
 
151
-		$cache_key        = Give_Cache::get_key( 'give_donor', $this->get_sql(), false );
151
+		$cache_key = Give_Cache::get_key('give_donor', $this->get_sql(), false);
152 152
 
153 153
 		// Get donors from cache.
154
-		$this->donors = Give_Cache::get_db_query( $cache_key );
154
+		$this->donors = Give_Cache::get_db_query($cache_key);
155 155
 
156
-		if ( is_null( $this->donors  ) ) {
157
-			if ( empty( $this->args['count'] ) ) {
158
-				$this->donors = $wpdb->get_results( $this->get_sql() );
156
+		if (is_null($this->donors)) {
157
+			if (empty($this->args['count'])) {
158
+				$this->donors = $wpdb->get_results($this->get_sql());
159 159
 			} else {
160
-				$this->donors = $wpdb->get_var( $this->get_sql() );
160
+				$this->donors = $wpdb->get_var($this->get_sql());
161 161
 			}
162 162
 
163
-			Give_Cache::set_db_query( $cache_key, $this->donors );
163
+			Give_Cache::set_db_query($cache_key, $this->donors);
164 164
 		}
165 165
 
166 166
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		 *
172 172
 		 * @param Give_Donors_Query $this Donors query object.
173 173
 		 */
174
-		do_action( 'give_post_get_donors', $this );
174
+		do_action('give_post_get_donors', $this);
175 175
 
176 176
 		return $this->donors;
177 177
 	}
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	public function get_sql() {
189 189
 		global $wpdb;
190 190
 
191
-		if ( $this->args['number'] < 1 ) {
191
+		if ($this->args['number'] < 1) {
192 192
 			$this->args['number'] = 99999999999;
193 193
 		}
194 194
 
@@ -196,22 +196,22 @@  discard block
 block discarded – undo
196 196
 
197 197
 
198 198
 		// Set offset.
199
-		if ( empty( $this->args['offset'] ) && ( 0 < $this->args['paged'] ) ) {
200
-			$this->args['offset'] = $this->args['number'] * ( $this->args['paged'] - 1 );
199
+		if (empty($this->args['offset']) && (0 < $this->args['paged'])) {
200
+			$this->args['offset'] = $this->args['number'] * ($this->args['paged'] - 1);
201 201
 		}
202 202
 
203 203
 		// Set fields.
204 204
 		$fields = "{$this->table_name}.*";
205
-		if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) {
206
-			if ( is_string( $this->args['fields'] ) ) {
205
+		if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) {
206
+			if (is_string($this->args['fields'])) {
207 207
 				$fields = "{$this->table_name}.{$this->args['fields']}";
208
-			} elseif ( is_array( $this->args['fields'] ) ) {
209
-				$fields = "{$this->table_name}." . implode( " , {$this->table_name}.", $this->args['fields'] );
208
+			} elseif (is_array($this->args['fields'])) {
209
+				$fields = "{$this->table_name}.".implode(" , {$this->table_name}.", $this->args['fields']);
210 210
 			}
211 211
 		}
212 212
 
213 213
 		// Set count.
214
-		if ( ! empty( $this->args['count'] ) ) {
214
+		if ( ! empty($this->args['count'])) {
215 215
 			$fields = "COUNT({$this->table_name}.id)";
216 216
 		}
217 217
 
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
 
220 220
 		$sql = $wpdb->prepare(
221 221
 			"SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;",
222
-			absint( $this->args['offset'] ),
223
-			absint( $this->args['number'] )
222
+			absint($this->args['offset']),
223
+			absint($this->args['number'])
224 224
 		);
225 225
 
226 226
 		// $where, $orderby and order already prepared query they can generate notice if you re prepare them in above.
227 227
 		// WordPress consider LIKE condition as placeholder if start with s,f, or d.
228
-		$sql = str_replace( 'LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql );
228
+		$sql = str_replace('LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql);
229 229
 
230 230
 		return $sql;
231 231
 	}
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
 		$where = '';
244 244
 
245 245
 		// Get sql query for meta.
246
-		if ( ! empty( $this->args['meta_query'] ) ) {
247
-			$meta_query_object = new WP_Meta_Query( $this->args['meta_query'] );
246
+		if ( ! empty($this->args['meta_query'])) {
247
+			$meta_query_object = new WP_Meta_Query($this->args['meta_query']);
248 248
 			$meta_query        = $meta_query_object->get_sql(
249 249
 				$this->meta_type,
250 250
 				$this->table_name,
251 251
 				'id'
252 252
 			);
253 253
 
254
-			$where = implode( '', $meta_query );
254
+			$where = implode('', $meta_query);
255 255
 		}
256 256
 
257 257
 		$where .= 'WHERE 1=1 ';
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 		$where .= $this->get_where_user();
262 262
 		$where .= $this->get_where_date();
263 263
 
264
-		return trim( $where );
264
+		return trim($where);
265 265
 		
266 266
 	}
267 267
 
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
 
280 280
 		$where = '';
281 281
 
282
-		if ( ! empty( $this->args['email'] ) ) {
282
+		if ( ! empty($this->args['email'])) {
283 283
 
284
-			if ( is_array( $this->args['email'] ) ) {
284
+			if (is_array($this->args['email'])) {
285 285
 
286
-				$emails_count       = count( $this->args['email'] );
287
-				$emails_placeholder = array_fill( 0, $emails_count, '%s' );
288
-				$emails             = implode( ', ', $emails_placeholder );
286
+				$emails_count       = count($this->args['email']);
287
+				$emails_placeholder = array_fill(0, $emails_count, '%s');
288
+				$emails             = implode(', ', $emails_placeholder);
289 289
 
290
-				$where .= $wpdb->prepare( "AND {$this->table_name}.email IN( $emails )", $this->args['email'] );
290
+				$where .= $wpdb->prepare("AND {$this->table_name}.email IN( $emails )", $this->args['email']);
291 291
 			} else {
292
-				$where .= $wpdb->prepare( "AND {$this->table_name}.email = %s", $this->args['email'] );
292
+				$where .= $wpdb->prepare("AND {$this->table_name}.email = %s", $this->args['email']);
293 293
 			}
294 294
 		}
295 295
 
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
 		$where = '';
310 310
 
311 311
 		// Specific donors.
312
-		if ( ! empty( $this->args['donor'] ) ) {
313
-			if ( ! is_array( $this->args['donor'] ) ) {
314
-				$this->args['donor'] = explode( ',', $this->args['donor'] );
312
+		if ( ! empty($this->args['donor'])) {
313
+			if ( ! is_array($this->args['donor'])) {
314
+				$this->args['donor'] = explode(',', $this->args['donor']);
315 315
 			}
316
-			$donor_ids = implode( ',', array_map( 'intval', $this->args['donor'] ) );
316
+			$donor_ids = implode(',', array_map('intval', $this->args['donor']));
317 317
 
318 318
 			$where .= "AND {$this->table_name}.id IN( {$donor_ids} )";
319 319
 		}
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
 		$where = '';
335 335
 
336 336
 		// Donors created for a specific date or in a date range
337
-		if ( ! empty( $this->args['date_query'] ) ) {
337
+		if ( ! empty($this->args['date_query'])) {
338 338
 			$date_query_object = new WP_Date_Query(
339
-				is_array( $this->args['date_query'] ) ? $this->args['date_query'] : wp_parse_args( $this->args['date_query'] ),
339
+				is_array($this->args['date_query']) ? $this->args['date_query'] : wp_parse_args($this->args['date_query']),
340 340
 				"{$this->table_name}.date_created"
341 341
 			);
342 342
 
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
 		$where = '';
372 372
 
373 373
 		// Donors created for a specific date or in a date range
374
-		if ( ! empty( $this->args['s'] ) && false !== strpos( $this->args['s'], ':' ) ) {
375
-			$search_parts = explode( ':', $this->args['s'] );
374
+		if ( ! empty($this->args['s']) && false !== strpos($this->args['s'], ':')) {
375
+			$search_parts = explode(':', $this->args['s']);
376 376
 
377
-			if ( ! empty( $search_parts[0] ) ) {
378
-				switch ( $search_parts[0] ) {
377
+			if ( ! empty($search_parts[0])) {
378
+				switch ($search_parts[0]) {
379 379
 					case 'name':
380 380
 						$where = "AND {$this->table_name}.name LIKE '%{$search_parts[1]}%'";
381 381
 						break;
@@ -403,11 +403,11 @@  discard block
 block discarded – undo
403 403
 		$where = '';
404 404
 
405 405
 		// Donors create for specific wp user.
406
-		if ( ! empty( $this->args['user'] ) ) {
407
-			if ( ! is_array( $this->args['user'] ) ) {
408
-				$this->args['user'] = explode( ',', $this->args['user'] );
406
+		if ( ! empty($this->args['user'])) {
407
+			if ( ! is_array($this->args['user'])) {
408
+				$this->args['user'] = explode(',', $this->args['user']);
409 409
 			}
410
-			$user_ids = implode( ',', array_map( 'intval', $this->args['user'] ) );
410
+			$user_ids = implode(',', array_map('intval', $this->args['user']));
411 411
 
412 412
 			$where .= "AND {$this->table_name}.user_id IN( {$user_ids} )";
413 413
 		}
@@ -426,14 +426,13 @@  discard block
 block discarded – undo
426 426
 	private function get_order_query() {
427 427
 		$table_columns = Give()->donors->get_columns();
428 428
 
429
-		$this->args['orderby'] = ! array_key_exists( $this->args['orderby'], $table_columns ) ?
430
-			'id' :
431
-			$this->args['orderby'];
429
+		$this->args['orderby'] = ! array_key_exists($this->args['orderby'], $table_columns) ?
430
+			'id' : $this->args['orderby'];
432 431
 
433
-		$this->args['orderby'] = esc_sql( $this->args['orderby'] );
434
-		$this->args['order']   = esc_sql( $this->args['order'] );
432
+		$this->args['orderby'] = esc_sql($this->args['orderby']);
433
+		$this->args['order']   = esc_sql($this->args['order']);
435 434
 
436
-		switch ( $table_columns[ $this->args['orderby'] ] ) {
435
+		switch ($table_columns[$this->args['orderby']]) {
437 436
 			case '%d':
438 437
 			case '%f':
439 438
 				$query = "ORDER BY {$this->table_name}.{$this->args['orderby']}+0";
Please login to merge, or discard this patch.
includes/api/class-give-api.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 * @uses   Give_API::invalid_key()
327 327
 	 * @uses   Give_API::invalid_auth()
328 328
 	 * @since  1.1
329
-	 * @return bool
329
+	 * @return false|null
330 330
 	 */
331 331
 	private function validate_request() {
332 332
 		global $wp_query;
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 	 *
723 723
 	 * @param array $args Arguments to override defaults
724 724
 	 *
725
-	 * @return array $dates
725
+	 * @return integer|null $dates
726 726
 	 */
727 727
 	public function get_dates( $args = array() ) {
728 728
 		$dates = array();
Please login to merge, or discard this patch.
Spacing   +525 added lines, -525 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -141,27 +141,27 @@  discard block
 block discarded – undo
141 141
 			'v1' => 'GIVE_API_V1',
142 142
 		);
143 143
 
144
-		foreach ( $this->get_versions() as $version => $class ) {
145
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
144
+		foreach ($this->get_versions() as $version => $class) {
145
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
146 146
 		}
147 147
 
148
-		add_action( 'init', array( $this, 'add_endpoint' ) );
149
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
150
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
151
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
152
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
153
-		add_action( 'personal_options_update', array( $this, 'generate_api_key' ) );
154
-		add_action( 'edit_user_profile_update', array( $this, 'generate_api_key' ) );
155
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
148
+		add_action('init', array($this, 'add_endpoint'));
149
+		add_action('wp', array($this, 'process_query'), - 1);
150
+		add_filter('query_vars', array($this, 'query_vars'));
151
+		add_action('show_user_profile', array($this, 'user_key_field'));
152
+		add_action('edit_user_profile', array($this, 'user_key_field'));
153
+		add_action('personal_options_update', array($this, 'generate_api_key'));
154
+		add_action('edit_user_profile_update', array($this, 'generate_api_key'));
155
+		add_action('give_process_api_key', array($this, 'process_api_key'));
156 156
 
157 157
 		// Setup a backwards compatibility check for user API Keys
158
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
158
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
159 159
 
160 160
 		// Determine if JSON_PRETTY_PRINT is available
161
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
161
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
162 162
 
163 163
 		// Allow API request logging to be turned off
164
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
164
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
165 165
 
166 166
 		// Setup Give_Payment_Stats instance
167 167
 		$this->stats = new Give_Payment_Stats();
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @return mixed
181 181
 	 */
182
-	public function __call( $name, $arguments ) {
182
+	public function __call($name, $arguments) {
183 183
 		$deprecated_function_arr = array(
184 184
 			'get_customers',
185 185
 		);
186 186
 
187
-		if ( in_array( $name, $deprecated_function_arr, true ) ) {
188
-			switch ( $name ) {
187
+		if (in_array($name, $deprecated_function_arr, true)) {
188
+			switch ($name) {
189 189
 				case 'get_customers':
190
-					$args = ! empty( $arguments[0] ) ? $arguments[0] : array();
190
+					$args = ! empty($arguments[0]) ? $arguments[0] : array();
191 191
 
192
-					return $this->get_donors( $args );
192
+					return $this->get_donors($args);
193 193
 			}
194 194
 		}
195 195
 	}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 * @since  1.1
203 203
 	 */
204 204
 	public function add_endpoint() {
205
-		add_rewrite_endpoint( 'give-api', EP_ALL );
205
+		add_rewrite_endpoint('give-api', EP_ALL);
206 206
 	}
207 207
 
208 208
 	/**
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return string[] $vars New query vars
217 217
 	 */
218
-	public function query_vars( $vars ) {
218
+	public function query_vars($vars) {
219 219
 
220 220
 		$vars[] = 'token';
221 221
 		$vars[] = 'key';
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	public function get_default_version() {
268 268
 
269
-		$version = get_option( 'give_default_api_version' );
269
+		$version = get_option('give_default_api_version');
270 270
 
271
-		if ( defined( 'GIVE_API_VERSION' ) ) {
271
+		if (defined('GIVE_API_VERSION')) {
272 272
 			$version = GIVE_API_VERSION;
273
-		} elseif ( ! $version ) {
273
+		} elseif ( ! $version) {
274 274
 			$version = 'v1';
275 275
 		}
276 276
 
@@ -291,14 +291,14 @@  discard block
 block discarded – undo
291 291
 
292 292
 		$version = $wp_query->query_vars['give-api'];
293 293
 
294
-		if ( strpos( $version, '/' ) ) {
294
+		if (strpos($version, '/')) {
295 295
 
296
-			$version = explode( '/', $version );
297
-			$version = strtolower( $version[0] );
296
+			$version = explode('/', $version);
297
+			$version = strtolower($version[0]);
298 298
 
299
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
299
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
300 300
 
301
-			if ( array_key_exists( $version, $this->versions ) ) {
301
+			if (array_key_exists($version, $this->versions)) {
302 302
 
303 303
 				$this->queried_version = $version;
304 304
 
@@ -334,16 +334,16 @@  discard block
 block discarded – undo
334 334
 		$this->override = false;
335 335
 
336 336
 		// Make sure we have both user and api key
337
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] !== 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
337
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] !== 'forms' || ! empty($wp_query->query_vars['token']))) {
338 338
 
339
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
339
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
340 340
 				$this->missing_auth();
341 341
 
342 342
 				return false;
343 343
 			}
344 344
 
345 345
 			// Retrieve the user by public API key and ensure they exist
346
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
346
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
347 347
 
348 348
 				$this->invalid_key();
349 349
 
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
 
352 352
 			} else {
353 353
 
354
-				$token  = urldecode( $wp_query->query_vars['token'] );
355
-				$secret = $this->get_user_secret_key( $user );
356
-				$public = urldecode( $wp_query->query_vars['key'] );
354
+				$token  = urldecode($wp_query->query_vars['token']);
355
+				$secret = $this->get_user_secret_key($user);
356
+				$public = urldecode($wp_query->query_vars['key']);
357 357
 
358
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
358
+				if (hash_equals(md5($secret.$public), $token)) {
359 359
 					$this->is_valid_request = true;
360 360
 				} else {
361 361
 					$this->invalid_auth();
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 				}
365 365
 
366 366
 			}
367
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) {
367
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') {
368 368
 			$this->is_valid_request = true;
369
-			$wp_query->set( 'key', 'public' );
369
+			$wp_query->set('key', 'public');
370 370
 		}
371 371
 	}
372 372
 
@@ -382,25 +382,25 @@  discard block
 block discarded – undo
382 382
 	 *
383 383
 	 * @return bool if user ID is found, false otherwise
384 384
 	 */
385
-	public function get_user( $key = '' ) {
385
+	public function get_user($key = '') {
386 386
 		global $wpdb, $wp_query;
387 387
 
388
-		if ( empty( $key ) ) {
389
-			$key = urldecode( $wp_query->query_vars['key'] );
388
+		if (empty($key)) {
389
+			$key = urldecode($wp_query->query_vars['key']);
390 390
 		}
391 391
 
392
-		if ( empty( $key ) ) {
392
+		if (empty($key)) {
393 393
 			return false;
394 394
 		}
395 395
 
396
-		$user = Give_Cache::get( md5( 'give_api_user_' . $key ), true );
396
+		$user = Give_Cache::get(md5('give_api_user_'.$key), true);
397 397
 
398
-		if ( false === $user ) {
399
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
400
-			Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true );
398
+		if (false === $user) {
399
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
400
+			Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true);
401 401
 		}
402 402
 
403
-		if ( $user != null ) {
403
+		if ($user != null) {
404 404
 			$this->user_id = $user;
405 405
 
406 406
 			return $user;
@@ -416,19 +416,19 @@  discard block
 block discarded – undo
416 416
 	 *
417 417
 	 * @return mixed|null|string
418 418
 	 */
419
-	public function get_user_public_key( $user_id = 0 ) {
419
+	public function get_user_public_key($user_id = 0) {
420 420
 		global $wpdb;
421 421
 
422
-		if ( empty( $user_id ) ) {
422
+		if (empty($user_id)) {
423 423
 			return '';
424 424
 		}
425 425
 
426
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
427
-		$user_public_key = Give_Cache::get( $cache_key, true );
426
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
427
+		$user_public_key = Give_Cache::get($cache_key, true);
428 428
 
429
-		if ( empty( $user_public_key ) ) {
430
-			$user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) );
431
-			Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true );
429
+		if (empty($user_public_key)) {
430
+			$user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id));
431
+			Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true);
432 432
 		}
433 433
 
434 434
 		return $user_public_key;
@@ -441,19 +441,19 @@  discard block
 block discarded – undo
441 441
 	 *
442 442
 	 * @return mixed|null|string
443 443
 	 */
444
-	public function get_user_secret_key( $user_id = 0 ) {
444
+	public function get_user_secret_key($user_id = 0) {
445 445
 		global $wpdb;
446 446
 
447
-		if ( empty( $user_id ) ) {
447
+		if (empty($user_id)) {
448 448
 			return '';
449 449
 		}
450 450
 
451
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
452
-		$user_secret_key = Give_Cache::get( $cache_key, true );
451
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
452
+		$user_secret_key = Give_Cache::get($cache_key, true);
453 453
 
454
-		if ( empty( $user_secret_key ) ) {
455
-			$user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) );
456
-			Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true );
454
+		if (empty($user_secret_key)) {
455
+			$user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id));
456
+			Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true);
457 457
 		}
458 458
 
459 459
 		return $user_secret_key;
@@ -469,10 +469,10 @@  discard block
 block discarded – undo
469 469
 	 */
470 470
 	private function missing_auth() {
471 471
 		$error          = array();
472
-		$error['error'] = __( 'You must specify both a token and API key.', 'give' );
472
+		$error['error'] = __('You must specify both a token and API key.', 'give');
473 473
 
474 474
 		$this->data = $error;
475
-		$this->output( 401 );
475
+		$this->output(401);
476 476
 	}
477 477
 
478 478
 	/**
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
 	 */
487 487
 	private function invalid_auth() {
488 488
 		$error          = array();
489
-		$error['error'] = __( 'Your request could not be authenticated.', 'give' );
489
+		$error['error'] = __('Your request could not be authenticated.', 'give');
490 490
 
491 491
 		$this->data = $error;
492
-		$this->output( 403 );
492
+		$this->output(403);
493 493
 	}
494 494
 
495 495
 	/**
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 	 */
504 504
 	private function invalid_key() {
505 505
 		$error          = array();
506
-		$error['error'] = __( 'Invalid API key.', 'give' );
506
+		$error['error'] = __('Invalid API key.', 'give');
507 507
 
508 508
 		$this->data = $error;
509
-		$this->output( 403 );
509
+		$this->output(403);
510 510
 	}
511 511
 
512 512
 	/**
@@ -519,10 +519,10 @@  discard block
 block discarded – undo
519 519
 	 */
520 520
 	private function invalid_version() {
521 521
 		$error          = array();
522
-		$error['error'] = __( 'Invalid API version.', 'give' );
522
+		$error['error'] = __('Invalid API version.', 'give');
523 523
 
524 524
 		$this->data = $error;
525
-		$this->output( 404 );
525
+		$this->output(404);
526 526
 	}
527 527
 
528 528
 	/**
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
 		global $wp_query;
539 539
 
540 540
 		// Start logging how long the request takes for logging
541
-		$before = microtime( true );
541
+		$before = microtime(true);
542 542
 
543 543
 		// Check for give-api var. Get out if not present
544
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
544
+		if (empty($wp_query->query_vars['give-api'])) {
545 545
 			return;
546 546
 		}
547 547
 
@@ -555,45 +555,45 @@  discard block
 block discarded – undo
555 555
 		$this->validate_request();
556 556
 
557 557
 		// Only proceed if no errors have been noted
558
-		if ( ! $this->is_valid_request ) {
558
+		if ( ! $this->is_valid_request) {
559 559
 			return;
560 560
 		}
561 561
 
562
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
563
-			define( 'GIVE_DOING_API', true );
562
+		if ( ! defined('GIVE_DOING_API')) {
563
+			define('GIVE_DOING_API', true);
564 564
 		}
565 565
 
566 566
 		$data         = array();
567 567
 		$this->routes = new $this->versions[$this->get_queried_version()];
568 568
 		$this->routes->validate_request();
569 569
 
570
-		switch ( $this->endpoint ) :
570
+		switch ($this->endpoint) :
571 571
 
572 572
 			case 'stats' :
573 573
 
574
-				$data = $this->routes->get_stats( array(
575
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
576
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
577
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
578
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
579
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
580
-				) );
574
+				$data = $this->routes->get_stats(array(
575
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
576
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
577
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
578
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
579
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
580
+				));
581 581
 
582 582
 				break;
583 583
 
584 584
 			case 'forms' :
585 585
 
586
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
586
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
587 587
 
588
-				$data = $this->routes->get_forms( $form );
588
+				$data = $this->routes->get_forms($form);
589 589
 
590 590
 				break;
591 591
 
592 592
 			case 'donors' :
593 593
 
594
-				$donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
594
+				$donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
595 595
 
596
-				$data = $this->routes->get_donors( $donor );
596
+				$data = $this->routes->get_donors($donor);
597 597
 
598 598
 				break;
599 599
 
@@ -606,26 +606,26 @@  discard block
 block discarded – undo
606 606
 				 * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
607 607
 				 * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
608 608
 				 */
609
-				$data = $this->routes->get_recent_donations( array(
610
-					'id'        => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
611
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
612
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
613
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
614
-				) );
609
+				$data = $this->routes->get_recent_donations(array(
610
+					'id'        => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
611
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
612
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
613
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
614
+				));
615 615
 
616 616
 				break;
617 617
 
618 618
 		endswitch;
619 619
 
620 620
 		// Allow extensions to setup their own return data
621
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
621
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
622 622
 
623
-		$after                       = microtime( true );
624
-		$request_time                = ( $after - $before );
623
+		$after                       = microtime(true);
624
+		$request_time                = ($after - $before);
625 625
 		$this->data['request_speed'] = $request_time;
626 626
 
627 627
 		// Log this API request, if enabled. We log it here because we have access to errors.
628
-		$this->log_request( $this->data );
628
+		$this->log_request($this->data);
629 629
 
630 630
 		// Send out data to the output function
631 631
 		$this->output();
@@ -655,25 +655,25 @@  discard block
 block discarded – undo
655 655
 		global $wp_query;
656 656
 
657 657
 		// Whitelist our query options
658
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
658
+		$accepted = apply_filters('give_api_valid_query_modes', array(
659 659
 			'stats',
660 660
 			'forms',
661 661
 			'donors',
662 662
 			'donations',
663
-		) );
663
+		));
664 664
 
665
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
666
-		$query = str_replace( $this->queried_version . '/', '', $query );
665
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
666
+		$query = str_replace($this->queried_version.'/', '', $query);
667 667
 
668 668
 		$error = array();
669 669
 
670 670
 		// Make sure our query is valid
671
-		if ( ! in_array( $query, $accepted ) ) {
672
-			$error['error'] = __( 'Invalid query.', 'give' );
671
+		if ( ! in_array($query, $accepted)) {
672
+			$error['error'] = __('Invalid query.', 'give');
673 673
 
674 674
 			$this->data = $error;
675 675
 			// 400 is Bad Request
676
-			$this->output( 400 );
676
+			$this->output(400);
677 677
 		}
678 678
 
679 679
 		$this->endpoint = $query;
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 	public function get_paged() {
691 691
 		global $wp_query;
692 692
 
693
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
693
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
694 694
 	}
695 695
 
696 696
 
@@ -705,13 +705,13 @@  discard block
 block discarded – undo
705 705
 	public function per_page() {
706 706
 		global $wp_query;
707 707
 
708
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
708
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
709 709
 
710
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
710
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
711 711
 			$per_page = 99999999;
712 712
 		} // End if().
713 713
 
714
-		return apply_filters( 'give_api_results_per_page', $per_page );
714
+		return apply_filters('give_api_results_per_page', $per_page);
715 715
 	}
716 716
 
717 717
 	/**
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	 *
725 725
 	 * @return array $dates
726 726
 	 */
727
-	public function get_dates( $args = array() ) {
727
+	public function get_dates($args = array()) {
728 728
 		$dates = array();
729 729
 
730 730
 		$defaults = array(
@@ -735,60 +735,60 @@  discard block
 block discarded – undo
735 735
 			'enddate'   => null,
736 736
 		);
737 737
 
738
-		$args = wp_parse_args( $args, $defaults );
738
+		$args = wp_parse_args($args, $defaults);
739 739
 
740
-		$current_time = current_time( 'timestamp' );
740
+		$current_time = current_time('timestamp');
741 741
 
742
-		if ( 'range' === $args['date'] ) {
743
-			$startdate          = strtotime( $args['startdate'] );
744
-			$enddate            = strtotime( $args['enddate'] );
745
-			$dates['day_start'] = date( 'd', $startdate );
746
-			$dates['day_end']   = date( 'd', $enddate );
747
-			$dates['m_start']   = date( 'n', $startdate );
748
-			$dates['m_end']     = date( 'n', $enddate );
749
-			$dates['year']      = date( 'Y', $startdate );
750
-			$dates['year_end']  = date( 'Y', $enddate );
742
+		if ('range' === $args['date']) {
743
+			$startdate          = strtotime($args['startdate']);
744
+			$enddate            = strtotime($args['enddate']);
745
+			$dates['day_start'] = date('d', $startdate);
746
+			$dates['day_end']   = date('d', $enddate);
747
+			$dates['m_start']   = date('n', $startdate);
748
+			$dates['m_end']     = date('n', $enddate);
749
+			$dates['year']      = date('Y', $startdate);
750
+			$dates['year_end']  = date('Y', $enddate);
751 751
 		} else {
752 752
 			// Modify dates based on predefined ranges
753
-			switch ( $args['date'] ) :
753
+			switch ($args['date']) :
754 754
 
755 755
 				case 'this_month' :
756 756
 					$dates['day']     = null;
757
-					$dates['m_start'] = date( 'n', $current_time );
758
-					$dates['m_end']   = date( 'n', $current_time );
759
-					$dates['year']    = date( 'Y', $current_time );
757
+					$dates['m_start'] = date('n', $current_time);
758
+					$dates['m_end']   = date('n', $current_time);
759
+					$dates['year']    = date('Y', $current_time);
760 760
 					break;
761 761
 
762 762
 				case 'last_month' :
763 763
 					$dates['day']     = null;
764
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
764
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
765 765
 					$dates['m_end']   = $dates['m_start'];
766
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
766
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
767 767
 					break;
768 768
 
769 769
 				case 'today' :
770
-					$dates['day']     = date( 'd', $current_time );
771
-					$dates['m_start'] = date( 'n', $current_time );
772
-					$dates['m_end']   = date( 'n', $current_time );
773
-					$dates['year']    = date( 'Y', $current_time );
770
+					$dates['day']     = date('d', $current_time);
771
+					$dates['m_start'] = date('n', $current_time);
772
+					$dates['m_end']   = date('n', $current_time);
773
+					$dates['year']    = date('Y', $current_time);
774 774
 					break;
775 775
 
776 776
 				case 'yesterday' :
777 777
 
778
-					$year  = date( 'Y', $current_time );
779
-					$month = date( 'n', $current_time );
780
-					$day   = date( 'd', $current_time );
778
+					$year  = date('Y', $current_time);
779
+					$month = date('n', $current_time);
780
+					$day   = date('d', $current_time);
781 781
 
782
-					if ( $month == 1 && $day == 1 ) {
782
+					if ($month == 1 && $day == 1) {
783 783
 
784
-						$year  -= 1;
784
+						$year -= 1;
785 785
 						$month = 12;
786
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
786
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
787 787
 
788
-					} elseif ( $month > 1 && $day == 1 ) {
788
+					} elseif ($month > 1 && $day == 1) {
789 789
 
790 790
 						$month -= 1;
791
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
791
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
792 792
 
793 793
 					} else {
794 794
 
@@ -804,65 +804,65 @@  discard block
 block discarded – undo
804 804
 					break;
805 805
 
806 806
 				case 'this_quarter' :
807
-					$month_now = date( 'n', $current_time );
807
+					$month_now = date('n', $current_time);
808 808
 
809 809
 					$dates['day'] = null;
810 810
 
811
-					if ( $month_now <= 3 ) {
811
+					if ($month_now <= 3) {
812 812
 
813 813
 						$dates['m_start'] = 1;
814 814
 						$dates['m_end']   = 3;
815
-						$dates['year']    = date( 'Y', $current_time );
815
+						$dates['year']    = date('Y', $current_time);
816 816
 
817
-					} elseif ( $month_now <= 6 ) {
817
+					} elseif ($month_now <= 6) {
818 818
 
819 819
 						$dates['m_start'] = 4;
820 820
 						$dates['m_end']   = 6;
821
-						$dates['year']    = date( 'Y', $current_time );
821
+						$dates['year']    = date('Y', $current_time);
822 822
 
823
-					} elseif ( $month_now <= 9 ) {
823
+					} elseif ($month_now <= 9) {
824 824
 
825 825
 						$dates['m_start'] = 7;
826 826
 						$dates['m_end']   = 9;
827
-						$dates['year']    = date( 'Y', $current_time );
827
+						$dates['year']    = date('Y', $current_time);
828 828
 
829 829
 					} else {
830 830
 
831 831
 						$dates['m_start'] = 10;
832 832
 						$dates['m_end']   = 12;
833
-						$dates['year']    = date( 'Y', $current_time );
833
+						$dates['year']    = date('Y', $current_time);
834 834
 
835 835
 					}
836 836
 					break;
837 837
 
838 838
 				case 'last_quarter' :
839
-					$month_now = date( 'n', $current_time );
839
+					$month_now = date('n', $current_time);
840 840
 
841 841
 					$dates['day'] = null;
842 842
 
843
-					if ( $month_now <= 3 ) {
843
+					if ($month_now <= 3) {
844 844
 
845 845
 						$dates['m_start'] = 10;
846 846
 						$dates['m_end']   = 12;
847
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
847
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
848 848
 
849
-					} elseif ( $month_now <= 6 ) {
849
+					} elseif ($month_now <= 6) {
850 850
 
851 851
 						$dates['m_start'] = 1;
852 852
 						$dates['m_end']   = 3;
853
-						$dates['year']    = date( 'Y', $current_time );
853
+						$dates['year']    = date('Y', $current_time);
854 854
 
855
-					} elseif ( $month_now <= 9 ) {
855
+					} elseif ($month_now <= 9) {
856 856
 
857 857
 						$dates['m_start'] = 4;
858 858
 						$dates['m_end']   = 6;
859
-						$dates['year']    = date( 'Y', $current_time );
859
+						$dates['year']    = date('Y', $current_time);
860 860
 
861 861
 					} else {
862 862
 
863 863
 						$dates['m_start'] = 7;
864 864
 						$dates['m_end']   = 9;
865
-						$dates['year']    = date( 'Y', $current_time );
865
+						$dates['year']    = date('Y', $current_time);
866 866
 
867 867
 					}
868 868
 					break;
@@ -871,14 +871,14 @@  discard block
 block discarded – undo
871 871
 					$dates['day']     = null;
872 872
 					$dates['m_start'] = null;
873 873
 					$dates['m_end']   = null;
874
-					$dates['year']    = date( 'Y', $current_time );
874
+					$dates['year']    = date('Y', $current_time);
875 875
 					break;
876 876
 
877 877
 				case 'last_year' :
878 878
 					$dates['day']     = null;
879 879
 					$dates['m_start'] = null;
880 880
 					$dates['m_end']   = null;
881
-					$dates['year']    = date( 'Y', $current_time ) - 1;
881
+					$dates['year']    = date('Y', $current_time) - 1;
882 882
 					break;
883 883
 
884 884
 			endswitch;
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 		 *
892 892
 		 * @param array $dates The dates used for retrieving earnings.
893 893
 		 */
894
-		return apply_filters( 'give_api_stat_dates', $dates );
894
+		return apply_filters('give_api_stat_dates', $dates);
895 895
 	}
896 896
 
897 897
 	/**
@@ -905,84 +905,84 @@  discard block
 block discarded – undo
905 905
 	 *
906 906
 	 * @return array $donors Multidimensional array of the donors.
907 907
 	 */
908
-	public function get_donors( $donor = null ) {
908
+	public function get_donors($donor = null) {
909 909
 
910 910
 		$donors = array();
911 911
 		$error  = array();
912
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
912
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
913 913
 			return $donors;
914 914
 		}
915 915
 
916 916
 		$paged    = $this->get_paged();
917 917
 		$per_page = $this->per_page();
918
-		$offset   = $per_page * ( $paged - 1 );
918
+		$offset   = $per_page * ($paged - 1);
919 919
 
920
-		if ( is_numeric( $donor ) ) {
920
+		if (is_numeric($donor)) {
921 921
 			$field = 'id';
922 922
 		} else {
923 923
 			$field = 'email';
924 924
 		}
925 925
 
926
-		$donor_query = Give()->donors->get_donors( array(
926
+		$donor_query = Give()->donors->get_donors(array(
927 927
 			'number' => $per_page,
928 928
 			'offset' => $offset,
929 929
 			$field   => $donor,
930
-		) );
930
+		));
931 931
 		$donor_count = 0;
932 932
 
933
-		if ( $donor_query ) {
933
+		if ($donor_query) {
934 934
 
935
-			foreach ( $donor_query as $donor_obj ) {
935
+			foreach ($donor_query as $donor_obj) {
936 936
 
937
-				$names      = explode( ' ', $donor_obj->name );
938
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
937
+				$names      = explode(' ', $donor_obj->name);
938
+				$first_name = ! empty($names[0]) ? $names[0] : '';
939 939
 				$last_name  = '';
940
-				if ( ! empty( $names[1] ) ) {
941
-					unset( $names[0] );
942
-					$last_name = implode( ' ', $names );
940
+				if ( ! empty($names[1])) {
941
+					unset($names[0]);
942
+					$last_name = implode(' ', $names);
943 943
 				}
944 944
 
945
-				$donors['donors'][ $donor_count ]['info']['user_id']      = '';
946
-				$donors['donors'][ $donor_count ]['info']['username']     = '';
947
-				$donors['donors'][ $donor_count ]['info']['display_name'] = '';
948
-				$donors['donors'][ $donor_count ]['info']['donor_id']     = $donor_obj->id;
949
-				$donors['donors'][ $donor_count ]['info']['first_name']   = $first_name;
950
-				$donors['donors'][ $donor_count ]['info']['last_name']    = $last_name;
951
-				$donors['donors'][ $donor_count ]['info']['email']        = $donor_obj->email;
945
+				$donors['donors'][$donor_count]['info']['user_id']      = '';
946
+				$donors['donors'][$donor_count]['info']['username']     = '';
947
+				$donors['donors'][$donor_count]['info']['display_name'] = '';
948
+				$donors['donors'][$donor_count]['info']['donor_id']     = $donor_obj->id;
949
+				$donors['donors'][$donor_count]['info']['first_name']   = $first_name;
950
+				$donors['donors'][$donor_count]['info']['last_name']    = $last_name;
951
+				$donors['donors'][$donor_count]['info']['email']        = $donor_obj->email;
952 952
 
953
-				if ( ! empty( $donor_obj->user_id ) ) {
953
+				if ( ! empty($donor_obj->user_id)) {
954 954
 
955
-					$user_data = get_userdata( $donor_obj->user_id );
955
+					$user_data = get_userdata($donor_obj->user_id);
956 956
 
957 957
 					// Donor with registered account.
958
-					$donors['donors'][ $donor_count ]['info']['user_id']      = $donor_obj->user_id;
959
-					$donors['donors'][ $donor_count ]['info']['username']     = $user_data->user_login;
960
-					$donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name;
958
+					$donors['donors'][$donor_count]['info']['user_id']      = $donor_obj->user_id;
959
+					$donors['donors'][$donor_count]['info']['username']     = $user_data->user_login;
960
+					$donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name;
961 961
 
962 962
 				}
963 963
 
964
-				$donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count;
965
-				$donors['donors'][ $donor_count ]['stats']['total_spent']     = $donor_obj->purchase_value;
964
+				$donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count;
965
+				$donors['donors'][$donor_count]['stats']['total_spent']     = $donor_obj->purchase_value;
966 966
 
967 967
 				/** @var $donor \Give_Donor */
968
-				$donor = new Give_Donor( $donor_obj->id );
968
+				$donor = new Give_Donor($donor_obj->id);
969 969
 
970 970
 				// Get donor's addresses.
971
-				$donors['donors'][ $donor_count ]['address'] = $donor->address;
971
+				$donors['donors'][$donor_count]['address'] = $donor->address;
972 972
 
973
-				$donor_count ++;
973
+				$donor_count++;
974 974
 
975 975
 			}
976
-		} elseif ( $donor ) {
976
+		} elseif ($donor) {
977 977
 
978 978
 			$error['error'] = sprintf( /* translators: %s: donor */
979
-				__( 'Donor %s not found.', 'give' ), $donor );
979
+				__('Donor %s not found.', 'give'), $donor );
980 980
 
981 981
 			return $error;
982 982
 
983 983
 		} else {
984 984
 
985
-			$error['error'] = __( 'No donors found.', 'give' );
985
+			$error['error'] = __('No donors found.', 'give');
986 986
 
987 987
 			return $error;
988 988
 
@@ -1001,37 +1001,37 @@  discard block
 block discarded – undo
1001 1001
 	 *
1002 1002
 	 * @return array $donors Multidimensional array of the forms.
1003 1003
 	 */
1004
-	public function get_forms( $form = null ) {
1004
+	public function get_forms($form = null) {
1005 1005
 
1006 1006
 		$forms = array();
1007 1007
 		$error = array();
1008 1008
 
1009
-		if ( $form == null ) {
1009
+		if ($form == null) {
1010 1010
 			$forms['forms'] = array();
1011 1011
 
1012
-			$form_list = get_posts( array(
1012
+			$form_list = get_posts(array(
1013 1013
 				'post_type'        => 'give_forms',
1014 1014
 				'posts_per_page'   => $this->per_page(),
1015 1015
 				'suppress_filters' => true,
1016 1016
 				'paged'            => $this->get_paged(),
1017
-			) );
1017
+			));
1018 1018
 
1019
-			if ( $form_list ) {
1019
+			if ($form_list) {
1020 1020
 				$i = 0;
1021
-				foreach ( $form_list as $form_info ) {
1022
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
1023
-					$i ++;
1021
+				foreach ($form_list as $form_info) {
1022
+					$forms['forms'][$i] = $this->get_form_data($form_info);
1023
+					$i++;
1024 1024
 				}
1025 1025
 			}
1026 1026
 		} else {
1027
-			if ( get_post_type( $form ) == 'give_forms' ) {
1028
-				$form_info = get_post( $form );
1027
+			if (get_post_type($form) == 'give_forms') {
1028
+				$form_info = get_post($form);
1029 1029
 
1030
-				$forms['forms'][0] = $this->get_form_data( $form_info );
1030
+				$forms['forms'][0] = $this->get_form_data($form_info);
1031 1031
 
1032 1032
 			} else {
1033 1033
 				$error['error'] = sprintf( /* translators: %s: form */
1034
-					__( 'Form %s not found.', 'give' ), $form );
1034
+					__('Form %s not found.', 'give'), $form );
1035 1035
 
1036 1036
 				return $error;
1037 1037
 			}
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 	 *
1050 1050
 	 * @return array                Array of post data to return back in the API.
1051 1051
 	 */
1052
-	private function get_form_data( $form_info ) {
1052
+	private function get_form_data($form_info) {
1053 1053
 
1054 1054
 		$form = array();
1055 1055
 
@@ -1059,60 +1059,60 @@  discard block
 block discarded – undo
1059 1059
 		$form['info']['create_date']   = $form_info->post_date;
1060 1060
 		$form['info']['modified_date'] = $form_info->post_modified;
1061 1061
 		$form['info']['status']        = $form_info->post_status;
1062
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1063
-		$form['info']['content']       = give_get_meta( $form_info->ID, '_give_form_content', true );
1064
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1062
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1063
+		$form['info']['content']       = give_get_meta($form_info->ID, '_give_form_content', true);
1064
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1065 1065
 
1066
-		if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
1067
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1068
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1066
+		if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) {
1067
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1068
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1069 1069
 		}
1070
-		if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) {
1071
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1070
+		if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) {
1071
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1072 1072
 		}
1073 1073
 
1074 1074
 		// Check whether any goal is to be achieved for the donation form.
1075
-		$goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true );
1076
-		$goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true );
1077
-		if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) {
1078
-			$total_income                         = give_get_form_earnings_stats( $form_info->ID );
1079
-			$goal_percentage_completed            = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100;
1080
-			$form['goal']['amount']               = isset( $goal_amount ) ? $goal_amount : '';
1081
-			$form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : '';
1075
+		$goal_option = give_get_meta($form_info->ID, '_give_goal_option', true);
1076
+		$goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true);
1077
+		if (give_is_setting_enabled($goal_option) && $goal_amount) {
1078
+			$total_income                         = give_get_form_earnings_stats($form_info->ID);
1079
+			$goal_percentage_completed            = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100;
1080
+			$form['goal']['amount']               = isset($goal_amount) ? $goal_amount : '';
1081
+			$form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : '';
1082 1082
 		}
1083 1083
 
1084
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1085
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1086
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1087
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1088
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1084
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1085
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1086
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1087
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1088
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1089 1089
 		}
1090 1090
 
1091 1091
 		$counter = 0;
1092
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1093
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1094
-				$counter ++;
1092
+		if (give_has_variable_prices($form_info->ID)) {
1093
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1094
+				$counter++;
1095 1095
 				// multi-level item
1096
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1097
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1096
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1097
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1098 1098
 
1099 1099
 			}
1100 1100
 		} else {
1101
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1101
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1102 1102
 		}
1103 1103
 
1104
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1104
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1105 1105
 
1106 1106
 			/**
1107 1107
 			 * Fires when generating API sensitive data.
1108 1108
 			 *
1109 1109
 			 * @since 1.1
1110 1110
 			 */
1111
-			do_action( 'give_api_sensitive_data' );
1111
+			do_action('give_api_sensitive_data');
1112 1112
 
1113 1113
 		}
1114 1114
 
1115
-		return apply_filters( 'give_api_forms_form', $form );
1115
+		return apply_filters('give_api_forms_form', $form);
1116 1116
 
1117 1117
 	}
1118 1118
 
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 	 *
1128 1128
 	 * @return array
1129 1129
 	 */
1130
-	public function get_stats( $args = array() ) {
1130
+	public function get_stats($args = array()) {
1131 1131
 		$defaults = array(
1132 1132
 			'type'      => null,
1133 1133
 			'form'      => null,
@@ -1136,9 +1136,9 @@  discard block
 block discarded – undo
1136 1136
 			'enddate'   => null,
1137 1137
 		);
1138 1138
 
1139
-		$args = wp_parse_args( $args, $defaults );
1139
+		$args = wp_parse_args($args, $defaults);
1140 1140
 
1141
-		$dates = $this->get_dates( $args );
1141
+		$dates = $this->get_dates($args);
1142 1142
 
1143 1143
 		$stats     = array();
1144 1144
 		$earnings  = array(
@@ -1149,40 +1149,40 @@  discard block
 block discarded – undo
1149 1149
 		);
1150 1150
 		$error     = array();
1151 1151
 
1152
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1152
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1153 1153
 			return $stats;
1154 1154
 		}
1155 1155
 
1156
-		if ( $args['type'] == 'donations' ) {
1156
+		if ($args['type'] == 'donations') {
1157 1157
 
1158
-			if ( $args['form'] == null ) {
1159
-				if ( $args['date'] == null ) {
1158
+			if ($args['form'] == null) {
1159
+				if ($args['date'] == null) {
1160 1160
 					$donations = $this->get_default_sales_stats();
1161
-				} elseif ( $args['date'] === 'range' ) {
1161
+				} elseif ($args['date'] === 'range') {
1162 1162
 					// Return donations for a date range.
1163 1163
 					// Ensure the end date is later than the start date.
1164
-					if ( $args['enddate'] < $args['startdate'] ) {
1165
-						$error['error'] = __( 'The end date must be later than the start date.', 'give' );
1164
+					if ($args['enddate'] < $args['startdate']) {
1165
+						$error['error'] = __('The end date must be later than the start date.', 'give');
1166 1166
 					}
1167 1167
 
1168 1168
 					// Ensure both the start and end date are specified
1169
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1170
-						$error['error'] = __( 'Invalid or no date range specified.', 'give' );
1169
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1170
+						$error['error'] = __('Invalid or no date range specified.', 'give');
1171 1171
 					}
1172 1172
 
1173 1173
 					$total = 0;
1174 1174
 
1175 1175
 					// Loop through the years
1176 1176
 					$y = $dates['year'];
1177
-					while ( $y <= $dates['year_end'] ) :
1177
+					while ($y <= $dates['year_end']) :
1178 1178
 
1179
-						if ( $dates['year'] == $dates['year_end'] ) {
1179
+						if ($dates['year'] == $dates['year_end']) {
1180 1180
 							$month_start = $dates['m_start'];
1181 1181
 							$month_end   = $dates['m_end'];
1182
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1182
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1183 1183
 							$month_start = $dates['m_start'];
1184 1184
 							$month_end   = 12;
1185
-						} elseif ( $y == $dates['year_end'] ) {
1185
+						} elseif ($y == $dates['year_end']) {
1186 1186
 							$month_start = 1;
1187 1187
 							$month_end   = $dates['m_end'];
1188 1188
 						} else {
@@ -1191,116 +1191,116 @@  discard block
 block discarded – undo
1191 1191
 						}
1192 1192
 
1193 1193
 						$i = $month_start;
1194
-						while ( $i <= $month_end ) :
1194
+						while ($i <= $month_end) :
1195 1195
 
1196
-							if ( $i == $dates['m_start'] ) {
1196
+							if ($i == $dates['m_start']) {
1197 1197
 								$d = $dates['day_start'];
1198 1198
 							} else {
1199 1199
 								$d = 1;
1200 1200
 							}
1201 1201
 
1202
-							if ( $i == $dates['m_end'] ) {
1202
+							if ($i == $dates['m_end']) {
1203 1203
 								$num_of_days = $dates['day_end'];
1204 1204
 							} else {
1205
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1205
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1206 1206
 							}
1207 1207
 
1208
-							while ( $d <= $num_of_days ) :
1209
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1210
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1211
-								if ( ! isset( $donations['sales'][ $date_key ] ) ) {
1212
-									$donations['sales'][ $date_key ] = 0;
1208
+							while ($d <= $num_of_days) :
1209
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1210
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1211
+								if ( ! isset($donations['sales'][$date_key])) {
1212
+									$donations['sales'][$date_key] = 0;
1213 1213
 								}
1214
-								$donations['sales'][ $date_key ] += $sale_count;
1214
+								$donations['sales'][$date_key] += $sale_count;
1215 1215
 								$total                           += $sale_count;
1216
-								$d ++;
1216
+								$d++;
1217 1217
 							endwhile;
1218
-							$i ++;
1218
+							$i++;
1219 1219
 						endwhile;
1220 1220
 
1221
-						$y ++;
1221
+						$y++;
1222 1222
 					endwhile;
1223 1223
 
1224 1224
 					$donations['totals'] = $total;
1225 1225
 				} else {
1226
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1226
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1227 1227
 						$donations_count = 0;
1228 1228
 
1229 1229
 						// Loop through the months
1230 1230
 						$month = $dates['m_start'];
1231 1231
 
1232
-						while ( $month <= $dates['m_end'] ) :
1233
-							$donations_count += give_get_sales_by_date( null, $month, $dates['year'] );
1234
-							$month ++;
1232
+						while ($month <= $dates['m_end']) :
1233
+							$donations_count += give_get_sales_by_date(null, $month, $dates['year']);
1234
+							$month++;
1235 1235
 						endwhile;
1236 1236
 
1237
-						$donations['donations'][ $args['date'] ] = $donations_count;
1237
+						$donations['donations'][$args['date']] = $donations_count;
1238 1238
 					} else {
1239
-						$donations['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1239
+						$donations['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1240 1240
 					}
1241 1241
 				}// End if().
1242
-			} elseif ( $args['form'] == 'all' ) {
1243
-				$forms = get_posts( array(
1242
+			} elseif ($args['form'] == 'all') {
1243
+				$forms = get_posts(array(
1244 1244
 					'post_type' => 'give_forms',
1245 1245
 					'nopaging'  => true,
1246
-				) );
1247
-				$i     = 0;
1248
-				foreach ( $forms as $form_info ) {
1249
-					$donations['donations'][ $i ] = array(
1250
-						$form_info->post_name => give_get_form_sales_stats( $form_info->ID ),
1246
+				));
1247
+				$i = 0;
1248
+				foreach ($forms as $form_info) {
1249
+					$donations['donations'][$i] = array(
1250
+						$form_info->post_name => give_get_form_sales_stats($form_info->ID),
1251 1251
 					);
1252
-					$i ++;
1252
+					$i++;
1253 1253
 				}
1254 1254
 			} else {
1255
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1256
-					$form_info                 = get_post( $args['form'] );
1255
+				if (get_post_type($args['form']) == 'give_forms') {
1256
+					$form_info                 = get_post($args['form']);
1257 1257
 					$donations['donations'][0] = array(
1258
-						$form_info->post_name => give_get_form_sales_stats( $args['form'] ),
1258
+						$form_info->post_name => give_get_form_sales_stats($args['form']),
1259 1259
 					);
1260 1260
 				} else {
1261 1261
 					$error['error'] = sprintf( /* translators: %s: form */
1262
-						__( 'Form %s not found.', 'give' ), $args['form'] );
1262
+						__('Form %s not found.', 'give'), $args['form'] );
1263 1263
 				}
1264 1264
 			}// End if().
1265 1265
 
1266
-			if ( ! empty( $error ) ) {
1266
+			if ( ! empty($error)) {
1267 1267
 				return $error;
1268 1268
 			}
1269 1269
 
1270 1270
 			return $donations;
1271 1271
 
1272
-		} elseif ( $args['type'] == 'earnings' ) {
1273
-			if ( $args['form'] == null ) {
1274
-				if ( $args['date'] == null ) {
1272
+		} elseif ($args['type'] == 'earnings') {
1273
+			if ($args['form'] == null) {
1274
+				if ($args['date'] == null) {
1275 1275
 					$earnings = $this->get_default_earnings_stats();
1276
-				} elseif ( $args['date'] === 'range' ) {
1276
+				} elseif ($args['date'] === 'range') {
1277 1277
 					// Return sales for a date range
1278 1278
 					// Ensure the end date is later than the start date
1279
-					if ( $args['enddate'] < $args['startdate'] ) {
1280
-						$error['error'] = __( 'The end date must be later than the start date.', 'give' );
1279
+					if ($args['enddate'] < $args['startdate']) {
1280
+						$error['error'] = __('The end date must be later than the start date.', 'give');
1281 1281
 					}
1282 1282
 
1283 1283
 					// Ensure both the start and end date are specified
1284
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1285
-						$error['error'] = __( 'Invalid or no date range specified.', 'give' );
1284
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1285
+						$error['error'] = __('Invalid or no date range specified.', 'give');
1286 1286
 					}
1287 1287
 
1288 1288
 					$total = (float) 0.00;
1289 1289
 
1290 1290
 					// Loop through the years
1291 1291
 					$y = $dates['year'];
1292
-					if ( ! isset( $earnings['earnings'] ) ) {
1292
+					if ( ! isset($earnings['earnings'])) {
1293 1293
 						$earnings['earnings'] = array();
1294 1294
 					}
1295
-					while ( $y <= $dates['year_end'] ) :
1295
+					while ($y <= $dates['year_end']) :
1296 1296
 
1297
-						if ( $dates['year'] == $dates['year_end'] ) {
1297
+						if ($dates['year'] == $dates['year_end']) {
1298 1298
 							$month_start = $dates['m_start'];
1299 1299
 							$month_end   = $dates['m_end'];
1300
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1300
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1301 1301
 							$month_start = $dates['m_start'];
1302 1302
 							$month_end   = 12;
1303
-						} elseif ( $y == $dates['year_end'] ) {
1303
+						} elseif ($y == $dates['year_end']) {
1304 1304
 							$month_start = 1;
1305 1305
 							$month_end   = $dates['m_end'];
1306 1306
 						} else {
@@ -1309,102 +1309,102 @@  discard block
 block discarded – undo
1309 1309
 						}
1310 1310
 
1311 1311
 						$i = $month_start;
1312
-						while ( $i <= $month_end ) :
1312
+						while ($i <= $month_end) :
1313 1313
 
1314
-							if ( $i == $dates['m_start'] ) {
1314
+							if ($i == $dates['m_start']) {
1315 1315
 								$d = $dates['day_start'];
1316 1316
 							} else {
1317 1317
 								$d = 1;
1318 1318
 							}
1319 1319
 
1320
-							if ( $i == $dates['m_end'] ) {
1320
+							if ($i == $dates['m_end']) {
1321 1321
 								$num_of_days = $dates['day_end'];
1322 1322
 							} else {
1323
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1323
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1324 1324
 							}
1325 1325
 
1326
-							while ( $d <= $num_of_days ) :
1327
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1328
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1329
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1330
-									$earnings['earnings'][ $date_key ] = 0;
1326
+							while ($d <= $num_of_days) :
1327
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1328
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1329
+								if ( ! isset($earnings['earnings'][$date_key])) {
1330
+									$earnings['earnings'][$date_key] = 0;
1331 1331
 								}
1332
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1332
+								$earnings['earnings'][$date_key] += $earnings_stat;
1333 1333
 								$total                             += $earnings_stat;
1334
-								$d ++;
1334
+								$d++;
1335 1335
 							endwhile;
1336 1336
 
1337
-							$i ++;
1337
+							$i++;
1338 1338
 						endwhile;
1339 1339
 
1340
-						$y ++;
1340
+						$y++;
1341 1341
 					endwhile;
1342 1342
 
1343 1343
 					$earnings['totals'] = $total;
1344 1344
 				} else {
1345
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1345
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1346 1346
 						$earnings_count = (float) 0.00;
1347 1347
 
1348 1348
 						// Loop through the months
1349 1349
 						$month = $dates['m_start'];
1350 1350
 
1351
-						while ( $month <= $dates['m_end'] ) :
1352
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1353
-							$month ++;
1351
+						while ($month <= $dates['m_end']) :
1352
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1353
+							$month++;
1354 1354
 						endwhile;
1355 1355
 
1356
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1356
+						$earnings['earnings'][$args['date']] = $earnings_count;
1357 1357
 					} else {
1358
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1358
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1359 1359
 					}
1360 1360
 				}// End if().
1361
-			} elseif ( $args['form'] == 'all' ) {
1362
-				$forms = get_posts( array(
1361
+			} elseif ($args['form'] == 'all') {
1362
+				$forms = get_posts(array(
1363 1363
 					'post_type' => 'give_forms',
1364 1364
 					'nopaging'  => true,
1365
-				) );
1365
+				));
1366 1366
 
1367 1367
 				$i = 0;
1368
-				foreach ( $forms as $form_info ) {
1369
-					$earnings['earnings'][ $i ] = array(
1370
-						$form_info->post_name => give_get_form_earnings_stats( $form_info->ID ),
1368
+				foreach ($forms as $form_info) {
1369
+					$earnings['earnings'][$i] = array(
1370
+						$form_info->post_name => give_get_form_earnings_stats($form_info->ID),
1371 1371
 					);
1372
-					$i ++;
1372
+					$i++;
1373 1373
 				}
1374 1374
 			} else {
1375
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1376
-					$form_info               = get_post( $args['form'] );
1375
+				if (get_post_type($args['form']) == 'give_forms') {
1376
+					$form_info               = get_post($args['form']);
1377 1377
 					$earnings['earnings'][0] = array(
1378 1378
 						$form_info->post_name => $this->stats->get_earnings(
1379 1379
 								$args['form'],
1380
-								is_numeric( $args['startdate'] )
1381
-									? strtotime( $args['startdate'] )
1380
+								is_numeric($args['startdate'])
1381
+									? strtotime($args['startdate'])
1382 1382
 									: $args['startdate'],
1383
-								is_numeric( $args['enddate'] )
1384
-									? strtotime( $args['enddate'] )
1383
+								is_numeric($args['enddate'])
1384
+									? strtotime($args['enddate'])
1385 1385
 									: $args['enddate']
1386 1386
 						),
1387 1387
 					);
1388 1388
 				} else {
1389 1389
 					$error['error'] = sprintf( /* translators: %s: form */
1390
-						__( 'Form %s not found.', 'give' ), $args['form'] );
1390
+						__('Form %s not found.', 'give'), $args['form'] );
1391 1391
 				}
1392 1392
 			}// End if().
1393 1393
 
1394
-			if ( ! empty( $error ) ) {
1394
+			if ( ! empty($error)) {
1395 1395
 				return $error;
1396 1396
 			}
1397 1397
 
1398 1398
 			return $earnings;
1399
-		} elseif ( $args['type'] == 'donors' ) {
1399
+		} elseif ($args['type'] == 'donors') {
1400 1400
 			$donors                             = new Give_DB_Donors();
1401 1401
 			$stats['donations']['total_donors'] = $donors->count();
1402 1402
 
1403 1403
 			return $stats;
1404 1404
 
1405
-		} elseif ( empty( $args['type'] ) ) {
1406
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1407
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1405
+		} elseif (empty($args['type'])) {
1406
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1407
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1408 1408
 
1409 1409
 			return array(
1410 1410
 				'stats' => $stats,
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 	 *
1423 1423
 	 * @return array
1424 1424
 	 */
1425
-	public function get_recent_donations( $args = array() ) {
1425
+	public function get_recent_donations($args = array()) {
1426 1426
 		global $wp_query;
1427 1427
 
1428 1428
 		$defaults = array(
@@ -1432,33 +1432,33 @@  discard block
 block discarded – undo
1432 1432
 			'enddate'   => null,
1433 1433
 		);
1434 1434
 
1435
-		$args = wp_parse_args( $args, $defaults );
1435
+		$args = wp_parse_args($args, $defaults);
1436 1436
 
1437 1437
 		$donations = array();
1438 1438
 
1439
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1439
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1440 1440
 			return $donations;
1441 1441
 		}
1442 1442
 
1443
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1443
+		if (isset($wp_query->query_vars['id'])) {
1444 1444
 			$query   = array();
1445
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1446
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1445
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1446
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1447 1447
 			$query   = array();
1448
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1449
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1450
-			$args  = array(
1448
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1449
+		} elseif (isset($wp_query->query_vars['email'])) {
1450
+			$args = array(
1451 1451
 				'fields'     => 'ids',
1452 1452
 				'meta_key'   => '_give_payment_donor_email',
1453 1453
 				'meta_value' => $wp_query->query_vars['email'],
1454 1454
 				'number'     => $this->per_page(),
1455 1455
 				'page'       => $this->get_paged(),
1456 1456
 			);
1457
-			$query = give_get_payments( $args );
1458
-		} elseif ( isset( $wp_query->query_vars['date'] ) ) {
1457
+			$query = give_get_payments($args);
1458
+		} elseif (isset($wp_query->query_vars['date'])) {
1459 1459
 
1460
-			$current_time = current_time( 'timestamp' );
1461
-			$dates        = $this->get_dates( $args );
1460
+			$current_time = current_time('timestamp');
1461
+			$dates        = $this->get_dates($args);
1462 1462
 			$start_date   = '';
1463 1463
 			$end_date     = '';
1464 1464
 
@@ -1471,27 +1471,27 @@  discard block
 block discarded – undo
1471 1471
 			 * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
1472 1472
 			 * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
1473 1473
 			 */
1474
-			switch ( $wp_query->query_vars['date'] ) {
1474
+			switch ($wp_query->query_vars['date']) {
1475 1475
 
1476 1476
 				case 'today':
1477 1477
 
1478 1478
 					// Set and Format Start and End Date to be date of today.
1479
-					$start_date = $end_date = date( 'Y/m/d', $current_time );
1479
+					$start_date = $end_date = date('Y/m/d', $current_time);
1480 1480
 
1481 1481
 					break;
1482 1482
 
1483 1483
 				case 'yesterday':
1484 1484
 
1485 1485
 					// Set and Format Start and End Date to be date of yesterday.
1486
-					$start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 );
1486
+					$start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1);
1487 1487
 
1488 1488
 					break;
1489 1489
 
1490 1490
 				case 'range':
1491 1491
 
1492 1492
 					// Format Start Date and End Date for filtering payment based on date range.
1493
-					$start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start'];
1494
-					$end_date   = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end'];
1493
+					$start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start'];
1494
+					$end_date   = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end'];
1495 1495
 
1496 1496
 					break;
1497 1497
 
@@ -1505,22 +1505,22 @@  discard block
 block discarded – undo
1505 1505
 				'page'       => $this->get_paged(),
1506 1506
 			);
1507 1507
 
1508
-			$query = give_get_payments( $args );
1508
+			$query = give_get_payments($args);
1509 1509
 		} else {
1510 1510
 			$args  = array(
1511 1511
 				'fields' => 'ids',
1512 1512
 				'number' => $this->per_page(),
1513 1513
 				'page'   => $this->get_paged(),
1514 1514
 			);
1515
-			$query = give_get_payments( $args );
1515
+			$query = give_get_payments($args);
1516 1516
 		}// End if().
1517 1517
 
1518
-		if ( $query ) {
1518
+		if ($query) {
1519 1519
 			$i = 0;
1520
-			foreach ( $query as $payment ) {
1520
+			foreach ($query as $payment) {
1521 1521
 
1522
-				if ( is_numeric( $payment ) ) {
1523
-					$payment      = new Give_Payment( $payment );
1522
+				if (is_numeric($payment)) {
1523
+					$payment      = new Give_Payment($payment);
1524 1524
 					$payment_meta = $payment->get_meta();
1525 1525
 					$user_info    = $payment->user_info;
1526 1526
 				}
@@ -1528,44 +1528,44 @@  discard block
 block discarded – undo
1528 1528
 				$payment_meta = $payment->get_meta();
1529 1529
 				$user_info    = $payment->user_info;
1530 1530
 
1531
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1532
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1533
-
1534
-				$donations['donations'][ $i ]['ID']             = $payment->ID;
1535
-				$donations['donations'][ $i ]['number']         = $payment->number;
1536
-				$donations['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1537
-				$donations['donations'][ $i ]['key']            = $payment->key;
1538
-				$donations['donations'][ $i ]['total']          = $payment->total;
1539
-				$donations['donations'][ $i ]['status']         = give_get_payment_status( $payment, true );
1540
-				$donations['donations'][ $i ]['gateway']        = $payment->gateway;
1541
-				$donations['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1542
-				$donations['donations'][ $i ]['fname']          = $first_name;
1543
-				$donations['donations'][ $i ]['lname']          = $last_name;
1544
-				$donations['donations'][ $i ]['email']          = $payment->email;
1545
-				$donations['donations'][ $i ]['date']           = $payment->date;
1546
-				$donations['donations'][ $i ]['payment_meta']   = array();
1547
-
1548
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1549
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1550
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1551
-
1552
-				$donations['donations'][ $i ]['form']['id']    = $form_id;
1553
-				$donations['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1554
-				$donations['donations'][ $i ]['form']['price'] = $price;
1555
-
1556
-				if ( give_has_variable_prices( $form_id ) ) {
1557
-					if ( isset( $payment_meta['price_id'] ) ) {
1558
-						$price_name                                         = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1559
-						$donations['donations'][ $i ]['form']['price_name'] = $price_name;
1560
-						$donations['donations'][ $i ]['form']['price_id']   = $price_id;
1561
-						$donations['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1531
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1532
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1533
+
1534
+				$donations['donations'][$i]['ID']             = $payment->ID;
1535
+				$donations['donations'][$i]['number']         = $payment->number;
1536
+				$donations['donations'][$i]['transaction_id'] = $payment->transaction_id;
1537
+				$donations['donations'][$i]['key']            = $payment->key;
1538
+				$donations['donations'][$i]['total']          = $payment->total;
1539
+				$donations['donations'][$i]['status']         = give_get_payment_status($payment, true);
1540
+				$donations['donations'][$i]['gateway']        = $payment->gateway;
1541
+				$donations['donations'][$i]['name']           = $first_name.' '.$last_name;
1542
+				$donations['donations'][$i]['fname']          = $first_name;
1543
+				$donations['donations'][$i]['lname']          = $last_name;
1544
+				$donations['donations'][$i]['email']          = $payment->email;
1545
+				$donations['donations'][$i]['date']           = $payment->date;
1546
+				$donations['donations'][$i]['payment_meta']   = array();
1547
+
1548
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1549
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1550
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1551
+
1552
+				$donations['donations'][$i]['form']['id']    = $form_id;
1553
+				$donations['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1554
+				$donations['donations'][$i]['form']['price'] = $price;
1555
+
1556
+				if (give_has_variable_prices($form_id)) {
1557
+					if (isset($payment_meta['price_id'])) {
1558
+						$price_name                                         = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1559
+						$donations['donations'][$i]['form']['price_name'] = $price_name;
1560
+						$donations['donations'][$i]['form']['price_id']   = $price_id;
1561
+						$donations['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1562 1562
 
1563 1563
 					}
1564 1564
 				}
1565 1565
 
1566
-				if( ! empty( $payment_meta ) ) {
1566
+				if ( ! empty($payment_meta)) {
1567 1567
 					// Add custom meta to API
1568
-					foreach ( $payment_meta as $meta_key => $meta_value ) {
1568
+					foreach ($payment_meta as $meta_key => $meta_value) {
1569 1569
 
1570 1570
 						$exceptions = array(
1571 1571
 							'form_title',
@@ -1578,20 +1578,20 @@  discard block
 block discarded – undo
1578 1578
 						);
1579 1579
 
1580 1580
 						// Don't clutter up results with dupes
1581
-						if ( in_array( $meta_key, $exceptions ) ) {
1581
+						if (in_array($meta_key, $exceptions)) {
1582 1582
 							continue;
1583 1583
 						}
1584 1584
 
1585
-						$donations['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1585
+						$donations['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1586 1586
 
1587 1587
 					}
1588 1588
 				}
1589 1589
 
1590
-				$i ++;
1590
+				$i++;
1591 1591
 			}// End foreach().
1592 1592
 		}// End if().
1593 1593
 
1594
-		return apply_filters( 'give_api_donations_endpoint', $donations );
1594
+		return apply_filters('give_api_donations_endpoint', $donations);
1595 1595
 	}
1596 1596
 
1597 1597
 	/**
@@ -1607,9 +1607,9 @@  discard block
 block discarded – undo
1607 1607
 	public function get_output_format() {
1608 1608
 		global $wp_query;
1609 1609
 
1610
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1610
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1611 1611
 
1612
-		return apply_filters( 'give_api_output_format', $format );
1612
+		return apply_filters('give_api_output_format', $format);
1613 1613
 	}
1614 1614
 
1615 1615
 
@@ -1625,8 +1625,8 @@  discard block
 block discarded – undo
1625 1625
 	 *
1626 1626
 	 * @return void
1627 1627
 	 */
1628
-	private function log_request( $data = array() ) {
1629
-		if ( ! $this->log_requests ) {
1628
+	private function log_request($data = array()) {
1629
+		if ( ! $this->log_requests) {
1630 1630
 			return;
1631 1631
 		}
1632 1632
 
@@ -1637,37 +1637,37 @@  discard block
 block discarded – undo
1637 1637
 
1638 1638
 		$query = array(
1639 1639
 			'give-api'    => $wp_query->query_vars['give-api'],
1640
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1641
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1642
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1643
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1644
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1645
-			'donor'       => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null,
1646
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1647
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1648
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1649
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1650
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1651
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1640
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1641
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1642
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1643
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1644
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1645
+			'donor'       => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null,
1646
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1647
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1648
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1649
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1650
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1651
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1652 1652
 		);
1653 1653
 
1654 1654
 		$log_data = array(
1655 1655
 			'log_type'     => 'api_request',
1656
-			'post_excerpt' => http_build_query( $query ),
1657
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1656
+			'post_excerpt' => http_build_query($query),
1657
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1658 1658
 		);
1659 1659
 
1660 1660
 		$log_meta = array(
1661
-			'api_query'  => http_build_query( $query ),
1661
+			'api_query'  => http_build_query($query),
1662 1662
 			'request_ip' => give_get_ip(),
1663 1663
 			'user'       => $this->user_id,
1664
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1665
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1664
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1665
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1666 1666
 			'time'       => $data['request_speed'],
1667 1667
 			'version'    => $this->get_queried_version(),
1668 1668
 		);
1669 1669
 
1670
-		Give()->logs->insert_log( $log_data, $log_meta );
1670
+		Give()->logs->insert_log($log_data, $log_meta);
1671 1671
 	}
1672 1672
 
1673 1673
 
@@ -1691,11 +1691,11 @@  discard block
 block discarded – undo
1691 1691
 	 *
1692 1692
 	 * @param int       $status_code
1693 1693
 	 */
1694
-	public function output( $status_code = 200 ) {
1694
+	public function output($status_code = 200) {
1695 1695
 
1696 1696
 		$format = $this->get_output_format();
1697 1697
 
1698
-		status_header( $status_code );
1698
+		status_header($status_code);
1699 1699
 
1700 1700
 		/**
1701 1701
 		 * Fires before outputting the API.
@@ -1706,25 +1706,25 @@  discard block
 block discarded – undo
1706 1706
 		 * @param Give_API $this   The Give_API object.
1707 1707
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1708 1708
 		 */
1709
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1709
+		do_action('give_api_output_before', $this->data, $this, $format);
1710 1710
 
1711
-		switch ( $format ) :
1711
+		switch ($format) :
1712 1712
 
1713 1713
 			case 'xml' :
1714 1714
 
1715
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1716
-				$xml = Array2XML::createXML( 'give', $this->data );
1715
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1716
+				$xml = Array2XML::createXML('give', $this->data);
1717 1717
 				echo $xml->saveXML();
1718 1718
 
1719 1719
 				break;
1720 1720
 
1721 1721
 			case 'json' :
1722 1722
 
1723
-				header( 'Content-Type: application/json' );
1724
-				if ( ! empty( $this->pretty_print ) ) {
1725
-					echo json_encode( $this->data, $this->pretty_print );
1723
+				header('Content-Type: application/json');
1724
+				if ( ! empty($this->pretty_print)) {
1725
+					echo json_encode($this->data, $this->pretty_print);
1726 1726
 				} else {
1727
-					echo json_encode( $this->data );
1727
+					echo json_encode($this->data);
1728 1728
 				}
1729 1729
 
1730 1730
 				break;
@@ -1739,7 +1739,7 @@  discard block
 block discarded – undo
1739 1739
 				 * @param array    $data Response data to return.
1740 1740
 				 * @param Give_API $this The Give_API object.
1741 1741
 				 */
1742
-				do_action( "give_api_output_{$format}", $this->data, $this );
1742
+				do_action("give_api_output_{$format}", $this->data, $this);
1743 1743
 
1744 1744
 				break;
1745 1745
 
@@ -1754,7 +1754,7 @@  discard block
 block discarded – undo
1754 1754
 		 * @param Give_API $this   The Give_API object.
1755 1755
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1756 1756
 		 */
1757
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1757
+		do_action('give_api_output_after', $this->data, $this, $format);
1758 1758
 
1759 1759
 		give_die();
1760 1760
 	}
@@ -1771,41 +1771,41 @@  discard block
 block discarded – undo
1771 1771
 	 *
1772 1772
 	 * @return void
1773 1773
 	 */
1774
-	function user_key_field( $user ) {
1774
+	function user_key_field($user) {
1775 1775
 
1776
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1776
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1777 1777
 
1778
-			$user = get_userdata( $user->ID );
1778
+			$user = get_userdata($user->ID);
1779 1779
 			?>
1780 1780
 			<table class="form-table">
1781 1781
 				<tbody>
1782 1782
 				<tr>
1783 1783
 					<th>
1784
-						<?php _e( 'Give API Keys', 'give' ); ?>
1784
+						<?php _e('Give API Keys', 'give'); ?>
1785 1785
 					</th>
1786 1786
 					<td>
1787 1787
 						<?php
1788
-						$public_key = $this->get_user_public_key( $user->ID );
1789
-						$secret_key = $this->get_user_secret_key( $user->ID );
1788
+						$public_key = $this->get_user_public_key($user->ID);
1789
+						$secret_key = $this->get_user_secret_key($user->ID);
1790 1790
 						?>
1791
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1791
+						<?php if (empty($user->give_user_public_key)) { ?>
1792 1792
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" />
1793
-							<span class="description"><?php _e( 'Generate API Key', 'give' ); ?></span>
1793
+							<span class="description"><?php _e('Generate API Key', 'give'); ?></span>
1794 1794
 						<?php } else { ?>
1795
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?>
1795
+							<strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?>
1796 1796
 								&nbsp;</strong>
1797
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>" />
1797
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>" />
1798 1798
 							<br />
1799
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Secret key:', 'give' ); ?>
1799
+							<strong style="display:inline-block; width: 125px;"><?php _e('Secret key:', 'give'); ?>
1800 1800
 								&nbsp;</strong>
1801
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>" />
1801
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>" />
1802 1802
 							<br />
1803
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Token:', 'give' ); ?>
1803
+							<strong style="display:inline-block; width: 125px;"><?php _e('Token:', 'give'); ?>
1804 1804
 								&nbsp;</strong>
1805
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>" />
1805
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>" />
1806 1806
 							<br />
1807 1807
 							<input name="give_revoke_api_key" type="checkbox" id="give_revoke_api_key" />
1808
-							<span class="description"><label for="give_revoke_api_key"><?php _e( 'Revoke API Keys', 'give' ); ?></label></span>
1808
+							<span class="description"><label for="give_revoke_api_key"><?php _e('Revoke API Keys', 'give'); ?></label></span>
1809 1809
 						<?php } ?>
1810 1810
 					</td>
1811 1811
 				</tr>
@@ -1824,61 +1824,61 @@  discard block
 block discarded – undo
1824 1824
 	 *
1825 1825
 	 * @return void
1826 1826
 	 */
1827
-	public function process_api_key( $args ) {
1827
+	public function process_api_key($args) {
1828 1828
 
1829
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1830
-			wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array(
1829
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1830
+			wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array(
1831 1831
 				'response' => 403,
1832
-			) );
1832
+			));
1833 1833
 		}
1834 1834
 
1835
-		if ( empty( $args['user_id'] ) ) {
1836
-			wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array(
1835
+		if (empty($args['user_id'])) {
1836
+			wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array(
1837 1837
 				'response' => 401,
1838
-			) );
1838
+			));
1839 1839
 		}
1840 1840
 
1841
-		if ( is_numeric( $args['user_id'] ) ) {
1842
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1841
+		if (is_numeric($args['user_id'])) {
1842
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1843 1843
 		} else {
1844
-			$userdata = get_user_by( 'login', $args['user_id'] );
1844
+			$userdata = get_user_by('login', $args['user_id']);
1845 1845
 			$user_id  = $userdata->ID;
1846 1846
 		}
1847
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1847
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1848 1848
 
1849
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1850
-			wp_die( sprintf( /* translators: %s: process */
1851
-				__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array(
1849
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1850
+			wp_die(sprintf( /* translators: %s: process */
1851
+				__('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array(
1852 1852
 				'response' => 403,
1853
-			) );
1854
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1855
-			wp_die( sprintf( /* translators: %s: process */
1856
-				__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array(
1853
+			));
1854
+		} elseif ( ! current_user_can('manage_give_settings')) {
1855
+			wp_die(sprintf( /* translators: %s: process */
1856
+				__('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array(
1857 1857
 				'response' => 403,
1858
-			) );
1858
+			));
1859 1859
 		}
1860 1860
 
1861
-		switch ( $process ) {
1861
+		switch ($process) {
1862 1862
 			case 'generate':
1863
-				if ( $this->generate_api_key( $user_id ) ) {
1864
-					Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1865
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1863
+				if ($this->generate_api_key($user_id)) {
1864
+					Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1865
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1866 1866
 					exit();
1867 1867
 				} else {
1868
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1868
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1869 1869
 					exit();
1870 1870
 				}
1871 1871
 				break;
1872 1872
 			case 'regenerate':
1873
-				$this->generate_api_key( $user_id, true );
1874
-				Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1875
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1873
+				$this->generate_api_key($user_id, true);
1874
+				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1875
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1876 1876
 				exit();
1877 1877
 				break;
1878 1878
 			case 'revoke':
1879
-				$this->revoke_api_key( $user_id );
1880
-				Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1881
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1879
+				$this->revoke_api_key($user_id);
1880
+				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1881
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1882 1882
 				exit();
1883 1883
 				break;
1884 1884
 			default;
@@ -1897,59 +1897,59 @@  discard block
 block discarded – undo
1897 1897
 	 *
1898 1898
 	 * @return boolean True if (re)generated successfully, false otherwise.
1899 1899
 	 */
1900
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1900
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1901 1901
 
1902 1902
 		// Bail out, if user doesn't exists.
1903
-		if ( empty( $user_id ) ) {
1903
+		if (empty($user_id)) {
1904 1904
 			return false;
1905 1905
 		}
1906 1906
 
1907
-		$user = get_userdata( $user_id );
1907
+		$user = get_userdata($user_id);
1908 1908
 
1909 1909
 		// Bail Out, if user object doesn't exists.
1910
-		if ( ! $user ) {
1910
+		if ( ! $user) {
1911 1911
 			return false;
1912 1912
 		}
1913 1913
 
1914 1914
 		$new_public_key = '';
1915 1915
 		$new_secret_key = '';
1916 1916
 
1917
-		if( ! empty( $_POST['from'] ) && 'profile' === $_POST['from'] ) {
1917
+		if ( ! empty($_POST['from']) && 'profile' === $_POST['from']) {
1918 1918
 			// For User Profile Page.
1919
-			if( ! empty( $_POST['give_set_api_key'] ) ) {
1919
+			if ( ! empty($_POST['give_set_api_key'])) {
1920 1920
 				// Generate API Key from User Profile page.
1921
-				$new_public_key = $this->generate_public_key( $user->user_email );
1922
-				$new_secret_key = $this->generate_private_key( $user->ID );
1923
-			} elseif ( ! empty( $_POST['give_revoke_api_key'] ) ) {
1921
+				$new_public_key = $this->generate_public_key($user->user_email);
1922
+				$new_secret_key = $this->generate_private_key($user->ID);
1923
+			} elseif ( ! empty($_POST['give_revoke_api_key'])) {
1924 1924
 				// Revoke API Key from User Profile page.
1925
-				$this->revoke_api_key( $user->ID );
1925
+				$this->revoke_api_key($user->ID);
1926 1926
 			} else {
1927 1927
 				return false;
1928 1928
 			}
1929 1929
 		} else {
1930 1930
 			// For Tools > API page.
1931
-			$public_key = $this->get_user_public_key( $user_id );
1931
+			$public_key = $this->get_user_public_key($user_id);
1932 1932
 
1933
-			if ( empty( $public_key ) && ! $regenerate ) {
1933
+			if (empty($public_key) && ! $regenerate) {
1934 1934
 				// Generating API for first time.
1935
-				$new_public_key = $this->generate_public_key( $user->user_email );
1936
-				$new_secret_key = $this->generate_private_key( $user->ID );
1937
-			} elseif ( $public_key && $regenerate ) {
1935
+				$new_public_key = $this->generate_public_key($user->user_email);
1936
+				$new_secret_key = $this->generate_private_key($user->ID);
1937
+			} elseif ($public_key && $regenerate) {
1938 1938
 				// API Key already exists and Regenerating API Key.
1939
-				$this->revoke_api_key( $user->ID );
1940
-				$new_public_key = $this->generate_public_key( $user->user_email );
1941
-				$new_secret_key = $this->generate_private_key( $user->ID );
1942
-			} elseif ( ! empty( $public_key ) && ! $regenerate ) {
1939
+				$this->revoke_api_key($user->ID);
1940
+				$new_public_key = $this->generate_public_key($user->user_email);
1941
+				$new_secret_key = $this->generate_private_key($user->ID);
1942
+			} elseif ( ! empty($public_key) && ! $regenerate) {
1943 1943
 				// Doing nothing, when API Key exists but still try to generate again instead of regenerating.
1944 1944
 				return false;
1945 1945
 			} else {
1946 1946
 				// Revoke API Key.
1947
-				$this->revoke_api_key( $user->ID );
1947
+				$this->revoke_api_key($user->ID);
1948 1948
 			}
1949 1949
 		}
1950 1950
 
1951
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1952
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1951
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1952
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1953 1953
 
1954 1954
 		return true;
1955 1955
 	}
@@ -1964,26 +1964,26 @@  discard block
 block discarded – undo
1964 1964
 	 *
1965 1965
 	 * @return bool
1966 1966
 	 */
1967
-	public function revoke_api_key( $user_id = 0 ) {
1967
+	public function revoke_api_key($user_id = 0) {
1968 1968
 
1969
-		if ( empty( $user_id ) ) {
1969
+		if (empty($user_id)) {
1970 1970
 			return false;
1971 1971
 		}
1972 1972
 
1973
-		$user = get_userdata( $user_id );
1973
+		$user = get_userdata($user_id);
1974 1974
 
1975
-		if ( ! $user ) {
1975
+		if ( ! $user) {
1976 1976
 			return false;
1977 1977
 		}
1978 1978
 
1979
-		$public_key = $this->get_user_public_key( $user_id );
1980
-		$secret_key = $this->get_user_secret_key( $user_id );
1981
-		if ( ! empty( $public_key ) ) {
1982
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) );
1983
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) );
1984
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) );
1985
-			delete_user_meta( $user_id, $public_key );
1986
-			delete_user_meta( $user_id, $secret_key );
1979
+		$public_key = $this->get_user_public_key($user_id);
1980
+		$secret_key = $this->get_user_secret_key($user_id);
1981
+		if ( ! empty($public_key)) {
1982
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key)));
1983
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id)));
1984
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id)));
1985
+			delete_user_meta($user_id, $public_key);
1986
+			delete_user_meta($user_id, $secret_key);
1987 1987
 		} else {
1988 1988
 			return false;
1989 1989
 		}
@@ -2005,9 +2005,9 @@  discard block
 block discarded – undo
2005 2005
 	 *
2006 2006
 	 * @return string
2007 2007
 	 */
2008
-	private function generate_public_key( $user_email = '' ) {
2009
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
2010
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
2008
+	private function generate_public_key($user_email = '') {
2009
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
2010
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
2011 2011
 
2012 2012
 		return $public;
2013 2013
 	}
@@ -2022,9 +2022,9 @@  discard block
 block discarded – undo
2022 2022
 	 *
2023 2023
 	 * @return string
2024 2024
 	 */
2025
-	private function generate_private_key( $user_id = 0 ) {
2026
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
2027
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
2025
+	private function generate_private_key($user_id = 0) {
2026
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
2027
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
2028 2028
 
2029 2029
 		return $secret;
2030 2030
 	}
@@ -2039,8 +2039,8 @@  discard block
 block discarded – undo
2039 2039
 	 *
2040 2040
 	 * @return string
2041 2041
 	 */
2042
-	public function get_token( $user_id = 0 ) {
2043
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
2042
+	public function get_token($user_id = 0) {
2043
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
2044 2044
 	}
2045 2045
 
2046 2046
 	/**
@@ -2054,9 +2054,9 @@  discard block
 block discarded – undo
2054 2054
 
2055 2055
 		// Default sales return
2056 2056
 		$donations                               = array();
2057
-		$donations['donations']['today']         = $this->stats->get_sales( 0, 'today' );
2058
-		$donations['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
2059
-		$donations['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
2057
+		$donations['donations']['today']         = $this->stats->get_sales(0, 'today');
2058
+		$donations['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
2059
+		$donations['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
2060 2060
 		$donations['donations']['totals']        = give_get_total_donations();
2061 2061
 
2062 2062
 		return $donations;
@@ -2073,9 +2073,9 @@  discard block
 block discarded – undo
2073 2073
 
2074 2074
 		// Default earnings return
2075 2075
 		$earnings                              = array();
2076
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
2077
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
2078
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
2076
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
2077
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
2078
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
2079 2079
 		$earnings['earnings']['totals']        = give_get_total_earnings();
2080 2080
 
2081 2081
 		return $earnings;
@@ -2095,25 +2095,25 @@  discard block
 block discarded – undo
2095 2095
 	 *
2096 2096
 	 * @return string            The API key/secret for the user supplied
2097 2097
 	 */
2098
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
2098
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
2099 2099
 
2100
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
2100
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
2101 2101
 			return $check;
2102 2102
 		}
2103 2103
 
2104 2104
 		$return = $check;
2105 2105
 
2106
-		switch ( $meta_key ) {
2106
+		switch ($meta_key) {
2107 2107
 			case 'give_user_public_key':
2108
-				$return = Give()->api->get_user_public_key( $object_id );
2108
+				$return = Give()->api->get_user_public_key($object_id);
2109 2109
 				break;
2110 2110
 			case 'give_user_secret_key':
2111
-				$return = Give()->api->get_user_secret_key( $object_id );
2111
+				$return = Give()->api->get_user_secret_key($object_id);
2112 2112
 				break;
2113 2113
 		}
2114 2114
 
2115
-		if ( ! $single ) {
2116
-			$return = array( $return );
2115
+		if ( ! $single) {
2116
+			$return = array($return);
2117 2117
 		}
2118 2118
 
2119 2119
 		return $return;
Please login to merge, or discard this patch.
includes/class-give-db-form-meta.php 1 patch
Spacing   +3 added lines, -3 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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->formmeta    = $this->table_name = $wpdb->prefix . 'give_formmeta';
53
+		$wpdb->formmeta    = $this->table_name = $wpdb->prefix.'give_formmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -84,6 +84,6 @@  discard block
 block discarded – undo
84 84
 	 * @return bool
85 85
 	 */
86 86
 	protected function is_custom_meta_table_active() {
87
-		return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' );
87
+		return give_has_upgrade_completed('v20_move_metadata_into_new_table');
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
includes/admin/tools/class-settings-logs.php 1 patch
Spacing   +13 added lines, -13 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_Logs' ) ) :
16
+if ( ! class_exists('Give_Settings_Logs')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Logs.
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 		 */
35 35
 		public function __construct() {
36 36
 			$this->id    = 'logs';
37
-			$this->label = __( 'Logs', 'give' );
37
+			$this->label = __('Logs', 'give');
38 38
 
39 39
 			$this->default_tab = 'sales';
40 40
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		 */
51 51
 		public function get_settings() {
52 52
 			// Get settings.
53
-			$settings = apply_filters( 'give_settings_logs', array(
53
+			$settings = apply_filters('give_settings_logs', array(
54 54
 				array(
55 55
 					'id'         => 'give_tools_logs',
56 56
 					'type'       => 'title',
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 				),
59 59
 				array(
60 60
 					'id'   => 'logs',
61
-					'name' => __( 'Log', 'give' ),
61
+					'name' => __('Log', 'give'),
62 62
 					'type' => 'logs',
63 63
 
64 64
 				),
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 					'type'       => 'sectionend',
68 68
 					'table_html' => false,
69 69
 				),
70
-			) );
70
+			));
71 71
 
72 72
 			/**
73 73
 			 * Filter the settings.
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			 *
77 77
 			 * @param  array $settings
78 78
 			 */
79
-			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
79
+			$settings = apply_filters('give_get_settings_'.$this->id, $settings);
80 80
 
81 81
 			// Output.
82 82
 			return $settings;
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
 		 */
91 91
 		public function get_sections() {
92 92
 			$sections = array(
93
-				'sales'          => __( 'Donations', 'give' ),
94
-				'gateway_errors' => __( 'Payment Errors', 'give' ),
95
-				'api_requests'   => __( 'API Requests', 'give' ),
96
-				'updates'   => __( 'Updates', 'give' ),
93
+				'sales'          => __('Donations', 'give'),
94
+				'gateway_errors' => __('Payment Errors', 'give'),
95
+				'api_requests'   => __('API Requests', 'give'),
96
+				'updates'   => __('Updates', 'give'),
97 97
 			);
98 98
 
99
-			$sections = apply_filters( 'give_log_views', $sections );
99
+			$sections = apply_filters('give_log_views', $sections);
100 100
 
101
-			return apply_filters( 'give_get_sections_' . $this->id, $sections );
101
+			return apply_filters('give_get_sections_'.$this->id, $sections);
102 102
 		}
103 103
 	}
104 104
 
Please login to merge, or discard this patch.
includes/admin/tools/logs/logs.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function give_get_logs_tab() {
24 24
 
25
-	require( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php' );
25
+	require(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php');
26 26
 
27 27
 	// Get current section.
28 28
 	$current_section = $_GET['section'] = give_get_current_setting_section();
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @since 1.0
34 34
 	 */
35
-	do_action( "give_logs_view_{$current_section}" );
35
+	do_action("give_logs_view_{$current_section}");
36 36
 }
37 37
 
38 38
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  */
47 47
 function give_logs_view_sales() {
48 48
 
49
-	include GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-sales-logs-list-table.php';
49
+	include GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-sales-logs-list-table.php';
50 50
 
51 51
 	$logs_table = new Give_Sales_Log_Table();
52 52
 	$logs_table->prepare_items();
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		 *
60 60
 		 * @since 1.8.12
61 61
 		 */
62
-		do_action( 'give_logs_donations_top' );
62
+		do_action('give_logs_donations_top');
63 63
 
64 64
 		$logs_table->display(); ?>
65 65
 		<input type="hidden" name="post_type" value="give_forms"/>
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 		 *
74 74
 		 * @since 1.8.12
75 75
 		 */
76
-		do_action( 'give_logs_donations_bottom' );
76
+		do_action('give_logs_donations_bottom');
77 77
 		?>
78 78
 
79 79
 	</div>
80 80
 	<?php
81 81
 }
82 82
 
83
-add_action( 'give_logs_view_sales', 'give_logs_view_sales' );
83
+add_action('give_logs_view_sales', 'give_logs_view_sales');
84 84
 
85 85
 /**
86 86
  * Update Logs
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
  * @return void
91 91
  */
92 92
 function give_logs_view_updates() {
93
-	include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-update-logs-list-table.php' );
93
+	include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-update-logs-list-table.php');
94 94
 
95 95
 	$logs_table = new Give_Update_Log_Table();
96 96
 	$logs_table->prepare_items();
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		 *
104 104
 		 * @since 2.0.1
105 105
 		 */
106
-		do_action( 'give_logs_update_top' );
106
+		do_action('give_logs_update_top');
107 107
 
108 108
 		$logs_table->display(); ?>
109 109
 		<input type="hidden" name="post_type" value="give_forms"/>
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
 		 *
118 118
 		 * @since 2.0.1
119 119
 		 */
120
-		do_action( 'give_logs_update_bottom' );
120
+		do_action('give_logs_update_bottom');
121 121
 		?>
122 122
 
123 123
 	</div>
124 124
 	<?php
125 125
 }
126 126
 
127
-add_action( 'give_logs_view_updates', 'give_logs_view_updates' );
127
+add_action('give_logs_view_updates', 'give_logs_view_updates');
128 128
 
129 129
 /**
130 130
  * Gateway Error Logs
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
  * @return void
136 136
  */
137 137
 function give_logs_view_gateway_errors() {
138
-	include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-gateway-error-logs-list-table.php' );
138
+	include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-gateway-error-logs-list-table.php');
139 139
 
140 140
 	$logs_table = new Give_Gateway_Error_Log_Table();
141 141
 	$logs_table->prepare_items();
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		 *
149 149
 		 * @since 1.8.12
150 150
 		 */
151
-		do_action( 'give_logs_payment_error_top' );
151
+		do_action('give_logs_payment_error_top');
152 152
 
153 153
 		$logs_table->display(); ?>
154 154
 		<input type="hidden" name="post_type" value="give_forms"/>
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 		 *
163 163
 		 * @since 1.8.12
164 164
 		 */
165
-		do_action( 'give_logs_payment_error_bottom' );
165
+		do_action('give_logs_payment_error_bottom');
166 166
 		?>
167 167
 
168 168
 	</div>
169 169
 	<?php
170 170
 }
171 171
 
172
-add_action( 'give_logs_view_gateway_errors', 'give_logs_view_gateway_errors' );
172
+add_action('give_logs_view_gateway_errors', 'give_logs_view_gateway_errors');
173 173
 
174 174
 /**
175 175
  * API Request Logs
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
  * @return void
181 181
  */
182 182
 function give_logs_view_api_requests() {
183
-	include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-api-requests-logs-list-table.php' );
183
+	include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-api-requests-logs-list-table.php');
184 184
 
185 185
 	$logs_table = new Give_API_Request_Log_Table();
186 186
 	$logs_table->prepare_items();
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @since 1.0
192 192
 	 */
193
-	do_action( 'give_logs_api_requests_top' );
193
+	do_action('give_logs_api_requests_top');
194 194
 
195
-	$logs_table->search_box( esc_html__( 'Search', 'give' ), 'give-api-requests' );
195
+	$logs_table->search_box(esc_html__('Search', 'give'), 'give-api-requests');
196 196
 	$logs_table->display();
197 197
 	?>
198 198
 	<input type="hidden" name="post_type" value="give_forms"/>
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @since 1.0
208 208
 	 */
209
-	do_action( 'give_logs_api_requests_bottom' );
209
+	do_action('give_logs_api_requests_bottom');
210 210
 }
211
-add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' );
211
+add_action('give_logs_view_api_requests', 'give_logs_view_api_requests');
212 212
 
213 213
 /**
214 214
  * Renders the log views drop down.
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
 	$current_section = give_get_current_setting_section();
221 221
 
222 222
 	// If there are not any event attach to action then do not show form.
223
-	if ( ! has_action( 'give_log_view_actions' ) ) {
223
+	if ( ! has_action('give_log_view_actions')) {
224 224
 		return;
225 225
 	}
226 226
 	?>
227
-	<form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs&section=' . $current_section; ?>">
227
+	<form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs&section='.$current_section; ?>">
228 228
 		<?php
229 229
 		/**
230 230
 		 * Fires after displaying the reports page views drop down.
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
 		 *
234 234
 		 * @since 1.0
235 235
 		 */
236
-		do_action( 'give_log_view_actions' );
236
+		do_action('give_log_view_actions');
237 237
 		?>
238 238
 
239 239
 		<input type="hidden" name="post_type" value="give_forms"/>
240 240
 		<input type="hidden" name="page" value="give-tools"/>
241 241
 		<input type="hidden" name="tab" value="logs"/>
242 242
 
243
-		<?php submit_button( esc_html__( 'Apply', 'give' ), 'secondary', 'submit', false ); ?>
243
+		<?php submit_button(esc_html__('Apply', 'give'), 'secondary', 'submit', false); ?>
244 244
 	</form>
245 245
 	<?php
246 246
 }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
  *
253 253
  * @return string
254 254
  */
255
-function give_tools_set_form_method( $method ) {
255
+function give_tools_set_form_method($method) {
256 256
 	return 'get';
257 257
 }
258
-add_filter( 'give-tools_form_method_tab_logs', 'give_tools_set_form_method', 10 );
258
+add_filter('give-tools_form_method_tab_logs', 'give_tools_set_form_method', 10);
Please login to merge, or discard this patch.
includes/class-give-db-payment-meta.php 1 patch
Spacing   +3 added lines, -3 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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->paymentmeta = $this->table_name = $wpdb->prefix . 'give_paymentmeta';
53
+		$wpdb->paymentmeta = $this->table_name = $wpdb->prefix.'give_paymentmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -84,6 +84,6 @@  discard block
 block discarded – undo
84 84
 	 * @return bool
85 85
 	 */
86 86
 	protected function is_custom_meta_table_active() {
87
-		return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' );
87
+		return give_has_upgrade_completed('v20_move_metadata_into_new_table');
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
includes/class-give-db-logs-meta.php 1 patch
Spacing   +7 added lines, -7 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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->logmeta     = $this->table_name = $wpdb->prefix . 'give_logmeta';
53
+		$wpdb->logmeta     = $this->table_name = $wpdb->prefix.'give_logmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return bool
88 88
 	 */
89
-	public function delete_row( $log_id = 0 ) {
89
+	public function delete_row($log_id = 0) {
90 90
 		/* @var WPDB $wpdb */
91 91
 		global $wpdb;
92 92
 
93 93
 		// Row ID must be positive integer
94
-		$log_id = absint( $log_id );
94
+		$log_id = absint($log_id);
95 95
 
96
-		if ( empty( $log_id ) ) {
96
+		if (empty($log_id)) {
97 97
 			return false;
98 98
 		}
99 99
 
100
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE log_id = %d", $log_id ) ) ) {
100
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE log_id = %d", $log_id))) {
101 101
 			return false;
102 102
 		}
103 103
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @return bool
116 116
 	 */
117
-	protected function is_valid_post_type( $ID ) {
117
+	protected function is_valid_post_type($ID) {
118 118
 		return $ID && true;
119 119
 	}
120 120
 }
Please login to merge, or discard this patch.