Test Failed
Pull Request — master (#2225)
by Devin
04:31
created
includes/admin/tools/export/class-export.php 1 patch
Spacing   +27 added lines, -27 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
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @return bool Whether we can export or not
38 38
 	 */
39 39
 	public function can_export() {
40
-		return (bool) apply_filters( 'give_export_capability', current_user_can( 'export_give_reports' ) );
40
+		return (bool) apply_filters('give_export_capability', current_user_can('export_give_reports'));
41 41
 	}
42 42
 
43 43
 	/**
@@ -48,16 +48,16 @@  discard block
 block discarded – undo
48 48
 	 * @return void
49 49
 	 */
50 50
 	public function headers() {
51
-		ignore_user_abort( true );
51
+		ignore_user_abort(true);
52 52
 
53
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
54
-			set_time_limit( 0 );
53
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
54
+			set_time_limit(0);
55 55
 		}
56 56
 
57 57
 		nocache_headers();
58
-		header( 'Content-Type: text/csv; charset=utf-8' );
59
-		header( 'Content-Disposition: attachment; filename=give-export-' . $this->export_type . '-' . date( 'm-d-Y' ) . '.csv' );
60
-		header( "Expires: 0" );
58
+		header('Content-Type: text/csv; charset=utf-8');
59
+		header('Content-Disposition: attachment; filename=give-export-'.$this->export_type.'-'.date('m-d-Y').'.csv');
60
+		header("Expires: 0");
61 61
 	}
62 62
 
63 63
 	/**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function csv_cols() {
71 71
 		$cols = array(
72
-			'id'   => __( 'ID', 'give' ),
73
-			'date' => __( 'Date', 'give' )
72
+			'id'   => __('ID', 'give'),
73
+			'date' => __('Date', 'give')
74 74
 		);
75 75
 
76 76
 		return $cols;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	public function get_csv_cols() {
87 87
 		$cols = $this->csv_cols();
88 88
 
89
-		return apply_filters( "give_export_csv_cols_{$this->export_type}", $cols );
89
+		return apply_filters("give_export_csv_cols_{$this->export_type}", $cols);
90 90
 	}
91 91
 
92 92
 	/**
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 	public function csv_cols_out() {
101 101
 		$cols = $this->get_csv_cols();
102 102
 		$i    = 1;
103
-		foreach ( $cols as $col_id => $column ) {
104
-			echo '"' . addslashes( $column ) . '"';
105
-			echo $i == count( $cols ) ? '' : ',';
106
-			$i ++;
103
+		foreach ($cols as $col_id => $column) {
104
+			echo '"'.addslashes($column).'"';
105
+			echo $i == count($cols) ? '' : ',';
106
+			$i++;
107 107
 		}
108 108
 		echo "\r\n";
109 109
 	}
@@ -120,16 +120,16 @@  discard block
 block discarded – undo
120 120
 		$data = array(
121 121
 			0 => array(
122 122
 				'id'   => '',
123
-				'data' => date( 'F j, Y' )
123
+				'data' => date('F j, Y')
124 124
 			),
125 125
 			1 => array(
126 126
 				'id'   => '',
127
-				'data' => date( 'F j, Y' )
127
+				'data' => date('F j, Y')
128 128
 			)
129 129
 		);
130 130
 
131
-		$data = apply_filters( 'give_export_get_data', $data );
132
-		$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
131
+		$data = apply_filters('give_export_get_data', $data);
132
+		$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
133 133
 
134 134
 		return $data;
135 135
 	}
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 		$cols = $this->get_csv_cols();
148 148
 
149 149
 		// Output each row
150
-		foreach ( $data as $row ) {
150
+		foreach ($data as $row) {
151 151
 			$i = 1;
152
-			foreach ( $row as $col_id => $column ) {
152
+			foreach ($row as $col_id => $column) {
153 153
 				// Make sure the column is valid
154
-				if ( array_key_exists( $col_id, $cols ) ) {
155
-					echo '"' . addslashes( $column ) . '"';
156
-					echo $i == count( $cols ) ? '' : ',';
157
-					$i ++;
154
+				if (array_key_exists($col_id, $cols)) {
155
+					echo '"'.addslashes($column).'"';
156
+					echo $i == count($cols) ? '' : ',';
157
+					$i++;
158 158
 				}
159 159
 			}
160 160
 			echo "\r\n";
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @return void
174 174
 	 */
