Completed
Pull Request — master (#703)
by
unknown
17:23
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
 
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
 	public function give_admin_bar_menu() {
43 43
 		global $wp_admin_bar;
44 44
 
45
-		if ( ! give_is_test_mode() || ! current_user_can( 'view_give_reports' ) ) {
45
+		if ( ! give_is_test_mode() || ! current_user_can('view_give_reports')) {
46 46
 			return false;
47 47
 		}
48 48
 
49 49
 		//Add the main siteadmin menu item
50
-		$wp_admin_bar->add_menu( array(
50
+		$wp_admin_bar->add_menu(array(
51 51
 			'id'     => 'give-test-notice',
52
-			'href'   => admin_url() . 'edit.php?post_type=give_forms&page=give-settings&tab=gateways',
52
+			'href'   => admin_url().'edit.php?post_type=give_forms&page=give-settings&tab=gateways',
53 53
 			'parent' => 'top-secondary',
54
-			'title'  => __( 'Give Test Mode Active', 'give' ),
55
-			'meta'   => array( 'class' => 'give-test-mode-active' ),
56
-		) );
54
+			'title'  => __('Give Test Mode Active', 'give'),
55
+			'meta'   => array('class' => 'give-test-mode-active'),
56
+		));
57 57
 
58 58
 	}
59 59
 
@@ -68,97 +68,97 @@  discard block
 block discarded – undo
68 68
 			'error'   => array()
69 69
 		);
70 70
 
71
-		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
+		if ( ! give_test_ajax_works() && ! get_user_meta(get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true) && current_user_can('manage_give_settings')) {
72 72
 			echo '<div class="error">';
73
-			echo '<p>' . __( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>';
74
-			echo '<p>' . sprintf( esc_attr__( 'Please see %1$sthis reference%2$s for possible solutions.', 'give' ), '<a href="https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/" target="_blank">', '</a>' ) . '</p>';
75
-			echo '<p><a href="' . add_query_arg( array(
73
+			echo '<p>'.__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>';
74
+			echo '<p>'.sprintf(esc_attr__('Please see %1$sthis reference%2$s for possible solutions.', 'give'), '<a href="https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/" target="_blank">', '</a>').'</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 payment has been deleted.', 'give' );
89
+						$notices['updated']['give-payment-deleted'] = esc_attr__('The payment 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 payment note has been deleted.', 'give' );
98
+						$notices['updated']['give-payment-note-deleted'] = esc_attr__('The payment 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 successfully generated.', 'give' );
110
+						$notices['updated']['give-api-key-generated'] = esc_attr__('API keys successfully 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 successfully regenerated.', 'give' );
116
+						$notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys successfully regenerated.', 'give');
117 117
 						break;
118 118
 					case 'api-key-revoked' :
119
-						$notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys successfully revoked.', 'give' );
119
+						$notices['updated']['give-api-key-revoked'] = esc_attr__('API keys successfully 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 payment note has been added successfully.', 'give' );
130
+						$notices['updated']['give-note-added'] = esc_attr__('The payment note has been added successfully.', 'give');
131 131
 						break;
132 132
 					case 'payment-updated' :
133
-						$notices['updated']['give-payment-updated'] = esc_attr__( 'The payment has been successfully updated.', 'give' );
133
+						$notices['updated']['give-payment-updated'] = esc_attr__('The payment has been successfully 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__( 'Donor successfully deleted', 'give' );
142
+						$notices['updated']['give-customer-deleted'] = esc_attr__('Donor successfully 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' => __( 'API Key', 'give' ),     // Singular name of the listed records
55
-			'plural'   => __( 'API Keys', 'give' ),    // Plural name of the listed records
53
+		parent::__construct(array(
54
+			'singular' => __('API Key', 'give'), // Singular name of the listed records
55
+			'plural'   => __('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 readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['key'] ) . '"/>';
88
+	public function column_key($item) {
89
+		return '<input 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 readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['token'] ) . '"/>';
103
+	public function column_token($item) {
104
+		return '<input 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 readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['secret'] ) . '"/>';
118
+	public function column_secret($item) {
119
+		return '<input 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
-				__( 'View API Log', 'give' )
142
+				), 'edit.php')),
143
+				__('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
-			__( 'Reissue', 'give' )
153
+			)), 'give-api-nonce')),
154
+			__('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
-			__( 'Revoke', 'give' )
162
+			)), 'give-api-nonce')),
163
+			__('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'   => __( 'Username', 'give' ),
181
-			'key'    => __( 'Public Key', 'give' ),
182
-			'token'  => __( 'Token', 'give' ),
183
-			'secret' => __( 'Secret Key', 'give' )
180
+			'user'   => __('Username', 'give'),
181
+			'key'    => __('Public Key', 'give'),
182
+			'token'  => __('Token', 'give'),
183
+			'secret' => __('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( __( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?>
208
+		<?php submit_button(__('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.
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -13,328 +13,328 @@
 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(
180
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ),
181
-                    esc_html( $version_info->name ),
182
-                    esc_url( $changelog_link ),
183
-                    esc_html( $version_info->new_version )
184
-                );
185
-            } else {
186
-                printf(
187
-                    __( '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>.', 'edd' ),
188
-                    esc_html( $version_info->name ),
189
-                    esc_url( $changelog_link ),
190
-                    esc_html( $version_info->new_version ),
191
-                    esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
192
-                );
193
-            }
178
+			if ( empty( $version_info->download_link ) ) {
179
+				printf(
180
+					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ),
181
+					esc_html( $version_info->name ),
182
+					esc_url( $changelog_link ),
183
+					esc_html( $version_info->new_version )
184
+				);
185
+			} else {
186
+				printf(
187
+					__( '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>.', 'edd' ),
188
+					esc_html( $version_info->name ),
189
+					esc_url( $changelog_link ),
190
+					esc_html( $version_info->new_version ),
191
+					esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
192
+				);
193
+			}
194 194
 
195
-            echo '</div></td></tr>';
196
-        }
197
-    }
195
+			echo '</div></td></tr>';
196
+		}
197
+	}
198 198
 
199 199
 
200
-    /**
201
-     * Updates information on the "View version x.x details" page with custom data.
202
-     *
203
-     * @uses api_request()
204
-     *
205
-     * @param mixed   $_data
206
-     * @param string  $_action
207
-     * @param object  $_args
208
-     * @return object $_data
209
-     */
210
-    function plugins_api_filter( $_data, $_action = '', $_args = null ) {
200
+	/**
201
+	 * Updates information on the "View version x.x details" page with custom data.
202
+	 *
203
+	 * @uses api_request()
204
+	 *
205
+	 * @param mixed   $_data
206
+	 * @param string  $_action
207
+	 * @param object  $_args
208
+	 * @return object $_data
209
+	 */
210
+	function plugins_api_filter( $_data, $_action = '', $_args = null ) {
211 211
 
212 212
 
213
-        if ( $_action != 'plugin_information' ) {
213
+		if ( $_action != 'plugin_information' ) {
214 214
 
215
-            return $_data;
215
+			return $_data;
216 216
 
217
-        }
217
+		}
218 218
 
219
-        if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
219
+		if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
220 220
 
221
-            return $_data;
221
+			return $_data;
222 222
 
223
-        }
223
+		}
224 224
 
225
-        $to_send = array(
226
-            'slug'   => $this->slug,
227
-            'is_ssl' => is_ssl(),
228
-            'fields' => array(
229
-                'banners' => false, // These will be supported soon hopefully
230
-                'reviews' => false
231
-            )
232
-        );
225
+		$to_send = array(
226
+			'slug'   => $this->slug,
227
+			'is_ssl' => is_ssl(),
228
+			'fields' => array(
229
+				'banners' => false, // These will be supported soon hopefully
230
+				'reviews' => false
231
+			)
232
+		);
233 233
 
234
-        $api_response = $this->api_request( 'plugin_information', $to_send );
234
+		$api_response = $this->api_request( 'plugin_information', $to_send );
235 235
 
236
-        if ( false !== $api_response ) {
237
-            $_data = $api_response;
238
-        }
236
+		if ( false !== $api_response ) {
237
+			$_data = $api_response;
238
+		}
239 239
 
240
-        return $_data;
241
-    }
240
+		return $_data;
241
+	}
242 242
 
243 243
 
244
-    /**
245
-     * Disable SSL verification in order to prevent download update failures
246
-     *
247
-     * @param array   $args
248
-     * @param string  $url
249
-     * @return object $array
250
-     */
251
-    function http_request_args( $args, $url ) {
252
-        // If it is an https request and we are performing a package download, disable ssl verification
253
-        if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
254
-            $args['sslverify'] = false;
255
-        }
256
-        return $args;
257
-    }
244
+	/**
245
+	 * Disable SSL verification in order to prevent download update failures
246
+	 *
247
+	 * @param array   $args
248
+	 * @param string  $url
249
+	 * @return object $array
250
+	 */
251
+	function http_request_args( $args, $url ) {
252
+		// If it is an https request and we are performing a package download, disable ssl verification
253
+		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
254
+			$args['sslverify'] = false;
255
+		}
256
+		return $args;
257
+	}
258 258
 
259
-    /**
260
-     * Calls the API and, if successfull, returns the object delivered by the API.
261
-     *
262
-     * @uses get_bloginfo()
263
-     * @uses wp_remote_post()
264
-     * @uses is_wp_error()
265
-     *
266
-     * @param string  $_action The requested action.
267
-     * @param array   $_data   Parameters for the API action.
268
-     * @return false||object
269
-     */
270
-    private function api_request( $_action, $_data ) {
271
-
272
-        global $wp_version;
273
-
274
-        $data = array_merge( $this->api_data, $_data );
275
-
276
-        if ( $data['slug'] != $this->slug )
277
-            return;
278
-
279
-        if ( empty( $data['license'] ) )
280
-            return;
281
-
282
-        if( $this->api_url == home_url() ) {
283
-            return false; // Don't allow a plugin to ping itself
284
-        }
285
-
286
-        $api_params = array(
287
-            'edd_action' => 'get_version',
288
-            'license'    => $data['license'],
289
-            'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
290
-            'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
291
-            'slug'       => $data['slug'],
292
-            'author'     => $data['author'],
293
-            'url'        => home_url()
294
-        );
259
+	/**
260
+	 * Calls the API and, if successfull, returns the object delivered by the API.
261
+	 *
262
+	 * @uses get_bloginfo()
263
+	 * @uses wp_remote_post()
264
+	 * @uses is_wp_error()
265
+	 *
266
+	 * @param string  $_action The requested action.
267
+	 * @param array   $_data   Parameters for the API action.
268
+	 * @return false||object
269
+	 */
270
+	private function api_request( $_action, $_data ) {
271
+
272
+		global $wp_version;
273
+
274
+		$data = array_merge( $this->api_data, $_data );
275
+
276
+		if ( $data['slug'] != $this->slug )
277
+			return;
278
+
279
+		if ( empty( $data['license'] ) )
280
+			return;
281
+
282
+		if( $this->api_url == home_url() ) {
283
+			return false; // Don't allow a plugin to ping itself
284
+		}
285
+
286
+		$api_params = array(
287
+			'edd_action' => 'get_version',
288
+			'license'    => $data['license'],
289
+			'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
290
+			'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
291
+			'slug'       => $data['slug'],
292
+			'author'     => $data['author'],
293
+			'url'        => home_url()
294
+		);
295 295
 
296
-        $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
296
+		$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
297 297
 
298
-        if ( ! is_wp_error( $request ) ) {
299
-            $request = json_decode( wp_remote_retrieve_body( $request ) );
300
-        }
298
+		if ( ! is_wp_error( $request ) ) {
299
+			$request = json_decode( wp_remote_retrieve_body( $request ) );
300
+		}
301 301
 
302
-        if ( $request && isset( $request->sections ) ) {
303
-            $request->sections = maybe_unserialize( $request->sections );
304
-        } else {
305
-            $request = false;
306
-        }
302
+		if ( $request && isset( $request->sections ) ) {
303
+			$request->sections = maybe_unserialize( $request->sections );
304
+		} else {
305
+			$request = false;
306
+		}
307 307
 
308
-        return $request;
309
-    }
308
+		return $request;
309
+	}
310 310
 
311
-    public function show_changelog() {
311
+	public function show_changelog() {
312 312
 
313 313
 
314
-        if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
315
-            return;
316
-        }
314
+		if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
315
+			return;
316
+		}
317 317
 
318
-        if( empty( $_REQUEST['plugin'] ) ) {
319
-            return;
320
-        }
321
-
322
-        if( empty( $_REQUEST['slug'] ) ) {
323
-            return;
324
-        }
325
-
326
-        if( ! current_user_can( 'update_plugins' ) ) {
327
-            wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
328
-        }
329
-
330
-        $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
331
-
332
-        if( $response && isset( $response->sections['changelog'] ) ) {
333
-            echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
334
-        }
335
-
336
-
337
-        exit;
338
-    }
318
+		if( empty( $_REQUEST['plugin'] ) ) {
319
+			return;
320
+		}
321
+
322
+		if( empty( $_REQUEST['slug'] ) ) {
323
+			return;
324
+		}
325
+
326
+		if( ! current_user_can( 'update_plugins' ) ) {
327
+			wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
328
+		}
329
+
330
+		$response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
331
+
332
+		if( $response && isset( $response->sections['changelog'] ) ) {
333
+			echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
334
+		}
335
+
336
+
337
+		exit;
338
+	}
339 339
 
340 340
 }
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,84 +111,84 @@  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
-                    __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ),
181
-                    esc_html( $version_info->name ),
182
-                    esc_url( $changelog_link ),
183
-                    esc_html( $version_info->new_version )
180
+                    __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd'),
181
+                    esc_html($version_info->name),
182
+                    esc_url($changelog_link),
183
+                    esc_html($version_info->new_version)
184 184
                 );
185 185
             } else {
186 186
                 printf(
187
-                    __( '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>.', 'edd' ),
188
-                    esc_html( $version_info->name ),
189
-                    esc_url( $changelog_link ),
190
-                    esc_html( $version_info->new_version ),
191
-                    esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
187
+                    __('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>.', 'edd'),
188
+                    esc_html($version_info->name),
189
+                    esc_url($changelog_link),
190
+                    esc_html($version_info->new_version),
191
+                    esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name))
192 192
                 );
193 193
             }
194 194
 
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
      * @param object  $_args
208 208
      * @return object $_data
209 209
      */
