Completed
Pull Request — master (#801)
by
unknown
18:24
created
includes/admin/upgrades/upgrade-functions.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Exit if accessed directly
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_show_upgrade_notices() {
27 27
 
28
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) {
28
+	if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') {
29 29
 		return;
30 30
 	} // Don't show notices on the upgrades page
31 31
 
32
-	$give_version = get_option( 'give_version' );
32
+	$give_version = get_option('give_version');
33 33
 
34
-	if ( ! $give_version ) {
34
+	if ( ! $give_version) {
35 35
 		// 1.0 is the first version to use this option so we must add it
36 36
 		$give_version = '1.0';
37 37
 	}
38 38
 
39
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
39
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
40 40
 
41 41
 	/*
42 42
 	 *  NOTICE:
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 
49 49
 	//v1.3.2 Upgrades
50
-	if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) {
50
+	if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) {
51 51
 		printf(
52 52
 			/* translators: %s: upgrade URL */
53
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
54
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) )
53
+			'<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
54
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id'))
55 55
 		);
56 56
 	}
57 57
 
58 58
 	//v1.3.4 Upgrades //ensure the user has gone through 1.3.4
59
-	if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) {
59
+	if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) {
60 60
 		printf(
61 61
 			/* translators: %s: upgrade URL */
62
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the transaction database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
63
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) )
62
+			'<div class="updated"><p>'.__('Give needs to upgrade the transaction database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
63
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status'))
64 64
 		);
65 65
 	}
66 66
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 }
72 72
 
73
-add_action( 'admin_notices', 'give_show_upgrade_notices' );
73
+add_action('admin_notices', 'give_show_upgrade_notices');
74 74
 
75 75
 /**
76 76
  * Triggers all upgrade functions
@@ -82,26 +82,26 @@  discard block
 block discarded – undo
82 82
  */