175 175
 	public function export() {
176
-		if ( ! $this->can_export() ) {
177
-			wp_die( __( 'You do not have permission to export data.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
176
+		if ( ! $this->can_export()) {
177
+			wp_die(__('You do not have permission to export data.', 'give'), __('Error', 'give'), array('response' => 403));
178 178
 		}
179 179
 
180 180
 		// Set headers
Please login to merge, or discard this patch.
includes/admin/tools/class-settings-export.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Export' ) ) :
16
+if ( ! class_exists('Give_Settings_Export')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Export.
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 		 */
44 44
 		public function __construct() {
45 45
 			$this->id    = 'export';
46
-			$this->label = __( 'Export', 'give' );
46
+			$this->label = __('Export', 'give');
47 47
 
48
-			add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 );
49
-			add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) );
50
-			add_action( 'give_admin_field_tools_export', array( $this, 'render_export_field' ), 10, 2 );
48
+			add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20);
49
+			add_action("give-tools_settings_{$this->id}_page", array($this, 'output'));
50
+			add_action('give_admin_field_tools_export', array($this, 'render_export_field'), 10, 2);
51 51
 
52 52
 			// Do not use main donor for this tab.
53
-			if( give_get_current_setting_tab() === $this->id ) {
54
-				add_action( 'give-tools_open_form', '__return_empty_string' );
55
-				add_action( 'give-tools_close_form', '__return_empty_string' );
53
+			if (give_get_current_setting_tab() === $this->id) {
54
+				add_action('give-tools_open_form', '__return_empty_string');
55
+				add_action('give-tools_close_form', '__return_empty_string');
56 56
 			}
57 57
 		}
58 58
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		 * @param  array $pages Lst of pages.
64 64
 		 * @return array
65 65
 		 */
66
-		public function add_settings_page( $pages ) {
67
-			$pages[ $this->id ] = $this->label;
66
+		public function add_settings_page($pages) {
67
+			$pages[$this->id] = $this->label;
68 68
 
69 69
 			return $pages;
70 70
 		}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			 * @param  array $settings
87 87
 			 */
88 88
 			$settings = apply_filters(
89
-				'give_get_settings_' . $this->id,
89
+				'give_get_settings_'.$this->id,
90 90
 				array(
91 91
 					array(
92 92
 						'id'   => 'give_tools_export',
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 					),
96 96
 					array(
97 97
 						'id'   => 'export',
98
-						'name' => __( 'Export', 'give' ),
98
+						'name' => __('Export', 'give'),
99 99
 						'type' => 'tools_export',
100 100
 					),
101 101
 					array(
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		public function output() {
120 120
 			$settings = $this->get_settings();
121 121
 
122
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
122
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
123 123
 		}
124 124
 
125 125
 		/**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 		 * @param $field
132 132
 		 * @param $option_value
133 133
 		 */
134
-		public function render_export_field( $field, $option_value ) {
135
-			include_once( 'views/html-admin-page-exports.php' );
134
+		public function render_export_field($field, $option_value) {
135
+			include_once('views/html-admin-page-exports.php');
136 136
 		}
137 137
 	}
138 138
 
Please login to merge, or discard this patch.
includes/admin/class-api-keys-table.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -254,8 +254,8 @@
 block discarded – undo
254 254
 		$args = array(
255 255
 		  'id' => 'give-api-user-search',
256 256
 		  'name' => 'user_id',
257
-        );
258
-        echo Give()->html->ajax_user_search($args); ?>
257
+		);
258
+		echo Give()->html->ajax_user_search($args); ?>
259 259
 		<?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?>
260 260
 		<?php
261 261
 		$give_api_is_bottom = true;
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  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
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 		global $status, $page;
54 54
 
55 55
 		// Set parent defaults
56
-		parent::__construct( array(
57
-			'singular' => esc_html__( 'API Key', 'give' ),     // Singular name of the listed records
58
-			'plural'   => esc_html__( 'API Keys', 'give' ),    // Plural name of the listed records
59
-			'ajax'     => false,// Does this table support ajax?
60
-		) );
56
+		parent::__construct(array(
57
+			'singular' => esc_html__('API Key', 'give'), // Singular name of the listed records
58
+			'plural'   => esc_html__('API Keys', 'give'), // Plural name of the listed records
59
+			'ajax'     => false, // Does this table support ajax?
60
+		));
61 61
 
62 62
 		$this->query();
63 63
 	}
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return string Column Name
75 75
 	 */
76
-	public function column_default( $item, $column_name ) {
77
-		return $item[ $column_name ];
76
+	public function column_default($item, $column_name) {
77
+		return $item[$column_name];
78 78
 	}
79 79
 
80 80
 	/**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return string Column Name
89 89
 	 */
90
-	public function column_key( $item ) {
91
-		return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['key'] ) . '"/>';
90
+	public function column_key($item) {
91
+		return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['key']).'"/>';
92 92
 	}
93 93
 
94 94
 	/**
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return string Column Name
103 103
 	 */
104
-	public function column_token( $item ) {
105
-		return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['token'] ) . '"/>';
104
+	public function column_token($item) {
105
+		return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['token']).'"/>';
106 106
 	}
107 107
 
108 108
 	/**
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return string Column Name
117 117
 	 */
118
-	public function column_secret( $item ) {
119
-		return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['secret'] ) . '"/>';
118
+	public function column_secret($item) {
119
+		return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['secret']).'"/>';
120 120
 	}
121 121
 
122 122
 	/**
@@ -126,46 +126,46 @@  discard block
 block discarded – undo
126 126
 	 * @since  1.1
127 127
 	 * @return string
128 128
 	 */
129
-	public function column_user( $item ) {
129
+	public function column_user($item) {
130 130
 
131 131
 		$actions = array();
132 132
 
133
-		if ( apply_filters( 'give_api_log_requests', true ) ) {
133
+		if (apply_filters('give_api_log_requests', true)) {
134 134
 			$actions['view'] = sprintf(
135 135
 				'<a href="%s">%s</a>',
136
-				esc_url( add_query_arg( array(
136
+				esc_url(add_query_arg(array(
137 137
 					'section'   => 'api_requests',
138 138
 					'post_type' => 'give_forms',
139 139
 					'page'      => 'give-tools',
140 140
 					'tab'       => 'logs',
141 141
 					's'         => $item['email'],
142
-				), 'edit.php' ) ),
143
-				esc_html__( 'View API Log', 'give' )
142
+				), 'edit.php')),
143
+				esc_html__('View API Log', 'give')
144 144
 			);
145 145
 		}
146 146
 
147 147
 		$actions['reissue'] = sprintf(
148 148
 			'<a href="%s" class="give-regenerate-api-key">%s</a>',
149
-			esc_url( wp_nonce_url( add_query_arg( array(
149
+			esc_url(wp_nonce_url(add_query_arg(array(
150 150
 				'user_id'          => $item['id'],
151 151
 				'give_action'      => 'process_api_key',
152 152
 				'give_api_process' => 'regenerate',
153
-			) ), 'give-api-nonce' ) ),
154
-			esc_html__( 'Reissue', 'give' )
153
+			)), 'give-api-nonce')),
154
+			esc_html__('Reissue', 'give')
155 155
 		);
156
-		$actions['revoke']  = sprintf(
156
+		$actions['revoke'] = sprintf(
157 157
 			'<a href="%s" class="give-revoke-api-key give-delete">%s</a>',
158
-			esc_url( wp_nonce_url( add_query_arg( array(
158
+			esc_url(wp_nonce_url(add_query_arg(array(
159 159
 				'user_id'          => $item['id'],
160 160
 				'give_action'      => 'process_api_key',
161 161
 				'give_api_process' => 'revoke',
162
-			) ), 'give-api-nonce' ) ),
163
-			esc_html__( 'Revoke', 'give' )
162
+			)), 'give-api-nonce')),
163
+			esc_html__('Revoke', 'give')
164 164
 		);
165 165
 
166
-		$actions = apply_filters( 'give_api_row_actions', array_filter( $actions ) );
166
+		$actions = apply_filters('give_api_row_actions', array_filter($actions));
167 167
 
168
-		return sprintf( '%1$s %2$s', $item['user'], $this->row_actions( $actions ) );
168
+		return sprintf('%1$s %2$s', $item['user'], $this->row_actions($actions));
169 169
 	}
170 170
 
171 171
 	/**
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	public function get_columns() {
191 191
 		$columns = array(
192
-			'user'   => esc_html__( 'Username', 'give' ),
193
-			'key'    => esc_html__( 'Public Key', 'give' ),
194
-			'token'  => esc_html__( 'Token', 'give' ),
195
-			'secret' => esc_html__( 'Secret Key', 'give' ),
192
+			'user'   => esc_html__('Username', 'give'),
193
+			'key'    => esc_html__('Public Key', 'give'),
194
+			'token'  => esc_html__('Token', 'give'),
195
+			'secret' => esc_html__('Secret Key', 'give'),
196 196
 		);
197 197
 
198 198
 		return $columns;
@@ -206,20 +206,20 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @param string $which
208 208
 	 */
209
-	protected function display_tablenav( $which ) {
210
-		if ( 'top' === $which ) {
211
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
209
+	protected function display_tablenav($which) {
210
+		if ('top' === $which) {
211
+			wp_nonce_field('bulk-'.$this->_args['plural']);
212 212
 		}
213 213
 		?>
214
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
214
+		<div class="tablenav <?php echo esc_attr($which); ?>">
215 215
 
216 216
 			<div class="alignleft actions bulkactions">
217
-				<?php $this->bulk_actions( $which ); ?>
217
+				<?php $this->bulk_actions($which); ?>
218 218
 			</div>
219 219
 
220 220
 			<?php
221
-			$this->extra_tablenav( $which );
222
-			$this->pagination( $which );
221
+			$this->extra_tablenav($which);
222
+			$this->pagination($which);
223 223
 			?>
224 224
 
225 225
 			<br class="clear"/>
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return void
239 239
 	 */
240
-	function bulk_actions( $which = '' ) {
240
+	function bulk_actions($which = '') {
241 241
 		// These aren't really bulk actions but this outputs the markup in the right place.
242 242
 		static $give_api_is_bottom;
243 243
 
244
-		if ( $give_api_is_bottom ) {
244
+		if ($give_api_is_bottom) {
245 245
 			return;
246 246
 		}
247 247
 		?>
248 248
 		<input type="hidden" name="give_action" value="process_api_key"/>
249 249
 		<input type="hidden" name="give_api_process" value="generate"/>
250
-		<?php wp_nonce_field( 'give-api-nonce' );
250
+		<?php wp_nonce_field('give-api-nonce');
251 251
 		/**
252 252
 		 * API Key user search.
253 253
 		 */
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		  'name' => 'user_id',
257 257
         );
258 258
         echo Give()->html->ajax_user_search($args); ?>
259
-		<?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?>
259
+		<?php submit_button(esc_html__('Generate New API Keys', 'give'), 'secondary', 'submit', false); ?>
260 260
 		<?php
261 261
 		$give_api_is_bottom = true;
262 262
 	}
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * @return int Current page number
270 270
 	 */
271 271
 	public function get_paged() {
272
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
272
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
273 273
 	}
274 274
 
275 275
 	/**
@@ -280,21 +280,21 @@  discard block
 block discarded – undo
280 280
 	 * @return array
281 281
 	 */
282 282
 	public function query() {
283
-		$users = get_users( array(
283
+		$users = get_users(array(
284 284
 			'meta_value' => 'give_user_secret_key',
285 285
 			'number'     => $this->per_page,
286
-			'offset'     => $this->per_page * ( $this->get_paged() - 1 ),
287
-		) );
288
-		$keys  = array();
289
-
290
-		foreach ( $users as $user ) {
291
-			$keys[ $user->ID ]['id']    = $user->ID;
292
-			$keys[ $user->ID ]['email'] = $user->user_email;
293
-			$keys[ $user->ID ]['user']  = '<a href="' . add_query_arg( 'user_id', $user->ID, 'user-edit.php' ) . '"><strong>' . $user->user_login . '</strong></a>';
294
-
295
-			$keys[ $user->ID ]['key']    = Give()->api->get_user_public_key( $user->ID );
296
-			$keys[ $user->ID ]['secret'] = Give()->api->get_user_secret_key( $user->ID );
297
-			$keys[ $user->ID ]['token']  = Give()->api->get_token( $user->ID );
286
+			'offset'     => $this->per_page * ($this->get_paged() - 1),
287
+		));
288
+		$keys = array();
289
+
290
+		foreach ($users as $user) {
291
+			$keys[$user->ID]['id']    = $user->ID;
292
+			$keys[$user->ID]['email'] = $user->user_email;
293
+			$keys[$user->ID]['user']  = '<a href="'.add_query_arg('user_id', $user->ID, 'user-edit.php').'"><strong>'.$user->user_login.'</strong></a>';
294
+
295
+			$keys[$user->ID]['key']    = Give()->api->get_user_public_key($user->ID);
296
+			$keys[$user->ID]['secret'] = Give()->api->get_user_secret_key($user->ID);
297
+			$keys[$user->ID]['token']  = Give()->api->get_token($user->ID);
298 298
 		}
299 299
 
300 300
 		return $keys;
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	public function total_items() {
312 312
 		global $wpdb;
313 313
 
314
-		if ( ! ( $total_items = Give_Cache::get( 'give_total_api_keys', true ) ) ) {
314
+		if ( ! ($total_items = Give_Cache::get('give_total_api_keys', true))) {
315 315
 			$total_items = $wpdb->get_var(
316 316
 				$wpdb->prepare(
317 317
 					"SELECT count(user_id)
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 				)
321 321
 			);
322 322
 
323
-			Give_Cache::set( 'give_total_api_keys', $total_items, HOUR_IN_SECONDS, true );
323
+			Give_Cache::set('give_total_api_keys', $total_items, HOUR_IN_SECONDS, true);
324 324
 		}
325 325
 
326 326
 		return $total_items;
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 		$hidden   = array(); // No hidden columns
340 340
 		$sortable = array(); // Not sortable... for now
341 341
 
342
-		$this->_column_headers = array( $columns, $hidden, $sortable );
342
+		$this->_column_headers = array($columns, $hidden, $sortable);
343 343
 
344 344
 		$data = $this->query();
345 345
 
@@ -347,10 +347,10 @@  discard block
 block discarded – undo
347 347
 
348 348
 		$this->items = $data;
349 349
 
350
-		$this->set_pagination_args( array(
350
+		$this->set_pagination_args(array(
351 351
 				'total_items' => $total_items,
352 352
 				'per_page'    => $this->per_page,
353
-				'total_pages' => ceil( $total_items / $this->per_page ),
353
+				'total_pages' => ceil($total_items / $this->per_page),
354 354
 			)
355 355
 		);
356 356
 	}
Please login to merge, or discard this patch.
includes/admin/tools/export/class-batch-export-forms.php 1 patch
Spacing   +51 added lines, -51 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
 
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
 	public function csv_cols() {
42 42
 
43 43
 		$cols = array(
44
-			'ID'                      => __( 'ID', 'give' ),
45
-			'post_name'               => __( 'Slug', 'give' ),
46
-			'post_title'              => __( 'Name', 'give' ),
47
-			'post_date'               => __( 'Date Created', 'give' ),
48
-			'post_author'             => __( 'Author', 'give' ),
49
-			'post_content'            => __( 'Description', 'give' ),
50
-			'post_excerpt'            => __( 'Excerpt', 'give' ),
51
-			'post_status'             => __( 'Status', 'give' ),
52
-			'categories'              => __( 'Categories', 'give' ),
53
-			'tags'                    => __( 'Tags', 'give' ),
54
-			'give_price'              => __( 'Price', 'give' ),
55
-			'_thumbnail_id'           => __( 'Featured Image', 'give' ),
56
-			'_give_form_sales'        => __( 'Donations', 'give' ),
57
-			'_give_download_earnings' => __( 'Income', 'give' ),
44
+			'ID'                      => __('ID', 'give'),
45
+			'post_name'               => __('Slug', 'give'),
46
+			'post_title'              => __('Name', 'give'),
47
+			'post_date'               => __('Date Created', 'give'),
48
+			'post_author'             => __('Author', 'give'),
49
+			'post_content'            => __('Description', 'give'),
50
+			'post_excerpt'            => __('Excerpt', 'give'),
51
+			'post_status'             => __('Status', 'give'),
52
+			'categories'              => __('Categories', 'give'),
53
+			'tags'                    => __('Tags', 'give'),
54
+			'give_price'              => __('Price', 'give'),
55
+			'_thumbnail_id'           => __('Featured Image', 'give'),
56
+			'_give_form_sales'        => __('Donations', 'give'),
57
+			'_give_download_earnings' => __('Income', 'give'),
58 58
 		);
59 59
 
60 60
 		return $cols;
@@ -84,43 +84,43 @@  discard block
 block discarded – undo
84 84
 			'paged'          => $this->step
85 85
 		);
86 86
 
87
-		$forms = new WP_Query( $args );
87
+		$forms = new WP_Query($args);
88 88
 
89
-		if ( $forms->posts ) {
90
-			foreach ( $forms->posts as $form ) {
89
+		if ($forms->posts) {
90
+			foreach ($forms->posts as $form) {
91 91
 
92 92
 				$row = [];
93 93
 
94
-				foreach ( $this->csv_cols() as $key => $value ) {
94
+				foreach ($this->csv_cols() as $key => $value) {
95 95
 
96 96
 					// Setup default value/
97
-					$row[ $key ] = '';
97
+					$row[$key] = '';
98 98
 
99
-					if ( in_array( $key, $meta ) ) {
99
+					if (in_array($key, $meta)) {
100 100
 
101
-						switch ( $key ) {
101
+						switch ($key) {
102 102
 
103 103
 							case '_thumbnail_id' :
104 104
 
105
-								$image_id    = get_post_thumbnail_id( $form->ID );
106
-								$row[ $key ] = wp_get_attachment_url( $image_id );
105
+								$image_id    = get_post_thumbnail_id($form->ID);
106
+								$row[$key] = wp_get_attachment_url($image_id);
107 107
 
108 108
 								break;
109 109
 
110 110
 							case 'give_price' :
111 111
 
112
-								if ( give_has_variable_prices( $form->ID ) ) {
112
+								if (give_has_variable_prices($form->ID)) {
113 113
 
114 114
 									$prices = [];
115
-									foreach ( give_get_variable_prices( $form->ID ) as $price ) {
116
-										$prices[] = $price['name'] . ': ' . $price['amount'];
115
+									foreach (give_get_variable_prices($form->ID) as $price) {
116
+										$prices[] = $price['name'].': '.$price['amount'];
117 117
 									}
118 118
 
119
-									$row[ $key ] = implode( ' | ', $prices );
119
+									$row[$key] = implode(' | ', $prices);
120 120
 
121 121
 								} else {
122 122
 
123
-									$row[ $key ] = give_get_form_price( $form->ID );
123
+									$row[$key] = give_get_form_price($form->ID);
124 124
 
125 125
 								}
126 126
 
@@ -128,44 +128,44 @@  discard block
 block discarded – undo
128 128
 
129 129
 							default :
130 130
 
131
-								$row[ $key ] = give_get_meta( $form->ID, $key, TRUE );
131
+								$row[$key] = give_get_meta($form->ID, $key, TRUE);
132 132
 
133 133
 								break;
134 134
 
135 135
 						}
136 136
 
137
-					} elseif ( isset( $form->$key ) ) {
137
+					} elseif (isset($form->$key)) {
138 138
 
139
-						switch ( $key ) {
139
+						switch ($key) {
140 140
 
141 141
 							case 'post_author' :
142 142
 
143
-								$row[ $key ] = get_the_author_meta( 'user_login', $form->post_author );
143
+								$row[$key] = get_the_author_meta('user_login', $form->post_author);
144 144
 
145 145
 								break;
146 146
 
147 147
 							default :
148 148
 
149
-								$row[ $key ] = $form->$key;
149
+								$row[$key] = $form->$key;
150 150
 
151 151
 								break;
152 152
 						}
153 153
 
154
-					} elseif ( 'tags' == $key ) {
154
+					} elseif ('tags' == $key) {
155 155
 
156
-						$terms = get_the_terms( $form->ID, 'form_tag' );
157
-						if ( $terms ) {
158
-							$terms       = wp_list_pluck( $terms, 'name' );
159
-							$row[ $key ] = implode( ' | ', $terms );
156
+						$terms = get_the_terms($form->ID, 'form_tag');
157
+						if ($terms) {
158
+							$terms       = wp_list_pluck($terms, 'name');
159
+							$row[$key] = implode(' | ', $terms);
160 160
 						}
161 161
 
162 162
 
163
-					} elseif ( 'categories' == $key ) {
163
+					} elseif ('categories' == $key) {
164 164
 
165
-						$terms = get_the_terms( $form->ID, 'form_category' );
166
-						if ( $terms ) {
167
-							$terms       = wp_list_pluck( $terms, 'name' );
168
-							$row[ $key ] = implode( ' | ', $terms );
165
+						$terms = get_the_terms($form->ID, 'form_category');
166
+						if ($terms) {
167
+							$terms       = wp_list_pluck($terms, 'name');
168
+							$row[$key] = implode(' | ', $terms);
169 169
 						}
170 170
 
171 171
 					}
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 
177 177
 			}
178 178
 
179
-			$data = apply_filters( 'give_export_get_data', $data );
180
-			$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
179
+			$data = apply_filters('give_export_get_data', $data);
180
+			$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
181 181
 
182 182
 			return $data;
183 183
 
@@ -197,20 +197,20 @@  discard block
 block discarded – undo
197 197
 
198 198
 		$args = array(
199 199
 			'post_type'      => 'give_forms',
200
-			'posts_per_page' => - 1,
200
+			'posts_per_page' => -1,
201 201
 			'post_status'    => 'any',
202 202
 			'fields'         => 'ids',
203 203
 		);
204 204
 
205
-		$forms  = new WP_Query( $args );
205
+		$forms = new WP_Query($args);
206 206
 		$total      = (int) $forms->post_count;
207 207
 		$percentage = 100;
208 208
 
209
-		if ( $total > 0 ) {
210
-			$percentage = ( ( 30 * $this->step ) / $total ) * 100;
209
+		if ($total > 0) {
210
+			$percentage = ((30 * $this->step) / $total) * 100;
211 211
 		}
212 212
 
213
-		if ( $percentage > 100 ) {
213
+		if ($percentage > 100) {
214 214
 			$percentage = 100;
215 215
 		}
216 216
 
Please login to merge, or discard this patch.
includes/actions.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -216,7 +216,6 @@
 block discarded – undo
216 216
 /**
217 217
  * Set Donation Amount for Multi Level Donation Forms
218 218
  *
219
- * @param int    $form_id
220 219
  * @param object $form
221 220
  *
222 221
  * @since 1.8.9
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_get_actions() {
27 27
 
28
-	$_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null;
28
+	$_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null;
29 29
 
30 30
 	// Add backward compatibility to give-action param ( $_GET )
31
-	if ( empty( $_get_action ) ) {
32
-		$_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null;
31
+	if (empty($_get_action)) {
32
+		$_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null;
33 33
 	}
34 34
 
35
-	if ( isset( $_get_action ) ) {
35
+	if (isset($_get_action)) {
36 36
 		/**
37 37
 		 * Fires in WordPress init or admin init, when give_action is present in $_GET.
38 38
 		 *
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @param array $_GET Array of HTTP GET variables.
42 42
 		 */
43
-		do_action( "give_{$_get_action}", $_GET );
43
+		do_action("give_{$_get_action}", $_GET);
44 44
 	}
45 45
 
46 46
 }
47 47
 
48
-add_action( 'init', 'give_get_actions' );
48
+add_action('init', 'give_get_actions');
49 49
 
50 50
 /**
51 51
  * Hooks Give actions, when present in the $_POST super global. Every give_action
@@ -58,15 +58,15 @@  discard block
 block discarded – undo
58 58
  */
59 59
 function give_post_actions() {
60 60
 
61
-	$_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null;
61
+	$_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null;
62 62
 
63 63
 
64 64
 	// Add backward compatibility to give-action param ( $_POST ).
65
-	if ( empty( $_post_action ) ) {
66
-		$_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null;
65
+	if (empty($_post_action)) {
66
+		$_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null;
67 67
 	}
68 68
 
69
-	if ( isset( $_post_action ) ) {
69
+	if (isset($_post_action)) {
70 70
 		/**
71 71
 		 * Fires in WordPress init or admin init, when give_action is present in $_POST.
72 72
 		 *
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 		 *
75 75
 		 * @param array $_POST Array of HTTP POST variables.
76 76
 		 */
77
-		do_action( "give_{$_post_action}", $_POST );
77
+		do_action("give_{$_post_action}", $_POST);
78 78
 	}
79 79
 
80 80
 }
81 81
 
82
-add_action( 'init', 'give_post_actions' );
82
+add_action('init', 'give_post_actions');
83 83
 
84 84
 /**
85 85
  * Connect WordPress user with Donor.
@@ -91,29 +91,29 @@  discard block
 block discarded – undo
91 91
  *
92 92
  * @return void
93 93
  */
94
-function give_connect_donor_to_wpuser( $user_id, $user_data ) {
94
+function give_connect_donor_to_wpuser($user_id, $user_data) {
95 95
 	/* @var Give_Donor $donor */
96
-	$donor = new Give_Donor( $user_data['user_email'] );
96
+	$donor = new Give_Donor($user_data['user_email']);
97 97
 
98 98
 	// Validate donor id and check if do nor is already connect to wp user or not.
99
-	if ( $donor->id && ! $donor->user_id ) {
99
+	if ($donor->id && ! $donor->user_id) {
100 100
 
101 101
 		// Update donor user_id.
102
-		if ( $donor->update( array( 'user_id' => $user_id ) ) ) {
103
-			$donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id );
104
-			$donor->add_note( $donor_note );
102
+		if ($donor->update(array('user_id' => $user_id))) {
103
+			$donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id);
104
+			$donor->add_note($donor_note);
105 105
 
106 106
 			// Update user_id meta in payments.
107
-			if ( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) {
108
-				foreach ( $donations as $donation ) {
109
-					give_update_meta( $donation, '_give_payment_user_id', $user_id );
107
+			if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) {
108
+				foreach ($donations as $donation) {
109
+					give_update_meta($donation, '_give_payment_user_id', $user_id);
110 110
 				}
111 111
 			}
112 112
 		}
113 113
 	}
114 114
 }
115 115
 
116
-add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 );
116
+add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2);
117 117
 
118 118
 
119 119
 /**
@@ -127,44 +127,44 @@  discard block
 block discarded – undo
127 127
  */
128 128
 function give_validate_license_when_site_migrated() {
129 129
 	// Store current site address if not already stored.
130
-	$home_url_parts              = parse_url( home_url() );
131
-	$home_url                    = isset( $home_url_parts['host'] ) ? $home_url_parts['host'] : false;
132
-	$home_url                    .= isset( $home_url_parts['path'] ) ? $home_url_parts['path'] : '';
133
-	$site_address_before_migrate = get_option( 'give_site_address_before_migrate' );
130
+	$home_url_parts              = parse_url(home_url());
131
+	$home_url                    = isset($home_url_parts['host']) ? $home_url_parts['host'] : false;
132
+	$home_url .= isset($home_url_parts['path']) ? $home_url_parts['path'] : '';
133
+	$site_address_before_migrate = get_option('give_site_address_before_migrate');
134 134
 
135 135
 	// Need $home_url to proceed
136
-	if ( ! $home_url ) {
136
+	if ( ! $home_url) {
137 137
 		return;
138 138
 	}
139 139
 
140 140
 	// Save site address
141
-	if ( ! $site_address_before_migrate ) {
141
+	if ( ! $site_address_before_migrate) {
142 142
 		// Update site address.
143
-		update_option( 'give_site_address_before_migrate', $home_url );
143
+		update_option('give_site_address_before_migrate', $home_url);
144 144
 
145 145
 		return;
146 146
 	}
147 147
 
148 148
 	// Backwards compat. for before when we were storing URL scheme.
149
-	if ( strpos( $site_address_before_migrate, 'http' ) ) {
150
-		$site_address_before_migrate = parse_url( $site_address_before_migrate );
151
-		$site_address_before_migrate = isset( $site_address_before_migrate['host'] ) ? $site_address_before_migrate['host'] : false;
149
+	if (strpos($site_address_before_migrate, 'http')) {
150
+		$site_address_before_migrate = parse_url($site_address_before_migrate);
151
+		$site_address_before_migrate = isset($site_address_before_migrate['host']) ? $site_address_before_migrate['host'] : false;
152 152
 		// Add path for multisite installs.
153
-		$site_address_before_migrate .= isset( $site_address_before_migrate['path'] ) ? $site_address_before_migrate['path'] : '';
153
+		$site_address_before_migrate .= isset($site_address_before_migrate['path']) ? $site_address_before_migrate['path'] : '';
154 154
 	}
155 155
 
156 156
 	// If the two URLs don't match run CRON.
157
-	if ( $home_url !== $site_address_before_migrate ) {
157
+	if ($home_url !== $site_address_before_migrate) {
158 158
 		// Immediately run cron.
159
-		wp_schedule_single_event( time(), 'give_validate_license_when_site_migrated' );
159
+		wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated');
160 160
 
161 161
 		// Update site address.
162
-		update_option( 'give_site_address_before_migrate', $home_url );
162
+		update_option('give_site_address_before_migrate', $home_url);
163 163
 	}
164 164
 
165 165
 }
166 166
 
167
-add_action( 'admin_init', 'give_validate_license_when_site_migrated' );
167
+add_action('admin_init', 'give_validate_license_when_site_migrated');
168 168
 
169 169
 
170 170
 /**
@@ -174,19 +174,19 @@  discard block
 block discarded – undo
174 174
  *
175 175
  * @param $data
176 176
  */
177
-function give_donor_batch_export_complete( $data ) {
177
+function give_donor_batch_export_complete($data) {
178 178
 	// Remove donor ids cache.
179 179
 	if (
180
-		isset( $data['class'] )
180
+		isset($data['class'])
181 181
 		&& 'Give_Batch_Donors_Export' === $data['class']
182
-		&& ! empty( $data['forms'] )
183
-		&& isset( $data['give_export_option']['query_id'] )
182
+		&& ! empty($data['forms'])
183
+		&& isset($data['give_export_option']['query_id'])
184 184
 	) {
185
-		Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) );
185
+		Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id']));
186 186
 	}
187 187
 }
188 188
 
189
-add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' );
189
+add_action('give_file_export_complete', 'give_donor_batch_export_complete');
190 190
 
191 191
 /**
192 192
  * Print css for wordpress setting pages.
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 	/* @var WP_Screen $screen */
198 198
 	$screen = get_current_screen();
199 199
 
200
-	if ( ! ( $screen instanceof WP_Screen ) ) {
200
+	if ( ! ($screen instanceof WP_Screen)) {
201 201
 		return false;
202 202
 	}
203 203
 
204
-	switch ( true ) {
205
-		case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ):
204
+	switch (true) {
205
+		case ('plugins' === $screen->base || 'plugins-network' === $screen->base):
206 206
 			?>
207 207
 			<style>
208 208
 				tr.active.update + tr.give-addon-notice-tr td {
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 }
241 241
 
242
-add_action( 'admin_head', 'give_admin_quick_css' );
242
+add_action('admin_head', 'give_admin_quick_css');
243 243
 
244 244
 
245 245
 /**
@@ -252,28 +252,28 @@  discard block
 block discarded – undo
252 252
  *
253 253
  * @return void
254 254
  */
255
-function give_set_donation_levels_max_min_amount( $form_id ) {
255
+function give_set_donation_levels_max_min_amount($form_id) {
256 256
 	if (
257
-		( 'set' === $_POST['_give_price_option'] ) ||
258
-		( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) ||
259
-		! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) )
257
+		('set' === $_POST['_give_price_option']) ||
258
+		(in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) ||
259
+		! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount'))
260 260
 	) {
261 261
 		// Delete old meta.
262
-		give_delete_meta( $form_id, '_give_levels_minimum_amount' );
263
-		give_delete_meta( $form_id, '_give_levels_maximum_amount' );
262
+		give_delete_meta($form_id, '_give_levels_minimum_amount');
263
+		give_delete_meta($form_id, '_give_levels_maximum_amount');
264 264
 
265 265
 		return;
266 266
 	}
267 267
 
268 268
 	// Sanitize donation level amounts.
269
-	$donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts );
269
+	$donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts);
270 270
 
271
-	$min_amount = min( $donation_levels_amounts );
272
-	$max_amount = max( $donation_levels_amounts );
271
+	$min_amount = min($donation_levels_amounts);
272
+	$max_amount = max($donation_levels_amounts);
273 273
 
274 274
 	// Set Minimum and Maximum amount for Multi Level Donation Forms
275
-	give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 );
276
-	give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 );
275
+	give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0);
276
+	give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0);
277 277
 }
278 278
 
279
-add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 );
280 279
\ No newline at end of file
280
+add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30);
281 281
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/donors/class-donor-table.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -253,7 +253,7 @@
 block discarded – undo
253 253
 	 *
254 254
 	 * @access public
255 255
 	 * @since  1.0
256
-	 * @return mixed string If search is present, false otherwise.
256
+	 * @return string|false string If search is present, false otherwise.
257 257
 	 */
258 258
 	public function get_search() {
259 259
 		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  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
 
19 19
 // Load WP_List_Table if not loaded
20
-if ( ! class_exists( 'WP_List_Table' ) ) {
21
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
20
+if ( ! class_exists('WP_List_Table')) {
21
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
22 22
 }
23 23
 
24 24
 /**
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	public function __construct() {
62 62
 
63 63
 		// Set parent defaults
64
-		parent::__construct( array(
65
-			'singular' => __( 'Donor', 'give' ),     // Singular name of the listed records.
66
-			'plural'   => __( 'Donors', 'give' ),    // Plural name of the listed records.
67
-			'ajax'     => false,// Does this table support ajax?.
68
-		) );
64
+		parent::__construct(array(
65
+			'singular' => __('Donor', 'give'), // Singular name of the listed records.
66
+			'plural'   => __('Donors', 'give'), // Plural name of the listed records.
67
+			'ajax'     => false, // Does this table support ajax?.
68
+		));
69 69
 
70 70
 	}
71 71
 
@@ -80,22 +80,22 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return void
82 82
 	 */
83
-	public function search_box( $text, $input_id ) {
84
-		$input_id = $input_id . '-search-input';
83
+	public function search_box($text, $input_id) {
84
+		$input_id = $input_id.'-search-input';
85 85
 
86
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
87
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
86
+		if ( ! empty($_REQUEST['orderby'])) {
87
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
88 88
 		}
89
-		if ( ! empty( $_REQUEST['order'] ) ) {
90
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
89
+		if ( ! empty($_REQUEST['order'])) {
90
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
91 91
 		}
92 92
 		?>
93 93
 		<p class="search-box" role="search">
94 94
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
95 95
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
96
-			<?php submit_button( $text, 'button', false, false, array(
96
+			<?php submit_button($text, 'button', false, false, array(
97 97
 				'ID' => 'search-submit',
98
-			) ); ?>
98
+			)); ?>
99 99
 		</p>
100 100
 		<?php
101 101
 	}
@@ -111,31 +111,31 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @return string Column Name.
113 113
 	 */
114
-	public function column_default( $donor, $column_name ) {
115
-		switch ( $column_name ) {
114
+	public function column_default($donor, $column_name) {
115
+		switch ($column_name) {
116 116
 
117 117
 			case 'num_donations' :
118 118
 				$value = sprintf(
119 119
 					'<a href="%s">%s</a>',
120
-					admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ),
121
-					esc_html( $donor['num_donations'] )
120
+					admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])),
121
+					esc_html($donor['num_donations'])
122 122
 				);
123 123
 				break;
124 124
 
125 125
 			case 'amount_spent' :
126
-				$value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) );
126
+				$value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false)));
127 127
 				break;
128 128
 
129 129
 			case 'date_created' :
130
-				$value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) );
130
+				$value = date_i18n(give_date_format(), strtotime($donor['date_created']));
131 131
 				break;
132 132
 
133 133
 			default:
134
-				$value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null;
134
+				$value = isset($donor[$column_name]) ? $donor[$column_name] : null;
135 135
 				break;
136 136
 		}
137 137
 
138
-		return apply_filters( "give_donors_column_{$column_name}", $value, $donor['id'] );
138
+		return apply_filters("give_donors_column_{$column_name}", $value, $donor['id']);
139 139
 
140 140
 	}
141 141
 
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string
148 148
 	 */
149
-	public function column_name( $donor ) {
150
-		$name     = '#' . $donor['id'] . ' ';
151
-		$name     .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>';
152
-		$view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] );
153
-		$actions  = $this->get_row_actions( $donor );
149
+	public function column_name($donor) {
150
+		$name     = '#'.$donor['id'].' ';
151
+		$name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>';
152
+		$view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']);
153
+		$actions  = $this->get_row_actions($donor);
154 154
 
155
-		return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions );
155
+		return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions);
156 156
 	}
157 157
 
158 158
 	/**
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public function get_columns() {
166 166
 		$columns = array(
167
-			'name'          => __( 'Name', 'give' ),
168
-			'email'         => __( 'Email', 'give' ),
169
-			'num_donations' => __( 'Donations', 'give' ),
170
-			'amount_spent'  => __( 'Total Donated', 'give' ),
171
-			'date_created'  => __( 'Date Created', 'give' ),
167
+			'name'          => __('Name', 'give'),
168
+			'email'         => __('Email', 'give'),
169
+			'num_donations' => __('Donations', 'give'),
170
+			'amount_spent'  => __('Total Donated', 'give'),
171
+			'date_created'  => __('Date Created', 'give'),
172 172
 		);
173 173
 
174
-		return apply_filters( 'give_list_donors_columns', $columns );
174
+		return apply_filters('give_list_donors_columns', $columns);
175 175
 
176 176
 	}
177 177
 
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 	public function get_sortable_columns() {
186 186
 
187 187
 		$columns = array(
188
-			'date_created'  => array( 'date_created', true ),
189
-			'name'          => array( 'name', true ),
190
-			'num_donations' => array( 'purchase_count', false ),
191
-			'amount_spent'  => array( 'purchase_value', false ),
188
+			'date_created'  => array('date_created', true),
189
+			'name'          => array('name', true),
190
+			'num_donations' => array('purchase_count', false),
191
+			'amount_spent'  => array('purchase_value', false),
192 192
 		);
193 193
 
194
-		return apply_filters( 'give_list_donors_sortable_columns', $columns );
194
+		return apply_filters('give_list_donors_sortable_columns', $columns);
195 195
 	}
196 196
 
197 197
 	/**
@@ -204,19 +204,19 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return array An array of action links.
206 206
 	 */
207
-	public function get_row_actions( $donor ) {
207
+	public function get_row_actions($donor) {
208 208
 
209 209
 		$actions = array(
210 210
 
211
-			'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ),
211
+			'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')),
212 212
 
213
-			'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ),
213
+			'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')),
214 214
 
215
-			'delete' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor['id'] ), sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ),
215
+			'delete' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor['id']), sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')),
216 216
 
217 217
 		);
218 218
 
219
-		return apply_filters( 'give_donor_row_actions', $actions, $donor );
219
+		return apply_filters('give_donor_row_actions', $actions, $donor);
220 220
 
221 221
 	}
222 222
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @since  1.0
231 231
 	 * @return void
232 232
 	 */
233
-	public function bulk_actions( $which = '' ) {
233
+	public function bulk_actions($which = '') {
234 234
 		// These aren't really bulk actions but this outputs the markup in the right place.
235 235
 	}
236 236
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * @return int Current page number.
243 243
 	 */
244 244
 	public function get_paged() {
245
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
245
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
246 246
 	}
247 247
 
248 248
 	/**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @return mixed string If search is present, false otherwise.
254 254
 	 */
255 255
 	public function get_search() {
256
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
256
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
257 257
 	}
258 258
 
259 259
 	/**
@@ -270,13 +270,13 @@  discard block
 block discarded – undo
270 270
 
271 271
 		// Get donor query.
272 272
 		$args   = $this->get_donor_query();
273
-		$donors = Give()->donors->get_donors( $args );
273
+		$donors = Give()->donors->get_donors($args);
274 274
 
275
-		if ( $donors ) {
275
+		if ($donors) {
276 276
 
277
-			foreach ( $donors as $donor ) {
277
+			foreach ($donors as $donor) {
278 278
 
279
-				$user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0;
279
+				$user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0;
280 280
 
281 281
 				$data[] = array(
282 282
 					'id'            => $donor->id,
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			}
291 291
 		}
292 292
 
293
-		return apply_filters( 'give_donors_column_query_data', $data );
293
+		return apply_filters('give_donors_column_query_data', $data);
294 294
 	}
295 295
 
296 296
 	/**
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
 
306 306
 		$_donor_query['number'] = - 1;
307 307
 		$_donor_query['offset'] = 0;
308
-		$donors                 = Give()->donors->get_donors( $_donor_query );
308
+		$donors                 = Give()->donors->get_donors($_donor_query);
309 309
 
310
-		return count( $donors );
310
+		return count($donors);
311 311
 	}
312 312
 
313 313
 	/**
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
 	 */
320 320
 	public function get_donor_query() {
321 321
 		$paged   = $this->get_paged();
322
-		$offset  = $this->per_page * ( $paged - 1 );
322
+		$offset  = $this->per_page * ($paged - 1);
323 323
 		$search  = $this->get_search();
324
-		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
325
-		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
324
+		$order   = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC';
325
+		$orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id';
326 326
 
327 327
 		$args = array(
328 328
 			'number'  => $this->per_page,
@@ -331,10 +331,10 @@  discard block
 block discarded – undo
331 331
 			'orderby' => $orderby,
332 332
 		);
333 333
 
334
-		if ( $search ) {
335
-			if ( is_email( $search ) ) {
334
+		if ($search) {
335
+			if (is_email($search)) {
336 336
 				$args['email'] = $search;
337
-			} elseif ( is_numeric( $search ) ) {
337
+			} elseif (is_numeric($search)) {
338 338
 				$args['id'] = $search;
339 339
 			} else {
340 340
 				$args['name'] = $search;
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 		$hidden   = array(); // No hidden columns.
358 358
 		$sortable = $this->get_sortable_columns();
359 359
 
360
-		$this->_column_headers = array( $columns, $hidden, $sortable );
360
+		$this->_column_headers = array($columns, $hidden, $sortable);
361 361
 
362 362
 		$this->items = $this->donor_data();
363 363
 
364 364
 		$this->total = $this->get_donor_count();
365 365
 
366
-		$this->set_pagination_args( array(
366
+		$this->set_pagination_args(array(
367 367
 			'total_items' => $this->total,
368 368
 			'per_page'    => $this->per_page,
369
-			'total_pages' => ceil( $this->total / $this->per_page ),
370
-		) );
369
+			'total_pages' => ceil($this->total / $this->per_page),
370
+		));
371 371
 	}
372 372
 }
Please login to merge, or discard this patch.
includes/admin/donors/donor-actions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
  *
273 273
  * @param  array $args The $_POST array being passed.
274 274
  *
275
- * @return int Whether it was a successful deletion.
275
+ * @return false|null Whether it was a successful deletion.
276 276
  */
277 277
 function give_donor_delete( $args ) {
278 278
 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
  * Remove an email address to the donor from within the admin and log a donor note and redirect back to the donor interface for feedback.
547 547
  *
548 548
  * @since  1.7
549
- * @return bool|null
549
+ * @return false|null
550 550
  */
551 551
 function give_remove_donor_email() {
552 552
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
  * and redirect back to the donor interface for feedback
590 590
  *
591 591
  * @since  1.7
592
- * @return bool|null
592
+ * @return false|null
593 593
  */
594 594
 function give_set_donor_primary_email() {
595 595
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
Please login to merge, or discard this patch.
Spacing   +190 added lines, -190 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
 
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array|bool $output Response messages
25 25
  */
26
-function give_edit_donor( $args ) {
26
+function give_edit_donor($args) {
27 27
 
28
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
28
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
29 29
 
30
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
31
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
30
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
31
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
32 32
 			'response' => 403,
33
-		) );
33
+		));
34 34
 	}
35 35
 
36
-	if ( empty( $args ) ) {
36
+	if (empty($args)) {
37 37
 		return false;
38 38
 	}
39 39
 
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
 	$donor_id   = (int) $args['customerinfo']['id'];
42 42
 	$nonce      = $args['_wpnonce'];
43 43
 
44
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
45
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
44
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
45
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
46 46
 			'response' => 400,
47
-		) );
47
+		));
48 48
 	}
49 49
 
50
-	$donor = new Give_Donor( $donor_id );
50
+	$donor = new Give_Donor($donor_id);
51 51
 
52
-	if ( empty( $donor->id ) ) {
52
+	if (empty($donor->id)) {
53 53
 		return false;
54 54
 	}
55 55
 
@@ -64,67 +64,67 @@  discard block
 block discarded – undo
64 64
 		'country' => '',
65 65
 	);
66 66
 
67
-	$donor_info = wp_parse_args( $donor_info, $defaults );
67
+	$donor_info = wp_parse_args($donor_info, $defaults);
68 68
 
69
-	if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) {
69
+	if ((int) $donor_info['user_id'] !== (int) $donor->user_id) {
70 70
 
71 71
 		// Make sure we don't already have this user attached to a donor.
72
-		if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) {
73
-			give_set_error( 'give-invalid-donor-user_id', sprintf( __( 'The User ID #%d is already associated with a different donor.', 'give' ), $donor_info['user_id'] ) );
72
+		if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) {
73
+			give_set_error('give-invalid-donor-user_id', sprintf(__('The User ID #%d is already associated with a different donor.', 'give'), $donor_info['user_id']));
74 74
 		}
75 75
 
76 76
 		// Make sure it's actually a user.
77
-		$user = get_user_by( 'id', $donor_info['user_id'] );
78
-		if ( ! empty( $donor_info['user_id'] ) && false === $user ) {
79
-			give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ), $donor_info['user_id'] ) );
77
+		$user = get_user_by('id', $donor_info['user_id']);
78
+		if ( ! empty($donor_info['user_id']) && false === $user) {
79
+			give_set_error('give-invalid-user_id', sprintf(__('The User ID #%d does not exist. Please assign an existing user.', 'give'), $donor_info['user_id']));
80 80
 		}
81 81
 	}
82 82
 
83
-	if ( give_get_errors() ) {
83
+	if (give_get_errors()) {
84 84
 		return false;
85 85
 	}
86 86
 
87 87
 	// Setup the donor address, if present.
88 88
 	$address = array();
89
-	if ( intval( $donor_info['user_id'] ) > 0 ) {
90
-
91
-		$current_address = (array) get_user_meta( $donor_info['user_id'], '_give_user_address', true );
92
-
93
-		if ( is_array( $current_address ) && 0 < count( $current_address ) ) {
94
-			$current_address    = wp_parse_args( $current_address, $defaults );
95
-			$address['line1']   = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : $current_address['line1'];
96
-			$address['line2']   = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : $current_address['line2'];
97
-			$address['city']    = ! empty( $donor_info['city'] ) ? $donor_info['city'] : $current_address['city'];
98
-			$address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : $current_address['country'];
99
-			$address['zip']     = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : $current_address['zip'];
100
-			$address['state']   = ! empty( $donor_info['state'] ) ? $donor_info['state'] : $current_address['state'];
89
+	if (intval($donor_info['user_id']) > 0) {
90
+
91
+		$current_address = (array) get_user_meta($donor_info['user_id'], '_give_user_address', true);
92
+
93
+		if (is_array($current_address) && 0 < count($current_address)) {
94
+			$current_address    = wp_parse_args($current_address, $defaults);
95
+			$address['line1']   = ! empty($donor_info['line1']) ? $donor_info['line1'] : $current_address['line1'];
96
+			$address['line2']   = ! empty($donor_info['line2']) ? $donor_info['line2'] : $current_address['line2'];
97
+			$address['city']    = ! empty($donor_info['city']) ? $donor_info['city'] : $current_address['city'];
98
+			$address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : $current_address['country'];
99
+			$address['zip']     = ! empty($donor_info['zip']) ? $donor_info['zip'] : $current_address['zip'];
100
+			$address['state']   = ! empty($donor_info['state']) ? $donor_info['state'] : $current_address['state'];
101 101
 		} else {
102
-			$address['line1']   = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : '';
103
-			$address['line2']   = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : '';
104
-			$address['city']    = ! empty( $donor_info['city'] ) ? $donor_info['city'] : '';
105
-			$address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : '';
106
-			$address['zip']     = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : '';
107
-			$address['state']   = ! empty( $donor_info['state'] ) ? $donor_info['state'] : '';
102
+			$address['line1']   = ! empty($donor_info['line1']) ? $donor_info['line1'] : '';
103
+			$address['line2']   = ! empty($donor_info['line2']) ? $donor_info['line2'] : '';
104
+			$address['city']    = ! empty($donor_info['city']) ? $donor_info['city'] : '';
105
+			$address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : '';
106
+			$address['zip']     = ! empty($donor_info['zip']) ? $donor_info['zip'] : '';
107
+			$address['state']   = ! empty($donor_info['state']) ? $donor_info['state'] : '';
108 108
 		}
109 109
 
110 110
 	}
111 111
 
112 112
 	// Sanitize the inputs.
113 113
 	$donor_data            = array();
114
-	$donor_data['name']    = strip_tags( stripslashes( $donor_info['name'] ) );
114
+	$donor_data['name']    = strip_tags(stripslashes($donor_info['name']));
115 115
 	$donor_data['user_id'] = $donor_info['user_id'];
116 116
 
117
-	$donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id );
118
-	$address    = apply_filters( 'give_edit_donor_address', $address, $donor_id );
117
+	$donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id);
118
+	$address    = apply_filters('give_edit_donor_address', $address, $donor_id);
119 119
 
120
-	$donor_data = array_map( 'sanitize_text_field', $donor_data );
121
-	$address    = array_map( 'sanitize_text_field', $address );
120
+	$donor_data = array_map('sanitize_text_field', $donor_data);
121
+	$address    = array_map('sanitize_text_field', $address);
122 122
 
123
-	$output = give_connect_user_donor_profile( $donor, $donor_data, $address );
123
+	$output = give_connect_user_donor_profile($donor, $donor_data, $address);
124 124
 
125
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
126
-		header( 'Content-Type: application/json' );
127
-		echo json_encode( $output );
125
+	if (defined('DOING_AJAX') && DOING_AJAX) {
126
+		header('Content-Type: application/json');
127
+		echo json_encode($output);
128 128
 		wp_die();
129 129
 	}
130 130
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
 }
134 134
 
135
-add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 );
135
+add_action('give_edit-donor', 'give_edit_donor', 10, 1);
136 136
 
137 137
 /**
138 138
  * Save a donor note.
@@ -143,40 +143,40 @@  discard block
 block discarded – undo
143 143
  *
144 144
  * @return int         The Note ID that was saved, or 0 if nothing was saved.
145 145
  */
146
-function give_donor_save_note( $args ) {
146
+function give_donor_save_note($args) {
147 147
 
148
-	$donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
148
+	$donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports');
149 149
 
150
-	if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) {
151
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
150
+	if ( ! is_admin() || ! current_user_can($donor_view_role)) {
151
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
152 152
 			'response' => 403,
153
-		) );
153
+		));
154 154
 	}
155 155
 
156
-	if ( empty( $args ) ) {
156
+	if (empty($args)) {
157 157
 		return false;
158 158
 	}
159 159
 
160
-	$donor_note = trim( sanitize_text_field( $args['donor_note'] ) );
160
+	$donor_note = trim(sanitize_text_field($args['donor_note']));
161 161
 	$donor_id   = (int) $args['customer_id'];
162 162
 	$nonce      = $args['add_donor_note_nonce'];
163 163
 
164
-	if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) {
165
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
164
+	if ( ! wp_verify_nonce($nonce, 'add-donor-note')) {
165
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
166 166
 			'response' => 400,
167
-		) );
167
+		));
168 168
 	}
169 169
 
170
-	if ( empty( $donor_note ) ) {
171
-		give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) );
170
+	if (empty($donor_note)) {
171
+		give_set_error('empty-donor-note', __('A note is required.', 'give'));
172 172
 	}
