Completed
Pull Request — master (#986)
by Rami
20:36
created
includes/admin/class-admin-notices.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
 	 *
38 38
 	 * Display admin bar when active
39 39
 	 *
40
-	 * @return bool
40
+	 * @return false|null
41 41
 	 */
42 42
 	public function give_admin_bar_menu() {
43 43
 		global $wp_admin_bar;
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 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
 
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 	 * @since 1.0
28 28
 	 */
29 29
 	public function __construct() {
30
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
31
-		add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) );
32
-		add_action( 'admin_bar_menu', array( $this, 'give_admin_bar_menu' ), 1000 );
30
+		add_action('admin_notices', array($this, 'show_notices'));
31
+		add_action('give_dismiss_notices', array($this, 'dismiss_notices'));
32
+		add_action('admin_bar_menu', array($this, 'give_admin_bar_menu'), 1000);
33 33
 	}
34 34
 
35 35
 
@@ -41,18 +41,18 @@  discard block
 block discarded – undo
41 41
 	public function give_admin_bar_menu() {
42 42
 		global $wp_admin_bar;
43 43
 
44
-		if ( ! give_is_test_mode() || ! current_user_can( 'view_give_reports' ) ) {
44
+		if ( ! give_is_test_mode() || ! current_user_can('view_give_reports')) {
45 45
 			return false;
46 46
 		}
47 47
 
48 48
 		//Add the main siteadmin menu item.
49
-		$wp_admin_bar->add_menu( array(
49
+		$wp_admin_bar->add_menu(array(
50 50
 			'id'     => 'give-test-notice',
51
-			'href'   => admin_url() . 'edit.php?post_type=give_forms&page=give-settings&tab=gateways',
51
+			'href'   => admin_url().'edit.php?post_type=give_forms&page=give-settings&tab=gateways',
52 52
 			'parent' => 'top-secondary',
53
-			'title'  => esc_html__( 'Give Test Mode Active', 'give' ),
54
-			'meta'   => array( 'class' => 'give-test-mode-active' ),
55
-		) );
53
+			'title'  => esc_html__('Give Test Mode Active', 'give'),
54
+			'meta'   => array('class' => 'give-test-mode-active'),
55
+		));
56 56
 
57 57
 	}
58 58
 
@@ -67,98 +67,98 @@  discard block
 block discarded – undo
67 67
 			'error'   => array()
68 68
 		);
69 69
 
70
-		if ( ! give_test_ajax_works() && ! get_user_meta( get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true ) && current_user_can( 'manage_give_settings' ) ) {
70
+		if ( ! give_test_ajax_works() && ! get_user_meta(get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true) && current_user_can('manage_give_settings')) {
71 71
 			echo '<div class="error">';
72
-			echo '<p>' . esc_html__( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>';
72
+			echo '<p>'.esc_html__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>';
73 73
 			/* translators: %s: https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/ */
74
-			echo '<p>' . sprintf( __( 'Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give' ), esc_url( 'https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/' ) ) . '</p>';
75
-			echo '<p><a href="' . add_query_arg( array(
74
+			echo '<p>'.sprintf(__('Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give'), esc_url('https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/')).'</p>';
75
+			echo '<p><a href="'.add_query_arg(array(
76 76
 					'give_action' => 'dismiss_notices',
77 77
 					'give_notice' => 'admin_ajax_inaccessible'
78
-				) ) . '">' . esc_attr__( 'Dismiss Notice', 'give' ) . '</a></p>';
78
+				)).'">'.esc_attr__('Dismiss Notice', 'give').'</a></p>';
79 79
 			echo '</div>';
80 80
 		}
81 81
 
82 82
 
83
-		if ( isset( $_GET['give-message'] ) ) {
83
+		if (isset($_GET['give-message'])) {
84 84
 
85 85
 			// Donation reports errors.
86
-			if ( current_user_can( 'view_give_reports' ) ) {
87
-				switch ( $_GET['give-message'] ) {
86
+			if (current_user_can('view_give_reports')) {
87
+				switch ($_GET['give-message']) {
88 88
 					case 'payment_deleted' :
89
-						$notices['updated']['give-payment-deleted'] = esc_attr__( 'The donation has been deleted.', 'give' );
89
+						$notices['updated']['give-payment-deleted'] = esc_attr__('The donation has been deleted.', 'give');
90 90
 						break;
91 91
 					case 'email_sent' :
92
-						$notices['updated']['give-payment-sent'] = esc_attr__( 'The donation receipt has been resent.', 'give' );
92
+						$notices['updated']['give-payment-sent'] = esc_attr__('The donation receipt has been resent.', 'give');
93 93
 						break;
94 94
 					case 'refreshed-reports' :
95
-						$notices['updated']['give-refreshed-reports'] = esc_attr__( 'The reports cache has been cleared.', 'give' );
95
+						$notices['updated']['give-refreshed-reports'] = esc_attr__('The reports cache has been cleared.', 'give');
96 96
 						break;
97 97
 					case 'payment-note-deleted' :
98
-						$notices['updated']['give-payment-note-deleted'] = esc_attr__( 'The donation note has been deleted.', 'give' );
98
+						$notices['updated']['give-payment-note-deleted'] = esc_attr__('The donation note has been deleted.', 'give');
99 99
 						break;
100 100
 				}
101 101
 			}
102 102
 
103 103
 			// Give settings notices and errors.
104
-			if ( current_user_can( 'manage_give_settings' ) ) {
105
-				switch ( $_GET['give-message'] ) {
104
+			if (current_user_can('manage_give_settings')) {
105
+				switch ($_GET['give-message']) {
106 106
 					case 'settings-imported' :
107
-						$notices['updated']['give-settings-imported'] = esc_attr__( 'The settings have been imported.', 'give' );
107
+						$notices['updated']['give-settings-imported'] = esc_attr__('The settings have been imported.', 'give');
108 108
 						break;
109 109
 					case 'api-key-generated' :
110
-						$notices['updated']['give-api-key-generated'] = esc_attr__( 'API keys have been generated.', 'give' );
110
+						$notices['updated']['give-api-key-generated'] = esc_attr__('API keys have been generated.', 'give');
111 111
 						break;
112 112
 					case 'api-key-exists' :
113
-						$notices['error']['give-api-key-exists'] = esc_attr__( 'The specified user already has API keys.', 'give' );
113
+						$notices['error']['give-api-key-exists'] = esc_attr__('The specified user already has API keys.', 'give');
114 114
 						break;
115 115
 					case 'api-key-regenerated' :
116
-						$notices['updated']['give-api-key-regenerated'] = esc_attr__( 'API keys have been regenerated.', 'give' );
116
+						$notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys have been regenerated.', 'give');
117 117
 						break;
118 118
 					case 'api-key-revoked' :
119
-						$notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys have been revoked.', 'give' );
119
+						$notices['updated']['give-api-key-revoked'] = esc_attr__('API keys have been revoked.', 'give');
120 120
 						break;
121 121
 					case 'sent-test-email' :
122
-						$notices['updated']['give-sent-test-email'] = esc_attr__( 'The test email has been sent.', 'give' );
122
+						$notices['updated']['give-sent-test-email'] = esc_attr__('The test email has been sent.', 'give');
123 123
 						break;
124 124
 				}
125 125
 			}
126 126
 			// Payments errors.
127
-			if ( current_user_can( 'edit_give_payments' ) ) {
128
-				switch ( $_GET['give-message'] ) {
127
+			if (current_user_can('edit_give_payments')) {
128
+				switch ($_GET['give-message']) {
129 129
 					case 'note-added' :
130
-						$notices['updated']['give-note-added'] = esc_attr__( 'The donation note has been added.', 'give' );
130
+						$notices['updated']['give-note-added'] = esc_attr__('The donation note has been added.', 'give');
131 131
 						break;
132 132
 					case 'payment-updated' :
133
-						$notices['updated']['give-payment-updated'] = esc_attr__( 'The donation has been updated.', 'give' );
133
+						$notices['updated']['give-payment-updated'] = esc_attr__('The donation has been updated.', 'give');
134 134
 						break;
135 135
 				}
136 136
 			}
137 137
 
138 138
 			// Customer Notices.
139
-			if ( current_user_can( 'edit_give_payments' ) ) {
140
-				switch ( $_GET['give-message'] ) {
139
+			if (current_user_can('edit_give_payments')) {
140
+				switch ($_GET['give-message']) {
141 141
 					case 'customer-deleted' :
142
-						$notices['updated']['give-customer-deleted'] = esc_attr__( 'The donor has been deleted.', 'give' );
142
+						$notices['updated']['give-customer-deleted'] = esc_attr__('The donor has been deleted.', 'give');
143 143
 						break;
144 144
 				}
145 145
 			}
146 146
 
147 147
 		}
148 148
 
149
-		if ( count( $notices['updated'] ) > 0 ) {
150
-			foreach ( $notices['updated'] as $notice => $message ) {
151
-				add_settings_error( 'give-notices', $notice, $message, 'updated' );
149
+		if (count($notices['updated']) > 0) {
150
+			foreach ($notices['updated'] as $notice => $message) {
151
+				add_settings_error('give-notices', $notice, $message, 'updated');
152 152
 			}
153 153
 		}
154 154
 
155
-		if ( count( $notices['error'] ) > 0 ) {
156
-			foreach ( $notices['error'] as $notice => $message ) {
157
-				add_settings_error( 'give-notices', $notice, $message, 'error' );
155
+		if (count($notices['error']) > 0) {
156
+			foreach ($notices['error'] as $notice => $message) {
157
+				add_settings_error('give-notices', $notice, $message, 'error');
158 158
 			}
159 159
 		}
160 160
 
161
-		settings_errors( 'give-notices' );
161
+		settings_errors('give-notices');
162 162
 
163 163
 	}
164 164
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 * @return void
171 171
 	 */
172 172
 	function give_admin_addons_notices() {
173
-		add_settings_error( 'give-notices', 'give-addons-feed-error', esc_attr__( 'There seems to be an issue with the server. Please try again in a few minutes.', 'give' ), 'error' );
174
-		settings_errors( 'give-notices' );
173
+		add_settings_error('give-notices', 'give-addons-feed-error', esc_attr__('There seems to be an issue with the server. Please try again in a few minutes.', 'give'), 'error');
174
+		settings_errors('give-notices');
175 175
 	}
176 176
 
177 177
 
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
 	 * @return void
183 183
 	 */
184 184
 	function dismiss_notices() {
185
-		if ( isset( $_GET['give_notice'] ) ) {
186
-			update_user_meta( get_current_user_id(), '_give_' . $_GET['give_notice'] . '_dismissed', 1 );
187
-			wp_redirect( remove_query_arg( array( 'give_action', 'give_notice' ) ) );
185
+		if (isset($_GET['give_notice'])) {
186
+			update_user_meta(get_current_user_id(), '_give_'.$_GET['give_notice'].'_dismissed', 1);
187
+			wp_redirect(remove_query_arg(array('give_action', 'give_notice')));
188 188
 			exit;
189 189
 		}
190 190
 	}
Please login to merge, or discard this patch.
includes/admin/class-api-keys-table.php 2 patches
Doc Comments   +1 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,7 +81,6 @@  discard block
 block discarded – undo
81 81
 	 * @since  1.1
82 82
 	 *
83 83
 	 * @param array  $item        Contains all the data of the keys
84
-	 * @param string $column_name The name of the column
85 84
 	 *
86 85
 	 * @return string Column Name
87 86
 	 */
@@ -96,7 +95,6 @@  discard block
 block discarded – undo
96 95
 	 * @since  1.1
97 96
 	 *
98 97
 	 * @param array  $item        Contains all the data of the keys
99
-	 * @param string $column_name The name of the column
100 98
 	 *
101 99
 	 * @return string Column Name
102 100
 	 */
@@ -111,7 +109,6 @@  discard block
 block discarded – undo
111 109
 	 * @since  1.1
112 110
 	 *
113 111
 	 * @param array  $item        Contains all the data of the keys
114
-	 * @param string $column_name The name of the column
115 112
 	 *
116 113
 	 * @return string Column Name
117 114
 	 */
@@ -124,7 +121,7 @@  discard block
 block discarded – undo
124 121
 	 *
125 122
 	 * @access public
126 123
 	 * @since  1.1
127
-	 * @return void
124
+	 * @return string
128 125
 	 */
129 126
 	public function column_user( $item ) {
130 127
 
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 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
 /**
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 		global $status, $page;
51 51
 
52 52
 		// Set parent defaults
53
-		parent::__construct( array(
54
-			'singular' => esc_html__( 'API Key', 'give' ),     // Singular name of the listed records
55
-			'plural'   => esc_html__( 'API Keys', 'give' ),    // Plural name of the listed records
53
+		parent::__construct(array(
54
+			'singular' => esc_html__('API Key', 'give'), // Singular name of the listed records
55
+			'plural'   => esc_html__('API Keys', 'give'), // Plural name of the listed records
56 56
 			'ajax'     => false                       // Does this table support ajax?
57
-		) );
57
+		));
58 58
 
59 59
 		$this->query();
60 60
 	}
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return string Column Name
72 72
 	 */
73
-	public function column_default( $item, $column_name ) {
74
-		return $item[ $column_name ];
73
+	public function column_default($item, $column_name) {
74
+		return $item[$column_name];
75 75
 	}
76 76
 
77 77
 	/**
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return string Column Name
87 87
 	 */
88
-	public function column_key( $item ) {
89
-		return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['key'] ) . '"/>';
88
+	public function column_key($item) {
89
+		return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['key']).'"/>';
90 90
 	}
91 91
 
92 92
 	/**
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @return string Column Name
102 102
 	 */
103
-	public function column_token( $item ) {
104
-		return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['token'] ) . '"/>';
103
+	public function column_token($item) {
104
+		return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['token']).'"/>';
105 105
 	}
106 106
 
107 107
 	/**
@@ -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 void
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
 					'view'      => 'api_requests',
138 138
 					'post_type' => 'give_forms',
139 139
 					'page'      => 'give-reports',
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
 	/**
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	public function get_columns() {
179 179
 		$columns = array(
180
-			'user'   => esc_html__( 'Username', 'give' ),
181
-			'key'    => esc_html__( 'Public Key', 'give' ),
182
-			'token'  => esc_html__( 'Token', 'give' ),
183
-			'secret' => esc_html__( 'Secret Key', 'give' )
180
+			'user'   => esc_html__('Username', 'give'),
181
+			'key'    => esc_html__('Public Key', 'give'),
182
+			'token'  => esc_html__('Token', 'give'),
183
+			'secret' => esc_html__('Secret Key', 'give')
184 184
 		);
185 185
 
186 186
 		return $columns;
@@ -193,19 +193,19 @@  discard block
 block discarded – undo
193 193
 	 * @since  1.1
194 194
 	 * @return void
195 195
 	 */
196
-	function bulk_actions( $which = '' ) {
196
+	function bulk_actions($which = '') {
197 197
 		// These aren't really bulk actions but this outputs the markup in the right place
198 198
 		static $give_api_is_bottom;
199 199
 
200
-		if ( $give_api_is_bottom ) {
200
+		if ($give_api_is_bottom) {
201 201
 			return;
202 202
 		}
203 203
 		?>
204 204
 		<input type="hidden" name="give_action" value="process_api_key"/>
205 205
 		<input type="hidden" name="give_api_process" value="generate"/>
206
-		<?php wp_nonce_field( 'give-api-nonce' ); ?>
206
+		<?php wp_nonce_field('give-api-nonce'); ?>
207 207
 		<?php echo Give()->html->ajax_user_search(); ?>
208
-		<?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?>
208
+		<?php submit_button(esc_html__('Generate New API Keys', 'give'), 'secondary', 'submit', false); ?>
209 209
 		<?php
210 210
 		$give_api_is_bottom = true;
211 211
 	}
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @return int Current page number
219 219
 	 */
220 220
 	public function get_paged() {
221
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
221
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
222 222
 	}
223 223
 
224 224
 	/**
@@ -229,21 +229,21 @@  discard block
 block discarded – undo
229 229
 	 * @return array
230 230
 	 */
231 231
 	public function query() {
232
-		$users = get_users( array(
232
+		$users = get_users(array(
233 233
 			'meta_value' => 'give_user_secret_key',
234 234
 			'number'     => $this->per_page,
235
-			'offset'     => $this->per_page * ( $this->get_paged() - 1 )
236
-		) );
237
-		$keys  = array();
238
-
239
-		foreach ( $users as $user ) {
240
-			$keys[ $user->ID ]['id']    = $user->ID;
241
-			$keys[ $user->ID ]['email'] = $user->user_email;
242
-			$keys[ $user->ID ]['user']  = '<a href="' . add_query_arg( 'user_id', $user->ID, 'user-edit.php' ) . '"><strong>' . $user->user_login . '</strong></a>';
243
-
244
-			$keys[ $user->ID ]['key']    = Give()->api->get_user_public_key( $user->ID );
245
-			$keys[ $user->ID ]['secret'] = Give()->api->get_user_secret_key( $user->ID );
246
-			$keys[ $user->ID ]['token']  = Give()->api->get_token( $user->ID );
235
+			'offset'     => $this->per_page * ($this->get_paged() - 1)
236
+		));
237
+		$keys = array();
238
+
239
+		foreach ($users as $user) {
240
+			$keys[$user->ID]['id']    = $user->ID;
241
+			$keys[$user->ID]['email'] = $user->user_email;
242
+			$keys[$user->ID]['user']  = '<a href="'.add_query_arg('user_id', $user->ID, 'user-edit.php').'"><strong>'.$user->user_login.'</strong></a>';
243
+
244
+			$keys[$user->ID]['key']    = Give()->api->get_user_public_key($user->ID);
245
+			$keys[$user->ID]['secret'] = Give()->api->get_user_secret_key($user->ID);
246
+			$keys[$user->ID]['token']  = Give()->api->get_token($user->ID);
247 247
 		}
248 248
 
249 249
 		return $keys;
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 	public function total_items() {
261 261
 		global $wpdb;
262 262
 
263
-		if ( ! get_transient( 'give_total_api_keys' ) ) {
264
-			$total_items = $wpdb->get_var( "SELECT count(user_id) FROM $wpdb->usermeta WHERE meta_value='give_user_secret_key'" );
263
+		if ( ! get_transient('give_total_api_keys')) {
264
+			$total_items = $wpdb->get_var("SELECT count(user_id) FROM $wpdb->usermeta WHERE meta_value='give_user_secret_key'");
265 265
 
266
-			set_transient( 'give_total_api_keys', $total_items, 60 * 60 );
266
+			set_transient('give_total_api_keys', $total_items, 60 * 60);
267 267
 		}
268 268
 
269
-		return get_transient( 'give_total_api_keys' );
269
+		return get_transient('give_total_api_keys');
270 270
 	}
271 271
 
272 272
 	/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		$hidden   = array(); // No hidden columns
283 283
 		$sortable = array(); // Not sortable... for now
284 284
 
285
-		$this->_column_headers = array( $columns, $hidden, $sortable, 'id' );
285
+		$this->_column_headers = array($columns, $hidden, $sortable, 'id');
286 286
 
287 287
 		$data = $this->query();
288 288
 
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 
291 291
 		$this->items = $data;
292 292
 
293
-		$this->set_pagination_args( array(
293
+		$this->set_pagination_args(array(
294 294
 				'total_items' => $total_items,
295 295
 				'per_page'    => $this->per_page,
296
-				'total_pages' => ceil( $total_items / $this->per_page )
296
+				'total_pages' => ceil($total_items / $this->per_page)
297 297
 			)
298 298
 		);
299 299
 	}
Please login to merge, or discard this patch.
includes/admin/EDD_SL_Plugin_Updater.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
      * @uses api_request()
68 68
      *
69 69
      * @param array   $_transient_data Update array build by WordPress.
70
-     * @return array Modified update array with custom plugin data.
70
+     * @return stdClass Modified update array with custom plugin data.
71 71
      */
72 72
     function check_update( $_transient_data ) {
73 73
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,7 +4,9 @@  discard block
 block discarded – undo
4 4
 //set_site_transient( 'update_plugins', null );
5 5
 
6 6
 // Exit if accessed directly
7
-if ( ! defined( 'ABSPATH' ) ) exit;
7
+if ( ! defined( 'ABSPATH' ) ) {
8
+	exit;
9
+}
8 10
 
9 11
 /**
10 12
  * Allows plugins to use their own update API.
@@ -273,11 +275,13 @@  discard block
 block discarded – undo
273 275
 
274 276
         $data = array_merge( $this->api_data, $_data );
275 277
 
276
-        if ( $data['slug'] != $this->slug )
277
-            return;
278
+        if ( $data['slug'] != $this->slug ) {
279
+                    return;
280
+        }
278 281
 
279
-        if ( empty( $data['license'] ) )
280
-            return;
282
+        if ( empty( $data['license'] ) ) {
283
+                    return;
284
+        }
281 285
 
282 286
         if( $this->api_url == home_url() ) {
283 287
             return false; // Don't allow a plugin to ping itself
Please login to merge, or discard this patch.
Indentation   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -13,330 +13,330 @@
 block discarded – undo
13 13
  * @version 1.6
14 14
  */
15 15
 class EDD_SL_Plugin_Updater {
16
-    private $api_url   = '';
17
-    private $api_data  = array();
18
-    private $name      = '';
19
-    private $slug      = '';
20
-
21
-    /**
22
-     * Class constructor.
23
-     *
24
-     * @uses plugin_basename()
25
-     * @uses hook()
26
-     *
27
-     * @param string  $_api_url     The URL pointing to the custom API endpoint.
28
-     * @param string  $_plugin_file Path to the plugin file.
29
-     * @param array   $_api_data    Optional data to send with API calls.
30
-     * @return void
31
-     */
32
-    function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
-        $this->api_url  = trailingslashit( $_api_url );
34
-        $this->api_data = $_api_data;
35
-        $this->name     = plugin_basename( $_plugin_file );
36
-        $this->slug     = basename( $_plugin_file, '.php' );
37
-        $this->version  = $_api_data['version'];
38
-
39
-        // Set up hooks.
40
-        $this->init();
41
-        add_action( 'admin_init', array( $this, 'show_changelog' ) );
42
-    }
43
-
44
-    /**
45
-     * Set up WordPress filters to hook into WP's update process.
46
-     *
47
-     * @uses add_filter()
48
-     *
49
-     * @return void
50
-     */
51
-    public function init() {
16
+	private $api_url   = '';
17
+	private $api_data  = array();
18
+	private $name      = '';
19
+	private $slug      = '';
20
+
21
+	/**
22
+	 * Class constructor.
23
+	 *
24
+	 * @uses plugin_basename()
25
+	 * @uses hook()
26
+	 *
27
+	 * @param string  $_api_url     The URL pointing to the custom API endpoint.
28
+	 * @param string  $_plugin_file Path to the plugin file.
29
+	 * @param array   $_api_data    Optional data to send with API calls.
30
+	 * @return void
31
+	 */
32
+	function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
+		$this->api_url  = trailingslashit( $_api_url );
34
+		$this->api_data = $_api_data;
35
+		$this->name     = plugin_basename( $_plugin_file );
36
+		$this->slug     = basename( $_plugin_file, '.php' );
37
+		$this->version  = $_api_data['version'];
38
+
39
+		// Set up hooks.
40
+		$this->init();
41
+		add_action( 'admin_init', array( $this, 'show_changelog' ) );
42
+	}
43
+
44
+	/**
45
+	 * Set up WordPress filters to hook into WP's update process.
46
+	 *
47
+	 * @uses add_filter()
48
+	 *
49
+	 * @return void
50
+	 */
51
+	public function init() {
52 52
 
53
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
54
-        add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
53
+		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
54
+		add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
55 55
 
56
-        add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
57
-    }
56
+		add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
57
+	}
58 58
 
59
-    /**
60
-     * Check for Updates at the defined API endpoint and modify the update array.
61
-     *
62
-     * This function dives into the update API just when WordPress creates its update array,
63
-     * then adds a custom API call and injects the custom plugin data retrieved from the API.
64
-     * It is reassembled from parts of the native WordPress plugin update code.
65
-     * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
66
-     *
67
-     * @uses api_request()
68
-     *
69
-     * @param array   $_transient_data Update array build by WordPress.
70
-     * @return array Modified update array with custom plugin data.
71
-     */
72
-    function check_update( $_transient_data ) {
59
+	/**
60
+	 * Check for Updates at the defined API endpoint and modify the update array.
61
+	 *
62
+	 * This function dives into the update API just when WordPress creates its update array,
63
+	 * then adds a custom API call and injects the custom plugin data retrieved from the API.
64
+	 * It is reassembled from parts of the native WordPress plugin update code.
65
+	 * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
66
+	 *
67
+	 * @uses api_request()
68
+	 *
69
+	 * @param array   $_transient_data Update array build by WordPress.
70
+	 * @return array Modified update array with custom plugin data.
71
+	 */
72
+	function check_update( $_transient_data ) {
73 73
 
74
-        global $pagenow;
74
+		global $pagenow;
75 75
 
76
-        if( ! is_object( $_transient_data ) ) {
77
-            $_transient_data = new stdClass;
78
-        }
76
+		if( ! is_object( $_transient_data ) ) {
77
+			$_transient_data = new stdClass;
78
+		}
79 79
 
80
-        if( 'plugins.php' == $pagenow && is_multisite() ) {
81
-            return $_transient_data;
82
-        }
80
+		if( 'plugins.php' == $pagenow && is_multisite() ) {
81
+			return $_transient_data;
82
+		}
83 83
 
84
-        if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
84
+		if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
85 85
 
86
-            $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
86
+			$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
87 87
 
88
-            if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
88
+			if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
89 89
 
90
-                $this->did_check = true;
90
+				$this->did_check = true;
91 91
 
92
-                if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
92
+				if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
93 93
 
94
-                    $_transient_data->response[ $this->name ] = $version_info;
94
+					$_transient_data->response[ $this->name ] = $version_info;
95 95
 
96
-                }
96
+				}
97 97
 
98
-                $_transient_data->last_checked = time();
99
-                $_transient_data->checked[ $this->name ] = $this->version;
98
+				$_transient_data->last_checked = time();
99
+				$_transient_data->checked[ $this->name ] = $this->version;
100 100
 
101
-            }
101
+			}
102 102
 
103
-        }
103
+		}
104 104
 
105
-        return $_transient_data;
106
-    }
105
+		return $_transient_data;
106
+	}
107 107
 
108
-    /**
109
-     * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
110
-     *
111
-     * @param string  $file
112
-     * @param array   $plugin
113
-     */
114
-    public function show_update_notification( $file, $plugin ) {
108
+	/**
109
+	 * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
110
+	 *
111
+	 * @param string  $file
112
+	 * @param array   $plugin
113
+	 */
114
+	public function show_update_notification( $file, $plugin ) {
115 115
 
116
-        if( ! current_user_can( 'update_plugins' ) ) {
117
-            return;
118
-        }
116
+		if( ! current_user_can( 'update_plugins' ) ) {
117
+			return;
118
+		}
119 119
 
120
-        if( ! is_multisite() ) {
121
-            return;
122
-        }
120
+		if( ! is_multisite() ) {
121
+			return;
122
+		}
123 123
 
124
-        if ( $this->name != $file ) {
125
-            return;
126
-        }
124
+		if ( $this->name != $file ) {
125
+			return;
126
+		}
127 127
 
128
-        // Remove our filter on the site transient
129
-        remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
128
+		// Remove our filter on the site transient
129
+		remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
130 130
 
131
-        $update_cache = get_site_transient( 'update_plugins' );
131
+		$update_cache = get_site_transient( 'update_plugins' );
132 132
 
133
-        if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
133
+		if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
134 134
 
135
-            $cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
136
-            $version_info = get_transient( $cache_key );
135
+			$cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
136
+			$version_info = get_transient( $cache_key );
137 137
 
138
-            if( false === $version_info ) {
138
+			if( false === $version_info ) {
139 139
 
140
-                $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
140
+				$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
141 141
 
142
-                set_transient( $cache_key, $version_info, 3600 );
143
-            }
142
+				set_transient( $cache_key, $version_info, 3600 );
143
+			}
144 144
 
145 145
 
146
-            if( ! is_object( $version_info ) ) {
147
-                return;
148
-            }
146
+			if( ! is_object( $version_info ) ) {
147
+				return;
148
+			}
149 149
 
150
-            if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
150
+			if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
151 151
 
152
-                $update_cache->response[ $this->name ] = $version_info;
152
+				$update_cache->response[ $this->name ] = $version_info;
153 153
 
154
-            }
154
+			}
155 155
 
156
-            $update_cache->last_checked = time();
157
-            $update_cache->checked[ $this->name ] = $this->version;
156
+			$update_cache->last_checked = time();
157
+			$update_cache->checked[ $this->name ] = $this->version;
158 158
 
159
-            set_site_transient( 'update_plugins', $update_cache );
159
+			set_site_transient( 'update_plugins', $update_cache );
160 160
 
161
-        } else {
161
+		} else {
162 162
 
163
-            $version_info = $update_cache->response[ $this->name ];
163
+			$version_info = $update_cache->response[ $this->name ];
164 164
 
165
-        }
165
+		}
166 166
 
167
-        // Restore our filter
168
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
167
+		// Restore our filter
168
+		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
169 169
 
170
-        if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
170
+		if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
171 171
 
172
-            // build a plugin list row, with update notification
173
-            $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
174
-            echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
172
+			// build a plugin list row, with update notification
173
+			$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
174
+			echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
175 175
 
176
-            $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
176
+			$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
177 177
 
178
-            if ( empty( $version_info->download_link ) ) {
179
-                printf(
178
+			if ( empty( $version_info->download_link ) ) {
179
+				printf(
180 180
 					/* translators: 1: name 2: changelog URL 3: version */
181
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'give' ),
182
-                    esc_html( $version_info->name ),
183
-                    esc_url( $changelog_link ),
184
-                    esc_html( $version_info->new_version )
185
-                );
186
-            } else {
187
-                printf(
181
+					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'give' ),
182
+					esc_html( $version_info->name ),
183
+					esc_url( $changelog_link ),
184
+					esc_html( $version_info->new_version )
185
+				);
186
+			} else {
187
+				printf(
188 188
 					/* translators: 1: name 2: changelog URL 3: version 4: update URL */
189
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'give' ),
190
-                    esc_html( $version_info->name ),
191
-                    esc_url( $changelog_link ),
192
-                    esc_html( $version_info->new_version ),
193
-                    esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
194
-                );
195
-            }
196
-
197
-            echo '</div></td></tr>';
198
-        }
199
-    }
200
-
201
-
202
-    /**
203
-     * Updates information on the "View version x.x details" page with custom data.
204
-     *
205
-     * @uses api_request()
206
-     *
207
-     * @param mixed   $_data
208
-     * @param string  $_action
209
-     * @param object  $_args
210
-     * @return object $_data
211
-     */
212
-    function plugins_api_filter( $_data, $_action = '', $_args = null ) {
213
-
214
-
215
-        if ( $_action != 'plugin_information' ) {
216
-
217
-            return $_data;
218
-
219
-        }
220
-
221
-        if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
222
-
223
-            return $_data;
224
-
225
-        }
226
-
227
-        $to_send = array(
228
-            'slug'   => $this->slug,
229
-            'is_ssl' => is_ssl(),
230
-            'fields' => array(
231
-                'banners' => false, // These will be supported soon hopefully
232
-                'reviews' => false
233
-            )
234
-        );
235
-
236
-        $api_response = $this->api_request( 'plugin_information', $to_send );
237
-
238
-        if ( false !== $api_response ) {
239
-            $_data = $api_response;
240
-        }
241
-
242
-        return $_data;
243
-    }
244
-
245
-
246
-    /**
247
-     * Disable SSL verification in order to prevent download update failures
248
-     *
249
-     * @param array   $args
250
-     * @param string  $url
251
-     * @return object $array
252
-     */
253
-    function http_request_args( $args, $url ) {
254
-        // If it is an https request and we are performing a package download, disable ssl verification
255
-        if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
256
-            $args['sslverify'] = false;
257
-        }
258
-        return $args;
259
-    }
260
-
261
-    /**
262
-     * Calls the API and, if successfull, returns the object delivered by the API.
263
-     *
264
-     * @uses get_bloginfo()
265
-     * @uses wp_remote_post()
266
-     * @uses is_wp_error()
267
-     *
268
-     * @param string  $_action The requested action.
269
-     * @param array   $_data   Parameters for the API action.
270
-     * @return false||object
271
-     */
272
-    private function api_request( $_action, $_data ) {
273
-
274
-        global $wp_version;
275
-
276
-        $data = array_merge( $this->api_data, $_data );
277
-
278
-        if ( $data['slug'] != $this->slug )
279
-            return;
280
-
281
-        if ( empty( $data['license'] ) )
282
-            return;
283
-
284
-        if( $this->api_url == home_url() ) {
285
-            return false; // Don't allow a plugin to ping itself
286
-        }
287
-
288
-        $api_params = array(
289
-            'edd_action' => 'get_version',
290
-            'license'    => $data['license'],
291
-            'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
292
-            'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
293
-            'slug'       => $data['slug'],
294
-            'author'     => $data['author'],
295
-            'url'        => home_url()
296
-        );
189
+					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'give' ),
190
+					esc_html( $version_info->name ),
191
+					esc_url( $changelog_link ),
192
+					esc_html( $version_info->new_version ),
193
+					esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
194
+				);
195
+			}
196
+
197
+			echo '</div></td></tr>';
198
+		}
199
+	}
200
+
201
+
202
+	/**
203
+	 * Updates information on the "View version x.x details" page with custom data.
204
+	 *
205
+	 * @uses api_request()
206
+	 *
207
+	 * @param mixed   $_data
208
+	 * @param string  $_action
209
+	 * @param object  $_args
210
+	 * @return object $_data
211
+	 */
212
+	function plugins_api_filter( $_data, $_action = '', $_args = null ) {
213
+
214
+
215
+		if ( $_action != 'plugin_information' ) {
216
+
217
+			return $_data;
218
+
219
+		}
220
+
221
+		if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
222
+
223
+			return $_data;
224
+
225
+		}
226
+
227
+		$to_send = array(
228
+			'slug'   => $this->slug,
229
+			'is_ssl' => is_ssl(),
230
+			'fields' => array(
231
+				'banners' => false, // These will be supported soon hopefully
232
+				'reviews' => false
233
+			)
234
+		);
235
+
236
+		$api_response = $this->api_request( 'plugin_information', $to_send );
237
+
238
+		if ( false !== $api_response ) {
239
+			$_data = $api_response;
240
+		}
241
+
242
+		return $_data;
243
+	}
244
+
245
+
246
+	/**
247
+	 * Disable SSL verification in order to prevent download update failures
248
+	 *
249
+	 * @param array   $args
250
+	 * @param string  $url
251
+	 * @return object $array
252
+	 */
253
+	function http_request_args( $args, $url ) {
254
+		// If it is an https request and we are performing a package download, disable ssl verification
255
+		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
256
+			$args['sslverify'] = false;
257
+		}
258
+		return $args;
259
+	}
260
+
261
+	/**
262
+	 * Calls the API and, if successfull, returns the object delivered by the API.
263
+	 *
264
+	 * @uses get_bloginfo()
265
+	 * @uses wp_remote_post()
266
+	 * @uses is_wp_error()
267
+	 *
268
+	 * @param string  $_action The requested action.
269
+	 * @param array   $_data   Parameters for the API action.
270
+	 * @return false||object
271
+	 */
272
+	private function api_request( $_action, $_data ) {
273
+
274
+		global $wp_version;
275
+
276
+		$data = array_merge( $this->api_data, $_data );
277
+
278
+		if ( $data['slug'] != $this->slug )
279
+			return;
280
+
281
+		if ( empty( $data['license'] ) )
282
+			return;
283
+
284
+		if( $this->api_url == home_url() ) {
285
+			return false; // Don't allow a plugin to ping itself
286
+		}
287
+
288
+		$api_params = array(
289
+			'edd_action' => 'get_version',
290
+			'license'    => $data['license'],
291
+			'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
292
+			'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
293
+			'slug'       => $data['slug'],
294
+			'author'     => $data['author'],
295
+			'url'        => home_url()
296
+		);
297 297
 
298
-        $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
298
+		$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
299 299
 
300
-        if ( ! is_wp_error( $request ) ) {
301
-            $request = json_decode( wp_remote_retrieve_body( $request ) );
302
-        }
300
+		if ( ! is_wp_error( $request ) ) {
301
+			$request = json_decode( wp_remote_retrieve_body( $request ) );
302
+		}
303 303
 
304
-        if ( $request && isset( $request->sections ) ) {
305
-            $request->sections = maybe_unserialize( $request->sections );
306
-        } else {
307
-            $request = false;
308
-        }
304
+		if ( $request && isset( $request->sections ) ) {
305
+			$request->sections = maybe_unserialize( $request->sections );
306
+		} else {
307
+			$request = false;
308
+		}
309 309
 
310
-        return $request;
311
-    }
310
+		return $request;
311
+	}
312 312
 
313
-    public function show_changelog() {
313
+	public function show_changelog() {
314 314
 
315 315
 
316
-        if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
317
-            return;
318
-        }
316
+		if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
317
+			return;
318
+		}
319 319
 
320
-        if( empty( $_REQUEST['plugin'] ) ) {
321
-            return;
322
-        }
323
-
324
-        if( empty( $_REQUEST['slug'] ) ) {
325
-            return;
326
-        }
327
-
328
-        if( ! current_user_can( 'update_plugins' ) ) {
329
-            wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
330
-        }
331
-
332
-        $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
333
-
334
-        if( $response && isset( $response->sections['changelog'] ) ) {
335
-            echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
336
-        }
337
-
338
-
339
-        exit;
340
-    }
320
+		if( empty( $_REQUEST['plugin'] ) ) {
321
+			return;
322
+		}
323
+
324
+		if( empty( $_REQUEST['slug'] ) ) {
325
+			return;
326
+		}
327
+
328
+		if( ! current_user_can( 'update_plugins' ) ) {
329
+			wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
330
+		}
331
+
332
+		$response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
333
+
334
+		if( $response && isset( $response->sections['changelog'] ) ) {
335
+			echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
336
+		}
337
+
338
+
339
+		exit;
340
+	}
341 341
 