210
-    function plugins_api_filter( $_data, $_action = '', $_args = null ) {
210
+    function plugins_api_filter($_data, $_action = '', $_args = null) {
211 211
 
212 212
 
213
-        if ( $_action != 'plugin_information' ) {
213
+        if ($_action != 'plugin_information') {
214 214
 
215 215
             return $_data;
216 216
 
217 217
         }
218 218
 
219
-        if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
219
+        if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) {
220 220
 
221 221
             return $_data;
222 222
 
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
             )
232 232
         );
233 233
 
234
-        $api_response = $this->api_request( 'plugin_information', $to_send );
234
+        $api_response = $this->api_request('plugin_information', $to_send);
235 235
 
236
-        if ( false !== $api_response ) {
236
+        if (false !== $api_response) {
237 237
             $_data = $api_response;
238 238
         }
239 239
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
      * @param string  $url
249 249
      * @return object $array
250 250
      */
251
-    function http_request_args( $args, $url ) {
251
+    function http_request_args($args, $url) {
252 252
         // If it is an https request and we are performing a package download, disable ssl verification
253
-        if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
253
+        if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) {
254 254
             $args['sslverify'] = false;
255 255
         }
256 256
         return $args;
@@ -267,40 +267,40 @@  discard block
 block discarded – undo
267 267
      * @param array   $_data   Parameters for the API action.
268 268
      * @return false||object
269 269
      */
270
-    private function api_request( $_action, $_data ) {
270
+    private function api_request($_action, $_data) {
271 271
 
272 272
         global $wp_version;
273 273
 
274
-        $data = array_merge( $this->api_data, $_data );
274
+        $data = array_merge($this->api_data, $_data);
275 275
 
276
-        if ( $data['slug'] != $this->slug )
276
+        if ($data['slug'] != $this->slug)
277 277
             return;
278 278
 
279
-        if ( empty( $data['license'] ) )
279
+        if (empty($data['license']))
280 280
             return;
281 281
 
282
-        if( $this->api_url == home_url() ) {
282
+        if ($this->api_url == home_url()) {
283 283
             return false; // Don't allow a plugin to ping itself
284 284
         }
285 285
 
286 286
         $api_params = array(
287 287
             'edd_action' => 'get_version',
288 288
             'license'    => $data['license'],
289
-            'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
290
-            'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
289
+            'item_name'  => isset($data['item_name']) ? $data['item_name'] : false,
290
+            'item_id'    => isset($data['item_id']) ? $data['item_id'] : false,
291 291
             'slug'       => $data['slug'],
292 292
             'author'     => $data['author'],
293 293
             'url'        => home_url()
294 294
         );
295 295
 
296
-        $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
296
+        $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
297 297
 
298
-        if ( ! is_wp_error( $request ) ) {
299
-            $request = json_decode( wp_remote_retrieve_body( $request ) );
298
+        if ( ! is_wp_error($request)) {
299
+            $request = json_decode(wp_remote_retrieve_body($request));
300 300
         }
301 301
 
302
-        if ( $request && isset( $request->sections ) ) {
303
-            $request->sections = maybe_unserialize( $request->sections );
302
+        if ($request && isset($request->sections)) {
303
+            $request->sections = maybe_unserialize($request->sections);
304 304
         } else {
305 305
             $request = false;
306 306
         }
@@ -311,26 +311,26 @@  discard block
 block discarded – undo
311 311
     public function show_changelog() {
312 312
 
313 313
 
314
-        if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
314
+        if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) {
315 315
             return;
316 316
         }
317 317
 
318
-        if( empty( $_REQUEST['plugin'] ) ) {
318
+        if (empty($_REQUEST['plugin'])) {
319 319
             return;
320 320
         }
321 321
 
322
-        if( empty( $_REQUEST['slug'] ) ) {
322
+        if (empty($_REQUEST['slug'])) {
323 323
             return;
324 324
         }
325 325
 
326
-        if( ! current_user_can( 'update_plugins' ) ) {
327
-            wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
326
+        if ( ! current_user_can('update_plugins')) {
327
+            wp_die(__('You do not have permission to install plugin updates', 'edd'), __('Error', 'edd'), array('response' => 403));
328 328
         }
329 329
 
330
-        $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
330
+        $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug']));
331 331
 
332
-        if( $response && isset( $response->sections['changelog'] ) ) {
333
-            echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
332
+        if ($response && isset($response->sections['changelog'])) {
333
+            echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>';
334 334
         }
335 335
 
336 336
 
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.
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   +83 added lines, -83 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'         => __( 'Name', 'give' ),
36
-		'form_category' => __( 'Categories', 'give' ),
37
-		'form_tag'      => __( 'Tags', 'give' ),
38
-		'price'         => __( 'Price', 'give' ),
39
-		'goal'          => __( 'Goal', 'give' ),
40
-		'donations'     => __( 'Donations', 'give' ),
41
-		'earnings'      => __( 'Income', 'give' ),
42
-		'shortcode'     => __( 'Shortcode', 'give' ),
43
-		'date'          => __( 'Date', 'give' )
35
+		'title'         => __('Name', 'give'),
36
+		'form_category' => __('Categories', 'give'),
37
+		'form_tag'      => __('Tags', 'give'),
38
+		'price'         => __('Price', 'give'),
39
+		'goal'          => __('Goal', 'give'),
40
+		'donations'     => __('Donations', 'give'),
41
+		'earnings'      => __('Income', 'give'),
42
+		'shortcode'     => __('Shortcode', 'give'),
43
+		'date'          => __('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,67 +66,67 @@  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
 		global $give_options;
72 72
 
73
-		$style = isset( $give_options['button_style'] ) ? $give_options['button_style'] : 'button';
74
-		$color = isset( $give_options['checkout_color'] ) ? $give_options['checkout_color'] : 'blue';
75
-		$color = ( $color == 'inherit' ) ? '' : $color;
73
+		$style = isset($give_options['button_style']) ? $give_options['button_style'] : 'button';
74
+		$color = isset($give_options['checkout_color']) ? $give_options['checkout_color'] : 'blue';
75
+		$color = ($color == 'inherit') ? '' : $color;
76 76
 
77
-		$purchase_text = ! empty( $give_options['add_to_cart_text'] ) ? $give_options['add_to_cart_text'] : __( 'Purchase', 'give' );
77
+		$purchase_text = ! empty($give_options['add_to_cart_text']) ? $give_options['add_to_cart_text'] : __('Purchase', 'give');
78 78
 
79
-		switch ( $column_name ) {
79
+		switch ($column_name) {
80 80
 			case 'form_category':
81
-				echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' );
81
+				echo get_the_term_list($post_id, 'give_forms_category', '', ', ', '');
82 82
 				break;
83 83
 			case 'form_tag':
84
-				echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' );
84
+				echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', '');
85 85
 				break;
86 86
 			case 'price':
87
-				if ( give_has_variable_prices( $post_id ) ) {
88
-					echo give_price_range( $post_id );
87
+				if (give_has_variable_prices($post_id)) {
88
+					echo give_price_range($post_id);
89 89
 				} else {
90
-					echo give_price( $post_id, false );
91
-					echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />';
90
+					echo give_price($post_id, false);
91
+					echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />';
92 92
 				}
93 93
 				break;
94 94
 			case 'goal':
95
-				$goal_option = get_post_meta( $post_id, '_give_goal_option', true );
96
-				if ( ! empty( $goal_option ) && $goal_option === 'yes' ) {
97
-					echo give_goal( $post_id, false );
95
+				$goal_option = get_post_meta($post_id, '_give_goal_option', true);
96
+				if ( ! empty($goal_option) && $goal_option === 'yes') {
97
+					echo give_goal($post_id, false);
98 98
 				} else {
99
-					echo __( 'No Goal Set', 'give' );
99
+					echo __('No Goal Set', 'give');
100 100
 				}
101 101
 
102
-				echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />';
102
+				echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />';
103 103
 				break;
104 104
 			case 'donations':
105
-				if ( current_user_can( 'view_give_forms_stats', $post_id ) ) {
106
-					echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form=' . $post_id ) ) . '">';
107
-					echo give_get_form_sales_stats( $post_id );
105
+				if (current_user_can('view_give_forms_stats', $post_id)) {
106
+					echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form='.$post_id)).'">';
107
+					echo give_get_form_sales_stats($post_id);
108 108
 					echo '</a>';
109 109
 				} else {
110 110
 					echo '-';
111 111
 				}
112 112
 				break;
113 113
 			case 'earnings':
114
-				if ( current_user_can( 'view_give_forms_stats', $post_id ) ) {
115
-					echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $post_id ) ) . '">';
116
-					echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ) ) );
114
+				if (current_user_can('view_give_forms_stats', $post_id)) {
115
+					echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$post_id)).'">';
116
+					echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id)));
117 117
 					echo '</a>';
118 118
 				} else {
119 119
 					echo '-';
120 120
 				}
121 121
 				break;
122 122
 			case 'shortcode':
123
-				echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;' . absint( $post_id ) . '&#34;]">';
123
+				echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;'.absint($post_id).'&#34;]">';
124 124
 				break;
125 125
 		}
126 126
 	}
127 127
 }
128 128
 
129
-add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 );
129
+add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2);
130 130
 
131 131
 /**
132 132
  * Registers the sortable columns in the list table
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
  *
138 138
  * @return array $columns Array of sortable columns
139 139
  */
140
-function give_sortable_form_columns( $columns ) {
140
+function give_sortable_form_columns($columns) {
141 141
 	$columns['price']    = 'price';
142 142
 	$columns['sales']    = 'sales';
143 143
 	$columns['earnings'] = 'earnings';
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	return $columns;
147 147
 }
148 148
 
149
-add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' );
149
+add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns');
150 150
 
151 151
 /**
152 152
  * Sorts Columns in the Forms List Table
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
  *
158 158
  * @return array $vars Array of all the sort variables
159 159
  */
160
-function give_sort_forms( $vars ) {
160
+function give_sort_forms($vars) {
161 161
 	// Check if we're viewing the "give_forms" post type
162
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
162
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
163 163
 		// Check if 'orderby' is set to "sales"
164
-		if ( isset( $vars['orderby'] ) && 'sales' == $vars['orderby'] ) {
164
+		if (isset($vars['orderby']) && 'sales' == $vars['orderby']) {
165 165
 			$vars = array_merge(
166 166
 				$vars,
167 167
 				array(
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		}
173 173
 
174 174
 		// Check if "orderby" is set to "earnings"
175
-		if ( isset( $vars['orderby'] ) && 'earnings' == $vars['orderby'] ) {
175
+		if (isset($vars['orderby']) && 'earnings' == $vars['orderby']) {
176 176
 			$vars = array_merge(
177 177
 				$vars,
178 178
 				array(
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		}
184 184
 
185 185
 		// Check if "orderby" is set to "price"
186
-		if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
186
+		if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
187 187
 			$vars = array_merge(
188 188
 				$vars,
189 189
 				array(
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		}
195 195
 
196 196
 		// Check if "orderby" is set to "goal"
197
-		if ( isset( $vars['orderby'] ) && 'goal' == $vars['orderby'] ) {
197
+		if (isset($vars['orderby']) && 'goal' == $vars['orderby']) {
198 198
 			$vars = array_merge(
199 199
 				$vars,
200 200
 				array(
@@ -217,16 +217,16 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return array       Array of all sort variables
219 219
  */
220
-function give_filter_forms( $vars ) {
221
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
220
+function give_filter_forms($vars) {
221
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
222 222
 
223 223
 		// If an author ID was passed, use it
224
-		if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) {
224
+		if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) {
225 225
 
226 226
 			$author_id = $_REQUEST['author'];
227
-			if ( (int) $author_id !== get_current_user_id() ) {
227
+			if ((int) $author_id !== get_current_user_id()) {
228 228
 				// Tried to view the products of another person, sorry
229
-				wp_die( __( 'You do not have permission to view this data.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
229
+				wp_die(__('You do not have permission to view this data.', 'give'), __('Error', 'give'), array('response' => 403));
230 230
 			}
231 231
 			$vars = array_merge(
232 232
 				$vars,
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
  * @return void
252 252
  */
253 253
 function give_forms_load() {
254
-	add_filter( 'request', 'give_sort_forms' );
255
-	add_filter( 'request', 'give_filter_forms' );
254
+	add_filter('request', 'give_sort_forms');
255
+	add_filter('request', 'give_filter_forms');
256 256
 }
257 257
 
258
-add_action( 'load-edit.php', 'give_forms_load', 9999 );
258
+add_action('load-edit.php', 'give_forms_load', 9999);
259 259
 
260 260
 /**
261 261
  * Remove Forms Month Filter
@@ -269,17 +269,17 @@  discard block
 block discarded – undo
269 269
  * @global      $typenow The post type we are viewing
270 270
  * @return array Empty array disables the dropdown
271 271
  */
272
-function give_remove_month_filter( $dates ) {
272
+function give_remove_month_filter($dates) {
273 273
 	global $typenow;
274 274
 
275
-	if ( $typenow == 'give_forms' ) {
275
+	if ($typenow == 'give_forms') {
276 276
 		$dates = array();
277 277
 	}
278 278
 
279 279
 	return $dates;
280 280
 }
281 281
 
282
-add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 );
282
+add_filter('months_dropdown_results', 'give_remove_month_filter', 99);
283 283
 
284 284
 /**
285 285
  * Adds price field to Quick Edit options
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
  *
292 292
  * @return void
293 293
  */
294
-function give_price_field_quick_edit( $column_name, $post_type ) {
295
-	if ( $column_name != 'price' || $post_type != 'give_forms' ) {
294
+function give_price_field_quick_edit($column_name, $post_type) {
295
+	if ($column_name != 'price' || $post_type != 'give_forms') {
296 296
 		return;
297 297
 	}
298 298
 	?>
299 299
 	<fieldset class="inline-edit-col-left">
300 300
 		<div id="give-give-data" class="inline-edit-col">
301
-			<h4><?php echo sprintf( __( '%s Configuration', 'give' ), give_get_forms_label_singular() ); ?></h4>
301
+			<h4><?php echo sprintf(__('%s Configuration', 'give'), give_get_forms_label_singular()); ?></h4>
302 302
 			<label>
303
-				<span class="title"><?php _e( 'Price', 'give' ); ?></span>
303
+				<span class="title"><?php _e('Price', 'give'); ?></span>
304 304
 				<span class="input-text-wrap">
305 305
 					<input type="text" name="_give_regprice" class="text regprice" />
306 306
 				</span>
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 	<?php
312 312
 }
313 313
 
314
-add_action( 'quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2 );
315
-add_action( 'bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2 );
314
+add_action('quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2);
315
+add_action('bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2);
316 316
 
317 317
 /**
318 318
  * Updates price when saving post
@@ -323,23 +323,23 @@  discard block
 block discarded – undo
323 323
  *
324 324
  * @return void
325 325
  */
326
-function give_price_save_quick_edit( $post_id ) {
327
-	if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) {
326
+function give_price_save_quick_edit($post_id) {
327
+	if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) {
328 328
 		return;
329 329
 	}
330
-	if ( ! current_user_can( 'edit_post', $post_id ) ) {
330
+	if ( ! current_user_can('edit_post', $post_id)) {
331 331
 		return $post_id;
332 332
 	}
333
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
333
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
334 334
 		return $post_id;
335 335
 	}
336 336
 
337
-	if ( isset( $_REQUEST['_give_regprice'] ) ) {
338
-		update_post_meta( $post_id, '_give_set_price', strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) );
337
+	if (isset($_REQUEST['_give_regprice'])) {
338
+		update_post_meta($post_id, '_give_set_price', strip_tags(stripslashes($_REQUEST['_give_regprice'])));
339 339
 	}
340 340
 }
341 341
 
342
-add_action( 'save_post', 'give_price_save_quick_edit' );
342
+add_action('save_post', 'give_price_save_quick_edit');
343 343
 
344 344
 /**
345 345
  * Process bulk edit actions via AJAX
@@ -349,18 +349,18 @@  discard block
 block discarded – undo
349 349
  */
350 350
 function give_save_bulk_edit() {
351 351
 
352
-	$post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
352
+	$post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
353 353
 
354
-	if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
355
-		$price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0;
356
-		foreach ( $post_ids as $post_id ) {
354
+	if ( ! empty($post_ids) && is_array($post_ids)) {
355
+		$price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0;
356
+		foreach ($post_ids as $post_id) {
357 357
 
358
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
358
+			if ( ! current_user_can('edit_post', $post_id)) {
359 359
 				continue;
360 360
 			}
361 361
 
362
-			if ( ! empty( $price ) ) {
363
-				update_post_meta( $post_id, '_give_set_price', give_sanitize_amount( $price ) );
362
+			if ( ! empty($price)) {
363
+				update_post_meta($post_id, '_give_set_price', give_sanitize_amount($price));
364 364
 			}
365 365
 		}
366 366
 	}
@@ -368,4 +368,4 @@  discard block
 block discarded – undo
368 368
 	die();
369 369
 }
370 370
 
371
-add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' );
371
+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'      => __( 'Log ID', 'give' ),
94
-			'details' => __( 'Request Details', 'give' ),
95
-			'ip'      => __( 'Request IP', 'give' ),
96
-			'date'    => __( 'Date', 'give' )
93
+			'ID'      => __('Log ID', 'give'),
94
+			'details' => __('Request Details', 'give'),
95
+			'ip'      => __('Request IP', 'give'),
96
+			'date'    => __('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" title="<?php _e( 'View Request Details', 'give' ); ?> "><?php _e( 'View Request', 'give' ); ?></a>
132
+		<a href="#TB_inline?width=640&amp;inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox" title="<?php _e('View Request Details', 'give'); ?> "><?php _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>' . __( 'API Request:', 'give' ) . '</strong></p>';
139
-			echo '<div>' . $request . '</div>';
140
-			if ( ! empty( $error ) ) {
141
-				echo '<p><strong>' . __( '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>'.__('API Request:', 'give').'</strong></p>';
139
+			echo '<div>'.$request.'</div>';
140
+			if ( ! empty($error)) {
141
+				echo '<p><strong>'.__('Error', 'give').'</strong></p>';
142
+				echo '<div>'.esc_html($error).'</div>';
143 143
 			}
144
-			echo '<p><strong>' . __( 'API User:', 'give' ) . '</strong></p>';
145
-			echo '<div>' . get_post_meta( $item['ID'], '_give_log_user', true ) . '</div>';
146
-			echo '<p><strong>' . __( 'API Key:', 'give' ) . '</strong></p>';
147
-			echo '<div>' . get_post_meta( $item['ID'], '_give_log_key', true ) . '</div>';
148
-			echo '<p><strong>' . __( 'Request Date:', 'give' ) . '</strong></p>';
149
-			echo '<div>' . get_post_field( 'post_date', $item['ID'] ) . '</div>';
144
+			echo '<p><strong>'.__('API User:', 'give').'</strong></p>';
145
+			echo '<div>'.get_post_meta($item['ID'], '_give_log_user', true).'</div>';
146
+			echo '<p><strong>'.__('API Key:', 'give').'</strong></p>';
147
+			echo '<div>'.get_post_meta($item['ID'], '_give_log_key', true).'</div>';
148
+			echo '<p><strong>'.__('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="' . __( 'This payment was made in test mode', 'give' ) . '">' . __( '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="'.__('This payment was made in test mode', 'give').'">'.__('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'         => __( 'Log ID', 'give' ),
111
-			'user_id'    => __( 'Donor', 'give' ),
110
+			'ID'         => __('Log ID', 'give'),
111
+			'user_id'    => __('Donor', 'give'),
112 112
 			'form'       => give_get_forms_label_singular(),
113
-			'amount'     => __( 'Donation Amount', 'give' ),
114
-			'status'     => __( 'Status', 'give' ),
115
-			'payment_id' => __( 'Transaction ID', 'give' ),
116
-			'date'       => __( 'Date', 'give' )
113
+			'amount'     => __('Donation Amount', 'give'),
114
+			'status'     => __('Status', 'give'),
115
+			'payment_id' => __('Transaction ID', 'give'),
116
+			'date'       => __('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">' . __( '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">'.__('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.
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
-		__( 'Income', 'give' )    => $earnings_data,
181
-		__( 'Donations', 'give' ) => $sales_data
180
+		__('Income', 'give')    => $earnings_data,
181
+		__('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
 					?>
@@ -206,32 +206,32 @@  discard block
 block discarded – undo
206 206
 				<tbody>
207 207
 				<tr>
208 208
 					<td class="row-title">
209
-						<label for="tablecell"><?php _e( 'Total income for period: ', 'give' ); ?></label></td>
210
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td>
209
+						<label for="tablecell"><?php _e('Total income for period: ', 'give'); ?></label></td>
210
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td>
211 211
 				</tr>
212 212
 				<tr class="alternate">
213 213
 					<td class="row-title">
214
-						<label for="tablecell"><?php _e( 'Total donations for period shown: ', 'give' ); ?></label>
214
+						<label for="tablecell"><?php _e('Total donations for period shown: ', 'give'); ?></label>
215 215
 					</td>
216
-					<td><?php echo give_format_amount( $sales_totals, false ); ?></td>
216
+					<td><?php echo give_format_amount($sales_totals, false); ?></td>
217 217
 				</tr>
218
-				<?php if ( 'this_month' == $dates['range'] ) : ?>
218
+				<?php if ('this_month' == $dates['range']) : ?>
219 219
 					<tr>
220 220
 						<td class="row-title">
221
-							<label for="tablecell"><?php _e( 'Estimated monthly income: ', 'give' ); ?></label>
221
+							<label for="tablecell"><?php _e('Estimated monthly income: ', 'give'); ?></label>
222 222
 						</td>
223
-						<td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'] ) ); ?></td>
223
+						<td><?php echo give_currency_filter(give_format_amount($estimated['earnings'])); ?></td>
224 224
 					</tr>
225 225
 					<tr class="alternate">
226 226
 						<td class="row-title">
227
-							<label for="tablecell"><?php _e( 'Estimated monthly donations: ', 'give' ); ?></label>
227
+							<label for="tablecell"><?php _e('Estimated monthly donations: ', 'give'); ?></label>
228 228
 						</td>
229
-						<td><?php echo give_format_amount( $estimated['sales'], false ); ?></td>
229
+						<td><?php echo give_format_amount($estimated['sales'], false); ?></td>
230 230
 					</tr>
231 231
 				<?php endif; ?>
232 232
 			</table>
233 233
 
234
-			<?php do_action( 'give_reports_graph_additional_stats' ); ?>
234
+			<?php do_action('give_reports_graph_additional_stats'); ?>
235 235
 
236 236
 		</div>
237 237
 	</div>
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
  * @since 1.0
250 250
  * @return void
251 251
  */
252
-function give_reports_graph_of_form( $form_id = 0 ) {
252
+function give_reports_graph_of_form($form_id = 0) {
253 253
 	// Retrieve the queried dates
254 254
 	$dates = give_get_report_dates();
255 255
 
256 256
 	// Determine graph options
257
-	switch ( $dates['range'] ) :
257
+	switch ($dates['range']) :
258 258
 		case 'today' :
259 259
 		case 'yesterday' :
260 260
 			$day_by_day = true;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 			$day_by_day = false;
273 273
 			break;
274 274
 		case 'other' :
275
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) {
275
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) {
276 276
 				$day_by_day = false;
277 277
 			} else {
278 278
 				$day_by_day = true;
@@ -284,75 +284,75 @@  discard block
 block discarded – undo
284 284
 	endswitch;
285 285
 
286 286
 	$earnings_totals = (float) 0.00; // Total earnings for time period shown
287
-	$sales_totals    = 0;            // Total sales for time period shown
287
+	$sales_totals    = 0; // Total sales for time period shown
288 288
 
289 289
 	$earnings_data = array();
290 290
 	$sales_data    = array();
291 291
 	$stats         = new Give_Payment_Stats;
292 292
 
293
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
293
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
294 294
 
295 295
 		// Hour by hour
296 296
 		$month  = $dates['m_start'];
297 297
 		$hour   = 1;
298 298
 		$minute = 0;
299 299
 		$second = 0;
300
-		while ( $hour <= 23 ) :
300
+		while ($hour <= 23) :
301 301
 
302
-			if ( $hour == 23 ) {
302
+			if ($hour == 23) {
303 303
 				$minute = $second = 59;
304 304
 			}
305 305
 
306
-			$date     = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] );
307
-			$date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] );
306
+			$date     = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']);
307
+			$date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']);
308 308
 
309
-			$sales = $stats->get_sales( $form_id, $date, $date_end );
309
+			$sales = $stats->get_sales($form_id, $date, $date_end);
310 310
 			$sales_totals += $sales;
311 311
 
312
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
312
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
313 313
 			$earnings_totals += $earnings;
314 314
 
315
-			$sales_data[]    = array( $date * 1000, $sales );
316
-			$earnings_data[] = array( $date * 1000, $earnings );
315
+			$sales_data[]    = array($date * 1000, $sales);
316
+			$earnings_data[] = array($date * 1000, $earnings);
317 317
 
318
-			$hour ++;
318
+			$hour++;
319 319
 		endwhile;
320 320
 
321
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
321
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
322 322
 
323 323
 		//Day by day
324 324
 		$day     = $dates['day'];
325 325
 		$day_end = $dates['day_end'];
326 326
 		$month   = $dates['m_start'];
327
-		while ( $day <= $day_end ) :
327
+		while ($day <= $day_end) :
328 328
 
329
-			$date     = mktime( 0, 0, 0, $month, $day, $dates['year'] );
330
-			$date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] );
331
-			$sales    = $stats->get_sales( $form_id, $date, $date_end );
329
+			$date     = mktime(0, 0, 0, $month, $day, $dates['year']);
330
+			$date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']);
331
+			$sales    = $stats->get_sales($form_id, $date, $date_end);
332 332
 			$sales_totals += $sales;
333 333
 
334
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
334
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
335 335
 			$earnings_totals += $earnings;
336 336
 
337
-			$sales_data[]    = array( $date * 1000, $sales );
338
-			$earnings_data[] = array( $date * 1000, $earnings );
337
+			$sales_data[]    = array($date * 1000, $sales);
338
+			$earnings_data[] = array($date * 1000, $earnings);
339 339
 
340
-			$day ++;
340
+			$day++;
341 341
 		endwhile;
342 342
 
343 343
 	} else {
344 344
 
345 345
 		$y = $dates['year'];
346 346
 
347
-		while ( $y <= $dates['year_end'] ) :
347
+		while ($y <= $dates['year_end']) :
348 348
 
349 349
 			$last_year = false;
350 350
 
351
-			if ( $dates['year'] == $dates['year_end'] ) {
351
+			if ($dates['year'] == $dates['year_end']) {
352 352
 				$month_start = $dates['m_start'];
353 353
 				$month_end   = $dates['m_end'];
354 354
 				$last_year   = true;
355
-			} elseif ( $y == $dates['year'] ) {
355
+			} elseif ($y == $dates['year']) {
356 356
 				$month_start = $dates['m_start'];
357 357
 				$month_end   = 12;
358 358
 			} else {
@@ -361,79 +361,79 @@  discard block
 block discarded – undo
361 361
 			}
362 362
 
363 363
 			$i = $month_start;
364
-			while ( $i <= $month_end ) :
364
+			while ($i <= $month_end) :
365 365
 
366
-				if ( $day_by_day ) :
366
+				if ($day_by_day) :
367 367
 
368
-					if ( $i == $month_end && $last_year ) {
368
+					if ($i == $month_end && $last_year) {
369 369
 
370 370
 						$num_of_days = $dates['day_end'];
371 371
 
372 372
 					} else {
373 373
 
374
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
374
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
375 375
 
376 376
 					}
377 377
 
378 378
 					$d = $dates['day'];
379
-					while ( $d <= $num_of_days ) :
379
+					while ($d <= $num_of_days) :
380 380
 
381
-						$date     = mktime( 0, 0, 0, $i, $d, $y );
382
-						$end_date = mktime( 23, 59, 59, $i, $d, $y );
381
+						$date     = mktime(0, 0, 0, $i, $d, $y);
382
+						$end_date = mktime(23, 59, 59, $i, $d, $y);
383 383
 
384
-						$sales = $stats->get_sales( $form_id, $date, $end_date );
384
+						$sales = $stats->get_sales($form_id, $date, $end_date);
385 385
 						$sales_totals += $sales;
386 386
 
387
-						$earnings = $stats->get_earnings( $form_id, $date, $end_date );
387
+						$earnings = $stats->get_earnings($form_id, $date, $end_date);
388 388
 						$earnings_totals += $earnings;
389 389
 
390
-						$sales_data[]    = array( $date * 1000, $sales );
391
-						$earnings_data[] = array( $date * 1000, $earnings );
392
-						$d ++;
390
+						$sales_data[]    = array($date * 1000, $sales);
391
+						$earnings_data[] = array($date * 1000, $earnings);
392
+						$d++;
393 393
 
394 394
 					endwhile;
395 395
 
396 396
 				else :
397 397
 
398
-					$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
398
+					$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
399 399
 
400
-					$date     = mktime( 0, 0, 0, $i, 1, $y );
401
-					$end_date = mktime( 23, 59, 59, $i, $num_of_days, $y );
400
+					$date     = mktime(0, 0, 0, $i, 1, $y);
401
+					$end_date = mktime(23, 59, 59, $i, $num_of_days, $y);
402 402
 
403
-					$sales = $stats->get_sales( $form_id, $date, $end_date );
403
+					$sales = $stats->get_sales($form_id, $date, $end_date);
404 404
 					$sales_totals += $sales;
405 405
 
406
-					$earnings = $stats->get_earnings( $form_id, $date, $end_date );
406
+					$earnings = $stats->get_earnings($form_id, $date, $end_date);
407 407
 					$earnings_totals += $earnings;
408 408
 
409
-					$sales_data[]    = array( $date * 1000, $sales );
410
-					$earnings_data[] = array( $date * 1000, $earnings );
409
+					$sales_data[]    = array($date * 1000, $sales);
410
+					$earnings_data[] = array($date * 1000, $earnings);
411 411
 				endif;
412 412
 
413
-				$i ++;
413
+				$i++;
414 414
 
415 415
 			endwhile;
416 416
 
417
-			$y ++;
417
+			$y++;
418 418
 		endwhile;
419 419
 
420 420
 	}
421 421
 
422 422
 	$data = array(
423
-		__( 'Income', 'give' )    => $earnings_data,
424
-		__( 'Donations', 'give' ) => $sales_data
423
+		__('Income', 'give')    => $earnings_data,
424
+		__('Donations', 'give') => $sales_data
425 425
 	);
426 426
 
427 427
 	?>
428
-	<h3><span><?php printf( __( 'Income Over Time for %s', 'give' ), get_the_title( $form_id ) ); ?></span></h3>
428
+	<h3><span><?php printf(__('Income Over Time for %s', 'give'), get_the_title($form_id)); ?></span></h3>
429 429
 
430 430
 	<div class="metabox-holder" style="padding-top: 0;">
431 431
 		<div class="postbox">
432 432
 			<div class="inside">
433 433
 				<?php
434
-				$graph = new Give_Graph( $data );
435
-				$graph->set( 'x_mode', 'time' );
436
-				$graph->set( 'multiple_y_axes', true );
434
+				$graph = new Give_Graph($data);
435
+				$graph->set('x_mode', 'time');
436
+				$graph->set('multiple_y_axes', true);
437 437
 				$graph->display();
438 438
 				?>
439 439
 			</div>
@@ -443,26 +443,26 @@  discard block
 block discarded – undo
443 443
 			<tbody>
444 444
 			<tr>
445 445
 				<td class="row-title">
446
-					<label for="tablecell"><?php _e( 'Total income for period: ', 'give' ); ?></label></td>
447
-				<td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td>
446
+					<label for="tablecell"><?php _e('Total income for period: ', 'give'); ?></label></td>
447
+				<td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td>
448 448
 			</tr>
449 449
 			<tr class="alternate">
450 450
 				<td class="row-title">
451
-					<label for="tablecell"><?php _e( 'Total donations for period: ', 'give' ); ?></label>
451
+					<label for="tablecell"><?php _e('Total donations for period: ', 'give'); ?></label>
452 452
 				</td>
453 453
 				<td><?php echo $sales_totals; ?></td>
454 454
 			</tr>
455 455
 			<tr>
456 456
 				<td class="row-title">
457
-					<label for="tablecell"><?php _e( 'Average monthly income: %s', 'give' ); ?></label>
457
+					<label for="tablecell"><?php _e('Average monthly income: %s', 'give'); ?></label>
458 458
 				</td>
459
-				<td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ) ) ); ?></td>
459
+				<td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id))); ?></td>
460 460
 			</tr>
461 461
 			<tr class="alternate">
462 462
 				<td class="row-title">
463
-					<label for="tablecell"><?php _e( 'Average monthly donations: %s', 'give' ); ?></label>
463
+					<label for="tablecell"><?php _e('Average monthly donations: %s', 'give'); ?></label>
464 464
 				</td>
465
-				<td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td>
465
+				<td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td>
466 466
 			</tr>
467 467
 			</tbody>
468 468
 		</table>
@@ -479,30 +479,30 @@  discard block
 block discarded – undo
479 479
  * @return void
480 480
  */
481 481
 function give_reports_graph_controls() {
482
-	$date_options = apply_filters( 'give_report_date_options', array(
483
-		'today'        => __( 'Today', 'give' ),
484
-		'yesterday'    => __( 'Yesterday', 'give' ),
485
-		'this_week'    => __( 'This Week', 'give' ),
486
-		'last_week'    => __( 'Last Week', 'give' ),
487
-		'this_month'   => __( 'This Month', 'give' ),
488
-		'last_month'   => __( 'Last Month', 'give' ),
489
-		'this_quarter' => __( 'This Quarter', 'give' ),
490
-		'last_quarter' => __( 'Last Quarter', 'give' ),
491
-		'this_year'    => __( 'This Year', 'give' ),
492
-		'last_year'    => __( 'Last Year', 'give' ),
493
-		'other'        => __( 'Custom', 'give' )
494
-	) );
482
+	$date_options = apply_filters('give_report_date_options', array(
483
+		'today'        => __('Today', 'give'),
484
+		'yesterday'    => __('Yesterday', 'give'),
485
+		'this_week'    => __('This Week', 'give'),
486
+		'last_week'    => __('Last Week', 'give'),
487
+		'this_month'   => __('This Month', 'give'),
488
+		'last_month'   => __('Last Month', 'give'),
489
+		'this_quarter' => __('This Quarter', 'give'),
490
+		'last_quarter' => __('Last Quarter', 'give'),
491
+		'this_year'    => __('This Year', 'give'),
492
+		'last_year'    => __('Last Year', 'give'),
493
+		'other'        => __('Custom', 'give')
494
+	));
495 495
 
496 496
 	$dates   = give_get_report_dates();
497 497
 	$display = $dates['range'] == 'other' ? '' : 'style="display:none;"';
498 498
 	$view    = give_get_reporting_view();
499 499
 
500
-	if ( empty( $dates['day_end'] ) ) {
501
-		$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) );
500
+	if (empty($dates['day_end'])) {
501
+		$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y'));
502 502
 	}
503 503
 
504 504
 	//echo '<pre>'; print_r( $dates ); echo '</pre>';
505
-	do_action( 'give_report_graph_controls_before' );
505
+	do_action('give_report_graph_controls_before');
506 506
 	?>
507 507
 	<form id="give-graphs-filter" method="get" class="alignright">
508 508
 		<div class="tablenav top alignright">
@@ -510,53 +510,53 @@  discard block
 block discarded – undo
510 510
 
511 511
 				<input type="hidden" name="post_type" value="give_forms" />
512 512
 				<input type="hidden" name="page" value="give-reports" />
513
-				<input type="hidden" name="view" value="<?php echo esc_attr( $view ); ?>" />
513
+				<input type="hidden" name="view" value="<?php echo esc_attr($view); ?>" />
514 514
 
515
-				<?php if ( isset( $_GET['form-id'] ) ) : ?>
516
-					<input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" />
515
+				<?php if (isset($_GET['form-id'])) : ?>
516
+					<input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" />
517 517
 				<?php endif; ?>
518 518
 
519 519
 				<div id="give-graphs-date-options-wrap" class="alignright">
520 520
 					<select id="give-graphs-date-options" name="range">
521
-						<?php foreach ( $date_options as $key => $option ) : ?>
522
-							<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option>
521
+						<?php foreach ($date_options as $key => $option) : ?>
522
+							<option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option>
523 523
 						<?php endforeach; ?>
524 524
 					</select>
525 525
 
526
-					<input type="submit" class="button-secondary" value="<?php _e( 'Filter', 'give' ); ?>" />
526
+					<input type="submit" class="button-secondary" value="<?php _e('Filter', 'give'); ?>" />
527 527
 				</div>
528 528
 
529 529
 				<div id="give-date-range-options" <?php echo $display; ?>>
530
-					<span><?php _e( 'From', 'give' ); ?>&nbsp;</span>
530
+					<span><?php _e('From', 'give'); ?>&nbsp;</span>
531 531
 					<select id="give-graphs-month-start" name="m_start">
532
-						<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
533
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['m_start'] ); ?>><?php echo give_month_num_to_name( $i ); ?></option>
532
+						<?php for ($i = 1; $i <= 12; $i++) : ?>
533
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['m_start']); ?>><?php echo give_month_num_to_name($i); ?></option>
534 534
 						<?php endfor; ?>
535 535
 					</select>
536 536
 					<select id="give-graphs-day-start" name="day">
537
-						<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
538
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['day'] ); ?>><?php echo $i; ?></option>
537
+						<?php for ($i = 1; $i <= 31; $i++) : ?>
538
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['day']); ?>><?php echo $i; ?></option>
539 539
 						<?php endfor; ?>
540 540
 					</select>
541 541
 					<select id="give-graphs-year-start" name="year">
542
-						<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
543
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['year'] ); ?>><?php echo $i; ?></option>
542
+						<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
543
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['year']); ?>><?php echo $i; ?></option>
544 544
 						<?php endfor; ?>
545 545
 					</select>
546
-					<span><?php _e( 'To', 'give' ); ?>&nbsp;</span>
546
+					<span><?php _e('To', 'give'); ?>&nbsp;</span>
547 547
 					<select id="give-graphs-month-end" name="m_end">
548
-						<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
549
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['m_end'] ); ?>><?php echo give_month_num_to_name( $i ); ?></option>
548
+						<?php for ($i = 1; $i <= 12; $i++) : ?>
549
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['m_end']); ?>><?php echo give_month_num_to_name($i); ?></option>
550 550
 						<?php endfor; ?>
551 551
 					</select>
552 552
 					<select id="give-graphs-day-end" name="day_end">
553
-						<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
554
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['day_end'] ); ?>><?php echo $i; ?></option>
553
+						<?php for ($i = 1; $i <= 31; $i++) : ?>
554
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['day_end']); ?>><?php echo $i; ?></option>
555 555
 						<?php endfor; ?>
556 556
 					</select>
557 557
 					<select id="give-graphs-year-end" name="year_end">
558
-						<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
559
-							<option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['year_end'] ); ?>><?php echo $i; ?></option>
558
+						<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
559
+							<option value="<?php echo absint($i); ?>" <?php selected($i, $dates['year_end']); ?>><?php echo $i; ?></option>
560 560
 						<?php endfor; ?>
561 561
 					</select>
562 562
 				</div>
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 		</div>
567 567
 	</form>
568 568
 	<?php
569
-	do_action( 'give_report_graph_controls_after' );
569
+	do_action('give_report_graph_controls_after');
570 570
 }
571 571
 
572 572
 /**
@@ -581,65 +581,65 @@  discard block
 block discarded – undo
581 581
 function give_get_report_dates() {
582 582
 	$dates = array();
583 583
 
584
-	$current_time = current_time( 'timestamp' );
584
+	$current_time = current_time('timestamp');
585 585
 
586
-	$dates['range']    = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month';
587
-	$dates['year']     = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
588
-	$dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' );
589
-	$dates['m_start']  = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1;
590
-	$dates['m_end']    = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12;
591
-	$dates['day']      = isset( $_GET['day'] ) ? $_GET['day'] : 1;
592
-	$dates['day_end']  = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
586
+	$dates['range']    = isset($_GET['range']) ? $_GET['range'] : 'this_month';
587
+	$dates['year']     = isset($_GET['year']) ? $_GET['year'] : date('Y');
588
+	$dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y');
589
+	$dates['m_start']  = isset($_GET['m_start']) ? $_GET['m_start'] : 1;
590
+	$dates['m_end']    = isset($_GET['m_end']) ? $_GET['m_end'] : 12;
591
+	$dates['day']      = isset($_GET['day']) ? $_GET['day'] : 1;
592
+	$dates['day_end']  = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
593 593
 
594 594
 	// Modify dates based on predefined ranges
595
-	switch ( $dates['range'] ) :
595
+	switch ($dates['range']) :
596 596
 
597 597
 		case 'this_month' :
598
-			$dates['m_start']  = date( 'n', $current_time );
599
-			$dates['m_end']    = date( 'n', $current_time );
598
+			$dates['m_start']  = date('n', $current_time);
599
+			$dates['m_end']    = date('n', $current_time);
600 600
 			$dates['day']      = 1;
601
-			$dates['day_end']  = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
602
-			$dates['year']     = date( 'Y' );
603
-			$dates['year_end'] = date( 'Y' );
601
+			$dates['day_end']  = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
602
+			$dates['year']     = date('Y');
603
+			$dates['year_end'] = date('Y');
604 604
 			break;
605 605
 
606 606
 		case 'last_month' :
607
-			if ( date( 'n' ) == 1 ) {
607
+			if (date('n') == 1) {
608 608
 				$dates['m_start']  = 12;
609 609
 				$dates['m_end']    = 12;
610
-				$dates['year']     = date( 'Y', $current_time ) - 1;
611
-				$dates['year_end'] = date( 'Y', $current_time ) - 1;
610
+				$dates['year']     = date('Y', $current_time) - 1;
611
+				$dates['year_end'] = date('Y', $current_time) - 1;
612 612
 			} else {
613
-				$dates['m_start']  = date( 'n' ) - 1;
614
-				$dates['m_end']    = date( 'n' ) - 1;
613
+				$dates['m_start']  = date('n') - 1;
614
+				$dates['m_end']    = date('n') - 1;
615 615
 				$dates['year_end'] = $dates['year'];
616 616
 			}
617
-			$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
617
+			$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
618 618
 			break;
619 619
 
620 620
 		case 'today' :
621
-			$dates['day']     = date( 'd', $current_time );
622
-			$dates['m_start'] = date( 'n', $current_time );
623
-			$dates['m_end']   = date( 'n', $current_time );
624
-			$dates['year']    = date( 'Y', $current_time );
621
+			$dates['day']     = date('d', $current_time);
622
+			$dates['m_start'] = date('n', $current_time);
623
+			$dates['m_end']   = date('n', $current_time);
624
+			$dates['year']    = date('Y', $current_time);
625 625
 			break;
626 626
 
627 627
 		case 'yesterday' :
628 628
 
629
-			$year  = date( 'Y', $current_time );
630
-			$month = date( 'n', $current_time );
631
-			$day   = date( 'd', $current_time );
629
+			$year  = date('Y', $current_time);
630
+			$month = date('n', $current_time);
631
+			$day   = date('d', $current_time);
632 632
 
633
-			if ( $month == 1 && $day == 1 ) {
633
+			if ($month == 1 && $day == 1) {
634 634
 
635 635
 				$year -= 1;
636 636
 				$month = 12;
637
-				$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
637
+				$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
638 638
 
639
-			} elseif ( $month > 1 && $day == 1 ) {
639
+			} elseif ($month > 1 && $day == 1) {
640 640
 
641 641
 				$month -= 1;
642
-				$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
642
+				$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
643 643
 
644 644
 			} else {
645 645
 
@@ -655,91 +655,91 @@  discard block
 block discarded – undo
655 655
 			break;
656 656
 
657 657
 		case 'this_week' :
658
-			$dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1;
659
-			$dates['day'] += get_option( 'start_of_week' );
658
+			$dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1;
659
+			$dates['day'] += get_option('start_of_week');
660 660
 			$dates['day_end'] = $dates['day'] + 6;
661
-			$dates['m_start'] = date( 'n', $current_time );
662
-			$dates['m_end']   = date( 'n', $current_time );
663
-			$dates['year']    = date( 'Y', $current_time );
661
+			$dates['m_start'] = date('n', $current_time);
662
+			$dates['m_end']   = date('n', $current_time);
663
+			$dates['year']    = date('Y', $current_time);
664 664
 			break;
665 665
 
666 666
 		case 'last_week' :
667
-			$dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8;
668
-			$dates['day'] += get_option( 'start_of_week' );
667
+			$dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8;
668
+			$dates['day'] += get_option('start_of_week');
669 669
 			$dates['day_end'] = $dates['day'] + 6;
670
-			$dates['year']    = date( 'Y' );
671
-
672
-			if ( date( 'j', $current_time ) <= 7 ) {
673
-				$dates['m_start'] = date( 'n', $current_time ) - 1;
674
-				$dates['m_end']   = date( 'n', $current_time ) - 1;
675
-				if ( $dates['m_start'] <= 1 ) {
676
-					$dates['year']     = date( 'Y', $current_time ) - 1;
677
-					$dates['year_end'] = date( 'Y', $current_time ) - 1;
670
+			$dates['year']    = date('Y');
671
+
672
+			if (date('j', $current_time) <= 7) {
673
+				$dates['m_start'] = date('n', $current_time) - 1;
674
+				$dates['m_end']   = date('n', $current_time) - 1;
675
+				if ($dates['m_start'] <= 1) {
676
+					$dates['year']     = date('Y', $current_time) - 1;
677
+					$dates['year_end'] = date('Y', $current_time) - 1;
678 678
 				}
679 679
 			} else {
680
-				$dates['m_start'] = date( 'n', $current_time );
681
-				$dates['m_end']   = date( 'n', $current_time );
680
+				$dates['m_start'] = date('n', $current_time);
681
+				$dates['m_end']   = date('n', $current_time);
682 682
 			}
683 683
 			break;
684 684
 
685 685
 		case 'this_quarter' :
686
-			$month_now = date( 'n', $current_time );
686
+			$month_now = date('n', $current_time);
687 687
 
688
-			if ( $month_now <= 3 ) {
688
+			if ($month_now <= 3) {
689 689
 
690 690
 				$dates['m_start'] = 1;
691 691
 				$dates['m_end']   = 4;
692
-				$dates['year']    = date( 'Y', $current_time );
692
+				$dates['year']    = date('Y', $current_time);
693 693
 
694
-			} else if ( $month_now <= 6 ) {
694
+			} else if ($month_now <= 6) {
695 695
 
696 696
 				$dates['m_start'] = 4;
697 697
 				$dates['m_end']   = 7;
698
-				$dates['year']    = date( 'Y', $current_time );
698
+				$dates['year']    = date('Y', $current_time);
699 699
 
700
-			} else if ( $month_now <= 9 ) {
700
+			} else if ($month_now <= 9) {
701 701
 
702 702
 				$dates['m_start'] = 7;
703 703
 				$dates['m_end']   = 10;
704
-				$dates['year']    = date( 'Y', $current_time );
704
+				$dates['year']    = date('Y', $current_time);
705 705
 
706 706
 			} else {
707 707
 
708 708
 				$dates['m_start']  = 10;
709 709
 				$dates['m_end']    = 1;
710
-				$dates['year']     = date( 'Y', $current_time );
711
-				$dates['year_end'] = date( 'Y', $current_time ) + 1;
710
+				$dates['year']     = date('Y', $current_time);
711
+				$dates['year_end'] = date('Y', $current_time) + 1;
712 712
 
713 713
 			}
714 714
 			break;
715 715
 
716 716
 		case 'last_quarter' :
717
-			$month_now = date( 'n' );
717
+			$month_now = date('n');
718 718
 
719
-			if ( $month_now <= 3 ) {
719
+			if ($month_now <= 3) {
720 720
 
721 721
 				$dates['m_start']  = 10;
722 722
 				$dates['m_end']    = 12;
723
-				$dates['year']     = date( 'Y', $current_time ) - 1; // Previous year
724
-				$dates['year_end'] = date( 'Y', $current_time ) - 1; // Previous year
723
+				$dates['year']     = date('Y', $current_time) - 1; // Previous year
724
+				$dates['year_end'] = date('Y', $current_time) - 1; // Previous year
725 725
 
726
-			} else if ( $month_now <= 6 ) {
726
+			} else if ($month_now <= 6) {
727 727
 
728 728
 				$dates['m_start'] = 1;
729 729
 				$dates['m_end']   = 3;
730
-				$dates['year']    = date( 'Y', $current_time );
730
+				$dates['year']    = date('Y', $current_time);
731 731
 
732
-			} else if ( $month_now <= 9 ) {
732
+			} else if ($month_now <= 9) {
733 733
 
734 734
 				$dates['m_start'] = 4;
735 735
 				$dates['m_end']   = 6;
736
-				$dates['year']    = date( 'Y', $current_time );
736
+				$dates['year']    = date('Y', $current_time);
737 737
 
738 738
 			} else {
739 739
 
740 740
 				$dates['m_start'] = 7;
741 741
 				$dates['m_end']   = 9;
742
-				$dates['year']    = date( 'Y', $current_time );
742
+				$dates['year']    = date('Y', $current_time);
743 743
 
744 744
 			}
745 745
 			break;
@@ -747,19 +747,19 @@  discard block
 block discarded – undo
747 747
 		case 'this_year' :
748 748
 			$dates['m_start'] = 1;
749 749
 			$dates['m_end']   = 12;
750
-			$dates['year']    = date( 'Y', $current_time );
750
+			$dates['year']    = date('Y', $current_time);
751 751
 			break;
752 752
 
753 753
 		case 'last_year' :
754 754
 			$dates['m_start']  = 1;
755 755
 			$dates['m_end']    = 12;
756
-			$dates['year']     = date( 'Y', $current_time ) - 1;
757
-			$dates['year_end'] = date( 'Y', $current_time ) - 1;
756
+			$dates['year']     = date('Y', $current_time) - 1;
757
+			$dates['year_end'] = date('Y', $current_time) - 1;
758 758
 			break;
759 759
 
760 760
 	endswitch;
761 761
 
762
-	return apply_filters( 'give_report_dates', $dates );
762
+	return apply_filters('give_report_dates', $dates);
763 763
 }
764 764
 
765 765
 /**
@@ -769,17 +769,17 @@  discard block
 block discarded – undo
769 769
  *
770 770
  * @param $data
771 771
  */
772
-function give_parse_report_dates( $data ) {
772
+function give_parse_report_dates($data) {
773 773
 	$dates = give_get_report_dates();
774 774
 
775 775
 	$view = give_get_reporting_view();
776
-	$id   = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null;
776
+	$id   = isset($_GET['form-id']) ? $_GET['form-id'] : null;
777 777
 
778
-	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 ) ) ) );
778
+	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))));
779 779
 	give_die();
780 780
 }
781 781
 
782
-add_action( 'give_filter_reports', 'give_parse_report_dates' );
782
+add_action('give_filter_reports', 'give_parse_report_dates');
783 783
 
784 784
 
785 785
 /**
@@ -789,16 +789,16 @@  discard block
 block discarded – undo
789 789
  */
790 790
 function give_reports_refresh_button() {
791 791
 
792
-	$url = wp_nonce_url( add_query_arg( array(
792
+	$url = wp_nonce_url(add_query_arg(array(
793 793
 		'give_action'  => 'refresh_reports_transients',
794 794
 		'give-message' => 'refreshed-reports'
795
-	) ), 'give-refresh-reports' );
795
+	)), 'give-refresh-reports');
796 796
 
797
-	echo '<a href="' . $url . '" data-tooltip="' . __( '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">' . __( 'Refresh Reports', 'give' ) . '</a>';
797
+	echo '<a href="'.$url.'" data-tooltip="'.__('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">'.__('Refresh Reports', 'give').'</a>';
798 798
 
799 799
 }
800 800
 
801
-add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' );
801
+add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button');
802 802
 
803 803
 /**
804 804
  * Trigger the refresh of reports transients
@@ -809,18 +809,18 @@  discard block
 block discarded – undo
809 809
  *
810 810
  * @return void
811 811
  */
812
-function give_run_refresh_reports_transients( $data ) {
812
+function give_run_refresh_reports_transients($data) {
813 813
 
814
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) {
814
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) {
815 815
 		return;
816 816
 	}
817 817
 
818 818
 	//Delete transients
819
-	delete_transient( 'give_estimated_monthly_stats' );
820
-	delete_transient( 'give_earnings_total' );
821
-	delete_transient( md5( 'give_earnings_this_monththis_month' ) );
822
-	delete_transient( md5( 'give_earnings_todaytoday' ) );
819
+	delete_transient('give_estimated_monthly_stats');
820
+	delete_transient('give_earnings_total');
821
+	delete_transient(md5('give_earnings_this_monththis_month'));
822
+	delete_transient(md5('give_earnings_todaytoday'));
823 823
 
824 824
 }
825 825
 
826
-add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' );
827 826
\ No newline at end of file
827
+add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients');
828 828
\ No newline at end of file
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.
includes/admin/shortcodes/abstract-shortcode-generator.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	/**
105 105
 	 * Define the shortcode attribute fields
106 106
 	 *
107
-	 * @return false|array
107
+	 * @return boolean
108 108
 	 *
109 109
 	 * @since 1.0
110 110
 	 */
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	/**
117 117
 	 * Generate the shortcode dialog fields
118 118
 	 *
119
-	 * @param array $defined_fields
119
+	 * @param boolean $defined_fields
120 120
 	 *
121 121
 	 * @return array
122 122
 	 *
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -246,8 +246,8 @@
 block discarded – undo
246 246
 
247 247
 			// do not reindex array!
248 248
 			$field['options'] = array(
249
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : sprintf( '– %s –', __( 'Select', 'give' ) ) ),
250
-			                    ) + $field['options'];
249
+									'' => ( $field['placeholder'] ? $field['placeholder'] : sprintf( '– %s –', __( 'Select', 'give' ) ) ),
250
+								) + $field['options'];
251 251
 
252 252
 			foreach ( $field['options'] as $value => $text ) {
253 253
 				$new_listbox['values'][] = array(
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @since       1.3.0
12 12
  */
13 13
 
14
-defined( 'ABSPATH' ) or exit;
14
+defined('ABSPATH') or exit;
15 15
 
16 16
 abstract class Give_Shortcode_Generator {
17 17
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @since 1.0
59 59
 	 */
60
-	public function __construct( $shortcode ) {
60
+	public function __construct($shortcode) {
61 61
 
62 62
 
63 63
 		$this->shortcode_tag = $shortcode;
64 64
 
65
-		add_action( 'admin_init', array( $this, 'init' ) );
65
+		add_action('admin_init', array($this, 'init'));
66 66
 
67 67
 	}
68 68
 
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function init() {
75 75
 
76
-		if ( $this->shortcode_tag ) {
76
+		if ($this->shortcode_tag) {
77 77
 
78
-			$this->self = get_class( $this );
78
+			$this->self = get_class($this);
79 79
 
80 80
 			$this->errors   = array();
81 81
 			$this->required = array();
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 			$fields = $this->get_fields();
85 85
 
86 86
 			$defaults = array(
87
-				'btn_close' => __( 'Close', 'give' ),
88
-				'btn_okay'  => __( 'Insert Shortcode', 'give' ),
87
+				'btn_close' => __('Close', 'give'),
88
+				'btn_okay'  => __('Insert Shortcode', 'give'),
89 89
 				'errors'    => $this->errors,
90 90
 				'fields'    => $fields,
91
-				'label'     => '[' . $this->shortcode_tag . ']',
91
+				'label'     => '['.$this->shortcode_tag.']',
92 92
 				'required'  => $this->required,
93
-				'title'     => __( 'Insert Shortcode', 'give' ),
93
+				'title'     => __('Insert Shortcode', 'give'),
94 94
 			);
95 95
 
96
-			if ( user_can_richedit() ) {
96
+			if (user_can_richedit()) {
97 97
 
98
-				Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults );
98
+				Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults);
99 99
 
100 100
 			}
101 101
 		}
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @since 1.0
126 126
 	 */
127
-	protected function generate_fields( $defined_fields ) {
127
+	protected function generate_fields($defined_fields) {
128 128
 
129 129
 		$fields = array();
130 130
 
131
-		if ( is_array( $defined_fields ) ) {
131
+		if (is_array($defined_fields)) {
132 132
 
133
-			foreach ( $defined_fields as $field ) {
133
+			foreach ($defined_fields as $field) {
134 134
 
135 135
 				$defaults = array(
136 136
 					'label'       => false,
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
 					'type'        => '',
142 142
 				);
143 143
 
144
-				$field  = wp_parse_args( (array) $field, $defaults );
145
-				$method = 'generate_' . strtolower( $field['type'] );
144
+				$field  = wp_parse_args((array) $field, $defaults);
145
+				$method = 'generate_'.strtolower($field['type']);
146 146
 
147
-				if ( method_exists( $this, $method ) ) {
147
+				if (method_exists($this, $method)) {
148 148
 
149
-					$field = call_user_func( array( $this, $method ), $field );
149
+					$field = call_user_func(array($this, $method), $field);
150 150
 
151
-					if ( $field ) {
151
+					if ($field) {
152 152
 						$fields[] = $field;
153 153
 					}
154 154
 				}
@@ -168,22 +168,22 @@  discard block
 block discarded – undo
168 168
 	protected function get_fields() {
169 169
 
170 170
 		$defined_fields   = $this->define_fields();
171
-		$generated_fields = $this->generate_fields( $defined_fields );
171
+		$generated_fields = $this->generate_fields($defined_fields);
172 172
 
173 173
 		$errors = array();
174 174
 
175
-		if ( ! empty( $this->errors ) ) {
176
-			foreach ( $this->required as $name => $alert ) {
177
-				if ( false === array_search( $name, array_column( $generated_fields, 'name' ) ) ) {
175
+		if ( ! empty($this->errors)) {
176
+			foreach ($this->required as $name => $alert) {
177
+				if (false === array_search($name, array_column($generated_fields, 'name'))) {
178 178
 
179
-					$errors[] = $this->errors[ $name ];
179
+					$errors[] = $this->errors[$name];
180 180
 				}
181 181
 			}
182 182
 
183 183
 			$this->errors = $errors;
184 184
 		}
185 185
 
186
-		if ( ! empty( $errors ) ) {
186
+		if ( ! empty($errors)) {
187 187
 
188 188
 			return $errors;
189 189
 		}
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @since 1.0
202 202
 	 */
203
-	protected function generate_container( $field ) {
203
+	protected function generate_container($field) {
204 204
 
205
-		if ( array_key_exists( 'html', $field ) ) {
205
+		if (array_key_exists('html', $field)) {
206 206
 
207 207
 			return array(
208 208
 				'type' => $field['type'],
@@ -222,36 +222,36 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @since 1.0
224 224
 	 */
225
-	protected function generate_listbox( $field ) {
225
+	protected function generate_listbox($field) {
226 226
 
227
-		$listbox = shortcode_atts( array(
227
+		$listbox = shortcode_atts(array(
228 228
 			'label'    => '',
229 229
 			'minWidth' => '',
230 230
 			'name'     => false,
231 231
 			'tooltip'  => '',
232 232
 			'type'     => '',
233 233
 			'value'    => '',
234
-		), $field );
234
+		), $field);
235 235
 
236
-		if ( $this->validate( $field ) ) {
236
+		if ($this->validate($field)) {
237 237
 
238 238
 			$new_listbox = array();
239 239
 
240
-			foreach ( $listbox as $key => $value ) {
240
+			foreach ($listbox as $key => $value) {
241 241
 
242
-				if ( $key == 'value' && empty( $value ) ) {
243
-					$new_listbox[ $key ] = $listbox['name'];
244
-				} else if ( $value ) {
245
-					$new_listbox[ $key ] = $value;
242
+				if ($key == 'value' && empty($value)) {
243
+					$new_listbox[$key] = $listbox['name'];
244
+				} else if ($value) {
245
+					$new_listbox[$key] = $value;
246 246
 				}
247 247
 			}
248 248
 
249 249
 			// do not reindex array!
250 250
 			$field['options'] = array(
251
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : sprintf( '– %s –', __( 'Select', 'give' ) ) ),
251
+				                    '' => ($field['placeholder'] ? $field['placeholder'] : sprintf('– %s –', __('Select', 'give'))),
252 252
 			                    ) + $field['options'];
253 253
 
254
-			foreach ( $field['options'] as $value => $text ) {
254
+			foreach ($field['options'] as $value => $text) {
255 255
 				$new_listbox['values'][] = array(
256 256
 					'text'  => $text,
257 257
 					'value' => $value,
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @since 1.0
275 275
 	 */
276
-	protected function generate_post( $field ) {
276
+	protected function generate_post($field) {
277 277
 
278 278
 		$args = array(
279 279
 			'post_type'      => 'post',
@@ -282,23 +282,23 @@  discard block
 block discarded – undo
282 282
 			'posts_per_page' => 30,
283 283
 		);
284 284
 
285
-		$args    = wp_parse_args( (array) $field['query_args'], $args );
286
-		$posts   = get_posts( $args );
285
+		$args    = wp_parse_args((array) $field['query_args'], $args);
286
+		$posts   = get_posts($args);
287 287
 		$options = array();
288 288
 
289
-		if ( $posts ) {
290
-			foreach ( $posts as $post ) {
291
-				$options[ absint( $post->ID ) ] = esc_html( $post->post_title );
289
+		if ($posts) {
290
+			foreach ($posts as $post) {
291
+				$options[absint($post->ID)] = esc_html($post->post_title);
292 292
 			}
293 293
 
294 294
 			$field['type']    = 'listbox';
295 295
 			$field['options'] = $options;
296 296
 
297
-			return $this->generate_listbox( $field );
297
+			return $this->generate_listbox($field);
298 298
 		}
299 299
 
300 300
 		// perform validation here before returning false
301
-		$this->validate( $field );
301
+		$this->validate($field);
302 302
 
303 303
 		return false;
304 304
 	}
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @since 1.0
314 314
 	 */
315
-	protected function generate_textbox( $field ) {
315
+	protected function generate_textbox($field) {
316 316
 
317
-		$textbox = shortcode_atts( array(
317
+		$textbox = shortcode_atts(array(
318 318
 			'label'     => '',
319 319
 			'maxLength' => '',
320 320
 			'minHeight' => '',
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 			'tooltip'   => '',
325 325
 			'type'      => '',
326 326
 			'value'     => '',
327
-		), $field );
327
+		), $field);
328 328
 
329
-		if ( $this->validate( $field ) ) {
330
-			return array_filter( $textbox, array( $this, 'return_textbox_value' ) );
329
+		if ($this->validate($field)) {
330
+			return array_filter($textbox, array($this, 'return_textbox_value'));
331 331
 		}
332 332
 
333 333
 		return false;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 *
341 341
 	 * @return bool
342 342
 	 */
343
-	function return_textbox_value( $value ) {
343
+	function return_textbox_value($value) {
344 344
 		return $value !== '';
345 345
 	}
346 346
 
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 	 *
357 357
 	 * @since 1.0
358 358
 	 */
359
-	protected function validate( $field ) {
359
+	protected function validate($field) {
360 360
 
361
-		extract( shortcode_atts(
361
+		extract(shortcode_atts(
362 362
 				array(
363 363
 					'name'     => false,
364 364
 					'required' => false,
@@ -366,34 +366,34 @@  discard block
 block discarded – undo
366 366
 				), $field )
367 367
 		);
368 368
 
369
-		if ( $name ) {
369
+		if ($name) {
370 370
 
371
-			if ( isset( $required['error'] ) ) {
371
+			if (isset($required['error'])) {
372 372
 
373 373
 				$error = array(
374 374
 					'type' => 'container',
375 375
 					'html' => $required['error'],
376 376
 				);
377 377
 
378
-				$this->errors[ $name ] = $this->generate_container( $error );
378
+				$this->errors[$name] = $this->generate_container($error);
379 379
 			}
380 380
 
381
-			if ( ! ! $required || is_array( $required ) ) {
381
+			if ( ! ! $required || is_array($required)) {
382 382
 
383
-				$alert = __( 'Some of the Shortcode options are required.', 'give' );
383
+				$alert = __('Some of the Shortcode options are required.', 'give');
384 384
 
385
-				if ( isset( $required['alert'] ) ) {
385
+				if (isset($required['alert'])) {
386 386
 
387 387
 					$alert = $required['alert'];
388 388
 
389
-				} else if ( ! empty( $label ) ) {
389
+				} else if ( ! empty($label)) {
390 390
 
391
-					$alert = sprintf( __( 'The "%s" option is required.', 'give' ),
392
-						str_replace( ':', '', $label )
391
+					$alert = sprintf(__('The "%s" option is required.', 'give'),
392
+						str_replace(':', '', $label)
393 393
 					);
394 394
 				}
395 395
 
396
-				$this->required[ $name ] = $alert;
396
+				$this->required[$name] = $alert;
397 397
 			}
398 398
 
399 399
 			return true;
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.
Spacing   +478 added lines, -478 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
 
@@ -139,27 +139,27 @@  discard block
 block discarded – undo
139 139
 			'v1' => 'GIVE_API_V1',
140 140
 		);
141 141
 
142
-		foreach ( $this->get_versions() as $version => $class ) {
143
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
142
+		foreach ($this->get_versions() as $version => $class) {
143
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
144 144
 		}
145 145
 
146
-		add_action( 'init', array( $this, 'add_endpoint' ) );
147
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
148
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
149
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
150
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
151
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
152
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
153
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
146
+		add_action('init', array($this, 'add_endpoint'));
147
+		add_action('wp', array($this, 'process_query'), - 1);
148
+		add_filter('query_vars', array($this, 'query_vars'));
149
+		add_action('show_user_profile', array($this, 'user_key_field'));
150
+		add_action('edit_user_profile', array($this, 'user_key_field'));
151
+		add_action('personal_options_update', array($this, 'update_key'));
152
+		add_action('edit_user_profile_update', array($this, 'update_key'));
153
+		add_action('give_process_api_key', array($this, 'process_api_key'));
154 154
 
155 155
 		// Setup a backwards compatibility check for user API Keys
156
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
156
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
157 157
 
158 158
 		// Determine if JSON_PRETTY_PRINT is available
159
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
159
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
160 160
 
161 161
 		// Allow API request logging to be turned off
162
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
162
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
163 163
 
164 164
 		// Setup Give_Payment_Stats instance
165 165
 		$this->stats = new Give_Payment_Stats;
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @since  1.1
177 177
 	 */
178
-	public function add_endpoint( $rewrite_rules ) {
179
-		add_rewrite_endpoint( 'give-api', EP_ALL );
178
+	public function add_endpoint($rewrite_rules) {
179
+		add_rewrite_endpoint('give-api', EP_ALL);
180 180
 	}
181 181
 
182 182
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return string[] $vars New query vars
191 191
 	 */
192
-	public function query_vars( $vars ) {
192
+	public function query_vars($vars) {
193 193
 
194 194
 		$vars[] = 'token';
195 195
 		$vars[] = 'key';
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function get_default_version() {
242 242
 
243
-		$version = get_option( 'give_default_api_version' );
243
+		$version = get_option('give_default_api_version');
244 244
 
245
-		if ( defined( 'GIVE_API_VERSION' ) ) {
245
+		if (defined('GIVE_API_VERSION')) {
246 246
 			$version = GIVE_API_VERSION;
247
-		} elseif ( ! $version ) {
247
+		} elseif ( ! $version) {
248 248
 			$version = 'v1';
249 249
 		}
250 250
 
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 
266 266
 		$version = $wp_query->query_vars['give-api'];
267 267
 
268
-		if ( strpos( $version, '/' ) ) {
268
+		if (strpos($version, '/')) {
269 269
 
270
-			$version = explode( '/', $version );
271
-			$version = strtolower( $version[0] );
270
+			$version = explode('/', $version);
271
+			$version = strtolower($version[0]);
272 272
 
273
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
273
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
274 274
 
275
-			if ( array_key_exists( $version, $this->versions ) ) {
275
+			if (array_key_exists($version, $this->versions)) {
276 276
 
277 277
 				$this->queried_version = $version;
278 278
 
@@ -309,32 +309,32 @@  discard block
 block discarded – undo
309 309
 		$this->override = false;
310 310
 
311 311
 		// Make sure we have both user and api key
312
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
312
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) {
313 313
 
314
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
314
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
315 315
 				$this->missing_auth();
316 316
 			}
317 317
 
318 318
 			// Retrieve the user by public API key and ensure they exist
319
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
319
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
320 320
 
321 321
 				$this->invalid_key();
322 322
 
323 323
 			} else {
324 324
 
325
-				$token  = urldecode( $wp_query->query_vars['token'] );
326
-				$secret = $this->get_user_secret_key( $user );
327
-				$public = urldecode( $wp_query->query_vars['key'] );
325
+				$token  = urldecode($wp_query->query_vars['token']);
326
+				$secret = $this->get_user_secret_key($user);
327
+				$public = urldecode($wp_query->query_vars['key']);
328 328
 
329
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
329
+				if (hash_equals(md5($secret.$public), $token)) {
330 330
 					$this->is_valid_request = true;
331 331
 				} else {
332 332
 					$this->invalid_auth();
333 333
 				}
334 334
 			}
335
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) {
335
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') {
336 336
 			$this->is_valid_request = true;
337
-			$wp_query->set( 'key', 'public' );
337
+			$wp_query->set('key', 'public');
338 338
 		}
339 339
 	}
340 340
 
@@ -350,25 +350,25 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @return bool if user ID is found, false otherwise
352 352
 	 */
353
-	public function get_user( $key = '' ) {
353
+	public function get_user($key = '') {
354 354
 		global $wpdb, $wp_query;
355 355
 
356
-		if ( empty( $key ) ) {
357
-			$key = urldecode( $wp_query->query_vars['key'] );
356
+		if (empty($key)) {
357
+			$key = urldecode($wp_query->query_vars['key']);
358 358
 		}
359 359
 
360
-		if ( empty( $key ) ) {
360
+		if (empty($key)) {
361 361
 			return false;
362 362
 		}
363 363
 
364
-		$user = get_transient( md5( 'give_api_user_' . $key ) );
364
+		$user = get_transient(md5('give_api_user_'.$key));
365 365
 
366
-		if ( false === $user ) {
367
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
368
-			set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS );
366
+		if (false === $user) {
367
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
368
+			set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS);
369 369
 		}
370 370
 
371
-		if ( $user != null ) {
371
+		if ($user != null) {
372 372
 			$this->user_id = $user;
373 373
 
374 374
 			return $user;
@@ -377,37 +377,37 @@  discard block
 block discarded – undo
377 377
 		return false;
378 378
 	}
379 379
 
380
-	public function get_user_public_key( $user_id = 0 ) {
380
+	public function get_user_public_key($user_id = 0) {
381 381
 		global $wpdb;
382 382
 
383
-		if ( empty( $user_id ) ) {
383
+		if (empty($user_id)) {
384 384
 			return '';
385 385
 		}
386 386
 
387
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
388
-		$user_public_key = get_transient( $cache_key );
387
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
388
+		$user_public_key = get_transient($cache_key);
389 389
 
390
-		if ( empty( $user_public_key ) ) {
391
-			$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 ) );
392
-			set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS );
390
+		if (empty($user_public_key)) {
391
+			$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));
392
+			set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS);
393 393
 		}
394 394
 
395 395
 		return $user_public_key;
396 396
 	}
397 397
 
398
-	public function get_user_secret_key( $user_id = 0 ) {
398
+	public function get_user_secret_key($user_id = 0) {
399 399
 		global $wpdb;
400 400
 
401
-		if ( empty( $user_id ) ) {
401
+		if (empty($user_id)) {
402 402
 			return '';
403 403
 		}
404 404
 
405
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
406
-		$user_secret_key = get_transient( $cache_key );
405
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
406
+		$user_secret_key = get_transient($cache_key);
407 407
 
408
-		if ( empty( $user_secret_key ) ) {
409
-			$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 ) );
410
-			set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS );
408
+		if (empty($user_secret_key)) {
409
+			$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));
410
+			set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS);
411 411
 		}
412 412
 
413 413
 		return $user_secret_key;
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	private function missing_auth() {
425 425
 		$error          = array();
426
-		$error['error'] = esc_attr__( 'You must specify both a token and API key!', 'give' );
426
+		$error['error'] = esc_attr__('You must specify both a token and API key!', 'give');
427 427
 
428 428
 		$this->data = $error;
429
-		$this->output( 401 );
429
+		$this->output(401);
430 430
 	}
431 431
 
432 432
 	/**
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
 	 */
441 441
 	private function invalid_auth() {
442 442
 		$error          = array();
443
-		$error['error'] = esc_attr__( 'Your request could not be authenticated!', 'give' );
443
+		$error['error'] = esc_attr__('Your request could not be authenticated!', 'give');
444 444
 
445 445
 		$this->data = $error;
446
-		$this->output( 403 );
446
+		$this->output(403);
447 447
 	}
448 448
 
449 449
 	/**
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	private function invalid_key() {
459 459
 		$error          = array();
460
-		$error['error'] = esc_attr__( 'Invalid API key!', 'give' );
460
+		$error['error'] = esc_attr__('Invalid API key!', 'give');
461 461
 
462 462
 		$this->data = $error;
463
-		$this->output( 403 );
463
+		$this->output(403);
464 464
 	}
465 465
 
466 466
 	/**
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
 	 */
474 474
 	private function invalid_version() {
475 475
 		$error          = array();
476
-		$error['error'] = esc_attr__( 'Invalid API version!', 'give' );
476
+		$error['error'] = esc_attr__('Invalid API version!', 'give');
477 477
 
478 478
 		$this->data = $error;
479
-		$this->output( 404 );
479
+		$this->output(404);
480 480
 	}
481 481
 
482 482
 	/**
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 		global $wp_query;
493 493
 
494 494
 		// Start logging how long the request takes for logging
495
-		$before = microtime( true );
495
+		$before = microtime(true);
496 496
 
497 497
 		// Check for give-api var. Get out if not present
498
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
498
+		if (empty($wp_query->query_vars['give-api'])) {
499 499
 			return;
500 500
 		}
501 501
 
@@ -509,45 +509,45 @@  discard block
 block discarded – undo
509 509
 		$this->validate_request();
510 510
 
511 511
 		// Only proceed if no errors have been noted
512
-		if ( ! $this->is_valid_request ) {
512
+		if ( ! $this->is_valid_request) {
513 513
 			return;
514 514
 		}
515 515
 
516
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
517
-			define( 'GIVE_DOING_API', true );
516
+		if ( ! defined('GIVE_DOING_API')) {
517
+			define('GIVE_DOING_API', true);
518 518
 		}
519 519
 
520 520
 		$data         = array();
521 521
 		$this->routes = new $this->versions[$this->get_queried_version()];
522 522
 		$this->routes->validate_request();
523 523
 
524
-		switch ( $this->endpoint ) :
524
+		switch ($this->endpoint) :
525 525
 
526 526
 			case 'stats' :
527 527
 
528
-				$data = $this->routes->get_stats( array(
529
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
530
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
531
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
532
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
533
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null
534
-				) );
528
+				$data = $this->routes->get_stats(array(
529
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
530
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
531
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
532
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
533
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null
534
+				));
535 535
 
536 536
 				break;
537 537
 
538 538
 			case 'forms' :
539 539
 
540
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
540
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
541 541
 
542
-				$data = $this->routes->get_forms( $form );
542
+				$data = $this->routes->get_forms($form);
543 543
 
544 544
 				break;
545 545
 
546 546
 			case 'donors' :
547 547
 
548
-				$customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
548
+				$customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
549 549
 
550
-				$data = $this->routes->get_customers( $customer );
550
+				$data = $this->routes->get_customers($customer);
551 551
 
552 552
 				break;
553 553
 
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 		endswitch;
561 561
 
562 562
 		// Allow extensions to setup their own return data
563
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
563
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
564 564
 
565
-		$after                       = microtime( true );
566
-		$request_time                = ( $after - $before );
565
+		$after                       = microtime(true);
566
+		$request_time                = ($after - $before);
567 567
 		$this->data['request_speed'] = $request_time;
568 568
 
569 569
 		// Log this API request, if enabled. We log it here because we have access to errors.
570
-		$this->log_request( $this->data );
570
+		$this->log_request($this->data);
571 571
 
572 572
 		// Send out data to the output function
573 573
 		$this->output();
@@ -597,25 +597,25 @@  discard block
 block discarded – undo
597 597
 		global $wp_query;
598 598
 
599 599
 		// Whitelist our query options
600
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
600
+		$accepted = apply_filters('give_api_valid_query_modes', array(
601 601
 			'stats',
602 602
 			'forms',
603 603
 			'donors',
604 604
 			'donations'
605
-		) );
605
+		));
606 606
 
607
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
608
-		$query = str_replace( $this->queried_version . '/', '', $query );
607
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
608
+		$query = str_replace($this->queried_version.'/', '', $query);
609 609
 
610 610
 		$error = array();
611 611
 
612 612
 		// Make sure our query is valid
613
-		if ( ! in_array( $query, $accepted ) ) {
614
-			$error['error'] = __( 'Invalid query!', 'give' );
613
+		if ( ! in_array($query, $accepted)) {
614
+			$error['error'] = __('Invalid query!', 'give');
615 615
 
616 616
 			$this->data = $error;
617 617
 			// 400 is Bad Request
618
-			$this->output( 400 );
618
+			$this->output(400);
619 619
 		}
620 620
 
621 621
 		$this->endpoint = $query;
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	public function get_paged() {
633 633
 		global $wp_query;
634 634
 
635
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
635
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
636 636
 	}
637 637
 
638 638
 
@@ -647,13 +647,13 @@  discard block
 block discarded – undo
647 647
 	public function per_page() {
648 648
 		global $wp_query;
649 649
 
650
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
650
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
651 651
 
652
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
652
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
653 653
 			$per_page = 99999999;
654 654
 		} // Customers query doesn't support -1
655 655
 
656
-		return apply_filters( 'give_api_results_per_page', $per_page );
656
+		return apply_filters('give_api_results_per_page', $per_page);
657 657
 	}
658 658
 
659 659
 	/**
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	 *
667 667
 	 * @return array $dates
668 668
 	 */
669
-	public function get_dates( $args = array() ) {
669
+	public function get_dates($args = array()) {
670 670
 		$dates = array();
671 671
 
672 672
 		$defaults = array(
@@ -677,60 +677,60 @@  discard block
 block discarded – undo
677 677
 			'enddate'   => null
678 678
 		);
679 679
 
680
-		$args = wp_parse_args( $args, $defaults );
680
+		$args = wp_parse_args($args, $defaults);
681 681
 
682
-		$current_time = current_time( 'timestamp' );
682
+		$current_time = current_time('timestamp');
683 683
 
684
-		if ( 'range' === $args['date'] ) {
685
-			$startdate          = strtotime( $args['startdate'] );
686
-			$enddate            = strtotime( $args['enddate'] );
687
-			$dates['day_start'] = date( 'd', $startdate );
688
-			$dates['day_end']   = date( 'd', $enddate );
689
-			$dates['m_start']   = date( 'n', $startdate );
690
-			$dates['m_end']     = date( 'n', $enddate );
691
-			$dates['year']      = date( 'Y', $startdate );
692
-			$dates['year_end']  = date( 'Y', $enddate );
684
+		if ('range' === $args['date']) {
685
+			$startdate          = strtotime($args['startdate']);
686
+			$enddate            = strtotime($args['enddate']);
687
+			$dates['day_start'] = date('d', $startdate);
688
+			$dates['day_end']   = date('d', $enddate);
689
+			$dates['m_start']   = date('n', $startdate);
690
+			$dates['m_end']     = date('n', $enddate);
691
+			$dates['year']      = date('Y', $startdate);
692
+			$dates['year_end']  = date('Y', $enddate);
693 693
 		} else {
694 694
 			// Modify dates based on predefined ranges
695
-			switch ( $args['date'] ) :
695
+			switch ($args['date']) :
696 696
 
697 697
 				case 'this_month' :
698 698
 					$dates['day']     = null;
699
-					$dates['m_start'] = date( 'n', $current_time );
700
-					$dates['m_end']   = date( 'n', $current_time );
701
-					$dates['year']    = date( 'Y', $current_time );
699
+					$dates['m_start'] = date('n', $current_time);
700
+					$dates['m_end']   = date('n', $current_time);
701
+					$dates['year']    = date('Y', $current_time);
702 702
 					break;
703 703
 
704 704
 				case 'last_month' :
705 705
 					$dates['day']     = null;
706
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
706
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
707 707
 					$dates['m_end']   = $dates['m_start'];
708
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
708
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
709 709
 					break;
710 710
 
711 711
 				case 'today' :
712
-					$dates['day']     = date( 'd', $current_time );
713
-					$dates['m_start'] = date( 'n', $current_time );
714
-					$dates['m_end']   = date( 'n', $current_time );
715
-					$dates['year']    = date( 'Y', $current_time );
712
+					$dates['day']     = date('d', $current_time);
713
+					$dates['m_start'] = date('n', $current_time);
714
+					$dates['m_end']   = date('n', $current_time);
715
+					$dates['year']    = date('Y', $current_time);
716 716
 					break;
717 717
 
718 718
 				case 'yesterday' :
719 719
 
720
-					$year  = date( 'Y', $current_time );
721
-					$month = date( 'n', $current_time );
722
-					$day   = date( 'd', $current_time );
720
+					$year  = date('Y', $current_time);
721
+					$month = date('n', $current_time);
722
+					$day   = date('d', $current_time);
723 723
 
724
-					if ( $month == 1 && $day == 1 ) {
724
+					if ($month == 1 && $day == 1) {
725 725
 
726 726
 						$year -= 1;
727 727
 						$month = 12;
728
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
728
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
729 729
 
730
-					} elseif ( $month > 1 && $day == 1 ) {
730
+					} elseif ($month > 1 && $day == 1) {
731 731
 
732 732
 						$month -= 1;
733
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
733
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
734 734
 
735 735
 					} else {
736 736
 
@@ -746,65 +746,65 @@  discard block
 block discarded – undo
746 746
 					break;
747 747
 
748 748
 				case 'this_quarter' :
749
-					$month_now = date( 'n', $current_time );
749
+					$month_now = date('n', $current_time);
750 750
 
751 751
 					$dates['day'] = null;
752 752
 
753
-					if ( $month_now <= 3 ) {
753
+					if ($month_now <= 3) {
754 754
 
755 755
 						$dates['m_start'] = 1;
756 756
 						$dates['m_end']   = 3;
757
-						$dates['year']    = date( 'Y', $current_time );
757
+						$dates['year']    = date('Y', $current_time);
758 758
 
759
-					} else if ( $month_now <= 6 ) {
759
+					} else if ($month_now <= 6) {
760 760
 
761 761
 						$dates['m_start'] = 4;
762 762
 						$dates['m_end']   = 6;
763
-						$dates['year']    = date( 'Y', $current_time );
763
+						$dates['year']    = date('Y', $current_time);
764 764
 
765
-					} else if ( $month_now <= 9 ) {
765
+					} else if ($month_now <= 9) {
766 766
 
767 767
 						$dates['m_start'] = 7;
768 768
 						$dates['m_end']   = 9;
769
-						$dates['year']    = date( 'Y', $current_time );
769
+						$dates['year']    = date('Y', $current_time);
770 770
 
771 771
 					} else {
772 772
 
773 773
 						$dates['m_start'] = 10;
774 774
 						$dates['m_end']   = 12;
775
-						$dates['year']    = date( 'Y', $current_time );
775
+						$dates['year']    = date('Y', $current_time);
776 776
 
777 777
 					}
778 778
 					break;
779 779
 
780 780
 				case 'last_quarter' :
781
-					$month_now = date( 'n', $current_time );
781
+					$month_now = date('n', $current_time);
782 782
 
783 783
 					$dates['day'] = null;
784 784
 
785
-					if ( $month_now <= 3 ) {
785
+					if ($month_now <= 3) {
786 786
 
787 787
 						$dates['m_start'] = 10;
788 788
 						$dates['m_end']   = 12;
789
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
789
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
790 790
 
791
-					} else if ( $month_now <= 6 ) {
791
+					} else if ($month_now <= 6) {
792 792
 
793 793
 						$dates['m_start'] = 1;
794 794
 						$dates['m_end']   = 3;
795
-						$dates['year']    = date( 'Y', $current_time );
795
+						$dates['year']    = date('Y', $current_time);
796 796
 
797
-					} else if ( $month_now <= 9 ) {
797
+					} else if ($month_now <= 9) {
798 798
 
799 799
 						$dates['m_start'] = 4;
800 800
 						$dates['m_end']   = 6;
801
-						$dates['year']    = date( 'Y', $current_time );
801
+						$dates['year']    = date('Y', $current_time);
802 802
 
803 803
 					} else {
804 804
 
805 805
 						$dates['m_start'] = 7;
806 806
 						$dates['m_end']   = 9;
807
-						$dates['year']    = date( 'Y', $current_time );
807
+						$dates['year']    = date('Y', $current_time);
808 808
 
809 809
 					}
810 810
 					break;
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 					$dates['day']     = null;
814 814
 					$dates['m_start'] = null;
815 815
 					$dates['m_end']   = null;
816
-					$dates['year']    = date( 'Y', $current_time );
816
+					$dates['year']    = date('Y', $current_time);
817 817
 					break;
818 818
 
819 819
 				case 'last_year' :
820 820
 					$dates['day']     = null;
821 821
 					$dates['m_start'] = null;
822 822
 					$dates['m_end']   = null;
823
-					$dates['year']    = date( 'Y', $current_time ) - 1;
823
+					$dates['year']    = date('Y', $current_time) - 1;
824 824
 					break;
825 825
 
826 826
 			endswitch;
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		 * @param object $dates The dates used for retreiving earnings/donations
835 835
 		 */
836 836
 
837
-		return apply_filters( 'give_api_stat_dates', $dates );
837
+		return apply_filters('give_api_stat_dates', $dates);
838 838
 	}
839 839
 
840 840
 	/**
@@ -849,11 +849,11 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return array $customers Multidimensional array of the customers
851 851
 	 */
852
-	public function get_customers( $customer = null ) {
852
+	public function get_customers($customer = null) {
853 853
 
854 854
 		$customers = array();
855 855
 		$error     = array();
856
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
856
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
857 857
 			return $customers;
858 858
 		}
859 859
 
@@ -861,68 +861,68 @@  discard block
 block discarded – undo
861 861
 
862 862
 		$paged    = $this->get_paged();
863 863
 		$per_page = $this->per_page();
864
-		$offset   = $per_page * ( $paged - 1 );
864
+		$offset   = $per_page * ($paged - 1);
865 865
 
866
-		if ( is_numeric( $customer ) ) {
866
+		if (is_numeric($customer)) {
867 867
 			$field = 'id';
868 868
 		} else {
869 869
 			$field = 'email';
870 870
 		}
871 871
 
872
-		$customer_query = Give()->customers->get_customers( array(
872
+		$customer_query = Give()->customers->get_customers(array(
873 873
 			'number' => $per_page,
874 874
 			'offset' => $offset,
875 875
 			$field   => $customer
876
-		) );
876
+		));
877 877
 		$customer_count = 0;
878 878
 
879
-		if ( $customer_query ) {
879
+		if ($customer_query) {
880 880
 
881
-			foreach ( $customer_query as $customer_obj ) {
881
+			foreach ($customer_query as $customer_obj) {
882 882
 
883
-				$names      = explode( ' ', $customer_obj->name );
884
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
883
+				$names      = explode(' ', $customer_obj->name);
884
+				$first_name = ! empty($names[0]) ? $names[0] : '';
885 885
 				$last_name  = '';
886
-				if ( ! empty( $names[1] ) ) {
887
-					unset( $names[0] );
888
-					$last_name = implode( ' ', $names );
886
+				if ( ! empty($names[1])) {
887
+					unset($names[0]);
888
+					$last_name = implode(' ', $names);
889 889
 				}
890 890
 
891
-				$customers['donors'][ $customer_count ]['info']['user_id']      = '';
892
-				$customers['donors'][ $customer_count ]['info']['username']     = '';
893
-				$customers['donors'][ $customer_count ]['info']['display_name'] = '';
894
-				$customers['donors'][ $customer_count ]['info']['customer_id']  = $customer_obj->id;
895
-				$customers['donors'][ $customer_count ]['info']['first_name']   = $first_name;
896
-				$customers['donors'][ $customer_count ]['info']['last_name']    = $last_name;
897
-				$customers['donors'][ $customer_count ]['info']['email']        = $customer_obj->email;
891
+				$customers['donors'][$customer_count]['info']['user_id']      = '';
892
+				$customers['donors'][$customer_count]['info']['username']     = '';
893
+				$customers['donors'][$customer_count]['info']['display_name'] = '';
894
+				$customers['donors'][$customer_count]['info']['customer_id']  = $customer_obj->id;
895
+				$customers['donors'][$customer_count]['info']['first_name']   = $first_name;
896
+				$customers['donors'][$customer_count]['info']['last_name']    = $last_name;
897
+				$customers['donors'][$customer_count]['info']['email']        = $customer_obj->email;
898 898
 
899
-				if ( ! empty( $customer_obj->user_id ) ) {
899
+				if ( ! empty($customer_obj->user_id)) {
900 900
 
901
-					$user_data = get_userdata( $customer_obj->user_id );
901
+					$user_data = get_userdata($customer_obj->user_id);
902 902
 
903 903
 					// Customer with registered account
904
-					$customers['donors'][ $customer_count ]['info']['user_id']      = $customer_obj->user_id;
905
-					$customers['donors'][ $customer_count ]['info']['username']     = $user_data->user_login;
906
-					$customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name;
904
+					$customers['donors'][$customer_count]['info']['user_id']      = $customer_obj->user_id;
905
+					$customers['donors'][$customer_count]['info']['username']     = $user_data->user_login;
906
+					$customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name;
907 907
 
908 908
 				}
909 909
 
910
-				$customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count;
911
-				$customers['donors'][ $customer_count ]['stats']['total_spent']     = $customer_obj->purchase_value;
910
+				$customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count;
911
+				$customers['donors'][$customer_count]['stats']['total_spent']     = $customer_obj->purchase_value;
912 912
 
913
-				$customer_count ++;
913
+				$customer_count++;
914 914
 
915 915
 			}
916 916
 
917
-		} elseif ( $customer ) {
917
+		} elseif ($customer) {
918 918
 
919
-			$error['error'] = sprintf( __( 'Donor %s not found!', 'give' ), $customer );
919
+			$error['error'] = sprintf(__('Donor %s not found!', 'give'), $customer);
920 920
 
921 921
 			return $error;
922 922
 
923 923
 		} else {
924 924
 
925
-			$error['error'] = __( 'No donors found!', 'give' );
925
+			$error['error'] = __('No donors found!', 'give');
926 926
 
927 927
 			return $error;
928 928
 
@@ -941,36 +941,36 @@  discard block
 block discarded – undo
941 941
 	 *
942 942
 	 * @return array $customers Multidimensional array of the forms
943 943
 	 */
944
-	public function get_forms( $form = null ) {
944
+	public function get_forms($form = null) {
945 945
 
946 946
 		$forms = array();
947 947
 		$error = array();
948 948
 
949
-		if ( $form == null ) {
949
+		if ($form == null) {
950 950
 			$forms['forms'] = array();
951 951
 
952
-			$form_list = get_posts( array(
952
+			$form_list = get_posts(array(
953 953
 				'post_type'        => 'give_forms',
954 954
 				'posts_per_page'   => $this->per_page(),
955 955
 				'suppress_filters' => true,
956 956
 				'paged'            => $this->get_paged()
957
-			) );
957
+			));
958 958
 
959
-			if ( $form_list ) {
959
+			if ($form_list) {
960 960
 				$i = 0;
961
-				foreach ( $form_list as $form_info ) {
962
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
963
-					$i ++;
961
+				foreach ($form_list as $form_info) {
962
+					$forms['forms'][$i] = $this->get_form_data($form_info);
963
+					$i++;
964 964
 				}
965 965
 			}
966 966
 		} else {
967
-			if ( get_post_type( $form ) == 'give_forms' ) {
968
-				$form_info = get_post( $form );
967
+			if (get_post_type($form) == 'give_forms') {
968
+				$form_info = get_post($form);
969 969
 
970
-				$forms['forms'][0] = $this->get_form_data( $form_info );
970
+				$forms['forms'][0] = $this->get_form_data($form_info);
971 971
 
972 972
 			} else {
973
-				$error['error'] = sprintf( __( 'Form %s not found!', 'give' ), $form );
973
+				$error['error'] = sprintf(__('Form %s not found!', 'give'), $form);
974 974
 
975 975
 				return $error;
976 976
 			}
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 	 *
989 989
 	 * @return array                Array of post data to return back in the API
990 990
 	 */
991
-	private function get_form_data( $form_info ) {
991
+	private function get_form_data($form_info) {
992 992
 
993 993
 		$form = array();
994 994
 
@@ -998,46 +998,46 @@  discard block
 block discarded – undo
998 998
 		$form['info']['create_date']   = $form_info->post_date;
999 999
 		$form['info']['modified_date'] = $form_info->post_modified;
1000 1000
 		$form['info']['status']        = $form_info->post_status;
1001
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1002
-		$form['info']['content']       = get_post_meta( $form_info->ID, '_give_form_content', true );
1003
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1001
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1002
+		$form['info']['content']       = get_post_meta($form_info->ID, '_give_form_content', true);
1003
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1004 1004
 
1005
-		if ( give_get_option( 'enable_categories' ) == 'on' ) {
1006
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1007
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1005
+		if (give_get_option('enable_categories') == 'on') {
1006
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1007
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1008 1008
 		}
1009
-		if ( give_get_option( 'enable_tags' ) == 'on' ) {
1010
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1009
+		if (give_get_option('enable_tags') == 'on') {
1010
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1011 1011
 		}
1012 1012
 
1013
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1014
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1015
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1016
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1017
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1013
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1014
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1015
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1016
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1017
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1018 1018
 		}
1019 1019
 
1020 1020
 		$counter = 0;
1021
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1022
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1023
-				$counter ++;
1021
+		if (give_has_variable_prices($form_info->ID)) {
1022
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1023
+				$counter++;
1024 1024
 				//muli-level item
1025
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1026
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1025
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1026
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1027 1027
 
1028 1028
 			}
1029 1029
 		} else {
1030
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1030
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1031 1031
 		}
1032 1032
 
1033
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1033
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1034 1034
 
1035 1035
 			//Sensitive data here
1036
-			do_action( 'give_api_sensitive_data' );
1036
+			do_action('give_api_sensitive_data');
1037 1037
 
1038 1038
 		}
1039 1039
 
1040
-		return apply_filters( 'give_api_forms_form', $form );
1040
+		return apply_filters('give_api_forms_form', $form);
1041 1041
 
1042 1042
 	}
1043 1043
 
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 	 *
1053 1053
 	 * @return array
1054 1054
 	 */
1055
-	public function get_stats( $args = array() ) {
1055
+	public function get_stats($args = array()) {
1056 1056
 		$defaults = array(
1057 1057
 			'type'      => null,
1058 1058
 			'form'      => null,
@@ -1061,9 +1061,9 @@  discard block
 block discarded – undo
1061 1061
 			'enddate'   => null
1062 1062
 		);
1063 1063
 
1064
-		$args = wp_parse_args( $args, $defaults );
1064
+		$args = wp_parse_args($args, $defaults);
1065 1065
 
1066
-		$dates = $this->get_dates( $args );
1066
+		$dates = $this->get_dates($args);
1067 1067
 
1068 1068
 		$stats    = array();
1069 1069
 		$earnings = array(
@@ -1074,41 +1074,41 @@  discard block
 block discarded – undo
1074 1074
 		);
1075 1075
 		$error    = array();
1076 1076
 
1077
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1077
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1078 1078
 			return $stats;
1079 1079
 		}
1080 1080
 
1081
-		if ( $args['type'] == 'donations' ) {
1081
+		if ($args['type'] == 'donations') {
1082 1082
 
1083
-			if ( $args['form'] == null ) {
1084
-				if ( $args['date'] == null ) {
1083
+			if ($args['form'] == null) {
1084
+				if ($args['date'] == null) {
1085 1085
 					$sales = $this->get_default_sales_stats();
1086
-				} elseif ( $args['date'] === 'range' ) {
1086
+				} elseif ($args['date'] === 'range') {
1087 1087
 					// Return sales for a date range
1088 1088
 
1089 1089
 					// Ensure the end date is later than the start date
1090
-					if ( $args['enddate'] < $args['startdate'] ) {
1091
-						$error['error'] = __( 'The end date must be later than the start date!', 'give' );
1090
+					if ($args['enddate'] < $args['startdate']) {
1091
+						$error['error'] = __('The end date must be later than the start date!', 'give');
1092 1092
 					}
1093 1093
 
1094 1094
 					// Ensure both the start and end date are specified
1095
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1096
-						$error['error'] = __( 'Invalid or no date range specified!', 'give' );
1095
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1096
+						$error['error'] = __('Invalid or no date range specified!', 'give');
1097 1097
 					}
1098 1098
 
1099 1099
 					$total = 0;
1100 1100
 
1101 1101
 					// Loop through the years
1102 1102
 					$y = $dates['year'];
1103
-					while ( $y <= $dates['year_end'] ) :
1103
+					while ($y <= $dates['year_end']) :
1104 1104
 
1105
-						if ( $dates['year'] == $dates['year_end'] ) {
1105
+						if ($dates['year'] == $dates['year_end']) {
1106 1106
 							$month_start = $dates['m_start'];
1107 1107
 							$month_end   = $dates['m_end'];
1108
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1108
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1109 1109
 							$month_start = $dates['m_start'];
1110 1110
 							$month_end   = 12;
1111
-						} elseif ( $y == $dates['year_end'] ) {
1111
+						} elseif ($y == $dates['year_end']) {
1112 1112
 							$month_start = 1;
1113 1113
 							$month_end   = $dates['m_end'];
1114 1114
 						} else {
@@ -1117,109 +1117,109 @@  discard block
 block discarded – undo
1117 1117
 						}
1118 1118
 
1119 1119
 						$i = $month_start;
1120
-						while ( $i <= $month_end ) :
1120
+						while ($i <= $month_end) :
1121 1121
 
1122
-							if ( $i == $dates['m_start'] ) {
1122
+							if ($i == $dates['m_start']) {
1123 1123
 								$d = $dates['day_start'];
1124 1124
 							} else {
1125 1125
 								$d = 1;
1126 1126
 							}
1127 1127
 
1128
-							if ( $i == $dates['m_end'] ) {
1128
+							if ($i == $dates['m_end']) {
1129 1129
 								$num_of_days = $dates['day_end'];
1130 1130
 							} else {
1131
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1131
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1132 1132
 							}
1133 1133
 
1134
-							while ( $d <= $num_of_days ) :
1135
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1136
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1137
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1138
-									$sales['sales'][ $date_key ] = 0;
1134
+							while ($d <= $num_of_days) :
1135
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1136
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1137
+								if ( ! isset($sales['sales'][$date_key])) {
1138
+									$sales['sales'][$date_key] = 0;
1139 1139
 								}
1140
-								$sales['sales'][ $date_key ] += $sale_count;
1140
+								$sales['sales'][$date_key] += $sale_count;
1141 1141
 								$total += $sale_count;
1142
-								$d ++;
1142
+								$d++;
1143 1143
 							endwhile;
1144
-							$i ++;
1144
+							$i++;
1145 1145
 						endwhile;
1146 1146
 
1147
-						$y ++;
1147
+						$y++;
1148 1148
 					endwhile;
1149 1149
 
1150 1150
 					$sales['totals'] = $total;
1151 1151
 				} else {
1152
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1152
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1153 1153
 						$sales_count = 0;
1154 1154
 
1155 1155
 						// Loop through the months
1156 1156
 						$month = $dates['m_start'];
1157 1157
 
1158
-						while ( $month <= $dates['m_end'] ) :
1159
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1160
-							$month ++;
1158
+						while ($month <= $dates['m_end']) :
1159
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1160
+							$month++;
1161 1161
 						endwhile;
1162 1162
 
1163
-						$sales['donations'][ $args['date'] ] = $sales_count;
1163
+						$sales['donations'][$args['date']] = $sales_count;
1164 1164
 					} else {
1165
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1165
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1166 1166
 					}
1167 1167
 				}
1168
-			} elseif ( $args['form'] == 'all' ) {
1169
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1168
+			} elseif ($args['form'] == 'all') {
1169
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1170 1170
 				$i     = 0;
1171
-				foreach ( $forms as $form_info ) {
1172
-					$sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) );
1173
-					$i ++;
1171
+				foreach ($forms as $form_info) {
1172
+					$sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID));
1173
+					$i++;
1174 1174
 				}
1175 1175
 			} else {
1176
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1177
-					$form_info             = get_post( $args['form'] );
1178
-					$sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) );
1176
+				if (get_post_type($args['form']) == 'give_forms') {
1177
+					$form_info             = get_post($args['form']);
1178
+					$sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form']));
1179 1179
 				} else {
1180
-					$error['error'] = sprintf( __( 'Product %s not found!', 'give' ), $args['form'] );
1180
+					$error['error'] = sprintf(__('Product %s not found!', 'give'), $args['form']);
1181 1181
 				}
1182 1182
 			}
1183 1183
 
1184
-			if ( ! empty( $error ) ) {
1184
+			if ( ! empty($error)) {
1185 1185
 				return $error;
1186 1186
 			}
1187 1187
 
1188 1188
 			return $sales;
1189 1189
 
1190
-		} elseif ( $args['type'] == 'earnings' ) {
1191
-			if ( $args['form'] == null ) {
1192
-				if ( $args['date'] == null ) {
1190
+		} elseif ($args['type'] == 'earnings') {
1191
+			if ($args['form'] == null) {
1192
+				if ($args['date'] == null) {
1193 1193
 					$earnings = $this->get_default_earnings_stats();
1194
-				} elseif ( $args['date'] === 'range' ) {
1194
+				} elseif ($args['date'] === 'range') {
1195 1195
 					// Return sales for a date range
1196 1196
 
1197 1197
 					// Ensure the end date is later than the start date
1198
-					if ( $args['enddate'] < $args['startdate'] ) {
1199
-						$error['error'] = __( 'The end date must be later than the start date!', 'give' );
1198
+					if ($args['enddate'] < $args['startdate']) {
1199
+						$error['error'] = __('The end date must be later than the start date!', 'give');
1200 1200
 					}
1201 1201
 
1202 1202
 					// Ensure both the start and end date are specified
1203
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1204
-						$error['error'] = __( 'Invalid or no date range specified!', 'give' );
1203
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1204
+						$error['error'] = __('Invalid or no date range specified!', 'give');
1205 1205
 					}
1206 1206
 
1207 1207
 					$total = (float) 0.00;
1208 1208
 
1209 1209
 					// Loop through the years
1210 1210
 					$y = $dates['year'];
1211
-					if ( ! isset( $earnings['earnings'] ) ) {
1211
+					if ( ! isset($earnings['earnings'])) {
1212 1212
 						$earnings['earnings'] = array();
1213 1213
 					}
1214
-					while ( $y <= $dates['year_end'] ) :
1214
+					while ($y <= $dates['year_end']) :
1215 1215
 
1216
-						if ( $dates['year'] == $dates['year_end'] ) {
1216
+						if ($dates['year'] == $dates['year_end']) {
1217 1217
 							$month_start = $dates['m_start'];
1218 1218
 							$month_end   = $dates['m_end'];
1219
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1219
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1220 1220
 							$month_start = $dates['m_start'];
1221 1221
 							$month_end   = 12;
1222
-						} elseif ( $y == $dates['year_end'] ) {
1222
+						} elseif ($y == $dates['year_end']) {
1223 1223
 							$month_start = 1;
1224 1224
 							$month_end   = $dates['m_end'];
1225 1225
 						} else {
@@ -1228,88 +1228,88 @@  discard block
 block discarded – undo
1228 1228
 						}
1229 1229
 
1230 1230
 						$i = $month_start;
1231
-						while ( $i <= $month_end ) :
1231
+						while ($i <= $month_end) :
1232 1232
 
1233
-							if ( $i == $dates['m_start'] ) {
1233
+							if ($i == $dates['m_start']) {
1234 1234
 								$d = $dates['day_start'];
1235 1235
 							} else {
1236 1236
 								$d = 1;
1237 1237
 							}
1238 1238
 
1239
-							if ( $i == $dates['m_end'] ) {
1239
+							if ($i == $dates['m_end']) {
1240 1240
 								$num_of_days = $dates['day_end'];
1241 1241
 							} else {
1242
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1242
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1243 1243
 							}
1244 1244
 
1245
-							while ( $d <= $num_of_days ) :
1246
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1247
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1248
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1249
-									$earnings['earnings'][ $date_key ] = 0;
1245
+							while ($d <= $num_of_days) :
1246
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1247
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1248
+								if ( ! isset($earnings['earnings'][$date_key])) {
1249
+									$earnings['earnings'][$date_key] = 0;
1250 1250
 								}
1251
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1251
+								$earnings['earnings'][$date_key] += $earnings_stat;
1252 1252
 								$total += $earnings_stat;
1253
-								$d ++;
1253
+								$d++;
1254 1254
 							endwhile;
1255 1255
 
1256
-							$i ++;
1256
+							$i++;
1257 1257
 						endwhile;
1258 1258
 
1259
-						$y ++;
1259
+						$y++;
1260 1260
 					endwhile;
1261 1261
 
1262 1262
 					$earnings['totals'] = $total;
1263 1263
 				} else {
1264
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1264
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1265 1265
 						$earnings_count = (float) 0.00;
1266 1266
 
1267 1267
 						// Loop through the months
1268 1268
 						$month = $dates['m_start'];
1269 1269
 
1270
-						while ( $month <= $dates['m_end'] ) :
1271
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1272
-							$month ++;
1270
+						while ($month <= $dates['m_end']) :
1271
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1272
+							$month++;
1273 1273
 						endwhile;
1274 1274
 
1275
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1275
+						$earnings['earnings'][$args['date']] = $earnings_count;
1276 1276
 					} else {
1277
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1277
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1278 1278
 					}
1279 1279
 				}
1280
-			} elseif ( $args['form'] == 'all' ) {
1281
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1280
+			} elseif ($args['form'] == 'all') {
1281
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1282 1282
 
1283 1283
 				$i = 0;
1284
-				foreach ( $forms as $form_info ) {
1285
-					$earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) );
1286
-					$i ++;
1284
+				foreach ($forms as $form_info) {
1285
+					$earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID));
1286
+					$i++;
1287 1287
 				}
1288 1288
 			} else {
1289
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1290
-					$form_info               = get_post( $args['form'] );
1291
-					$earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) );
1289
+				if (get_post_type($args['form']) == 'give_forms') {
1290
+					$form_info               = get_post($args['form']);
1291
+					$earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form']));
1292 1292
 				} else {
1293
-					$error['error'] = sprintf( __( 'Form %s not found!', 'give' ), $args['form'] );
1293
+					$error['error'] = sprintf(__('Form %s not found!', 'give'), $args['form']);
1294 1294
 				}
1295 1295
 			}
1296 1296
 
1297
-			if ( ! empty( $error ) ) {
1297
+			if ( ! empty($error)) {
1298 1298
 				return $error;
1299 1299
 			}
1300 1300
 
1301 1301
 			return $earnings;
1302
-		} elseif ( $args['type'] == 'donors' ) {
1302
+		} elseif ($args['type'] == 'donors') {
1303 1303
 			$customers                          = new Give_DB_Customers();
1304 1304
 			$stats['donations']['total_donors'] = $customers->count();
1305 1305
 
1306 1306
 			return $stats;
1307 1307
 
1308
-		} elseif ( empty( $args['type'] ) ) {
1309
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1310
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1308
+		} elseif (empty($args['type'])) {
1309
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1310
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1311 1311
 
1312
-			return array( 'stats' => $stats );
1312
+			return array('stats' => $stats);
1313 1313
 		}
1314 1314
 	}
1315 1315
 
@@ -1325,18 +1325,18 @@  discard block
 block discarded – undo
1325 1325
 
1326 1326
 		$sales = array();
1327 1327
 
1328
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1328
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1329 1329
 			return $sales;
1330 1330
 		}
1331 1331
 
1332
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1332
+		if (isset($wp_query->query_vars['id'])) {
1333 1333
 			$query   = array();
1334
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1335
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1334
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1335
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1336 1336
 			$query   = array();
1337
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1338
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1339
-			$args  = array(
1337
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1338
+		} elseif (isset($wp_query->query_vars['email'])) {
1339
+			$args = array(
1340 1340
 				'fields'     => 'ids',
1341 1341
 				'meta_key'   => '_give_payment_user_email',
1342 1342
 				'meta_value' => $wp_query->query_vars['email'],
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
 				'page'       => $this->get_paged(),
1345 1345
 				'status'     => 'publish'
1346 1346
 			);
1347
-			$query = give_get_payments( $args );
1347
+			$query = give_get_payments($args);
1348 1348
 		} else {
1349 1349
 			$args  = array(
1350 1350
 				'fields' => 'ids',
@@ -1352,14 +1352,14 @@  discard block
 block discarded – undo
1352 1352
 				'page'   => $this->get_paged(),
1353 1353
 				'status' => 'publish'
1354 1354
 			);
1355
-			$query = give_get_payments( $args );
1355
+			$query = give_get_payments($args);
1356 1356
 		}
1357
-		if ( $query ) {
1357
+		if ($query) {
1358 1358
 			$i = 0;
1359
-			foreach ( $query as $payment ) {
1359
+			foreach ($query as $payment) {
1360 1360
 
1361
-				if ( is_numeric( $payment ) ) {
1362
-					$payment      = new Give_Payment( $payment );
1361
+				if (is_numeric($payment)) {
1362
+					$payment      = new Give_Payment($payment);
1363 1363
 					$payment_meta = $payment->get_meta();
1364 1364
 					$user_info    = $payment->user_info;
1365 1365
 				} else {
@@ -1369,40 +1369,40 @@  discard block
 block discarded – undo
1369 1369
 				$payment_meta = $payment->get_meta();
1370 1370
 				$user_info    = $payment->user_info;
1371 1371
 
1372
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1373
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1374
-
1375
-				$sales['donations'][ $i ]['ID']             = $payment->number;
1376
-				$sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1377
-				$sales['donations'][ $i ]['key']            = $payment->key;
1378
-				$sales['donations'][ $i ]['total']          = $payment->total;
1379
-				$sales['donations'][ $i ]['gateway']        = $payment->gateway;
1380
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1381
-				$sales['donations'][ $i ]['fname']          = $first_name;
1382
-				$sales['donations'][ $i ]['lname']          = $last_name;
1383
-				$sales['donations'][ $i ]['email']          = $payment->email;
1384
-				$sales['donations'][ $i ]['date']           = $payment->date;
1385
-
1386
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1387
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1388
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1389
-
1390
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1391
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1392
-				$sales['donations'][ $i ]['form']['price'] = $price;
1393
-
1394
-				if ( give_has_variable_prices( $form_id ) ) {
1395
-					if ( isset( $payment_meta['price_id'] ) ) {
1396
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1397
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1398
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1399
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1372
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1373
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1374
+
1375
+				$sales['donations'][$i]['ID']             = $payment->number;
1376
+				$sales['donations'][$i]['transaction_id'] = $payment->transaction_id;
1377
+				$sales['donations'][$i]['key']            = $payment->key;
1378
+				$sales['donations'][$i]['total']          = $payment->total;
1379
+				$sales['donations'][$i]['gateway']        = $payment->gateway;
1380
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1381
+				$sales['donations'][$i]['fname']          = $first_name;
1382
+				$sales['donations'][$i]['lname']          = $last_name;
1383
+				$sales['donations'][$i]['email']          = $payment->email;
1384
+				$sales['donations'][$i]['date']           = $payment->date;
1385
+
1386
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1387
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1388
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1389
+
1390
+				$sales['donations'][$i]['form']['id']    = $form_id;
1391
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1392
+				$sales['donations'][$i]['form']['price'] = $price;
1393
+
1394
+				if (give_has_variable_prices($form_id)) {
1395
+					if (isset($payment_meta['price_id'])) {
1396
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1397
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1398
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1399
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1400 1400
 
1401 1401
 					}
1402 1402
 				}
1403 1403
 
1404 1404
 				//Add custom meta to API
1405
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1405
+				foreach ($payment_meta as $meta_key => $meta_value) {
1406 1406
 
1407 1407
 					$exceptions = array(
1408 1408
 						'form_title',
@@ -1415,19 +1415,19 @@  discard block
 block discarded – undo
1415 1415
 					);
1416 1416
 
1417 1417
 					//Don't clutter up results with dupes
1418
-					if ( in_array( $meta_key, $exceptions ) ) {
1418
+					if (in_array($meta_key, $exceptions)) {
1419 1419
 						continue;
1420 1420
 					}
1421 1421
 
1422
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1422
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1423 1423
 
1424 1424
 				}
1425 1425
 
1426
-				$i ++;
1426
+				$i++;
1427 1427
 			}
1428 1428
 		}
1429 1429
 
1430
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1430
+		return apply_filters('give_api_donations_endpoint', $sales);
1431 1431
 	}
1432 1432
 
1433 1433
 	/**
@@ -1442,9 +1442,9 @@  discard block
 block discarded – undo
1442 1442
 	public function get_output_format() {
1443 1443
 		global $wp_query;
1444 1444
 
1445
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1445
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1446 1446
 
1447
-		return apply_filters( 'give_api_output_format', $format );
1447
+		return apply_filters('give_api_output_format', $format);
1448 1448
 	}
1449 1449
 
1450 1450
 
@@ -1460,8 +1460,8 @@  discard block
 block discarded – undo
1460 1460
 	 *
1461 1461
 	 * @return void
1462 1462
 	 */
1463
-	private function log_request( $data = array() ) {
1464
-		if ( ! $this->log_requests ) {
1463
+	private function log_request($data = array()) {
1464
+		if ( ! $this->log_requests) {
1465 1465
 			return;
1466 1466
 		}
1467 1467
 
@@ -1469,36 +1469,36 @@  discard block
 block discarded – undo
1469 1469
 
1470 1470
 		$query = array(
1471 1471
 			'give-api'    => $wp_query->query_vars['give-api'],
1472
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1473
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1474
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1475
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1476
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1477
-			'customer'    => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null,
1478
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1479
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1480
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1481
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1482
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1483
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1472
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1473
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1474
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1475
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1476
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1477
+			'customer'    => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null,
1478
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1479
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1480
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1481
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1482
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1483
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1484 1484
 		);
1485 1485
 
1486 1486
 		$log_data = array(
1487 1487
 			'log_type'     => 'api_request',
1488
-			'post_excerpt' => http_build_query( $query ),
1489
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1488
+			'post_excerpt' => http_build_query($query),
1489
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1490 1490
 		);
1491 1491
 
1492 1492
 		$log_meta = array(
1493 1493
 			'request_ip' => give_get_ip(),
1494 1494
 			'user'       => $this->user_id,
1495
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1496
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1495
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1496
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1497 1497
 			'time'       => $data['request_speed'],
1498 1498
 			'version'    => $this->get_queried_version()
1499 1499
 		);
1500 1500
 
1501
-		$give_logs->insert_log( $log_data, $log_meta );
1501
+		$give_logs->insert_log($log_data, $log_meta);
1502 1502
 	}
1503 1503
 
1504 1504
 
@@ -1522,32 +1522,32 @@  discard block
 block discarded – undo
1522 1522
 	 *
1523 1523
 	 * @param int $status_code
1524 1524
 	 */
1525
-	public function output( $status_code = 200 ) {
1525
+	public function output($status_code = 200) {
1526 1526
 		global $wp_query;
1527 1527
 
1528 1528
 		$format = $this->get_output_format();
1529 1529
 
1530
-		status_header( $status_code );
1530
+		status_header($status_code);
1531 1531
 
1532
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1532
+		do_action('give_api_output_before', $this->data, $this, $format);
1533 1533
 
1534
-		switch ( $format ) :
1534
+		switch ($format) :
1535 1535
 
1536 1536
 			case 'xml' :
1537 1537
 
1538
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1539
-				$xml = Array2XML::createXML( 'give', $this->data );
1538
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1539
+				$xml = Array2XML::createXML('give', $this->data);
1540 1540
 				echo $xml->saveXML();
1541 1541
 
1542 1542
 				break;
1543 1543
 
1544 1544
 			case 'json' :
1545 1545
 
1546
-				header( 'Content-Type: application/json' );
1547
-				if ( ! empty( $this->pretty_print ) ) {
1548
-					echo json_encode( $this->data, $this->pretty_print );
1546
+				header('Content-Type: application/json');
1547
+				if ( ! empty($this->pretty_print)) {
1548
+					echo json_encode($this->data, $this->pretty_print);
1549 1549
 				} else {
1550
-					echo json_encode( $this->data );
1550
+					echo json_encode($this->data);
1551 1551
 				}
1552 1552
 
1553 1553
 				break;
@@ -1556,13 +1556,13 @@  discard block
 block discarded – undo
1556 1556
 			default :
1557 1557
 
1558 1558
 				// Allow other formats to be added via extensions
1559
-				do_action( 'give_api_output_' . $format, $this->data, $this );
1559
+				do_action('give_api_output_'.$format, $this->data, $this);
1560 1560
 
1561 1561
 				break;
1562 1562
 
1563 1563
 		endswitch;
1564 1564
 
1565
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1565
+		do_action('give_api_output_after', $this->data, $this, $format);
1566 1566
 
1567 1567
 		give_die();
1568 1568
 	}
@@ -1579,37 +1579,37 @@  discard block
 block discarded – undo
1579 1579
 	 *
1580 1580
 	 * @return void
1581 1581
 	 */
1582
-	function user_key_field( $user ) {
1582
+	function user_key_field($user) {
1583 1583
 
1584
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1585
-			$user = get_userdata( $user->ID );
1584
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1585
+			$user = get_userdata($user->ID);
1586 1586
 			?>
1587 1587
 			<table class="form-table">
1588 1588
 				<tbody>
1589 1589
 				<tr>
1590 1590
 					<th>
1591
-						<?php esc_attr_e( 'Give API Keys', 'give' ); ?>
1591
+						<?php esc_attr_e('Give API Keys', 'give'); ?>
1592 1592
 					</th>
1593 1593
 					<td>
1594 1594
 						<?php
1595
-						$public_key = $this->get_user_public_key( $user->ID );
1596
-						$secret_key = $this->get_user_secret_key( $user->ID );
1595
+						$public_key = $this->get_user_public_key($user->ID);
1596
+						$secret_key = $this->get_user_secret_key($user->ID);
1597 1597
 						?>
1598
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1598
+						<?php if (empty($user->give_user_public_key)) { ?>
1599 1599
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1600
-							<span class="description"><?php esc_attr_e( 'Generate API Key', 'give' ); ?></span>
1600
+							<span class="description"><?php esc_attr_e('Generate API Key', 'give'); ?></span>
1601 1601
 						<?php } else { ?>
1602
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?>&nbsp;</strong>
1603
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/>
1602
+							<strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?>&nbsp;</strong>
1603
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/>
1604 1604
 							<br/>
1605
-							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e( 'Secret key:', 'give' ); ?>&nbsp;</strong>
1606
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/>
1605
+							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e('Secret key:', 'give'); ?>&nbsp;</strong>
1606
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/>
1607 1607
 							<br/>
1608
-							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e( 'Token:', 'give' ); ?>&nbsp;</strong>
1609
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/>
1608
+							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e('Token:', 'give'); ?>&nbsp;</strong>
1609
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/>
1610 1610
 							<br/>
1611 1611
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1612
-							<span class="description"><label for="give_set_api_key"><?php esc_attr_e( 'Revoke API Keys', 'give' ); ?></label></span>
1612
+							<span class="description"><label for="give_set_api_key"><?php esc_attr_e('Revoke API Keys', 'give'); ?></label></span>
1613 1613
 						<?php } ?>
1614 1614
 					</td>
1615 1615
 				</tr>
@@ -1628,53 +1628,53 @@  discard block
 block discarded – undo
1628 1628
 	 *
1629 1629
 	 * @return void
1630 1630
 	 */
1631
-	public function process_api_key( $args ) {
1631
+	public function process_api_key($args) {
1632 1632
 
1633
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1633
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1634 1634
 
1635
-			wp_die( esc_attr__( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1635
+			wp_die(esc_attr__('Nonce verification failed', 'give'), __('Error', 'give'), array('response' => 403));
1636 1636
 
1637 1637
 		}
1638 1638
 
1639
-		if ( empty( $args['user_id'] ) ) {
1640
-			wp_die( esc_attr__( 'User ID Required', 'give' ), esc_attr__( 'Error', 'give' ), array( 'response' => 401 ) );
1639
+		if (empty($args['user_id'])) {
1640
+			wp_die(esc_attr__('User ID Required', 'give'), esc_attr__('Error', 'give'), array('response' => 401));
1641 1641
 		}
1642 1642
 
1643
-		if ( is_numeric( $args['user_id'] ) ) {
1644
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1643
+		if (is_numeric($args['user_id'])) {
1644
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1645 1645
 		} else {
1646
-			$userdata = get_user_by( 'login', $args['user_id'] );
1646
+			$userdata = get_user_by('login', $args['user_id']);
1647 1647
 			$user_id  = $userdata->ID;
1648 1648
 		}
1649
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1649
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1650 1650
 
1651
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1652
-			wp_die( sprintf( __( 'You do not have permission to %s API keys for this user', 'give' ), $process ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1653
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1654
-			wp_die( sprintf( __( 'You do not have permission to %s API keys for this user', 'give' ), $process ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1651
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1652
+			wp_die(sprintf(__('You do not have permission to %s API keys for this user', 'give'), $process), __('Error', 'give'), array('response' => 403));
1653
+		} elseif ( ! current_user_can('manage_give_settings')) {
1654
+			wp_die(sprintf(__('You do not have permission to %s API keys for this user', 'give'), $process), __('Error', 'give'), array('response' => 403));
1655 1655
 		}
1656 1656
 
1657
-		switch ( $process ) {
1657
+		switch ($process) {
1658 1658
 			case 'generate':
1659
-				if ( $this->generate_api_key( $user_id ) ) {
1660
-					delete_transient( 'give-total-api-keys' );
1661
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1659
+				if ($this->generate_api_key($user_id)) {
1660
+					delete_transient('give-total-api-keys');
1661
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1662 1662
 					exit();
1663 1663
 				} else {
1664
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1664
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1665 1665
 					exit();
1666 1666
 				}
1667 1667
 				break;
1668 1668
 			case 'regenerate':
1669
-				$this->generate_api_key( $user_id, true );
1670
-				delete_transient( 'give-total-api-keys' );
1671
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1669
+				$this->generate_api_key($user_id, true);
1670
+				delete_transient('give-total-api-keys');
1671
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1672 1672
 				exit();
1673 1673
 				break;
1674 1674
 			case 'revoke':
1675
-				$this->revoke_api_key( $user_id );
1676
-				delete_transient( 'give-total-api-keys' );
1677
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1675
+				$this->revoke_api_key($user_id);
1676
+				delete_transient('give-total-api-keys');
1677
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1678 1678
 				exit();
1679 1679
 				break;
1680 1680
 			default;
@@ -1693,34 +1693,34 @@  discard block
 block discarded – undo
1693 1693
 	 *
1694 1694
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1695 1695
 	 */
1696
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1696
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1697 1697
 
1698
-		if ( empty( $user_id ) ) {
1698
+		if (empty($user_id)) {
1699 1699
 			return false;
1700 1700
 		}
1701 1701
 
1702
-		$user = get_userdata( $user_id );
1702
+		$user = get_userdata($user_id);
1703 1703
 
1704
-		if ( ! $user ) {
1704
+		if ( ! $user) {
1705 1705
 			return false;
1706 1706
 		}
1707 1707
 
1708
-		$public_key = $this->get_user_public_key( $user_id );
1709
-		$secret_key = $this->get_user_secret_key( $user_id );
1708
+		$public_key = $this->get_user_public_key($user_id);
1709
+		$secret_key = $this->get_user_secret_key($user_id);
1710 1710
 
1711
-		if ( empty( $public_key ) || $regenerate == true ) {
1712
-			$new_public_key = $this->generate_public_key( $user->user_email );
1713
-			$new_secret_key = $this->generate_private_key( $user->ID );
1711
+		if (empty($public_key) || $regenerate == true) {
1712
+			$new_public_key = $this->generate_public_key($user->user_email);
1713
+			$new_secret_key = $this->generate_private_key($user->ID);
1714 1714
 		} else {
1715 1715
 			return false;
1716 1716
 		}
1717 1717
 
1718
-		if ( $regenerate == true ) {
1719
-			$this->revoke_api_key( $user->ID );
1718
+		if ($regenerate == true) {
1719
+			$this->revoke_api_key($user->ID);
1720 1720
 		}
1721 1721
 
1722
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1723
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1722
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1723
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1724 1724
 
1725 1725
 		return true;
1726 1726
 	}
@@ -1735,26 +1735,26 @@  discard block
 block discarded – undo
1735 1735
 	 *
1736 1736
 	 * @return string
1737 1737
 	 */
1738
-	public function revoke_api_key( $user_id = 0 ) {
1738
+	public function revoke_api_key($user_id = 0) {
1739 1739
 
1740
-		if ( empty( $user_id ) ) {
1740
+		if (empty($user_id)) {
1741 1741
 			return false;
1742 1742
 		}
1743 1743
 
1744
-		$user = get_userdata( $user_id );
1744
+		$user = get_userdata($user_id);
1745 1745
 
1746
-		if ( ! $user ) {
1746
+		if ( ! $user) {
1747 1747
 			return false;
1748 1748
 		}
1749 1749
 
1750
-		$public_key = $this->get_user_public_key( $user_id );
1751
-		$secret_key = $this->get_user_secret_key( $user_id );
1752
-		if ( ! empty( $public_key ) ) {
1753
-			delete_transient( md5( 'give_api_user_' . $public_key ) );
1754
-			delete_transient( md5( 'give_api_user_public_key' . $user_id ) );
1755
-			delete_transient( md5( 'give_api_user_secret_key' . $user_id ) );
1756
-			delete_user_meta( $user_id, $public_key );
1757
-			delete_user_meta( $user_id, $secret_key );
1750
+		$public_key = $this->get_user_public_key($user_id);
1751
+		$secret_key = $this->get_user_secret_key($user_id);
1752
+		if ( ! empty($public_key)) {
1753
+			delete_transient(md5('give_api_user_'.$public_key));
1754
+			delete_transient(md5('give_api_user_public_key'.$user_id));
1755
+			delete_transient(md5('give_api_user_secret_key'.$user_id));
1756
+			delete_user_meta($user_id, $public_key);
1757
+			delete_user_meta($user_id, $secret_key);
1758 1758
 		} else {
1759 1759
 			return false;
1760 1760
 		}
@@ -1779,22 +1779,22 @@  discard block
 block discarded – undo
1779 1779
 	 *
1780 1780
 	 * @return void
1781 1781
 	 */
1782
-	public function update_key( $user_id ) {
1783
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1782
+	public function update_key($user_id) {
1783
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1784 1784
 
1785
-			$user = get_userdata( $user_id );
1785
+			$user = get_userdata($user_id);
1786 1786
 
1787
-			$public_key = $this->get_user_public_key( $user_id );
1788
-			$secret_key = $this->get_user_secret_key( $user_id );
1787
+			$public_key = $this->get_user_public_key($user_id);
1788
+			$secret_key = $this->get_user_secret_key($user_id);
1789 1789
 
1790
-			if ( empty( $public_key ) ) {
1791
-				$new_public_key = $this->generate_public_key( $user->user_email );
1792
-				$new_secret_key = $this->generate_private_key( $user->ID );
1790
+			if (empty($public_key)) {
1791
+				$new_public_key = $this->generate_public_key($user->user_email);
1792
+				$new_secret_key = $this->generate_private_key($user->ID);
1793 1793
 
1794
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1795
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1794
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1795
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1796 1796
 			} else {
1797
-				$this->revoke_api_key( $user_id );
1797
+				$this->revoke_api_key($user_id);
1798 1798
 			}
1799 1799
 		}
1800 1800
 	}
@@ -1809,9 +1809,9 @@  discard block
 block discarded – undo
1809 1809
 	 *
1810 1810
 	 * @return string
1811 1811
 	 */
1812
-	private function generate_public_key( $user_email = '' ) {
1813
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1814
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1812
+	private function generate_public_key($user_email = '') {
1813
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1814
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1815 1815
 
1816 1816
 		return $public;
1817 1817
 	}
@@ -1826,9 +1826,9 @@  discard block
 block discarded – undo
1826 1826
 	 *
1827 1827
 	 * @return string
1828 1828
 	 */
1829
-	private function generate_private_key( $user_id = 0 ) {
1830
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1831
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1829
+	private function generate_private_key($user_id = 0) {
1830
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1831
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1832 1832
 
1833 1833
 		return $secret;
1834 1834
 	}
@@ -1843,8 +1843,8 @@  discard block
 block discarded – undo
1843 1843
 	 *
1844 1844
 	 * @return string
1845 1845
 	 */
1846
-	public function get_token( $user_id = 0 ) {
1847
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
1846
+	public function get_token($user_id = 0) {
1847
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
1848 1848
 	}
1849 1849
 
1850 1850
 	/**
@@ -1858,9 +1858,9 @@  discard block
 block discarded – undo
1858 1858
 
1859 1859
 		// Default sales return
1860 1860
 		$sales                               = array();
1861
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
1862
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
1863
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
1861
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
1862
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
1863
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
1864 1864
 		$sales['donations']['totals']        = give_get_total_sales();
1865 1865
 
1866 1866
 		return $sales;
@@ -1877,9 +1877,9 @@  discard block
 block discarded – undo
1877 1877
 
1878 1878
 		// Default earnings return
1879 1879
 		$earnings                              = array();
1880
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
1881
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
1882
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
1880
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
1881
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
1882
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
1883 1883
 		$earnings['earnings']['totals']        = give_get_total_earnings();
1884 1884
 
1885 1885
 		return $earnings;
@@ -1899,25 +1899,25 @@  discard block
 block discarded – undo
1899 1899
 	 *
1900 1900
 	 * @return string            The API key/secret for the user supplied
1901 1901
 	 */
1902
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
1902
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
1903 1903
 
1904
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
1904
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
1905 1905
 			return $check;
1906 1906
 		}
1907 1907
 
1908 1908
 		$return = $check;
1909 1909
 
1910
-		switch ( $meta_key ) {
1910
+		switch ($meta_key) {
1911 1911
 			case 'give_user_public_key':
1912
-				$return = Give()->api->get_user_public_key( $object_id );
1912
+				$return = Give()->api->get_user_public_key($object_id);
1913 1913
 				break;
1914 1914
 			case 'give_user_secret_key':
1915
-				$return = Give()->api->get_user_secret_key( $object_id );
1915
+				$return = Give()->api->get_user_secret_key($object_id);
1916 1916
 				break;
1917 1917
 		}
1918 1918
 
1919
-		if ( ! $single ) {
1920
-			$return = array( $return );
1919
+		if ( ! $single) {
1920
+			$return = array($return);
1921 1921
 		}
1922 1922
 
1923 1923
 		return $return;
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.