173 173
 
174
-	if ( give_get_errors() ) {
174
+	if (give_get_errors()) {
175 175
 		return false;
176 176
 	}
177 177
 
178
-	$donor    = new Give_Donor( $donor_id );
179
-	$new_note = $donor->add_note( $donor_note );
178
+	$donor    = new Give_Donor($donor_id);
179
+	$new_note = $donor->add_note($donor_note);
180 180
 
181 181
 	/**
182 182
 	 * Fires before inserting donor note.
@@ -186,22 +186,22 @@  discard block
 block discarded – undo
186 186
 	 * @param int    $donor_id The ID of the donor.
187 187
 	 * @param string $new_note Note content.
188 188
 	 */
189
-	do_action( 'give_pre_insert_donor_note', $donor_id, $new_note );
189
+	do_action('give_pre_insert_donor_note', $donor_id, $new_note);
190 190
 
191
-	if ( ! empty( $new_note ) && ! empty( $donor->id ) ) {
191
+	if ( ! empty($new_note) && ! empty($donor->id)) {
192 192
 
193 193
 		ob_start();
194 194
 		?>
195 195
 		<div class="donor-note-wrapper dashboard-comment-wrap comment-item">
196 196
 			<span class="note-content-wrap">
197
-				<?php echo stripslashes( $new_note ); ?>
197
+				<?php echo stripslashes($new_note); ?>
198 198
 			</span>
199 199
 		</div>
200 200
 		<?php
201 201
 		$output = ob_get_contents();
202 202
 		ob_end_clean();
203 203
 
204
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
204
+		if (defined('DOING_AJAX') && DOING_AJAX) {
205 205
 			echo $output;
206 206
 			exit;
207 207
 		}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 }
216 216
 
217
-add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 );
217
+add_action('give_add-donor-note', 'give_donor_save_note', 10, 1);
218 218
 
219 219
 /**
220 220
  * Delete a donor.
@@ -225,41 +225,41 @@  discard block
 block discarded – undo
225 225
  *
226 226
  * @return int Whether it was a successful deletion.
227 227
  */
228
-function give_donor_delete( $args ) {
228
+function give_donor_delete($args) {
229 229
 
230
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
230
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
231 231
 
232
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
233
-		wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array(
232
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
233
+		wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array(
234 234
 			'response' => 403,
235
-		) );
235
+		));
236 236
 	}