342 342
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 //set_site_transient( 'update_plugins', null );
5 5
 
6 6
 // Exit if accessed directly
7
-if ( ! defined( 'ABSPATH' ) ) exit;
7
+if ( ! defined('ABSPATH')) exit;
8 8
 
9 9
 /**
10 10
  * Allows plugins to use their own update API.
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
      * @param array   $_api_data    Optional data to send with API calls.
30 30
      * @return void
31 31
      */
32
-    function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
-        $this->api_url  = trailingslashit( $_api_url );
32
+    function __construct($_api_url, $_plugin_file, $_api_data = null) {
33
+        $this->api_url  = trailingslashit($_api_url);
34 34
         $this->api_data = $_api_data;
35
-        $this->name     = plugin_basename( $_plugin_file );
36
-        $this->slug     = basename( $_plugin_file, '.php' );
35
+        $this->name     = plugin_basename($_plugin_file);
36
+        $this->slug     = basename($_plugin_file, '.php');
37 37
         $this->version  = $_api_data['version'];
38 38
 
39 39
         // Set up hooks.
40 40
         $this->init();
41
-        add_action( 'admin_init', array( $this, 'show_changelog' ) );
41
+        add_action('admin_init', array($this, 'show_changelog'));
42 42
     }
43 43
 
44 44
     /**
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function init() {
52 52
 
53
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
54
-        add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
53
+        add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
54
+        add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3);
55 55
 
56
-        add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
56
+        add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2);
57 57
     }
58 58
 
59 59
     /**
@@ -69,34 +69,34 @@  discard block
 block discarded – undo
69 69
      * @param array   $_transient_data Update array build by WordPress.
70 70
      * @return array Modified update array with custom plugin data.
71 71
      */