83 83
 function give_trigger_upgrades() {
84 84
 
85
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
86
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
85
+	if ( ! current_user_can('manage_give_settings')) {
86
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
87 87
 	}
88 88
 
89
-	$give_version = get_option( 'give_version' );
89
+	$give_version = get_option('give_version');
90 90
 
91
-	if ( ! $give_version ) {
91
+	if ( ! $give_version) {
92 92
 		// 1.0 is the first version to use this option so we must add it
93 93
 		$give_version = '1.0';
94
-		add_option( 'give_version', $give_version );
94
+		add_option('give_version', $give_version);
95 95
 	}
96 96
 
97
-	update_option( 'give_version', GIVE_VERSION );
97
+	update_option('give_version', GIVE_VERSION);
98 98
 
99
-	if ( DOING_AJAX ) {
100
-		die( 'complete' );
99
+	if (DOING_AJAX) {
100
+		die('complete');
101 101
 	} // Let AJAX know that the upgrade is complete
102 102
 }
103 103
 
104
-add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' );
104
+add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades');
105 105
 
106 106
 /**
107 107
  * Check if the upgrade routine has been run for a specific action
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
  *
113 113
  * @return bool                   If the action has been added to the completed actions array
114 114
  */
115
-function give_has_upgrade_completed( $upgrade_action = '' ) {
115
+function give_has_upgrade_completed($upgrade_action = '') {
116 116
 
117
-	if ( empty( $upgrade_action ) ) {
117
+	if (empty($upgrade_action)) {
118 118
 		return false;
119 119
 	}
120 120
 
121 121
 	$completed_upgrades = give_get_completed_upgrades();
122 122
 
123
-	return in_array( $upgrade_action, $completed_upgrades );
123
+	return in_array($upgrade_action, $completed_upgrades);
124 124
 
125 125
 }
126 126
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
  *
134 134
  * @return bool                   If the function was successfully added
135 135
  */
136
-function give_set_upgrade_complete( $upgrade_action = '' ) {
136
+function give_set_upgrade_complete($upgrade_action = '') {
137 137
 
138
-	if ( empty( $upgrade_action ) ) {
138
+	if (empty($upgrade_action)) {
139 139
 		return false;
140 140
 	}
141 141
 
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	$completed_upgrades[] = $upgrade_action;
144 144
 
145 145
 	// Remove any blanks, and only show uniques
146
-	$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
146
+	$completed_upgrades = array_unique(array_values($completed_upgrades));
147 147
 
148
-	return update_option( 'give_completed_upgrades', $completed_upgrades );
148
+	return update_option('give_completed_upgrades', $completed_upgrades);
149 149
 }
150 150
 
151 151
 /**
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
  */
157 157
 function give_get_completed_upgrades() {
158 158
 
159
-	$completed_upgrades = get_option( 'give_completed_upgrades' );
159
+	$completed_upgrades = get_option('give_completed_upgrades');
160 160
 
161
-	if ( false === $completed_upgrades ) {
161
+	if (false === $completed_upgrades) {
162 162
 		$completed_upgrades = array();
163 163
 	}
164 164
 
@@ -177,30 +177,30 @@  discard block
 block discarded – undo
177 177
  */
178 178
 function give_v132_upgrade_give_payment_customer_id() {
179 179
 	global $wpdb;
180
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
181
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
180
+	if ( ! current_user_can('manage_give_settings')) {
181
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
182 182
 	}
183 183
 
184
-	ignore_user_abort( true );
184
+	ignore_user_abort(true);
185 185
 
186
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
187
-		@set_time_limit( 0 );
186
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
187
+		@set_time_limit(0);
188 188
 	}
189 189
 
190 190
 	//UPDATE DB METAKEYS
191 191
 	$sql   = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'";
192
-	$query = $wpdb->query( $sql );
192
+	$query = $wpdb->query($sql);
193 193
 
194
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
195
-	give_set_upgrade_complete( 'upgrade_give_payment_customer_id' );
196
-	delete_option( 'give_doing_upgrade' );
197
-	wp_redirect( admin_url() );
194
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
195
+	give_set_upgrade_complete('upgrade_give_payment_customer_id');
196
+	delete_option('give_doing_upgrade');
197
+	wp_redirect(admin_url());
198 198
 	exit;
199 199
 
200 200
 
201 201
 }
202 202
 
203
-add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' );
203
+add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id');
204 204
 
205 205
 /**
206 206
  * Upgrades the Offline Status
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
 
215 215
 	global $wpdb;
216 216
 
217
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
218
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
217
+	if ( ! current_user_can('manage_give_settings')) {
218
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
219 219
 	}
220 220
 
221
-	ignore_user_abort( true );
221
+	ignore_user_abort(true);
222 222
 
223
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
224
-		@set_time_limit( 0 );
223
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
224
+		@set_time_limit(0);
225 225
 	}
226 226
 
227 227
 	// Get abandoned offline payments
@@ -231,35 +231,35 @@  discard block
 block discarded – undo
231 231
 	$where .= "AND ( p.post_status = 'abandoned' )";
232 232
 	$where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )";
233 233
 
234
-	$sql            = $select . $join . $where;
235
-	$found_payments = $wpdb->get_col( $sql );
234
+	$sql            = $select.$join.$where;
235
+	$found_payments = $wpdb->get_col($sql);
236 236
 
237 237
 
238
-	foreach ( $found_payments as $payment ) {
238
+	foreach ($found_payments as $payment) {
239 239
 
240 240
 		//Only change ones marked abandoned since our release last week
241 241
 		//because the admin may have marked some abandoned themselves
242
-		$modified_time = get_post_modified_time( 'U', false, $payment );
242
+		$modified_time = get_post_modified_time('U', false, $payment);
243 243
 
244 244
 		//1450124863 =  12/10/2015 20:42:25
245
-		if ( $modified_time >= 1450124863 ) {
245
+		if ($modified_time >= 1450124863) {
246 246
 
247
-			give_update_payment_status( $payment, 'pending' );
247
+			give_update_payment_status($payment, 'pending');
248 248
 
249 249
 		}
250 250
 
251 251
 	}
252 252
 
253
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
254
-	give_set_upgrade_complete( 'upgrade_give_offline_status' );
255
-	delete_option( 'give_doing_upgrade' );
256
-	wp_redirect( admin_url() );
253
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
254
+	give_set_upgrade_complete('upgrade_give_offline_status');
255
+	delete_option('give_doing_upgrade');
256
+	wp_redirect(admin_url());
257 257
 	exit;
258 258
 
259 259
 
260 260
 }
261 261
 
262
-add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' );
262
+add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status');
263 263
 
264 264
 
265 265
 /**
@@ -271,17 +271,17 @@  discard block
 block discarded – undo
271 271
  */
272 272
 function give_v152_cleanup_users() {
273 273
 
274
-	$give_version = get_option( 'give_version' );
274
+	$give_version = get_option('give_version');
275 275
 
276
-	if ( ! $give_version ) {
276
+	if ( ! $give_version) {
277 277
 		// 1.0 is the first version to use this option so we must add it
278 278
 		$give_version = '1.0';
279 279
 	}
280 280
 
281
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
281
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
282 282
 
283 283
 	//v1.5.2 Upgrades
284
-	if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) {
284
+	if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) {
285 285
 
286 286
 		//Delete all caps with "ss"
287 287
 		//Also delete all unused "campaign" roles
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 		);
329 329
 	
330 330
 		global $wp_roles;
331
-		foreach ( $delete_caps as $cap ) {
332
-			foreach ( array_keys( $wp_roles->roles ) as $role ) {
333
-				$wp_roles->remove_cap( $role, $cap );
331
+		foreach ($delete_caps as $cap) {
332
+			foreach (array_keys($wp_roles->roles) as $role) {
333
+				$wp_roles->remove_cap($role, $cap);
334 334
 			}
335 335
 		}
336 336
 	
@@ -340,12 +340,12 @@  discard block
 block discarded – undo
340 340
 		$roles->add_caps();
341 341
 		
342 342
 		//The Update Ran
343
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
344
-		give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' );
345
-		delete_option( 'give_doing_upgrade' );
343
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
344
+		give_set_upgrade_complete('upgrade_give_user_caps_cleanup');
345
+		delete_option('give_doing_upgrade');
346 346
 
347 347
 	}
348 348
 
349 349
 }
350 350
 
351
-add_action( 'admin_init', 'give_v152_cleanup_users' );
352 351
\ No newline at end of file
352
+add_action('admin_init', 'give_v152_cleanup_users');
353 353
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/upgrades/upgrades.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
  * @return void
22 22
  */
23 23
 function give_upgrades_screen() {
24
-	$action = isset( $_GET['give-upgrade'] ) ? sanitize_text_field( $_GET['give-upgrade'] ) : '';
25
-	$step   = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1;
26
-	$total  = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false;
27
-	$custom = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 0;
28
-	$number = isset( $_GET['number'] ) ? absint( $_GET['number'] ) : 100;
29
-	$steps  = round( ( $total / $number ), 0 );
24
+	$action = isset($_GET['give-upgrade']) ? sanitize_text_field($_GET['give-upgrade']) : '';
25
+	$step   = isset($_GET['step']) ? absint($_GET['step']) : 1;
26
+	$total  = isset($_GET['total']) ? absint($_GET['total']) : false;
27
+	$custom = isset($_GET['custom']) ? absint($_GET['custom']) : 0;
28
+	$number = isset($_GET['number']) ? absint($_GET['number']) : 100;
29
+	$steps  = round(($total / $number), 0);
30 30
 
31 31
 	$doing_upgrade_args = array(
32 32
 		'page'         => 'give-upgrades',
@@ -36,25 +36,25 @@  discard block
 block discarded – undo
36 36
 		'custom'       => $custom,
37 37
 		'steps'        => $steps
38 38
 	);
39
-	update_option( 'give_doing_upgrade', $doing_upgrade_args );
40
-	if ( $step > $steps ) {
39
+	update_option('give_doing_upgrade', $doing_upgrade_args);
40
+	if ($step > $steps) {
41 41
 		// Prevent a weird case where the estimate was off. Usually only a couple.
42 42
 		$steps = $step;
43 43
 	}
44 44
 	?>
45 45
 	<div class="wrap">
46
-		<h2><?php esc_html_e( 'Give - Upgrades', 'give' ); ?></h2>
46
+		<h2><?php esc_html_e('Give - Upgrades', 'give'); ?></h2>
47 47
 
48
-		<?php if ( ! empty( $action ) ) : ?>
48
+		<?php if ( ! empty($action)) : ?>
49 49
 
50 50
 			<div id="give-upgrade-status">
51
-				<p style="font-size: 20px;max-width: 900px;"><?php esc_html_e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?>
52
-					<img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style="  position: relative; top: 3px; left: 6px;" />
51
+				<p style="font-size: 20px;max-width: 900px;"><?php esc_html_e('The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give'); ?>
52
+					<img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style="  position: relative; top: 3px; left: 6px;" />
53 53
 				</p>
54 54
 
55
-				<?php if ( ! empty( $total ) ) : ?>
55
+				<?php if ( ! empty($total)) : ?>
56 56
 					<p>
57
-						<strong><?php printf( esc_html__( 'Step %d of approximately %d running', 'give' ), $step, $steps ); ?></strong>
57
+						<strong><?php printf(esc_html__('Step %d of approximately %d running', 'give'), $step, $steps); ?></strong>
58 58
 					</p>
59 59
 				<?php endif; ?>
60 60
 			</div>
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 
69 69
 			<div id="give-upgrade-status">
70 70
 				<p style="font-size: 20px;max-width: 900px;">
71
-					<?php esc_html_e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?>
72
-					<img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style="  position: relative; top: 3px; left: 6px;" />
71
+					<?php esc_html_e('The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give'); ?>
72
+					<img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style="  position: relative; top: 3px; left: 6px;" />
73 73
 				</p>
74 74
 			</div>
75 75
 			<script type="text/javascript">
Please login to merge, or discard this patch.
includes/admin/class-admin-notices.php 1 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'  => esc_html__( 'Give Test Mode Active', 'give' ),
55
-			'meta'   => array( 'class' => 'give-test-mode-active' ),
56
-		) );
54
+			'title'  => esc_html__('Give Test Mode Active', 'give'),
55
+			'meta'   => array('class' => 'give-test-mode-active'),
56
+		));
57 57
 
58 58
 	}
59 59
 
@@ -68,98 +68,98 @@  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>' . esc_html__( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>';
73
+			echo '<p>'.esc_html__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>';
74 74
 			/* translators: %s: https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/ */
75
-			echo '<p>' . sprintf( __( 'Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give' ), esc_url( 'https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/' ) ) . '</p>';
76
-			echo '<p><a href="' . add_query_arg( array(
75
+			echo '<p>'.sprintf(__('Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give'), esc_url('https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/')).'</p>';
76
+			echo '<p><a href="'.add_query_arg(array(
77 77
 					'give_action' => 'dismiss_notices',
78 78
 					'give_notice' => 'admin_ajax_inaccessible'
79
-				) ) . '">' . esc_html__( 'Dismiss Notice', 'give' ) . '</a></p>';
79
+				)).'">'.esc_html__('Dismiss Notice', 'give').'</a></p>';
80 80
 			echo '</div>';
81 81
 		}
82 82
 
83 83
 
84
-		if ( isset( $_GET['give-message'] ) ) {
84
+		if (isset($_GET['give-message'])) {
85 85
 
86 86
 			// Donation reports errors
87
-			if ( current_user_can( 'view_give_reports' ) ) {
88
-				switch ( $_GET['give-message'] ) {
87
+			if (current_user_can('view_give_reports')) {
88
+				switch ($_GET['give-message']) {
89 89
 					case 'payment_deleted' :
90
-						$notices['updated']['give-payment-deleted'] = esc_attr__( 'The payment has been deleted.', 'give' );
90
+						$notices['updated']['give-payment-deleted'] = esc_attr__('The payment has been deleted.', 'give');
91 91
 						break;
92 92
 					case 'email_sent' :
93
-						$notices['updated']['give-payment-sent'] = esc_attr__( 'The donation receipt has been resent.', 'give' );
93
+						$notices['updated']['give-payment-sent'] = esc_attr__('The donation receipt has been resent.', 'give');
94 94
 						break;
95 95
 					case 'refreshed-reports' :
96
-						$notices['updated']['give-refreshed-reports'] = esc_attr__( 'The reports cache has been cleared.', 'give' );
96
+						$notices['updated']['give-refreshed-reports'] = esc_attr__('The reports cache has been cleared.', 'give');
97 97
 						break;
98 98
 					case 'payment-note-deleted' :
99
-						$notices['updated']['give-payment-note-deleted'] = esc_attr__( 'The payment note has been deleted.', 'give' );
99
+						$notices['updated']['give-payment-note-deleted'] = esc_attr__('The payment note has been deleted.', 'give');
100 100
 						break;
101 101
 				}
102 102
 			}
103 103
 
104 104
 			// Give settings notices and errors
105
-			if ( current_user_can( 'manage_give_settings' ) ) {
106
-				switch ( $_GET['give-message'] ) {
105
+			if (current_user_can('manage_give_settings')) {
106
+				switch ($_GET['give-message']) {
107 107
 					case 'settings-imported' :
108
-						$notices['updated']['give-settings-imported'] = esc_attr__( 'The settings have been imported.', 'give' );
108
+						$notices['updated']['give-settings-imported'] = esc_attr__('The settings have been imported.', 'give');
109 109
 						break;
110 110
 					case 'api-key-generated' :
111
-						$notices['updated']['give-api-key-generated'] = esc_attr__( 'API keys successfully generated.', 'give' );
111
+						$notices['updated']['give-api-key-generated'] = esc_attr__('API keys successfully generated.', 'give');
112 112
 						break;
113 113
 					case 'api-key-exists' :
114
-						$notices['error']['give-api-key-exists'] = esc_attr__( 'The specified user already has API keys.', 'give' );
114
+						$notices['error']['give-api-key-exists'] = esc_attr__('The specified user already has API keys.', 'give');
115 115
 						break;
116 116
 					case 'api-key-regenerated' :
117
-						$notices['updated']['give-api-key-regenerated'] = esc_attr__( 'API keys successfully regenerated.', 'give' );
117
+						$notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys successfully regenerated.', 'give');
118 118
 						break;
119 119
 					case 'api-key-revoked' :
120
-						$notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys successfully revoked.', 'give' );
120
+						$notices['updated']['give-api-key-revoked'] = esc_attr__('API keys successfully revoked.', 'give');
121 121
 						break;
122 122
 					case 'sent-test-email' :
123
-						$notices['updated']['give-sent-test-email'] = esc_attr__( 'The test email has been sent.', 'give' );
123
+						$notices['updated']['give-sent-test-email'] = esc_attr__('The test email has been sent.', 'give');
124 124
 						break;
125 125
 				}
126 126
 			}
127 127
 			// Payments errors
128
-			if ( current_user_can( 'edit_give_payments' ) ) {
129
-				switch ( $_GET['give-message'] ) {
128
+			if (current_user_can('edit_give_payments')) {
129
+				switch ($_GET['give-message']) {
130 130
 					case 'note-added' :
131
-						$notices['updated']['give-note-added'] = esc_attr__( 'The payment note has been added successfully.', 'give' );
131
+						$notices['updated']['give-note-added'] = esc_attr__('The payment note has been added successfully.', 'give');
132 132
 						break;
133 133
 					case 'payment-updated' :
134
-						$notices['updated']['give-payment-updated'] = esc_attr__( 'The payment has been successfully updated.', 'give' );
134
+						$notices['updated']['give-payment-updated'] = esc_attr__('The payment has been successfully updated.', 'give');
135 135
 						break;
136 136
 				}
137 137
 			}
138 138
 
139 139
 			// Customer Notices
140
-			if ( current_user_can( 'edit_give_payments' ) ) {
141
-				switch ( $_GET['give-message'] ) {
140
+			if (current_user_can('edit_give_payments')) {
141
+				switch ($_GET['give-message']) {
142 142
 					case 'customer-deleted' :
143
-						$notices['updated']['give-customer-deleted'] = esc_attr__( 'Donor successfully deleted.', 'give' );
143
+						$notices['updated']['give-customer-deleted'] = esc_attr__('Donor successfully deleted.', 'give');
144 144
 						break;
145 145
 				}
146 146
 			}
147 147
 
148 148
 		}
149 149
 
150
-		if ( count( $notices['updated'] ) > 0 ) {
151
-			foreach ( $notices['updated'] as $notice => $message ) {
152
-				add_settings_error( 'give-notices', $notice, $message, 'updated' );
150
+		if (count($notices['updated']) > 0) {
151
+			foreach ($notices['updated'] as $notice => $message) {
152
+				add_settings_error('give-notices', $notice, $message, 'updated');
153 153
 			}
154 154
 		}
155 155
 
156
-		if ( count( $notices['error'] ) > 0 ) {
157
-			foreach ( $notices['error'] as $notice => $message ) {
158
-				add_settings_error( 'give-notices', $notice, $message, 'error' );
156
+		if (count($notices['error']) > 0) {
157
+			foreach ($notices['error'] as $notice => $message) {
158
+				add_settings_error('give-notices', $notice, $message, 'error');
159 159
 			}
160 160
 		}
161 161
 
162
-		settings_errors( 'give-notices' );
162
+		settings_errors('give-notices');
163 163
 
164 164
 	}
165 165
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @return void
172 172
 	 */
173 173
 	function give_admin_addons_notices() {
174
-		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' );
175
-		settings_errors( 'give-notices' );
174
+		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');
175
+		settings_errors('give-notices');
176 176
 	}
177 177
 
178 178
 
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	 * @return void
184 184
 	 */
185 185
 	function dismiss_notices() {
186
-		if ( isset( $_GET['give_notice'] ) ) {
187
-			update_user_meta( get_current_user_id(), '_give_' . $_GET['give_notice'] . '_dismissed', 1 );
188
-			wp_redirect( remove_query_arg( array( 'give_action', 'give_notice' ) ) );
186
+		if (isset($_GET['give_notice'])) {
187
+			update_user_meta(get_current_user_id(), '_give_'.$_GET['give_notice'].'_dismissed', 1);
188
+			wp_redirect(remove_query_arg(array('give_action', 'give_notice')));
189 189
 			exit;
190 190
 		}
191 191
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export-customers.php 1 patch
Spacing   +71 added lines, -71 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
 
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @param array $request The Form Data passed into the batch processing
48 48
 	 */
49
-	public function set_properties( $request ) {
49
+	public function set_properties($request) {
50 50
 
51 51
 		//Set data from form submission
52
-		if ( isset( $_POST['form'] ) ) {
53
-			parse_str( $_POST['form'], $this->data );
52
+		if (isset($_POST['form'])) {
53
+			parse_str($_POST['form'], $this->data);
54 54
 		}
55 55
 
56 56
 		$this->form = $this->data['forms'];
57 57
 
58
-		$this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null;
58
+		$this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null;
59 59
 
60 60
 	}
61 61
 
@@ -70,36 +70,36 @@  discard block
 block discarded – undo
70 70
 
71 71
 		$cols = array();
72 72
 
73
-		$columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array();
73
+		$columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array();
74 74
 
75
-		if ( empty( $columns ) ) {
75
+		if (empty($columns)) {
76 76
 			return false;
77 77
 		}
78
-		if ( ! empty( $columns['full_name'] ) ) {
79
-			$cols['full_name'] = esc_html__( 'Full Name', 'give' );
78
+		if ( ! empty($columns['full_name'])) {
79
+			$cols['full_name'] = esc_html__('Full Name', 'give');
80 80
 		}
81
-		if ( ! empty( $columns['email'] ) ) {
82
-			$cols['email'] = esc_html__( 'Email Address', 'give' );
81
+		if ( ! empty($columns['email'])) {
82
+			$cols['email'] = esc_html__('Email Address', 'give');
83 83
 		}
84
-		if ( ! empty( $columns['address'] ) ) {
85
-			$cols['address_line1']   = esc_html__( 'Address', 'give' );
86
-			$cols['address_line2']   = esc_html__( 'Address (Line 2)', 'give' );
87
-			$cols['address_city']    = esc_html__( 'City', 'give' );
88
-			$cols['address_state']   = esc_html__( 'State', 'give' );
89
-			$cols['address_zip']     = esc_html__( 'Zip', 'give' );
90
-			$cols['address_country'] = esc_html__( 'Country', 'give' );
84
+		if ( ! empty($columns['address'])) {
85
+			$cols['address_line1']   = esc_html__('Address', 'give');
86
+			$cols['address_line2']   = esc_html__('Address (Line 2)', 'give');
87
+			$cols['address_city']    = esc_html__('City', 'give');
88
+			$cols['address_state']   = esc_html__('State', 'give');
89
+			$cols['address_zip']     = esc_html__('Zip', 'give');
90
+			$cols['address_country'] = esc_html__('Country', 'give');
91 91
 		}
92
-		if ( ! empty( $columns['userid'] ) ) {
93
-			$cols['userid'] = esc_html__( 'User ID', 'give' );
92
+		if ( ! empty($columns['userid'])) {
93
+			$cols['userid'] = esc_html__('User ID', 'give');
94 94
 		}
95
-		if ( ! empty( $columns['date_first_donated'] ) ) {
96
-			$cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' );
95
+		if ( ! empty($columns['date_first_donated'])) {
96
+			$cols['date_first_donated'] = esc_html__('First Donation Date', 'give');
97 97
 		}
98
-		if ( ! empty( $columns['donations'] ) ) {
99
-			$cols['donations'] = esc_html__( 'Number of Donations', 'give' );
98
+		if ( ! empty($columns['donations'])) {
99
+			$cols['donations'] = esc_html__('Number of Donations', 'give');
100 100
 		}
101
-		if ( ! empty( $columns['donation_sum'] ) ) {
102
-			$cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' );
101
+		if ( ! empty($columns['donation_sum'])) {
102
+			$cols['donation_sum'] = esc_html__('Sum of Donations', 'give');
103 103
 		}
104 104
 
105 105
 		return $cols;
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 
120 120
 		$i = 0;
121 121
 
122
-		if ( ! empty( $this->form ) ) {
122
+		if ( ! empty($this->form)) {
123 123
 
124 124
 			// Export donors of a specific product
125 125
 			global $give_logs;
126 126
 
127 127
 			$args = array(
128
-				'post_parent'    => absint( $this->form ),
128
+				'post_parent'    => absint($this->form),
129 129
 				'log_type'       => 'sale',
130 130
 				'posts_per_page' => 30,
131 131
 				'paged'          => $this->step
132 132
 			);
133 133
 
134 134
 			//Check for price option
135
-			if ( null !== $this->price_id ) {
135
+			if (null !== $this->price_id) {
136 136
 				$args['meta_query'] = array(
137 137
 					array(
138 138
 						'key'   => '_give_log_price_id',
@@ -141,33 +141,33 @@  discard block
 block discarded – undo
141 141
 				);
142 142
 			}
143 143
 
144
-			$logs = $give_logs->get_connected_logs( $args );
144
+			$logs = $give_logs->get_connected_logs($args);
145 145
 
146
-			if ( $logs ) {
147
-				foreach ( $logs as $log ) {
148
-					$payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true );
149
-					$payment    = new Give_Payment( $payment_id );
150
-					$donor      = Give()->customers->get_customer_by( 'id', $payment->customer_id );
151
-					$data[]     = $this->set_donor_data( $i, $data, $donor );
152
-					$i ++;
146
+			if ($logs) {
147
+				foreach ($logs as $log) {
148
+					$payment_id = get_post_meta($log->ID, '_give_log_payment_id', true);
149
+					$payment    = new Give_Payment($payment_id);
150
+					$donor      = Give()->customers->get_customer_by('id', $payment->customer_id);
151
+					$data[]     = $this->set_donor_data($i, $data, $donor);
152
+					$i++;
153 153
 				}
154 154
 			}
155 155
 
156 156
 		} else {
157 157
 
158 158
 			// Export all customers
159
-			$offset = 30 * ( $this->step - 1 );
160
-			$donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) );
159
+			$offset = 30 * ($this->step - 1);
160
+			$donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset));
161 161
 
162
-			foreach ( $donors as $donor ) {
162
+			foreach ($donors as $donor) {
163 163
 
164
-				$data[] = $this->set_donor_data( $i, $data, $donor );
165
-				$i ++;
164
+				$data[] = $this->set_donor_data($i, $data, $donor);
165
+				$i++;
166 166
 			}
167 167
 		}
168 168
 
169
-		$data = apply_filters( 'give_export_get_data', $data );
170
-		$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
169
+		$data = apply_filters('give_export_get_data', $data);
170
+		$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
171 171
 
172 172
 		return $data;
173 173
 	}
@@ -183,19 +183,19 @@  discard block
 block discarded – undo
183 183
 		$percentage = 0;
184 184
 
185 185
 		// We can't count the number when getting them for a specific form
186
-		if ( empty( $this->form ) ) {
186
+		if (empty($this->form)) {
187 187
 
188 188
 			$total = Give()->customers->count();
189 189
 
190
-			if ( $total > 0 ) {
190
+			if ($total > 0) {
191 191
 
192
-				$percentage = ( ( 30 * $this->step ) / $total ) * 100;
192
+				$percentage = ((30 * $this->step) / $total) * 100;
193 193
 
194 194
 			}
195 195
 
196 196
 		}
197 197
 
198
-		if ( $percentage > 100 ) {
198
+		if ($percentage > 100) {
199 199
 			$percentage = 100;
200 200
 		}
201 201
 
@@ -207,46 +207,46 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @param $donor
209 209
 	 */
210
-	private function set_donor_data( $i, $data, $donor ) {
210
+	private function set_donor_data($i, $data, $donor) {
211 211
 
212 212
 		$columns = $this->csv_cols();
213 213
 
214 214
 		//Set address variable
215 215
 		$address = '';
216
-		if ( isset( $donor->user_id ) && $donor->user_id > 0 ) {
217
-			$address = give_get_donor_address( $donor->user_id );
216
+		if (isset($donor->user_id) && $donor->user_id > 0) {
217
+			$address = give_get_donor_address($donor->user_id);
218 218
 		}
219 219
 
220 220
 		//Set columns
221
-		if ( ! empty( $columns['full_name'] ) ) {
222
-			$data[ $i ]['full_name'] = $donor->name;
221
+		if ( ! empty($columns['full_name'])) {
222
+			$data[$i]['full_name'] = $donor->name;
223 223
 		}
224
-		if ( ! empty( $columns['email'] ) ) {
225
-			$data[ $i ]['email'] = $donor->email;
224
+		if ( ! empty($columns['email'])) {
225
+			$data[$i]['email'] = $donor->email;
226 226
 		}
227
-		if ( ! empty( $columns['address_line1'] ) ) {
227
+		if ( ! empty($columns['address_line1'])) {
228 228
 
229
-			$data[ $i ]['address_line1']   = isset( $address['line1'] ) ? $address['line1'] : '';
230
-			$data[ $i ]['address_line2']   = isset( $address['line2'] ) ? $address['line2'] : '';
231
-			$data[ $i ]['address_city']    = isset( $address['city'] ) ? $address['city'] : '';
232
-			$data[ $i ]['address_state']   = isset( $address['state'] ) ? $address['state'] : '';
233
-			$data[ $i ]['address_zip']     = isset( $address['zip'] ) ? $address['zip'] : '';
234
-			$data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : '';
229
+			$data[$i]['address_line1']   = isset($address['line1']) ? $address['line1'] : '';
230
+			$data[$i]['address_line2']   = isset($address['line2']) ? $address['line2'] : '';
231
+			$data[$i]['address_city']    = isset($address['city']) ? $address['city'] : '';
232
+			$data[$i]['address_state']   = isset($address['state']) ? $address['state'] : '';
233
+			$data[$i]['address_zip']     = isset($address['zip']) ? $address['zip'] : '';
234
+			$data[$i]['address_country'] = isset($address['country']) ? $address['country'] : '';
235 235
 		}
236
-		if ( ! empty( $columns['userid'] ) ) {
237
-			$data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : '';
236
+		if ( ! empty($columns['userid'])) {
237
+			$data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : '';
238 238
 		}
239
-		if ( ! empty( $columns['date_first_donated'] ) ) {
240
-			$data[ $i ]['date_first_donated'] = date_i18n( get_option( 'date_format' ), strtotime( $donor->date_created ) );
239
+		if ( ! empty($columns['date_first_donated'])) {
240
+			$data[$i]['date_first_donated'] = date_i18n(get_option('date_format'), strtotime($donor->date_created));
241 241
 		}
242
-		if ( ! empty( $columns['donations'] ) ) {
243
-			$data[ $i ]['donations'] = $donor->purchase_count;
242
+		if ( ! empty($columns['donations'])) {
243
+			$data[$i]['donations'] = $donor->purchase_count;
244 244
 		}
245
-		if ( ! empty( $columns['donation_sum'] ) ) {
246
-			$data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value );
245
+		if ( ! empty($columns['donation_sum'])) {
246
+			$data[$i]['donation_sum'] = give_format_amount($donor->purchase_value);
247 247
 		}
248 248
 
249
-		return $data[ $i ];
249
+		return $data[$i];
250 250
 
251 251
 	}
252 252
 
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export-payments.php 1 patch
Spacing   +80 added lines, -80 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
 
@@ -39,29 +39,29 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function csv_cols() {
41 41
 		$cols = array(
42
-			'id'       => esc_html__( 'ID', 'give' ), // unaltered payment ID (use for querying)
43
-			'seq_id'   => esc_html__( 'Payment Number', 'give' ), // sequential payment ID
44
-			'email'    => esc_html__( 'Email', 'give' ),
45
-			'first'    => esc_html__( 'First Name', 'give' ),
46
-			'last'     => esc_html__( 'Last Name', 'give' ),
47
-			'address1' => esc_html__( 'Address', 'give' ),
48
-			'address2' => esc_html__( 'Address (Line 2)', 'give' ),
49
-			'city'     => esc_html__( 'City', 'give' ),
50
-			'state'    => esc_html__( 'State', 'give' ),
51
-			'country'  => esc_html__( 'Country', 'give' ),
52
-			'zip'      => esc_html__( 'Zip / Postal Code', 'give' ),
53
-			'products' => esc_html__( 'Products', 'give' ),
54
-			'amount'   => esc_html__( 'Amount', 'give' ) . ' (' . html_entity_decode( give_currency_filter( '' ) ) . ')',
55
-			'gateway'  => esc_html__( 'Payment Method', 'give' ),
56
-			'trans_id' => esc_html__( 'Transaction ID', 'give' ),
57
-			'key'      => esc_html__( 'Purchase Key', 'give' ),
58
-			'date'     => esc_html__( 'Date', 'give' ),
59
-			'user'     => esc_html__( 'User', 'give' ),
60
-			'status'   => esc_html__( 'Status', 'give' )
42
+			'id'       => esc_html__('ID', 'give'), // unaltered payment ID (use for querying)
43
+			'seq_id'   => esc_html__('Payment Number', 'give'), // sequential payment ID
44
+			'email'    => esc_html__('Email', 'give'),
45
+			'first'    => esc_html__('First Name', 'give'),
46
+			'last'     => esc_html__('Last Name', 'give'),
47
+			'address1' => esc_html__('Address', 'give'),
48
+			'address2' => esc_html__('Address (Line 2)', 'give'),
49
+			'city'     => esc_html__('City', 'give'),
50
+			'state'    => esc_html__('State', 'give'),
51
+			'country'  => esc_html__('Country', 'give'),
52
+			'zip'      => esc_html__('Zip / Postal Code', 'give'),
53
+			'products' => esc_html__('Products', 'give'),
54
+			'amount'   => esc_html__('Amount', 'give').' ('.html_entity_decode(give_currency_filter('')).')',
55
+			'gateway'  => esc_html__('Payment Method', 'give'),
56
+			'trans_id' => esc_html__('Transaction ID', 'give'),
57
+			'key'      => esc_html__('Purchase Key', 'give'),
58
+			'date'     => esc_html__('Date', 'give'),
59
+			'user'     => esc_html__('User', 'give'),
60
+			'status'   => esc_html__('Status', 'give')
61 61
 		);
62 62
 
63
-		if ( ! give_get_option( 'enable_sequential' ) ) {
64
-			unset( $cols['seq_id'] );
63
+		if ( ! give_get_option('enable_sequential')) {
64
+			unset($cols['seq_id']);
65 65
 		}
66 66
 
67 67
 		return $cols;
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 			'status' => $this->status
88 88
 		);
89 89
 
90
-		if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
90
+		if ( ! empty($this->start) || ! empty($this->end)) {
91 91
 
92 92
 			$args['date_query'] = array(
93 93
 				array(
94
-					'after'     => date( 'Y-n-d 00:00:00', strtotime( $this->start ) ),
95
-					'before'    => date( 'Y-n-d 23:59:59', strtotime( $this->end ) ),
94
+					'after'     => date('Y-n-d 00:00:00', strtotime($this->start)),
95
+					'before'    => date('Y-n-d 23:59:59', strtotime($this->end)),
96 96
 					'inclusive' => true
97 97
 				)
98 98
 			);
@@ -101,104 +101,104 @@  discard block
 block discarded – undo
101 101
 
102 102
 		//echo json_encode($args ); exit;
103 103
 
104
-		$payments = give_get_payments( $args );
104
+		$payments = give_get_payments($args);
105 105
 
106
-		if ( $payments ) {
106
+		if ($payments) {
107 107
 
108
-			foreach ( $payments as $payment ) {
109
-				$payment_meta = give_get_payment_meta( $payment->ID );
110
-				$user_info    = give_get_payment_meta_user_info( $payment->ID );
111
-				$total        = give_get_payment_amount( $payment->ID );
112
-				$user_id      = isset( $user_info['id'] ) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email'];
108
+			foreach ($payments as $payment) {
109
+				$payment_meta = give_get_payment_meta($payment->ID);
110
+				$user_info    = give_get_payment_meta_user_info($payment->ID);
111
+				$total        = give_get_payment_amount($payment->ID);
112
+				$user_id      = isset($user_info['id']) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email'];
113 113
 				$products     = '';
114 114
 				$skus         = '';
115 115
 
116
-				if ( $downloads ) {
117
-					foreach ( $downloads as $key => $download ) {
116
+				if ($downloads) {
117
+					foreach ($downloads as $key => $download) {
118 118
 
119 119
 						// Form ID
120
-						$id  = isset( $payment_meta['cart_details'] ) ? $download['id'] : $download;
121
-						$qty = isset( $download['quantity'] ) ? $download['quantity'] : 1;
120
+						$id  = isset($payment_meta['cart_details']) ? $download['id'] : $download;
121
+						$qty = isset($download['quantity']) ? $download['quantity'] : 1;
122 122
 
123
-						if ( isset( $download['price'] ) ) {
123
+						if (isset($download['price'])) {
124 124
 							$price = $download['price'];
125 125
 						} else {
126 126
 							// If the download has variable prices, override the default price
127
-							$price_override = isset( $payment_meta['cart_details'] ) ? $download['price'] : null;
128
-							$price          = give_get_download_final_price( $id, $user_info, $price_override );
127
+							$price_override = isset($payment_meta['cart_details']) ? $download['price'] : null;
128
+							$price          = give_get_download_final_price($id, $user_info, $price_override);
129 129
 						}
130 130
 
131 131
 
132 132
 						// Display the Downoad Name
133
-						$products .= html_entity_decode( get_the_title( $id ) );
133
+						$products .= html_entity_decode(get_the_title($id));
134 134
 
135
-						if ( $qty > 1 ) {
136
-							$products .= html_entity_decode( ' (' . $qty . ')' );
135
+						if ($qty > 1) {
136
+							$products .= html_entity_decode(' ('.$qty.')');
137 137
 						}
138 138
 
139 139
 						$products .= ' - ';
140 140
 
141
-						if ( give_use_skus() ) {
142
-							$sku = give_get_download_sku( $id );
141
+						if (give_use_skus()) {
142
+							$sku = give_get_download_sku($id);
143 143
 
144
-							if ( ! empty( $sku ) ) {
144
+							if ( ! empty($sku)) {
145 145
 								$skus .= $sku;
146 146
 							}
147 147
 						}
148 148
 
149
-						if ( isset( $downloads[ $key ]['item_number'] ) && isset( $downloads[ $key ]['item_number']['options'] ) ) {
150
-							$price_options = $downloads[ $key ]['item_number']['options'];
149
+						if (isset($downloads[$key]['item_number']) && isset($downloads[$key]['item_number']['options'])) {
150
+							$price_options = $downloads[$key]['item_number']['options'];
151 151
 
152
-							if ( isset( $price_options['price_id'] ) ) {
153
-								$products .= html_entity_decode( give_get_price_option_name( $id, $price_options['price_id'], $payment->ID ) ) . ' - ';
152
+							if (isset($price_options['price_id'])) {
153
+								$products .= html_entity_decode(give_get_price_option_name($id, $price_options['price_id'], $payment->ID)).' - ';
154 154
 							}
155 155
 						}
156 156
 
157
-						$products .= html_entity_decode( give_currency_filter( give_format_amount( $price ) ) );
157
+						$products .= html_entity_decode(give_currency_filter(give_format_amount($price)));
158 158
 
159
-						if ( $key != ( count( $downloads ) - 1 ) ) {
159
+						if ($key != (count($downloads) - 1)) {
160 160
 							$products .= ' / ';
161 161
 
162
-							if ( give_use_skus() ) {
162
+							if (give_use_skus()) {
163 163
 								$skus .= ' / ';
164 164
 							}
165 165
 						}
166 166
 					}
167 167
 				}
168 168
 
169
-				if ( is_numeric( $user_id ) ) {
170
-					$user = get_userdata( $user_id );
169
+				if (is_numeric($user_id)) {
170
+					$user = get_userdata($user_id);
171 171
 				} else {
172 172
 					$user = false;
173 173
 				}
174 174
 
175 175
 				$data[] = array(
176 176
 					'id'       => $payment->ID,
177
-					'seq_id'   => give_get_payment_number( $payment->ID ),
177
+					'seq_id'   => give_get_payment_number($payment->ID),
178 178
 					'email'    => $payment_meta['email'],
179 179
 					'first'    => $user_info['first_name'],
180 180
 					'last'     => $user_info['last_name'],
181
-					'address1' => isset( $user_info['address']['line1'] ) ? $user_info['address']['line1'] : '',
182
-					'address2' => isset( $user_info['address']['line2'] ) ? $user_info['address']['line2'] : '',
183
-					'city'     => isset( $user_info['address']['city'] ) ? $user_info['address']['city'] : '',
184
-					'state'    => isset( $user_info['address']['state'] ) ? $user_info['address']['state'] : '',
185
-					'country'  => isset( $user_info['address']['country'] ) ? $user_info['address']['country'] : '',
186
-					'zip'      => isset( $user_info['address']['zip'] ) ? $user_info['address']['zip'] : '',
181
+					'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '',
182
+					'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '',
183
+					'city'     => isset($user_info['address']['city']) ? $user_info['address']['city'] : '',
184
+					'state'    => isset($user_info['address']['state']) ? $user_info['address']['state'] : '',
185
+					'country'  => isset($user_info['address']['country']) ? $user_info['address']['country'] : '',
186
+					'zip'      => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '',
187 187
 					'products' => $products,
188 188
 					'skus'     => $skus,
189
-					'amount'   => html_entity_decode( give_format_amount( $total ) ),
190
-					'gateway'  => give_get_gateway_admin_label( get_post_meta( $payment->ID, '_give_payment_gateway', true ) ),
191
-					'trans_id' => give_get_payment_transaction_id( $payment->ID ),
189
+					'amount'   => html_entity_decode(give_format_amount($total)),
190
+					'gateway'  => give_get_gateway_admin_label(get_post_meta($payment->ID, '_give_payment_gateway', true)),
191
+					'trans_id' => give_get_payment_transaction_id($payment->ID),
192 192
 					'key'      => $payment_meta['key'],
193 193
 					'date'     => $payment->post_date,
194
-					'user'     => $user ? $user->display_name : esc_html__( 'guest', 'give' ),
195
-					'status'   => give_get_payment_status( $payment, true )
194
+					'user'     => $user ? $user->display_name : esc_html__('guest', 'give'),
195
+					'status'   => give_get_payment_status($payment, true)
196 196
 				);
197 197
 
198 198
 			}
199 199
 
200
-			$data = apply_filters( 'give_export_get_data', $data );
201
-			$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
200
+			$data = apply_filters('give_export_get_data', $data);
201
+			$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
202 202
 
203 203
 			return $data;
204 204
 
@@ -218,27 +218,27 @@  discard block
 block discarded – undo
218 218
 
219 219
 		$status = $this->status;
220 220
 		$args   = array(
221
-			'start-date' => date( 'n/d/Y', strtotime( $this->start ) ),
222
-			'end-date'   => date( 'n/d/Y', strtotime( $this->end ) ),
221
+			'start-date' => date('n/d/Y', strtotime($this->start)),
222
+			'end-date'   => date('n/d/Y', strtotime($this->end)),
223 223
 		);
224 224
 
225
-		if ( 'any' == $status ) {
225
+		if ('any' == $status) {
226 226
 
227
-			$total = array_sum( (array) give_count_payments( $args ) );
227
+			$total = array_sum((array) give_count_payments($args));
228 228
 
229 229
 		} else {
230 230
 
231
-			$total = give_count_payments( $args )->$status;
231
+			$total = give_count_payments($args)->$status;
232 232
 
233 233
 		}
234 234
 
235 235
 		$percentage = 100;
236 236
 
237
-		if ( $total > 0 ) {
238
-			$percentage = ( ( 30 * $this->step ) / $total ) * 100;
237
+		if ($total > 0) {
238
+			$percentage = ((30 * $this->step) / $total) * 100;
239 239
 		}
240 240
 
241
-		if ( $percentage > 100 ) {
241
+		if ($percentage > 100) {
242 242
 			$percentage = 100;
243 243
 		}
244 244
 
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @param array $request The Form Data passed into the batch processing
254 254
 	 */
255
-	public function set_properties( $request ) {
256
-		$this->start  = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : '';
257
-		$this->end    = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : '';
258
-		$this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete';
255
+	public function set_properties($request) {
256
+		$this->start  = isset($request['start']) ? sanitize_text_field($request['start']) : '';
257
+		$this->end    = isset($request['end']) ? sanitize_text_field($request['end']) : '';
258
+		$this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'complete';
259 259
 	}
260 260
 }
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export.php 1 patch
Spacing   +33 added lines, -33 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' ) ) exit;
15
+if ( ! defined('ABSPATH')) exit;
16 16
 
17 17
 /**
18 18
  * Give_Batch_Export Class
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 	 * @param $_step int The step to process
105 105
 	 * @since 1.5
106 106
 	 */
107
-	public function __construct( $_step = 1 ) {
107
+	public function __construct($_step = 1) {
108 108
 
109 109
 		$upload_dir       = wp_upload_dir();
110 110
 		$this->filetype   = '.csv';
111
-		$this->filename   = 'give-' . $this->export_type . $this->filetype;
112
-		$this->file       = trailingslashit( $upload_dir['basedir'] ) . $this->filename;
111
+		$this->filename   = 'give-'.$this->export_type.$this->filetype;
112
+		$this->file       = trailingslashit($upload_dir['basedir']).$this->filename;
113 113
 
114
-		if ( ! is_writeable( $upload_dir['basedir'] ) ) {
114
+		if ( ! is_writeable($upload_dir['basedir'])) {
115 115
 			$this->is_writable = false;
116 116
 		}
117 117
 
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public function process_step() {
129 129
 
130
-		if ( ! $this->can_export() ) {
131
-			wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
130
+		if ( ! $this->can_export()) {
131
+			wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
132 132
 		}
133 133
 
134
-		if( $this->step < 2 ) {
134
+		if ($this->step < 2) {
135 135
 
136 136
 			// Make sure we start with a fresh file on step 1
137
-			@unlink( $this->file );
137
+			@unlink($this->file);
138 138
 			$this->print_csv_cols();
139 139
 		}
140 140
 
141 141
 		$rows = $this->print_csv_rows();
142 142
 
143
-		if( $rows ) {
143
+		if ($rows) {
144 144
 			return true;
145 145
 		} else {
146 146
 			return false;
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 		$col_data = '';
161 161
 		$cols = $this->get_csv_cols();
162 162
 		$i = 1;
163
-		foreach( $cols as $col_id => $column ) {
164
-			$col_data .= '"' . addslashes( $column ) . '"';
165
-			$col_data .= $i == count( $cols ) ? '' : ',';
163
+		foreach ($cols as $col_id => $column) {
164
+			$col_data .= '"'.addslashes($column).'"';
165
+			$col_data .= $i == count($cols) ? '' : ',';
166 166
 			$i++;
167 167
 		}
168 168
 		$col_data .= "\r\n";
169 169
 
170
-		$this->stash_step_data( $col_data );
170
+		$this->stash_step_data($col_data);
171 171
 
172 172
 		return $col_data;
173 173
 
@@ -186,23 +186,23 @@  discard block
 block discarded – undo
186 186
 		$data     = $this->get_data();
187 187
 		$cols     = $this->get_csv_cols();
188 188
 
189
-		if( $data ) {
189
+		if ($data) {
190 190
 
191 191
 			// Output each row
192
-			foreach ( $data as $row ) {
192
+			foreach ($data as $row) {
193 193
 				$i = 1;
194
-				foreach ( $row as $col_id => $column ) {
194
+				foreach ($row as $col_id => $column) {
195 195
 					// Make sure the column is valid
196
-					if ( array_key_exists( $col_id, $cols ) ) {
197
-						$row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"';
198
-						$row_data .= $i == count( $cols ) ? '' : ',';
196
+					if (array_key_exists($col_id, $cols)) {
197
+						$row_data .= '"'.addslashes(preg_replace("/\"/", "'", $column)).'"';
198
+						$row_data .= $i == count($cols) ? '' : ',';
199 199
 						$i++;
200 200
 					}
201 201
 				}
202 202
 				$row_data .= "\r\n";
203 203
 			}
204 204
 
205
-			$this->stash_step_data( $row_data );
205
+			$this->stash_step_data($row_data);
206 206
 
207 207
 			return $row_data;
208 208
 		}
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
 
231 231
 		$file = '';
232 232
 
233
-		if ( @file_exists( $this->file ) ) {
233
+		if (@file_exists($this->file)) {
234 234
 
235
-			if ( ! is_writeable( $this->file ) ) {
235
+			if ( ! is_writeable($this->file)) {
236 236
 				$this->is_writable = false;
237 237
 			}
238 238
 
239
-			$file = @file_get_contents( $this->file );
239
+			$file = @file_get_contents($this->file);
240 240
 
241 241
 		} else {
242 242
 
243
-			@file_put_contents( $this->file, '' );
244
-			@chmod( $this->file, 0664 );
243
+			@file_put_contents($this->file, '');
244
+			@chmod($this->file, 0664);
245 245
 
246 246
 		}
247 247
 
@@ -255,18 +255,18 @@  discard block
 block discarded – undo
255 255
 	 * @param $data string The data to add to the file
256 256
 	 * @return void
257 257
 	 */
258
-	protected function stash_step_data( $data = '' ) {
258
+	protected function stash_step_data($data = '') {
259 259
 
260 260
 		$file = $this->get_file();
261 261
 		$file .= $data;
262
-		@file_put_contents( $this->file, $file );
262
+		@file_put_contents($this->file, $file);
263 263
 
264 264
 		// If we have no rows after this step, mark it as an empty export
265
-		$file_rows    = file( $this->file, FILE_SKIP_EMPTY_LINES);
265
+		$file_rows    = file($this->file, FILE_SKIP_EMPTY_LINES);
266 266
 		$default_cols = $this->get_csv_cols();
267
-		$default_cols = empty( $default_cols ) ? 0 : 1;
267
+		$default_cols = empty($default_cols) ? 0 : 1;
268 268
 
269
-		$this->is_empty = count( $file_rows ) == $default_cols ? true : false;
269
+		$this->is_empty = count($file_rows) == $default_cols ? true : false;
270 270
 
271 271
 	}
272 272
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
 		$file = $this->get_file();
286 286
 
287
-		@unlink( $this->file );
287
+		@unlink($this->file);
288 288
 
289 289
 		echo $file;
290 290
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @since 1.5
298 298
 	 * @param array $request The Form Data passed into the batch processing
299 299
 	 */
300
-	public function set_properties( $request ) {}
300
+	public function set_properties($request) {}
301 301
 
302 302
 	/**
303 303
 	 * Allow for prefetching of data for the remainder of the exporter
Please login to merge, or discard this patch.
includes/admin/reporting/export/export-actions.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -22,20 +22,20 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function give_process_batch_export_form() {
24 24
 
25
-	if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) {
26
-		wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
25
+	if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) {
26
+		wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
27 27
 	}
28 28
 
29
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
29
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php';
30 30
 
31
-	do_action( 'give_batch_export_class_include', $_REQUEST['class'] );
31
+	do_action('give_batch_export_class_include', $_REQUEST['class']);
32 32
 
33 33
 	$export = new $_REQUEST['class'];
34 34
 	$export->export();
35 35
 
36 36
 }
37 37
 
38
-add_action( 'give_form_batch_export', 'give_process_batch_export_form' );
38
+add_action('give_form_batch_export', 'give_process_batch_export_form');
39 39
 
40 40
 /**
41 41
  * Exports earnings for a specified time period
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
  * @return void
47 47
  */
48 48
 function give_export_earnings() {
49
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php';
49
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php';
50 50
 
51 51
 	$earnings_export = new Give_Earnings_Export();
52 52
 
53 53
 	$earnings_export->export();
54 54
 }
55 55
 
56
-add_action( 'give_earnings_export', 'give_export_earnings' );
56
+add_action('give_earnings_export', 'give_export_earnings');
57 57
 
58 58
 
59 59
 /**
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
  * @return void
67 67
  */
68 68
 function give_export_all_customers() {
69
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php';
69
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php';
70 70
 
71 71
 	$customer_export = new Give_Donors_Export();
72 72
 
73 73
 	$customer_export->export();
74 74
 }
75 75
 
76
-add_action( 'give_email_export', 'give_export_all_customers' );
76
+add_action('give_email_export', 'give_export_all_customers');
77 77
 
78 78
 /**
79 79
  * Add a hook allowing extensions to register a hook on the batch export process
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
  * @return void
83 83
  */
84 84
 function give_register_batch_exporters() {
85
-	if ( is_admin() ) {
86
-		do_action( 'give_register_batch_exporter' );
85
+	if (is_admin()) {
86
+		do_action('give_register_batch_exporter');
87 87
 	}
88 88
 }
89 89
 
90
-add_action( 'plugins_loaded', 'give_register_batch_exporters' );
90
+add_action('plugins_loaded', 'give_register_batch_exporters');
91 91
 
92 92
 /**
93 93
  * Register the payments batch exporter
94 94
  * @since  1.5
95 95
  */
96 96
 function give_register_payments_batch_export() {
97
-	add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 );
97
+	add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1);
98 98
 }
99 99
 
100
-add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 );
100
+add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10);
101 101
 
102 102
 /**
103 103
  * Loads the payments batch process if needed
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
  *
109 109
  * @return void
110 110
  */
111
-function give_include_payments_batch_processor( $class ) {
111
+function give_include_payments_batch_processor($class) {
112 112
 
113
-	if ( 'Give_Batch_Payments_Export' === $class ) {
114
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php';
113
+	if ('Give_Batch_Payments_Export' === $class) {
114
+		require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php';
115 115
 	}
116 116
 
117 117
 }
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
  * @since  1.5.2
122 122
  */
123 123
 function give_register_customers_batch_export() {
124
-	add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 );
124
+	add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1);
125 125
 }
126 126
 
127
-add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 );
127
+add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10);
128 128
 
129 129
 /**
130 130
  * Loads the customers batch process if needed
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return void
137 137
  */
138
-function give_include_customers_batch_processor( $class ) {
138
+function give_include_customers_batch_processor($class) {
139 139
 
140
-	if ( 'Give_Batch_Customers_Export' === $class ) {
141
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php';
140
+	if ('Give_Batch_Customers_Export' === $class) {
141
+		require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php';
142 142
 	}
143 143
 
144 144
 }
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
  * @since  1.5
150 150
  */
151 151
 function give_register_forms_batch_export() {
152
-	add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 );
152
+	add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1);
153 153
 }
154 154
 
155
-add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 );
155
+add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10);
156 156
 
157 157
 /**
158 158
  * Loads the file downloads batch process if needed
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return void
165 165
  */
166
-function give_include_forms_batch_processor( $class ) {
166
+function give_include_forms_batch_processor($class) {
167 167
 
168
-	if ( 'Give_Batch_Forms_Export' === $class ) {
169
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php';
168
+	if ('Give_Batch_Forms_Export' === $class) {
169
+		require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php';
170 170
 	}
171 171
 
172 172
 }
173 173
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export-forms.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
 	public function csv_cols() {
42 42
 
43 43
 		$cols = array(
44
-			'ID'                      => esc_html__( 'ID', 'give' ),
45
-			'post_name'               => esc_html__( 'Slug', 'give' ),
46
-			'post_title'              => esc_html__( 'Name', 'give' ),
47
-			'post_date'               => esc_html__( 'Date Created', 'give' ),
48
-			'post_author'             => esc_html__( 'Author', 'give' ),
49
-			'post_content'            => esc_html__( 'Description', 'give' ),
50
-			'post_excerpt'            => esc_html__( 'Excerpt', 'give' ),
51
-			'post_status'             => esc_html__( 'Status', 'give' ),
52
-			'categories'              => esc_html__( 'Categories', 'give' ),
53
-			'tags'                    => esc_html__( 'Tags', 'give' ),
54
-			'give_price'              => esc_html__( 'Price', 'give' ),
55
-			'_thumbnail_id'           => esc_html__( 'Featured Image', 'give' ),
56
-			'_give_form_sales'        => esc_html__( 'Donations', 'give' ),
57
-			'_give_download_earnings' => esc_html__( 'Income', 'give' ),
44
+			'ID'                      => esc_html__('ID', 'give'),
45
+			'post_name'               => esc_html__('Slug', 'give'),
46
+			'post_title'              => esc_html__('Name', 'give'),
47
+			'post_date'               => esc_html__('Date Created', 'give'),
48
+			'post_author'             => esc_html__('Author', 'give'),
49
+			'post_content'            => esc_html__('Description', 'give'),
50
+			'post_excerpt'            => esc_html__('Excerpt', 'give'),
51
+			'post_status'             => esc_html__('Status', 'give'),
52
+			'categories'              => esc_html__('Categories', 'give'),
53
+			'tags'                    => esc_html__('Tags', 'give'),
54
+			'give_price'              => esc_html__('Price', 'give'),
55
+			'_thumbnail_id'           => esc_html__('Featured Image', 'give'),
56
+			'_give_form_sales'        => esc_html__('Donations', 'give'),
57
+			'_give_download_earnings' => esc_html__('Income', 'give'),
58 58
 		);
59 59
 
60 60
 		return $cols;
@@ -86,43 +86,43 @@  discard block
 block discarded – undo
86 86
 			'paged'          => $this->step
87 87
 		);
88 88
 
89
-		$downloads = new WP_Query( $args );
89
+		$downloads = new WP_Query($args);
90 90
 
91
-		if ( $downloads->posts ) {
92
-			foreach ( $downloads->posts as $download ) {
91
+		if ($downloads->posts) {
92
+			foreach ($downloads->posts as $download) {
93 93
 
94 94
 				$row = array();
95 95
 
96
-				foreach ( $this->csv_cols() as $key => $value ) {
96
+				foreach ($this->csv_cols() as $key => $value) {
97 97
 
98 98
 					// Setup default value
99
-					$row[ $key ] = '';
99
+					$row[$key] = '';
100 100
 
101
-					if ( in_array( $key, $meta ) ) {
101
+					if (in_array($key, $meta)) {
102 102
 
103
-						switch ( $key ) {
103
+						switch ($key) {
104 104
 
105 105
 							case '_thumbnail_id' :
106 106
 
107
-								$image_id    = get_post_thumbnail_id( $download->ID );
108
-								$row[ $key ] = wp_get_attachment_url( $image_id );
107
+								$image_id    = get_post_thumbnail_id($download->ID);
108
+								$row[$key] = wp_get_attachment_url($image_id);
109 109
 
110 110
 								break;
111 111
 
112 112
 							case 'give_price' :
113 113
 
114
-								if ( give_has_variable_prices( $download->ID ) ) {
114
+								if (give_has_variable_prices($download->ID)) {
115 115
 
116 116
 									$prices = array();
117
-									foreach ( give_get_variable_prices( $download->ID ) as $price ) {
118
-										$prices[] = $price['name'] . ': ' . $price['amount'];
117
+									foreach (give_get_variable_prices($download->ID) as $price) {
118
+										$prices[] = $price['name'].': '.$price['amount'];
119 119
 									}
120 120
 
121
-									$row[ $key ] = implode( ' | ', $prices );
121
+									$row[$key] = implode(' | ', $prices);
122 122
 
123 123
 								} else {
124 124
 
125
-									$row[ $key ] = give_get_download_price( $download->ID );
125
+									$row[$key] = give_get_download_price($download->ID);
126 126
 
127 127
 								}
128 128
 
@@ -132,54 +132,54 @@  discard block
 block discarded – undo
132 132
 
133 133
 
134 134
 								$files = array();
135
-								foreach ( give_get_download_files( $download->ID ) as $file ) {
135
+								foreach (give_get_download_files($download->ID) as $file) {
136 136
 									$files[] = $file['file'];
137 137
 								}
138 138
 
139
-								$row[ $key ] = implode( ' | ', $files );
139
+								$row[$key] = implode(' | ', $files);
140 140
 
141 141
 								break;
142 142
 
143 143
 							default :
144 144
 
145
-								$row[ $key ] = get_post_meta( $download->ID, $key, true );
145
+								$row[$key] = get_post_meta($download->ID, $key, true);
146 146
 
147 147
 								break;
148 148
 
149 149
 						}
150 150
 
151
-					} elseif ( isset( $download->$key ) ) {
151
+					} elseif (isset($download->$key)) {
152 152
 
153
-						switch ( $key ) {
153
+						switch ($key) {
154 154
 
155 155
 							case 'post_author' :
156 156
 
157
-								$row[ $key ] = get_the_author_meta( 'user_login', $download->post_author );
157
+								$row[$key] = get_the_author_meta('user_login', $download->post_author);
158 158
 
159 159
 								break;
160 160
 
161 161
 							default :
162 162
 
163
-								$row[ $key ] = $download->$key;
163
+								$row[$key] = $download->$key;
164 164
 
165 165
 								break;
166 166
 						}
167 167
 
168
-					} elseif ( 'tags' == $key ) {
168
+					} elseif ('tags' == $key) {
169 169
 
170
-						$terms = get_the_terms( $download->ID, 'download_tag' );
171
-						if ( $terms ) {
172
-							$terms       = wp_list_pluck( $terms, 'name' );
173
-							$row[ $key ] = implode( ' | ', $terms );
170
+						$terms = get_the_terms($download->ID, 'download_tag');
171
+						if ($terms) {
172
+							$terms       = wp_list_pluck($terms, 'name');
173
+							$row[$key] = implode(' | ', $terms);
174 174
 						}
175 175
 
176 176
 
177
-					} elseif ( 'categories' == $key ) {
177
+					} elseif ('categories' == $key) {
178 178
 
179
-						$terms = get_the_terms( $download->ID, 'download_category' );
180
-						if ( $terms ) {
181
-							$terms       = wp_list_pluck( $terms, 'name' );
182
-							$row[ $key ] = implode( ' | ', $terms );
179
+						$terms = get_the_terms($download->ID, 'download_category');
180
+						if ($terms) {
181
+							$terms       = wp_list_pluck($terms, 'name');
182
+							$row[$key] = implode(' | ', $terms);
183 183
 						}
184 184
 
185 185
 					}
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 
191 191
 			}
192 192
 
193
-			$data = apply_filters( 'give_export_get_data', $data );
194
-			$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
193
+			$data = apply_filters('give_export_get_data', $data);
194
+			$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
195 195
 
196 196
 			return $data;
197 197
 		}
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
 
211 211
 		$args = array(
212 212
 			'post_type'      => 'give_forms',
213
-			'posts_per_page' => - 1,
213
+			'posts_per_page' => -1,
214 214
 			'post_status'    => 'any',
215 215
 			'fields'         => 'ids',
216 216
 		);
217 217
 
218
-		$downloads  = new WP_Query( $args );
218
+		$downloads  = new WP_Query($args);
219 219
 		$total      = (int) $downloads->post_count;
220 220
 		$percentage = 100;
221 221
 
222
-		if ( $total > 0 ) {
223
-			$percentage = ( ( 30 * $this->step ) / $total ) * 100;
222
+		if ($total > 0) {
223
+			$percentage = ((30 * $this->step) / $total) * 100;
224 224
 		}
225 225
 
226
-		if ( $percentage > 100 ) {
226
+		if ($percentage > 100) {
227 227
 			$percentage = 100;
228 228
 		}
229 229
 
Please login to merge, or discard this patch.
includes/admin/reporting/class-export.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @return bool Whether we can export or not
38 38
 	 */
39 39
 	public function can_export() {
40
-		return (bool) apply_filters( 'give_export_capability', current_user_can( 'export_give_reports' ) );
40
+		return (bool) apply_filters('give_export_capability', current_user_can('export_give_reports'));
41 41
 	}
42 42
 
43 43
 	/**
@@ -48,16 +48,16 @@  discard block
 block discarded – undo
48 48
 	 * @return void
49 49
 	 */
50 50
 	public function headers() {
51
-		ignore_user_abort( true );
51
+		ignore_user_abort(true);
52 52
 
53
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
54
-			set_time_limit( 0 );
53
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
54
+			set_time_limit(0);
55 55
 		}
56 56
 
57 57
 		nocache_headers();
58
-		header( 'Content-Type: text/csv; charset=utf-8' );
59
-		header( 'Content-Disposition: attachment; filename=give-export-' . $this->export_type . '-' . date( 'm-d-Y' ) . '.csv' );
60
-		header( "Expires: 0" );
58
+		header('Content-Type: text/csv; charset=utf-8');
59
+		header('Content-Disposition: attachment; filename=give-export-'.$this->export_type.'-'.date('m-d-Y').'.csv');
60
+		header("Expires: 0");
61 61
 	}
62 62
 
63 63
 	/**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function csv_cols() {
71 71
 		$cols = array(
72
-			'id'   => esc_html__( 'ID', 'give' ),
73
-			'date' => esc_html__( 'Date', 'give' )
72
+			'id'   => esc_html__('ID', 'give'),
73
+			'date' => esc_html__('Date', 'give')
74 74
 		);
75 75
 
76 76
 		return $cols;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	public function get_csv_cols() {
87 87
 		$cols = $this->csv_cols();
88 88
 
89
-		return apply_filters( 'give_export_csv_cols_' . $this->export_type, $cols );
89
+		return apply_filters('give_export_csv_cols_'.$this->export_type, $cols);
90 90
 	}
91 91
 
92 92
 	/**
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 	public function csv_cols_out() {
101 101
 		$cols = $this->get_csv_cols();
102 102
 		$i    = 1;
103
-		foreach ( $cols as $col_id => $column ) {
104
-			echo '"' . addslashes( $column ) . '"';
105
-			echo $i == count( $cols ) ? '' : ',';
106
-			$i ++;
103
+		foreach ($cols as $col_id => $column) {
104
+			echo '"'.addslashes($column).'"';
105
+			echo $i == count($cols) ? '' : ',';
106
+			$i++;
107 107
 		}
108 108
 		echo "\r\n";
109 109
 	}
@@ -120,16 +120,16 @@  discard block
 block discarded – undo
120 120
 		$data = array(
121 121
 			0 => array(
122 122
 				'id'   => '',
123
-				'data' => date( 'F j, Y' )
123
+				'data' => date('F j, Y')
124 124
 			),
125 125
 			1 => array(
126 126
 				'id'   => '',
127
-				'data' => date( 'F j, Y' )
127
+				'data' => date('F j, Y')
128 128
 			)
129 129
 		);
130 130
 
131
-		$data = apply_filters( 'give_export_get_data', $data );
132
-		$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
131
+		$data = apply_filters('give_export_get_data', $data);
132
+		$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
133 133
 
134 134
 		return $data;
135 135
 	}
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 		$cols = $this->get_csv_cols();
148 148
 
149 149
 		// Output each row
150
-		foreach ( $data as $row ) {
150
+		foreach ($data as $row) {
151 151
 			$i = 1;
152
-			foreach ( $row as $col_id => $column ) {
152
+			foreach ($row as $col_id => $column) {
153 153
 				// Make sure the column is valid
154
-				if ( array_key_exists( $col_id, $cols ) ) {
155
-					echo '"' . addslashes( $column ) . '"';
156
-					echo $i == count( $cols ) ? '' : ',';
157
-					$i ++;
154
+				if (array_key_exists($col_id, $cols)) {
155
+					echo '"'.addslashes($column).'"';
156
+					echo $i == count($cols) ? '' : ',';
157
+					$i++;
158 158
 				}
159 159
 			}
160 160
 			echo "\r\n";
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @return void
174 174
 	 */
175 175
 	public function export() {
176
-		if ( ! $this->can_export() ) {
177
-			wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
176
+		if ( ! $this->can_export()) {
177
+			wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
178 178
 		}
179 179
 
180 180
 		// Set headers
Please login to merge, or discard this patch.