237 237
 
238
-	if ( empty( $args ) ) {
238
+	if (empty($args)) {
239 239
 		return false;
240 240
 	}
241 241
 
242 242
 	$donor_id    = (int) $args['customer_id'];
243
-	$confirm     = ! empty( $args['give-donor-delete-confirm'] ) ? true : false;
244
-	$remove_data = ! empty( $args['give-donor-delete-records'] ) ? true : false;
243
+	$confirm     = ! empty($args['give-donor-delete-confirm']) ? true : false;
244
+	$remove_data = ! empty($args['give-donor-delete-records']) ? true : false;
245 245
 	$nonce       = $args['_wpnonce'];
246 246
 
247
-	if ( ! wp_verify_nonce( $nonce, 'delete-donor' ) ) {
248
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
247
+	if ( ! wp_verify_nonce($nonce, 'delete-donor')) {
248
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
249 249
 			'response' => 400,
250
-		) );
250
+		));
251 251
 	}
252 252
 
253
-	if ( ! $confirm ) {
254
-		give_set_error( 'donor-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) );
253
+	if ( ! $confirm) {
254
+		give_set_error('donor-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give'));
255 255
 	}
256 256
 
257
-	if ( give_get_errors() ) {
258
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id ) );
257
+	if (give_get_errors()) {
258
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id));
259 259
 		exit;
260 260
 	}
261 261
 
262
-	$donor = new Give_Donor( $donor_id );
262
+	$donor = new Give_Donor($donor_id);
263 263
 
264 264
 	/**
265 265
 	 * Fires before deleting donor.
@@ -270,50 +270,50 @@  discard block
 block discarded – undo
270 270
 	 * @param bool $confirm     Delete confirmation.
271 271
 	 * @param bool $remove_data Records delete confirmation.
272 272
 	 */
273
-	do_action( 'give_pre_delete_donor', $donor_id, $confirm, $remove_data );
273
+	do_action('give_pre_delete_donor', $donor_id, $confirm, $remove_data);
274 274
 
275
-	if ( $donor->id > 0 ) {
275
+	if ($donor->id > 0) {
276 276
 
277
-		$payments_array = explode( ',', $donor->payment_ids );
278
-		$success        = Give()->donors->delete( $donor->id );
277
+		$payments_array = explode(',', $donor->payment_ids);
278
+		$success        = Give()->donors->delete($donor->id);
279 279
 
280
-		if ( $success ) {
280
+		if ($success) {
281 281
 
282
-			if ( $remove_data ) {
282
+			if ($remove_data) {
283 283
 
284 284
 				// Remove all donations, logs, etc.
285
-				foreach ( $payments_array as $payment_id ) {
286
-					give_delete_donation( $payment_id );
285
+				foreach ($payments_array as $payment_id) {
286
+					give_delete_donation($payment_id);
287 287
 				}
288 288
 			} else {
289 289
 
290 290
 				// Just set the donations to customer_id of 0.
291
-				foreach ( $payments_array as $payment_id ) {
292
-					give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 );
291
+				foreach ($payments_array as $payment_id) {
292
+					give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
293 293
 				}
294 294
 			}
295 295
 
296
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted' );
296
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted');
297 297
 
298 298
 		} else {
299 299
 
300
-			give_set_error( 'give-donor-delete-failed', __( 'Error deleting donor.', 'give' ) );
301
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor_id );
300
+			give_set_error('give-donor-delete-failed', __('Error deleting donor.', 'give'));
301
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor_id);
302 302
 
303 303
 		}
304 304
 	} else {
305 305
 
306
-		give_set_error( 'give-donor-delete-invalid-id', __( 'Invalid Donor ID.', 'give' ) );
307
-		$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' );
306
+		give_set_error('give-donor-delete-invalid-id', __('Invalid Donor ID.', 'give'));
307
+		$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
308 308
 
309 309
 	}
310 310
 
311
-	wp_redirect( $redirect );
311
+	wp_redirect($redirect);
312 312
 	exit;
313 313
 
314 314
 }
315 315
 
316
-add_action( 'give_delete-donor', 'give_donor_delete', 10, 1 );
316
+add_action('give_delete-donor', 'give_donor_delete', 10, 1);
317 317
 
318 318
 /**
319 319
  * Disconnect a user ID from a donor
@@ -324,17 +324,17 @@  discard block
 block discarded – undo
324 324
  *
325 325
  * @return bool|array        If the disconnect was successful.
326 326
  */
327
-function give_disconnect_donor_user_id( $args ) {
327
+function give_disconnect_donor_user_id($args) {
328 328
 
329
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
329
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
330 330
 
331
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
332
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
331
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
332
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
333 333
 			'response' => 403,
334
-		) );
334
+		));
335 335
 	}
336 336
 
337
-	if ( empty( $args ) ) {
337
+	if (empty($args)) {
338 338
 		return false;
339 339
 	}
340 340
 
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 
343 343
 	$nonce = $args['_wpnonce'];
344 344
 
345
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
346
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
345
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
346
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
347 347
 			'response' => 400,
348
-		) );
348
+		));
349 349
 	}
350 350
 
351
-	$donor = new Give_Donor( $donor_id );
352
-	if ( empty( $donor->id ) ) {
351
+	$donor = new Give_Donor($donor_id);
352
+	if (empty($donor->id)) {
353 353
 		return false;
354 354
 	}
355 355
 
@@ -363,34 +363,34 @@  discard block
 block discarded – undo
363 363
 	 * @param int $donor_id The ID of the donor.
364 364
 	 * @param int $user_id  The ID of the user.
365 365
 	 */
366
-	do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id );
366
+	do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id);
367 367
 
368 368
 	$output     = array();
369 369
 	$donor_args = array(
370 370
 		'user_id' => 0,
371 371
 	);
372 372
 
373
-	if ( $donor->update( $donor_args ) ) {
373
+	if ($donor->update($donor_args)) {
374 374
 		global $wpdb;
375 375
 
376
-		if ( ! empty( $donor->payment_ids ) ) {
377
-			$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )" );
376
+		if ( ! empty($donor->payment_ids)) {
377
+			$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )");
378 378
 		}
379 379
 
380 380
 		// Set Donor Disconnection status true, if user and donor are disconnected with each other.
381
-		update_user_meta( $user_id, '_give_is_donor_disconnected', true );
382
-		update_user_meta( $user_id, '_give_disconnected_donor_id', $donor->id );
383
-		$donor->update_meta( '_give_disconnected_user_id', $user_id );
381
+		update_user_meta($user_id, '_give_is_donor_disconnected', true);
382
+		update_user_meta($user_id, '_give_disconnected_donor_id', $donor->id);
383
+		$donor->update_meta('_give_disconnected_user_id', $user_id);
384 384
 
385 385
 		$output['success'] = true;
386 386
 
387 387
 	} else {
388 388
 
389 389
 		$output['success'] = false;
390
-		give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) );
390
+		give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give'));
391 391
 	}
392 392
 
393
-	$output['redirect'] = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' ) . $donor_id;
393
+	$output['redirect'] = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=').$donor_id;
394 394
 
395 395
 	/**
396 396
 	 * Fires after disconnecting user ID from a donor.
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
 	 *
400 400
 	 * @param int $donor_id The ID of the donor.
401 401
 	 */
402
-	do_action( 'give_post_donor_disconnect_user_id', $donor_id );
402
+	do_action('give_post_donor_disconnect_user_id', $donor_id);
403 403
 
404
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
405
-		header( 'Content-Type: application/json' );
406
-		echo json_encode( $output );
404
+	if (defined('DOING_AJAX') && DOING_AJAX) {
405
+		header('Content-Type: application/json');
406
+		echo json_encode($output);
407 407
 		wp_die();
408 408
 	}
409 409
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 
412 412
 }
413 413
 
414
-add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 );
414
+add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1);
415 415
 
416 416
 /**
417 417
  * Add an email address to the donor from within the admin and log a donor note.
@@ -422,90 +422,90 @@  discard block
 block discarded – undo
422 422
  *
423 423
  * @return mixed        If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string).
424 424
  */
425
-function give_add_donor_email( $args ) {
425
+function give_add_donor_email($args) {
426 426
 	/**
427 427
 	 * Define variable
428 428
 	 *
429 429
 	 * @since 1.8.14
430 430
 	 */
431 431
 	$donor_id = '';
432
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
432
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
433 433
 
434
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
435
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
434
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
435
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
436 436
 			'response' => 403,
437
-		) );
437
+		));
438 438
 	}
439 439
 
440 440
 	$output = array();
441
-	if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
441
+	if (empty($args) || empty($args['email']) || empty($args['customer_id'])) {
442 442
 		$output['success'] = false;
443
-		if ( empty( $args['email'] ) ) {
444
-			$output['message'] = __( 'Email address is required.', 'give' );
445
-		} elseif ( empty( $args['customer_id'] ) ) {
446
-			$output['message'] = __( 'Donor ID is required.', 'give' );
443
+		if (empty($args['email'])) {
444
+			$output['message'] = __('Email address is required.', 'give');
445
+		} elseif (empty($args['customer_id'])) {
446
+			$output['message'] = __('Donor ID is required.', 'give');
447 447
 		} else {
448
-			$output['message'] = __( 'An error has occurred. Please try again.', 'give' );
448
+			$output['message'] = __('An error has occurred. Please try again.', 'give');
449 449
 		}
450
-	} elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
450
+	} elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) {
451 451
 		$output = array(
452 452
 			'success' => false,
453
-			'message' => __( 'Nonce verification failed.', 'give' ),
453
+			'message' => __('Nonce verification failed.', 'give'),
454 454
 		);
455
-	} elseif ( ! is_email( $args['email'] ) ) {
455
+	} elseif ( ! is_email($args['email'])) {
456 456
 		$output = array(
457 457
 			'success' => false,
458
-			'message' => __( 'Invalid email.', 'give' ),
458
+			'message' => __('Invalid email.', 'give'),
459 459
 		);
460 460
 	} else {
461
-		$email    = sanitize_email( $args['email'] );
461
+		$email    = sanitize_email($args['email']);
462 462
 		$donor_id = (int) $args['customer_id'];
463 463
 		$primary  = 'true' === $args['primary'] ? true : false;
464
-		$donor    = new Give_Donor( $donor_id );
465
-		if ( false === $donor->add_email( $email, $primary ) ) {
466
-			if ( in_array( $email, $donor->emails ) ) {
464
+		$donor    = new Give_Donor($donor_id);
465
+		if (false === $donor->add_email($email, $primary)) {
466
+			if (in_array($email, $donor->emails)) {
467 467
 				$output = array(
468 468
 					'success' => false,
469
-					'message' => __( 'Email already associated with this donor.', 'give' ),
469
+					'message' => __('Email already associated with this donor.', 'give'),
470 470
 				);
471 471
 			} else {
472 472
 				$output = array(
473 473
 					'success' => false,
474
-					'message' => __( 'Email address is already associated with another donor.', 'give' ),
474
+					'message' => __('Email address is already associated with another donor.', 'give'),
475 475
 				);
476 476
 			}
477 477
 		} else {
478
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-message=email-added' );
478
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-message=email-added');
479 479
 			$output   = array(
480 480
 				'success'  => true,
481
-				'message'  => __( 'Email successfully added to donor.', 'give' ),
481
+				'message'  => __('Email successfully added to donor.', 'give'),
482 482
 				'redirect' => $redirect,
483 483
 			);
484 484
 
485 485
 			$user       = wp_get_current_user();
486
-			$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
487
-			$donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login );
488
-			$donor->add_note( $donor_note );
486
+			$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
487
+			$donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login);
488
+			$donor->add_note($donor_note);
489 489
 
490
-			if ( $primary ) {
491
-				$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login );
492
-				$donor->add_note( $donor_note );
490
+			if ($primary) {
491
+				$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login);
492
+				$donor->add_note($donor_note);
493 493
 			}
494 494
 		}
495 495
 	}// End if().
496 496
 
497
-	do_action( 'give_post_add_donor_email', $donor_id, $args );
497
+	do_action('give_post_add_donor_email', $donor_id, $args);
498 498
 
499
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
500
-		header( 'Content-Type: application/json' );
501
-		echo json_encode( $output );
499
+	if (defined('DOING_AJAX') && DOING_AJAX) {
500
+		header('Content-Type: application/json');
501
+		echo json_encode($output);
502 502
 		wp_die();
503 503
 	}
504 504
 
505 505
 	return $output;
506 506
 }
507 507
 
508
-add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
508
+add_action('give_add_donor_email', 'give_add_donor_email', 10, 1);
509 509
 
510 510
 
511 511
 /**
@@ -515,39 +515,39 @@  discard block
 block discarded – undo
515 515
  * @return bool|null
516 516
  */
517 517
 function give_remove_donor_email() {
518
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
518
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
519 519
 		return false;
520 520
 	}
521
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
521
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
522 522
 		return false;
523 523
 	}
524
-	if ( empty( $_GET['_wpnonce'] ) ) {
524
+	if (empty($_GET['_wpnonce'])) {
525 525
 		return false;
526 526
 	}
527 527
 
528 528
 	$nonce = $_GET['_wpnonce'];
529
-	if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
530
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
529
+	if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) {
530
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array(
531 531
 			'response' => 403,
532
-		) );
532
+		));
533 533
 	}
534 534
 
535
-	$donor = new Give_Donor( $_GET['id'] );
536
-	if ( $donor->remove_email( $_GET['email'] ) ) {
537
-		$url        = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
535
+	$donor = new Give_Donor($_GET['id']);
536
+	if ($donor->remove_email($_GET['email'])) {
537
+		$url        = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
538 538
 		$user       = wp_get_current_user();
539
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
540
-		$donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login );
541
-		$donor->add_note( $donor_note );
539
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
540
+		$donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login);
541
+		$donor->add_note($donor_note);
542 542
 	} else {
543
-		$url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
543
+		$url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
544 544
 	}
545 545
 
546
-	wp_safe_redirect( $url );
546
+	wp_safe_redirect($url);
547 547
 	exit;
548 548
 }
549 549
 
550
-add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
550
+add_action('give_remove_donor_email', 'give_remove_donor_email', 10);
551 551
 
552 552
 
553 553
 /**
@@ -558,41 +558,41 @@  discard block
 block discarded – undo
558 558
  * @return bool|null
559 559
  */
560 560
 function give_set_donor_primary_email() {
561
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
561
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
562 562
 		return false;
563 563
 	}
564 564
 
565
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
565
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
566 566
 		return false;
567 567
 	}
568 568
 
569
-	if ( empty( $_GET['_wpnonce'] ) ) {
569
+	if (empty($_GET['_wpnonce'])) {
570 570
 		return false;
571 571
 	}
572 572
 
573 573
 	$nonce = $_GET['_wpnonce'];
574 574
 
575
-	if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
576
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
575
+	if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) {
576
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array(
577 577
 			'response' => 403,
578
-		) );
578
+		));
579 579
 	}
580 580
 
581
-	$donor = new Give_Donor( $_GET['id'] );
581
+	$donor = new Give_Donor($_GET['id']);
582 582
 
583
-	if ( $donor->set_primary_email( $_GET['email'] ) ) {
584
-		$url        = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
583
+	if ($donor->set_primary_email($_GET['email'])) {
584
+		$url        = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
585 585
 		$user       = wp_get_current_user();
586
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
587
-		$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login );
586
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
587
+		$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login);
588 588
 
589
-		$donor->add_note( $donor_note );
589
+		$donor->add_note($donor_note);
590 590
 	} else {
591
-		$url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
591
+		$url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
592 592
 	}
593 593
 
594
-	wp_safe_redirect( $url );
594
+	wp_safe_redirect($url);
595 595
 	exit;
596 596
 }
597 597
 
598
-add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
598
+add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10);
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-donor-stats.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 	 * @access public
50 50
 	 * @since 1.5
51 51
 	 *
52
-	 * @return array $data The data for the CSV file
52
+	 * @return boolean $data The data for the CSV file
53 53
 	 */
