Test Failed
Pull Request — master (#2289)
by
unknown
04:37
created
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/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.
includes/class-give-db-donors.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @since  1.0
162 162
 	 * @access public
163 163
 	 *
164
-	 * @param  bool|string|int $_id_or_email
164
+	 * @param  integer $_id_or_email
165 165
 	 *
166 166
 	 * @return bool|int
167 167
 	 */
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * @param  int          $user_id       User ID.
317 317
 	 * @param  WP_User|bool $old_user_data User data.
318 318
 	 *
319
-	 * @return bool
319
+	 * @return false|null
320 320
 	 */
321 321
 	public function update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) {
322 322
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * @access public
374 374
 	 *
375 375
 	 * @param  string $field ID or email. Default is 'id'.
376
-	 * @param  mixed  $value The Customer ID or email to search. Default is 0.
376
+	 * @param  integer  $value The Customer ID or email to search. Default is 0.
377 377
 	 *
378 378
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
379 379
 	 */
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_customers';
38
+		$this->table_name  = $wpdb->prefix.'give_customers';
39 39
 		$this->primary_key = 'id';
40 40
 		$this->version     = '1.0';
41 41
 
42 42
 		// Set hooks and register table only if instance loading first time.
43
-		if ( ! ( Give()->donors instanceof Give_DB_Donors ) ) {
43
+		if ( ! (Give()->donors instanceof Give_DB_Donors)) {
44 44
 			// Setup hook.
45
-			add_action( 'profile_update', array( $this, 'update_donor_email_on_user_update' ), 10, 2 );
45
+			add_action('profile_update', array($this, 'update_donor_email_on_user_update'), 10, 2);
46 46
 
47 47
 			// Install table.
48 48
 			$this->register_table();
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 			'purchase_value' => 0.00,
90 90
 			'purchase_count' => 0,
91 91
 			'notes'          => '',
92
-			'date_created'   => date( 'Y-m-d H:i:s' ),
92
+			'date_created'   => date('Y-m-d H:i:s'),
93 93
 		);
94 94
 	}
95 95
 
@@ -103,40 +103,40 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return int|bool
105 105
 	 */
106
-	public function add( $data = array() ) {
106
+	public function add($data = array()) {
107 107
 
108 108
 		$defaults = array(
109 109
 			'payment_ids' => '',
110 110
 		);
111 111
 
112
-		$args = wp_parse_args( $data, $defaults );
112
+		$args = wp_parse_args($data, $defaults);
113 113
 
114
-		if ( empty( $args['email'] ) ) {
114
+		if (empty($args['email'])) {
115 115
 			return false;
116 116
 		}
117 117
 
118
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
119
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
118
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
119
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
120 120
 		}
121 121
 
122
-		$donor = $this->get_donor_by( 'email', $args['email'] );
122
+		$donor = $this->get_donor_by('email', $args['email']);
123 123
 
124 124
 		// update an existing donor.
125
-		if ( $donor ) {
125
+		if ($donor) {
126 126
 
127 127
 			// Update the payment IDs attached to the donor
128
-			if ( ! empty( $args['payment_ids'] ) ) {
128
+			if ( ! empty($args['payment_ids'])) {
129 129
 
130
-				if ( empty( $donor->payment_ids ) ) {
130
+				if (empty($donor->payment_ids)) {
131 131
 
132 132
 					$donor->payment_ids = $args['payment_ids'];
133 133
 
134 134
 				} else {
135 135
 
136
-					$existing_ids       = array_map( 'absint', explode( ',', $donor->payment_ids ) );
137
-					$payment_ids        = array_map( 'absint', explode( ',', $args['payment_ids'] ) );
138
-					$payment_ids        = array_merge( $payment_ids, $existing_ids );
139
-					$donor->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
136
+					$existing_ids       = array_map('absint', explode(',', $donor->payment_ids));
137
+					$payment_ids        = array_map('absint', explode(',', $args['payment_ids']));
138
+					$payment_ids        = array_merge($payment_ids, $existing_ids);
139
+					$donor->payment_ids = implode(',', array_unique(array_values($payment_ids)));
140 140
 
141 141
 				}
142 142
 
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 
145 145
 			}
146 146
 
147
-			$this->update( $donor->id, $args );
147
+			$this->update($donor->id, $args);
148 148
 
149 149
 			return $donor->id;
150 150
 
151 151
 		} else {
152 152
 
153
-			return $this->insert( $args, 'donor' );
153
+			return $this->insert($args, 'donor');
154 154
 
155 155
 		}
156 156
 
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @return bool|int
171 171
 	 */
172
-	public function delete( $_id_or_email = false ) {
172
+	public function delete($_id_or_email = false) {
173 173
 
174
-		if ( empty( $_id_or_email ) ) {
174
+		if (empty($_id_or_email)) {
175 175
 			return false;
176 176
 		}
177 177
 
178
-		$column = is_email( $_id_or_email ) ? 'email' : 'id';
179
-		$donor  = $this->get_donor_by( $column, $_id_or_email );
178
+		$column = is_email($_id_or_email) ? 'email' : 'id';
179
+		$donor  = $this->get_donor_by($column, $_id_or_email);
180 180
 
181
-		if ( $donor->id > 0 ) {
181
+		if ($donor->id > 0) {
182 182
 
183 183
 			global $wpdb;
184 184
 
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 			 *
188 188
 			 * @since 1.8.14
189 189
 			 */
190
-			Give()->donor_meta->delete_all_meta( $donor->id );
190
+			Give()->donor_meta->delete_all_meta($donor->id);
191 191
 
192
-			return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) );
192
+			return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d'));
193 193
 
194 194
 		} else {
195 195
 			return false;
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	 *
211 211
 	 * @return bool|int
212 212
 	 */
213
-	public function delete_by_user_id( $user_id = false ) {
213
+	public function delete_by_user_id($user_id = false) {
214 214
 
215
-		if ( empty( $user_id ) ) {
215
+		if (empty($user_id)) {
216 216
 			return false;
217 217
 		}
218 218
 
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
 		 *
222 222
 		 * @since 1.8.14
223 223
 		 */
224
-		$donor = new Give_Donor( $user_id, true );
225
-		if ( ! empty( $donor->id ) ) {
226
-			Give()->donor_meta->delete_all_meta( $donor->id );
224
+		$donor = new Give_Donor($user_id, true);
225
+		if ( ! empty($donor->id)) {
226
+			Give()->donor_meta->delete_all_meta($donor->id);
227 227
 		}
228 228
 
229 229
 		global $wpdb;
230 230
 
231
-		return $wpdb->delete( $this->table_name, array( 'user_id' => $user_id ), array( '%d' ) );
231
+		return $wpdb->delete($this->table_name, array('user_id' => $user_id), array('%d'));
232 232
 	}
233 233
 
234 234
 	/**
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return bool          True is exists, false otherwise.
244 244
 	 */
245
-	public function exists( $value = '', $field = 'email' ) {
245
+	public function exists($value = '', $field = 'email') {
246 246
 
247 247
 		$columns = $this->get_columns();
248
-		if ( ! array_key_exists( $field, $columns ) ) {
248
+		if ( ! array_key_exists($field, $columns)) {
249 249
 			return false;
250 250
 		}
251 251
 
252
-		return (bool) $this->get_column_by( 'id', $field, $value );
252
+		return (bool) $this->get_column_by('id', $field, $value);
253 253
 
254 254
 	}
255 255
 
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 	 *
265 265
 	 * @return bool
266 266
 	 */
267
-	public function attach_payment( $donor_id = 0, $payment_id = 0 ) {
267
+	public function attach_payment($donor_id = 0, $payment_id = 0) {
268 268
 
269
-		$donor = new Give_Donor( $donor_id );
269
+		$donor = new Give_Donor($donor_id);
270 270
 
271
-		if ( empty( $donor->id ) ) {
271
+		if (empty($donor->id)) {
272 272
 			return false;
273 273
 		}
274 274
 
275 275
 		// Attach the payment, but don't increment stats, as this function previously did not
276
-		return $donor->attach_payment( $payment_id, false );
276
+		return $donor->attach_payment($payment_id, false);
277 277
 
278 278
 	}
279 279
 
@@ -288,16 +288,16 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @return bool
290 290
 	 */
291
-	public function remove_payment( $donor_id = 0, $payment_id = 0 ) {
291
+	public function remove_payment($donor_id = 0, $payment_id = 0) {
292 292
 
293
-		$donor = new Give_Donor( $donor_id );
293
+		$donor = new Give_Donor($donor_id);
294 294
 
295
-		if ( ! $donor ) {
295
+		if ( ! $donor) {
296 296
 			return false;
297 297
 		}
298 298
 
299 299
 		// Remove the payment, but don't decrease stats, as this function previously did not
300
-		return $donor->remove_payment( $payment_id, false );
300
+		return $donor->remove_payment($payment_id, false);
301 301
 
302 302
 	}
303 303
 
@@ -311,18 +311,18 @@  discard block
 block discarded – undo
311 311
 	 *
312 312
 	 * @return bool
313 313
 	 */
314
-	public function increment_stats( $donor_id = 0, $amount = 0.00 ) {
314
+	public function increment_stats($donor_id = 0, $amount = 0.00) {
315 315
 
316
-		$donor = new Give_Donor( $donor_id );
316
+		$donor = new Give_Donor($donor_id);
317 317
 
318
-		if ( empty( $donor->id ) ) {
318
+		if (empty($donor->id)) {
319 319
 			return false;
320 320
 		}
321 321
 
322 322
 		$increased_count = $donor->increase_purchase_count();
323
-		$increased_value = $donor->increase_value( $amount );
323
+		$increased_value = $donor->increase_value($amount);
324 324
 
325
-		return ( $increased_count && $increased_value ) ? true : false;
325
+		return ($increased_count && $increased_value) ? true : false;
326 326
 
327 327
 	}
328 328
 
@@ -337,18 +337,18 @@  discard block
 block discarded – undo
337 337
 	 *
338 338
 	 * @return bool
339 339
 	 */
340
-	public function decrement_stats( $donor_id = 0, $amount = 0.00 ) {
340
+	public function decrement_stats($donor_id = 0, $amount = 0.00) {
341 341
 
342
-		$donor = new Give_Donor( $donor_id );
342
+		$donor = new Give_Donor($donor_id);
343 343
 
344
-		if ( ! $donor ) {
344
+		if ( ! $donor) {
345 345
 			return false;
346 346
 		}
347 347
 
348 348
 		$decreased_count = $donor->decrease_donation_count();
349
-		$decreased_value = $donor->decrease_value( $amount );
349
+		$decreased_value = $donor->decrease_value($amount);
350 350
 
351
-		return ( $decreased_count && $decreased_value ) ? true : false;
351
+		return ($decreased_count && $decreased_value) ? true : false;
352 352
 
353 353
 	}
354 354
 
@@ -363,31 +363,31 @@  discard block
 block discarded – undo
363 363
 	 *
364 364
 	 * @return bool
365 365
 	 */
366
-	public function update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) {
366
+	public function update_donor_email_on_user_update($user_id = 0, $old_user_data = false) {
367 367
 
368
-		$donor = new Give_Donor( $user_id, true );
368
+		$donor = new Give_Donor($user_id, true);
369 369
 
370
-		if ( ! $donor ) {
370
+		if ( ! $donor) {
371 371
 			return false;
372 372
 		}
373 373
 
374
-		$user = get_userdata( $user_id );
374
+		$user = get_userdata($user_id);
375 375
 
376
-		if ( ! empty( $user ) && $user->user_email !== $donor->email ) {
376
+		if ( ! empty($user) && $user->user_email !== $donor->email) {
377 377
 
378
-			if ( ! $this->get_donor_by( 'email', $user->user_email ) ) {
378
+			if ( ! $this->get_donor_by('email', $user->user_email)) {
379 379
 
380
-				$success = $this->update( $donor->id, array( 'email' => $user->user_email ) );
380
+				$success = $this->update($donor->id, array('email' => $user->user_email));
381 381
 
382
-				if ( $success ) {
382
+				if ($success) {
383 383
 					// Update some payment meta if we need to
384
-					$payments_array = explode( ',', $donor->payment_ids );
384
+					$payments_array = explode(',', $donor->payment_ids);
385 385
 
386
-					if ( ! empty( $payments_array ) ) {
386
+					if ( ! empty($payments_array)) {
387 387
 
388
-						foreach ( $payments_array as $payment_id ) {
388
+						foreach ($payments_array as $payment_id) {
389 389
 
390
-							give_update_payment_meta( $payment_id, 'email', $user->user_email );
390
+							give_update_payment_meta($payment_id, 'email', $user->user_email);
391 391
 
392 392
 						}
393 393
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 					 * @param  WP_User    $user  WordPress User object.
402 402
 					 * @param  Give_Donor $donor Give donor object.
403 403
 					 */
404
-					do_action( 'give_update_donor_email_on_user_update', $user, $donor );
404
+					do_action('give_update_donor_email_on_user_update', $user, $donor);
405 405
 
406 406
 				}
407 407
 
@@ -422,44 +422,44 @@  discard block
 block discarded – undo
422 422
 	 *
423 423
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
424 424
 	 */
425
-	public function get_donor_by( $field = 'id', $value = 0 ) {
426
-		$value = sanitize_text_field( $value );
425
+	public function get_donor_by($field = 'id', $value = 0) {
426
+		$value = sanitize_text_field($value);
427 427
 
428 428
 		// Bailout.
429
-		if ( empty( $field ) || empty( $value ) ) {
429
+		if (empty($field) || empty($value)) {
430 430
 			return null;
431 431
 		}
432 432
 
433 433
 		// Verify values.
434
-		if ( 'id' === $field || 'user_id' === $field ) {
434
+		if ('id' === $field || 'user_id' === $field) {
435 435
 			// Make sure the value is numeric to avoid casting objects, for example,
436 436
 			// to int 1.
437
-			if ( ! is_numeric( $value ) ) {
437
+			if ( ! is_numeric($value)) {
438 438
 				return false;
439 439
 			}
440 440
 
441
-			$value = absint( $value );
441
+			$value = absint($value);
442 442
 
443
-			if ( $value < 1 ) {
443
+			if ($value < 1) {
444 444
 				return false;
445 445
 			}
446 446
 
447
-		} elseif ( 'email' === $field ) {
447
+		} elseif ('email' === $field) {
448 448
 
449
-			if ( ! is_email( $value ) ) {
449
+			if ( ! is_email($value)) {
450 450
 				return false;
451 451
 			}
452 452
 
453
-			$value = trim( $value );
453
+			$value = trim($value);
454 454
 		}
455 455
 
456 456
 		// Bailout
457
-		if ( ! $value ) {
457
+		if ( ! $value) {
458 458
 			return false;
459 459
 		}
460 460
 
461 461
 		// Set query params.
462
-		switch ( $field ) {
462
+		switch ($field) {
463 463
 			case 'id':
464 464
 				$args['donor'] = $value;
465 465
 				break;
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 		}
475 475
 
476 476
 		// Get donors.
477
-		$donor = new Give_Donors_Query( $args );
477
+		$donor = new Give_Donors_Query($args);
478 478
 
479
-		if ( ! $donor = $donor->get_donors() ) {
479
+		if ( ! $donor = $donor->get_donors()) {
480 480
 			// Look for donor from an additional email.
481 481
 			$args = array(
482 482
 				'meta_query' => array(
@@ -487,15 +487,15 @@  discard block
 block discarded – undo
487 487
 				),
488 488
 			);
489 489
 
490
-			$donor = new Give_Donors_Query( $args );
490
+			$donor = new Give_Donors_Query($args);
491 491
 			$donor = $donor->get_donors();
492 492
 
493
-			if ( empty( $donor ) ) {
493
+			if (empty($donor)) {
494 494
 				return false;
495 495
 			}
496 496
 		}
497 497
 
498
-		return current( $donor );
498
+		return current($donor);
499 499
 	}
500 500
 
501 501
 	/**
@@ -508,18 +508,18 @@  discard block
 block discarded – undo
508 508
 	 *
509 509
 	 * @return array|object|null Donors array or object. Null if not found.
510 510
 	 */
511
-	public function get_donors( $args = array() ) {
512
-		$this->bc_1814_params( $args );
511
+	public function get_donors($args = array()) {
512
+		$this->bc_1814_params($args);
513 513
 
514
-		$cache_key = md5( 'give_donors_' . serialize( $args ) );
514
+		$cache_key = md5('give_donors_'.serialize($args));
515 515
 
516
-		$donors = wp_cache_get( $cache_key, 'donors' );
516
+		$donors = wp_cache_get($cache_key, 'donors');
517 517
 
518
-		if ( $donors === false ) {
519
-			$donors = new Give_Donors_Query( $args );
518
+		if ($donors === false) {
519
+			$donors = new Give_Donors_Query($args);
520 520
 			$donors = $donors->get_donors();
521 521
 
522
-			wp_cache_set( $cache_key, $donors, 'donors', 3600 );
522
+			wp_cache_set($cache_key, $donors, 'donors', 3600);
523 523
 		}
524 524
 
525 525
 		return $donors;
@@ -537,21 +537,21 @@  discard block
 block discarded – undo
537 537
 	 *
538 538
 	 * @return int         Total number of donors.
539 539
 	 */
540
-	public function count( $args = array() ) {
541
-		$this->bc_1814_params( $args );
540
+	public function count($args = array()) {
541
+		$this->bc_1814_params($args);
542 542
 		$args['count'] = true;
543 543
 
544
-		$cache_key = md5( 'give_donors_count' . serialize( $args ) );
545
-		$count     = wp_cache_get( $cache_key, 'donors' );
544
+		$cache_key = md5('give_donors_count'.serialize($args));
545
+		$count     = wp_cache_get($cache_key, 'donors');
546 546
 
547
-		if ( $count === false ) {
548
-			$donors = new Give_Donors_Query( $args );
547
+		if ($count === false) {
548
+			$donors = new Give_Donors_Query($args);
549 549
 			$count  = $donors->get_donors();
550 550
 
551
-			wp_cache_set( $cache_key, $count, 'donors', 3600 );
551
+			wp_cache_set($cache_key, $count, 'donors', 3600);
552 552
 		}
553 553
 
554
-		return absint( $count );
554
+		return absint($count);
555 555
 
556 556
 	}
557 557
 
@@ -565,9 +565,9 @@  discard block
 block discarded – undo
565 565
 	 */
566 566
 	public function create_table() {
567 567
 
568
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
568
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
569 569
 
570
-		$sql = "CREATE TABLE " . $this->table_name . " (
570
+		$sql = "CREATE TABLE ".$this->table_name." (
571 571
 		id bigint(20) NOT NULL AUTO_INCREMENT,
572 572
 		user_id bigint(20) NOT NULL,
573 573
 		email varchar(50) NOT NULL,
@@ -582,9 +582,9 @@  discard block
 block discarded – undo
582 582
 		KEY user (user_id)
583 583
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
584 584
 
585
-		dbDelta( $sql );
585
+		dbDelta($sql);
586 586
 
587
-		update_option( $this->table_name . '_db_version', $this->version );
587
+		update_option($this->table_name.'_db_version', $this->version);
588 588
 	}
589 589
 
590 590
 	/**
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	 * @return bool Returns if the donors table was installed and upgrade routine run.
597 597
 	 */
598 598
 	public function installed() {
599
-		return $this->table_exists( $this->table_name );
599
+		return $this->table_exists($this->table_name);
600 600
 	}
601 601
 
602 602
 	/**
@@ -607,41 +607,41 @@  discard block
 block discarded – undo
607 607
 	 *
608 608
 	 * @param $args
609 609
 	 */
610
-	private function bc_1814_params( &$args ) {
610
+	private function bc_1814_params(&$args) {
611 611
 		// Backward compatibility: user_id
612
-		if ( ! empty( $args['user_id'] ) ) {
612
+		if ( ! empty($args['user_id'])) {
613 613
 			$args['user'] = $args['user_id'];
614 614
 		}
615 615
 
616 616
 		// Backward compatibility: id
617
-		if ( ! empty( $args['id'] ) ) {
617
+		if ( ! empty($args['id'])) {
618 618
 			$args['donor'] = $args['id'];
619 619
 		}
620 620
 
621 621
 		// Backward compatibility: name
622
-		if ( ! empty( $args['name'] ) ) {
622
+		if ( ! empty($args['name'])) {
623 623
 			$args['s'] = "name:{$args['name']}";
624 624
 		}
625 625
 
626 626
 		// Backward compatibility: date
627 627
 		// Donors created for a specific date or in a date range.
628
-		if ( ! empty( $args['date'] ) ) {
628
+		if ( ! empty($args['date'])) {
629 629
 
630
-			if ( is_array( $args['date'] ) ) {
630
+			if (is_array($args['date'])) {
631 631
 
632
-				if ( ! empty( $args['date']['start'] ) ) {
633
-					$args['date_query']['after'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
632
+				if ( ! empty($args['date']['start'])) {
633
+					$args['date_query']['after'] = date('Y-m-d H:i:s', strtotime($args['date']['start']));
634 634
 				}
635 635
 
636
-				if ( ! empty( $args['date']['end'] ) ) {
637
-					$args['date_query']['before'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
636
+				if ( ! empty($args['date']['end'])) {
637
+					$args['date_query']['before'] = date('Y-m-d H:i:s', strtotime($args['date']['end']));
638 638
 				}
639 639
 
640 640
 			} else {
641 641
 
642
-				$args['date_query']['year']  = date( 'Y', strtotime( $args['date'] ) );
643
-				$args['date_query']['month'] = date( 'm', strtotime( $args['date'] ) );
644
-				$args['date_query']['day']   = date( 'd', strtotime( $args['date'] ) );
642
+				$args['date_query']['year']  = date('Y', strtotime($args['date']));
643
+				$args['date_query']['month'] = date('m', strtotime($args['date']));
644
+				$args['date_query']['day']   = date('d', strtotime($args['date']));
645 645
 			}
646 646
 
647 647
 		}
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		 * @access private
704 704
 		 * @since  1.7
705 705
 		 *
706
-		 * @return bool
706
+		 * @return false|null
707 707
 		 */
708 708
 		private function __remove_license_key_from_subscriptions() {
709 709
 			$subscriptions = get_option( 'give_subscriptions', array() );
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 		 * @param $plugin_data
737 737
 		 * @param $status
738 738
 		 *
739
-		 * @return bool
739
+		 * @return false|null
740 740
 		 */
741 741
 		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
742 742
 			// Bailout.
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 		 *
759 759
 		 * @since  1.8.7
760 760
 		 * @access public
761
-		 * @return array
761
+		 * @return string
762 762
 		 */
763 763
 		public function license_state_message() {
764 764
 			$message_data = array();
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  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
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -143,27 +143,27 @@  discard block
 block discarded – undo
143 143
 		 * @param string $_checkout_url
144 144
 		 * @param string $_account_url
145 145
 		 */
146
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
146
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
147 147
 
148 148
 			$give_options = give_get_settings();
149 149
 
150 150
 			$this->file             = $_file;
151 151
 			$this->item_name        = $_item_name;
152
-			$this->item_shortname   = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
152
+			$this->item_shortname   = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
153 153
 			$this->version          = $_version;
154
-			$this->license          = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
155
-			$this->license_data     = get_option( $this->item_shortname . '_license_active' );
154
+			$this->license          = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
155
+			$this->license_data     = get_option($this->item_shortname.'_license_active');
156 156
 			$this->author           = $_author;
157
-			$this->api_url          = is_null( $_api_url ) ? $this->api_url : $_api_url;
158
-			$this->checkout_url     = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
159
-			$this->account_url      = is_null( $_account_url ) ? $this->account_url : $_account_url;
157
+			$this->api_url          = is_null($_api_url) ? $this->api_url : $_api_url;
158
+			$this->checkout_url     = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
159
+			$this->account_url      = is_null($_account_url) ? $this->account_url : $_account_url;
160 160
 			$this->auto_updater_obj = null;
161 161
 
162 162
 			// Add Setting for Give Add-on activation status.
163
-			$is_addon_activated = get_option( 'give_is_addon_activated' );
164
-			if ( ! $is_addon_activated && is_object( $this ) && sizeof( $this ) > 0 ) {
165
-				update_option( 'give_is_addon_activated', true );
166
-				Give_Cache::set( 'give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS );
163
+			$is_addon_activated = get_option('give_is_addon_activated');
164
+			if ( ! $is_addon_activated && is_object($this) && sizeof($this) > 0) {
165
+				update_option('give_is_addon_activated', true);
166
+				Give_Cache::set('give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS);
167 167
 			}
168 168
 
169 169
 			// Setup hooks
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		 */
185 185
 		private function includes() {
186 186
 
187
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
187
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
188 188
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
189 189
 			}
190 190
 		}
@@ -202,30 +202,30 @@  discard block
 block discarded – undo
202 202
 		private function hooks() {
203 203
 
204 204
 			// Register settings.
205
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
205
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
206 206
 
207 207
 			// Activate license key on settings save.
208
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
208
+			add_action('admin_init', array($this, 'activate_license'));
209 209
 
210 210
 			// Deactivate license key.
211
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
211
+			add_action('admin_init', array($this, 'deactivate_license'));
212 212
 
213 213
 			// Updater.
214
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
215
-			add_action( 'admin_notices', array( $this, 'notices' ) );
214
+			add_action('admin_init', array($this, 'auto_updater'), 0);
215
+			add_action('admin_notices', array($this, 'notices'));
216 216
 
217 217
 			// Check license weekly.
218
-			Give_Cron::add_weekly_event( array( $this, 'weekly_license_check' ) );
219
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
218
+			Give_Cron::add_weekly_event(array($this, 'weekly_license_check'));
219
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
220 220
 
221 221
 			// Check subscription weekly.
222
-			Give_Cron::add_weekly_event( array( $this, 'weekly_subscription_check' ) );
223
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
222
+			Give_Cron::add_weekly_event(array($this, 'weekly_subscription_check'));
223
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
224 224
 
225 225
 			// Show addon notice on plugin page.
226
-			$plugin_name = explode( 'plugins/', $this->file );
227
-			$plugin_name = end( $plugin_name );
228
-			add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 );
226
+			$plugin_name = explode('plugins/', $this->file);
227
+			$plugin_name = end($plugin_name);
228
+			add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3);
229 229
 
230 230
 		}
231 231
 
@@ -265,16 +265,16 @@  discard block
 block discarded – undo
265 265
 		 *
266 266
 		 * @return array           License settings.
267 267
 		 */
268
-		public function settings( $settings ) {
268
+		public function settings($settings) {
269 269
 
270 270
 			$give_license_settings = array(
271 271
 				array(
272 272
 					'name'    => $this->item_name,
273
-					'id'      => $this->item_shortname . '_license_key',
273
+					'id'      => $this->item_shortname.'_license_key',
274 274
 					'desc'    => '',
275 275
 					'type'    => 'license_key',
276 276
 					'options' => array(
277
-						'license'      => get_option( $this->item_shortname . '_license_active' ),
277
+						'license'      => get_option($this->item_shortname.'_license_active'),
278 278
 						'shortname'    => $this->item_shortname,
279 279
 						'item_name'    => $this->item_name,
280 280
 						'api_url'      => $this->api_url,
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 				),
286 286
 			);
287 287
 
288
-			return array_merge( $settings, $give_license_settings );
288
+			return array_merge($settings, $give_license_settings);
289 289
 		}
290 290
 
291 291
 		/**
@@ -300,18 +300,18 @@  discard block
 block discarded – undo
300 300
 		 *
301 301
 		 * @return array           License settings content.
302 302
 		 */
303
-		public function license_settings_content( $settings ) {
303
+		public function license_settings_content($settings) {
304 304
 
305 305
 			$give_license_settings = array(
306 306
 				array(
307
-					'name' => __( 'Add-on Licenses', 'give' ),
307
+					'name' => __('Add-on Licenses', 'give'),
308 308
 					'desc' => '<hr>',
309 309
 					'type' => 'give_title',
310 310
 					'id'   => 'give_title',
311 311
 				),
312 312
 			);
313 313
 
314
-			return array_merge( $settings, $give_license_settings );
314
+			return array_merge($settings, $give_license_settings);
315 315
 		}
316 316
 
317 317
 		/**
@@ -326,65 +326,65 @@  discard block
 block discarded – undo
326 326
 		 */
327 327
 		public function activate_license() {
328 328
 			// Bailout.
329
-			if ( ! $this->__is_user_can_edit_license() ) {
329
+			if ( ! $this->__is_user_can_edit_license()) {
330 330
 				return;
331 331
 			}
332 332
 
333 333
 			// Allow third party addon developers to handle license activation.
334
-			if ( $this->__is_third_party_addon() ) {
335
-				do_action( 'give_activate_license', $this );
334
+			if ($this->__is_third_party_addon()) {
335
+				do_action('give_activate_license', $this);
336 336
 
337 337
 				return;
338 338
 			}
339 339
 
340 340
 			// Do not simultaneously activate add-ons if the user want to deactivate a specific add-on.
341
-			foreach ( $_POST as $key => $value ) {
342
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
341
+			foreach ($_POST as $key => $value) {
342
+				if (false !== strpos($key, 'license_key_deactivate')) {
343 343
 					// Don't activate a key when deactivating a different key
344 344
 					return;
345 345
 				}
346 346
 			}
347 347
 
348 348
 			// Delete previous license setting if a empty license key submitted.
349
-			if ( empty( $_POST["{$this->item_shortname}_license_key"] ) ) {
349
+			if (empty($_POST["{$this->item_shortname}_license_key"])) {
350 350
 				$this->unset_license();
351 351
 
352 352
 				return;
353 353
 			}
354 354
 
355 355
 			// Check if plugin previously installed.
356
-			if ( $this->is_valid_license() ) {
356
+			if ($this->is_valid_license()) {
357 357
 				return;
358 358
 			}
359 359
 
360 360
 			// Get license key.
361
-			$this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
361
+			$this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
362 362
 
363 363
 			// Delete previous license key from subscription if previously added.
364 364
 			$this->__remove_license_key_from_subscriptions();
365 365
 
366 366
 			// Make sure there are no api errors.
367
-			if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) {
367
+			if ( ! ($license_data = $this->get_license_info('activate_license'))) {
368 368
 				return;
369 369
 			}
370 370
 
371 371
 			// Make sure license is valid.
372 372
 			// return because admin will want to activate license again.
373
-			if ( ! $this->is_license( $license_data ) ) {
373
+			if ( ! $this->is_license($license_data)) {
374 374
 				// Add license key.
375
-				give_update_option( "{$this->item_shortname}_license_key", $this->license );
375
+				give_update_option("{$this->item_shortname}_license_key", $this->license);
376 376
 
377 377
 				return;
378 378
 			}
379 379
 
380 380
 			// Tell WordPress to look for updates.
381
-			set_site_transient( 'update_plugins', null );
381
+			set_site_transient('update_plugins', null);
382 382
 
383 383
 			// Add license data.
384
-			update_option( "{$this->item_shortname}_license_active", $license_data );
384
+			update_option("{$this->item_shortname}_license_active", $license_data);
385 385
 
386 386
 			// Add license key.
387
-			give_update_option( "{$this->item_shortname}_license_key", $this->license );
387
+			give_update_option("{$this->item_shortname}_license_key", $this->license);
388 388
 
389 389
 			// Check subscription for license key and store this to db (if any).
390 390
 			$this->__single_subscription_check();
@@ -402,27 +402,27 @@  discard block
 block discarded – undo
402 402
 		 */
403 403
 		public function deactivate_license() {
404 404
 			// Bailout.
405
-			if ( ! $this->__is_user_can_edit_license() ) {
405
+			if ( ! $this->__is_user_can_edit_license()) {
406 406
 				return;
407 407
 			}
408 408
 
409 409
 			// Allow third party add-on developers to handle license deactivation.
410
-			if ( $this->__is_third_party_addon() ) {
411
-				do_action( 'give_deactivate_license', $this );
410
+			if ($this->__is_third_party_addon()) {
411
+				do_action('give_deactivate_license', $this);
412 412
 
413 413
 				return;
414 414
 			}
415 415
 
416 416
 			// Run on deactivate button press.
417
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
417
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
418 418
 
419 419
 				// Make sure there are no api errors.
420
-				if ( ! ( $license_data = $this->get_license_info( 'deactivate_license' ) ) ) {
420
+				if ( ! ($license_data = $this->get_license_info('deactivate_license'))) {
421 421
 					return;
422 422
 				}
423 423
 
424 424
 				// Ensure deactivated successfully.
425
-				if ( isset( $license_data->success ) ) {
425
+				if (isset($license_data->success)) {
426 426
 					$this->unset_license();
427 427
 				}
428 428
 			}// End if().
@@ -439,30 +439,30 @@  discard block
 block discarded – undo
439 439
 		public function weekly_license_check() {
440 440
 
441 441
 			if (
442
-				! empty( $_POST['give_settings'] ) ||
443
-				empty( $this->license )
442
+				! empty($_POST['give_settings']) ||
443
+				empty($this->license)
444 444
 			) {
445 445
 				return;
446 446
 			}
447 447
 
448 448
 			// Allow third party add-on developers to handle their license check.
449
-			if ( $this->__is_third_party_addon() ) {
450
-				do_action( 'give_weekly_license_check', $this );
449
+			if ($this->__is_third_party_addon()) {
450
+				do_action('give_weekly_license_check', $this);
451 451
 
452 452
 				return;
453 453
 			}
454 454
 
455 455
 			// Make sure there are no api errors.
456
-			if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) {
456
+			if ( ! ($license_data = $this->get_license_info('check_license'))) {
457 457
 				return;
458 458
 			}
459 459
 
460 460
 			// Bailout.
461
-			if ( ! $this->is_license( $license_data ) ) {
461
+			if ( ! $this->is_license($license_data)) {
462 462
 				return;
463 463
 			}
464 464
 
465
-			update_option( $this->item_shortname . '_license_active', $license_data );
465
+			update_option($this->item_shortname.'_license_active', $license_data);
466 466
 
467 467
 			return;
468 468
 		}
@@ -478,21 +478,21 @@  discard block
 block discarded – undo
478 478
 		public function weekly_subscription_check() {
479 479
 			// Bailout.
480 480
 			if (
481
-				! empty( $_POST['give_settings'] ) ||
482
-				empty( $this->license )
481
+				! empty($_POST['give_settings']) ||
482
+				empty($this->license)
483 483
 			) {
484 484
 				return;
485 485
 			}
486 486
 
487 487
 			// Remove old subscription data.
488
-			if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) {
489
-				delete_option( 'give_subscriptions' );
490
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) );
488
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
489
+				delete_option('give_subscriptions');
490
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
491 491
 			}
492 492
 
493 493
 			// Allow third party add-on developers to handle their subscription check.
494
-			if ( $this->__is_third_party_addon() ) {
495
-				do_action( 'give_weekly_subscription_check', $this );
494
+			if ($this->__is_third_party_addon()) {
495
+				do_action('give_weekly_subscription_check', $this);
496 496
 
497 497
 				return;
498 498
 			}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		 * @return void
510 510
 		 */
511 511
 		private function __single_subscription_check() {
512
-			if ( empty( $this->license ) ) {
512
+			if (empty($this->license)) {
513 513
 				return;
514 514
 			}
515 515
 
@@ -520,29 +520,29 @@  discard block
 block discarded – undo
520 520
 			 * By default edd software licensing api does not have api to check subscription.
521 521
 			 * This is a custom feature to check subscriptions.
522 522
 			 */
523
-			if ( ! ( $subscription_data = $this->get_license_info( 'check_subscription', true ) ) ) {
523
+			if ( ! ($subscription_data = $this->get_license_info('check_subscription', true))) {
524 524
 				return;
525 525
 			}
526 526
 
527 527
 
528
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
529
-				$subscriptions = get_option( 'give_subscriptions', array() );
528
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
529
+				$subscriptions = get_option('give_subscriptions', array());
530 530
 
531 531
 				// Update subscription data only if subscription does not exist already.
532
-				$subscriptions[ $subscription_data['id'] ] = $subscription_data;
532
+				$subscriptions[$subscription_data['id']] = $subscription_data;
533 533
 
534 534
 
535 535
 				// Initiate default set of license for subscription.
536
-				if ( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
537
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
536
+				if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) {
537
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
538 538
 				}
539 539
 
540 540
 				// Store licenses for subscription.
541
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
542
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
541
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
542
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
543 543
 				}
544 544
 
545
-				update_option( 'give_subscriptions', $subscriptions );
545
+				update_option('give_subscriptions', $subscriptions);
546 546
 			}
547 547
 		}
548 548
 
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
 		 */
557 557
 		public function notices() {
558 558
 
559
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
559
+			if ( ! current_user_can('manage_give_settings')) {
560 560
 				return;
561 561
 			}
562 562
 
563 563
 			// Do not show licenses notices on license tab.
564
-			if ( 'licenses' === give_get_current_setting_tab() ) {
564
+			if ('licenses' === give_get_current_setting_tab()) {
565 565
 				return;
566 566
 			}
567 567
 
@@ -570,118 +570,118 @@  discard block
 block discarded – undo
570 570
 			static $addon_license_key_in_subscriptions;
571 571
 
572 572
 			// Set default value.
573
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
573
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
574 574
 			$messages                           = array();
575 575
 
576 576
 			// Check whether admin has Give Add-on activated since 24 hours?
577
-			$is_license_notice_hidden = Give_Cache::get( 'give_cache_hide_license_notice_after_activation' );
577
+			$is_license_notice_hidden = Give_Cache::get('give_cache_hide_license_notice_after_activation');
578 578
 
579 579
 			// Display Invalid License notice, if its more than 24 hours since first Give Add-on activation.
580 580
 			if (
581
-				empty( $this->license )
582
-				&& empty( $showed_invalid_message )
583
-				&& ( false === $is_license_notice_hidden )
581
+				empty($this->license)
582
+				&& empty($showed_invalid_message)
583
+				&& (false === $is_license_notice_hidden)
584 584
 			) {
585 585
 
586
-				Give()->notices->register_notice( array(
586
+				Give()->notices->register_notice(array(
587 587
 					'id'               => 'give-invalid-license',
588 588
 					'type'             => 'error',
589 589
 					'description'      => sprintf(
590
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
591
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
590
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
591
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
592 592
 					),
593 593
 					'dismissible_type' => 'user',
594 594
 					'dismiss_interval' => 'shortly',
595
-				) );
595
+				));
596 596
 
597 597
 				$showed_invalid_message = true;
598 598
 
599 599
 			}
600 600
 
601 601
 			// Get subscriptions.
602
-			$subscriptions = get_option( 'give_subscriptions' );
602
+			$subscriptions = get_option('give_subscriptions');
603 603
 
604 604
 			// Show subscription messages.
605
-			if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
605
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
606 606
 
607
-				foreach ( $subscriptions as $subscription ) {
607
+				foreach ($subscriptions as $subscription) {
608 608
 					// Subscription expires timestamp.
609
-					$subscription_expires = strtotime( $subscription['expires'] );
609
+					$subscription_expires = strtotime($subscription['expires']);
610 610
 
611 611
 					// Start showing subscriptions message before one week of renewal date.
612
-					if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
612
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
613 613
 						continue;
614 614
 					}
615 615
 
616 616
 					// Check if subscription message already exist in messages.
617
-					if ( array_key_exists( $subscription['id'], $messages ) ) {
617
+					if (array_key_exists($subscription['id'], $messages)) {
618 618
 						continue;
619 619
 					}
620 620
 
621 621
 					// Check if license already expired.
622
-					if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {
623
-						Give()->notices->register_notice( array(
622
+					if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {
623
+						Give()->notices->register_notice(array(
624 624
 							'id'               => "give-expired-subscription-{$subscription['id']}",
625 625
 							'type'             => 'error',
626 626
 							'description'      => sprintf(
627
-								__( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give' ),
628
-								urldecode( $subscription['invoice_url'] ),
627
+								__('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give'),
628
+								urldecode($subscription['invoice_url']),
629 629
 								$subscription['payment_id'],
630 630
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
631
-								Give()->notices->get_dismiss_link( array(
632
-									'title'            => __( 'Click here if already renewed', 'give' ),
631
+								Give()->notices->get_dismiss_link(array(
632
+									'title'            => __('Click here if already renewed', 'give'),
633 633
 									'dismissible_type' => 'user',
634 634
 									'dismiss_interval' => 'permanent',
635
-								) )
635
+								))
636 636
 							),
637 637
 							'dismissible_type' => 'user',
638 638
 							'dismiss_interval' => 'shortly',
639
-						) );
639
+						));
640 640
 					} else {
641
-						Give()->notices->register_notice( array(
641
+						Give()->notices->register_notice(array(
642 642
 							'id'               => "give-expires-subscription-{$subscription['id']}",
643 643
 							'type'             => 'error',
644 644
 							'description'      => sprintf(
645
-								__( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give' ),
646
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
647
-								urldecode( $subscription['invoice_url'] ),
645
+								__('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give'),
646
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
647
+								urldecode($subscription['invoice_url']),
648 648
 								$subscription['payment_id'],
649 649
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
650
-								Give()->notices->get_dismiss_link( array(
651
-									'title'            => __( 'Click here if already renewed', 'give' ),
650
+								Give()->notices->get_dismiss_link(array(
651
+									'title'            => __('Click here if already renewed', 'give'),
652 652
 									'dismissible_type' => 'user',
653 653
 									'dismiss_interval' => 'permanent',
654
-								) )
654
+								))
655 655
 							),
656 656
 							'dismissible_type' => 'user',
657 657
 							'dismiss_interval' => 'shortly',
658
-						) );
658
+						));
659 659
 					}
660 660
 
661 661
 					// Stop validation for these license keys.
662
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
662
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
663 663
 				}// End foreach().
664 664
 				$showed_subscriptions_message = true;
665 665
 			}// End if().
666 666
 
667 667
 			// Show Non Subscription Give Add-on messages.
668 668
 			if (
669
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
670
-				&& ! empty( $this->license )
671
-				&& empty( $showed_invalid_message )
669
+				! in_array($this->license, $addon_license_key_in_subscriptions)
670
+				&& ! empty($this->license)
671
+				&& empty($showed_invalid_message)
672 672
 				&& ! $this->is_valid_license()
673 673
 			) {
674 674
 
675
-				Give()->notices->register_notice( array(
675
+				Give()->notices->register_notice(array(
676 676
 					'id'               => 'give-invalid-license',
677 677
 					'type'             => 'error',
678 678
 					'description'      => sprintf(
679
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
680
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
679
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
680
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
681 681
 					),
682 682
 					'dismissible_type' => 'user',
683 683
 					'dismiss_interval' => 'shortly',
684
-				) );
684
+				));
685 685
 
686 686
 				$showed_invalid_message = true;
687 687
 
@@ -698,10 +698,10 @@  discard block
 block discarded – undo
698 698
 		 *
699 699
 		 * @return bool
700 700
 		 */
701
-		public function is_valid_license( $licence_data = null ) {
702
-			$license_data = empty( $licence_data ) ? $this->license_data : $licence_data;
701
+		public function is_valid_license($licence_data = null) {
702
+			$license_data = empty($licence_data) ? $this->license_data : $licence_data;
703 703
 
704
-			if ( apply_filters( 'give_is_valid_license', ( $this->is_license( $license_data ) && 'valid' === $license_data->license ) ) ) {
704
+			if (apply_filters('give_is_valid_license', ($this->is_license($license_data) && 'valid' === $license_data->license))) {
705 705
 				return true;
706 706
 			}
707 707
 
@@ -719,10 +719,10 @@  discard block
 block discarded – undo
719 719
 		 *
720 720
 		 * @return bool
721 721
 		 */
722
-		public function is_license( $licence_data = null ) {
723
-			$license_data = empty( $licence_data ) ? $this->license_data : $licence_data;
722
+		public function is_license($licence_data = null) {
723
+			$license_data = empty($licence_data) ? $this->license_data : $licence_data;
724 724
 
725
-			if ( apply_filters( 'give_is_license', ( is_object( $license_data ) && ! empty( $license_data ) && property_exists( $license_data, 'license' ) ) ) ) {
725
+			if (apply_filters('give_is_license', (is_object($license_data) && ! empty($license_data) && property_exists($license_data, 'license')))) {
726 726
 				return true;
727 727
 			}
728 728
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 		 * @return bool
739 739
 		 */
740 740
 		private function __is_third_party_addon() {
741
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
741
+			return (false === strpos($this->api_url, 'givewp.com/'));
742 742
 		}
743 743
 
744 744
 		/**
@@ -753,25 +753,25 @@  discard block
 block discarded – undo
753 753
 		 * @return bool
754 754
 		 */
755 755
 		private function __remove_license_key_from_subscriptions() {
756
-			$subscriptions = get_option( 'give_subscriptions', array() );
756
+			$subscriptions = get_option('give_subscriptions', array());
757 757
 
758 758
 			// Bailout.
759
-			if ( empty( $this->license ) ) {
759
+			if (empty($this->license)) {
760 760
 				return false;
761 761
 			}
762 762
 
763
-			if ( ! empty( $subscriptions ) ) {
764
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
765
-					$license_index = array_search( $this->license, $subscription['licenses'] );
766
-					if ( false !== $license_index ) {
763
+			if ( ! empty($subscriptions)) {
764
+				foreach ($subscriptions as $subscription_id => $subscription) {
765
+					$license_index = array_search($this->license, $subscription['licenses']);
766
+					if (false !== $license_index) {
767 767
 						// Remove license key.
768
-						unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] );
768
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
769 769
 
770 770
 						// Rearrange license keys.
771
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
771
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
772 772
 
773 773
 						// Update subscription information.
774
-						update_option( 'give_subscriptions', $subscriptions );
774
+						update_option('give_subscriptions', $subscriptions);
775 775
 						break;
776 776
 					}
777 777
 				}
@@ -785,17 +785,17 @@  discard block
 block discarded – undo
785 785
 		 *
786 786
 		 * @return bool
787 787
 		 */
788
-		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
788
+		public function plugin_page_notices($plugin_file, $plugin_data, $status) {
789 789
 			// Bailout.
790
-			if ( $this->is_valid_license() ) {
790
+			if ($this->is_valid_license()) {
791 791
 				return false;
792 792
 			}
793 793
 
794 794
 			$update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>';
795 795
 			$message            = $this->license_state_message();
796 796
 
797
-			if ( ! empty( $message['message'] ) ) {
798
-				echo sprintf( $update_notice_wrap, $message['message'] );
797
+			if ( ! empty($message['message'])) {
798
+				echo sprintf($update_notice_wrap, $message['message']);
799 799
 			}
800 800
 		}
801 801
 
@@ -810,11 +810,11 @@  discard block
 block discarded – undo
810 810
 		public function license_state_message() {
811 811
 			$message_data = array();
812 812
 
813
-			if ( ! $this->is_valid_license() ) {
813
+			if ( ! $this->is_valid_license()) {
814 814
 
815 815
 				$message_data['message'] = sprintf(
816 816
 					'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.',
817
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ),
817
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')),
818 818
 					$this->item_name
819 819
 				);
820 820
 			}
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 			// Bailout.
834 834
 			if (
835 835
 				! Give_Admin_Settings::verify_nonce() ||
836
-				! current_user_can( 'manage_give_settings' ) ||
836
+				! current_user_can('manage_give_settings') ||
837 837
 				'licenses' !== give_get_current_setting_tab()
838 838
 			) {
839 839
 				return false;
@@ -841,10 +841,10 @@  discard block
 block discarded – undo
841 841
 
842 842
 			// Security check.
843 843
 			if (
844
-				isset( $_POST[ $this->item_shortname . '_license_key-nonce' ] ) &&
845
-				! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' )
844
+				isset($_POST[$this->item_shortname.'_license_key-nonce']) &&
845
+				! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')
846 846
 			) {
847
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
847
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
848 848
 			}
849 849
 
850 850
 			return true;
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 		 *
863 863
 		 * @return mixed
864 864
 		 */
865
-		public function get_license_info( $edd_action = '', $response_in_array = false ) {
866
-			if ( empty( $edd_action ) ) {
865
+		public function get_license_info($edd_action = '', $response_in_array = false) {
866
+			if (empty($edd_action)) {
867 867
 				return false;
868 868
 			}
869 869
 
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 			$api_params = array(
872 872
 				'edd_action' => $edd_action, // never change from "edd_" to "give_"!
873 873
 				'license'    => $this->license,
874
-				'item_name'  => urlencode( $this->item_name ),
874
+				'item_name'  => urlencode($this->item_name),
875 875
 				'url'        => home_url(),
876 876
 			);
877 877
 
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
 			);
887 887
 
888 888
 			// Make sure there are no errors.
889
-			if ( is_wp_error( $response ) ) {
889
+			if (is_wp_error($response)) {
890 890
 				return false;
891 891
 			}
892 892
 
893
-			return json_decode( wp_remote_retrieve_body( $response ), $response_in_array );
893
+			return json_decode(wp_remote_retrieve_body($response), $response_in_array);
894 894
 		}
895 895
 
896 896
 
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 			$this->__remove_license_key_from_subscriptions();
906 906
 
907 907
 			// Remove license from database.
908
-			delete_option( "{$this->item_shortname}_license_active" );
909
-			give_delete_option( "{$this->item_shortname}_license_key" );
908
+			delete_option("{$this->item_shortname}_license_active");
909
+			give_delete_option("{$this->item_shortname}_license_key");
910 910
 
911 911
 			// Unset license param.
912 912
 			$this->license = '';
Please login to merge, or discard this patch.
includes/login-register.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
  * @param string $user_login Username
175 175
  * @param string $user_pass  Password
176 176
  *
177
- * @return bool
177
+ * @return false|null
178 178
  */
179 179
 function give_log_user_in( $user_id, $user_login, $user_pass ) {
180 180
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
  *
216 216
  * @param array $data Data sent from the register form
217 217
  *
218
- * @return bool
218
+ * @return false|null
219 219
  */
220 220
 function give_process_register_form( $data ) {
221 221
 
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,23 +26,23 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return string Login form
28 28
  */
29
-function give_login_form( $login_redirect = '', $logout_redirect = '' ) {
30
-	if ( empty( $login_redirect ) ) {
31
-		$login_redirect = add_query_arg( 'give-login-success', 'true', give_get_current_page_url() );
29
+function give_login_form($login_redirect = '', $logout_redirect = '') {
30
+	if (empty($login_redirect)) {
31
+		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
32 32
 	}
33 33
 
34
-	if ( empty( $logout_redirect ) ) {
35
-		$logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
34
+	if (empty($logout_redirect)) {
35
+		$logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url());
36 36
 	}
37 37
 
38 38
 	// Add user_logout action to logout url.
39 39
 	$logout_redirect = add_query_arg(
40 40
 		array(
41 41
 			'give_action'          => 'user_logout',
42
-			'give_logout_nonce'    => wp_create_nonce( 'give-logout-nonce' ),
43
-			'give_logout_redirect' => urlencode( $logout_redirect ),
42
+			'give_logout_nonce'    => wp_create_nonce('give-logout-nonce'),
43
+			'give_logout_redirect' => urlencode($logout_redirect),
44 44
 		),
45
-		home_url( '/' )
45
+		home_url('/')
46 46
 	);
47 47
 
48 48
 	ob_start();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		)
56 56
 	);
57 57
 
58
-	return apply_filters( 'give_login_form', ob_get_clean() );
58
+	return apply_filters('give_login_form', ob_get_clean());
59 59
 }
60 60
 
61 61
 /**
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
  *
69 69
  * @return string Register form
70 70
  */
71
-function give_register_form( $redirect = '' ) {
72
-	if ( empty( $redirect ) ) {
71
+function give_register_form($redirect = '') {
72
+	if (empty($redirect)) {
73 73
 		$redirect = give_get_current_page_url();
74 74
 	}
75 75
 
76 76
 	ob_start();
77 77
 
78
-	if ( ! is_user_logged_in() ) {
78
+	if ( ! is_user_logged_in()) {
79 79
 		give_get_template(
80 80
 			'shortcode-register',
81 81
 			array(
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 	}
86 86
 
87
-	return apply_filters( 'give_register_form', ob_get_clean() );
87
+	return apply_filters('give_register_form', ob_get_clean());
88 88
 }
89 89
 
90 90
 /**
@@ -96,34 +96,34 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return void
98 98
  */
99
-function give_process_login_form( $data ) {
100
-	if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) {
101
-		$user_data = get_user_by( 'login', $data['give_user_login'] );
102
-		if ( ! $user_data ) {
103
-			$user_data = get_user_by( 'email', $data['give_user_login'] );
99
+function give_process_login_form($data) {
100
+	if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) {
101
+		$user_data = get_user_by('login', $data['give_user_login']);
102
+		if ( ! $user_data) {
103
+			$user_data = get_user_by('email', $data['give_user_login']);
104 104
 		}
105
-		if ( $user_data ) {
105
+		if ($user_data) {
106 106
 			$user_ID    = $user_data->ID;
107 107
 			$user_email = $user_data->user_email;
108
-			if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_ID ) ) {
109
-				give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] );
108
+			if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_ID)) {
109
+				give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']);
110 110
 			} else {
111
-				give_set_error( 'password_incorrect', __( 'The password you entered is incorrect.', 'give' ) );
111
+				give_set_error('password_incorrect', __('The password you entered is incorrect.', 'give'));
112 112
 			}
113 113
 		} else {
114
-			give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
114
+			give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
115 115
 		}
116 116
 		// Check for errors and redirect if none present
117 117
 		$errors = give_get_errors();
118
-		if ( ! $errors ) {
119
-			$redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID );
120
-			wp_redirect( $redirect );
118
+		if ( ! $errors) {
119
+			$redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID);
120
+			wp_redirect($redirect);
121 121
 			give_die();
122 122
 		}
123 123
 	}
124 124
 }
125 125
 
126
-add_action( 'give_user_login', 'give_process_login_form' );
126
+add_action('give_user_login', 'give_process_login_form');
127 127
 
128 128
 
129 129
 /**
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return void
137 137
  */
138
-function give_process_user_logout( $data ) {
139
-	if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
138
+function give_process_user_logout($data) {
139
+	if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) {
140 140
 
141 141
 		// Prevent occurring of any custom action on wp_logout.
142
-		remove_all_actions( 'wp_logout' );
142
+		remove_all_actions('wp_logout');
143 143
 
144 144
 		/**
145 145
 		 * Fires before processing user logout.
146 146
 		 *
147 147
 		 * @since 1.0
148 148
 		 */
149
-		do_action( 'give_before_user_logout' );
149
+		do_action('give_before_user_logout');
150 150
 
151 151
 		// Logout user.
152 152
 		wp_logout();
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 		 *
157 157
 		 * @since 1.0
158 158
 		 */
159
-		do_action( 'give_after_user_logout' );
159
+		do_action('give_after_user_logout');
160 160
 
161
-		wp_redirect( $data['give_logout_redirect'] );
161
+		wp_redirect($data['give_logout_redirect']);
162 162
 		give_die();
163 163
 	}
164 164
 }
165 165
 
166
-add_action( 'give_user_logout', 'give_process_user_logout' );
166
+add_action('give_user_logout', 'give_process_user_logout');
167 167
 
168 168
 /**
169 169
  * Log User In
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @return bool
178 178
  */
179
-function give_log_user_in( $user_id, $user_login, $user_pass ) {
179
+function give_log_user_in($user_id, $user_login, $user_pass) {
180 180
 
181
-	if ( $user_id < 1 ) {
181
+	if ($user_id < 1) {
182 182
 		return false;
183 183
 	}
184 184
 
185
-	wp_set_auth_cookie( $user_id );
186
-	wp_set_current_user( $user_id, $user_login );
185
+	wp_set_auth_cookie($user_id);
186
+	wp_set_current_user($user_id, $user_login);
187 187
 
188 188
 	/**
189 189
 	 * Fires after the user has successfully logged in.
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @param string  $user_login Username.
194 194
 	 * @param WP_User $$user      WP_User object of the logged-in user.
195 195
 	 */
196
-	do_action( 'wp_login', $user_login, get_userdata( $user_id ) );
196
+	do_action('wp_login', $user_login, get_userdata($user_id));
197 197
 
198 198
 	/**
199 199
 	 * Fires after give user has successfully logged in.
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @param string $user_login Username.
205 205
 	 * @param string $user_pass  User password.
206 206
 	 */
207
-	do_action( 'give_log_user_in', $user_id, $user_login, $user_pass );
207
+	do_action('give_log_user_in', $user_id, $user_login, $user_pass);
208 208
 }
209 209
 
210 210
 
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return bool
219 219
  */
220
-function give_process_register_form( $data ) {
220
+function give_process_register_form($data) {
221 221
 
222
-	if ( is_user_logged_in() ) {
222
+	if (is_user_logged_in()) {
223 223
 		return false;
224 224
 	}
225 225
 
226
-	if ( empty( $_POST['give_register_submit'] ) ) {
226
+	if (empty($_POST['give_register_submit'])) {
227 227
 		return false;
228 228
 	}
229 229
 
@@ -232,38 +232,38 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @since 1.0
234 234
 	 */
235
-	do_action( 'give_pre_process_register_form' );
235
+	do_action('give_pre_process_register_form');
236 236
 
237
-	if ( empty( $data['give_user_login'] ) ) {
238
-		give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) );
237
+	if (empty($data['give_user_login'])) {
238
+		give_set_error('empty_username', esc_html__('Invalid username.', 'give'));
239 239
 	}
240 240
 
241
-	if ( username_exists( $data['give_user_login'] ) ) {
242
-		give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
241
+	if (username_exists($data['give_user_login'])) {
242
+		give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
243 243
 	}
244 244
 
245
-	if ( ! validate_username( $data['give_user_login'] ) ) {
246
-		give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
245
+	if ( ! validate_username($data['give_user_login'])) {
246
+		give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
247 247
 	}
248 248
 
249
-	if ( email_exists( $data['give_user_email'] ) ) {
250
-		give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) );
249
+	if (email_exists($data['give_user_email'])) {
250
+		give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give'));
251 251
 	}
252 252
 
253
-	if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) {
254
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
253
+	if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) {
254
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
255 255
 	}
256 256
 
257
-	if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) {
258
-		give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) );
257
+	if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) {
258
+		give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give'));
259 259
 	}
260 260
 
261
-	if ( empty( $_POST['give_user_pass'] ) ) {
262
-		give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) );
261
+	if (empty($_POST['give_user_pass'])) {
262
+		give_set_error('empty_password', esc_html__('Please enter a password.', 'give'));
263 263
 	}
264 264
 
265
-	if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) {
266
-		give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
265
+	if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) {
266
+		give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
267 267
 	}
268 268
 
269 269
 	/**
@@ -271,26 +271,26 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @since 1.0
273 273
 	 */
274
-	do_action( 'give_process_register_form' );
274
+	do_action('give_process_register_form');
275 275
 
276 276
 	// Check for errors and redirect if none present
277 277
 	$errors = give_get_errors();
278 278
 
279
-	if ( empty( $errors ) ) {
279
+	if (empty($errors)) {
280 280
 
281
-		$redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] );
281
+		$redirect = apply_filters('give_register_redirect', $data['give_redirect']);
282 282
 
283
-		give_register_and_login_new_user( array(
283
+		give_register_and_login_new_user(array(
284 284
 			'user_login'      => $data['give_user_login'],
285 285
 			'user_pass'       => $data['give_user_pass'],
286 286
 			'user_email'      => $data['give_user_email'],
287
-			'user_registered' => date( 'Y-m-d H:i:s' ),
288
-			'role'            => get_option( 'default_role' ),
289
-		) );
287
+			'user_registered' => date('Y-m-d H:i:s'),
288
+			'role'            => get_option('default_role'),
289
+		));
290 290
 
291
-		wp_redirect( $redirect );
291
+		wp_redirect($redirect);
292 292
 		give_die();
293 293
 	}
294 294
 }
295 295
 
296
-add_action( 'give_user_register', 'give_process_register_form' );
296
+add_action('give_user_register', 'give_process_register_form');
Please login to merge, or discard this patch.