72
-    function check_update( $_transient_data ) {
72
+    function check_update($_transient_data) {
73 73
 
74 74
         global $pagenow;
75 75
 
76
-        if( ! is_object( $_transient_data ) ) {
76
+        if ( ! is_object($_transient_data)) {
77 77
             $_transient_data = new stdClass;
78 78
         }
79 79
 
80
-        if( 'plugins.php' == $pagenow && is_multisite() ) {
80
+        if ('plugins.php' == $pagenow && is_multisite()) {
81 81
             return $_transient_data;
82 82
         }
83 83
 
84
-        if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
84
+        if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) {
85 85
 
86
-            $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
86
+            $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
87 87
 
88
-            if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
88
+            if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) {
89 89
 
90 90
                 $this->did_check = true;
91 91
 
92
-                if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
92
+                if (version_compare($this->version, $version_info->new_version, '<')) {
93 93
 
94
-                    $_transient_data->response[ $this->name ] = $version_info;
94
+                    $_transient_data->response[$this->name] = $version_info;
95 95
 
96 96
                 }
97 97
 
98 98
                 $_transient_data->last_checked = time();
99
-                $_transient_data->checked[ $this->name ] = $this->version;
99
+                $_transient_data->checked[$this->name] = $this->version;
100 100
 
101 101
             }
102 102
 
@@ -111,86 +111,86 @@  discard block
 block discarded – undo
111 111
      * @param string  $file
112 112
      * @param array   $plugin
113 113
      */
114
-    public function show_update_notification( $file, $plugin ) {
114
+    public function show_update_notification($file, $plugin) {
115 115
 
116
-        if( ! current_user_can( 'update_plugins' ) ) {
116
+        if ( ! current_user_can('update_plugins')) {
117 117
             return;
118 118
         }
119 119
 
120
-        if( ! is_multisite() ) {
120
+        if ( ! is_multisite()) {
121 121
             return;
122 122
         }
123 123
 
124
-        if ( $this->name != $file ) {
124
+        if ($this->name != $file) {
125 125
             return;
126 126
         }
127 127
 
128 128
         // Remove our filter on the site transient
129
-        remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
129
+        remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10);
130 130
 
131
-        $update_cache = get_site_transient( 'update_plugins' );
131
+        $update_cache = get_site_transient('update_plugins');
132 132
 
133
-        if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
133
+        if ( ! is_object($update_cache) || empty($update_cache->response) || empty($update_cache->response[$this->name])) {
134 134
 
135
-            $cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
136
-            $version_info = get_transient( $cache_key );
135
+            $cache_key    = md5('edd_plugin_'.sanitize_key($this->name).'_version_info');
136
+            $version_info = get_transient($cache_key);
137 137
 
138
-            if( false === $version_info ) {
138
+            if (false === $version_info) {
139 139
 
140
-                $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
140
+                $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
141 141
 
142
-                set_transient( $cache_key, $version_info, 3600 );
142
+                set_transient($cache_key, $version_info, 3600);
143 143
             }
144 144
 
145 145
 
146
-            if( ! is_object( $version_info ) ) {
146
+            if ( ! is_object($version_info)) {
147 147
                 return;
148 148
             }
149 149
 
150
-            if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
150
+            if (version_compare($this->version, $version_info->new_version, '<')) {
151 151
 
152
-                $update_cache->response[ $this->name ] = $version_info;
152
+                $update_cache->response[$this->name] = $version_info;
153 153
 
154 154
             }
155 155
 
156 156
             $update_cache->last_checked = time();
157
-            $update_cache->checked[ $this->name ] = $this->version;
157
+            $update_cache->checked[$this->name] = $this->version;
158 158
 
159
-            set_site_transient( 'update_plugins', $update_cache );
159
+            set_site_transient('update_plugins', $update_cache);
160 160
 
161 161
         } else {
162 162
 
163
-            $version_info = $update_cache->response[ $this->name ];
163
+            $version_info = $update_cache->response[$this->name];
164 164
 
165 165
         }
166 166
 
167 167
         // Restore our filter
168
-        add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
168
+        add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
169 169
 
170
-        if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
170
+        if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) {
171 171
 
172 172
             // build a plugin list row, with update notification
173
-            $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
174
-            echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
173
+            $wp_list_table = _get_list_table('WP_Plugins_List_Table');
174
+            echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">';
175 175
 
176
-            $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
176
+            $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911');
177 177
 
178
-            if ( empty( $version_info->download_link ) ) {
178
+            if (empty($version_info->download_link)) {
179 179
                 printf(
180 180
 					/* translators: 1: name 2: changelog URL 3: version */
181
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'give' ),
182
-                    esc_html( $version_info->name ),
183
-                    esc_url( $changelog_link ),
184
-                    esc_html( $version_info->new_version )
181
+                    __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'give'),
182
+                    esc_html($version_info->name),
183
+                    esc_url($changelog_link),
184
+                    esc_html($version_info->new_version)
185 185
                 );
186 186
             } else {
187 187
                 printf(
188 188
 					/* translators: 1: name 2: changelog URL 3: version 4: update URL */
189
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'give' ),
190
-                    esc_html( $version_info->name ),
191
-                    esc_url( $changelog_link ),
192
-                    esc_html( $version_info->new_version ),
193
-                    esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
189
+                    __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'give'),
190
+                    esc_html($version_info->name),
191
+                    esc_url($changelog_link),
192
+                    esc_html($version_info->new_version),
193
+                    esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name))
194 194
                 );
195 195
             }
196 196
 
@@ -209,16 +209,16 @@  discard block
 block discarded – undo
209 209
      * @param object  $_args
210 210
      * @return object $_data
211 211
      */
212
-    function plugins_api_filter( $_data, $_action = '', $_args = null ) {
212
+    function plugins_api_filter($_data, $_action = '', $_args = null) {
213 213
 
214 214
 
215
-        if ( $_action != 'plugin_information' ) {
215
+        if ($_action != 'plugin_information') {
216 216
 
217 217
             return $_data;
218 218
 
219 219
         }
220 220
 
221
-        if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
221
+        if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) {
222 222
 
223 223
             return $_data;
224 224
 
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
             )
234 234
         );
235 235
 
236
-        $api_response = $this->api_request( 'plugin_information', $to_send );
236
+        $api_response = $this->api_request('plugin_information', $to_send);
237 237
 
238
-        if ( false !== $api_response ) {
238
+        if (false !== $api_response) {
239 239
             $_data = $api_response;
240 240
         }
241 241
 
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
      * @param string  $url
251 251
      * @return object $array
252 252
      */
253
-    function http_request_args( $args, $url ) {
253
+    function http_request_args($args, $url) {
254 254
         // If it is an https request and we are performing a package download, disable ssl verification
255
-        if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
255
+        if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) {
256 256
             $args['sslverify'] = false;
257 257
         }
258 258
         return $args;
@@ -269,40 +269,40 @@  discard block
 block discarded – undo
269 269
      * @param array   $_data   Parameters for the API action.
270 270
      * @return false||object
271 271
      */
272
-    private function api_request( $_action, $_data ) {
272
+    private function api_request($_action, $_data) {
273 273
 
274 274
         global $wp_version;
275 275
 
276
-        $data = array_merge( $this->api_data, $_data );
276
+        $data = array_merge($this->api_data, $_data);
277 277
 
278
-        if ( $data['slug'] != $this->slug )
278
+        if ($data['slug'] != $this->slug)
279 279
             return;
280 280
 
281
-        if ( empty( $data['license'] ) )
281
+        if (empty($data['license']))
282 282
             return;
283 283
 
284
-        if( $this->api_url == home_url() ) {
284
+        if ($this->api_url == home_url()) {
285 285
             return false; // Don't allow a plugin to ping itself
286 286
         }
287 287
 
288 288
         $api_params = array(
289 289
             'edd_action' => 'get_version',
290 290
             'license'    => $data['license'],
291
-            'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
292
-            'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
291
+            'item_name'  => isset($data['item_name']) ? $data['item_name'] : false,
292
+            'item_id'    => isset($data['item_id']) ? $data['item_id'] : false,
293 293
             'slug'       => $data['slug'],
294 294
             'author'     => $data['author'],
295 295
             'url'        => home_url()
296 296
         );
297 297
 
298
-        $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
298
+        $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
299 299
 
300
-        if ( ! is_wp_error( $request ) ) {
301
-            $request = json_decode( wp_remote_retrieve_body( $request ) );
300
+        if ( ! is_wp_error($request)) {
301
+            $request = json_decode(wp_remote_retrieve_body($request));
302 302
         }
303 303
 
304
-        if ( $request && isset( $request->sections ) ) {
305
-            $request->sections = maybe_unserialize( $request->sections );
304
+        if ($request && isset($request->sections)) {
305
+            $request->sections = maybe_unserialize($request->sections);
306 306
         } else {
307 307
             $request = false;
308 308
         }
@@ -313,26 +313,26 @@  discard block
 block discarded – undo
313 313
     public function show_changelog() {
314 314
 
315 315
 
316
-        if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
316
+        if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) {
317 317
             return;
318 318
         }
319 319
 
320
-        if( empty( $_REQUEST['plugin'] ) ) {
320
+        if (empty($_REQUEST['plugin'])) {
321 321
             return;
322 322
         }
323 323
 
324
-        if( empty( $_REQUEST['slug'] ) ) {
324
+        if (empty($_REQUEST['slug'])) {
325 325
             return;
326 326
         }
327 327
 
328
-        if( ! current_user_can( 'update_plugins' ) ) {
329
-            wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
328
+        if ( ! current_user_can('update_plugins')) {
329
+            wp_die(esc_html__('You do not have permission to install plugin updates.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
330 330
         }
331 331
 
332
-        $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
332
+        $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug']));
333 333
 
334
-        if( $response && isset( $response->sections['changelog'] ) ) {
335
-            echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
334
+        if ($response && isset($response->sections['changelog'])) {
335
+            echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>';
336 336
         }
337 337
 
338 338
 
Please login to merge, or discard this patch.
includes/admin/forms/dashboard-columns.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -321,7 +321,7 @@
 block discarded – undo
321 321
  *
322 322
  * @param int $post_id Download (Post) ID
323 323
  *
324
- * @return void
324
+ * @return null|integer
325 325
  */
326 326
 function give_price_save_quick_edit( $post_id ) {
327 327
 	if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) {
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 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
 
@@ -27,34 +27,34 @@  discard block
 block discarded – undo
27 27
  * @return array $form_columns Updated array of forms columns
28 28
  *  Post Type List Table
29 29
  */
30
-function give_form_columns( $give_form_columns ) {
30
+function give_form_columns($give_form_columns) {
31 31
 
32 32
 	//Standard columns
33 33
 	$give_form_columns = array(
34 34
 		'cb'            => '<input type="checkbox"/>',
35
-		'title'         => esc_html__( 'Name', 'give' ),
36
-		'form_category' => esc_html__( 'Categories', 'give' ),
37
-		'form_tag'      => esc_html__( 'Tags', 'give' ),
38
-		'price'         => esc_html__( 'Price', 'give' ),
39
-		'goal'          => esc_html__( 'Goal', 'give' ),
40
-		'donations'     => esc_html__( 'Donations', 'give' ),
41
-		'earnings'      => esc_html__( 'Income', 'give' ),
42
-		'shortcode'     => esc_html__( 'Shortcode', 'give' ),
43
-		'date'          => esc_html__( 'Date', 'give' )
35
+		'title'         => esc_html__('Name', 'give'),
36
+		'form_category' => esc_html__('Categories', 'give'),
37
+		'form_tag'      => esc_html__('Tags', 'give'),
38
+		'price'         => esc_html__('Price', 'give'),
39
+		'goal'          => esc_html__('Goal', 'give'),
40
+		'donations'     => esc_html__('Donations', 'give'),
41
+		'earnings'      => esc_html__('Income', 'give'),
42
+		'shortcode'     => esc_html__('Shortcode', 'give'),
43
+		'date'          => esc_html__('Date', 'give')
44 44
 	);
45 45
 
46 46
 	//Does the user want categories / tags?
47
-	if ( give_get_option( 'enable_categories' ) !== 'on' ) {
48
-		unset( $give_form_columns['form_category'] );
47
+	if (give_get_option('enable_categories') !== 'on') {
48
+		unset($give_form_columns['form_category']);
49 49
 	}
50
-	if ( give_get_option( 'enable_tags' ) !== 'on' ) {
51
-		unset( $give_form_columns['form_tag'] );
50
+	if (give_get_option('enable_tags') !== 'on') {
51
+		unset($give_form_columns['form_tag']);
52 52
 	}
53 53
 
54
-	return apply_filters( 'give_forms_columns', $give_form_columns );
54
+	return apply_filters('give_forms_columns', $give_form_columns);
55 55
 }
56 56
 
57
-add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' );
57
+add_filter('manage_edit-give_forms_columns', 'give_form_columns');
58 58
 
59 59
 /**
60 60
  * Render Give Form Columns
@@ -66,60 +66,60 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return void
68 68
  */
69
-function give_render_form_columns( $column_name, $post_id ) {
70
-	if ( get_post_type( $post_id ) == 'give_forms' ) {
69
+function give_render_form_columns($column_name, $post_id) {
70
+	if (get_post_type($post_id) == 'give_forms') {
71 71
 		
72
-		switch ( $column_name ) {
72
+		switch ($column_name) {
73 73
 			case 'form_category':
74
-				echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' );
74
+				echo get_the_term_list($post_id, 'give_forms_category', '', ', ', '');
75 75
 				break;
76 76
 			case 'form_tag':
77
-				echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' );
77
+				echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', '');
78 78
 				break;
79 79
 			case 'price':
80
-				if ( give_has_variable_prices( $post_id ) ) {
81
-					echo give_price_range( $post_id );
80
+				if (give_has_variable_prices($post_id)) {
81
+					echo give_price_range($post_id);
82 82
 				} else {
83
-					echo give_price( $post_id, false );
84
-					echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />';
83
+					echo give_price($post_id, false);
84
+					echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />';
85 85
 				}
86 86
 				break;
87 87
 			case 'goal':
88
-				$goal_option = get_post_meta( $post_id, '_give_goal_option', true );
89
-				if ( ! empty( $goal_option ) && $goal_option === 'yes' ) {
90
-					echo give_goal( $post_id, false );
88
+				$goal_option = get_post_meta($post_id, '_give_goal_option', true);
89
+				if ( ! empty($goal_option) && $goal_option === 'yes') {
90
+					echo give_goal($post_id, false);
91 91
 				} else {
92
-					echo esc_html__( 'No Goal Set', 'give' );
92
+					echo esc_html__('No Goal Set', 'give');
93 93
 				}
94 94
 
95
-				echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />';
95
+				echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />';
96 96
 				break;
97 97
 			case 'donations':
98
-				if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
99
-					echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form=' . $post_id ) ) . '">';
100
-					echo give_get_form_sales_stats( $post_id );
98
+				if (current_user_can('view_give_form_stats', $post_id)) {
99
+					echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form='.$post_id)).'">';
100
+					echo give_get_form_sales_stats($post_id);
101 101
 					echo '</a>';
102 102
 				} else {
103 103
 					echo '-';
104 104
 				}
105 105
 				break;
106 106
 			case 'earnings':
107
-				if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
108
-					echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $post_id ) ) . '">';
109
-					echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ) ) );
107
+				if (current_user_can('view_give_form_stats', $post_id)) {
108
+					echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$post_id)).'">';
109
+					echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id)));
110 110
 					echo '</a>';
111 111
 				} else {
112 112
 					echo '-';
113 113
 				}
114 114
 				break;
115 115
 			case 'shortcode':
116
-				echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;' . absint( $post_id ) . '&#34;]">';
116
+				echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;'.absint($post_id).'&#34;]">';
117 117
 				break;
118 118
 		}
119 119
 	}
120 120
 }
121 121
 
122
-add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 );
122
+add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2);
123 123
 
124 124
 /**
125 125
  * Registers the sortable columns in the list table
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
  *
131 131
  * @return array $columns Array of sortable columns
132 132
  */
133
-function give_sortable_form_columns( $columns ) {
133
+function give_sortable_form_columns($columns) {
134 134
 	$columns['price']    = 'price';
135 135
 	$columns['sales']    = 'sales';
136 136
 	$columns['earnings'] = 'earnings';
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	return $columns;
140 140
 }
141 141
 
142
-add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' );
142
+add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns');
143 143
 
144 144
 /**
145 145
  * Sorts Columns in the Forms List Table
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
  *
151 151
  * @return array $vars Array of all the sort variables
152 152
  */
153
-function give_sort_forms( $vars ) {
153
+function give_sort_forms($vars) {
154 154
 	// Check if we're viewing the "give_forms" post type
155
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
155
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
156 156
 		// Check if 'orderby' is set to "sales"
157
-		if ( isset( $vars['orderby'] ) && 'sales' == $vars['orderby'] ) {
157
+		if (isset($vars['orderby']) && 'sales' == $vars['orderby']) {
158 158
 			$vars = array_merge(
159 159
 				$vars,
160 160
 				array(
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		}
166 166
 
167 167
 		// Check if "orderby" is set to "earnings"
168
-		if ( isset( $vars['orderby'] ) && 'earnings' == $vars['orderby'] ) {
168
+		if (isset($vars['orderby']) && 'earnings' == $vars['orderby']) {
169 169
 			$vars = array_merge(
170 170
 				$vars,
171 171
 				array(
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		}
177 177
 
178 178
 		// Check if "orderby" is set to "price"
179
-		if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
179
+		if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
180 180
 			$vars = array_merge(
181 181
 				$vars,
182 182
 				array(
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		}
188 188
 
189 189
 		// Check if "orderby" is set to "goal"
190
-		if ( isset( $vars['orderby'] ) && 'goal' == $vars['orderby'] ) {
190
+		if (isset($vars['orderby']) && 'goal' == $vars['orderby']) {
191 191
 			$vars = array_merge(
192 192
 				$vars,
193 193
 				array(
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
  *
211 211
  * @return array       Array of all sort variables
212 212
  */
213
-function give_filter_forms( $vars ) {
214
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
213
+function give_filter_forms($vars) {
214
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
215 215
 
216 216
 		// If an author ID was passed, use it
217
-		if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) {
217
+		if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) {
218 218
 
219 219
 			$author_id = $_REQUEST['author'];
220
-			if ( (int) $author_id !== get_current_user_id() ) {
220
+			if ((int) $author_id !== get_current_user_id()) {
221 221
 				// Tried to view the products of another person, sorry
222
-				wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
222
+				wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
223 223
 			}
224 224
 			$vars = array_merge(
225 225
 				$vars,
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
  * @return void
245 245
  */
246 246
 function give_forms_load() {
247
-	add_filter( 'request', 'give_sort_forms' );
248
-	add_filter( 'request', 'give_filter_forms' );
247
+	add_filter('request', 'give_sort_forms');
248
+	add_filter('request', 'give_filter_forms');
249 249
 }
250 250
 
251
-add_action( 'load-edit.php', 'give_forms_load', 9999 );
251
+add_action('load-edit.php', 'give_forms_load', 9999);
252 252
 
253 253
 /**
254 254
  * Remove Forms Month Filter
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
  * @global      $typenow The post type we are viewing
263 263
  * @return array Empty array disables the dropdown
264 264
  */
265
-function give_remove_month_filter( $dates ) {
265
+function give_remove_month_filter($dates) {
266 266
 	global $typenow;
267 267
 
268
-	if ( $typenow == 'give_forms' ) {
268
+	if ($typenow == 'give_forms') {
269 269
 		$dates = array();
270 270
 	}
271 271
 
272 272
 	return $dates;
273 273
 }
274 274
 
275
-add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 );
275
+add_filter('months_dropdown_results', 'give_remove_month_filter', 99);
276 276
 
277 277
 /**
278 278
  * Adds price field to Quick Edit options
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
  *
285 285
  * @return void
286 286
  */
287
-function give_price_field_quick_edit( $column_name, $post_type ) {
288
-	if ( $column_name != 'price' || $post_type != 'give_forms' ) {
287
+function give_price_field_quick_edit($column_name, $post_type) {
288
+	if ($column_name != 'price' || $post_type != 'give_forms') {
289 289
 		return;
290 290
 	}
291 291
 	?>
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 			<h4><?php 
295 295
 				printf(
296 296
 					/* translators: %s: forms singular label */
297
-					esc_html__( '%s Configuration', 'give' ),
297
+					esc_html__('%s Configuration', 'give'),
298 298
 					give_get_forms_label_singular()
299 299
 				);
300 300
 			?></h4>
301 301
 			<label>
302
-				<span class="title"><?php esc_html_e( 'Price', 'give' ); ?></span>
302
+				<span class="title"><?php esc_html_e('Price', 'give'); ?></span>
303 303
 				<span class="input-text-wrap">
304 304
 					<input type="text" name="_give_regprice" class="text regprice" />
305 305
 				</span>
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 	<?php
311 311
 }
312 312
 
313
-add_action( 'quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2 );
314
-add_action( 'bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2 );
313
+add_action('quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2);
314
+add_action('bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2);
315 315
 
316 316
 /**
317 317
  * Updates price when saving post
@@ -322,23 +322,23 @@  discard block
 block discarded – undo
322 322
  *
323 323
  * @return void
324 324
  */
325
-function give_price_save_quick_edit( $post_id ) {
326
-	if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) {
325
+function give_price_save_quick_edit($post_id) {
326
+	if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) {
327 327
 		return;
328 328
 	}
329
-	if ( ! current_user_can( 'edit_post', $post_id ) ) {
329
+	if ( ! current_user_can('edit_post', $post_id)) {
330 330
 		return $post_id;
331 331
 	}
332
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
332
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
333 333
 		return $post_id;
334 334
 	}
335 335
 
336
-	if ( isset( $_REQUEST['_give_regprice'] ) ) {
337
-		update_post_meta( $post_id, '_give_set_price', strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) );
336
+	if (isset($_REQUEST['_give_regprice'])) {
337
+		update_post_meta($post_id, '_give_set_price', strip_tags(stripslashes($_REQUEST['_give_regprice'])));
338 338
 	}
339 339
 }
340 340
 
341
-add_action( 'save_post', 'give_price_save_quick_edit' );
341
+add_action('save_post', 'give_price_save_quick_edit');
342 342
 
343 343
 /**
344 344
  * Process bulk edit actions via AJAX
@@ -348,18 +348,18 @@  discard block
 block discarded – undo
348 348
  */
349 349
 function give_save_bulk_edit() {
350 350
 
351
-	$post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
351
+	$post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
352 352
 
353
-	if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
354
-		$price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0;
355
-		foreach ( $post_ids as $post_id ) {
353
+	if ( ! empty($post_ids) && is_array($post_ids)) {
354
+		$price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0;
355
+		foreach ($post_ids as $post_id) {
356 356
 
357
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
357
+			if ( ! current_user_can('edit_post', $post_id)) {
358 358
 				continue;
359 359
 			}
360 360
 
361
-			if ( ! empty( $price ) ) {
362
-				update_post_meta( $post_id, '_give_set_price', give_sanitize_amount( $price ) );
361
+			if ( ! empty($price)) {
362
+				update_post_meta($post_id, '_give_set_price', give_sanitize_amount($price));
363 363
 			}
364 364
 		}
365 365
 	}
@@ -367,4 +367,4 @@  discard block
 block discarded – undo
367 367
 	die();
368 368
 }
369 369
 
370
-add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' );
370
+add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit');
Please login to merge, or discard this patch.
includes/admin/reporting/class-api-requests-logs-list-table.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@
 block discarded – undo
157 157
 	 *
158 158
 	 * @access public
159 159
 	 * @since  1.0
160
-	 * @return mixed String if search is present, false otherwise
160
+	 * @return string|false String if search is present, false otherwise
161 161
 	 */
162 162
 	public function get_search() {
163 163
 		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
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
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51 51
 			'ajax'     => false                        // Does this table support ajax?
52
-		) );
52
+		));
53 53
 	}
54 54
 
55 55
 	/**
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return void
65 65
 	 */
66
-	public function search_box( $text, $input_id ) {
67
-		$input_id = $input_id . '-search-input';
66
+	public function search_box($text, $input_id) {
67
+		$input_id = $input_id.'-search-input';
68 68
 
69
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
70
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
69
+		if ( ! empty($_REQUEST['orderby'])) {
70
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
71 71
 		}
72
-		if ( ! empty( $_REQUEST['order'] ) ) {
73
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
72
+		if ( ! empty($_REQUEST['order'])) {
73
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
74 74
 		}
75 75
 		?>
76 76
 		<p class="search-box">
77 77
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
78 78
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
79
-			<?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
79
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?>
80 80
 		</p>
81 81
 	<?php
82 82
 	}
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function get_columns() {
92 92
 		$columns = array(
93
-			'ID'      => esc_html__( 'Log ID', 'give' ),
94
-			'details' => esc_html__( 'Request Details', 'give' ),
95
-			'ip'      => esc_html__( 'Request IP', 'give' ),
96
-			'date'    => esc_html__( 'Date', 'give' )
93
+			'ID'      => esc_html__('Log ID', 'give'),
94
+			'details' => esc_html__('Request Details', 'give'),
95
+			'ip'      => esc_html__('Request IP', 'give'),
96
+			'date'    => esc_html__('Date', 'give')
97 97
 		);
98 98
 
99 99
 		return $columns;
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return string Column Name
112 112
 	 */
113
-	public function column_default( $item, $column_name ) {
114
-		switch ( $column_name ) {
113
+	public function column_default($item, $column_name) {
114
+		switch ($column_name) {
115 115
 			default:
116
-				return $item[ $column_name ];
116
+				return $item[$column_name];
117 117
 		}
118 118
 	}
119 119
 
@@ -127,26 +127,26 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @return void
129 129
 	 */
130
-	public function column_details( $item ) {
130
+	public function column_details($item) {
131 131
 		?>
132
-		<a href="#TB_inline?width=640&amp;inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e( 'View Request', 'give' ); ?></a>
132
+		<a href="#TB_inline?width=640&amp;inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e('View Request', 'give'); ?></a>
133 133
 		<div id="log-details-<?php echo $item['ID']; ?>" style="display:none;">
134 134
 			<?php
135 135
 
136
-			$request = get_post_field( 'post_excerpt', $item['ID'] );
137
-			$error   = get_post_field( 'post_content', $item['ID'] );
138
-			echo '<p><strong>' . esc_html__( 'API Request:', 'give' ) . '</strong></p>';
139
-			echo '<div>' . $request . '</div>';
140
-			if ( ! empty( $error ) ) {
141
-				echo '<p><strong>' . esc_html__( 'Error', 'give' ) . '</strong></p>';
142
-				echo '<div>' . esc_html( $error ) . '</div>';
136
+			$request = get_post_field('post_excerpt', $item['ID']);
137
+			$error   = get_post_field('post_content', $item['ID']);
138
+			echo '<p><strong>'.esc_html__('API Request:', 'give').'</strong></p>';
139
+			echo '<div>'.$request.'</div>';
140
+			if ( ! empty($error)) {
141
+				echo '<p><strong>'.esc_html__('Error', 'give').'</strong></p>';
142
+				echo '<div>'.esc_html($error).'</div>';
143 143
 			}
144
-			echo '<p><strong>' . esc_html__( 'API User:', 'give' ) . '</strong></p>';
145
-			echo '<div>' . get_post_meta( $item['ID'], '_give_log_user', true ) . '</div>';
146
-			echo '<p><strong>' . esc_html__( 'API Key:', 'give' ) . '</strong></p>';
147
-			echo '<div>' . get_post_meta( $item['ID'], '_give_log_key', true ) . '</div>';
148
-			echo '<p><strong>' . esc_html__( 'Request Date:', 'give' ) . '</strong></p>';
149
-			echo '<div>' . get_post_field( 'post_date', $item['ID'] ) . '</div>';
144
+			echo '<p><strong>'.esc_html__('API User:', 'give').'</strong></p>';
145
+			echo '<div>'.get_post_meta($item['ID'], '_give_log_user', true).'</div>';
146
+			echo '<p><strong>'.esc_html__('API Key:', 'give').'</strong></p>';
147
+			echo '<div>'.get_post_meta($item['ID'], '_give_log_key', true).'</div>';
148
+			echo '<p><strong>'.esc_html__('Request Date:', 'give').'</strong></p>';
149
+			echo '<div>'.get_post_field('post_date', $item['ID']).'</div>';
150 150
 			?>
151 151
 		</div>
152 152
 	<?php
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @return mixed String if search is present, false otherwise
161 161
 	 */
162 162
 	public function get_search() {
163
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
163
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
164 164
 	}
165 165
 
166 166
 
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @param string $which
178 178
 	 */
179
-	protected function display_tablenav( $which ) {
180
-		if ( 'top' === $which ) {
181
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
179
+	protected function display_tablenav($which) {
180
+		if ('top' === $which) {
181
+			wp_nonce_field('bulk-'.$this->_args['plural']);
182 182
 		}
183 183
 		?>
184
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
184
+		<div class="tablenav <?php echo esc_attr($which); ?>">
185 185
 
186 186
 			<div class="alignleft actions bulkactions">
187
-				<?php $this->bulk_actions( $which ); ?>
187
+				<?php $this->bulk_actions($which); ?>
188 188
 			</div>
189 189
 			<?php
190
-			$this->extra_tablenav( $which );
191
-			$this->pagination( $which );
190
+			$this->extra_tablenav($which);
191
+			$this->pagination($which);
192 192
 			?>
193 193
 
194 194
 			<br class="clear"/>
@@ -210,31 +210,31 @@  discard block
 block discarded – undo
210 210
 
211 211
 		$search = $this->get_search();
212 212
 
213
-		if ( $search ) {
214
-			if ( filter_var( $search, FILTER_VALIDATE_IP ) ) {
213
+		if ($search) {
214
+			if (filter_var($search, FILTER_VALIDATE_IP)) {
215 215
 				// This is an IP address search
216 216
 				$key = '_give_log_request_ip';
217
-			} else if ( is_email( $search ) ) {
217
+			} else if (is_email($search)) {
218 218
 				// This is an email search
219
-				$userdata = get_user_by( 'email', $search );
219
+				$userdata = get_user_by('email', $search);
220 220
 
221
-				if ( $userdata ) {
221
+				if ($userdata) {
222 222
 					$search = $userdata->ID;
223 223
 				}
224 224
 
225 225
 				$key = '_give_log_user';
226
-			} elseif ( strlen( $search ) == 32 ) {
226
+			} elseif (strlen($search) == 32) {
227 227
 				// Look for an API key
228 228
 				$key = '_give_log_key';
229
-			} elseif ( stristr( $search, 'token:' ) ) {
229
+			} elseif (stristr($search, 'token:')) {
230 230
 				// Look for an API token
231
-				$search = str_ireplace( 'token:', '', $search );
231
+				$search = str_ireplace('token:', '', $search);
232 232
 				$key    = '_give_log_token';
233 233
 			} else {
234 234
 				// This is (probably) a user ID search
235
-				$userdata = get_userdata( $search );
235
+				$userdata = get_userdata($search);
236 236
 
237
-				if ( $userdata ) {
237
+				if ($userdata) {
238 238
 					$search = $userdata->ID;
239 239
 				}
240 240
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 * @return int Current page number
261 261
 	 */
262 262
 	public function get_paged() {
263
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
263
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
264 264
 	}
265 265
 
266 266
 	/**
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @since  1.0
271 271
 	 * @return void
272 272
 	 */
273
-	function bulk_actions( $which = '' ) {
273
+	function bulk_actions($which = '') {
274 274
 		give_log_views();
275 275
 	}
276 276
 
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
 			'meta_query' => $this->get_meta_query()
294 294
 		);
295 295
 
296
-		$logs = $give_logs->get_connected_logs( $log_query );
296
+		$logs = $give_logs->get_connected_logs($log_query);
297 297
 
298
-		if ( $logs ) {
299
-			foreach ( $logs as $log ) {
298
+		if ($logs) {
299
+			foreach ($logs as $log) {
300 300
 
301 301
 				$logs_data[] = array(
302 302
 					'ID'   => $log->ID,
303
-					'ip'   => get_post_meta( $log->ID, '_give_log_request_ip', true ),
303
+					'ip'   => get_post_meta($log->ID, '_give_log_request_ip', true),
304 304
 					'date' => $log->post_date
305 305
 				);
306 306
 			}
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 		$columns               = $this->get_columns();
329 329
 		$hidden                = array(); // No hidden columns
330 330
 		$sortable              = $this->get_sortable_columns();
331
-		$this->_column_headers = array( $columns, $hidden, $sortable );
331
+		$this->_column_headers = array($columns, $hidden, $sortable);
332 332
 		$this->items           = $this->get_logs();
333
-		$total_items           = $give_logs->get_log_count( 0, 'api_requests' );
333
+		$total_items           = $give_logs->get_log_count(0, 'api_requests');
334 334
 
335
-		$this->set_pagination_args( array(
335
+		$this->set_pagination_args(array(
336 336
 				'total_items' => $total_items,
337 337
 				'per_page'    => $this->per_page,
338
-				'total_pages' => ceil( $total_items / $this->per_page )
338
+				'total_pages' => ceil($total_items / $this->per_page)
339 339
 			)
340 340
 		);
341 341
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/class-sales-logs-list-table.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 	 *
144 144
 	 * @access public
145 145
 	 * @since  1.0
146
-	 * @return mixed string If search is present, false otherwise
146
+	 * @return string|false string If search is present, false otherwise
147 147
 	 */
148 148
 	public function get_search() {
149 149
 		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,8 +71,8 @@
 block discarded – undo
71 71
 
72 72
 			case 'user_id' :
73 73
 				return '<a href="' .
74
-				       admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) .
75
-				       '">' . $item['user_name'] . '</a>';
74
+					   admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) .
75
+					   '">' . $item['user_name'] . '</a>';
76 76
 
77 77
 			case 'amount' :
78 78
 				return give_currency_filter( give_format_amount( $item['amount'] ) );
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16 16
 // Load WP_List_Table if not loaded
17
-if ( ! class_exists( 'WP_List_Table' ) ) {
18
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17
+if ( ! class_exists('WP_List_Table')) {
18
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
19 19
 }
20 20
 
21 21
 /**
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 		global $status, $page;
45 45
 
46 46
 		// Set parent defaults
47
-		parent::__construct( array(
48
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
49
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
47
+		parent::__construct(array(
48
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
49
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
50 50
 			'ajax'     => false                        // Does this table support ajax?
51
-		) );
51
+		));
52 52
 
53
-		add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) );
53
+		add_action('give_log_view_actions', array($this, 'give_forms_filter'));
54 54
 	}
55 55
 
56 56
 	/**
@@ -64,37 +64,37 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
67
+	public function column_default($item, $column_name) {
68 68
 
69
-		$payment = give_get_payment_by( 'id', $item['payment_id'] );
69
+		$payment = give_get_payment_by('id', $item['payment_id']);
70 70
 
71
-		switch ( $column_name ) {
71
+		switch ($column_name) {
72 72
 			case 'form' :
73
-				return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . get_the_title( $item[ $column_name ] ) . '</a>';
73
+				return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.get_the_title($item[$column_name]).'</a>';
74 74
 
75 75
 			case 'user_id' :
76
-				return '<a href="' .
77
-				       admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) .
78
-				       '">' . $item['user_name'] . '</a>';
76
+				return '<a href="'.
77
+				       admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))).
78
+				       '">'.$item['user_name'].'</a>';
79 79
 
80 80
 			case 'amount' :
81
-				return give_currency_filter( give_format_amount( $item['amount'] ) );
81
+				return give_currency_filter(give_format_amount($item['amount']));
82 82
 
83 83
 			case 'status' :
84 84
 
85
-				$value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>';
85
+				$value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>';
86 86
 
87
-				if ( $payment->mode == 'test' ) {
88
-					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>';
87
+				if ($payment->mode == 'test') {
88
+					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>';
89 89
 				}
90 90
 
91 91
 				return $value;
92 92
 
93 93
 			case 'payment_id' :
94
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>';
94
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>';
95 95
 
96 96
 			default:
97
-				return $item[ $column_name ];
97
+				return $item[$column_name];
98 98
 		}
99 99
 	}
100 100
 
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function get_columns() {
109 109
 		$columns = array(
110
-			'ID'         => esc_html__( 'Log ID', 'give' ),
111
-			'user_id'    => esc_html__( 'Donor', 'give' ),
110
+			'ID'         => esc_html__('Log ID', 'give'),
111
+			'user_id'    => esc_html__('Donor', 'give'),
112 112
 			'form'       => give_get_forms_label_singular(),
113
-			'amount'     => esc_html__( 'Donation Amount', 'give' ),
114
-			'status'     => esc_html__( 'Status', 'give' ),
115
-			'payment_id' => esc_html__( 'Transaction ID', 'give' ),
116
-			'date'       => esc_html__( 'Date', 'give' )
113
+			'amount'     => esc_html__('Donation Amount', 'give'),
114
+			'status'     => esc_html__('Status', 'give'),
115
+			'payment_id' => esc_html__('Transaction ID', 'give'),
116
+			'date'       => esc_html__('Date', 'give')
117 117
 		);
118 118
 
119 119
 		return $columns;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @return int Current page number
128 128
 	 */
129 129
 	public function get_paged() {
130
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
130
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
131 131
 	}
132 132
 
133 133
 	/**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @return mixed int If User ID, string If Email/Login
139 139
 	 */
140 140
 	public function get_filtered_user() {
141
-		return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false;
141
+		return isset($_GET['user']) ? absint($_GET['user']) : false;
142 142
 	}
143 143
 
144 144
 	/**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @return int Download ID
150 150
 	 */
151 151
 	public function get_filtered_give_form() {
152
-		return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false;
152
+		return ! empty($_GET['form']) ? absint($_GET['form']) : false;
153 153
 	}
154 154
 
155 155
 	/**
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @return mixed string If search is present, false otherwise
161 161
 	 */
162 162
 	public function get_search() {
163
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
163
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
164 164
 	}
165 165
 
166 166
 
@@ -176,20 +176,20 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @param string $which
178 178
 	 */
179
-	protected function display_tablenav( $which ) {
179
+	protected function display_tablenav($which) {
180 180
 
181
-		if ( 'top' === $which ) {
182
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
181
+		if ('top' === $which) {
182
+			wp_nonce_field('bulk-'.$this->_args['plural']);
183 183
 		}
184 184
 		?>
185
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
185
+		<div class="tablenav <?php echo esc_attr($which); ?>">
186 186
 
187 187
 			<div class="alignleft actions bulkactions">
188
-				<?php $this->bulk_actions( $which ); ?>
188
+				<?php $this->bulk_actions($which); ?>
189 189
 			</div>
190 190
 			<?php
191
-			$this->extra_tablenav( $which );
192
-			$this->pagination( $which );
191
+			$this->extra_tablenav($which);
192
+			$this->pagination($which);
193 193
 			?>
194 194
 
195 195
 			<br class="clear"/>
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
 		$meta_query = array();
214 214
 
215
-		if ( $user ) {
215
+		if ($user) {
216 216
 			// Show only logs from a specific user
217 217
 			$meta_query[] = array(
218 218
 				'key'   => '_give_log_user_id',
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 		}
222 222
 
223 223
 		$search = $this->get_search();
224
-		if ( $search ) {
225
-			if ( is_email( $search ) ) {
224
+		if ($search) {
225
+			if (is_email($search)) {
226 226
 				// This is an email search. We use this to ensure it works for guest users and logged-in users
227 227
 				$key     = '_give_log_user_info';
228 228
 				$compare = 'LIKE';
@@ -231,32 +231,32 @@  discard block
 block discarded – undo
231 231
 				$key     = '_give_log_user_id';
232 232
 				$compare = 'LIKE';
233 233
 
234
-				if ( ! is_numeric( $search ) ) {
234
+				if ( ! is_numeric($search)) {
235 235
 					// Searching for user by username
236
-					$user = get_user_by( 'login', $search );
236
+					$user = get_user_by('login', $search);
237 237
 
238
-					if ( $user ) {
238
+					if ($user) {
239 239
 						// Found one, set meta value to user's ID
240 240
 						$search = $user->ID;
241 241
 					} else {
242 242
 						// No user found so let's do a real search query
243
-						$users = new WP_User_Query( array(
243
+						$users = new WP_User_Query(array(
244 244
 							'search'         => $search,
245
-							'search_columns' => array( 'user_url', 'user_nicename' ),
245
+							'search_columns' => array('user_url', 'user_nicename'),
246 246
 							'number'         => 1,
247 247
 							'fields'         => 'ids'
248
-						) );
248
+						));
249 249
 
250 250
 						$found_user = $users->get_results();
251 251
 
252
-						if ( $found_user ) {
252
+						if ($found_user) {
253 253
 							$search = $found_user[0];
254 254
 						}
255 255
 					}
256 256
 				}
257 257
 			}
258 258
 
259
-			if ( ! $this->file_search ) {
259
+			if ( ! $this->file_search) {
260 260
 				// Meta query only works for non file name searche
261 261
 				$meta_query[] = array(
262 262
 					'key'     => $key,
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 * @since  1.0
278 278
 	 * @return void
279 279
 	 */
280
-	function bulk_actions( $which = '' ) {
280
+	function bulk_actions($which = '') {
281 281
 		give_log_views();
282 282
 	}
283 283
 
@@ -289,22 +289,22 @@  discard block
 block discarded – undo
289 289
 	 * @return void
290 290
 	 */
291 291
 	public function give_forms_filter() {
292
-		$give_forms = get_posts( array(
292
+		$give_forms = get_posts(array(
293 293
 			'post_type'              => 'give_forms',
294 294
 			'post_status'            => 'any',
295
-			'posts_per_page'         => - 1,
295
+			'posts_per_page'         => -1,
296 296
 			'orderby'                => 'title',
297 297
 			'order'                  => 'ASC',
298 298
 			'fields'                 => 'ids',
299 299
 			'update_post_meta_cache' => false,
300 300
 			'update_post_term_cache' => false
301
-		) );
301
+		));
302 302
 
303
-		if ( $give_forms ) {
303
+		if ($give_forms) {
304 304
 			echo '<select name="form" id="give-log-form-filter">';
305
-			echo '<option value="0">' . esc_html__( 'All', 'give' ) . '</option>';
306
-			foreach ( $give_forms as $form ) {
307
-				echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( get_the_title( $form ) ) . '</option>';
305
+			echo '<option value="0">'.esc_html__('All', 'give').'</option>';
306
+			foreach ($give_forms as $form) {
307
+				echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html(get_the_title($form)).'</option>';
308 308
 			}
309 309
 			echo '</select>';
310 310
 		}
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
 		global $give_logs;
323 323
 
324 324
 		// Prevent the queries from getting cached. Without this there are occasional memory issues for some installs
325
-		wp_suspend_cache_addition( true );
325
+		wp_suspend_cache_addition(true);
326 326
 
327 327
 		$logs_data = array();
328 328
 		$paged     = $this->get_paged();
329
-		$give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null;
329
+		$give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null;
330 330
 		$user      = $this->get_filtered_user();
331 331
 
332 332
 		$log_query = array(
@@ -336,26 +336,26 @@  discard block
 block discarded – undo
336 336
 			'meta_query'  => $this->get_meta_query()
337 337
 		);
338 338
 
339
-		$logs = $give_logs->get_connected_logs( $log_query );
339
+		$logs = $give_logs->get_connected_logs($log_query);
340 340
 
341
-		if ( $logs ) {
342
-			foreach ( $logs as $log ) {
343
-				$payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true );
341
+		if ($logs) {
342
+			foreach ($logs as $log) {
343
+				$payment_id = get_post_meta($log->ID, '_give_log_payment_id', true);
344 344
 
345 345
 				// Make sure this payment hasn't been deleted
346
-				if ( get_post( $payment_id ) ) :
347
-					$user_info      = give_get_payment_meta_user_info( $payment_id );
348
-					$payment_meta   = give_get_payment_meta( $payment_id );
349
-					$payment_amount = give_get_payment_amount( $payment_id );
346
+				if (get_post($payment_id)) :
347
+					$user_info      = give_get_payment_meta_user_info($payment_id);
348
+					$payment_meta   = give_get_payment_meta($payment_id);
349
+					$payment_amount = give_get_payment_amount($payment_id);
350 350
 
351 351
 					$logs_data[] = array(
352
-						'ID'         => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>',
352
+						'ID'         => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>',
353 353
 						'payment_id' => $payment_id,
354 354
 						'form'       => $log->post_parent,
355 355
 						'amount'     => $payment_amount,
356 356
 						'user_id'    => $user_info['id'],
357
-						'user_name'  => $user_info['first_name'] . ' ' . $user_info['last_name'],
358
-						'date'       => get_post_field( 'post_date', $payment_id )
357
+						'user_name'  => $user_info['first_name'].' '.$user_info['last_name'],
358
+						'date'       => get_post_field('post_date', $payment_id)
359 359
 					);
360 360
 
361 361
 				endif;
@@ -384,15 +384,15 @@  discard block
 block discarded – undo
384 384
 		$columns               = $this->get_columns();
385 385
 		$hidden                = array();
386 386
 		$sortable              = $this->get_sortable_columns();
387
-		$this->_column_headers = array( $columns, $hidden, $sortable );
387
+		$this->_column_headers = array($columns, $hidden, $sortable);
388 388
 		$current_page          = $this->get_pagenum();
389 389
 		$this->items           = $this->get_logs();
390
-		$total_items           = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() );
390
+		$total_items           = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query());
391 391
 
392
-		$this->set_pagination_args( array(
392
+		$this->set_pagination_args(array(
393 393
 				'total_items' => $total_items,
394 394
 				'per_page'    => $this->per_page,
395
-				'total_pages' => ceil( $total_items / $this->per_page )
395
+				'total_pages' => ceil($total_items / $this->per_page)
396 396
 			)
397 397
 		);
398 398
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/graphing.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -576,7 +576,7 @@
 block discarded – undo
576 576
  * selected date-range (if any)
577 577
  *
578 578
  * @since 1.0
579
- * @return array
579
+ * @return integer|null
580 580
  */
581 581
 function give_get_report_dates() {
582 582
 	$dates = array();
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -143,9 +143,11 @@  discard block
 block discarded – undo
143 143
 
144 144
 					endwhile;
145 145
 
146
-				else :
146
+				else {
147
+					:
147 148
 
148 149
 					$sales = give_get_sales_by_date( null, $i, $y );
150
+				}
149 151
 					$sales_totals += $sales;
150 152
 
151 153
 					$earnings = give_get_earnings_by_date( null, $i, $y );
@@ -393,9 +395,11 @@  discard block
 block discarded – undo
393 395
 
394 396
 					endwhile;
395 397
 
396
-				else :
398
+				else {
399
+					:
397 400
 
398 401
 					$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
402
+				}
399 403
 
400 404
 					$date     = mktime( 0, 0, 0, $i, 1, $y );
401 405
 					$end_date = mktime( 23, 59, 59, $i, $num_of_days, $y );
Please login to merge, or discard this patch.
Spacing   +243 added lines, -243 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,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	$dates = give_get_report_dates();
26 26
 
27 27
 	// Determine graph options
28
-	switch ( $dates['range'] ) :
28
+	switch ($dates['range']) :
29 29
 		case 'today' :
30 30
 		case 'yesterday' :
31 31
 			$day_by_day = true;
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			$day_by_day = false;
38 38
 			break;
39 39
 		case 'other' :
40
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) {
40
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) {
41 41
 				$day_by_day = false;
42 42
 			} else {
43 43
 				$day_by_day = true;
@@ -49,61 +49,61 @@  discard block
 block discarded – undo
49 49
 	endswitch;
50 50
 
51 51
 	$earnings_totals = 0.00; // Total earnings for time period shown
52
-	$sales_totals    = 0;            // Total sales for time period shown
52
+	$sales_totals    = 0; // Total sales for time period shown
53 53
 
54 54
 	$earnings_data = array();
55 55
 	$sales_data    = array();
56 56
 
57
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
57
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
58 58
 		// Hour by hour
59 59
 		$hour  = 1;
60
-		$month = date( 'n', current_time( 'timestamp' ) );
61
-		while ( $hour <= 23 ) :
60
+		$month = date('n', current_time('timestamp'));
61
+		while ($hour <= 23) :
62 62
 
63
-			$sales    = give_get_sales_by_date( $dates['day'], $month, $dates['year'], $hour );
64
-			$earnings = give_get_earnings_by_date( $dates['day'], $month, $dates['year'], $hour );
63
+			$sales    = give_get_sales_by_date($dates['day'], $month, $dates['year'], $hour);
64
+			$earnings = give_get_earnings_by_date($dates['day'], $month, $dates['year'], $hour);
65 65
 
66 66
 			$sales_totals += $sales;
67 67
 			$earnings_totals += $earnings;
68 68
 
69
-			$date            = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ) * 1000;
70
-			$sales_data[]    = array( $date, $sales );
71
-			$earnings_data[] = array( $date, $earnings );
69
+			$date            = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']) * 1000;
70
+			$sales_data[]    = array($date, $sales);
71
+			$earnings_data[] = array($date, $earnings);
72 72
 
73
-			$hour ++;
73
+			$hour++;
74 74
 		endwhile;
75 75
 
76
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
76
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
77 77
 
78 78
 		// Day by day
79 79
 		$day     = $dates['day'];
80 80
 		$day_end = $dates['day_end'];
81 81
 		$month   = $dates['m_start'];
82
-		while ( $day <= $day_end ) :
83
-			$sales = give_get_sales_by_date( $day, $month, $dates['year'] );
82
+		while ($day <= $day_end) :
83
+			$sales = give_get_sales_by_date($day, $month, $dates['year']);
84 84
 			$sales_totals += $sales;
85 85
 
86
-			$earnings = give_get_earnings_by_date( $day, $month, $dates['year'] );
86
+			$earnings = give_get_earnings_by_date($day, $month, $dates['year']);
87 87
 			$earnings_totals += $earnings;
88 88
 
89
-			$date            = mktime( 0, 0, 0, $month, $day, $dates['year'] ) * 1000;
90
-			$sales_data[]    = array( $date, $sales );
91
-			$earnings_data[] = array( $date, $earnings );
92
-			$day ++;
89
+			$date            = mktime(0, 0, 0, $month, $day, $dates['year']) * 1000;
90
+			$sales_data[]    = array($date, $sales);
91
+			$earnings_data[] = array($date, $earnings);
92
+			$day++;
93 93
 		endwhile;
94 94
 
95 95
 	} else {
96 96
 
97 97
 		$y = $dates['year'];
98
-		while ( $y <= $dates['year_end'] ) :
98
+		while ($y <= $dates['year_end']) :
99 99
 
100
-			if ( $dates['year'] == $dates['year_end'] ) {
100
+			if ($dates['year'] == $dates['year_end']) {
101 101
 				$month_start = $dates['m_start'];
102 102
 				$month_end   = $dates['m_end'];
103
-			} elseif ( $y == $dates['year'] ) {
103
+			} elseif ($y == $dates['year']) {
104 104
 				$month_start = $dates['m_start'];
105 105
 				$month_end   = 12;
106
-			} elseif ( $y == $dates['year_end'] ) {
106
+			} elseif ($y == $dates['year_end']) {
107 107
 				$month_start = 1;
108 108
 				$month_end   = $dates['m_end'];
109 109
 			} else {
@@ -112,48 +112,48 @@  discard block
 block discarded – undo
112 112
 			}
113 113
 
114 114
 			$i = $month_start;
115
-			while ( $i <= $month_end ) :
115
+			while ($i <= $month_end) :
116 116
 
117
-				if ( $day_by_day ) :
117
+				if ($day_by_day) :
118 118
 
119
-					if ( $i == $month_end ) {
119
+					if ($i == $month_end) {
120 120
 
121 121
 						$num_of_days = $dates['day_end'];
122 122
 
123 123
 					} else {
124 124
 
125
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
125
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
126 126
 
127 127
 					}
128 128
 
129 129
 					$d = $dates['day'];
130 130
 
131
-					while ( $d <= $num_of_days ) :
131
+					while ($d <= $num_of_days) :
132 132
 
133
-						$sales = give_get_sales_by_date( $d, $i, $y );
133
+						$sales = give_get_sales_by_date($d, $i, $y);
134 134
 						$sales_totals += $sales;
135 135
 
136
-						$earnings = give_get_earnings_by_date( $d, $i, $y );
136
+						$earnings = give_get_earnings_by_date($d, $i, $y);
137 137
 						$earnings_totals += $earnings;
138 138
 
139
-						$date            = mktime( 0, 0, 0, $i, $d, $y ) * 1000;
140
-						$sales_data[]    = array( $date, $sales );
141
-						$earnings_data[] = array( $date, $earnings );
142
-						$d ++;
139
+						$date            = mktime(0, 0, 0, $i, $d, $y) * 1000;
140
+						$sales_data[]    = array($date, $sales);
141
+						$earnings_data[] = array($date, $earnings);
142
+						$d++;
143 143
 
144 144
 					endwhile;
145 145
 
146 146
 				else :
147 147
 
148
-					$sales = give_get_sales_by_date( null, $i, $y );
148
+					$sales = give_get_sales_by_date(null, $i, $y);
149 149
 					$sales_totals += $sales;
150 150
 
151
-					$earnings = give_get_earnings_by_date( null, $i, $y );
151
+					$earnings = give_get_earnings_by_date(null, $i, $y);
152 152
 					$earnings_totals += $earnings;
153 153
 
154
-					if ( $i == $month_end ) {
154
+					if ($i == $month_end) {
155 155
 
156
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
156
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
157 157
 
158 158
 					} else {
159 159
 
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
 
162 162
 					}
163 163
 
164
-					$date            = mktime( 0, 0, 0, $i, $num_of_days, $y ) * 1000;
165
-					$sales_data[]    = array( $date, $sales );
166
-					$earnings_data[] = array( $date, $earnings );
164
+					$date            = mktime(0, 0, 0, $i, $num_of_days, $y) * 1000;
165
+					$sales_data[]    = array($date, $sales);
166
+					$earnings_data[] = array($date, $earnings);
167 167
 
168 168
 				endif;
169 169
 
170
-				$i ++;
170
+				$i++;
171 171
 
172 172
 			endwhile;
173 173
 
174
-			$y ++;
174
+			$y++;
175 175
 		endwhile;
176 176
 
177 177
 	}
178 178
 
179 179
 	$data = array(
180
-		esc_html__( 'Income', 'give' )    => $earnings_data,
181
-		esc_html__( 'Donations', 'give' ) => $sales_data
180
+		esc_html__('Income', 'give')    => $earnings_data,
181
+		esc_html__('Donations', 'give') => $sales_data
182 182
 	);
183 183
 
184 184
 	// start our own output buffer
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 			<div class="postbox">
191 191
 				<div class="inside">
192 192
 					<?php
193
-					$graph = new Give_Graph( $data );
194
-					$graph->set( 'x_mode', 'time' );
195
-					$graph->set( 'multiple_y_axes', true );
193
+					$graph = new Give_Graph($data);
194
+					$graph->set('x_mode', 'time');
195
+					$graph->set('multiple_y_axes', true);
196 196
 					$graph->display();
197 197
 
198
-					if ( 'this_month' == $dates['range'] ) {
198
+					if ('this_month' == $dates['range']) {
199 199
 						$estimated = give_estimated_monthly_stats();
200 200
 					}
201 201
 					?>
@@ -205,21 +205,21 @@  discard block
 block discarded – undo
205 205
 			<table class="widefat reports-table alignleft" style="max-width:450px">
206 206
 				<tbody>
207 207
 				<tr>
208
-					<th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th>
209
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td>
208
+					<th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th>
209
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td>
210 210
 				</tr>
211 211
 				<tr class="alternate">
212
-					<th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?><strong></th>
212
+					<th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?><strong></th>
213 213
 					<td><?php echo $sales_totals; ?></td>
214 214
 				</tr>
215
-				<?php if ( 'this_month' == $dates['range'] ) : ?>
215
+				<?php if ('this_month' == $dates['range']) : ?>
216 216
 					<tr>
217
-						<th scope="row"><strong><?php esc_html_e( 'Estimated monthly income:', 'give' ); ?></strong></th>
218
-						<td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'] ) ); ?></td>
217
+						<th scope="row"><strong><?php esc_html_e('Estimated monthly income:', 'give'); ?></strong></th>
218
+						<td><?php echo give_currency_filter(give_format_amount($estimated['earnings'])); ?></td>
219 219
 					</tr>
220 220
 					<tr class="alternate">
221
-						<th scope="row"><strong><?php esc_html_e( 'Estimated monthly donations:', 'give' ); ?></strong></th>
222
-						<td><?php echo floor( $estimated['sales'] ); ?></td>
221
+						<th scope="row"><strong><?php esc_html_e('Estimated monthly donations:', 'give'); ?></strong></th>
222
+						<td><?php echo floor($estimated['sales']); ?></td>
223 223
 					</tr>
224 224
 				<?php endif; ?>
225 225
 			</table>
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			 *
233 233
 			 * @since 1.0
234 234
 			 */
235
-			do_action( 'give_reports_graph_additional_stats' );
235
+			do_action('give_reports_graph_additional_stats');
236 236
 			?>
237 237
 
238 238
 		</div>
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
  * @since 1.0
252 252
  * @return void
253 253
  */
254
-function give_reports_graph_of_form( $form_id = 0 ) {
254
+function give_reports_graph_of_form($form_id = 0) {
255 255
 	// Retrieve the queried dates
256 256
 	$dates = give_get_report_dates();
257 257
 
258 258
 	// Determine graph options
259
-	switch ( $dates['range'] ) :
259
+	switch ($dates['range']) :
260 260
 		case 'today' :
261 261
 		case 'yesterday' :
262 262
 			$day_by_day = true;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 			$day_by_day = false;
275 275
 			break;
276 276
 		case 'other' :
277
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) {
277
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) {
278 278
 				$day_by_day = false;
279 279
 			} else {
280 280
 				$day_by_day = true;
@@ -286,75 +286,75 @@  discard block
 block discarded – undo
286 286
 	endswitch;
287 287
 
288 288
 	$earnings_totals = (float) 0.00; // Total earnings for time period shown
289
-	$sales_totals    = 0;            // Total sales for time period shown
289
+	$sales_totals    = 0; // Total sales for time period shown
290 290
 
291 291
 	$earnings_data = array();
292 292
 	$sales_data    = array();
293 293
 	$stats         = new Give_Payment_Stats;
294 294
 
295
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
295
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
296 296
 
297 297
 		// Hour by hour
298 298
 		$month  = $dates['m_start'];
299 299
 		$hour   = 1;
300 300
 		$minute = 0;
301 301
 		$second = 0;
302
-		while ( $hour <= 23 ) :
302
+		while ($hour <= 23) :
303 303
 
304
-			if ( $hour == 23 ) {
304
+			if ($hour == 23) {
305 305
 				$minute = $second = 59;
306 306
 			}
307 307
 
308
-			$date     = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] );
309
-			$date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] );
308
+			$date     = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']);
309
+			$date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']);
310 310
 
311
-			$sales = $stats->get_sales( $form_id, $date, $date_end );
311
+			$sales = $stats->get_sales($form_id, $date, $date_end);
312 312
 			$sales_totals += $sales;
313 313
 
314
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
314
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
315 315
 			$earnings_totals += $earnings;
316 316
 
317
-			$sales_data[]    = array( $date * 1000, $sales );
318
-			$earnings_data[] = array( $date * 1000, $earnings );
317
+			$sales_data[]    = array($date * 1000, $sales);
318
+			$earnings_data[] = array($date * 1000, $earnings);
319 319
 
320
-			$hour ++;
320
+			$hour++;
321 321
 		endwhile;
322 322
 
323
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
323
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
324 324
 
325 325
 		//Day by day
326 326
 		$day     = $dates['day'];
327 327
 		$day_end = $dates['day_end'];
328 328
 		$month   = $dates['m_start'];
329
-		while ( $day <= $day_end ) :
329
+		while ($day <= $day_end) :
330 330
 
331
-			$date     = mktime( 0, 0, 0, $month, $day, $dates['year'] );
332
-			$date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] );
333
-			$sales    = $stats->get_sales( $form_id, $date, $date_end );
331
+			$date     = mktime(0, 0, 0, $month, $day, $dates['year']);
332
+			$date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']);
333
+			$sales    = $stats->get_sales($form_id, $date, $date_end);
334 334
 			$sales_totals += $sales;
335 335
 
336
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
336
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
337 337
 			$earnings_totals += $earnings;
338 338
 
339
-			$sales_data[]    = array( $date * 1000, $sales );
340
-			$earnings_data[] = array( $date * 1000, $earnings );
339
+			$sales_data[]    = array($date * 1000, $sales);
340
+			$earnings_data[] = array($date * 1000, $earnings);
341 341
 
342
-			$day ++;
342
+			$day++;
343 343
 		endwhile;
344 344
 
345 345
 	} else {
346 346
 
347 347
 		$y = $dates['year'];
348 348
 
349
-		while ( $y <= $dates['year_end'] ) :
349
+		while ($y <= $dates['year_end']) :
350 350
 
351 351
 			$last_year = false;
352 352
 
353
-			if ( $dates['year'] == $dates['year_end'] ) {
353
+			if ($dates['year'] == $dates['year_end']) {
354 354
 				$month_start = $dates['m_start'];
355 355
 				$month_end   = $dates['m_end'];
356 356
 				$last_year   = true;
357
-			} elseif ( $y == $dates['year'] ) {
357
+			} elseif ($y == $dates['year']) {
358 358
 				$month_start = $dates['m_start'];
359 359
 				$month_end   = 12;
360 360
 			} else {
@@ -363,75 +363,75 @@  discard block
 block discarded – undo
363 363
 			}
364 364
 
365 365
 			$i = $month_start;
366
-			while ( $i <= $month_end ) :
366
+			while ($i <= $month_end) :
367 367
 
368
-				if ( $day_by_day ) :
368
+				if ($day_by_day) :
369 369
 
370
-					if ( $i == $month_end && $last_year ) {
370
+					if ($i == $month_end && $last_year) {
371 371
 
372 372
 						$num_of_days = $dates['day_end'];
373 373
 
374 374
 					} else {
375 375
 
376
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
376
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
377 377
 
378 378
 					}
379 379
 
380 380
 					$d = $dates['day'];
381
-					while ( $d <= $num_of_days ) :
381
+					while ($d <= $num_of_days) :
382 382
 
383
-						$date     = mktime( 0, 0, 0, $i, $d, $y );
384
-						$end_date = mktime( 23, 59, 59, $i, $d, $y );
383
+						$date     = mktime(0, 0, 0, $i, $d, $y);
384
+						$end_date = mktime(23, 59, 59, $i, $d, $y);
385 385
 
386
-						$sales = $stats->get_sales( $form_id, $date, $end_date );
386
+						$sales = $stats->get_sales($form_id, $date, $end_date);
387 387
 						$sales_totals += $sales;
388 388
 
389
-						$earnings = $stats->get_earnings( $form_id, $date, $end_date );
389
+						$earnings = $stats->get_earnings($form_id, $date, $end_date);
390 390
 						$earnings_totals += $earnings;
391 391
 
392
-						$sales_data[]    = array( $date * 1000, $sales );
393
-						$earnings_data[] = array( $date * 1000, $earnings );
394
-						$d ++;
392
+						$sales_data[]    = array($date * 1000, $sales);
393
+						$earnings_data[] = array($date * 1000, $earnings);
394
+						$d++;
395 395
 
396 396
 					endwhile;
397 397
 
398 398
 				else :
399 399
 
400
-					$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
400
+					$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
401 401
 
402
-					$date     = mktime( 0, 0, 0, $i, 1, $y );
403
-					$end_date = mktime( 23, 59, 59, $i, $num_of_days, $y );
402
+					$date     = mktime(0, 0, 0, $i, 1, $y);
403
+					$end_date = mktime(23, 59, 59, $i, $num_of_days, $y);
404 404
 
405
-					$sales = $stats->get_sales( $form_id, $date, $end_date );
405
+					$sales = $stats->get_sales($form_id, $date, $end_date);
406 406
 					$sales_totals += $sales;
407 407
 
408
-					$earnings = $stats->get_earnings( $form_id, $date, $end_date );
408
+					$earnings = $stats->get_earnings($form_id, $date, $end_date);
409 409
 					$earnings_totals += $earnings;
410 410
 
411
-					$sales_data[]    = array( $date * 1000, $sales );
412
-					$earnings_data[] = array( $date * 1000, $earnings );
411
+					$sales_data[]    = array($date * 1000, $sales);
412
+					$earnings_data[] = array($date * 1000, $earnings);
413 413
 				endif;
414 414
 
415
-				$i ++;
415
+				$i++;
416 416
 
417 417
 			endwhile;
418 418
 
419
-			$y ++;
419
+			$y++;
420 420
 		endwhile;
421 421
 
422 422
 	}
423 423
 
424 424
 	$data = array(
425
-		esc_html__( 'Income', 'give' )    => $earnings_data,
426
-		esc_html__( 'Donations', 'give' ) => $sales_data
425
+		esc_html__('Income', 'give')    => $earnings_data,
426
+		esc_html__('Donations', 'give') => $sales_data
427 427
 	);
428 428
 
429 429
 	?>
430 430
 	<h3><span><?php
431 431
 		printf(
432 432
 			/* translators: %s: form title */
433
-			esc_html__( 'Income Over Time for %s', 'give' ),
434
-			get_the_title( $form_id )
433
+			esc_html__('Income Over Time for %s', 'give'),
434
+			get_the_title($form_id)
435 435
 		);
436 436
 	?></span></h3>
437 437
 
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
 		<div class="postbox">
440 440
 			<div class="inside">
441 441
 				<?php
442
-				$graph = new Give_Graph( $data );
443
-				$graph->set( 'x_mode', 'time' );
444
-				$graph->set( 'multiple_y_axes', true );
442
+				$graph = new Give_Graph($data);
443
+				$graph->set('x_mode', 'time');
444
+				$graph->set('multiple_y_axes', true);
445 445
 				$graph->display();
446 446
 				?>
447 447
 			</div>
@@ -450,20 +450,20 @@  discard block
 block discarded – undo
450 450
 		<table class="widefat reports-table alignleft" style="max-width:450px">
451 451
 			<tbody>
452 452
 			<tr>
453
-				<th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th>
454
-				<td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td>
453
+				<th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th>
454
+				<td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td>
455 455
 			</tr>
456 456
 			<tr class="alternate">
457
-				<th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?></strong></th>
457
+				<th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?></strong></th>
458 458
 				<td><?php echo $sales_totals; ?></td>
459 459
 			</tr>
460 460
 			<tr>
461
-				<th scope="row"><strong><?php esc_html_e( 'Average monthly income:', 'give' ); ?></strong></th>
462
-				<td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ) ) ); ?></td>
461
+				<th scope="row"><strong><?php esc_html_e('Average monthly income:', 'give'); ?></strong></th>
462
+				<td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id))); ?></td>
463 463
 			</tr>
464 464
 			<tr class="alternate">
465
-				<th scope="row"><strong><?php esc_html_e( 'Average monthly donations:', 'give' ); ?></strong></th>
466
-				<td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td>
465
+				<th scope="row"><strong><?php esc_html_e('Average monthly donations:', 'give'); ?></strong></th>
466
+				<td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td>
467 467
 			</tr>
468 468
 			</tbody>
469 469
 		</table>
@@ -480,26 +480,26 @@  discard block
 block discarded – undo
480 480
  * @return void
481 481
  */
482 482
 function give_reports_graph_controls() {
483
-	$date_options = apply_filters( 'give_report_date_options', array(
484
-		'today'        => esc_html__( 'Today', 'give' ),
485
-		'yesterday'    => esc_html__( 'Yesterday', 'give' ),
486
-		'this_week'    => esc_html__( 'This Week', 'give' ),
487
-		'last_week'    => esc_html__( 'Last Week', 'give' ),
488
-		'this_month'   => esc_html__( 'This Month', 'give' ),
489
-		'last_month'   => esc_html__( 'Last Month', 'give' ),
490
-		'this_quarter' => esc_html__( 'This Quarter', 'give' ),
491
-		'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
492
-		'this_year'    => esc_html__( 'This Year', 'give' ),
493
-		'last_year'    => esc_html__( 'Last Year', 'give' ),
494
-		'other'        => esc_html__( 'Custom', 'give' )
495
-	) );
483
+	$date_options = apply_filters('give_report_date_options', array(
484
+		'today'        => esc_html__('Today', 'give'),
485
+		'yesterday'    => esc_html__('Yesterday', 'give'),
486
+		'this_week'    => esc_html__('This Week', 'give'),
487
+		'last_week'    => esc_html__('Last Week', 'give'),
488
+		'this_month'   => esc_html__('This Month', 'give'),
489
+		'last_month'   => esc_html__('Last Month', 'give'),
490
+		'this_quarter' => esc_html__('This Quarter', 'give'),
491
+		'last_quarter' => esc_html__('Last Quarter', 'give'),
492
+		'this_year'    => esc_html__('This Year', 'give'),
493
+		'last_year'    => esc_html__('Last Year', 'give'),
494
+		'other'        => esc_html__('Custom', 'give')
495
+	));
496 496
 
497 497
 	$dates   = give_get_report_dates();
498 498
 	$display = $dates['range'] == 'other' ? '' : 'style="display:none;"';
499 499
 	$view    = give_get_reporting_view();
500 500
 
501
-	if ( empty( $dates['day_end'] ) ) {
502
-		$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) );
501
+	if (empty($dates['day_end'])) {
502
+		$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y'));
503 503
 	}
504 504
 
505 505
 	/**
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 	 *
508 508
 	 * @since 1.0
509 509
 	 */
510
-	do_action( 'give_report_graph_controls_before' );
510
+	do_action('give_report_graph_controls_before');
511 511
 	?>
512 512
 	<form id="give-graphs-filter" method="get" class="alignright">
513 513
 		<div class="tablenav top alignright">
@@ -515,53 +515,53 @@  discard block
 block discarded – undo
515 515
 
516 516
 				<input type="hidden" name="post_type" value="give_forms" />
517 517
 				<input type="hidden" name="page" value="give-reports" />
518
-				<input type="hidden" name="view" value="<?php echo esc_attr( $view ); ?>" />
518
+				<input type="hidden" name="view" value="<?php echo esc_attr($view); ?>" />
519 519
 
520
-				<?php if ( isset( $_GET['form-id'] ) ) : ?>
521
-					<input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" />
520
+				<?php if (isset($_GET['form-id'])) : ?>
521
+					<input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" />
522 522
 				<?php endif; ?>
523 523
 
524 524
 				<div id="give-graphs-date-options-wrap" class="alignright">
525 525
 					<select id="give-graphs-date-options" name="range">
526
-						<?php foreach ( $date_options as $key => $option ) : ?>
527
-							<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option>
526
+						<?php foreach ($date_options as $key => $option) : ?>
527
+							<option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option>
528 528
 						<?php endforeach; ?>
529 529
 					</select>
530 530
 
531
-					<input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Filter', 'give' ); ?>" />
531
+					<input type="submit" class="button-secondary" value="<?php esc_attr_e('Filter', 'give'); ?>" />
532 532
 				</div>
533 533
 
534 534
 				<div id="give-date-range-options" <?php echo $display; ?>>
535
-					<span><?php esc_html_e( 'From', 'give' ); ?>&nbsp;</span>
535
+					<span><?php esc_html_e('From', 'give'); ?>&nbsp;</span>
536 536
 					<select id="give-graphs-month-start" name="m_start">
537
-						<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
538
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['m_start'] ); ?>><?php echo give_month_num_to_name( $i ); ?></option>
537
+						<?php for ($i = 1; $i <= 12; $i++) : ?>
538
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['m_start']); ?>><?php echo give_month_num_to_name($i); ?></option>
539 539
 						<?php endfor; ?>
540 540
 					</select>
541 541
 					<select id="give-graphs-day-start" name="day">
542
-						<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
543
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['day'] ); ?>><?php echo $i; ?></option>
542
+						<?php for ($i = 1; $i <= 31; $i++) : ?>
543
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['day']); ?>><?php echo $i; ?></option>
544 544
 						<?php endfor; ?>
545 545
 					</select>
546 546
 					<select id="give-graphs-year-start" name="year">
547
-						<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
548
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['year'] ); ?>><?php echo $i; ?></option>
547
+						<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
548
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['year']); ?>><?php echo $i; ?></option>
549 549
 						<?php endfor; ?>
550 550
 					</select>
551
-					<span><?php esc_html_e( 'To', 'give' ); ?>&nbsp;</span>
551
+					<span><?php esc_html_e('To', 'give'); ?>&nbsp;</span>
552 552
 					<select id="give-graphs-month-end" name="m_end">
553
-						<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
554
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['m_end'] ); ?>><?php echo give_month_num_to_name( $i ); ?></option>
553
+						<?php for ($i = 1; $i <= 12; $i++) : ?>
554
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['m_end']); ?>><?php echo give_month_num_to_name($i); ?></option>
555 555
 						<?php endfor; ?>
556 556
 					</select>
557 557
 					<select id="give-graphs-day-end" name="day_end">
558
-						<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
559
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['day_end'] ); ?>><?php echo $i; ?></option>
558
+						<?php for ($i = 1; $i <= 31; $i++) : ?>
559
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['day_end']); ?>><?php echo $i; ?></option>
560 560
 						<?php endfor; ?>
561 561
 					</select>
562 562
 					<select id="give-graphs-year-end" name="year_end">
563
-						<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
564
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['year_end'] ); ?>><?php echo $i; ?></option>
563
+						<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
564
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['year_end']); ?>><?php echo $i; ?></option>
565 565
 						<?php endfor; ?>
566 566
 					</select>
567 567
 				</div>
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	 *
577 577
 	 * @since 1.0
578 578
 	 */
579
-	do_action( 'give_report_graph_controls_after' );
579
+	do_action('give_report_graph_controls_after');
580 580
 }
581 581
 
582 582
 /**
@@ -591,65 +591,65 @@  discard block
 block discarded – undo
591 591
 function give_get_report_dates() {
592 592
 	$dates = array();
593 593
 
594
-	$current_time = current_time( 'timestamp' );
594
+	$current_time = current_time('timestamp');
595 595
 
596
-	$dates['range']    = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month';
597
-	$dates['year']     = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
598
-	$dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' );
599
-	$dates['m_start']  = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1;
600
-	$dates['m_end']    = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12;
601
-	$dates['day']      = isset( $_GET['day'] ) ? $_GET['day'] : 1;
602
-	$dates['day_end']  = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
596
+	$dates['range']    = isset($_GET['range']) ? $_GET['range'] : 'this_month';
597
+	$dates['year']     = isset($_GET['year']) ? $_GET['year'] : date('Y');
598
+	$dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y');
599
+	$dates['m_start']  = isset($_GET['m_start']) ? $_GET['m_start'] : 1;
600
+	$dates['m_end']    = isset($_GET['m_end']) ? $_GET['m_end'] : 12;
601
+	$dates['day']      = isset($_GET['day']) ? $_GET['day'] : 1;
602
+	$dates['day_end']  = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
603 603
 
604 604
 	// Modify dates based on predefined ranges
605
-	switch ( $dates['range'] ) :
605
+	switch ($dates['range']) :
606 606
 
607 607
 		case 'this_month' :
608
-			$dates['m_start']  = date( 'n', $current_time );
609
-			$dates['m_end']    = date( 'n', $current_time );
608
+			$dates['m_start']  = date('n', $current_time);
609
+			$dates['m_end']    = date('n', $current_time);
610 610
 			$dates['day']      = 1;
611
-			$dates['day_end']  = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
612
-			$dates['year']     = date( 'Y' );
613
-			$dates['year_end'] = date( 'Y' );
611
+			$dates['day_end']  = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
612
+			$dates['year']     = date('Y');
613
+			$dates['year_end'] = date('Y');
614 614
 			break;
615 615
 
616 616
 		case 'last_month' :
617
-			if ( date( 'n' ) == 1 ) {
617
+			if (date('n') == 1) {
618 618
 				$dates['m_start']  = 12;
619 619
 				$dates['m_end']    = 12;
620
-				$dates['year']     = date( 'Y', $current_time ) - 1;
621
-				$dates['year_end'] = date( 'Y', $current_time ) - 1;
620
+				$dates['year']     = date('Y', $current_time) - 1;
621
+				$dates['year_end'] = date('Y', $current_time) - 1;
622 622
 			} else {
623
-				$dates['m_start']  = date( 'n' ) - 1;
624
-				$dates['m_end']    = date( 'n' ) - 1;
623
+				$dates['m_start']  = date('n') - 1;
624
+				$dates['m_end']    = date('n') - 1;
625 625
 				$dates['year_end'] = $dates['year'];
626 626
 			}
627
-			$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
627
+			$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
628 628
 			break;
629 629
 
630 630
 		case 'today' :
631
-			$dates['day']     = date( 'd', $current_time );
632
-			$dates['m_start'] = date( 'n', $current_time );
633
-			$dates['m_end']   = date( 'n', $current_time );
634
-			$dates['year']    = date( 'Y', $current_time );
631
+			$dates['day']     = date('d', $current_time);
632
+			$dates['m_start'] = date('n', $current_time);
633
+			$dates['m_end']   = date('n', $current_time);
634
+			$dates['year']    = date('Y', $current_time);
635 635
 			break;
636 636
 
637 637
 		case 'yesterday' :
638 638
 
639
-			$year  = date( 'Y', $current_time );
640
-			$month = date( 'n', $current_time );
641
-			$day   = date( 'd', $current_time );
639
+			$year  = date('Y', $current_time);
640
+			$month = date('n', $current_time);
641
+			$day   = date('d', $current_time);
642 642
 
643
-			if ( $month == 1 && $day == 1 ) {
643
+			if ($month == 1 && $day == 1) {
644 644
 
645 645
 				$year -= 1;
646 646
 				$month = 12;
647
-				$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
647
+				$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
648 648
 
649
-			} elseif ( $month > 1 && $day == 1 ) {
649
+			} elseif ($month > 1 && $day == 1) {
650 650
 
651 651
 				$month -= 1;
652
-				$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
652
+				$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
653 653
 
654 654
 			} else {
655 655
 
@@ -665,91 +665,91 @@  discard block
 block discarded – undo
665 665
 			break;
666 666
 
667 667
 		case 'this_week' :
668
-			$dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1;
669
-			$dates['day'] += get_option( 'start_of_week' );
668
+			$dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1;
669
+			$dates['day'] += get_option('start_of_week');
670 670
 			$dates['day_end'] = $dates['day'] + 6;
671
-			$dates['m_start'] = date( 'n', $current_time );
672
-			$dates['m_end']   = date( 'n', $current_time );
673
-			$dates['year']    = date( 'Y', $current_time );
671
+			$dates['m_start'] = date('n', $current_time);
672
+			$dates['m_end']   = date('n', $current_time);
673
+			$dates['year']    = date('Y', $current_time);
674 674
 			break;
675 675
 
676 676
 		case 'last_week' :
677
-			$dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8;
678
-			$dates['day'] += get_option( 'start_of_week' );
677
+			$dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8;
678
+			$dates['day'] += get_option('start_of_week');
679 679
 			$dates['day_end'] = $dates['day'] + 6;
680
-			$dates['year']    = date( 'Y' );
681
-
682
-			if ( date( 'j', $current_time ) <= 7 ) {
683
-				$dates['m_start'] = date( 'n', $current_time ) - 1;
684
-				$dates['m_end']   = date( 'n', $current_time ) - 1;
685
-				if ( $dates['m_start'] <= 1 ) {
686
-					$dates['year']     = date( 'Y', $current_time ) - 1;
687
-					$dates['year_end'] = date( 'Y', $current_time ) - 1;
680
+			$dates['year']    = date('Y');
681
+
682
+			if (date('j', $current_time) <= 7) {
683
+				$dates['m_start'] = date('n', $current_time) - 1;
684
+				$dates['m_end']   = date('n', $current_time) - 1;
685
+				if ($dates['m_start'] <= 1) {
686
+					$dates['year']     = date('Y', $current_time) - 1;
687
+					$dates['year_end'] = date('Y', $current_time) - 1;
688 688
 				}
689 689
 			} else {
690
-				$dates['m_start'] = date( 'n', $current_time );
691
-				$dates['m_end']   = date( 'n', $current_time );
690
+				$dates['m_start'] = date('n', $current_time);
691
+				$dates['m_end']   = date('n', $current_time);
692 692
 			}
693 693
 			break;
694 694
 
695 695
 		case 'this_quarter' :
696
-			$month_now = date( 'n', $current_time );
696
+			$month_now = date('n', $current_time);
697 697
 
698
-			if ( $month_now <= 3 ) {
698
+			if ($month_now <= 3) {
699 699
 
700 700
 				$dates['m_start'] = 1;
701 701
 				$dates['m_end']   = 4;
702
-				$dates['year']    = date( 'Y', $current_time );
702
+				$dates['year']    = date('Y', $current_time);
703 703
 
704
-			} else if ( $month_now <= 6 ) {
704
+			} else if ($month_now <= 6) {
705 705
 
706 706
 				$dates['m_start'] = 4;
707 707
 				$dates['m_end']   = 7;
708
-				$dates['year']    = date( 'Y', $current_time );
708
+				$dates['year']    = date('Y', $current_time);
709 709
 
710
-			} else if ( $month_now <= 9 ) {
710
+			} else if ($month_now <= 9) {
711 711
 
712 712
 				$dates['m_start'] = 7;
713 713
 				$dates['m_end']   = 10;
714
-				$dates['year']    = date( 'Y', $current_time );
714
+				$dates['year']    = date('Y', $current_time);
715 715
 
716 716
 			} else {
717 717
 
718 718
 				$dates['m_start']  = 10;
719 719
 				$dates['m_end']    = 1;
720
-				$dates['year']     = date( 'Y', $current_time );
721
-				$dates['year_end'] = date( 'Y', $current_time ) + 1;
720
+				$dates['year']     = date('Y', $current_time);
721
+				$dates['year_end'] = date('Y', $current_time) + 1;
722 722
 
723 723
 			}
724 724
 			break;
725 725
 
726 726
 		case 'last_quarter' :
727
-			$month_now = date( 'n' );
727
+			$month_now = date('n');
728 728
 
729
-			if ( $month_now <= 3 ) {
729
+			if ($month_now <= 3) {
730 730
 
731 731
 				$dates['m_start']  = 10;
732 732
 				$dates['m_end']    = 12;
733
-				$dates['year']     = date( 'Y', $current_time ) - 1; // Previous year
734
-				$dates['year_end'] = date( 'Y', $current_time ) - 1; // Previous year
733
+				$dates['year']     = date('Y', $current_time) - 1; // Previous year
734
+				$dates['year_end'] = date('Y', $current_time) - 1; // Previous year
735 735
 
736
-			} else if ( $month_now <= 6 ) {
736
+			} else if ($month_now <= 6) {
737 737
 
738 738
 				$dates['m_start'] = 1;
739 739
 				$dates['m_end']   = 3;
740
-				$dates['year']    = date( 'Y', $current_time );
740
+				$dates['year']    = date('Y', $current_time);
741 741
 
742
-			} else if ( $month_now <= 9 ) {
742
+			} else if ($month_now <= 9) {
743 743
 
744 744
 				$dates['m_start'] = 4;
745 745
 				$dates['m_end']   = 6;
746
-				$dates['year']    = date( 'Y', $current_time );
746
+				$dates['year']    = date('Y', $current_time);
747 747
 
748 748
 			} else {
749 749
 
750 750
 				$dates['m_start'] = 7;
751 751
 				$dates['m_end']   = 9;
752
-				$dates['year']    = date( 'Y', $current_time );
752
+				$dates['year']    = date('Y', $current_time);
753 753
 
754 754
 			}
755 755
 			break;
@@ -757,19 +757,19 @@  discard block
 block discarded – undo
757 757
 		case 'this_year' :
758 758
 			$dates['m_start'] = 1;
759 759
 			$dates['m_end']   = 12;
760
-			$dates['year']    = date( 'Y', $current_time );
760
+			$dates['year']    = date('Y', $current_time);
761 761
 			break;
762 762
 
763 763
 		case 'last_year' :
764 764
 			$dates['m_start']  = 1;
765 765
 			$dates['m_end']    = 12;
766
-			$dates['year']     = date( 'Y', $current_time ) - 1;
767
-			$dates['year_end'] = date( 'Y', $current_time ) - 1;
766
+			$dates['year']     = date('Y', $current_time) - 1;
767
+			$dates['year_end'] = date('Y', $current_time) - 1;
768 768
 			break;
769 769
 
770 770
 	endswitch;
771 771
 
772
-	return apply_filters( 'give_report_dates', $dates );
772
+	return apply_filters('give_report_dates', $dates);
773 773
 }
774 774
 
775 775
 /**
@@ -779,17 +779,17 @@  discard block
 block discarded – undo
779 779
  *
780 780
  * @param $data
781 781
  */
782
-function give_parse_report_dates( $data ) {
782
+function give_parse_report_dates($data) {
783 783
 	$dates = give_get_report_dates();
784 784
 
785 785
 	$view = give_get_reporting_view();
786
-	$id   = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null;
786
+	$id   = isset($_GET['form-id']) ? $_GET['form-id'] : null;
787 787
 
788
-	wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) );
788
+	wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&view='.esc_attr($view).'&form-id='.absint($id))));
789 789
 	give_die();
790 790
 }
791 791
 
792
-add_action( 'give_filter_reports', 'give_parse_report_dates' );
792
+add_action('give_filter_reports', 'give_parse_report_dates');
793 793
 
794 794
 
795 795
 /**
@@ -801,16 +801,16 @@  discard block
 block discarded – undo
801 801
  */
802 802
 function give_reports_refresh_button() {
803 803
 
804
-	$url = wp_nonce_url( add_query_arg( array(
804
+	$url = wp_nonce_url(add_query_arg(array(
805 805
 		'give_action'  => 'refresh_reports_transients',
806 806
 		'give-message' => 'refreshed-reports'
807
-	) ), 'give-refresh-reports' );
807
+	)), 'give-refresh-reports');
808 808
 
809
-	echo '<a href="' . $url . '" data-tooltip="' . esc_attr__( 'Clicking this will clear the reports cache.', 'give' ) . '" data-tooltip-my-position="right center"  data-tooltip-target-position="left center" class="button alignright give-refresh-reports-button give-tooltip">' . esc_html__( 'Refresh Reports', 'give' ) . '</a>';
809
+	echo '<a href="'.$url.'" data-tooltip="'.esc_attr__('Clicking this will clear the reports cache.', 'give').'" data-tooltip-my-position="right center"  data-tooltip-target-position="left center" class="button alignright give-refresh-reports-button give-tooltip">'.esc_html__('Refresh Reports', 'give').'</a>';
810 810
 
811 811
 }
812 812
 
813
-add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' );
813
+add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button');
814 814
 
815 815
 /**
816 816
  * Trigger the refresh of reports transients
@@ -821,18 +821,18 @@  discard block
 block discarded – undo
821 821
  *
822 822
  * @return void
823 823
  */
824
-function give_run_refresh_reports_transients( $data ) {
824
+function give_run_refresh_reports_transients($data) {
825 825
 
826
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) {
826
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) {
827 827
 		return;
828 828
 	}
829 829
 
830 830
 	//Delete transients
831
-	delete_transient( 'give_estimated_monthly_stats' );
832
-	delete_transient( 'give_earnings_total' );
833
-	delete_transient( md5( 'give_earnings_this_monththis_month' ) );
834
-	delete_transient( md5( 'give_earnings_todaytoday' ) );
831
+	delete_transient('give_estimated_monthly_stats');
832
+	delete_transient('give_earnings_total');
833
+	delete_transient(md5('give_earnings_this_monththis_month'));
834
+	delete_transient(md5('give_earnings_todaytoday'));
835 835
 
836 836
 }
837 837
 
838
-add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' );
839 838
\ No newline at end of file
839
+add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients');
840 840
\ No newline at end of file
Please login to merge, or discard this patch.
includes/api/class-give-api.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @access public
213 213
 	 * @since  1.1
214
-	 * @return array
214
+	 * @return string
215 215
 	 */
216 216
 	public function get_versions() {
217 217
 		return $this->versions;
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	 *
663 663
 	 * @param array $args Arguments to override defaults
664 664
 	 *
665
-	 * @return array $dates
665
+	 * @return integer|null $dates
666 666
 	 */
667 667
 	public function get_dates( $args = array() ) {
668 668
 		$dates = array();
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 	 *
1713 1713
 	 * @param int $user_id User ID of user to revoke key for
1714 1714
 	 *
1715
-	 * @return string
1715
+	 * @return boolean
1716 1716
 	 */
1717 1717
 	public function revoke_api_key( $user_id = 0 ) {
1718 1718
 
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
 	 * Determines whether results should be displayed in XML or JSON
1438 1438
 	 *
1439 1439
 	 * @since 1.1
1440
-     * @access public
1440
+	 * @access public
1441 1441
 	 *
1442 1442
 	 * @return mixed|void
1443 1443
 	 */
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	 *
1456 1456
 	 * @access private
1457 1457
 	 * @since  1.1
1458
-     *
1458
+	 *
1459 1459
 	 * @global Give_Logging $give_logs
1460 1460
 	 * @global WP_Query     $wp_query
1461 1461
 	 *
@@ -1468,15 +1468,15 @@  discard block
 block discarded – undo
1468 1468
 			return;
1469 1469
 		}
1470 1470
 
1471
-        /**
1472
-         * @var Give_Logging $give_logs
1473
-         */
1471
+		/**
1472
+		 * @var Give_Logging $give_logs
1473
+		 */
1474 1474
 		global $give_logs;
1475 1475
 
1476
-        /**
1477
-         * @var WP_Query $wp_query
1478
-         */
1479
-        global $wp_query;
1476
+		/**
1477
+		 * @var WP_Query $wp_query
1478
+		 */
1479
+		global $wp_query;
1480 1480
 
1481 1481
 		$query = array(
1482 1482
 			'give-api'    => $wp_query->query_vars['give-api'],
@@ -1534,9 +1534,9 @@  discard block
 block discarded – undo
1534 1534
 	 * @param int $status_code
1535 1535
 	 */
1536 1536
 	public function output( $status_code = 200 ) {
1537
-        /**
1538
-         * @var WP_Query $wp_query
1539
-         */
1537
+		/**
1538
+		 * @var WP_Query $wp_query
1539
+		 */
1540 1540
 		global $wp_query;
1541 1541
 
1542 1542
 		$format = $this->get_output_format();
Please login to merge, or discard this patch.
Spacing   +482 added lines, -482 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
 
@@ -140,27 +140,27 @@  discard block
 block discarded – undo
140 140
 			'v1' => 'GIVE_API_V1',
141 141
 		);
142 142
 
143
-		foreach ( $this->get_versions() as $version => $class ) {
144
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
143
+		foreach ($this->get_versions() as $version => $class) {
144
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
145 145
 		}
146 146
 
147
-		add_action( 'init', array( $this, 'add_endpoint' ) );
148
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
149
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
150
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
151
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
152
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
153
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
154
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
147
+		add_action('init', array($this, 'add_endpoint'));
148
+		add_action('wp', array($this, 'process_query'), - 1);
149
+		add_filter('query_vars', array($this, 'query_vars'));
150
+		add_action('show_user_profile', array($this, 'user_key_field'));
151
+		add_action('edit_user_profile', array($this, 'user_key_field'));
152
+		add_action('personal_options_update', array($this, 'update_key'));
153
+		add_action('edit_user_profile_update', array($this, 'update_key'));
154
+		add_action('give_process_api_key', array($this, 'process_api_key'));
155 155
 
156 156
 		// Setup a backwards compatibility check for user API Keys
157
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
157
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
158 158
 
159 159
 		// Determine if JSON_PRETTY_PRINT is available
160
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
160
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
161 161
 
162 162
 		// Allow API request logging to be turned off
163
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
163
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
164 164
 
165 165
 		// Setup Give_Payment_Stats instance
166 166
 		$this->stats = new Give_Payment_Stats;
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @since  1.1
178 178
 	 */
179
-	public function add_endpoint( $rewrite_rules ) {
180
-		add_rewrite_endpoint( 'give-api', EP_ALL );
179
+	public function add_endpoint($rewrite_rules) {
180
+		add_rewrite_endpoint('give-api', EP_ALL);
181 181
 	}
182 182
 
183 183
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return string[] $vars New query vars
192 192
 	 */
193
-	public function query_vars( $vars ) {
193
+	public function query_vars($vars) {
194 194
 
195 195
 		$vars[] = 'token';
196 196
 		$vars[] = 'key';
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function get_default_version() {
243 243
 
244
-		$version = get_option( 'give_default_api_version' );
244
+		$version = get_option('give_default_api_version');
245 245
 
246
-		if ( defined( 'GIVE_API_VERSION' ) ) {
246
+		if (defined('GIVE_API_VERSION')) {
247 247
 			$version = GIVE_API_VERSION;
248
-		} elseif ( ! $version ) {
248
+		} elseif ( ! $version) {
249 249
 			$version = 'v1';
250 250
 		}
251 251
 
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
 
267 267
 		$version = $wp_query->query_vars['give-api'];
268 268
 
269
-		if ( strpos( $version, '/' ) ) {
269
+		if (strpos($version, '/')) {
270 270
 
271
-			$version = explode( '/', $version );
272
-			$version = strtolower( $version[0] );
271
+			$version = explode('/', $version);
272
+			$version = strtolower($version[0]);
273 273
 
274
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
274
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
275 275
 
276
-			if ( array_key_exists( $version, $this->versions ) ) {
276
+			if (array_key_exists($version, $this->versions)) {
277 277
 
278 278
 				$this->queried_version = $version;
279 279
 
@@ -310,32 +310,32 @@  discard block
 block discarded – undo
310 310
 		$this->override = false;
311 311
 
312 312
 		// Make sure we have both user and api key
313
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
313
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) {
314 314
 
315
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
315
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
316 316
 				$this->missing_auth();
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
 
324 324
 			} else {
325 325
 
326
-				$token  = urldecode( $wp_query->query_vars['token'] );
327
-				$secret = $this->get_user_secret_key( $user );
328
-				$public = urldecode( $wp_query->query_vars['key'] );
326
+				$token  = urldecode($wp_query->query_vars['token']);
327
+				$secret = $this->get_user_secret_key($user);
328
+				$public = urldecode($wp_query->query_vars['key']);
329 329
 
330
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
330
+				if (hash_equals(md5($secret.$public), $token)) {
331 331
 					$this->is_valid_request = true;
332 332
 				} else {
333 333
 					$this->invalid_auth();
334 334
 				}
335 335
 			}
336
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) {
336
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') {
337 337
 			$this->is_valid_request = true;
338
-			$wp_query->set( 'key', 'public' );
338
+			$wp_query->set('key', 'public');
339 339
 		}
340 340
 	}
341 341
 
@@ -351,25 +351,25 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @return bool if user ID is found, false otherwise
353 353
 	 */
354
-	public function get_user( $key = '' ) {
354
+	public function get_user($key = '') {
355 355
 		global $wpdb, $wp_query;
356 356
 
357
-		if ( empty( $key ) ) {
358
-			$key = urldecode( $wp_query->query_vars['key'] );
357
+		if (empty($key)) {
358
+			$key = urldecode($wp_query->query_vars['key']);
359 359
 		}
360 360
 
361
-		if ( empty( $key ) ) {
361
+		if (empty($key)) {
362 362
 			return false;
363 363
 		}
364 364
 
365
-		$user = get_transient( md5( 'give_api_user_' . $key ) );
365
+		$user = get_transient(md5('give_api_user_'.$key));
366 366
 
367
-		if ( false === $user ) {
368
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
369
-			set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS );
367
+		if (false === $user) {
368
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
369
+			set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS);
370 370
 		}
371 371
 
372
-		if ( $user != null ) {
372
+		if ($user != null) {
373 373
 			$this->user_id = $user;
374 374
 
375 375
 			return $user;
@@ -378,37 +378,37 @@  discard block
 block discarded – undo
378 378
 		return false;
379 379
 	}
380 380
 
381
-	public function get_user_public_key( $user_id = 0 ) {
381
+	public function get_user_public_key($user_id = 0) {
382 382
 		global $wpdb;
383 383
 
384
-		if ( empty( $user_id ) ) {
384
+		if (empty($user_id)) {
385 385
 			return '';
386 386
 		}
387 387
 
388
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
389
-		$user_public_key = get_transient( $cache_key );
388
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
389
+		$user_public_key = get_transient($cache_key);
390 390
 
391
-		if ( empty( $user_public_key ) ) {
392
-			$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 ) );
393
-			set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS );
391
+		if (empty($user_public_key)) {
392
+			$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));
393
+			set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS);
394 394
 		}
395 395
 
396 396
 		return $user_public_key;
397 397
 	}
398 398
 
399
-	public function get_user_secret_key( $user_id = 0 ) {
399
+	public function get_user_secret_key($user_id = 0) {
400 400
 		global $wpdb;
401 401
 
402
-		if ( empty( $user_id ) ) {
402
+		if (empty($user_id)) {
403 403
 			return '';
404 404
 		}
405 405
 
406
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
407
-		$user_secret_key = get_transient( $cache_key );
406
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
407
+		$user_secret_key = get_transient($cache_key);
408 408
 
409
-		if ( empty( $user_secret_key ) ) {
410
-			$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 ) );
411
-			set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS );
409
+		if (empty($user_secret_key)) {
410
+			$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));
411
+			set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS);
412 412
 		}
413 413
 
414 414
 		return $user_secret_key;
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 	 */
425 425
 	private function missing_auth() {
426 426
 		$error          = array();
427
-		$error['error'] = esc_html__( 'You must specify both a token and API key.', 'give' );
427
+		$error['error'] = esc_html__('You must specify both a token and API key.', 'give');
428 428
 
429 429
 		$this->data = $error;
430
-		$this->output( 401 );
430
+		$this->output(401);
431 431
 	}
432 432
 
433 433
 	/**
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
 	 */
442 442
 	private function invalid_auth() {
443 443
 		$error          = array();
444
-		$error['error'] = esc_html__( 'Your request could not be authenticated.', 'give' );
444
+		$error['error'] = esc_html__('Your request could not be authenticated.', 'give');
445 445
 
446 446
 		$this->data = $error;
447
-		$this->output( 403 );
447
+		$this->output(403);
448 448
 	}
449 449
 
450 450
 	/**
@@ -458,10 +458,10 @@  discard block
 block discarded – undo
458 458
 	 */
459 459
 	private function invalid_key() {
460 460
 		$error          = array();
461
-		$error['error'] = esc_html__( 'Invalid API key.', 'give' );
461
+		$error['error'] = esc_html__('Invalid API key.', 'give');
462 462
 
463 463
 		$this->data = $error;
464
-		$this->output( 403 );
464
+		$this->output(403);
465 465
 	}
466 466
 
467 467
 	/**
@@ -474,10 +474,10 @@  discard block
 block discarded – undo
474 474
 	 */
475 475
 	private function invalid_version() {
476 476
 		$error          = array();
477
-		$error['error'] = esc_html__( 'Invalid API version.', 'give' );
477
+		$error['error'] = esc_html__('Invalid API version.', 'give');
478 478
 
479 479
 		$this->data = $error;
480
-		$this->output( 404 );
480
+		$this->output(404);
481 481
 	}
482 482
 
483 483
 	/**
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
 		global $wp_query;
494 494
 
495 495
 		// Start logging how long the request takes for logging
496
-		$before = microtime( true );
496
+		$before = microtime(true);
497 497
 
498 498
 		// Check for give-api var. Get out if not present
499
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
499
+		if (empty($wp_query->query_vars['give-api'])) {
500 500
 			return;
501 501
 		}
502 502
 
@@ -510,45 +510,45 @@  discard block
 block discarded – undo
510 510
 		$this->validate_request();
511 511
 
512 512
 		// Only proceed if no errors have been noted
513
-		if ( ! $this->is_valid_request ) {
513
+		if ( ! $this->is_valid_request) {
514 514
 			return;
515 515
 		}
516 516
 
517
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
518
-			define( 'GIVE_DOING_API', true );
517
+		if ( ! defined('GIVE_DOING_API')) {
518
+			define('GIVE_DOING_API', true);
519 519
 		}
520 520
 
521 521
 		$data         = array();
522 522
 		$this->routes = new $this->versions[$this->get_queried_version()];
523 523
 		$this->routes->validate_request();
524 524
 
525
-		switch ( $this->endpoint ) :
525
+		switch ($this->endpoint) :
526 526
 
527 527
 			case 'stats' :
528 528
 
529
-				$data = $this->routes->get_stats( array(
530
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
531
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
532
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
533
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
534
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null
535
-				) );
529
+				$data = $this->routes->get_stats(array(
530
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
531
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
532
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
533
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
534
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null
535
+				));
536 536
 
537 537
 				break;
538 538
 
539 539
 			case 'forms' :
540 540
 
541
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
541
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
542 542
 
543
-				$data = $this->routes->get_forms( $form );
543
+				$data = $this->routes->get_forms($form);
544 544
 
545 545
 				break;
546 546
 
547 547
 			case 'donors' :
548 548
 
549
-				$customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
549
+				$customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
550 550
 
551
-				$data = $this->routes->get_customers( $customer );
551
+				$data = $this->routes->get_customers($customer);
552 552
 
553 553
 				break;
554 554
 
@@ -561,14 +561,14 @@  discard block
 block discarded – undo
561 561
 		endswitch;
562 562
 
563 563
 		// Allow extensions to setup their own return data
564
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
564
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
565 565
 
566
-		$after                       = microtime( true );
567
-		$request_time                = ( $after - $before );
566
+		$after                       = microtime(true);
567
+		$request_time                = ($after - $before);
568 568
 		$this->data['request_speed'] = $request_time;
569 569
 
570 570
 		// Log this API request, if enabled. We log it here because we have access to errors.
571
-		$this->log_request( $this->data );
571
+		$this->log_request($this->data);
572 572
 
573 573
 		// Send out data to the output function
574 574
 		$this->output();
@@ -598,25 +598,25 @@  discard block
 block discarded – undo
598 598
 		global $wp_query;
599 599
 
600 600
 		// Whitelist our query options
601
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
601
+		$accepted = apply_filters('give_api_valid_query_modes', array(
602 602
 			'stats',
603 603
 			'forms',
604 604
 			'donors',
605 605
 			'donations'
606
-		) );
606
+		));
607 607
 
608
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
609
-		$query = str_replace( $this->queried_version . '/', '', $query );
608
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
609
+		$query = str_replace($this->queried_version.'/', '', $query);
610 610
 
611 611
 		$error = array();
612 612
 
613 613
 		// Make sure our query is valid
614
-		if ( ! in_array( $query, $accepted ) ) {
615
-			$error['error'] = esc_html__( 'Invalid query.', 'give' );
614
+		if ( ! in_array($query, $accepted)) {
615
+			$error['error'] = esc_html__('Invalid query.', 'give');
616 616
 
617 617
 			$this->data = $error;
618 618
 			// 400 is Bad Request
619
-			$this->output( 400 );
619
+			$this->output(400);
620 620
 		}
621 621
 
622 622
 		$this->endpoint = $query;
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 	public function get_paged() {
634 634
 		global $wp_query;
635 635
 
636
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
636
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
637 637
 	}
638 638
 
639 639
 
@@ -648,13 +648,13 @@  discard block
 block discarded – undo
648 648
 	public function per_page() {
649 649
 		global $wp_query;
650 650
 
651
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
651
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
652 652
 
653
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
653
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
654 654
 			$per_page = 99999999;
655 655
 		} // Customers query doesn't support -1
656 656
 
657
-		return apply_filters( 'give_api_results_per_page', $per_page );
657
+		return apply_filters('give_api_results_per_page', $per_page);
658 658
 	}
659 659
 
660 660
 	/**
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	 *
668 668
 	 * @return array $dates
669 669
 	 */
670
-	public function get_dates( $args = array() ) {
670
+	public function get_dates($args = array()) {
671 671
 		$dates = array();
672 672
 
673 673
 		$defaults = array(
@@ -678,60 +678,60 @@  discard block
 block discarded – undo
678 678
 			'enddate'   => null
679 679
 		);
680 680
 
681
-		$args = wp_parse_args( $args, $defaults );
681
+		$args = wp_parse_args($args, $defaults);
682 682
 
683
-		$current_time = current_time( 'timestamp' );
683
+		$current_time = current_time('timestamp');
684 684
 
685
-		if ( 'range' === $args['date'] ) {
686
-			$startdate          = strtotime( $args['startdate'] );
687
-			$enddate            = strtotime( $args['enddate'] );
688
-			$dates['day_start'] = date( 'd', $startdate );
689
-			$dates['day_end']   = date( 'd', $enddate );
690
-			$dates['m_start']   = date( 'n', $startdate );
691
-			$dates['m_end']     = date( 'n', $enddate );
692
-			$dates['year']      = date( 'Y', $startdate );
693
-			$dates['year_end']  = date( 'Y', $enddate );
685
+		if ('range' === $args['date']) {
686
+			$startdate          = strtotime($args['startdate']);
687
+			$enddate            = strtotime($args['enddate']);
688
+			$dates['day_start'] = date('d', $startdate);
689
+			$dates['day_end']   = date('d', $enddate);
690
+			$dates['m_start']   = date('n', $startdate);
691
+			$dates['m_end']     = date('n', $enddate);
692
+			$dates['year']      = date('Y', $startdate);
693
+			$dates['year_end']  = date('Y', $enddate);
694 694
 		} else {
695 695
 			// Modify dates based on predefined ranges
696
-			switch ( $args['date'] ) :
696
+			switch ($args['date']) :
697 697
 
698 698
 				case 'this_month' :
699 699
 					$dates['day']     = null;
700
-					$dates['m_start'] = date( 'n', $current_time );
701
-					$dates['m_end']   = date( 'n', $current_time );
702
-					$dates['year']    = date( 'Y', $current_time );
700
+					$dates['m_start'] = date('n', $current_time);
701
+					$dates['m_end']   = date('n', $current_time);
702
+					$dates['year']    = date('Y', $current_time);
703 703
 					break;
704 704
 
705 705
 				case 'last_month' :
706 706
 					$dates['day']     = null;
707
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
707
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
708 708
 					$dates['m_end']   = $dates['m_start'];
709
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
709
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
710 710
 					break;
711 711
 
712 712
 				case 'today' :
713
-					$dates['day']     = date( 'd', $current_time );
714
-					$dates['m_start'] = date( 'n', $current_time );
715
-					$dates['m_end']   = date( 'n', $current_time );
716
-					$dates['year']    = date( 'Y', $current_time );
713
+					$dates['day']     = date('d', $current_time);
714
+					$dates['m_start'] = date('n', $current_time);
715
+					$dates['m_end']   = date('n', $current_time);
716
+					$dates['year']    = date('Y', $current_time);
717 717
 					break;
718 718
 
719 719
 				case 'yesterday' :
720 720
 
721
-					$year  = date( 'Y', $current_time );
722
-					$month = date( 'n', $current_time );
723
-					$day   = date( 'd', $current_time );
721
+					$year  = date('Y', $current_time);
722
+					$month = date('n', $current_time);
723
+					$day   = date('d', $current_time);
724 724
 
725
-					if ( $month == 1 && $day == 1 ) {
725
+					if ($month == 1 && $day == 1) {
726 726
 
727 727
 						$year -= 1;
728 728
 						$month = 12;
729
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
729
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
730 730
 
731
-					} elseif ( $month > 1 && $day == 1 ) {
731
+					} elseif ($month > 1 && $day == 1) {
732 732
 
733 733
 						$month -= 1;
734
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
734
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
735 735
 
736 736
 					} else {
737 737
 
@@ -747,65 +747,65 @@  discard block
 block discarded – undo
747 747
 					break;
748 748
 
749 749
 				case 'this_quarter' :
750
-					$month_now = date( 'n', $current_time );
750
+					$month_now = date('n', $current_time);
751 751
 
752 752
 					$dates['day'] = null;
753 753
 
754
-					if ( $month_now <= 3 ) {
754
+					if ($month_now <= 3) {
755 755
 
756 756
 						$dates['m_start'] = 1;
757 757
 						$dates['m_end']   = 3;
758
-						$dates['year']    = date( 'Y', $current_time );
758
+						$dates['year']    = date('Y', $current_time);
759 759
 
760
-					} else if ( $month_now <= 6 ) {
760
+					} else if ($month_now <= 6) {
761 761
 
762 762
 						$dates['m_start'] = 4;
763 763
 						$dates['m_end']   = 6;
764
-						$dates['year']    = date( 'Y', $current_time );
764
+						$dates['year']    = date('Y', $current_time);
765 765
 
766
-					} else if ( $month_now <= 9 ) {
766
+					} else if ($month_now <= 9) {
767 767
 
768 768
 						$dates['m_start'] = 7;
769 769
 						$dates['m_end']   = 9;
770
-						$dates['year']    = date( 'Y', $current_time );
770
+						$dates['year']    = date('Y', $current_time);
771 771
 
772 772
 					} else {
773 773
 
774 774
 						$dates['m_start'] = 10;
775 775
 						$dates['m_end']   = 12;
776
-						$dates['year']    = date( 'Y', $current_time );
776
+						$dates['year']    = date('Y', $current_time);
777 777
 
778 778
 					}
779 779
 					break;
780 780
 
781 781
 				case 'last_quarter' :
782
-					$month_now = date( 'n', $current_time );
782
+					$month_now = date('n', $current_time);
783 783
 
784 784
 					$dates['day'] = null;
785 785
 
786
-					if ( $month_now <= 3 ) {
786
+					if ($month_now <= 3) {
787 787
 
788 788
 						$dates['m_start'] = 10;
789 789
 						$dates['m_end']   = 12;
790
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
790
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
791 791
 
792
-					} else if ( $month_now <= 6 ) {
792
+					} else if ($month_now <= 6) {
793 793
 
794 794
 						$dates['m_start'] = 1;
795 795
 						$dates['m_end']   = 3;
796
-						$dates['year']    = date( 'Y', $current_time );
796
+						$dates['year']    = date('Y', $current_time);
797 797
 
798
-					} else if ( $month_now <= 9 ) {
798
+					} else if ($month_now <= 9) {
799 799
 
800 800
 						$dates['m_start'] = 4;
801 801
 						$dates['m_end']   = 6;
802
-						$dates['year']    = date( 'Y', $current_time );
802
+						$dates['year']    = date('Y', $current_time);
803 803
 
804 804
 					} else {
805 805
 
806 806
 						$dates['m_start'] = 7;
807 807
 						$dates['m_end']   = 9;
808
-						$dates['year']    = date( 'Y', $current_time );
808
+						$dates['year']    = date('Y', $current_time);
809 809
 
810 810
 					}
811 811
 					break;
@@ -814,14 +814,14 @@  discard block
 block discarded – undo
814 814
 					$dates['day']     = null;
815 815
 					$dates['m_start'] = null;
816 816
 					$dates['m_end']   = null;
817
-					$dates['year']    = date( 'Y', $current_time );
817
+					$dates['year']    = date('Y', $current_time);
818 818
 					break;
819 819
 
820 820
 				case 'last_year' :
821 821
 					$dates['day']     = null;
822 822
 					$dates['m_start'] = null;
823 823
 					$dates['m_end']   = null;
824
-					$dates['year']    = date( 'Y', $current_time ) - 1;
824
+					$dates['year']    = date('Y', $current_time) - 1;
825 825
 					break;
826 826
 
827 827
 			endswitch;
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 		 * @param object $dates The dates used for retrieving earnings/donations
836 836
 		 */
837 837
 
838
-		return apply_filters( 'give_api_stat_dates', $dates );
838
+		return apply_filters('give_api_stat_dates', $dates);
839 839
 	}
840 840
 
841 841
 	/**
@@ -850,11 +850,11 @@  discard block
 block discarded – undo
850 850
 	 *
851 851
 	 * @return array $customers Multidimensional array of the customers
852 852
 	 */
853
-	public function get_customers( $customer = null ) {
853
+	public function get_customers($customer = null) {
854 854
 
855 855
 		$customers = array();
856 856
 		$error     = array();
857
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
857
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
858 858
 			return $customers;
859 859
 		}
860 860
 
@@ -862,64 +862,64 @@  discard block
 block discarded – undo
862 862
 
863 863
 		$paged    = $this->get_paged();
864 864
 		$per_page = $this->per_page();
865
-		$offset   = $per_page * ( $paged - 1 );
865
+		$offset   = $per_page * ($paged - 1);
866 866
 
867
-		if ( is_numeric( $customer ) ) {
867
+		if (is_numeric($customer)) {
868 868
 			$field = 'id';
869 869
 		} else {
870 870
 			$field = 'email';
871 871
 		}
872 872
 
873
-		$customer_query = Give()->customers->get_customers( array(
873
+		$customer_query = Give()->customers->get_customers(array(
874 874
 			'number' => $per_page,
875 875
 			'offset' => $offset,
876 876
 			$field   => $customer
877
-		) );
877
+		));
878 878
 		$customer_count = 0;
879 879
 
880
-		if ( $customer_query ) {
880
+		if ($customer_query) {
881 881
 
882
-			foreach ( $customer_query as $customer_obj ) {
882
+			foreach ($customer_query as $customer_obj) {
883 883
 
884
-				$names      = explode( ' ', $customer_obj->name );
885
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
884
+				$names      = explode(' ', $customer_obj->name);
885
+				$first_name = ! empty($names[0]) ? $names[0] : '';
886 886
 				$last_name  = '';
887
-				if ( ! empty( $names[1] ) ) {
888
-					unset( $names[0] );
889
-					$last_name = implode( ' ', $names );
887
+				if ( ! empty($names[1])) {
888
+					unset($names[0]);
889
+					$last_name = implode(' ', $names);
890 890
 				}
891 891
 
892
-				$customers['donors'][ $customer_count ]['info']['user_id']      = '';
893
-				$customers['donors'][ $customer_count ]['info']['username']     = '';
894
-				$customers['donors'][ $customer_count ]['info']['display_name'] = '';
895
-				$customers['donors'][ $customer_count ]['info']['customer_id']  = $customer_obj->id;
896
-				$customers['donors'][ $customer_count ]['info']['first_name']   = $first_name;
897
-				$customers['donors'][ $customer_count ]['info']['last_name']    = $last_name;
898
-				$customers['donors'][ $customer_count ]['info']['email']        = $customer_obj->email;
892
+				$customers['donors'][$customer_count]['info']['user_id']      = '';
893
+				$customers['donors'][$customer_count]['info']['username']     = '';
894
+				$customers['donors'][$customer_count]['info']['display_name'] = '';
895
+				$customers['donors'][$customer_count]['info']['customer_id']  = $customer_obj->id;
896
+				$customers['donors'][$customer_count]['info']['first_name']   = $first_name;
897
+				$customers['donors'][$customer_count]['info']['last_name']    = $last_name;
898
+				$customers['donors'][$customer_count]['info']['email']        = $customer_obj->email;
899 899
 
900
-				if ( ! empty( $customer_obj->user_id ) ) {
900
+				if ( ! empty($customer_obj->user_id)) {
901 901
 
902
-					$user_data = get_userdata( $customer_obj->user_id );
902
+					$user_data = get_userdata($customer_obj->user_id);
903 903
 
904 904
 					// Customer with registered account
905
-					$customers['donors'][ $customer_count ]['info']['user_id']      = $customer_obj->user_id;
906
-					$customers['donors'][ $customer_count ]['info']['username']     = $user_data->user_login;
907
-					$customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name;
905
+					$customers['donors'][$customer_count]['info']['user_id']      = $customer_obj->user_id;
906
+					$customers['donors'][$customer_count]['info']['username']     = $user_data->user_login;
907
+					$customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name;
908 908
 
909 909
 				}
910 910
 
911
-				$customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count;
912
-				$customers['donors'][ $customer_count ]['stats']['total_spent']     = $customer_obj->purchase_value;
911
+				$customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count;
912
+				$customers['donors'][$customer_count]['stats']['total_spent']     = $customer_obj->purchase_value;
913 913
 
914
-				$customer_count ++;
914
+				$customer_count++;
915 915
 
916 916
 			}
917 917
 
918
-		} elseif ( $customer ) {
918
+		} elseif ($customer) {
919 919
 
920 920
 			$error['error'] = sprintf(
921 921
 				/* translators: %s: customer */
922
-				esc_html__( 'Donor %s not found.', 'give' ),
922
+				esc_html__('Donor %s not found.', 'give'),
923 923
 				$customer
924 924
 			);
925 925
 
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 
928 928
 		} else {
929 929
 
930
-			$error['error'] = esc_html__( 'No donors found.', 'give' );
930
+			$error['error'] = esc_html__('No donors found.', 'give');
931 931
 
932 932
 			return $error;
933 933
 
@@ -946,38 +946,38 @@  discard block
 block discarded – undo
946 946
 	 *
947 947
 	 * @return array $customers Multidimensional array of the forms
948 948
 	 */
949
-	public function get_forms( $form = null ) {
949
+	public function get_forms($form = null) {
950 950
 
951 951
 		$forms = array();
952 952
 		$error = array();
953 953
 
954
-		if ( $form == null ) {
954
+		if ($form == null) {
955 955
 			$forms['forms'] = array();
956 956
 
957
-			$form_list = get_posts( array(
957
+			$form_list = get_posts(array(
958 958
 				'post_type'        => 'give_forms',
959 959
 				'posts_per_page'   => $this->per_page(),
960 960
 				'suppress_filters' => true,
961 961
 				'paged'            => $this->get_paged()
962
-			) );
962
+			));
963 963
 
964
-			if ( $form_list ) {
964
+			if ($form_list) {
965 965
 				$i = 0;
966
-				foreach ( $form_list as $form_info ) {
967
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
968
-					$i ++;
966
+				foreach ($form_list as $form_info) {
967
+					$forms['forms'][$i] = $this->get_form_data($form_info);
968
+					$i++;
969 969
 				}
970 970
 			}
971 971
 		} else {
972
-			if ( get_post_type( $form ) == 'give_forms' ) {
973
-				$form_info = get_post( $form );
972
+			if (get_post_type($form) == 'give_forms') {
973
+				$form_info = get_post($form);
974 974
 
975
-				$forms['forms'][0] = $this->get_form_data( $form_info );
975
+				$forms['forms'][0] = $this->get_form_data($form_info);
976 976
 
977 977
 			} else {
978 978
 				$error['error'] = sprintf(
979 979
 					/* translators: %s: form */
980
-					esc_html__( 'Form %s not found.', 'give' ),
980
+					esc_html__('Form %s not found.', 'give'),
981 981
 					$form
982 982
 				);
983 983
 
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 	 *
998 998
 	 * @return array                Array of post data to return back in the API
999 999
 	 */
1000
-	private function get_form_data( $form_info ) {
1000
+	private function get_form_data($form_info) {
1001 1001
 
1002 1002
 		$form = array();
1003 1003
 
@@ -1007,50 +1007,50 @@  discard block
 block discarded – undo
1007 1007
 		$form['info']['create_date']   = $form_info->post_date;
1008 1008
 		$form['info']['modified_date'] = $form_info->post_modified;
1009 1009
 		$form['info']['status']        = $form_info->post_status;
1010
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1011
-		$form['info']['content']       = get_post_meta( $form_info->ID, '_give_form_content', true );
1012
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1010
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1011
+		$form['info']['content']       = get_post_meta($form_info->ID, '_give_form_content', true);
1012
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1013 1013
 
1014
-		if ( give_get_option( 'enable_categories' ) == 'on' ) {
1015
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1016
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1014
+		if (give_get_option('enable_categories') == 'on') {
1015
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1016
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1017 1017
 		}
1018
-		if ( give_get_option( 'enable_tags' ) == 'on' ) {
1019
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1018
+		if (give_get_option('enable_tags') == 'on') {
1019
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1020 1020
 		}
1021 1021
 
1022
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1023
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1024
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1025
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1026
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1022
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1023
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1024
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1025
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1026
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1027 1027
 		}
1028 1028
 
1029 1029
 		$counter = 0;
1030
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1031
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1032
-				$counter ++;
1030
+		if (give_has_variable_prices($form_info->ID)) {
1031
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1032
+				$counter++;
1033 1033
 				//muli-level item
1034
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1035
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1034
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1035
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1036 1036
 
1037 1037
 			}
1038 1038
 		} else {
1039
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1039
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1040 1040
 		}
1041 1041
 
1042
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1042
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1043 1043
 
1044 1044
 			/**
1045 1045
 			 * Fires when generating API sensitive data.
1046 1046
 			 *
1047 1047
 			 * @since 1.1
1048 1048
 			 */
1049
-			do_action( 'give_api_sensitive_data' );
1049
+			do_action('give_api_sensitive_data');
1050 1050
 
1051 1051
 		}
1052 1052
 
1053
-		return apply_filters( 'give_api_forms_form', $form );
1053
+		return apply_filters('give_api_forms_form', $form);
1054 1054
 
1055 1055
 	}
1056 1056
 
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 	 *
1066 1066
 	 * @return array
1067 1067
 	 */
1068
-	public function get_stats( $args = array() ) {
1068
+	public function get_stats($args = array()) {
1069 1069
 		$defaults = array(
1070 1070
 			'type'      => null,
1071 1071
 			'form'      => null,
@@ -1074,9 +1074,9 @@  discard block
 block discarded – undo
1074 1074
 			'enddate'   => null
1075 1075
 		);
1076 1076
 
1077
-		$args = wp_parse_args( $args, $defaults );
1077
+		$args = wp_parse_args($args, $defaults);
1078 1078
 
1079
-		$dates = $this->get_dates( $args );
1079
+		$dates = $this->get_dates($args);
1080 1080
 
1081 1081
 		$stats    = array();
1082 1082
 		$earnings = array(
@@ -1087,41 +1087,41 @@  discard block
 block discarded – undo
1087 1087
 		);
1088 1088
 		$error    = array();
1089 1089
 
1090
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1090
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1091 1091
 			return $stats;
1092 1092
 		}
1093 1093
 
1094
-		if ( $args['type'] == 'donations' ) {
1094
+		if ($args['type'] == 'donations') {
1095 1095
 
1096
-			if ( $args['form'] == null ) {
1097
-				if ( $args['date'] == null ) {
1096
+			if ($args['form'] == null) {
1097
+				if ($args['date'] == null) {
1098 1098
 					$sales = $this->get_default_sales_stats();
1099
-				} elseif ( $args['date'] === 'range' ) {
1099
+				} elseif ($args['date'] === 'range') {
1100 1100
 					// Return sales for a date range
1101 1101
 
1102 1102
 					// Ensure the end date is later than the start date
1103
-					if ( $args['enddate'] < $args['startdate'] ) {
1104
-						$error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' );
1103
+					if ($args['enddate'] < $args['startdate']) {
1104
+						$error['error'] = esc_html__('The end date must be later than the start date.', 'give');
1105 1105
 					}
1106 1106
 
1107 1107
 					// Ensure both the start and end date are specified
1108
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1109
-						$error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' );
1108
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1109
+						$error['error'] = esc_html__('Invalid or no date range specified.', 'give');
1110 1110
 					}
1111 1111
 
1112 1112
 					$total = 0;
1113 1113
 
1114 1114
 					// Loop through the years
1115 1115
 					$y = $dates['year'];
1116
-					while ( $y <= $dates['year_end'] ) :
1116
+					while ($y <= $dates['year_end']) :
1117 1117
 
1118
-						if ( $dates['year'] == $dates['year_end'] ) {
1118
+						if ($dates['year'] == $dates['year_end']) {
1119 1119
 							$month_start = $dates['m_start'];
1120 1120
 							$month_end   = $dates['m_end'];
1121
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1121
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1122 1122
 							$month_start = $dates['m_start'];
1123 1123
 							$month_end   = 12;
1124
-						} elseif ( $y == $dates['year_end'] ) {
1124
+						} elseif ($y == $dates['year_end']) {
1125 1125
 							$month_start = 1;
1126 1126
 							$month_end   = $dates['m_end'];
1127 1127
 						} else {
@@ -1130,113 +1130,113 @@  discard block
 block discarded – undo
1130 1130
 						}
1131 1131
 
1132 1132
 						$i = $month_start;
1133
-						while ( $i <= $month_end ) :
1133
+						while ($i <= $month_end) :
1134 1134
 
1135
-							if ( $i == $dates['m_start'] ) {
1135
+							if ($i == $dates['m_start']) {
1136 1136
 								$d = $dates['day_start'];
1137 1137
 							} else {
1138 1138
 								$d = 1;
1139 1139
 							}
1140 1140
 
1141
-							if ( $i == $dates['m_end'] ) {
1141
+							if ($i == $dates['m_end']) {
1142 1142
 								$num_of_days = $dates['day_end'];
1143 1143
 							} else {
1144
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1144
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1145 1145
 							}
1146 1146
 
1147
-							while ( $d <= $num_of_days ) :
1148
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1149
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1150
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1151
-									$sales['sales'][ $date_key ] = 0;
1147
+							while ($d <= $num_of_days) :
1148
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1149
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1150
+								if ( ! isset($sales['sales'][$date_key])) {
1151
+									$sales['sales'][$date_key] = 0;
1152 1152
 								}
1153
-								$sales['sales'][ $date_key ] += $sale_count;
1153
+								$sales['sales'][$date_key] += $sale_count;
1154 1154
 								$total += $sale_count;
1155
-								$d ++;
1155
+								$d++;
1156 1156
 							endwhile;
1157
-							$i ++;
1157
+							$i++;
1158 1158
 						endwhile;
1159 1159
 
1160
-						$y ++;
1160
+						$y++;
1161 1161
 					endwhile;
1162 1162
 
1163 1163
 					$sales['totals'] = $total;
1164 1164
 				} else {
1165
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1165
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1166 1166
 						$sales_count = 0;
1167 1167
 
1168 1168
 						// Loop through the months
1169 1169
 						$month = $dates['m_start'];
1170 1170
 
1171
-						while ( $month <= $dates['m_end'] ) :
1172
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1173
-							$month ++;
1171
+						while ($month <= $dates['m_end']) :
1172
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1173
+							$month++;
1174 1174
 						endwhile;
1175 1175
 
1176
-						$sales['donations'][ $args['date'] ] = $sales_count;
1176
+						$sales['donations'][$args['date']] = $sales_count;
1177 1177
 					} else {
1178
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1178
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1179 1179
 					}
1180 1180
 				}
1181
-			} elseif ( $args['form'] == 'all' ) {
1182
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1181
+			} elseif ($args['form'] == 'all') {
1182
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1183 1183
 				$i     = 0;
1184
-				foreach ( $forms as $form_info ) {
1185
-					$sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) );
1186
-					$i ++;
1184
+				foreach ($forms as $form_info) {
1185
+					$sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID));
1186
+					$i++;
1187 1187
 				}
1188 1188
 			} else {
1189
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1190
-					$form_info             = get_post( $args['form'] );
1191
-					$sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) );
1189
+				if (get_post_type($args['form']) == 'give_forms') {
1190
+					$form_info             = get_post($args['form']);
1191
+					$sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form']));
1192 1192
 				} else {
1193 1193
 					$error['error'] = sprintf(
1194 1194
 						/* translators: %s: form */
1195
-						esc_html__( 'Product %s not found.', 'give' ),
1195
+						esc_html__('Product %s not found.', 'give'),
1196 1196
 						$args['form']
1197 1197
 					);
1198 1198
 				}
1199 1199
 			}
1200 1200
 
1201
-			if ( ! empty( $error ) ) {
1201
+			if ( ! empty($error)) {
1202 1202
 				return $error;
1203 1203
 			}
1204 1204
 
1205 1205
 			return $sales;
1206 1206
 
1207
-		} elseif ( $args['type'] == 'earnings' ) {
1208
-			if ( $args['form'] == null ) {
1209
-				if ( $args['date'] == null ) {
1207
+		} elseif ($args['type'] == 'earnings') {
1208
+			if ($args['form'] == null) {
1209
+				if ($args['date'] == null) {
1210 1210
 					$earnings = $this->get_default_earnings_stats();
1211
-				} elseif ( $args['date'] === 'range' ) {
1211
+				} elseif ($args['date'] === 'range') {
1212 1212
 					// Return sales for a date range
1213 1213
 
1214 1214
 					// Ensure the end date is later than the start date
1215
-					if ( $args['enddate'] < $args['startdate'] ) {
1216
-						$error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' );
1215
+					if ($args['enddate'] < $args['startdate']) {
1216
+						$error['error'] = esc_html__('The end date must be later than the start date.', 'give');
1217 1217
 					}
1218 1218
 
1219 1219
 					// Ensure both the start and end date are specified
1220
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1221
-						$error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' );
1220
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1221
+						$error['error'] = esc_html__('Invalid or no date range specified.', 'give');
1222 1222
 					}
1223 1223
 
1224 1224
 					$total = (float) 0.00;
1225 1225
 
1226 1226
 					// Loop through the years
1227 1227
 					$y = $dates['year'];
1228
-					if ( ! isset( $earnings['earnings'] ) ) {
1228
+					if ( ! isset($earnings['earnings'])) {
1229 1229
 						$earnings['earnings'] = array();
1230 1230
 					}
1231
-					while ( $y <= $dates['year_end'] ) :
1231
+					while ($y <= $dates['year_end']) :
1232 1232
 
1233
-						if ( $dates['year'] == $dates['year_end'] ) {
1233
+						if ($dates['year'] == $dates['year_end']) {
1234 1234
 							$month_start = $dates['m_start'];
1235 1235
 							$month_end   = $dates['m_end'];
1236
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1236
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1237 1237
 							$month_start = $dates['m_start'];
1238 1238
 							$month_end   = 12;
1239
-						} elseif ( $y == $dates['year_end'] ) {
1239
+						} elseif ($y == $dates['year_end']) {
1240 1240
 							$month_start = 1;
1241 1241
 							$month_end   = $dates['m_end'];
1242 1242
 						} else {
@@ -1245,92 +1245,92 @@  discard block
 block discarded – undo
1245 1245
 						}
1246 1246
 
1247 1247
 						$i = $month_start;
1248
-						while ( $i <= $month_end ) :
1248
+						while ($i <= $month_end) :
1249 1249
 
1250
-							if ( $i == $dates['m_start'] ) {
1250
+							if ($i == $dates['m_start']) {
1251 1251
 								$d = $dates['day_start'];
1252 1252
 							} else {
1253 1253
 								$d = 1;
1254 1254
 							}
1255 1255
 
1256
-							if ( $i == $dates['m_end'] ) {
1256
+							if ($i == $dates['m_end']) {
1257 1257
 								$num_of_days = $dates['day_end'];
1258 1258
 							} else {
1259
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1259
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1260 1260
 							}
1261 1261
 
1262
-							while ( $d <= $num_of_days ) :
1263
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1264
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1265
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1266
-									$earnings['earnings'][ $date_key ] = 0;
1262
+							while ($d <= $num_of_days) :
1263
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1264
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1265
+								if ( ! isset($earnings['earnings'][$date_key])) {
1266
+									$earnings['earnings'][$date_key] = 0;
1267 1267
 								}
1268
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1268
+								$earnings['earnings'][$date_key] += $earnings_stat;
1269 1269
 								$total += $earnings_stat;
1270
-								$d ++;
1270
+								$d++;
1271 1271
 							endwhile;
1272 1272
 
1273
-							$i ++;
1273
+							$i++;
1274 1274
 						endwhile;
1275 1275
 
1276
-						$y ++;
1276
+						$y++;
1277 1277
 					endwhile;
1278 1278
 
1279 1279
 					$earnings['totals'] = $total;
1280 1280
 				} else {
1281
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1281
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1282 1282
 						$earnings_count = (float) 0.00;
1283 1283
 
1284 1284
 						// Loop through the months
1285 1285
 						$month = $dates['m_start'];
1286 1286
 
1287
-						while ( $month <= $dates['m_end'] ) :
1288
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1289
-							$month ++;
1287
+						while ($month <= $dates['m_end']) :
1288
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1289
+							$month++;
1290 1290
 						endwhile;
1291 1291
 
1292
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1292
+						$earnings['earnings'][$args['date']] = $earnings_count;
1293 1293
 					} else {
1294
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1294
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1295 1295
 					}
1296 1296
 				}
1297
-			} elseif ( $args['form'] == 'all' ) {
1298
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1297
+			} elseif ($args['form'] == 'all') {
1298
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1299 1299
 
1300 1300
 				$i = 0;
1301
-				foreach ( $forms as $form_info ) {
1302
-					$earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) );
1303
-					$i ++;
1301
+				foreach ($forms as $form_info) {
1302
+					$earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID));
1303
+					$i++;
1304 1304
 				}
1305 1305
 			} else {
1306
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1307
-					$form_info               = get_post( $args['form'] );
1308
-					$earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) );
1306
+				if (get_post_type($args['form']) == 'give_forms') {
1307
+					$form_info               = get_post($args['form']);
1308
+					$earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form']));
1309 1309
 				} else {
1310 1310
 					$error['error'] = sprintf(
1311 1311
 						/* translators: %s: form */
1312
-						esc_html__( 'Form %s not found.', 'give' ),
1312
+						esc_html__('Form %s not found.', 'give'),
1313 1313
 						$args['form']
1314 1314
 					);
1315 1315
 				}
1316 1316
 			}
1317 1317
 
1318
-			if ( ! empty( $error ) ) {
1318
+			if ( ! empty($error)) {
1319 1319
 				return $error;
1320 1320
 			}
1321 1321
 
1322 1322
 			return $earnings;
1323
-		} elseif ( $args['type'] == 'donors' ) {
1323
+		} elseif ($args['type'] == 'donors') {
1324 1324
 			$customers                          = new Give_DB_Customers();
1325 1325
 			$stats['donations']['total_donors'] = $customers->count();
1326 1326
 
1327 1327
 			return $stats;
1328 1328
 
1329
-		} elseif ( empty( $args['type'] ) ) {
1330
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1331
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1329
+		} elseif (empty($args['type'])) {
1330
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1331
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1332 1332
 
1333
-			return array( 'stats' => $stats );
1333
+			return array('stats' => $stats);
1334 1334
 		}
1335 1335
 	}
1336 1336
 
@@ -1346,18 +1346,18 @@  discard block
 block discarded – undo
1346 1346
 
1347 1347
 		$sales = array();
1348 1348
 
1349
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1349
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1350 1350
 			return $sales;
1351 1351
 		}
1352 1352
 
1353
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1353
+		if (isset($wp_query->query_vars['id'])) {
1354 1354
 			$query   = array();
1355
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1356
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1355
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1356
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1357 1357
 			$query   = array();
1358
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1359
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1360
-			$args  = array(
1358
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1359
+		} elseif (isset($wp_query->query_vars['email'])) {
1360
+			$args = array(
1361 1361
 				'fields'     => 'ids',
1362 1362
 				'meta_key'   => '_give_payment_user_email',
1363 1363
 				'meta_value' => $wp_query->query_vars['email'],
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
 				'page'       => $this->get_paged(),
1366 1366
 				'status'     => 'publish'
1367 1367
 			);
1368
-			$query = give_get_payments( $args );
1368
+			$query = give_get_payments($args);
1369 1369
 		} else {
1370 1370
 			$args  = array(
1371 1371
 				'fields' => 'ids',
@@ -1373,14 +1373,14 @@  discard block
 block discarded – undo
1373 1373
 				'page'   => $this->get_paged(),
1374 1374
 				'status' => 'publish'
1375 1375
 			);
1376
-			$query = give_get_payments( $args );
1376
+			$query = give_get_payments($args);
1377 1377
 		}
1378
-		if ( $query ) {
1378
+		if ($query) {
1379 1379
 			$i = 0;
1380
-			foreach ( $query as $payment ) {
1380
+			foreach ($query as $payment) {
1381 1381
 
1382
-				if ( is_numeric( $payment ) ) {
1383
-					$payment      = new Give_Payment( $payment );
1382
+				if (is_numeric($payment)) {
1383
+					$payment      = new Give_Payment($payment);
1384 1384
 					$payment_meta = $payment->get_meta();
1385 1385
 					$user_info    = $payment->user_info;
1386 1386
 				} else {
@@ -1390,40 +1390,40 @@  discard block
 block discarded – undo
1390 1390
 				$payment_meta = $payment->get_meta();
1391 1391
 				$user_info    = $payment->user_info;
1392 1392
 
1393
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1394
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1395
-
1396
-				$sales['donations'][ $i ]['ID']             = $payment->number;
1397
-				$sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1398
-				$sales['donations'][ $i ]['key']            = $payment->key;
1399
-				$sales['donations'][ $i ]['total']          = $payment->total;
1400
-				$sales['donations'][ $i ]['gateway']        = $payment->gateway;
1401
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1402
-				$sales['donations'][ $i ]['fname']          = $first_name;
1403
-				$sales['donations'][ $i ]['lname']          = $last_name;
1404
-				$sales['donations'][ $i ]['email']          = $payment->email;
1405
-				$sales['donations'][ $i ]['date']           = $payment->date;
1406
-
1407
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1408
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1409
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1410
-
1411
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1412
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1413
-				$sales['donations'][ $i ]['form']['price'] = $price;
1414
-
1415
-				if ( give_has_variable_prices( $form_id ) ) {
1416
-					if ( isset( $payment_meta['price_id'] ) ) {
1417
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1418
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1419
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1420
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1393
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1394
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1395
+
1396
+				$sales['donations'][$i]['ID']             = $payment->number;
1397
+				$sales['donations'][$i]['transaction_id'] = $payment->transaction_id;
1398
+				$sales['donations'][$i]['key']            = $payment->key;
1399
+				$sales['donations'][$i]['total']          = $payment->total;
1400
+				$sales['donations'][$i]['gateway']        = $payment->gateway;
1401
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1402
+				$sales['donations'][$i]['fname']          = $first_name;
1403
+				$sales['donations'][$i]['lname']          = $last_name;
1404
+				$sales['donations'][$i]['email']          = $payment->email;
1405
+				$sales['donations'][$i]['date']           = $payment->date;
1406
+
1407
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1408
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1409
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1410
+
1411
+				$sales['donations'][$i]['form']['id']    = $form_id;
1412
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1413
+				$sales['donations'][$i]['form']['price'] = $price;
1414
+
1415
+				if (give_has_variable_prices($form_id)) {
1416
+					if (isset($payment_meta['price_id'])) {
1417
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1418
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1419
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1420
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1421 1421
 
1422 1422
 					}
1423 1423
 				}
1424 1424
 
1425 1425
 				//Add custom meta to API
1426
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1426
+				foreach ($payment_meta as $meta_key => $meta_value) {
1427 1427
 
1428 1428
 					$exceptions = array(
1429 1429
 						'form_title',
@@ -1436,19 +1436,19 @@  discard block
 block discarded – undo
1436 1436
 					);
1437 1437
 
1438 1438
 					//Don't clutter up results with dupes
1439
-					if ( in_array( $meta_key, $exceptions ) ) {
1439
+					if (in_array($meta_key, $exceptions)) {
1440 1440
 						continue;
1441 1441
 					}
1442 1442
 
1443
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1443
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1444 1444
 
1445 1445
 				}
1446 1446
 
1447
-				$i ++;
1447
+				$i++;
1448 1448
 			}
1449 1449
 		}
1450 1450
 
1451
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1451
+		return apply_filters('give_api_donations_endpoint', $sales);
1452 1452
 	}
1453 1453
 
1454 1454
 	/**
@@ -1464,9 +1464,9 @@  discard block
 block discarded – undo
1464 1464
 	public function get_output_format() {
1465 1465
 		global $wp_query;
1466 1466
 
1467
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1467
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1468 1468
 
1469
-		return apply_filters( 'give_api_output_format', $format );
1469
+		return apply_filters('give_api_output_format', $format);
1470 1470
 	}
1471 1471
 
1472 1472
 
@@ -1483,8 +1483,8 @@  discard block
 block discarded – undo
1483 1483
 	 *
1484 1484
 	 * @return void
1485 1485
 	 */
1486
-	private function log_request( $data = array() ) {
1487
-		if ( ! $this->log_requests ) {
1486
+	private function log_request($data = array()) {
1487
+		if ( ! $this->log_requests) {
1488 1488
 			return;
1489 1489
 		}
1490 1490
 
@@ -1500,36 +1500,36 @@  discard block
 block discarded – undo
1500 1500
 
1501 1501
 		$query = array(
1502 1502
 			'give-api'    => $wp_query->query_vars['give-api'],
1503
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1504
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1505
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1506
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1507
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1508
-			'customer'    => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null,
1509
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1510
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1511
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1512
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1513
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1514
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1503
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1504
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1505
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1506
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1507
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1508
+			'customer'    => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null,
1509
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1510
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1511
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1512
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1513
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1514
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1515 1515
 		);
1516 1516
 
1517 1517
 		$log_data = array(
1518 1518
 			'log_type'     => 'api_request',
1519
-			'post_excerpt' => http_build_query( $query ),
1520
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1519
+			'post_excerpt' => http_build_query($query),
1520
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1521 1521
 		);
1522 1522
 
1523 1523
 		$log_meta = array(
1524 1524
 			'request_ip' => give_get_ip(),
1525 1525
 			'user'       => $this->user_id,
1526
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1527
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1526
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1527
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1528 1528
 			'time'       => $data['request_speed'],
1529 1529
 			'version'    => $this->get_queried_version()
1530 1530
 		);
1531 1531
 
1532
-		$give_logs->insert_log( $log_data, $log_meta );
1532
+		$give_logs->insert_log($log_data, $log_meta);
1533 1533
 	}
1534 1534
 
1535 1535
 
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
 	 *
1554 1554
 	 * @param int $status_code
1555 1555
 	 */
1556
-	public function output( $status_code = 200 ) {
1556
+	public function output($status_code = 200) {
1557 1557
         /**
1558 1558
          * @var WP_Query $wp_query
1559 1559
          */
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 
1562 1562
 		$format = $this->get_output_format();
1563 1563
 
1564
-		status_header( $status_code );
1564
+		status_header($status_code);
1565 1565
 
1566 1566
 		/**
1567 1567
 		 * Fires before outputing the API.
@@ -1572,25 +1572,25 @@  discard block
 block discarded – undo
1572 1572
 		 * @param Give_API $this   The Give_API object.
1573 1573
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1574 1574
 		 */
1575
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1575
+		do_action('give_api_output_before', $this->data, $this, $format);
1576 1576
 
1577
-		switch ( $format ) :
1577
+		switch ($format) :
1578 1578
 
1579 1579
 			case 'xml' :
1580 1580
 
1581
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1582
-				$xml = Array2XML::createXML( 'give', $this->data );
1581
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1582
+				$xml = Array2XML::createXML('give', $this->data);
1583 1583
 				echo $xml->saveXML();
1584 1584
 
1585 1585
 				break;
1586 1586
 
1587 1587
 			case 'json' :
1588 1588
 
1589
-				header( 'Content-Type: application/json' );
1590
-				if ( ! empty( $this->pretty_print ) ) {
1591
-					echo json_encode( $this->data, $this->pretty_print );
1589
+				header('Content-Type: application/json');
1590
+				if ( ! empty($this->pretty_print)) {
1591
+					echo json_encode($this->data, $this->pretty_print);
1592 1592
 				} else {
1593
-					echo json_encode( $this->data );
1593
+					echo json_encode($this->data);
1594 1594
 				}
1595 1595
 
1596 1596
 				break;
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
 				 * @param array    $data Response data to return.
1607 1607
 				 * @param Give_API $this The Give_API object.
1608 1608
 				 */
1609
-				do_action( "give_api_output_{$format}", $this->data, $this );
1609
+				do_action("give_api_output_{$format}", $this->data, $this);
1610 1610
 
1611 1611
 				break;
1612 1612
 
@@ -1621,7 +1621,7 @@  discard block
 block discarded – undo
1621 1621
 		 * @param Give_API $this   The Give_API object.
1622 1622
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1623 1623
 		 */
1624
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1624
+		do_action('give_api_output_after', $this->data, $this, $format);
1625 1625
 
1626 1626
 		give_die();
1627 1627
 	}
@@ -1638,37 +1638,37 @@  discard block
 block discarded – undo
1638 1638
 	 *
1639 1639
 	 * @return void
1640 1640
 	 */
1641
-	function user_key_field( $user ) {
1641
+	function user_key_field($user) {
1642 1642
 
1643
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1644
-			$user = get_userdata( $user->ID );
1643
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1644
+			$user = get_userdata($user->ID);
1645 1645
 			?>
1646 1646
 			<table class="form-table">
1647 1647
 				<tbody>
1648 1648
 				<tr>
1649 1649
 					<th>
1650
-						<?php esc_html_e( 'Give API Keys', 'give' ); ?>
1650
+						<?php esc_html_e('Give API Keys', 'give'); ?>
1651 1651
 					</th>
1652 1652
 					<td>
1653 1653
 						<?php
1654
-						$public_key = $this->get_user_public_key( $user->ID );
1655
-						$secret_key = $this->get_user_secret_key( $user->ID );
1654
+						$public_key = $this->get_user_public_key($user->ID);
1655
+						$secret_key = $this->get_user_secret_key($user->ID);
1656 1656
 						?>
1657
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1657
+						<?php if (empty($user->give_user_public_key)) { ?>
1658 1658
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1659
-							<span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span>
1659
+							<span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span>
1660 1660
 						<?php } else { ?>
1661
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?>&nbsp;</strong>
1662
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/>
1661
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?>&nbsp;</strong>
1662
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/>
1663 1663
 							<br/>
1664
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?>&nbsp;</strong>
1665
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/>
1664
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?>&nbsp;</strong>
1665
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/>
1666 1666
 							<br/>
1667
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?>&nbsp;</strong>
1668
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/>
1667
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?>&nbsp;</strong>
1668
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/>
1669 1669
 							<br/>
1670 1670
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1671
-							<span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span>
1671
+							<span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span>
1672 1672
 						<?php } ?>
1673 1673
 					</td>
1674 1674
 				</tr>
@@ -1687,69 +1687,69 @@  discard block
 block discarded – undo
1687 1687
 	 *
1688 1688
 	 * @return void
1689 1689
 	 */
1690
-	public function process_api_key( $args ) {
1690
+	public function process_api_key($args) {
1691 1691
 
1692
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1692
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1693 1693
 
1694
-			wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
1694
+			wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
1695 1695
 
1696 1696
 		}
1697 1697
 
1698
-		if ( empty( $args['user_id'] ) ) {
1699
-			wp_die( esc_html__( 'User ID Required.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 401 ) );
1698
+		if (empty($args['user_id'])) {
1699
+			wp_die(esc_html__('User ID Required.', 'give'), esc_html__('Error', 'give'), array('response' => 401));
1700 1700
 		}
1701 1701
 
1702
-		if ( is_numeric( $args['user_id'] ) ) {
1703
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1702
+		if (is_numeric($args['user_id'])) {
1703
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1704 1704
 		} else {
1705
-			$userdata = get_user_by( 'login', $args['user_id'] );
1705
+			$userdata = get_user_by('login', $args['user_id']);
1706 1706
 			$user_id  = $userdata->ID;
1707 1707
 		}
1708
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1708
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1709 1709
 
1710
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1710
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1711 1711
 			wp_die(
1712 1712
 				sprintf(
1713 1713
 					/* translators: %s: process */
1714
-					esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ),
1714
+					esc_html__('You do not have permission to %s API keys for this user.', 'give'),
1715 1715
 					$process
1716 1716
 				),
1717
-				esc_html__( 'Error', 'give' ),
1718
-				array( 'response' => 403 )
1717
+				esc_html__('Error', 'give'),
1718
+				array('response' => 403)
1719 1719
 			);
1720
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1720
+		} elseif ( ! current_user_can('manage_give_settings')) {
1721 1721
 			wp_die(
1722 1722
 				sprintf(
1723 1723
 					/* translators: %s: process */
1724
-					esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ),
1724
+					esc_html__('You do not have permission to %s API keys for this user.', 'give'),
1725 1725
 					$process
1726 1726
 				),
1727
-				esc_html__( 'Error', 'give' ),
1728
-				array( 'response' => 403 )
1727
+				esc_html__('Error', 'give'),
1728
+				array('response' => 403)
1729 1729
 			);
1730 1730
 		}
1731 1731
 
1732
-		switch ( $process ) {
1732
+		switch ($process) {
1733 1733
 			case 'generate':
1734
-				if ( $this->generate_api_key( $user_id ) ) {
1735
-					delete_transient( 'give_total_api_keys' );
1736
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1734
+				if ($this->generate_api_key($user_id)) {
1735
+					delete_transient('give_total_api_keys');
1736
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1737 1737
 					exit();
1738 1738
 				} else {
1739
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1739
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1740 1740
 					exit();
1741 1741
 				}
1742 1742
 				break;
1743 1743
 			case 'regenerate':
1744
-				$this->generate_api_key( $user_id, true );
1745
-				delete_transient( 'give_total_api_keys' );
1746
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1744
+				$this->generate_api_key($user_id, true);
1745
+				delete_transient('give_total_api_keys');
1746
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1747 1747
 				exit();
1748 1748
 				break;
1749 1749
 			case 'revoke':
1750
-				$this->revoke_api_key( $user_id );
1751
-				delete_transient( 'give_total_api_keys' );
1752
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1750
+				$this->revoke_api_key($user_id);
1751
+				delete_transient('give_total_api_keys');
1752
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1753 1753
 				exit();
1754 1754
 				break;
1755 1755
 			default;
@@ -1768,34 +1768,34 @@  discard block
 block discarded – undo
1768 1768
 	 *
1769 1769
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1770 1770
 	 */
1771
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1771
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1772 1772
 
1773
-		if ( empty( $user_id ) ) {
1773
+		if (empty($user_id)) {
1774 1774
 			return false;
1775 1775
 		}
1776 1776
 
1777
-		$user = get_userdata( $user_id );
1777
+		$user = get_userdata($user_id);
1778 1778
 
1779
-		if ( ! $user ) {
1779
+		if ( ! $user) {
1780 1780
 			return false;
1781 1781
 		}
1782 1782
 
1783
-		$public_key = $this->get_user_public_key( $user_id );
1784
-		$secret_key = $this->get_user_secret_key( $user_id );
1783
+		$public_key = $this->get_user_public_key($user_id);
1784
+		$secret_key = $this->get_user_secret_key($user_id);
1785 1785
 
1786
-		if ( empty( $public_key ) || $regenerate == true ) {
1787
-			$new_public_key = $this->generate_public_key( $user->user_email );
1788
-			$new_secret_key = $this->generate_private_key( $user->ID );
1786
+		if (empty($public_key) || $regenerate == true) {
1787
+			$new_public_key = $this->generate_public_key($user->user_email);
1788
+			$new_secret_key = $this->generate_private_key($user->ID);
1789 1789
 		} else {
1790 1790
 			return false;
1791 1791
 		}
1792 1792
 
1793
-		if ( $regenerate == true ) {
1794
-			$this->revoke_api_key( $user->ID );
1793
+		if ($regenerate == true) {
1794
+			$this->revoke_api_key($user->ID);
1795 1795
 		}
1796 1796
 
1797
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1798
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1797
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1798
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1799 1799
 
1800 1800
 		return true;
1801 1801
 	}
@@ -1810,26 +1810,26 @@  discard block
 block discarded – undo
1810 1810
 	 *
1811 1811
 	 * @return string
1812 1812
 	 */
1813
-	public function revoke_api_key( $user_id = 0 ) {
1813
+	public function revoke_api_key($user_id = 0) {
1814 1814
 
1815
-		if ( empty( $user_id ) ) {
1815
+		if (empty($user_id)) {
1816 1816
 			return false;
1817 1817
 		}
1818 1818
 
1819
-		$user = get_userdata( $user_id );
1819
+		$user = get_userdata($user_id);
1820 1820
 
1821
-		if ( ! $user ) {
1821
+		if ( ! $user) {
1822 1822
 			return false;
1823 1823
 		}
1824 1824
 
1825
-		$public_key = $this->get_user_public_key( $user_id );
1826
-		$secret_key = $this->get_user_secret_key( $user_id );
1827
-		if ( ! empty( $public_key ) ) {
1828
-			delete_transient( md5( 'give_api_user_' . $public_key ) );
1829
-			delete_transient( md5( 'give_api_user_public_key' . $user_id ) );
1830
-			delete_transient( md5( 'give_api_user_secret_key' . $user_id ) );
1831
-			delete_user_meta( $user_id, $public_key );
1832
-			delete_user_meta( $user_id, $secret_key );
1825
+		$public_key = $this->get_user_public_key($user_id);
1826
+		$secret_key = $this->get_user_secret_key($user_id);
1827
+		if ( ! empty($public_key)) {
1828
+			delete_transient(md5('give_api_user_'.$public_key));
1829
+			delete_transient(md5('give_api_user_public_key'.$user_id));
1830
+			delete_transient(md5('give_api_user_secret_key'.$user_id));
1831
+			delete_user_meta($user_id, $public_key);
1832
+			delete_user_meta($user_id, $secret_key);
1833 1833
 		} else {
1834 1834
 			return false;
1835 1835
 		}
@@ -1854,22 +1854,22 @@  discard block
 block discarded – undo
1854 1854
 	 *
1855 1855
 	 * @return void
1856 1856
 	 */
1857
-	public function update_key( $user_id ) {
1858
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1857
+	public function update_key($user_id) {
1858
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1859 1859
 
1860
-			$user = get_userdata( $user_id );
1860
+			$user = get_userdata($user_id);
1861 1861
 
1862
-			$public_key = $this->get_user_public_key( $user_id );
1863
-			$secret_key = $this->get_user_secret_key( $user_id );
1862
+			$public_key = $this->get_user_public_key($user_id);
1863
+			$secret_key = $this->get_user_secret_key($user_id);
1864 1864
 
1865
-			if ( empty( $public_key ) ) {
1866
-				$new_public_key = $this->generate_public_key( $user->user_email );
1867
-				$new_secret_key = $this->generate_private_key( $user->ID );
1865
+			if (empty($public_key)) {
1866
+				$new_public_key = $this->generate_public_key($user->user_email);
1867
+				$new_secret_key = $this->generate_private_key($user->ID);
1868 1868
 
1869
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1870
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1869
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1870
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1871 1871
 			} else {
1872
-				$this->revoke_api_key( $user_id );
1872
+				$this->revoke_api_key($user_id);
1873 1873
 			}
1874 1874
 		}
1875 1875
 	}
@@ -1884,9 +1884,9 @@  discard block
 block discarded – undo
1884 1884
 	 *
1885 1885
 	 * @return string
1886 1886
 	 */
1887
-	private function generate_public_key( $user_email = '' ) {
1888
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1889
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1887
+	private function generate_public_key($user_email = '') {
1888
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1889
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1890 1890
 
1891 1891
 		return $public;
1892 1892
 	}
@@ -1901,9 +1901,9 @@  discard block
 block discarded – undo
1901 1901
 	 *
1902 1902
 	 * @return string
1903 1903
 	 */
1904
-	private function generate_private_key( $user_id = 0 ) {
1905
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1906
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1904
+	private function generate_private_key($user_id = 0) {
1905
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1906
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1907 1907
 
1908 1908
 		return $secret;
1909 1909
 	}
@@ -1918,8 +1918,8 @@  discard block
 block discarded – undo
1918 1918
 	 *
1919 1919
 	 * @return string
1920 1920
 	 */
1921
-	public function get_token( $user_id = 0 ) {
1922
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
1921
+	public function get_token($user_id = 0) {
1922
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
1923 1923
 	}
1924 1924
 
1925 1925
 	/**
@@ -1933,9 +1933,9 @@  discard block
 block discarded – undo
1933 1933
 
1934 1934
 		// Default sales return
1935 1935
 		$sales                               = array();
1936
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
1937
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
1938
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
1936
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
1937
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
1938
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
1939 1939
 		$sales['donations']['totals']        = give_get_total_sales();
1940 1940
 
1941 1941
 		return $sales;
@@ -1952,9 +1952,9 @@  discard block
 block discarded – undo
1952 1952
 
1953 1953
 		// Default earnings return
1954 1954
 		$earnings                              = array();
1955
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
1956
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
1957
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
1955
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
1956
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
1957
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
1958 1958
 		$earnings['earnings']['totals']        = give_get_total_earnings();
1959 1959
 
1960 1960
 		return $earnings;
@@ -1974,25 +1974,25 @@  discard block
 block discarded – undo
1974 1974
 	 *
1975 1975
 	 * @return string            The API key/secret for the user supplied
1976 1976
 	 */
1977
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
1977
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
1978 1978
 
1979
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
1979
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
1980 1980
 			return $check;
1981 1981
 		}
1982 1982
 
1983 1983
 		$return = $check;
1984 1984
 
1985
-		switch ( $meta_key ) {
1985
+		switch ($meta_key) {
1986 1986
 			case 'give_user_public_key':
1987
-				$return = Give()->api->get_user_public_key( $object_id );
1987
+				$return = Give()->api->get_user_public_key($object_id);
1988 1988
 				break;
1989 1989
 			case 'give_user_secret_key':
1990
-				$return = Give()->api->get_user_secret_key( $object_id );
1990
+				$return = Give()->api->get_user_secret_key($object_id);
1991 1991
 				break;
1992 1992
 		}
1993 1993
 
1994
-		if ( ! $single ) {
1995
-			$return = array( $return );
1994
+		if ( ! $single) {
1995
+			$return = array($return);
1996 1996
 		}
1997 1997
 
1998 1998
 		return $return;
Please login to merge, or discard this patch.
includes/process-purchase.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @access      private
23 23
  * @since       1.0
24
- * @return      void
24
+ * @return      false|null
25 25
  */
26 26
 function give_process_purchase_form() {
27 27
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
  *
327 327
  * @since  1.0.1
328 328
  *
329
- * @param $payment_mode
329
+ * @param string $payment_mode
330 330
  *
331 331
  * @return mixed|void
332 332
  */
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1070,58 +1070,58 @@
 block discarded – undo
1070 1070
  * @return bool
1071 1071
  */
1072 1072
 function give_validate_multi_donation_form_level(  $valid_data, $data ) {
1073
-    /* @var Give_Donate_Form $form*/
1074
-    $form = new Give_Donate_Form( $data['give-form-id'] );
1073
+	/* @var Give_Donate_Form $form*/
1074
+	$form = new Give_Donate_Form( $data['give-form-id'] );
1075 1075
 
1076
-    $donation_level_matched = false;
1076
+	$donation_level_matched = false;
1077 1077
 
1078
-    if( $form->is_multi_type_donation_form() ) {
1078
+	if( $form->is_multi_type_donation_form() ) {
1079 1079
 
1080
-        // Bailout.
1081
-        if( ! ( $variable_prices = $form->get_prices() ) ) {
1082
-            return false;
1083
-        }
1080
+		// Bailout.
1081
+		if( ! ( $variable_prices = $form->get_prices() ) ) {
1082
+			return false;
1083
+		}
1084 1084
 
1085
-        // Sanitize donation amount.
1086
-        $data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1085
+		// Sanitize donation amount.
1086
+		$data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1087 1087
 
1088
-        // Get number of decimals.
1089
-        $default_decimals = give_get_price_decimals();
1088
+		// Get number of decimals.
1089
+		$default_decimals = give_get_price_decimals();
1090 1090
 
1091
-        if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){
1092
-            return true;
1093
-        }
1091
+		if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){
1092
+			return true;
1093
+		}
1094 1094
 
1095 1095
         
1096
-        // Find correct donation level from all donation levels.
1097
-        foreach ( $variable_prices as $variable_price ) {
1098
-            // Sanitize level amount.
1099
-            $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1100
-
1101
-            // Set first match donation level ID.
1102
-            if( $data['give-amount'] === $variable_price['_give_amount'] ) {
1103
-                $_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1104
-                $donation_level_matched = true;
1105
-                break;
1106
-            }
1107
-        }
1108
-
1109
-        // If donation amount is not find in donation levels then check if form has custom donation feature enable or not.
1110
-        // If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1111
-        if(
1112
-            ! $donation_level_matched
1113
-            && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) )
1114
-        ) {
1115
-            // Sanitize custom minimum amount.
1116
-            $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1117
-
1118
-            if( $data['give-amount'] >= $custom_minimum_amount ) {
1119
-                $_POST['give-price-id'] = 'custom';
1120
-                $donation_level_matched  = true;
1121
-            }
1122
-        }
1123
-    }
1124
-
1125
-    return ( $donation_level_matched ? true : false );
1096
+		// Find correct donation level from all donation levels.
1097
+		foreach ( $variable_prices as $variable_price ) {
1098
+			// Sanitize level amount.
1099
+			$variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1100
+
1101
+			// Set first match donation level ID.
1102
+			if( $data['give-amount'] === $variable_price['_give_amount'] ) {
1103
+				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1104
+				$donation_level_matched = true;
1105
+				break;
1106
+			}
1107
+		}
1108
+
1109
+		// If donation amount is not find in donation levels then check if form has custom donation feature enable or not.
1110
+		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1111
+		if(
1112
+			! $donation_level_matched
1113
+			&& ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) )
1114
+		) {
1115
+			// Sanitize custom minimum amount.
1116
+			$custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1117
+
1118
+			if( $data['give-amount'] >= $custom_minimum_amount ) {
1119
+				$_POST['give-price-id'] = 'custom';
1120
+				$donation_level_matched  = true;
1121
+			}
1122
+		}
1123
+	}
1124
+
1125
+	return ( $donation_level_matched ? true : false );
1126 1126
 }
1127 1127
 add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1128 1128
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +250 added lines, -250 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
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_purchase' );
33
+	do_action('give_pre_process_purchase');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_purchase_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array      $_POST      Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_purchase_form_user( $valid_data );
58
+	$user = give_get_purchase_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_checkout_errors' );
67
+			do_action('give_ajax_checkout_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	//If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	//After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		//Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address']
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';
103
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
103
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
104 104
 
105 105
 	// Setup donation information
106 106
 	$purchase_data = array(
107 107
 		'price'        => $price,
108 108
 		'purchase_key' => $purchase_key,
109 109
 		'user_email'   => $user['user_email'],
110
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
111
-		'user_info'    => stripslashes_deep( $user_info ),
110
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
111
+		'user_info'    => stripslashes_deep($user_info),
112 112
 		'post_data'    => $_POST,
113 113
 		'gateway'      => $valid_data['gateway'],
114 114
 		'card_info'    => $valid_data['cc_info']
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 	 * @param array      $user_info  Array containing basic user information.
129 129
 	 * @param bool|array $valid_data Validate fields.
130 130
 	 */
131
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
131
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
132 132
 
133 133
 	//Sanity check for price
134
-	if ( ! $purchase_data['price'] ) {
134
+	if ( ! $purchase_data['price']) {
135 135
 		// Revert to manual
136 136
 		$purchase_data['gateway'] = 'manual';
137 137
 		$_POST['give-gateway']    = 'manual';
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @since 1.7
144 144
 	 */
145
-	$purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data );
145
+	$purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data);
146 146
 
147 147
 	// Setup the data we're storing in the donation session
148 148
 	$session_data = $purchase_data;
149 149
 
150 150
 	// Make sure credit card numbers are never stored in sessions
151
-	unset( $session_data['card_info']['card_number'] );
152
-	unset( $session_data['post_data']['card_number'] );
151
+	unset($session_data['card_info']['card_number']);
152
+	unset($session_data['post_data']['card_number']);
153 153
 
154 154
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
155
-	give_set_purchase_session( $session_data );
155
+	give_set_purchase_session($session_data);
156 156
 
157 157
 	// Send info to the gateway for payment processing
158
-	give_send_to_gateway( $purchase_data['gateway'], $purchase_data );
158
+	give_send_to_gateway($purchase_data['gateway'], $purchase_data);
159 159
 	give_die();
160 160
 
161 161
 }
162 162
 
163
-add_action( 'give_purchase', 'give_process_purchase_form' );
164
-add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' );
163
+add_action('give_purchase', 'give_process_purchase_form');
164
+add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form');
165
+add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form');
166 166
 
167 167
 /**
168 168
  * Process the checkout login form
@@ -173,37 +173,37 @@  discard block
 block discarded – undo
173 173
  */
174 174
 function give_process_form_login() {
175 175
 
176
-	$is_ajax = isset( $_POST['give_ajax'] );
176
+	$is_ajax = isset($_POST['give_ajax']);
177 177
 
178 178
 	$user_data = give_purchase_form_validate_user_login();
179 179
 
180
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
181
-		if ( $is_ajax ) {
180
+	if (give_get_errors() || $user_data['user_id'] < 1) {
181
+		if ($is_ajax) {
182 182
 			/**
183 183
 			 * Fires when AJAX sends back errors from the donation form.
184 184
 			 *
185 185
 			 * @since 1.0
186 186
 			 */
187
-			do_action( 'give_ajax_checkout_errors' );
187
+			do_action('give_ajax_checkout_errors');
188 188
 			give_die();
189 189
 		} else {
190
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
190
+			wp_redirect($_SERVER['HTTP_REFERER']);
191 191
 			exit;
192 192
 		}
193 193
 	}
194 194
 
195
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
195
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
196 196
 
197
-	if ( $is_ajax ) {
197
+	if ($is_ajax) {
198 198
 		echo 'success';
199 199
 		give_die();
200 200
 	} else {
201
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
201
+		wp_redirect($_SERVER['HTTP_REFERER']);
202 202
 	}
203 203
 }
204 204
 
205
-add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' );
206
-add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' );
205
+add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login');
206
+add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login');
207 207
 
208 208
 /**
209 209
  * Donation Form Validate Fields
@@ -215,45 +215,45 @@  discard block
 block discarded – undo
215 215
 function give_purchase_form_validate_fields() {
216 216
 
217 217
 	// Check if there is $_POST
218
-	if ( empty( $_POST ) ) {
218
+	if (empty($_POST)) {
219 219
 		return false;
220 220
 	}
221 221
 
222
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
222
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
223 223
 
224 224
 	// Start an array to collect valid data
225 225
 	$valid_data = array(
226 226
 		'gateway'          => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here)
227
-		'need_new_user'    => false,     // New user flag
228
-		'need_user_login'  => false,     // Login user flag
229
-		'logged_user_data' => array(),   // Logged user collected data
230
-		'new_user_data'    => array(),   // New user collected data
231
-		'login_user_data'  => array(),   // Login user collected data
232
-		'guest_user_data'  => array(),   // Guest user collected data
227
+		'need_new_user'    => false, // New user flag
228
+		'need_user_login'  => false, // Login user flag
229
+		'logged_user_data' => array(), // Logged user collected data
230
+		'new_user_data'    => array(), // New user collected data
231
+		'login_user_data'  => array(), // Login user collected data
232
+		'guest_user_data'  => array(), // Guest user collected data
233 233
 		'cc_info'          => give_purchase_form_validate_cc()    // Credit card info
234 234
 	);
235 235
 
236 236
 	//Validate Honeypot First
237
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
238
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
237
+	if ( ! empty($_POST['give-honeypot'])) {
238
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
239 239
 	}
240 240
 
241 241
 	// Validate agree to terms
242
-	$terms_option = get_post_meta( $form_id, '_give_terms_option', true );
243
-	if ( isset( $terms_option ) && $terms_option === 'yes' ) {
242
+	$terms_option = get_post_meta($form_id, '_give_terms_option', true);
243
+	if (isset($terms_option) && $terms_option === 'yes') {
244 244
 		give_purchase_form_validate_agree_to_terms();
245 245
 	}
246 246
 
247
-	if ( is_user_logged_in() ) {
247
+	if (is_user_logged_in()) {
248 248
 		// Collect logged in user data
249 249
 		$valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();
250
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
250
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
251 251
 		// Set new user registration as required
252 252
 		$valid_data['need_new_user'] = true;
253 253
 		// Validate new user data
254 254
 		$valid_data['new_user_data'] = give_purchase_form_validate_new_user();
255 255
 		// Check if login validation is needed
256
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
256
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
257 257
 		// Set user login as required
258 258
 		$valid_data['need_user_login'] = true;
259 259
 		// Validate users login info
@@ -278,41 +278,41 @@  discard block
 block discarded – undo
278 278
  */
279 279
 function give_purchase_form_validate_gateway() {
280 280
 
281
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
282
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
283
-	$gateway = give_get_default_gateway( $form_id );
281
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
282
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
283
+	$gateway = give_get_default_gateway($form_id);
284 284
 
285 285
 	// Check if a gateway value is present
286
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
286
+	if ( ! empty($_REQUEST['give-gateway'])) {
287 287
 
288
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
288
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
289 289
 
290 290
 		//Is amount being donated in LIVE mode 0.00? If so, error:
291
-		if ( $amount == 0 && ! give_is_test_mode() ) {
291
+		if ($amount == 0 && ! give_is_test_mode()) {
292 292
 
293
-			give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) );
293
+			give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
294 294
 
295 295
 		} //Check for a minimum custom amount
296
-		elseif ( ! give_verify_minimum_price() ) {
296
+		elseif ( ! give_verify_minimum_price()) {
297 297
 
298 298
 			give_set_error(
299 299
 				'invalid_donation_minimum',
300 300
 				sprintf(
301 301
 					/* translators: %s: minimum donation amount */
302
-					esc_html__( 'This form has a minimum donation amount of %s.', 'give' ),
303
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
302
+					esc_html__('This form has a minimum donation amount of %s.', 'give'),
303
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
304 304
 				)
305 305
 			);
306 306
 
307 307
 		} //Is this test mode zero donation? Let it through but set to manual gateway
308
-		elseif ( $amount == 0 && give_is_test_mode() ) {
308
+		elseif ($amount == 0 && give_is_test_mode()) {
309 309
 
310 310
 			$gateway = 'manual';
311 311
 
312 312
 		} //Check if this gateway is active
313
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
313
+		elseif ( ! give_is_gateway_active($gateway)) {
314 314
 
315
-			give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) );
315
+			give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
316 316
 
317 317
 		}
318 318
 
@@ -331,23 +331,23 @@  discard block
 block discarded – undo
331 331
  */
332 332
 function give_verify_minimum_price() {
333 333
 
334
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
335
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
336
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;
337
-	$variable_prices = give_has_variable_prices( $form_id );
334
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
335
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
336
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
337
+	$variable_prices = give_has_variable_prices($form_id);
338 338
 
339
-	if ( $variable_prices && ! empty( $price_id ) ) {
339
+	if ($variable_prices && ! empty($price_id)) {
340 340
 
341
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
341
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
342 342
 
343
-		if ( $price_level_amount == $amount ) {
343
+		if ($price_level_amount == $amount) {
344 344
 			return true;
345 345
 		}
346 346
 	}
347 347
 
348
-	$minimum = give_get_form_minimum_price( $form_id );
348
+	$minimum = give_get_form_minimum_price($form_id);
349 349
 
350
-	if ( $minimum > $amount ) {
350
+	if ($minimum > $amount) {
351 351
 		return false;
352 352
 	}
353 353
 
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
  */
364 364
 function give_purchase_form_validate_agree_to_terms() {
365 365
 	// Validate agree to terms
366
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
366
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
367 367
 		// User did not agree
368
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms of use.', 'give' ) ) );
368
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms of use.', 'give')));
369 369
 	}
370 370
 }
371 371
 
@@ -379,43 +379,43 @@  discard block
 block discarded – undo
379 379
  *
380 380
  * @return      array
381 381
  */
382
-function give_purchase_form_required_fields( $form_id ) {
382
+function give_purchase_form_required_fields($form_id) {
383 383
 
384
-	$payment_mode = give_get_chosen_gateway( $form_id );
384
+	$payment_mode = give_get_chosen_gateway($form_id);
385 385
 
386 386
 	$required_fields = array(
387 387
 		'give_email' => array(
388 388
 			'error_id'      => 'invalid_email',
389
-			'error_message' => esc_html__( 'Please enter a valid email address.', 'give' )
389
+			'error_message' => esc_html__('Please enter a valid email address.', 'give')
390 390
 		),
391 391
 		'give_first' => array(
392 392
 			'error_id'      => 'invalid_first_name',
393
-			'error_message' => esc_html__( 'Please enter your first name.', 'give' )
393
+			'error_message' => esc_html__('Please enter your first name.', 'give')
394 394
 		)
395 395
 	);
396 396
 
397
-	$require_address = give_require_billing_address( $payment_mode );
397
+	$require_address = give_require_billing_address($payment_mode);
398 398
 
399
-	if ( $require_address ) {
400
-		$required_fields['card_address']    = array(
399
+	if ($require_address) {
400
+		$required_fields['card_address'] = array(
401 401
 			'error_id'      => 'invalid_card_address',
402
-			'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' )
402
+			'error_message' => esc_html__('Please enter your primary billing address.', 'give')
403 403
 		);
404
-		$required_fields['card_zip']        = array(
404
+		$required_fields['card_zip'] = array(
405 405
 			'error_id'      => 'invalid_zip_code',
406
-			'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' )
406
+			'error_message' => esc_html__('Please enter your zip / postal code.', 'give')
407 407
 		);
408
-		$required_fields['card_city']       = array(
408
+		$required_fields['card_city'] = array(
409 409
 			'error_id'      => 'invalid_city',
410
-			'error_message' => esc_html__( 'Please enter your billing city.', 'give' )
410
+			'error_message' => esc_html__('Please enter your billing city.', 'give')
411 411
 		);
412 412
 		$required_fields['billing_country'] = array(
413 413
 			'error_id'      => 'invalid_country',
414
-			'error_message' => esc_html__( 'Please select your billing country.', 'give' )
414
+			'error_message' => esc_html__('Please select your billing country.', 'give')
415 415
 		);
416
-		$required_fields['card_state']      = array(
416
+		$required_fields['card_state'] = array(
417 417
 			'error_id'      => 'invalid_state',
418
-			'error_message' => esc_html__( 'Please enter billing state / province.', 'give' )
418
+			'error_message' => esc_html__('Please enter billing state / province.', 'give')
419 419
 		);
420 420
 	}
421 421
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 	 *
425 425
 	 * @since 1.7
426 426
 	 */
427
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
427
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
428 428
 
429 429
 	return $required_fields;
430 430
 
@@ -439,16 +439,16 @@  discard block
 block discarded – undo
439 439
  *
440 440
  * @return mixed|void
441 441
  */
442
-function give_require_billing_address( $payment_mode ) {
442
+function give_require_billing_address($payment_mode) {
443 443
 
444 444
 	$return = false;
445 445
 
446
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
446
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
447 447
 		$return = true;
448 448
 	}
449 449
 
450 450
 	// Let payment gateways and other extensions determine if address fields should be required
451
-	return apply_filters( 'give_require_billing_address', $return );
451
+	return apply_filters('give_require_billing_address', $return);
452 452
 
453 453
 }
454 454
 
@@ -462,43 +462,43 @@  discard block
 block discarded – undo
462 462
 function give_purchase_form_validate_logged_in_user() {
463 463
 	global $user_ID;
464 464
 
465
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
465
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
466 466
 
467 467
 	// Start empty array to collect valid user data
468 468
 	$valid_user_data = array(
469 469
 		// Assume there will be errors
470
-		'user_id' => - 1
470
+		'user_id' => -1
471 471
 	);
472 472
 
473 473
 	// Verify there is a user_ID
474
-	if ( $user_ID > 0 ) {
474
+	if ($user_ID > 0) {
475 475
 		// Get the logged in user data
476
-		$user_data = get_userdata( $user_ID );
476
+		$user_data = get_userdata($user_ID);
477 477
 
478 478
 		// Loop through required fields and show error messages
479
-		foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
480
-			if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
481
-				give_set_error( $value['error_id'], $value['error_message'] );
479
+		foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
480
+			if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
481
+				give_set_error($value['error_id'], $value['error_message']);
482 482
 			}
483 483
 		}
484 484
 
485 485
 		// Verify data
486
-		if ( $user_data ) {
486
+		if ($user_data) {
487 487
 			// Collected logged in user data
488 488
 			$valid_user_data = array(
489 489
 				'user_id'    => $user_ID,
490
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
491
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
492
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
490
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
491
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
492
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
493 493
 			);
494 494
 
495
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
496
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
495
+			if ( ! is_email($valid_user_data['user_email'])) {
496
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
497 497
 			}
498 498
 
499 499
 		} else {
500 500
 			// Set invalid user error
501
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
501
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
502 502
 		}
503 503
 	}
504 504
 
@@ -516,90 +516,90 @@  discard block
 block discarded – undo
516 516
 function give_purchase_form_validate_new_user() {
517 517
 
518 518
 	$registering_new_user = false;
519
-	$form_id              = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
519
+	$form_id              = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
520 520
 
521 521
 	// Start an empty array to collect valid user data
522 522
 	$valid_user_data = array(
523 523
 		// Assume there will be errors
524
-		'user_id'    => - 1,
524
+		'user_id'    => -1,
525 525
 		// Get first name
526
-		'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '',
526
+		'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '',
527 527
 		// Get last name
528
-		'user_last'  => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '',
528
+		'user_last'  => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '',
529 529
 	);
530 530
 
531 531
 	// Check the new user's credentials against existing ones
532
-	$user_login   = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false;
533
-	$user_email   = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false;
534
-	$user_pass    = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false;
535
-	$pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false;
532
+	$user_login   = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false;
533
+	$user_email   = isset($_POST['give_email']) ? trim($_POST['give_email']) : false;
534
+	$user_pass    = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false;
535
+	$pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false;
536 536
 
537 537
 	// Loop through required fields and show error messages
538
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
539
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
540
-			give_set_error( $value['error_id'], $value['error_message'] );
538
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
539
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
540
+			give_set_error($value['error_id'], $value['error_message']);
541 541
 		}
542 542
 	}
543 543
 
544 544
 	// Check if we have an username to register
545
-	if ( $user_login && strlen( $user_login ) > 0 ) {
545
+	if ($user_login && strlen($user_login) > 0) {
546 546
 		$registering_new_user = true;
547 547
 
548 548
 		// We have an user name, check if it already exists
549
-		if ( username_exists( $user_login ) ) {
549
+		if (username_exists($user_login)) {
550 550
 			// Username already registered
551
-			give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
551
+			give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
552 552
 			// Check if it's valid
553
-		} else if ( ! give_validate_username( $user_login ) ) {
553
+		} else if ( ! give_validate_username($user_login)) {
554 554
 			// Invalid username
555
-			if ( is_multisite() ) {
556
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
555
+			if (is_multisite()) {
556
+				give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
557 557
 			} else {
558
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
558
+				give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
559 559
 			}
560 560
 		} else {
561 561
 			// All the checks have run and it's good to go
562 562
 			$valid_user_data['user_login'] = $user_login;
563 563
 		}
564
-	} elseif ( give_logged_in_only( $form_id ) ) {
565
-		give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
564
+	} elseif (give_logged_in_only($form_id)) {
565
+		give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give'));
566 566
 	}
567 567
 
568 568
 	// Check if we have an email to verify
569
-	if ( $user_email && strlen( $user_email ) > 0 ) {
569
+	if ($user_email && strlen($user_email) > 0) {
570 570
 		// Validate email
571
-		if ( ! is_email( $user_email ) ) {
572
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
571
+		if ( ! is_email($user_email)) {
572
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
573 573
 			// Check if email exists
574
-		} else if ( email_exists( $user_email ) && $registering_new_user ) {
575
-			give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) );
574
+		} else if (email_exists($user_email) && $registering_new_user) {
575
+			give_set_error('email_used', esc_html__('The email already active for another user.', 'give'));
576 576
 		} else {
577 577
 			// All the checks have run and it's good to go
578 578
 			$valid_user_data['user_email'] = $user_email;
579 579
 		}
580 580
 	} else {
581 581
 		// No email
582
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
582
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
583 583
 	}
584 584
 
585 585
 	// Check password
586
-	if ( $user_pass && $pass_confirm ) {
586
+	if ($user_pass && $pass_confirm) {
587 587
 		// Verify confirmation matches
588
-		if ( $user_pass != $pass_confirm ) {
588
+		if ($user_pass != $pass_confirm) {
589 589
 			// Passwords do not match
590
-			give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
590
+			give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
591 591
 		} else {
592 592
 			// All is good to go
593 593
 			$valid_user_data['user_pass'] = $user_pass;
594 594
 		}
595 595
 	} else {
596 596
 		// Password or confirmation missing
597
-		if ( ! $user_pass && $registering_new_user ) {
597
+		if ( ! $user_pass && $registering_new_user) {
598 598
 			// The password is invalid
599
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
600
-		} else if ( ! $pass_confirm && $registering_new_user ) {
599
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
600
+		} else if ( ! $pass_confirm && $registering_new_user) {
601 601
 			// Confirmation password is invalid
602
-			give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) );
602
+			give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give'));
603 603
 		}
604 604
 	}
605 605
 
@@ -618,36 +618,36 @@  discard block
 block discarded – undo
618 618
 	// Start an array to collect valid user data
619 619
 	$valid_user_data = array(
620 620
 		// Assume there will be errors
621
-		'user_id' => - 1
621
+		'user_id' => -1
622 622
 	);
623 623
 
624 624
 	// Username
625
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
626
-		give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
625
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
626
+		give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give'));
627 627
 
628 628
 		return $valid_user_data;
629 629
 	}
630 630
 
631 631
 	// Get the user by login
632
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
632
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
633 633
 
634 634
 	// Check if user exists
635
-	if ( $user_data ) {
635
+	if ($user_data) {
636 636
 		// Get password
637
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
637
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
638 638
 
639 639
 		// Check user_pass
640
-		if ( $user_pass ) {
640
+		if ($user_pass) {
641 641
 			// Check if password is valid
642
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
642
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
643 643
 				// Incorrect password
644 644
 				give_set_error(
645 645
 					'password_incorrect',
646 646
 					sprintf(
647 647
 						'%1$s <a href="%2$s">%3$s</a>',
648
-						esc_html__( 'The password you entered is incorrect.', 'give' ),
649
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
650
-						esc_html__( 'Reset Password', 'give' )
648
+						esc_html__('The password you entered is incorrect.', 'give'),
649
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
650
+						esc_html__('Reset Password', 'give')
651 651
 					)
652 652
 				);
653 653
 				// All is correct
@@ -664,11 +664,11 @@  discard block
 block discarded – undo
664 664
 			}
665 665
 		} else {
666 666
 			// Empty password
667
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
667
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
668 668
 		}
669 669
 	} else {
670 670
 		// no username
671
-		give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
671
+		give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
672 672
 	}
673 673
 
674 674
 	return $valid_user_data;
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
  */
684 684
 function give_purchase_form_validate_guest_user() {
685 685
 
686
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
686
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
687 687
 
688 688
 	// Start an array to collect valid user data
689 689
 	$valid_user_data = array(
@@ -692,32 +692,32 @@  discard block
 block discarded – undo
692 692
 	);
693 693
 
694 694
 	// Show error message if user must be logged in
695
-	if ( give_logged_in_only( $form_id ) ) {
696
-		give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) );
695
+	if (give_logged_in_only($form_id)) {
696
+		give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give'));
697 697
 	}
698 698
 
699 699
 	// Get the guest email
700
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
700
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
701 701
 
702 702
 	// Check email
703
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
703
+	if ($guest_email && strlen($guest_email) > 0) {
704 704
 		// Validate email
705
-		if ( ! is_email( $guest_email ) ) {
705
+		if ( ! is_email($guest_email)) {
706 706
 			// Invalid email
707
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
707
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
708 708
 		} else {
709 709
 			// All is good to go
710 710
 			$valid_user_data['user_email'] = $guest_email;
711 711
 		}
712 712
 	} else {
713 713
 		// No email
714
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
714
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
715 715
 	}
716 716
 
717 717
 	// Loop through required fields and show error messages
718
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
719
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
720
-			give_set_error( $value['error_id'], $value['error_message'] );
718
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
719
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
720
+			give_set_error($value['error_id'], $value['error_message']);
721 721
 		}
722 722
 	}
723 723
 
@@ -733,36 +733,36 @@  discard block
 block discarded – undo
733 733
  * @since   1.0
734 734
  * @return  integer
735 735
  */
736
-function give_register_and_login_new_user( $user_data = array() ) {
736
+function give_register_and_login_new_user($user_data = array()) {
737 737
 	// Verify the array
738
-	if ( empty( $user_data ) ) {
739
-		return - 1;
738
+	if (empty($user_data)) {
739
+		return -1;
740 740
 	}
741 741
 
742
-	if ( give_get_errors() ) {
743
-		return - 1;
742
+	if (give_get_errors()) {
743
+		return -1;
744 744
 	}
745 745
 
746
-	$user_args = apply_filters( 'give_insert_user_args', array(
747
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
748
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
749
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
750
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
751
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
752
-		'user_registered' => date( 'Y-m-d H:i:s' ),
753
-		'role'            => get_option( 'default_role' )
754
-	), $user_data );
746
+	$user_args = apply_filters('give_insert_user_args', array(
747
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
748
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
749
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
750
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
751
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
752
+		'user_registered' => date('Y-m-d H:i:s'),
753
+		'role'            => get_option('default_role')
754
+	), $user_data);
755 755
 
756 756
 	// Insert new user
757
-	$user_id = wp_insert_user( $user_args );
757
+	$user_id = wp_insert_user($user_args);
758 758
 
759 759
 	// Validate inserted user
760
-	if ( is_wp_error( $user_id ) ) {
761
-		return - 1;
760
+	if (is_wp_error($user_id)) {
761
+		return -1;
762 762
 	}
763 763
 
764 764
 	// Allow themes and plugins to filter the user data
765
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
765
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
766 766
 
767 767
 	/**
768 768
 	 * Fires after inserting user.
@@ -772,10 +772,10 @@  discard block
 block discarded – undo
772 772
 	 * @param int   $user_id   User id.
773 773
 	 * @param array $user_data Array containing user data.
774 774
 	 */
775
-	do_action( 'give_insert_user', $user_id, $user_data );
775
+	do_action('give_insert_user', $user_id, $user_data);
776 776
 
777 777
 	// Login new user
778
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
778
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
779 779
 
780 780
 	// Return user id
781 781
 	return $user_id;
@@ -790,27 +790,27 @@  discard block
 block discarded – undo
790 790
  * @since   1.0
791 791
  * @return  array
792 792
  */
793
-function give_get_purchase_form_user( $valid_data = array() ) {
793
+function give_get_purchase_form_user($valid_data = array()) {
794 794
 
795 795
 	// Initialize user
796 796
 	$user    = false;
797
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
797
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
798 798
 
799
-	if ( $is_ajax ) {
799
+	if ($is_ajax) {
800 800
 		// Do not create or login the user during the ajax submission (check for errors only)
801 801
 		return true;
802
-	} else if ( is_user_logged_in() ) {
802
+	} else if (is_user_logged_in()) {
803 803
 		// Set the valid user as the logged in collected data
804 804
 		$user = $valid_data['logged_in_user'];
805
-	} else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
805
+	} else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
806 806
 		// New user registration
807
-		if ( $valid_data['need_new_user'] === true ) {
807
+		if ($valid_data['need_new_user'] === true) {
808 808
 			// Set user
809 809
 			$user = $valid_data['new_user_data'];
810 810
 			// Register and login new user
811
-			$user['user_id'] = give_register_and_login_new_user( $user );
811
+			$user['user_id'] = give_register_and_login_new_user($user);
812 812
 			// User login
813
-		} else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
813
+		} else if ($valid_data['need_user_login'] === true && ! $is_ajax) {
814 814
 
815 815
 			/*
816 816
 			 * The login form is now processed in the give_process_purchase_login() function.
@@ -825,48 +825,48 @@  discard block
 block discarded – undo
825 825
 			// Set user
826 826
 			$user = $valid_data['login_user_data'];
827 827
 			// Login user
828
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
828
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
829 829
 		}
830 830
 	}
831 831
 
832 832
 	// Check guest checkout
833
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
833
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
834 834
 		// Set user
835 835
 		$user = $valid_data['guest_user_data'];
836 836
 	}
837 837
 
838 838
 	// Verify we have an user
839
-	if ( false === $user || empty( $user ) ) {
839
+	if (false === $user || empty($user)) {
840 840
 		// Return false
841 841
 		return false;
842 842
 	}
843 843
 
844 844
 	// Get user first name
845
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
846
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
845
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
846
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
847 847
 	}
848 848
 
849 849
 	// Get user last name
850
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
851
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
850
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
851
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
852 852
 	}
853 853
 
854 854
 	// Get the user's billing address details
855 855
 	$user['address']            = array();
856
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
857
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
858
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
859
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
860
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
861
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
862
-
863
-	if ( empty( $user['address']['country'] ) ) {
856
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
857
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
858
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
859
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
860
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
861
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
862
+
863
+	if (empty($user['address']['country'])) {
864 864
 		$user['address'] = false;
865 865
 	} // Country will always be set if address fields are present
866 866
 
867
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
867
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
868 868
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return purchases
869
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
869
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
870 870
 	}
871 871
 
872 872
 	// Return valid user
@@ -885,16 +885,16 @@  discard block
 block discarded – undo
885 885
 	$card_data = give_get_purchase_cc_info();
886 886
 
887 887
 	// Validate the card zip
888
-	if ( ! empty( $card_data['card_zip'] ) ) {
889
-		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
890
-			give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
888
+	if ( ! empty($card_data['card_zip'])) {
889
+		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
890
+			give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give'));
891 891
 		}
892 892
 	}
893 893
 
894 894
 	//Ensure no spaces
895
-	if ( ! empty( $card_data['card_number'] ) ) {
896
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs
897
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
895
+	if ( ! empty($card_data['card_number'])) {
896
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs
897
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
898 898
 	}
899 899
 
900 900
 	// This should validate card numbers at some point too
@@ -910,17 +910,17 @@  discard block
 block discarded – undo
910 910
  */
911 911
 function give_get_purchase_cc_info() {
912 912
 	$cc_info                   = array();
913
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
914
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
915
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
916
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
917
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
918
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
919
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
920
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
921
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
922
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
923
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
913
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
914
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
915
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
916
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
917
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
918
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
919
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
920
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
921
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
922
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
923
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
924 924
 
925 925
 	// Return cc info
926 926
 	return $cc_info;
@@ -936,14 +936,14 @@  discard block
 block discarded – undo
936 936
  *
937 937
  * @return bool|mixed|void
938 938
  */
939
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
939
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
940 940
 	$ret = false;
941 941
 
942
-	if ( empty( $zip ) || empty( $country_code ) ) {
942
+	if (empty($zip) || empty($country_code)) {
943 943
 		return $ret;
944 944
 	}
945 945
 
946
-	$country_code = strtoupper( $country_code );
946
+	$country_code = strtoupper($country_code);
947 947
 
948 948
 	$zip_regex = array(
949 949
 		"AD" => "AD\d{3}",
@@ -1103,11 +1103,11 @@  discard block
 block discarded – undo
1103 1103
 		"ZM" => "\d{5}"
1104 1104
 	);
1105 1105
 
1106
-	if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) {
1106
+	if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) {
1107 1107
 		$ret = true;
1108 1108
 	}
1109 1109
 
1110
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1110
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1111 1111
 }
1112 1112
 
1113 1113
 
@@ -1121,37 +1121,37 @@  discard block
 block discarded – undo
1121 1121
  *
1122 1122
  * @return bool
1123 1123
  */
1124
-function give_validate_multi_donation_form_level(  $valid_data, $data ) {
1124
+function give_validate_multi_donation_form_level($valid_data, $data) {
1125 1125
     /* @var Give_Donate_Form $form*/
1126
-    $form = new Give_Donate_Form( $data['give-form-id'] );
1126
+    $form = new Give_Donate_Form($data['give-form-id']);
1127 1127
 
1128 1128
     $donation_level_matched = false;
1129 1129
 
1130
-    if( $form->is_multi_type_donation_form() ) {
1130
+    if ($form->is_multi_type_donation_form()) {
1131 1131
 
1132 1132
         // Bailout.
1133
-        if( ! ( $variable_prices = $form->get_prices() ) ) {
1133
+        if ( ! ($variable_prices = $form->get_prices())) {
1134 1134
             return false;
1135 1135
         }
1136 1136
 
1137 1137
         // Sanitize donation amount.
1138
-        $data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1138
+        $data['give-amount'] = give_sanitize_amount($data['give-amount']);
1139 1139
 
1140 1140
         // Get number of decimals.
1141 1141
         $default_decimals = give_get_price_decimals();
1142 1142
 
1143
-        if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){
1143
+        if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1144 1144
             return true;
1145 1145
         }
1146 1146
 
1147 1147
         
1148 1148
         // Find correct donation level from all donation levels.
1149
-        foreach ( $variable_prices as $variable_price ) {
1149
+        foreach ($variable_prices as $variable_price) {
1150 1150
             // Sanitize level amount.
1151
-            $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1151
+            $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1152 1152
 
1153 1153
             // Set first match donation level ID.
1154
-            if( $data['give-amount'] === $variable_price['_give_amount'] ) {
1154
+            if ($data['give-amount'] === $variable_price['_give_amount']) {
1155 1155
                 $_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1156 1156
                 $donation_level_matched = true;
1157 1157
                 break;
@@ -1160,20 +1160,20 @@  discard block
 block discarded – undo
1160 1160
 
1161 1161
         // If donation amount is not find in donation levels then check if form has custom donation feature enable or not.
1162 1162
         // If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1163
-        if(
1163
+        if (
1164 1164
             ! $donation_level_matched
1165
-            && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) )
1165
+            && ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true))
1166 1166
         ) {
1167 1167
             // Sanitize custom minimum amount.
1168
-            $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1168
+            $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1169 1169
 
1170
-            if( $data['give-amount'] >= $custom_minimum_amount ) {
1170
+            if ($data['give-amount'] >= $custom_minimum_amount) {
1171 1171
                 $_POST['give-price-id'] = 'custom';
1172
-                $donation_level_matched  = true;
1172
+                $donation_level_matched = true;
1173 1173
             }
1174 1174
         }
1175 1175
     }
1176 1176
 
1177
-    return ( $donation_level_matched ? true : false );
1177
+    return ($donation_level_matched ? true : false);
1178 1178
 }
1179
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1180 1179
\ No newline at end of file
1180
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
1181 1181
\ No newline at end of file
Please login to merge, or discard this patch.