54 54
 	public function get_data() {
55 55
 
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 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
 
@@ -57,32 +57,32 @@  discard block
 block discarded – undo
57 57
 
58 58
 		$args = array(
59 59
 			'number'  => $this->per_step,
60
-			'offset'  => $this->per_step * ( $this->step - 1 ),
60
+			'offset'  => $this->per_step * ($this->step - 1),
61 61
 			'orderby' => 'id',
62 62
 			'order'   => 'DESC',
63 63
 		);
64 64
 
65
-		$donors = Give()->donors->get_donors( $args );
65
+		$donors = Give()->donors->get_donors($args);
66 66
 
67
-		if ( $donors ) {
67
+		if ($donors) {
68 68
 
69
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
69
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
70 70
 
71
-			foreach ( $donors as $donor ) {
71
+			foreach ($donors as $donor) {
72 72
 
73
-				$attached_payment_ids = explode( ',', $donor->payment_ids );
73
+				$attached_payment_ids = explode(',', $donor->payment_ids);
74 74
 
75 75
 				$attached_args = array(
76 76
 					'post__in' => $attached_payment_ids,
77
-					'number'   => - 1,
77
+					'number'   => -1,
78 78
 					'status'   => $allowed_payment_status,
79 79
 				);
80 80
 
81
-				$attached_payments = (array) give_get_payments( $attached_args );
81
+				$attached_payments = (array) give_get_payments($attached_args);
82 82
 
83 83
 				$unattached_args = array(
84 84
 					'post__not_in' => $attached_payment_ids,
85
-					'number'       => - 1,
85
+					'number'       => -1,
86 86
 					'status'       => $allowed_payment_status,
87 87
 					'meta_query'   => array(
88 88
 						array(
@@ -93,29 +93,29 @@  discard block
 block discarded – undo
93 93
 					),
94 94
 				);
95 95
 
96
-				$unattached_payments = give_get_payments( $unattached_args );
96
+				$unattached_payments = give_get_payments($unattached_args);
97 97
 
98
-				$payments = array_merge( $attached_payments, $unattached_payments );
98
+				$payments = array_merge($attached_payments, $unattached_payments);
99 99
 
100 100
 				$purchase_value = 0.00;
101 101
 				$purchase_count = 0;
102 102
 				$payment_ids    = array();
103 103
 
104
-				if ( $payments ) {
104
+				if ($payments) {
105 105
 
106
-					foreach ( $payments as $payment ) {
106
+					foreach ($payments as $payment) {
107 107
 
108 108
 						$should_process_payment = 'publish' == $payment->post_status ? true : false;
109
-						$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
109
+						$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
110 110
 
111
-						if ( true === $should_process_payment ) {
111
+						if (true === $should_process_payment) {
112 112
 
113
-							if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
114
-								$purchase_value += give_get_payment_amount( $payment->ID );
113
+							if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
114
+								$purchase_value += give_get_payment_amount($payment->ID);
115 115
 							}
116 116
 
117
-							if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
118
-								$purchase_count ++;
117
+							if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
118
+								$purchase_count++;
119 119
 							}
120 120
 						}
121 121
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 					}
124 124
 				}
125 125
 
126
-				$payment_ids = implode( ',', $payment_ids );
126
+				$payment_ids = implode(',', $payment_ids);
127 127
 
128 128
 				$donor_update_data = array(
129 129
 					'purchase_count' => $purchase_count,
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 					'payment_ids'    => $payment_ids,
132 132
 				);
133 133
 
134
-				$donor_instance = new Give_Donor( $donor->id );
135
-				$donor_instance->update( $donor_update_data );
134
+				$donor_instance = new Give_Donor($donor->id);
135
+				$donor_instance->update($donor_update_data);
136 136
 
137 137
 			}// End foreach().
138 138
 
@@ -152,21 +152,21 @@  discard block
 block discarded – undo
152 152
 	public function get_percentage_complete() {
153 153
 
154 154
 		$args = array(
155
-			'number'  => - 1,
155
+			'number'  => -1,
156 156
 			'orderby' => 'id',
157 157
 			'order'   => 'DESC',
158 158
 		);
159 159
 
160
-		$donors = Give()->donors->get_donors( $args );
161
-		$total     = count( $donors );
160
+		$donors = Give()->donors->get_donors($args);
161
+		$total = count($donors);
162 162
 
163 163
 		$percentage = 100;
164 164
 
165
-		if ( $total > 0 ) {
166
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
165
+		if ($total > 0) {
166
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
167 167
 		}
168 168
 
169
-		if ( $percentage > 100 ) {
169
+		if ($percentage > 100) {
170 170
 			$percentage = 100;
171 171
 		}
172 172
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @param array $request The Form Data passed into the batch processing
182 182
 	 */
183
-	public function set_properties( $request ) {
183
+	public function set_properties($request) {
184 184
 	}
185 185
 
186 186
 	/**
@@ -191,21 +191,21 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	public function process_step() {
193 193
 
194
-		if ( ! $this->can_export() ) {
195
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array(
194
+		if ( ! $this->can_export()) {
195
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array(
196 196
 				'response' => 403,
197
-			) );
197
+			));
198 198
 		}
199 199
 
200 200
 		$had_data = $this->get_data();
201 201
 
202
-		if ( $had_data ) {
202
+		if ($had_data) {
203 203
 			$this->done = false;
204 204
 
205 205
 			return true;
206 206
 		} else {
207 207
 			$this->done    = true;
208
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
208
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
209 209
 
210 210
 			return false;
211 211
 		}
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 	 * Headers
216 216
 	 */
217 217
 	public function headers() {
218
-		ignore_user_abort( true );
218
+		ignore_user_abort(true);
219 219
 
220
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
221
-			set_time_limit( 0 );
220
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
221
+			set_time_limit(0);
222 222
 		}
223 223
 	}
224 224
 
Please login to merge, or discard this patch.
includes/api/class-give-api.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 *
217 217
 	 * @access public
218 218
 	 * @since  1.1
219
-	 * @return array
219
+	 * @return string
220 220
 	 */
221 221
 	public function get_versions() {
222 222
 		return $this->versions;
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 * @uses   Give_API::invalid_key()
303 303
 	 * @uses   Give_API::invalid_auth()
304 304
 	 * @since  1.1
305
-	 * @return bool
305
+	 * @return false|null
306 306
 	 */
307 307
 	private function validate_request() {
308 308
 		global $wp_query;
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 	 *
695 695
 	 * @param array $args Arguments to override defaults
696 696
 	 *
697
-	 * @return array $dates
697
+	 * @return integer|null $dates
698 698
 	 */
699 699
 	public function get_dates( $args = array() ) {
700 700
 		$dates = array();
Please login to merge, or discard this patch.
Spacing   +511 added lines, -511 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();
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 * @since  1.1
177 177
 	 */
178 178
 	public function add_endpoint() {
179
-		add_rewrite_endpoint( 'give-api', EP_ALL );
179
+		add_rewrite_endpoint('give-api', EP_ALL);
180 180
 	}
181 181
 
182 182
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return string[] $vars New query vars
191 191
 	 */
192
-	public function query_vars( $vars ) {
192
+	public function query_vars($vars) {
193 193
 
194 194
 		$vars[] = 'token';
195 195
 		$vars[] = 'key';
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function get_default_version() {
242 242
 
243
-		$version = get_option( 'give_default_api_version' );
243
+		$version = get_option('give_default_api_version');
244 244
 
245
-		if ( defined( 'GIVE_API_VERSION' ) ) {
245
+		if (defined('GIVE_API_VERSION')) {
246 246
 			$version = GIVE_API_VERSION;
247
-		} elseif ( ! $version ) {
247
+		} elseif ( ! $version) {
248 248
 			$version = 'v1';
249 249
 		}
250 250
 
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 
266 266
 		$version = $wp_query->query_vars['give-api'];
267 267
 
268
-		if ( strpos( $version, '/' ) ) {
268
+		if (strpos($version, '/')) {
269 269
 
270
-			$version = explode( '/', $version );
271
-			$version = strtolower( $version[0] );
270
+			$version = explode('/', $version);
271
+			$version = strtolower($version[0]);
272 272
 
273
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
273
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
274 274
 
275
-			if ( array_key_exists( $version, $this->versions ) ) {
275
+			if (array_key_exists($version, $this->versions)) {
276 276
 
277 277
 				$this->queried_version = $version;
278 278
 
@@ -308,16 +308,16 @@  discard block
 block discarded – undo
308 308
 		$this->override = false;
309 309
 
310 310
 		// Make sure we have both user and api key
311
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] !== 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
311
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] !== 'forms' || ! empty($wp_query->query_vars['token']))) {
312 312
 
313
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
313
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
314 314
 				$this->missing_auth();
315 315
 
316 316
 				return false;
317 317
 			}
318 318
 
319 319
 			// Retrieve the user by public API key and ensure they exist
320
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
320
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
321 321
 
322 322
 				$this->invalid_key();
323 323
 
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 
326 326
 			} else {
327 327
 
328
-				$token  = urldecode( $wp_query->query_vars['token'] );
329
-				$secret = $this->get_user_secret_key( $user );
330
-				$public = urldecode( $wp_query->query_vars['key'] );
328
+				$token  = urldecode($wp_query->query_vars['token']);
329
+				$secret = $this->get_user_secret_key($user);
330
+				$public = urldecode($wp_query->query_vars['key']);
331 331
 
332
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
332
+				if (hash_equals(md5($secret.$public), $token)) {
333 333
 					$this->is_valid_request = true;
334 334
 				} else {
335 335
 					$this->invalid_auth();
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
 				}
339 339
 
340 340
 			}
341
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) {
341
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') {
342 342
 			$this->is_valid_request = true;
343
-			$wp_query->set( 'key', 'public' );
343
+			$wp_query->set('key', 'public');
344 344
 		}
345 345
 	}
346 346
 
@@ -356,25 +356,25 @@  discard block
 block discarded – undo
356 356
 	 *
357 357
 	 * @return bool if user ID is found, false otherwise
358 358
 	 */
359
-	public function get_user( $key = '' ) {
359
+	public function get_user($key = '') {
360 360
 		global $wpdb, $wp_query;
361 361
 
362
-		if ( empty( $key ) ) {
363
-			$key = urldecode( $wp_query->query_vars['key'] );
362
+		if (empty($key)) {
363
+			$key = urldecode($wp_query->query_vars['key']);
364 364
 		}
365 365
 
366
-		if ( empty( $key ) ) {
366
+		if (empty($key)) {
367 367
 			return false;
368 368
 		}
369 369
 
370
-		$user = Give_Cache::get( md5( 'give_api_user_' . $key ), true );
370
+		$user = Give_Cache::get(md5('give_api_user_'.$key), true);
371 371
 
372
-		if ( false === $user ) {
373
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
374
-			Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true );
372
+		if (false === $user) {
373
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
374
+			Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true);
375 375
 		}
376 376
 
377
-		if ( $user != null ) {
377
+		if ($user != null) {
378 378
 			$this->user_id = $user;
379 379
 
380 380
 			return $user;
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 	 *
391 391
 	 * @return mixed|null|string
392 392
 	 */
393
-	public function get_user_public_key( $user_id = 0 ) {
393
+	public function get_user_public_key($user_id = 0) {
394 394
 		global $wpdb;
395 395
 
396
-		if ( empty( $user_id ) ) {
396
+		if (empty($user_id)) {
397 397
 			return '';
398 398
 		}
399 399
 
400
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
401
-		$user_public_key = Give_Cache::get( $cache_key, true );
400
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
401
+		$user_public_key = Give_Cache::get($cache_key, true);
402 402
 
403
-		if ( empty( $user_public_key ) ) {
404
-			$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 ) );
405
-			Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true );
403
+		if (empty($user_public_key)) {
404
+			$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));
405
+			Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true);
406 406
 		}
407 407
 
408 408
 		return $user_public_key;
@@ -415,19 +415,19 @@  discard block
 block discarded – undo
415 415
 	 *
416 416
 	 * @return mixed|null|string
417 417
 	 */
418
-	public function get_user_secret_key( $user_id = 0 ) {
418
+	public function get_user_secret_key($user_id = 0) {
419 419
 		global $wpdb;
420 420
 
421
-		if ( empty( $user_id ) ) {
421
+		if (empty($user_id)) {
422 422
 			return '';
423 423
 		}
424 424
 
425
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
426
-		$user_secret_key = Give_Cache::get( $cache_key, true );
425
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
426
+		$user_secret_key = Give_Cache::get($cache_key, true);
427 427
 
428
-		if ( empty( $user_secret_key ) ) {
429
-			$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 ) );
430
-			Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true );
428
+		if (empty($user_secret_key)) {
429
+			$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));
430
+			Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true);
431 431
 		}
432 432
 
433 433
 		return $user_secret_key;
@@ -443,10 +443,10 @@  discard block
 block discarded – undo
443 443
 	 */
444 444
 	private function missing_auth() {
445 445
 		$error          = array();
446
-		$error['error'] = __( 'You must specify both a token and API key.', 'give' );
446
+		$error['error'] = __('You must specify both a token and API key.', 'give');
447 447
 
448 448
 		$this->data = $error;
449
-		$this->output( 401 );
449
+		$this->output(401);
450 450
 	}
451 451
 
452 452
 	/**
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
 	 */
461 461
 	private function invalid_auth() {
462 462
 		$error          = array();
463
-		$error['error'] = __( 'Your request could not be authenticated.', 'give' );
463
+		$error['error'] = __('Your request could not be authenticated.', 'give');
464 464
 
465 465
 		$this->data = $error;
466
-		$this->output( 403 );
466
+		$this->output(403);
467 467
 	}
468 468
 
469 469
 	/**
@@ -477,10 +477,10 @@  discard block
 block discarded – undo
477 477
 	 */
478 478
 	private function invalid_key() {
479 479
 		$error          = array();
480
-		$error['error'] = __( 'Invalid API key.', 'give' );
480
+		$error['error'] = __('Invalid API key.', 'give');
481 481
 
482 482
 		$this->data = $error;
483
-		$this->output( 403 );
483
+		$this->output(403);
484 484
 	}
485 485
 
486 486
 	/**
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
 	 */
494 494
 	private function invalid_version() {
495 495
 		$error          = array();
496
-		$error['error'] = __( 'Invalid API version.', 'give' );
496
+		$error['error'] = __('Invalid API version.', 'give');
497 497
 
498 498
 		$this->data = $error;
499
-		$this->output( 404 );
499
+		$this->output(404);
500 500
 	}
501 501
 
502 502
 	/**
@@ -512,10 +512,10 @@  discard block
 block discarded – undo
512 512
 		global $wp_query;
513 513
 
514 514
 		// Start logging how long the request takes for logging
515
-		$before = microtime( true );
515
+		$before = microtime(true);
516 516
 
517 517
 		// Check for give-api var. Get out if not present
518
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
518
+		if (empty($wp_query->query_vars['give-api'])) {
519 519
 			return;
520 520
 		}
521 521
 
@@ -529,45 +529,45 @@  discard block
 block discarded – undo
529 529
 		$this->validate_request();
530 530
 
531 531
 		// Only proceed if no errors have been noted
532
-		if ( ! $this->is_valid_request ) {
532
+		if ( ! $this->is_valid_request) {
533 533
 			return;
534 534
 		}
535 535
 
536
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
537
-			define( 'GIVE_DOING_API', true );
536
+		if ( ! defined('GIVE_DOING_API')) {
537
+			define('GIVE_DOING_API', true);
538 538
 		}
539 539
 
540 540
 		$data         = array();
541 541
 		$this->routes = new $this->versions[$this->get_queried_version()];
542 542
 		$this->routes->validate_request();
543 543
 
544
-		switch ( $this->endpoint ) :
544
+		switch ($this->endpoint) :
545 545
 
546 546
 			case 'stats' :
547 547
 
548
-				$data = $this->routes->get_stats( array(
549
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
550
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
551
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
552
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
553
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
554
-				) );
548
+				$data = $this->routes->get_stats(array(
549
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
550
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
551
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
552
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
553
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
554
+				));
555 555
 
556 556
 				break;
557 557
 
558 558
 			case 'forms' :
559 559
 
560
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
560
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
561 561
 
562
-				$data = $this->routes->get_forms( $form );
562
+				$data = $this->routes->get_forms($form);
563 563
 
564 564
 				break;
565 565
 
566 566
 			case 'donors' :
567 567
 
568
-				$donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
568
+				$donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
569 569
 
570
-				$data = $this->routes->get_donors( $donor );
570
+				$data = $this->routes->get_donors($donor);
571 571
 
572 572
 				break;
573 573
 
@@ -580,26 +580,26 @@  discard block
 block discarded – undo
580 580
 				 * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
581 581
 				 * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
582 582
 				 */
583
-				$data = $this->routes->get_recent_donations( array(
584
-					'id'        => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
585
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
586
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
587
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
588
-				) );
583
+				$data = $this->routes->get_recent_donations(array(
584
+					'id'        => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
585
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
586
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
587
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
588
+				));
589 589
 
590 590
 				break;
591 591
 
592 592
 		endswitch;
593 593
 
594 594
 		// Allow extensions to setup their own return data
595
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
595
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
596 596
 
597
-		$after                       = microtime( true );
598
-		$request_time                = ( $after - $before );
597
+		$after                       = microtime(true);
598
+		$request_time                = ($after - $before);
599 599
 		$this->data['request_speed'] = $request_time;
600 600
 
601 601
 		// Log this API request, if enabled. We log it here because we have access to errors.
602
-		$this->log_request( $this->data );
602
+		$this->log_request($this->data);
603 603
 
604 604
 		// Send out data to the output function
605 605
 		$this->output();
@@ -629,25 +629,25 @@  discard block
 block discarded – undo
629 629
 		global $wp_query;
630 630
 
631 631
 		// Whitelist our query options
632
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
632
+		$accepted = apply_filters('give_api_valid_query_modes', array(
633 633
 			'stats',
634 634
 			'forms',
635 635
 			'donors',
636 636
 			'donations',
637
-		) );
637
+		));
638 638
 
639
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
640
-		$query = str_replace( $this->queried_version . '/', '', $query );
639
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
640
+		$query = str_replace($this->queried_version.'/', '', $query);
641 641
 
642 642
 		$error = array();
643 643
 
644 644
 		// Make sure our query is valid
645
-		if ( ! in_array( $query, $accepted ) ) {
646
-			$error['error'] = __( 'Invalid query.', 'give' );
645
+		if ( ! in_array($query, $accepted)) {
646
+			$error['error'] = __('Invalid query.', 'give');
647 647
 
648 648
 			$this->data = $error;
649 649
 			// 400 is Bad Request
650
-			$this->output( 400 );
650
+			$this->output(400);
651 651
 		}
652 652
 
653 653
 		$this->endpoint = $query;
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 	public function get_paged() {
665 665
 		global $wp_query;
666 666
 
667
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
667
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
668 668
 	}
669 669
 
670 670
 
@@ -679,13 +679,13 @@  discard block
 block discarded – undo
679 679
 	public function per_page() {
680 680
 		global $wp_query;
681 681
 
682
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
682
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
683 683
 
684
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
684
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
685 685
 			$per_page = 99999999;
686 686
 		} // End if().
687 687
 
688
-		return apply_filters( 'give_api_results_per_page', $per_page );
688
+		return apply_filters('give_api_results_per_page', $per_page);
689 689
 	}
690 690
 
691 691
 	/**
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 	 *
699 699
 	 * @return array $dates
700 700
 	 */
701
-	public function get_dates( $args = array() ) {
701
+	public function get_dates($args = array()) {
702 702
 		$dates = array();
703 703
 
704 704
 		$defaults = array(
@@ -709,60 +709,60 @@  discard block
 block discarded – undo
709 709
 			'enddate'   => null,
710 710
 		);
711 711
 
712
-		$args = wp_parse_args( $args, $defaults );
712
+		$args = wp_parse_args($args, $defaults);
713 713
 
714
-		$current_time = current_time( 'timestamp' );
714
+		$current_time = current_time('timestamp');
715 715
 
716
-		if ( 'range' === $args['date'] ) {
717
-			$startdate          = strtotime( $args['startdate'] );
718
-			$enddate            = strtotime( $args['enddate'] );
719
-			$dates['day_start'] = date( 'd', $startdate );
720
-			$dates['day_end']   = date( 'd', $enddate );
721
-			$dates['m_start']   = date( 'n', $startdate );
722
-			$dates['m_end']     = date( 'n', $enddate );
723
-			$dates['year']      = date( 'Y', $startdate );
724
-			$dates['year_end']  = date( 'Y', $enddate );
716
+		if ('range' === $args['date']) {
717
+			$startdate          = strtotime($args['startdate']);
718
+			$enddate            = strtotime($args['enddate']);
719
+			$dates['day_start'] = date('d', $startdate);
720
+			$dates['day_end']   = date('d', $enddate);
721
+			$dates['m_start']   = date('n', $startdate);
722
+			$dates['m_end']     = date('n', $enddate);
723
+			$dates['year']      = date('Y', $startdate);
724
+			$dates['year_end']  = date('Y', $enddate);
725 725
 		} else {
726 726
 			// Modify dates based on predefined ranges
727
-			switch ( $args['date'] ) :
727
+			switch ($args['date']) :
728 728
 
729 729
 				case 'this_month' :
730 730
 					$dates['day']     = null;
731
-					$dates['m_start'] = date( 'n', $current_time );
732
-					$dates['m_end']   = date( 'n', $current_time );
733
-					$dates['year']    = date( 'Y', $current_time );
731
+					$dates['m_start'] = date('n', $current_time);
732
+					$dates['m_end']   = date('n', $current_time);
733
+					$dates['year']    = date('Y', $current_time);
734 734
 					break;
735 735
 
736 736
 				case 'last_month' :
737 737
 					$dates['day']     = null;
738
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
738
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
739 739
 					$dates['m_end']   = $dates['m_start'];
740
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
740
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
741 741
 					break;
742 742
 
743 743
 				case 'today' :
744
-					$dates['day']     = date( 'd', $current_time );
745
-					$dates['m_start'] = date( 'n', $current_time );
746
-					$dates['m_end']   = date( 'n', $current_time );
747
-					$dates['year']    = date( 'Y', $current_time );
744
+					$dates['day']     = date('d', $current_time);
745
+					$dates['m_start'] = date('n', $current_time);
746
+					$dates['m_end']   = date('n', $current_time);
747
+					$dates['year']    = date('Y', $current_time);
748 748
 					break;
749 749
 
750 750
 				case 'yesterday' :
751 751
 
752
-					$year  = date( 'Y', $current_time );
753
-					$month = date( 'n', $current_time );
754
-					$day   = date( 'd', $current_time );
752
+					$year  = date('Y', $current_time);
753
+					$month = date('n', $current_time);
754
+					$day   = date('d', $current_time);
755 755
 
756
-					if ( $month == 1 && $day == 1 ) {
756
+					if ($month == 1 && $day == 1) {
757 757
 
758
-						$year  -= 1;
758
+						$year -= 1;
759 759
 						$month = 12;
760
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
760
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
761 761
 
762
-					} elseif ( $month > 1 && $day == 1 ) {
762
+					} elseif ($month > 1 && $day == 1) {
763 763
 
764 764
 						$month -= 1;
765
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
765
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
766 766
 
767 767
 					} else {
768 768
 
@@ -778,65 +778,65 @@  discard block
 block discarded – undo
778 778
 					break;
779 779
 
780 780
 				case 'this_quarter' :
781
-					$month_now = date( 'n', $current_time );
781
+					$month_now = date('n', $current_time);
782 782
 
783 783
 					$dates['day'] = null;
784 784
 
785
-					if ( $month_now <= 3 ) {
785
+					if ($month_now <= 3) {
786 786
 
787 787
 						$dates['m_start'] = 1;
788 788
 						$dates['m_end']   = 3;
789
-						$dates['year']    = date( 'Y', $current_time );
789
+						$dates['year']    = date('Y', $current_time);
790 790
 
791
-					} elseif ( $month_now <= 6 ) {
791
+					} elseif ($month_now <= 6) {
792 792
 
793 793
 						$dates['m_start'] = 4;
794 794
 						$dates['m_end']   = 6;
795
-						$dates['year']    = date( 'Y', $current_time );
795
+						$dates['year']    = date('Y', $current_time);
796 796
 
797
-					} elseif ( $month_now <= 9 ) {
797
+					} elseif ($month_now <= 9) {
798 798
 
799 799
 						$dates['m_start'] = 7;
800 800
 						$dates['m_end']   = 9;
801
-						$dates['year']    = date( 'Y', $current_time );
801
+						$dates['year']    = date('Y', $current_time);
802 802
 
803 803
 					} else {
804 804
 
805 805
 						$dates['m_start'] = 10;
806 806
 						$dates['m_end']   = 12;
807
-						$dates['year']    = date( 'Y', $current_time );
807
+						$dates['year']    = date('Y', $current_time);
808 808
 
809 809
 					}
810 810
 					break;
811 811
 
812 812
 				case 'last_quarter' :
813
-					$month_now = date( 'n', $current_time );
813
+					$month_now = date('n', $current_time);
814 814
 
815 815
 					$dates['day'] = null;
816 816
 
817
-					if ( $month_now <= 3 ) {
817
+					if ($month_now <= 3) {
818 818
 
819 819
 						$dates['m_start'] = 10;
820 820
 						$dates['m_end']   = 12;
821
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
821
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
822 822
 
823
-					} elseif ( $month_now <= 6 ) {
823
+					} elseif ($month_now <= 6) {
824 824
 
825 825
 						$dates['m_start'] = 1;
826 826
 						$dates['m_end']   = 3;
827
-						$dates['year']    = date( 'Y', $current_time );
827
+						$dates['year']    = date('Y', $current_time);
828 828
 
829
-					} elseif ( $month_now <= 9 ) {
829
+					} elseif ($month_now <= 9) {
830 830
 
831 831
 						$dates['m_start'] = 4;
832 832
 						$dates['m_end']   = 6;
833
-						$dates['year']    = date( 'Y', $current_time );
833
+						$dates['year']    = date('Y', $current_time);
834 834
 
835 835
 					} else {
836 836
 
837 837
 						$dates['m_start'] = 7;
838 838
 						$dates['m_end']   = 9;
839
-						$dates['year']    = date( 'Y', $current_time );
839
+						$dates['year']    = date('Y', $current_time);
840 840
 
841 841
 					}
842 842
 					break;
@@ -845,14 +845,14 @@  discard block
 block discarded – undo
845 845
 					$dates['day']     = null;
846 846
 					$dates['m_start'] = null;
847 847
 					$dates['m_end']   = null;
848
-					$dates['year']    = date( 'Y', $current_time );
848
+					$dates['year']    = date('Y', $current_time);
849 849
 					break;
850 850
 
851 851
 				case 'last_year' :
852 852
 					$dates['day']     = null;
853 853
 					$dates['m_start'] = null;
854 854
 					$dates['m_end']   = null;
855
-					$dates['year']    = date( 'Y', $current_time ) - 1;
855
+					$dates['year']    = date('Y', $current_time) - 1;
856 856
 					break;
857 857
 
858 858
 			endswitch;
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		 *
866 866
 		 * @param array $dates The dates used for retrieving earnings.
867 867
 		 */
868
-		return apply_filters( 'give_api_stat_dates', $dates );
868
+		return apply_filters('give_api_stat_dates', $dates);
869 869
 	}
870 870
 
871 871
 	/**
@@ -879,78 +879,78 @@  discard block
 block discarded – undo
879 879
 	 *
880 880
 	 * @return array $donors Multidimensional array of the donors.
881 881
 	 */
882
-	public function get_donors( $donor = null ) {
882
+	public function get_donors($donor = null) {
883 883
 
884 884
 		$donors = array();
885 885
 		$error  = array();
886
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
886
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
887 887
 			return $donors;
888 888
 		}
889 889
 
890 890
 		$paged    = $this->get_paged();
891 891
 		$per_page = $this->per_page();
892
-		$offset   = $per_page * ( $paged - 1 );
892
+		$offset   = $per_page * ($paged - 1);
893 893
 
894
-		if ( is_numeric( $donor ) ) {
894
+		if (is_numeric($donor)) {
895 895
 			$field = 'id';
896 896
 		} else {
897 897
 			$field = 'email';
898 898
 		}
899 899
 
900
-		$donor_query = Give()->donors->get_donors( array(
900
+		$donor_query = Give()->donors->get_donors(array(
901 901
 			'number' => $per_page,
902 902
 			'offset' => $offset,
903 903
 			$field   => $donor,
904
-		) );
904
+		));
905 905
 		$donor_count = 0;
906 906
 
907
-		if ( $donor_query ) {
907
+		if ($donor_query) {
908 908
 
909
-			foreach ( $donor_query as $donor_obj ) {
909
+			foreach ($donor_query as $donor_obj) {
910 910
 
911
-				$names      = explode( ' ', $donor_obj->name );
912
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
911
+				$names      = explode(' ', $donor_obj->name);
912
+				$first_name = ! empty($names[0]) ? $names[0] : '';
913 913
 				$last_name  = '';
914
-				if ( ! empty( $names[1] ) ) {
915
-					unset( $names[0] );
916
-					$last_name = implode( ' ', $names );
914
+				if ( ! empty($names[1])) {
915
+					unset($names[0]);
916
+					$last_name = implode(' ', $names);
917 917
 				}
918 918
 
919
-				$donors['donors'][ $donor_count ]['info']['user_id']      = '';
920
-				$donors['donors'][ $donor_count ]['info']['username']     = '';
921
-				$donors['donors'][ $donor_count ]['info']['display_name'] = '';
922
-				$donors['donors'][ $donor_count ]['info']['donor_id']     = $donor_obj->id;
923
-				$donors['donors'][ $donor_count ]['info']['first_name']   = $first_name;
924
-				$donors['donors'][ $donor_count ]['info']['last_name']    = $last_name;
925
-				$donors['donors'][ $donor_count ]['info']['email']        = $donor_obj->email;
919
+				$donors['donors'][$donor_count]['info']['user_id']      = '';
920
+				$donors['donors'][$donor_count]['info']['username']     = '';
921
+				$donors['donors'][$donor_count]['info']['display_name'] = '';
922
+				$donors['donors'][$donor_count]['info']['donor_id']     = $donor_obj->id;
923
+				$donors['donors'][$donor_count]['info']['first_name']   = $first_name;
924
+				$donors['donors'][$donor_count]['info']['last_name']    = $last_name;
925
+				$donors['donors'][$donor_count]['info']['email']        = $donor_obj->email;
926 926
 
927
-				if ( ! empty( $donor_obj->user_id ) ) {
927
+				if ( ! empty($donor_obj->user_id)) {
928 928
 
929
-					$user_data = get_userdata( $donor_obj->user_id );
929
+					$user_data = get_userdata($donor_obj->user_id);
930 930
 
931 931
 					// Donor with registered account.
932
-					$donors['donors'][ $donor_count ]['info']['user_id']      = $donor_obj->user_id;
933
-					$donors['donors'][ $donor_count ]['info']['username']     = $user_data->user_login;
934
-					$donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name;
932
+					$donors['donors'][$donor_count]['info']['user_id']      = $donor_obj->user_id;
933
+					$donors['donors'][$donor_count]['info']['username']     = $user_data->user_login;
934
+					$donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name;
935 935
 
936 936
 				}
937 937
 
938
-				$donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count;
939
-				$donors['donors'][ $donor_count ]['stats']['total_spent']     = $donor_obj->purchase_value;
938
+				$donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count;
939
+				$donors['donors'][$donor_count]['stats']['total_spent']     = $donor_obj->purchase_value;
940 940
 
941
-				$donor_count ++;
941
+				$donor_count++;
942 942
 
943 943
 			}
944
-		} elseif ( $donor ) {
944
+		} elseif ($donor) {
945 945
 
946 946
 			$error['error'] = sprintf( /* translators: %s: donor */
947
-				__( 'Donor %s not found.', 'give' ), $donor );
947
+				__('Donor %s not found.', 'give'), $donor );
948 948
 
949 949
 			return $error;
950 950
 
951 951
 		} else {
952 952
 
953
-			$error['error'] = __( 'No donors found.', 'give' );
953
+			$error['error'] = __('No donors found.', 'give');
954 954
 
955 955
 			return $error;
956 956
 
@@ -969,37 +969,37 @@  discard block
 block discarded – undo
969 969
 	 *
970 970
 	 * @return array $donors Multidimensional array of the forms.
971 971
 	 */
972
-	public function get_forms( $form = null ) {
972
+	public function get_forms($form = null) {
973 973
 
974 974
 		$forms = array();
975 975
 		$error = array();
976 976
 
977
-		if ( $form == null ) {
977
+		if ($form == null) {
978 978
 			$forms['forms'] = array();
979 979
 
980
-			$form_list = get_posts( array(
980
+			$form_list = get_posts(array(
981 981
 				'post_type'        => 'give_forms',
982 982
 				'posts_per_page'   => $this->per_page(),
983 983
 				'suppress_filters' => true,
984 984
 				'paged'            => $this->get_paged(),
985
-			) );
985
+			));
986 986
 
987
-			if ( $form_list ) {
987
+			if ($form_list) {
988 988
 				$i = 0;
989
-				foreach ( $form_list as $form_info ) {
990
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
991
-					$i ++;
989
+				foreach ($form_list as $form_info) {
990
+					$forms['forms'][$i] = $this->get_form_data($form_info);
991
+					$i++;
992 992
 				}
993 993
 			}
994 994
 		} else {
995
-			if ( get_post_type( $form ) == 'give_forms' ) {
996
-				$form_info = get_post( $form );
995
+			if (get_post_type($form) == 'give_forms') {
996
+				$form_info = get_post($form);
997 997
 
998
-				$forms['forms'][0] = $this->get_form_data( $form_info );
998
+				$forms['forms'][0] = $this->get_form_data($form_info);
999 999
 
1000 1000
 			} else {
1001 1001
 				$error['error'] = sprintf( /* translators: %s: form */
1002
-					__( 'Form %s not found.', 'give' ), $form );
1002
+					__('Form %s not found.', 'give'), $form );
1003 1003
 
1004 1004
 				return $error;
1005 1005
 			}
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 	 *
1018 1018
 	 * @return array                Array of post data to return back in the API.
1019 1019
 	 */
1020
-	private function get_form_data( $form_info ) {
1020
+	private function get_form_data($form_info) {
1021 1021
 
1022 1022
 		$form = array();
1023 1023
 
@@ -1027,60 +1027,60 @@  discard block
 block discarded – undo
1027 1027
 		$form['info']['create_date']   = $form_info->post_date;
1028 1028
 		$form['info']['modified_date'] = $form_info->post_modified;
1029 1029
 		$form['info']['status']        = $form_info->post_status;
1030
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1031
-		$form['info']['content']       = give_get_meta( $form_info->ID, '_give_form_content', true );
1032
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1030
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1031
+		$form['info']['content']       = give_get_meta($form_info->ID, '_give_form_content', true);
1032
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1033 1033
 
1034
-		if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
1035
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1036
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1034
+		if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) {
1035
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1036
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1037 1037
 		}
1038
-		if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) {
1039
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1038
+		if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) {
1039
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1040 1040
 		}
1041 1041
 
1042 1042
 		// Check whether any goal is to be achieved for the donation form.
1043
-		$goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true );
1044
-		$goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true );
1045
-		if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) {
1046
-			$total_income                         = give_get_form_earnings_stats( $form_info->ID );
1047
-			$goal_percentage_completed            = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100;
1048
-			$form['goal']['amount']               = isset( $goal_amount ) ? $goal_amount : '';
1049
-			$form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : '';
1043
+		$goal_option = give_get_meta($form_info->ID, '_give_goal_option', true);
1044
+		$goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true);
1045
+		if (give_is_setting_enabled($goal_option) && $goal_amount) {
1046
+			$total_income                         = give_get_form_earnings_stats($form_info->ID);
1047
+			$goal_percentage_completed            = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100;
1048
+			$form['goal']['amount']               = isset($goal_amount) ? $goal_amount : '';
1049
+			$form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : '';
1050 1050
 		}
1051 1051
 
1052
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1053
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1054
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1055
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1056
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1052
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1053
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1054
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1055
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1056
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1057 1057
 		}
1058 1058
 
1059 1059
 		$counter = 0;
1060
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1061
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1062
-				$counter ++;
1060
+		if (give_has_variable_prices($form_info->ID)) {
1061
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1062
+				$counter++;
1063 1063
 				// multi-level item
1064
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1065
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1064
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1065
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1066 1066
 
1067 1067
 			}
1068 1068
 		} else {
1069
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1069
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1070 1070
 		}
1071 1071
 
1072
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1072
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1073 1073
 
1074 1074
 			/**
1075 1075
 			 * Fires when generating API sensitive data.
1076 1076
 			 *
1077 1077
 			 * @since 1.1
1078 1078
 			 */
1079
-			do_action( 'give_api_sensitive_data' );
1079
+			do_action('give_api_sensitive_data');
1080 1080
 
1081 1081
 		}
1082 1082
 
1083
-		return apply_filters( 'give_api_forms_form', $form );
1083
+		return apply_filters('give_api_forms_form', $form);
1084 1084
 
1085 1085
 	}
1086 1086
 
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 	 *
1096 1096
 	 * @return array
1097 1097
 	 */
1098
-	public function get_stats( $args = array() ) {
1098
+	public function get_stats($args = array()) {
1099 1099
 		$defaults = array(
1100 1100
 			'type'      => null,
1101 1101
 			'form'      => null,
@@ -1104,9 +1104,9 @@  discard block
 block discarded – undo
1104 1104
 			'enddate'   => null,
1105 1105
 		);
1106 1106
 
1107
-		$args = wp_parse_args( $args, $defaults );
1107
+		$args = wp_parse_args($args, $defaults);
1108 1108
 
1109
-		$dates = $this->get_dates( $args );
1109
+		$dates = $this->get_dates($args);
1110 1110
 
1111 1111
 		$stats     = array();
1112 1112
 		$earnings  = array(
@@ -1117,40 +1117,40 @@  discard block
 block discarded – undo
1117 1117
 		);
1118 1118
 		$error     = array();
1119 1119
 
1120
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1120
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1121 1121
 			return $stats;
1122 1122
 		}
1123 1123
 
1124
-		if ( $args['type'] == 'donations' ) {
1124
+		if ($args['type'] == 'donations') {
1125 1125
 
1126
-			if ( $args['form'] == null ) {
1127
-				if ( $args['date'] == null ) {
1126
+			if ($args['form'] == null) {
1127
+				if ($args['date'] == null) {
1128 1128
 					$donations = $this->get_default_sales_stats();
1129
-				} elseif ( $args['date'] === 'range' ) {
1129
+				} elseif ($args['date'] === 'range') {
1130 1130
 					// Return donations for a date range.
1131 1131
 					// Ensure the end date is later than the start date.
1132
-					if ( $args['enddate'] < $args['startdate'] ) {
1133
-						$error['error'] = __( 'The end date must be later than the start date.', 'give' );
1132
+					if ($args['enddate'] < $args['startdate']) {
1133
+						$error['error'] = __('The end date must be later than the start date.', 'give');
1134 1134
 					}
1135 1135
 
1136 1136
 					// Ensure both the start and end date are specified
1137
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1138
-						$error['error'] = __( 'Invalid or no date range specified.', 'give' );
1137
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1138
+						$error['error'] = __('Invalid or no date range specified.', 'give');
1139 1139
 					}
1140 1140
 
1141 1141
 					$total = 0;
1142 1142
 
1143 1143
 					// Loop through the years
1144 1144
 					$y = $dates['year'];
1145
-					while ( $y <= $dates['year_end'] ) :
1145
+					while ($y <= $dates['year_end']) :
1146 1146
 
1147
-						if ( $dates['year'] == $dates['year_end'] ) {
1147
+						if ($dates['year'] == $dates['year_end']) {
1148 1148
 							$month_start = $dates['m_start'];
1149 1149
 							$month_end   = $dates['m_end'];
1150
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1150
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1151 1151
 							$month_start = $dates['m_start'];
1152 1152
 							$month_end   = 12;
1153
-						} elseif ( $y == $dates['year_end'] ) {
1153
+						} elseif ($y == $dates['year_end']) {
1154 1154
 							$month_start = 1;
1155 1155
 							$month_end   = $dates['m_end'];
1156 1156
 						} else {
@@ -1159,116 +1159,116 @@  discard block
 block discarded – undo
1159 1159
 						}
1160 1160
 
1161 1161
 						$i = $month_start;
1162
-						while ( $i <= $month_end ) :
1162
+						while ($i <= $month_end) :
1163 1163
 
1164
-							if ( $i == $dates['m_start'] ) {
1164
+							if ($i == $dates['m_start']) {
1165 1165
 								$d = $dates['day_start'];
1166 1166
 							} else {
1167 1167
 								$d = 1;
1168 1168
 							}
1169 1169
 
1170
-							if ( $i == $dates['m_end'] ) {
1170
+							if ($i == $dates['m_end']) {
1171 1171
 								$num_of_days = $dates['day_end'];
1172 1172
 							} else {
1173
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1173
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1174 1174
 							}
1175 1175
 
1176
-							while ( $d <= $num_of_days ) :
1177
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1178
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1179
-								if ( ! isset( $donations['sales'][ $date_key ] ) ) {
1180
-									$donations['sales'][ $date_key ] = 0;
1176
+							while ($d <= $num_of_days) :
1177
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1178
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1179
+								if ( ! isset($donations['sales'][$date_key])) {
1180
+									$donations['sales'][$date_key] = 0;
1181 1181
 								}
1182
-								$donations['sales'][ $date_key ] += $sale_count;
1182
+								$donations['sales'][$date_key] += $sale_count;
1183 1183
 								$total                           += $sale_count;
1184
-								$d ++;
1184
+								$d++;
1185 1185
 							endwhile;
1186
-							$i ++;
1186
+							$i++;
1187 1187
 						endwhile;
1188 1188
 
1189
-						$y ++;
1189
+						$y++;
1190 1190
 					endwhile;
1191 1191
 
1192 1192
 					$donations['totals'] = $total;
1193 1193
 				} else {
1194
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1194
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1195 1195
 						$donations_count = 0;
1196 1196
 
1197 1197
 						// Loop through the months
1198 1198
 						$month = $dates['m_start'];
1199 1199
 
1200
-						while ( $month <= $dates['m_end'] ) :
1201
-							$donations_count += give_get_sales_by_date( null, $month, $dates['year'] );
1202
-							$month ++;
1200
+						while ($month <= $dates['m_end']) :
1201
+							$donations_count += give_get_sales_by_date(null, $month, $dates['year']);
1202
+							$month++;
1203 1203
 						endwhile;
1204 1204
 
1205
-						$donations['donations'][ $args['date'] ] = $donations_count;
1205
+						$donations['donations'][$args['date']] = $donations_count;
1206 1206
 					} else {
1207
-						$donations['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1207
+						$donations['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1208 1208
 					}
1209 1209
 				}// End if().
1210
-			} elseif ( $args['form'] == 'all' ) {
1211
-				$forms = get_posts( array(
1210
+			} elseif ($args['form'] == 'all') {
1211
+				$forms = get_posts(array(
1212 1212
 					'post_type' => 'give_forms',
1213 1213
 					'nopaging'  => true,
1214
-				) );
1215
-				$i     = 0;
1216
-				foreach ( $forms as $form_info ) {
1217
-					$donations['donations'][ $i ] = array(
1218
-						$form_info->post_name => give_get_form_sales_stats( $form_info->ID ),
1214
+				));
1215
+				$i = 0;
1216
+				foreach ($forms as $form_info) {
1217
+					$donations['donations'][$i] = array(
1218
+						$form_info->post_name => give_get_form_sales_stats($form_info->ID),
1219 1219
 					);
1220
-					$i ++;
1220
+					$i++;
1221 1221
 				}
1222 1222
 			} else {
1223
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1224
-					$form_info                 = get_post( $args['form'] );
1223
+				if (get_post_type($args['form']) == 'give_forms') {
1224
+					$form_info                 = get_post($args['form']);
1225 1225
 					$donations['donations'][0] = array(
1226
-						$form_info->post_name => give_get_form_sales_stats( $args['form'] ),
1226
+						$form_info->post_name => give_get_form_sales_stats($args['form']),
1227 1227
 					);
1228 1228
 				} else {
1229 1229
 					$error['error'] = sprintf( /* translators: %s: form */
1230
-						__( 'Form %s not found.', 'give' ), $args['form'] );
1230
+						__('Form %s not found.', 'give'), $args['form'] );
1231 1231
 				}
1232 1232
 			}// End if().
1233 1233
 
1234
-			if ( ! empty( $error ) ) {
1234
+			if ( ! empty($error)) {
1235 1235
 				return $error;
1236 1236
 			}
1237 1237
 
1238 1238
 			return $donations;
1239 1239
 
1240
-		} elseif ( $args['type'] == 'earnings' ) {
1241
-			if ( $args['form'] == null ) {
1242
-				if ( $args['date'] == null ) {
1240
+		} elseif ($args['type'] == 'earnings') {
1241
+			if ($args['form'] == null) {
1242
+				if ($args['date'] == null) {
1243 1243
 					$earnings = $this->get_default_earnings_stats();
1244
-				} elseif ( $args['date'] === 'range' ) {
1244
+				} elseif ($args['date'] === 'range') {
1245 1245
 					// Return sales for a date range
1246 1246
 					// Ensure the end date is later than the start date
1247
-					if ( $args['enddate'] < $args['startdate'] ) {
1248
-						$error['error'] = __( 'The end date must be later than the start date.', 'give' );
1247
+					if ($args['enddate'] < $args['startdate']) {
1248
+						$error['error'] = __('The end date must be later than the start date.', 'give');
1249 1249
 					}
1250 1250
 
1251 1251
 					// Ensure both the start and end date are specified
1252
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1253
-						$error['error'] = __( 'Invalid or no date range specified.', 'give' );
1252
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1253
+						$error['error'] = __('Invalid or no date range specified.', 'give');
1254 1254
 					}
1255 1255
 
1256 1256
 					$total = (float) 0.00;
1257 1257
 
1258 1258
 					// Loop through the years
1259 1259
 					$y = $dates['year'];
1260
-					if ( ! isset( $earnings['earnings'] ) ) {
1260
+					if ( ! isset($earnings['earnings'])) {
1261 1261
 						$earnings['earnings'] = array();
1262 1262
 					}
1263
-					while ( $y <= $dates['year_end'] ) :
1263
+					while ($y <= $dates['year_end']) :
1264 1264
 
1265
-						if ( $dates['year'] == $dates['year_end'] ) {
1265
+						if ($dates['year'] == $dates['year_end']) {
1266 1266
 							$month_start = $dates['m_start'];
1267 1267
 							$month_end   = $dates['m_end'];
1268
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1268
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1269 1269
 							$month_start = $dates['m_start'];
1270 1270
 							$month_end   = 12;
1271
-						} elseif ( $y == $dates['year_end'] ) {
1271
+						} elseif ($y == $dates['year_end']) {
1272 1272
 							$month_start = 1;
1273 1273
 							$month_end   = $dates['m_end'];
1274 1274
 						} else {
@@ -1277,94 +1277,94 @@  discard block
 block discarded – undo
1277 1277
 						}
1278 1278
 
1279 1279
 						$i = $month_start;
1280
-						while ( $i <= $month_end ) :
1280
+						while ($i <= $month_end) :
1281 1281
 
1282
-							if ( $i == $dates['m_start'] ) {
1282
+							if ($i == $dates['m_start']) {
1283 1283
 								$d = $dates['day_start'];
1284 1284
 							} else {
1285 1285
 								$d = 1;
1286 1286
 							}
1287 1287
 
1288
-							if ( $i == $dates['m_end'] ) {
1288
+							if ($i == $dates['m_end']) {
1289 1289
 								$num_of_days = $dates['day_end'];
1290 1290
 							} else {
1291
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1291
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1292 1292
 							}
1293 1293
 
1294
-							while ( $d <= $num_of_days ) :
1295
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1296
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1297
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1298
-									$earnings['earnings'][ $date_key ] = 0;
1294
+							while ($d <= $num_of_days) :
1295
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1296
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1297
+								if ( ! isset($earnings['earnings'][$date_key])) {
1298
+									$earnings['earnings'][$date_key] = 0;
1299 1299
 								}
1300
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1300
+								$earnings['earnings'][$date_key] += $earnings_stat;
1301 1301
 								$total                             += $earnings_stat;
1302
-								$d ++;
1302
+								$d++;
1303 1303
 							endwhile;
1304 1304
 
1305
-							$i ++;
1305
+							$i++;
1306 1306
 						endwhile;
1307 1307
 
1308
-						$y ++;
1308
+						$y++;
1309 1309
 					endwhile;
1310 1310
 
1311 1311
 					$earnings['totals'] = $total;
1312 1312
 				} else {
1313
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1313
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1314 1314
 						$earnings_count = (float) 0.00;
1315 1315
 
1316 1316
 						// Loop through the months
1317 1317
 						$month = $dates['m_start'];
1318 1318
 
1319
-						while ( $month <= $dates['m_end'] ) :
1320
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1321
-							$month ++;
1319
+						while ($month <= $dates['m_end']) :
1320
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1321
+							$month++;
1322 1322
 						endwhile;
1323 1323
 
1324
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1324
+						$earnings['earnings'][$args['date']] = $earnings_count;
1325 1325
 					} else {
1326
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1326
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1327 1327
 					}
1328 1328
 				}// End if().
1329
-			} elseif ( $args['form'] == 'all' ) {
1330
-				$forms = get_posts( array(
1329
+			} elseif ($args['form'] == 'all') {
1330
+				$forms = get_posts(array(
1331 1331
 					'post_type' => 'give_forms',
1332 1332
 					'nopaging'  => true,
1333
-				) );
1333
+				));
1334 1334
 
1335 1335
 				$i = 0;
1336
-				foreach ( $forms as $form_info ) {
1337
-					$earnings['earnings'][ $i ] = array(
1338
-						$form_info->post_name => give_get_form_earnings_stats( $form_info->ID ),
1336
+				foreach ($forms as $form_info) {
1337
+					$earnings['earnings'][$i] = array(
1338
+						$form_info->post_name => give_get_form_earnings_stats($form_info->ID),
1339 1339
 					);
1340
-					$i ++;
1340
+					$i++;
1341 1341
 				}
1342 1342
 			} else {
1343
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1344
-					$form_info               = get_post( $args['form'] );
1343
+				if (get_post_type($args['form']) == 'give_forms') {
1344
+					$form_info               = get_post($args['form']);
1345 1345
 					$earnings['earnings'][0] = array(
1346
-						$form_info->post_name => give_get_form_earnings_stats( $args['form'] ),
1346
+						$form_info->post_name => give_get_form_earnings_stats($args['form']),
1347 1347
 					);
1348 1348
 				} else {
1349 1349
 					$error['error'] = sprintf( /* translators: %s: form */
1350
-						__( 'Form %s not found.', 'give' ), $args['form'] );
1350
+						__('Form %s not found.', 'give'), $args['form'] );
1351 1351
 				}
1352 1352
 			}// End if().
1353 1353
 
1354
-			if ( ! empty( $error ) ) {
1354
+			if ( ! empty($error)) {
1355 1355
 				return $error;
1356 1356
 			}
1357 1357
 
1358 1358
 			return $earnings;
1359
-		} elseif ( $args['type'] == 'donors' ) {
1359
+		} elseif ($args['type'] == 'donors') {
1360 1360
 			$donors                             = new Give_DB_Donors();
1361 1361
 			$stats['donations']['total_donors'] = $donors->count();
1362 1362
 
1363 1363
 			return $stats;
1364 1364
 
1365
-		} elseif ( empty( $args['type'] ) ) {
1366
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1367
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1365
+		} elseif (empty($args['type'])) {
1366
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1367
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1368 1368
 
1369 1369
 			return array(
1370 1370
 				'stats' => $stats,
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
 	 *
1383 1383
 	 * @return array
1384 1384
 	 */
1385
-	public function get_recent_donations( $args = array() ) {
1385
+	public function get_recent_donations($args = array()) {
1386 1386
 		global $wp_query;
1387 1387
 
1388 1388
 		$defaults = array(
@@ -1392,33 +1392,33 @@  discard block
 block discarded – undo
1392 1392
 			'enddate'   => null,
1393 1393
 		);
1394 1394
 
1395
-		$args = wp_parse_args( $args, $defaults );
1395
+		$args = wp_parse_args($args, $defaults);
1396 1396
 
1397 1397
 		$donations = array();
1398 1398
 
1399
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1399
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1400 1400
 			return $donations;
1401 1401
 		}
1402 1402
 
1403
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1403
+		if (isset($wp_query->query_vars['id'])) {
1404 1404
 			$query   = array();
1405
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1406
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1405
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1406
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1407 1407
 			$query   = array();
1408
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1409
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1410
-			$args  = array(
1408
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1409
+		} elseif (isset($wp_query->query_vars['email'])) {
1410
+			$args = array(
1411 1411
 				'fields'     => 'ids',
1412 1412
 				'meta_key'   => '_give_payment_user_email',
1413 1413
 				'meta_value' => $wp_query->query_vars['email'],
1414 1414
 				'number'     => $this->per_page(),
1415 1415
 				'page'       => $this->get_paged(),
1416 1416
 			);
1417
-			$query = give_get_payments( $args );
1418
-		} elseif ( isset( $wp_query->query_vars['date'] ) ) {
1417
+			$query = give_get_payments($args);
1418
+		} elseif (isset($wp_query->query_vars['date'])) {
1419 1419
 
1420
-			$current_time = current_time( 'timestamp' );
1421
-			$dates        = $this->get_dates( $args );
1420
+			$current_time = current_time('timestamp');
1421
+			$dates        = $this->get_dates($args);
1422 1422
 			$start_date   = '';
1423 1423
 			$end_date     = '';
1424 1424
 
@@ -1431,27 +1431,27 @@  discard block
 block discarded – undo
1431 1431
 			 * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
1432 1432
 			 * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
1433 1433
 			 */
1434
-			switch ( $wp_query->query_vars['date'] ) {
1434
+			switch ($wp_query->query_vars['date']) {
1435 1435
 
1436 1436
 				case 'today':
1437 1437
 
1438 1438
 					// Set and Format Start and End Date to be date of today.
1439
-					$start_date = $end_date = date( 'Y/m/d', $current_time );
1439
+					$start_date = $end_date = date('Y/m/d', $current_time);
1440 1440
 
1441 1441
 					break;
1442 1442
 
1443 1443
 				case 'yesterday':
1444 1444
 
1445 1445
 					// Set and Format Start and End Date to be date of yesterday.
1446
-					$start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 );
1446
+					$start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1);
1447 1447
 
1448 1448
 					break;
1449 1449
 
1450 1450
 				case 'range':
1451 1451
 
1452 1452
 					// Format Start Date and End Date for filtering payment based on date range.
1453
-					$start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start'];
1454
-					$end_date   = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end'];
1453
+					$start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start'];
1454
+					$end_date   = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end'];
1455 1455
 
1456 1456
 					break;
1457 1457
 
@@ -1465,22 +1465,22 @@  discard block
 block discarded – undo
1465 1465
 				'page'       => $this->get_paged(),
1466 1466
 			);
1467 1467
 
1468
-			$query = give_get_payments( $args );
1468
+			$query = give_get_payments($args);
1469 1469
 		} else {
1470 1470
 			$args  = array(
1471 1471
 				'fields' => 'ids',
1472 1472
 				'number' => $this->per_page(),
1473 1473
 				'page'   => $this->get_paged(),
1474 1474
 			);
1475
-			$query = give_get_payments( $args );
1475
+			$query = give_get_payments($args);
1476 1476
 		}// End if().
1477 1477
 
1478
-		if ( $query ) {
1478
+		if ($query) {
1479 1479
 			$i = 0;
1480
-			foreach ( $query as $payment ) {
1480
+			foreach ($query as $payment) {
1481 1481
 
1482
-				if ( is_numeric( $payment ) ) {
1483
-					$payment      = new Give_Payment( $payment );
1482
+				if (is_numeric($payment)) {
1483
+					$payment      = new Give_Payment($payment);
1484 1484
 					$payment_meta = $payment->get_meta();
1485 1485
 					$user_info    = $payment->user_info;
1486 1486
 				}
@@ -1488,41 +1488,41 @@  discard block
 block discarded – undo
1488 1488
 				$payment_meta = $payment->get_meta();
1489 1489
 				$user_info    = $payment->user_info;
1490 1490
 
1491
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1492
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1493
-
1494
-				$donations['donations'][ $i ]['ID']             = $payment->number;
1495
-				$donations['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1496
-				$donations['donations'][ $i ]['key']            = $payment->key;
1497
-				$donations['donations'][ $i ]['total']          = $payment->total;
1498
-				$donations['donations'][ $i ]['status']         = give_get_payment_status( $payment, true );
1499
-				$donations['donations'][ $i ]['gateway']        = $payment->gateway;
1500
-				$donations['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1501
-				$donations['donations'][ $i ]['fname']          = $first_name;
1502
-				$donations['donations'][ $i ]['lname']          = $last_name;
1503
-				$donations['donations'][ $i ]['email']          = $payment->email;
1504
-				$donations['donations'][ $i ]['date']           = $payment->date;
1505
-
1506
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1507
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1508
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1509
-
1510
-				$donations['donations'][ $i ]['form']['id']    = $form_id;
1511
-				$donations['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1512
-				$donations['donations'][ $i ]['form']['price'] = $price;
1513
-
1514
-				if ( give_has_variable_prices( $form_id ) ) {
1515
-					if ( isset( $payment_meta['price_id'] ) ) {
1516
-						$price_name                                         = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1517
-						$donations['donations'][ $i ]['form']['price_name'] = $price_name;
1518
-						$donations['donations'][ $i ]['form']['price_id']   = $price_id;
1519
-						$donations['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1491
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1492
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1493
+
1494
+				$donations['donations'][$i]['ID']             = $payment->number;
1495
+				$donations['donations'][$i]['transaction_id'] = $payment->transaction_id;
1496
+				$donations['donations'][$i]['key']            = $payment->key;
1497
+				$donations['donations'][$i]['total']          = $payment->total;
1498
+				$donations['donations'][$i]['status']         = give_get_payment_status($payment, true);
1499
+				$donations['donations'][$i]['gateway']        = $payment->gateway;
1500
+				$donations['donations'][$i]['name']           = $first_name.' '.$last_name;
1501
+				$donations['donations'][$i]['fname']          = $first_name;
1502
+				$donations['donations'][$i]['lname']          = $last_name;
1503
+				$donations['donations'][$i]['email']          = $payment->email;
1504
+				$donations['donations'][$i]['date']           = $payment->date;
1505
+
1506
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1507
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1508
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1509
+
1510
+				$donations['donations'][$i]['form']['id']    = $form_id;
1511
+				$donations['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1512
+				$donations['donations'][$i]['form']['price'] = $price;
1513
+
1514
+				if (give_has_variable_prices($form_id)) {
1515
+					if (isset($payment_meta['price_id'])) {
1516
+						$price_name                                         = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1517
+						$donations['donations'][$i]['form']['price_name'] = $price_name;
1518
+						$donations['donations'][$i]['form']['price_id']   = $price_id;
1519
+						$donations['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1520 1520
 
1521 1521
 					}
1522 1522
 				}
1523 1523
 
1524 1524
 				// Add custom meta to API
1525
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1525
+				foreach ($payment_meta as $meta_key => $meta_value) {
1526 1526
 
1527 1527
 					$exceptions = array(
1528 1528
 						'form_title',
@@ -1535,19 +1535,19 @@  discard block
 block discarded – undo
1535 1535
 					);
1536 1536
 
1537 1537
 					// Don't clutter up results with dupes
1538
-					if ( in_array( $meta_key, $exceptions ) ) {
1538
+					if (in_array($meta_key, $exceptions)) {
1539 1539
 						continue;
1540 1540
 					}
1541 1541
 
1542
-					$donations['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1542
+					$donations['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1543 1543
 
1544 1544
 				}
1545 1545
 
1546
-				$i ++;
1546
+				$i++;
1547 1547
 			}// End foreach().
1548 1548
 		}// End if().
1549 1549
 
1550
-		return apply_filters( 'give_api_donations_endpoint', $donations );
1550
+		return apply_filters('give_api_donations_endpoint', $donations);
1551 1551
 	}
1552 1552
 
1553 1553
 	/**
@@ -1563,9 +1563,9 @@  discard block
 block discarded – undo
1563 1563
 	public function get_output_format() {
1564 1564
 		global $wp_query;
1565 1565
 
1566
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1566
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1567 1567
 
1568
-		return apply_filters( 'give_api_output_format', $format );
1568
+		return apply_filters('give_api_output_format', $format);
1569 1569
 	}
1570 1570
 
1571 1571
 
@@ -1582,8 +1582,8 @@  discard block
 block discarded – undo
1582 1582
 	 *
1583 1583
 	 * @return void
1584 1584
 	 */
1585
-	private function log_request( $data = array() ) {
1586
-		if ( ! $this->log_requests ) {
1585
+	private function log_request($data = array()) {
1586
+		if ( ! $this->log_requests) {
1587 1587
 			return;
1588 1588
 		}
1589 1589
 
@@ -1599,36 +1599,36 @@  discard block
 block discarded – undo
1599 1599
 
1600 1600
 		$query = array(
1601 1601
 			'give-api'    => $wp_query->query_vars['give-api'],
1602
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1603
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1604
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1605
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1606
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1607
-			'donor'       => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null,
1608
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1609
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1610
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1611
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1612
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1613
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1602
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1603
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1604
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1605
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1606
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1607
+			'donor'       => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null,
1608
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1609
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1610
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1611
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1612
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1613
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1614 1614
 		);
1615 1615
 
1616 1616
 		$log_data = array(
1617 1617
 			'log_type'     => 'api_request',
1618
-			'post_excerpt' => http_build_query( $query ),
1619
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1618
+			'post_excerpt' => http_build_query($query),
1619
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1620 1620
 		);
1621 1621
 
1622 1622
 		$log_meta = array(
1623 1623
 			'request_ip' => give_get_ip(),
1624 1624
 			'user'       => $this->user_id,
1625
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1626
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1625
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1626
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1627 1627
 			'time'       => $data['request_speed'],
1628 1628
 			'version'    => $this->get_queried_version(),
1629 1629
 		);
1630 1630
 
1631
-		$give_logs->insert_log( $log_data, $log_meta );
1631
+		$give_logs->insert_log($log_data, $log_meta);
1632 1632
 	}
1633 1633
 
1634 1634
 
@@ -1652,11 +1652,11 @@  discard block
 block discarded – undo
1652 1652
 	 *
1653 1653
 	 * @param int       $status_code
1654 1654
 	 */
1655
-	public function output( $status_code = 200 ) {
1655
+	public function output($status_code = 200) {
1656 1656
 
1657 1657
 		$format = $this->get_output_format();
1658 1658
 
1659
-		status_header( $status_code );
1659
+		status_header($status_code);
1660 1660
 
1661 1661
 		/**
1662 1662
 		 * Fires before outputting the API.
@@ -1667,25 +1667,25 @@  discard block
 block discarded – undo
1667 1667
 		 * @param Give_API $this   The Give_API object.
1668 1668
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1669 1669
 		 */
1670
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1670
+		do_action('give_api_output_before', $this->data, $this, $format);
1671 1671
 
1672
-		switch ( $format ) :
1672
+		switch ($format) :
1673 1673
 
1674 1674
 			case 'xml' :
1675 1675
 
1676
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1677
-				$xml = Array2XML::createXML( 'give', $this->data );
1676
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1677
+				$xml = Array2XML::createXML('give', $this->data);
1678 1678
 				echo $xml->saveXML();
1679 1679
 
1680 1680
 				break;
1681 1681
 
1682 1682
 			case 'json' :
1683 1683
 
1684
-				header( 'Content-Type: application/json' );
1685
-				if ( ! empty( $this->pretty_print ) ) {
1686
-					echo json_encode( $this->data, $this->pretty_print );
1684
+				header('Content-Type: application/json');
1685
+				if ( ! empty($this->pretty_print)) {
1686
+					echo json_encode($this->data, $this->pretty_print);
1687 1687
 				} else {
1688
-					echo json_encode( $this->data );
1688
+					echo json_encode($this->data);
1689 1689
 				}
1690 1690
 
1691 1691
 				break;
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
 				 * @param array    $data Response data to return.
1701 1701
 				 * @param Give_API $this The Give_API object.
1702 1702
 				 */
1703
-				do_action( "give_api_output_{$format}", $this->data, $this );
1703
+				do_action("give_api_output_{$format}", $this->data, $this);
1704 1704
 
1705 1705
 				break;
1706 1706
 
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
 		 * @param Give_API $this   The Give_API object.
1716 1716
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1717 1717
 		 */
1718
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1718
+		do_action('give_api_output_after', $this->data, $this, $format);
1719 1719
 
1720 1720
 		give_die();
1721 1721
 	}
@@ -1732,41 +1732,41 @@  discard block
 block discarded – undo
1732 1732
 	 *
1733 1733
 	 * @return void
1734 1734
 	 */
1735
-	function user_key_field( $user ) {
1735
+	function user_key_field($user) {
1736 1736
 
1737
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1737
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1738 1738
 
1739
-			$user = get_userdata( $user->ID );
1739
+			$user = get_userdata($user->ID);
1740 1740
 			?>
1741 1741
 			<table class="form-table">
1742 1742
 				<tbody>
1743 1743
 				<tr>
1744 1744
 					<th>
1745
-						<?php _e( 'Give API Keys', 'give' ); ?>
1745
+						<?php _e('Give API Keys', 'give'); ?>
1746 1746
 					</th>
1747 1747
 					<td>
1748 1748
 						<?php
1749
-						$public_key = $this->get_user_public_key( $user->ID );
1750
-						$secret_key = $this->get_user_secret_key( $user->ID );
1749
+						$public_key = $this->get_user_public_key($user->ID);
1750
+						$secret_key = $this->get_user_secret_key($user->ID);
1751 1751
 						?>
1752
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1752
+						<?php if (empty($user->give_user_public_key)) { ?>
1753 1753
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" />
1754
-							<span class="description"><?php _e( 'Generate API Key', 'give' ); ?></span>
1754
+							<span class="description"><?php _e('Generate API Key', 'give'); ?></span>
1755 1755
 						<?php } else { ?>
1756
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?>
1756
+							<strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?>
1757 1757
 								&nbsp;</strong>
1758
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>" />
1758
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>" />
1759 1759
 							<br />
1760
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Secret key:', 'give' ); ?>
1760
+							<strong style="display:inline-block; width: 125px;"><?php _e('Secret key:', 'give'); ?>
1761 1761
 								&nbsp;</strong>
1762
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>" />
1762
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>" />
1763 1763
 							<br />
1764
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Token:', 'give' ); ?>
1764
+							<strong style="display:inline-block; width: 125px;"><?php _e('Token:', 'give'); ?>
1765 1765
 								&nbsp;</strong>
1766
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>" />
1766
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>" />
1767 1767
 							<br />
1768 1768
 							<input name="give_revoke_api_key" type="checkbox" id="give_revoke_api_key" />
1769
-							<span class="description"><label for="give_revoke_api_key"><?php _e( 'Revoke API Keys', 'give' ); ?></label></span>
1769
+							<span class="description"><label for="give_revoke_api_key"><?php _e('Revoke API Keys', 'give'); ?></label></span>
1770 1770
 						<?php } ?>
1771 1771
 					</td>
1772 1772
 				</tr>
@@ -1785,61 +1785,61 @@  discard block
 block discarded – undo
1785 1785
 	 *
1786 1786
 	 * @return void
1787 1787
 	 */
1788
-	public function process_api_key( $args ) {
1788
+	public function process_api_key($args) {
1789 1789
 
1790
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1791
-			wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array(
1790
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1791
+			wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array(
1792 1792
 				'response' => 403,
1793
-			) );
1793
+			));
1794 1794
 		}
1795 1795
 
1796
-		if ( empty( $args['user_id'] ) ) {
1797
-			wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array(
1796
+		if (empty($args['user_id'])) {
1797
+			wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array(
1798 1798
 				'response' => 401,
1799
-			) );
1799
+			));
1800 1800
 		}
1801 1801
 
1802
-		if ( is_numeric( $args['user_id'] ) ) {
1803
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1802
+		if (is_numeric($args['user_id'])) {
1803
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1804 1804
 		} else {
1805
-			$userdata = get_user_by( 'login', $args['user_id'] );
1805
+			$userdata = get_user_by('login', $args['user_id']);
1806 1806
 			$user_id  = $userdata->ID;
1807 1807
 		}
1808
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1808
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1809 1809
 
1810
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1811
-			wp_die( sprintf( /* translators: %s: process */
1812
-				__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array(
1810
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1811
+			wp_die(sprintf( /* translators: %s: process */
1812
+				__('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array(
1813 1813
 				'response' => 403,
1814
-			) );
1815
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1816
-			wp_die( sprintf( /* translators: %s: process */
1817
-				__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array(
1814
+			));
1815
+		} elseif ( ! current_user_can('manage_give_settings')) {
1816
+			wp_die(sprintf( /* translators: %s: process */
1817
+				__('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array(
1818 1818
 				'response' => 403,
1819
-			) );
1819
+			));
1820 1820
 		}
1821 1821
 
1822
-		switch ( $process ) {
1822
+		switch ($process) {
1823 1823
 			case 'generate':
1824
-				if ( $this->generate_api_key( $user_id ) ) {
1825
-					Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1826
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1824
+				if ($this->generate_api_key($user_id)) {
1825
+					Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1826
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1827 1827
 					exit();
1828 1828
 				} else {
1829
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1829
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1830 1830
 					exit();
1831 1831
 				}
1832 1832
 				break;
1833 1833
 			case 'regenerate':
1834
-				$this->generate_api_key( $user_id, true );
1835
-				Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1836
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1834
+				$this->generate_api_key($user_id, true);
1835
+				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1836
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1837 1837
 				exit();
1838 1838
 				break;
1839 1839
 			case 'revoke':
1840
-				$this->revoke_api_key( $user_id );
1841
-				Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1842
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1840
+				$this->revoke_api_key($user_id);
1841
+				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1842
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1843 1843
 				exit();
1844 1844
 				break;
1845 1845
 			default;
@@ -1858,59 +1858,59 @@  discard block
 block discarded – undo
1858 1858
 	 *
1859 1859
 	 * @return boolean True if (re)generated successfully, false otherwise.
1860 1860
 	 */
1861
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1861
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1862 1862
 
1863 1863
 		// Bail out, if user doesn't exists.
1864
-		if ( empty( $user_id ) ) {
1864
+		if (empty($user_id)) {
1865 1865
 			return false;
1866 1866
 		}
1867 1867
 
1868
-		$user = get_userdata( $user_id );
1868
+		$user = get_userdata($user_id);
1869 1869
 
1870 1870
 		// Bail Out, if user object doesn't exists.
1871
-		if ( ! $user ) {
1871
+		if ( ! $user) {
1872 1872
 			return false;
1873 1873
 		}
1874 1874
 
1875 1875
 		$new_public_key = '';
1876 1876
 		$new_secret_key = '';
1877 1877
 
1878
-		if( ! empty( $_POST['from'] ) && 'profile' === $_POST['from'] ) {
1878
+		if ( ! empty($_POST['from']) && 'profile' === $_POST['from']) {
1879 1879
 			// For User Profile Page.
1880
-			if( ! empty( $_POST['give_set_api_key'] ) ) {
1880
+			if ( ! empty($_POST['give_set_api_key'])) {
1881 1881
 				// Generate API Key from User Profile page.
1882
-				$new_public_key = $this->generate_public_key( $user->user_email );
1883
-				$new_secret_key = $this->generate_private_key( $user->ID );
1884
-			} elseif ( ! empty( $_POST['give_revoke_api_key'] ) ) {
1882
+				$new_public_key = $this->generate_public_key($user->user_email);
1883
+				$new_secret_key = $this->generate_private_key($user->ID);
1884
+			} elseif ( ! empty($_POST['give_revoke_api_key'])) {
1885 1885
 				// Revoke API Key from User Profile page.
1886
-				$this->revoke_api_key( $user->ID );
1886
+				$this->revoke_api_key($user->ID);
1887 1887
 			} else {
1888 1888
 				return false;
1889 1889
 			}
1890 1890
 		} else {
1891 1891
 			// For Tools > API page.
1892
-			$public_key = $this->get_user_public_key( $user_id );
1892
+			$public_key = $this->get_user_public_key($user_id);
1893 1893
 
1894
-			if ( empty( $public_key ) && ! $regenerate ) {
1894
+			if (empty($public_key) && ! $regenerate) {
1895 1895
 				// Generating API for first time.
1896
-				$new_public_key = $this->generate_public_key( $user->user_email );
1897
-				$new_secret_key = $this->generate_private_key( $user->ID );
1898
-			} elseif ( $public_key && $regenerate ) {
1896
+				$new_public_key = $this->generate_public_key($user->user_email);
1897
+				$new_secret_key = $this->generate_private_key($user->ID);
1898
+			} elseif ($public_key && $regenerate) {
1899 1899
 				// API Key already exists and Regenerating API Key.
1900
-				$this->revoke_api_key( $user->ID );
1901
-				$new_public_key = $this->generate_public_key( $user->user_email );
1902
-				$new_secret_key = $this->generate_private_key( $user->ID );
1903
-			} elseif ( ! empty( $public_key ) && ! $regenerate ) {
1900
+				$this->revoke_api_key($user->ID);
1901
+				$new_public_key = $this->generate_public_key($user->user_email);
1902
+				$new_secret_key = $this->generate_private_key($user->ID);
1903
+			} elseif ( ! empty($public_key) && ! $regenerate) {
1904 1904
 				// Doing nothing, when API Key exists but still try to generate again instead of regenerating.
1905 1905
 				return false;
1906 1906
 			} else {
1907 1907
 				// Revoke API Key.
1908
-				$this->revoke_api_key( $user->ID );
1908
+				$this->revoke_api_key($user->ID);
1909 1909
 			}
1910 1910
 		}
1911 1911
 
1912
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1913
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1912
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1913
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1914 1914
 
1915 1915
 		return true;
1916 1916
 	}
@@ -1925,26 +1925,26 @@  discard block
 block discarded – undo
1925 1925
 	 *
1926 1926
 	 * @return bool
1927 1927
 	 */
1928
-	public function revoke_api_key( $user_id = 0 ) {
1928
+	public function revoke_api_key($user_id = 0) {
1929 1929
 
1930
-		if ( empty( $user_id ) ) {
1930
+		if (empty($user_id)) {
1931 1931
 			return false;
1932 1932
 		}
1933 1933
 
1934
-		$user = get_userdata( $user_id );
1934
+		$user = get_userdata($user_id);
1935 1935
 
1936
-		if ( ! $user ) {
1936
+		if ( ! $user) {
1937 1937
 			return false;
1938 1938
 		}
1939 1939
 
1940
-		$public_key = $this->get_user_public_key( $user_id );
1941
-		$secret_key = $this->get_user_secret_key( $user_id );
1942
-		if ( ! empty( $public_key ) ) {
1943
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) );
1944
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) );
1945
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) );
1946
-			delete_user_meta( $user_id, $public_key );
1947
-			delete_user_meta( $user_id, $secret_key );
1940
+		$public_key = $this->get_user_public_key($user_id);
1941
+		$secret_key = $this->get_user_secret_key($user_id);
1942
+		if ( ! empty($public_key)) {
1943
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key)));
1944
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id)));
1945
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id)));
1946
+			delete_user_meta($user_id, $public_key);
1947
+			delete_user_meta($user_id, $secret_key);
1948 1948
 		} else {
1949 1949
 			return false;
1950 1950
 		}
@@ -1966,9 +1966,9 @@  discard block
 block discarded – undo
1966 1966
 	 *
1967 1967
 	 * @return string
1968 1968
 	 */
1969
-	private function generate_public_key( $user_email = '' ) {
1970
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1971
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1969
+	private function generate_public_key($user_email = '') {
1970
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1971
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1972 1972
 
1973 1973
 		return $public;
1974 1974
 	}
@@ -1983,9 +1983,9 @@  discard block
 block discarded – undo
1983 1983
 	 *
1984 1984
 	 * @return string
1985 1985
 	 */
1986
-	private function generate_private_key( $user_id = 0 ) {
1987
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1988
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1986
+	private function generate_private_key($user_id = 0) {
1987
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1988
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1989 1989
 
1990 1990
 		return $secret;
1991 1991
 	}
@@ -2000,8 +2000,8 @@  discard block
 block discarded – undo
2000 2000
 	 *
2001 2001
 	 * @return string
2002 2002
 	 */
2003
-	public function get_token( $user_id = 0 ) {
2004
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
2003
+	public function get_token($user_id = 0) {
2004
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
2005 2005
 	}
2006 2006
 
2007 2007
 	/**
@@ -2015,9 +2015,9 @@  discard block
 block discarded – undo
2015 2015
 
2016 2016
 		// Default sales return
2017 2017
 		$donations                               = array();
2018
-		$donations['donations']['today']         = $this->stats->get_sales( 0, 'today' );
2019
-		$donations['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
2020
-		$donations['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
2018
+		$donations['donations']['today']         = $this->stats->get_sales(0, 'today');
2019
+		$donations['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
2020
+		$donations['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
2021 2021
 		$donations['donations']['totals']        = give_get_total_donations();
2022 2022
 
2023 2023
 		return $donations;
@@ -2034,9 +2034,9 @@  discard block
 block discarded – undo
2034 2034
 
2035 2035
 		// Default earnings return
2036 2036
 		$earnings                              = array();
2037
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
2038
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
2039
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
2037
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
2038
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
2039
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
2040 2040
 		$earnings['earnings']['totals']        = give_get_total_earnings();
2041 2041
 
2042 2042
 		return $earnings;
@@ -2056,25 +2056,25 @@  discard block
 block discarded – undo
2056 2056
 	 *
2057 2057
 	 * @return string            The API key/secret for the user supplied
2058 2058
 	 */
2059
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
2059
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
2060 2060
 
2061
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
2061
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
2062 2062
 			return $check;
2063 2063
 		}
2064 2064
 
2065 2065
 		$return = $check;
2066 2066
 
2067
-		switch ( $meta_key ) {
2067
+		switch ($meta_key) {
2068 2068
 			case 'give_user_public_key':
2069
-				$return = Give()->api->get_user_public_key( $object_id );
2069
+				$return = Give()->api->get_user_public_key($object_id);
2070 2070
 				break;
2071 2071
 			case 'give_user_secret_key':
2072
-				$return = Give()->api->get_user_secret_key( $object_id );
2072
+				$return = Give()->api->get_user_secret_key($object_id);
2073 2073
 				break;
2074 2074
 		}
2075 2075
 
2076
-		if ( ! $single ) {
2077
-			$return = array( $return );
2076
+		if ( ! $single) {
2077
+			$return = array($return);
2078 2078
 		}
2079 2079
 
2080 2080
 		return $return;
Please login to merge, or discard this patch.