Completed
Pull Request — master (#1203)
by Devin
20:46
created
includes/class-give-email-access.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	public $error = '';
24 24
 
25 25
 	private $verify_throttle;
26
-    private $token_expiration;
26
+	private $token_expiration;
27 27
 
28 28
 	/**
29 29
 	 * Give_Email_Access constructor.
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @return bool
244 244
 	 */
245 245
 	function is_valid_verify_key( $token ) {
246
-        /* @var WPDB $wpdb */
246
+		/* @var WPDB $wpdb */
247 247
 		global $wpdb;
248 248
 
249 249
 		// See if the verify_key exists
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 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
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	public function __construct() {
97 97
 
98 98
 		// get it started
99
-		add_action( 'init', array( $this, 'init' ) );
99
+		add_action('init', array($this, 'init'));
100 100
 	}
101 101
 
102 102
 	/**
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function init() {
113 113
 
114
-		$is_enabled = give_get_option( 'email_access' );
114
+		$is_enabled = give_get_option('email_access');
115 115
 
116 116
 		//Non-logged in users only
117
-		if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) {
117
+		if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) {
118 118
 			return;
119 119
 		}
120 120
 
121 121
 		//Are db columns setup?
122
-		$is_setup = give_get_option( 'email_access_installed' );
123
-		if ( empty( $is_setup ) ) {
122
+		$is_setup = give_get_option('email_access_installed');
123
+		if (empty($is_setup)) {
124 124
 			$this->create_columns();
125 125
 		}
126 126
 
127 127
 		// Timeouts
128
-		$this->verify_throttle  = apply_filters( 'give_nl_verify_throttle', 300 );
129
-		$this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 );
128
+		$this->verify_throttle  = apply_filters('give_nl_verify_throttle', 300);
129
+		$this->token_expiration = apply_filters('give_nl_token_expiration', 7200);
130 130
 
131 131
 		// Setup login
132 132
 		$this->check_for_token();
133 133
 
134
-		if ( $this->token_exists ) {
135
-			add_filter( 'give_can_view_receipt', '__return_true' );
136
-			add_filter( 'give_user_pending_verification', '__return_false' );
137
-			add_filter( 'give_get_users_purchases_args', array( $this, 'users_purchases_args' ) );
134
+		if ($this->token_exists) {
135
+			add_filter('give_can_view_receipt', '__return_true');
136
+			add_filter('give_user_pending_verification', '__return_false');
137
+			add_filter('give_get_users_purchases_args', array($this, 'users_purchases_args'));
138 138
 		}
139 139
 	}
140 140
 
@@ -148,25 +148,25 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return bool
150 150
 	 */
151
-	public function can_send_email( $customer_id ) {
151
+	public function can_send_email($customer_id) {
152 152
 		/* @var WPDB $wpdb */
153 153
 		global $wpdb;
154 154
 
155 155
 		// Prevent multiple emails within X minutes
156
-		$throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle );
156
+		$throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle);
157 157
 
158 158
 		// Does a user row exist?
159 159
 		$exists = (int) $wpdb->get_var(
160
-			$wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id )
160
+			$wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id)
161 161
 		);
162 162
 
163
-		if ( 0 < $exists ) {
163
+		if (0 < $exists) {
164 164
 			$row_id = (int) $wpdb->get_var(
165
-				$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle )
165
+				$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle)
166 166
 			);
167 167
 
168
-			if ( $row_id < 1 ) {
169
-				give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) );
168
+			if ($row_id < 1) {
169
+				give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give'));
170 170
 
171 171
 				return false;
172 172
 			}
@@ -186,34 +186,34 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return void
188 188
 	 */
189
-	public function send_email( $customer_id, $email ) {
189
+	public function send_email($customer_id, $email) {
190 190
 
191
-		$verify_key = wp_generate_password( 20, false );
191
+		$verify_key = wp_generate_password(20, false);
192 192
 
193 193
 		// Generate a new verify key
194
-		$this->set_verify_key( $customer_id, $email, $verify_key );
194
+		$this->set_verify_key($customer_id, $email, $verify_key);
195 195
 
196 196
 		// Get the donation history page
197
-		$page_id = give_get_option( 'history_page' );
197
+		$page_id = give_get_option('history_page');
198 198
 
199
-		$access_url = add_query_arg( array(
199
+		$access_url = add_query_arg(array(
200 200
 			'give_nl' => $verify_key,
201
-		), get_permalink( $page_id ) );
201
+		), get_permalink($page_id));
202 202
 
203 203
 		//Nice subject and message
204
-		$subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) );
204
+		$subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name')));
205 205
 
206
-		$message  = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n";
207
-		$message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details &raquo;', 'give' ) . '</a>' . "\n\n";
206
+		$message  = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n";
207
+		$message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details &raquo;', 'give').'</a>'."\n\n";
208 208
 		$message .= "\n\n";
209
-		$message .= esc_html__( 'Sincerely,', 'give' ) . "\n";
210
-		$message .= get_bloginfo( 'name' ) . "\n";
209
+		$message .= esc_html__('Sincerely,', 'give')."\n";
210
+		$message .= get_bloginfo('name')."\n";
211 211
 
212
-		$message = apply_filters( 'give_email_access_token_message', $message );
212
+		$message = apply_filters('give_email_access_token_message', $message);
213 213
 
214 214
 		// Send the email
215
-		Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) );
216
-		Give()->emails->send( $email, $subject, $message );
215
+		Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give')));
216
+		Give()->emails->send($email, $subject, $message);
217 217
 
218 218
 	}
219 219
 
@@ -227,24 +227,24 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function check_for_token() {
229 229
 
230
-		$token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : '';
230
+		$token = isset($_GET['give_nl']) ? $_GET['give_nl'] : '';
231 231
 
232 232
 		// Check for cookie
233
-		if ( empty( $token ) ) {
234
-			$token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : '';
233
+		if (empty($token)) {
234
+			$token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : '';
235 235
 		}
236 236
 
237
-		if ( ! empty( $token ) ) {
238
-			if ( ! $this->is_valid_token( $token ) ) {
239
-				if ( ! $this->is_valid_verify_key( $token ) ) {
237
+		if ( ! empty($token)) {
238
+			if ( ! $this->is_valid_token($token)) {
239
+				if ( ! $this->is_valid_verify_key($token)) {
240 240
 					return;
241 241
 				}
242 242
 			}
243 243
 
244 244
 			$this->token_exists = true;
245 245
 			// Set cookie
246
-			$lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time();
247
-			@setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
246
+			$lifetime = current_time('timestamp') + Give()->session->set_expiration_time();
247
+			@setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
248 248
 		}
249 249
 	}
250 250
 
@@ -258,18 +258,18 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @return bool
260 260
 	 */
261
-	public function is_valid_token( $token ) {
261
+	public function is_valid_token($token) {
262 262
 
263 263
 		global $wpdb;
264 264
 
265 265
 		// Make sure token isn't expired
266
-		$expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration );
266
+		$expires = date('Y-m-d H:i:s', time() - $this->token_expiration);
267 267
 
268 268
 		$email = $wpdb->get_var(
269
-			$wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires )
269
+			$wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires)
270 270
 		);
271 271
 
272
-		if ( ! empty( $email ) ) {
272
+		if ( ! empty($email)) {
273 273
 			$this->token_email = $email;
274 274
 			$this->token       = $token;
275 275
 
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 		}
278 278
 
279 279
 		//Set error only if email access form isn't being submitted
280
-		if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) {
281
-			give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', esc_html__( 'Your access token has expired. Please request a new one below:', 'give' ) ) );
280
+		if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) {
281
+			give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', esc_html__('Your access token has expired. Please request a new one below:', 'give')));
282 282
 		}
283 283
 
284 284
 		return false;
@@ -297,25 +297,25 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return void
299 299
 	 */
300
-	public function set_verify_key( $customer_id, $email, $verify_key ) {
300
+	public function set_verify_key($customer_id, $email, $verify_key) {
301 301
 		global $wpdb;
302 302
 
303
-		$now = date( 'Y-m-d H:i:s' );
303
+		$now = date('Y-m-d H:i:s');
304 304
 
305 305
 		// Insert or update?
306 306
 		$row_id = (int) $wpdb->get_var(
307
-			$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id )
307
+			$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id)
308 308
 		);
309 309
 
310 310
 		// Update
311
-		if ( ! empty( $row_id ) ) {
311
+		if ( ! empty($row_id)) {
312 312
 			$wpdb->query(
313
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id )
313
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id)
314 314
 			);
315 315
 		} // Insert
316 316
 		else {
317 317
 			$wpdb->query(
318
-				$wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now )
318
+				$wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now)
319 319
 			);
320 320
 		}
321 321
 	}
@@ -330,21 +330,21 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return bool
332 332
 	 */
333
-	public function is_valid_verify_key( $token ) {
333
+	public function is_valid_verify_key($token) {
334 334
         /* @var WPDB $wpdb */
335 335
 		global $wpdb;
336 336
 
337 337
 		// See if the verify_key exists
338 338
 		$row = $wpdb->get_row(
339
-			$wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token )
339
+			$wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token)
340 340
 		);
341 341
 
342
-		$now = date( 'Y-m-d H:i:s' );
342
+		$now = date('Y-m-d H:i:s');
343 343
 
344 344
 		// Set token
345
-		if ( ! empty( $row ) ) {
345
+		if ( ! empty($row)) {
346 346
 			$wpdb->query(
347
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id )
347
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id)
348 348
 			);
349 349
 
350 350
 			$this->token_email = $row->email;
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @return mixed
370 370
 	 */
371
-	public function users_purchases_args( $args ) {
371
+	public function users_purchases_args($args) {
372 372
 		$args['user'] = $this->token_email;
373 373
 
374 374
 		return $args;
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 		global $wpdb;
390 390
 
391 391
 		//Create columns in customers table
392
-		$query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" );
392
+		$query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`");
393 393
 
394 394
 		//Columns added properly
395
-		if ( $query ) {
396
-			give_update_option( 'email_access_installed', 1 );
395
+		if ($query) {
396
+			give_update_option('email_access_installed', 1);
397 397
 		}
398 398
 
399 399
 	}
Please login to merge, or discard this patch.
includes/admin/upgrades/upgrades.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,11 +64,14 @@
 block discarded – undo
64 64
 				}, 250 );
65 65
 			</script>
66 66
 
67
-		<?php else : ?>
67
+		<?php else {
68
+	: ?>
68 69
 
69 70
 			<div id="give-upgrade-status">
70 71
 				<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
+					<?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' );
73
+}
74
+?>
72 75
 					<img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style="  position: relative; top: 3px; left: 6px;" />
73 76
 				</p>
74 77
 			</div>
Please login to merge, or discard this 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
-		<h1><?php esc_html_e( 'Give - Upgrades', 'give' ); ?></h1>
46
+		<h1><?php esc_html_e('Give - Upgrades', 'give'); ?></h1>
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/reporting/export/export-functions.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
18
-require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export.php';
19
-require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-actions.php';
18
+require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export.php';
19
+require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-actions.php';
20 20
 
21 21
 /**
22 22
  * Process batch exports via ajax
@@ -26,79 +26,79 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function give_do_ajax_export() {
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
-	parse_str( $_POST['form'], $form );
31
+	parse_str($_POST['form'], $form);
32 32
 
33 33
 	$_REQUEST = $form = (array) $form;
34 34
 
35
-	if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) {
36
-		die( '-2' );
35
+	if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) {
36
+		die('-2');
37 37
 	}
38 38
 
39
-	do_action( 'give_batch_export_class_include', $form['give-export-class'] );
39
+	do_action('give_batch_export_class_include', $form['give-export-class']);
40 40
 
41
-	$step   = absint( $_POST['step'] );
42
-	$class  = sanitize_text_field( $form['give-export-class'] );
41
+	$step   = absint($_POST['step']);
42
+	$class  = sanitize_text_field($form['give-export-class']);
43 43
 
44
-	$export = new $class( $step );
44
+	$export = new $class($step);
45 45
 
46
-	if ( ! $export->can_export() ) {
47
-		die( '-1' );
46
+	if ( ! $export->can_export()) {
47
+		die('-1');
48 48
 	}
49 49
 
50
-	if ( ! $export->is_writable ) {
50
+	if ( ! $export->is_writable) {
51 51
 		$json_args = array(
52 52
 			'error'   => true,
53
-			'message' => esc_html__( 'Export location or file not writable.', 'give' )
53
+			'message' => esc_html__('Export location or file not writable.', 'give')
54 54
 		);
55 55
 		echo json_encode($json_args);
56 56
 		exit;
57 57
 	}
58 58
 
59
-	$export->set_properties( $_REQUEST );
59
+	$export->set_properties($_REQUEST);
60 60
 
61 61
 	$export->pre_fetch();
62 62
 
63
-	$ret = $export->process_step( $step );
63
+	$ret = $export->process_step($step);
64 64
 
65 65
 	$percentage = $export->get_percentage_complete();
66 66
 
67
-	if ( $ret ) {
67
+	if ($ret) {
68 68
 
69 69
 		$step += 1;
70
-		echo json_encode( array( 'step' => $step, 'percentage' => $percentage ) );
70
+		echo json_encode(array('step' => $step, 'percentage' => $percentage));
71 71
 		exit;
72 72
 
73
-	} elseif ( true === $export->is_empty ) {
73
+	} elseif (true === $export->is_empty) {
74 74
 
75
-		echo json_encode( array(
75
+		echo json_encode(array(
76 76
 			'error'   => true,
77
-			'message' => esc_html__( 'No data found for export parameters.', 'give' )
78
-		) );
77
+			'message' => esc_html__('No data found for export parameters.', 'give')
78
+		));
79 79
 		exit;
80 80
 
81
-	} elseif ( true === $export->done && true === $export->is_void ) {
81
+	} elseif (true === $export->done && true === $export->is_void) {
82 82
 
83
-		$message = ! empty( $export->message ) ? $export->message : esc_html__( 'Batch Processing Complete', 'give' );
84
-		echo json_encode( array( 'success' => true, 'message' => $message ) );
83
+		$message = ! empty($export->message) ? $export->message : esc_html__('Batch Processing Complete', 'give');
84
+		echo json_encode(array('success' => true, 'message' => $message));
85 85
 		exit;
86 86
 
87 87
 	} else {
88 88
 		
89
-		$args = array_merge( $_REQUEST, array(
89
+		$args = array_merge($_REQUEST, array(
90 90
 			'step'        => $step,
91 91
 			'class'       => $class,
92
-			'nonce'       => wp_create_nonce( 'give-batch-export' ),
92
+			'nonce'       => wp_create_nonce('give-batch-export'),
93 93
 			'give_action' => 'form_batch_export',
94
-		) );
94
+		));
95 95
 
96
-		$download_url = add_query_arg( $args, admin_url() );
96
+		$download_url = add_query_arg($args, admin_url());
97 97
 
98
-		echo json_encode( array( 'step' => 'done', 'url' => $download_url ) );
98
+		echo json_encode(array('step' => 'done', 'url' => $download_url));
99 99
 		exit;
100 100
 
101 101
 	}
102 102
 }
103 103
 
104
-add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' );
104
+add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export');
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-login.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,16 +42,16 @@
 block discarded – undo
42 42
 				'minWidth' => 320,
43 43
 				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after login.', 'give' ),
44 44
 			),
45
-            array(
46
-                'type' => 'container',
47
-                'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ),
48
-            ),
49
-            array(
50
-                'type'     => 'textbox',
51
-                'name'     => 'logout-redirect',
52
-                'minWidth' => 320,
53
-                'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ),
54
-            ),
45
+			array(
46
+				'type' => 'container',
47
+				'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ),
48
+			),
49
+			array(
50
+				'type'     => 'textbox',
51
+				'name'     => 'logout-redirect',
52
+				'minWidth' => 320,
53
+				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ),
54
+			),
55 55
 		);
56 56
 	}
57 57
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 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,10 +21,10 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function __construct() {
23 23
 
24
-		$this->shortcode['title'] = esc_html__( 'Login', 'give' );
25
-		$this->shortcode['label'] = esc_html__( 'Login', 'give' );
24
+		$this->shortcode['title'] = esc_html__('Login', 'give');
25
+		$this->shortcode['label'] = esc_html__('Login', 'give');
26 26
 
27
-		parent::__construct( 'give_login' );
27
+		parent::__construct('give_login');
28 28
 	}
29 29
 
30 30
 	/**
@@ -37,23 +37,23 @@  discard block
 block discarded – undo
37 37
 		return array(
38 38
 			array(
39 39
 				'type' => 'container',
40
-				'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Login Redirect URL (optional):', 'give' ) ),
40
+				'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Login Redirect URL (optional):', 'give')),
41 41
 			),
42 42
 			array(
43 43
 				'type'     => 'textbox',
44 44
 				'name'     => 'login-redirect',
45 45
 				'minWidth' => 320,
46
-				'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after login.', 'give' ),
46
+				'tooltip'  => esc_attr__('Enter an URL here to redirect to after login.', 'give'),
47 47
 			),
48 48
             array(
49 49
                 'type' => 'container',
50
-                'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ),
50
+                'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Logout Redirect URL (optional):', 'give')),
51 51
             ),
52 52
             array(
53 53
                 'type'     => 'textbox',
54 54
                 'name'     => 'logout-redirect',
55 55
                 'minWidth' => 320,
56
-                'tooltip'  => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ),
56
+                'tooltip'  => esc_attr__('Enter an URL here to redirect to after logout.', 'give'),
57 57
             ),
58 58
 		);
59 59
 	}
Please login to merge, or discard this patch.
includes/admin/shortcodes/abstract-shortcode-generator.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -248,8 +248,8 @@
 block discarded – undo
248 248
 
249 249
 			// do not reindex array!
250 250
 			$field['options'] = array(
251
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
252
-			                    ) + $field['options'];
251
+									'' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
252
+								) + $field['options'];
253 253
 
254 254
 			foreach ( $field['options'] as $value => $text ) {
255 255
 				$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
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @since 1.0
64 64
 	 */
65
-	public function __construct( $shortcode ) {
65
+	public function __construct($shortcode) {
66 66
 
67 67
 
68 68
 		$this->shortcode_tag = $shortcode;
69 69
 
70
-		add_action( 'admin_init', array( $this, 'init' ) );
70
+		add_action('admin_init', array($this, 'init'));
71 71
 
72 72
 	}
73 73
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function init() {
80 80
 
81
-		if ( $this->shortcode_tag ) {
81
+		if ($this->shortcode_tag) {
82 82
 
83
-			$this->self = get_class( $this );
83
+			$this->self = get_class($this);
84 84
 
85 85
 			$this->errors   = array();
86 86
 			$this->required = array();
@@ -89,18 +89,18 @@  discard block
 block discarded – undo
89 89
 			$fields = $this->get_fields();
90 90
 
91 91
 			$defaults = array(
92
-				'btn_close' => esc_html__( 'Close', 'give' ),
93
-				'btn_okay'  => esc_html__( 'Insert Shortcode', 'give' ),
92
+				'btn_close' => esc_html__('Close', 'give'),
93
+				'btn_okay'  => esc_html__('Insert Shortcode', 'give'),
94 94
 				'errors'    => $this->errors,
95 95
 				'fields'    => $fields,
96
-				'label'     => '[' . $this->shortcode_tag . ']',
96
+				'label'     => '['.$this->shortcode_tag.']',
97 97
 				'required'  => $this->required,
98
-				'title'     => esc_html__( 'Insert Shortcode', 'give' ),
98
+				'title'     => esc_html__('Insert Shortcode', 'give'),
99 99
 			);
100 100
 
101
-			if ( user_can_richedit() ) {
101
+			if (user_can_richedit()) {
102 102
 
103
-				Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults );
103
+				Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults);
104 104
 
105 105
 			}
106 106
 		}
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @since 1.0
131 131
 	 */
132
-	protected function generate_fields( $defined_fields ) {
132
+	protected function generate_fields($defined_fields) {
133 133
 
134 134
 		$fields = array();
135 135
 
136
-		if ( is_array( $defined_fields ) ) {
136
+		if (is_array($defined_fields)) {
137 137
 
138
-			foreach ( $defined_fields as $field ) {
138
+			foreach ($defined_fields as $field) {
139 139
 
140 140
 				$defaults = array(
141 141
 					'label'       => false,
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 					'type'        => '',
147 147
 				);
148 148
 
149
-				$field  = wp_parse_args( (array) $field, $defaults );
150
-				$method = 'generate_' . strtolower( $field['type'] );
149
+				$field  = wp_parse_args((array) $field, $defaults);
150
+				$method = 'generate_'.strtolower($field['type']);
151 151
 
152
-				if ( method_exists( $this, $method ) ) {
152
+				if (method_exists($this, $method)) {
153 153
 
154
-					$field = call_user_func( array( $this, $method ), $field );
154
+					$field = call_user_func(array($this, $method), $field);
155 155
 
156
-					if ( $field ) {
156
+					if ($field) {
157 157
 						$fields[] = $field;
158 158
 					}
159 159
 				}
@@ -173,22 +173,22 @@  discard block
 block discarded – undo
173 173
 	protected function get_fields() {
174 174
 
175 175
 		$defined_fields   = $this->define_fields();
176
-		$generated_fields = $this->generate_fields( $defined_fields );
176
+		$generated_fields = $this->generate_fields($defined_fields);
177 177
 
178 178
 		$errors = array();
179 179
 
180
-		if ( ! empty( $this->errors ) ) {
181
-			foreach ( $this->required as $name => $alert ) {
182
-				if ( false === array_search( $name, array_column( $generated_fields, 'name' ) ) ) {
180
+		if ( ! empty($this->errors)) {
181
+			foreach ($this->required as $name => $alert) {
182
+				if (false === array_search($name, array_column($generated_fields, 'name'))) {
183 183
 
184
-					$errors[] = $this->errors[ $name ];
184
+					$errors[] = $this->errors[$name];
185 185
 				}
186 186
 			}
187 187
 
188 188
 			$this->errors = $errors;
189 189
 		}
190 190
 
191
-		if ( ! empty( $errors ) ) {
191
+		if ( ! empty($errors)) {
192 192
 
193 193
 			return $errors;
194 194
 		}
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	protected function generate_container( $field ) {
208
+	protected function generate_container($field) {
209 209
 
210
-		if ( array_key_exists( 'html', $field ) ) {
210
+		if (array_key_exists('html', $field)) {
211 211
 
212 212
 			return array(
213 213
 				'type' => $field['type'],
@@ -227,36 +227,36 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @since 1.0
229 229
 	 */
230
-	protected function generate_listbox( $field ) {
230
+	protected function generate_listbox($field) {
231 231
 
232
-		$listbox = shortcode_atts( array(
232
+		$listbox = shortcode_atts(array(
233 233
 			'label'    => '',
234 234
 			'minWidth' => '',
235 235
 			'name'     => false,
236 236
 			'tooltip'  => '',
237 237
 			'type'     => '',
238 238
 			'value'    => '',
239
-		), $field );
239
+		), $field);
240 240
 
241
-		if ( $this->validate( $field ) ) {
241
+		if ($this->validate($field)) {
242 242
 
243 243
 			$new_listbox = array();
244 244
 
245
-			foreach ( $listbox as $key => $value ) {
245
+			foreach ($listbox as $key => $value) {
246 246
 
247
-				if ( $key == 'value' && empty( $value ) ) {
248
-					$new_listbox[ $key ] = $listbox['name'];
249
-				} else if ( $value ) {
250
-					$new_listbox[ $key ] = $value;
247
+				if ($key == 'value' && empty($value)) {
248
+					$new_listbox[$key] = $listbox['name'];
249
+				} else if ($value) {
250
+					$new_listbox[$key] = $value;
251 251
 				}
252 252
 			}
253 253
 
254 254
 			// do not reindex array!
255 255
 			$field['options'] = array(
256
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
256
+				                    '' => ($field['placeholder'] ? $field['placeholder'] : esc_attr__('- Select -', 'give')),
257 257
 			                    ) + $field['options'];
258 258
 
259
-			foreach ( $field['options'] as $value => $text ) {
259
+			foreach ($field['options'] as $value => $text) {
260 260
 				$new_listbox['values'][] = array(
261 261
 					'text'  => $text,
262 262
 					'value' => $value,
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @since 1.0
280 280
 	 */
281
-	protected function generate_post( $field ) {
281
+	protected function generate_post($field) {
282 282
 
283 283
 		$args = array(
284 284
 			'post_type'      => 'post',
@@ -287,23 +287,23 @@  discard block
 block discarded – undo
287 287
 			'posts_per_page' => 30,
288 288
 		);
289 289
 
290
-		$args    = wp_parse_args( (array) $field['query_args'], $args );
291
-		$posts   = get_posts( $args );
290
+		$args    = wp_parse_args((array) $field['query_args'], $args);
291
+		$posts   = get_posts($args);
292 292
 		$options = array();
293 293
 
294
-		if ( $posts ) {
295
-			foreach ( $posts as $post ) {
296
-				$options[ absint( $post->ID ) ] = $post->post_title;
294
+		if ($posts) {
295
+			foreach ($posts as $post) {
296
+				$options[absint($post->ID)] = $post->post_title;
297 297
 			}
298 298
 
299 299
 			$field['type']    = 'listbox';
300 300
 			$field['options'] = $options;
301 301
 
302
-			return $this->generate_listbox( $field );
302
+			return $this->generate_listbox($field);
303 303
 		}
304 304
 
305 305
 		// perform validation here before returning false
306
-		$this->validate( $field );
306
+		$this->validate($field);
307 307
 
308 308
 		return false;
309 309
 	}
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
 	 *
318 318
 	 * @since 1.0
319 319
 	 */
320
-	protected function generate_textbox( $field ) {
320
+	protected function generate_textbox($field) {
321 321
 
322
-		$textbox = shortcode_atts( array(
322
+		$textbox = shortcode_atts(array(
323 323
 			'label'     => '',
324 324
 			'maxLength' => '',
325 325
 			'minHeight' => '',
@@ -329,10 +329,10 @@  discard block
 block discarded – undo
329 329
 			'tooltip'   => '',
330 330
 			'type'      => '',
331 331
 			'value'     => '',
332
-		), $field );
332
+		), $field);
333 333
 
334
-		if ( $this->validate( $field ) ) {
335
-			return array_filter( $textbox, array( $this, 'return_textbox_value' ) );
334
+		if ($this->validate($field)) {
335
+			return array_filter($textbox, array($this, 'return_textbox_value'));
336 336
 		}
337 337
 
338 338
 		return false;
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * @return bool
347 347
 	 */
348
-	function return_textbox_value( $value ) {
348
+	function return_textbox_value($value) {
349 349
 		return $value !== '';
350 350
 	}
351 351
 
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
 	 *
362 362
 	 * @since 1.0
363 363
 	 */
364
-	protected function validate( $field ) {
364
+	protected function validate($field) {
365 365
 
366
-		extract( shortcode_atts(
366
+		extract(shortcode_atts(
367 367
 				array(
368 368
 					'name'     => false,
369 369
 					'required' => false,
@@ -371,36 +371,36 @@  discard block
 block discarded – undo
371 371
 				), $field )
372 372
 		);
373 373
 
374
-		if ( $name ) {
374
+		if ($name) {
375 375
 
376
-			if ( isset( $required['error'] ) ) {
376
+			if (isset($required['error'])) {
377 377
 
378 378
 				$error = array(
379 379
 					'type' => 'container',
380 380
 					'html' => $required['error'],
381 381
 				);
382 382
 
383
-				$this->errors[ $name ] = $this->generate_container( $error );
383
+				$this->errors[$name] = $this->generate_container($error);
384 384
 			}
385 385
 
386
-			if ( ! ! $required || is_array( $required ) ) {
386
+			if ( ! ! $required || is_array($required)) {
387 387
 
388
-				$alert = esc_html__( 'Some of the shortcode options are required.', 'give' );
388
+				$alert = esc_html__('Some of the shortcode options are required.', 'give');
389 389
 
390
-				if ( isset( $required['alert'] ) ) {
390
+				if (isset($required['alert'])) {
391 391
 
392 392
 					$alert = $required['alert'];
393 393
 
394
-				} else if ( ! empty( $label ) ) {
394
+				} else if ( ! empty($label)) {
395 395
 
396 396
 					$alert = sprintf(
397 397
 					/* translators: %s: option label */
398
-						esc_html__( 'The "%s" option is required.', 'give' ),
399
-						str_replace( ':', '', $label )
398
+						esc_html__('The "%s" option is required.', 'give'),
399
+						str_replace(':', '', $label)
400 400
 					);
401 401
 				}
402 402
 
403
-				$this->required[ $name ] = $alert;
403
+				$this->required[$name] = $alert;
404 404
 			}
405 405
 
406 406
 			return true;
Please login to merge, or discard this patch.
includes/admin/customers/customer-functions.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array        The altered list of views
25 25
  */
26
-function give_register_default_customer_views( $views ) {
26
+function give_register_default_customer_views($views) {
27 27
 
28 28
 	$default_views = array(
29 29
 		'overview' => 'give_customers_view',
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		'notes'    => 'give_customer_notes_view'
32 32
 	);
33 33
 
34
-	return array_merge( $views, $default_views );
34
+	return array_merge($views, $default_views);
35 35
 
36 36
 }
37 37
 
38
-add_filter( 'give_customer_views', 'give_register_default_customer_views', 1, 1 );
38
+add_filter('give_customer_views', 'give_register_default_customer_views', 1, 1);
39 39
 
40 40
 /**
41 41
  * Register a tab for the single customer view
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return array       The altered list of tabs
48 48
  */
49
-function give_register_default_customer_tabs( $tabs ) {
49
+function give_register_default_customer_tabs($tabs) {
50 50
 
51 51
 	$default_tabs = array(
52
-		'overview' => array( 'dashicon' => 'dashicons-admin-users', 'title' => esc_html__( 'Donor Profile', 'give' ) ),
53
-		'notes'    => array( 'dashicon' => 'dashicons-admin-comments', 'title' => esc_html__( 'Donor Notes', 'give' ) )
52
+		'overview' => array('dashicon' => 'dashicons-admin-users', 'title' => esc_html__('Donor Profile', 'give')),
53
+		'notes'    => array('dashicon' => 'dashicons-admin-comments', 'title' => esc_html__('Donor Notes', 'give'))
54 54
 	);
55 55
 
56
-	return array_merge( $tabs, $default_tabs );
56
+	return array_merge($tabs, $default_tabs);
57 57
 }
58 58
 
59
-add_filter( 'give_customer_tabs', 'give_register_default_customer_tabs', 1, 1 );
59
+add_filter('give_customer_tabs', 'give_register_default_customer_tabs', 1, 1);
60 60
 
61 61
 /**
62 62
  * Register the Delete icon as late as possible so it's at the bottom
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @return array       The altered list of tabs, with 'delete' at the bottom
69 69
  */
70
-function give_register_delete_customer_tab( $tabs ) {
70
+function give_register_delete_customer_tab($tabs) {
71 71
 
72
-	$tabs['delete'] = array( 'dashicon' => 'dashicons-trash', 'title' => esc_html__( 'Delete Donor', 'give' ) );
72
+	$tabs['delete'] = array('dashicon' => 'dashicons-trash', 'title' => esc_html__('Delete Donor', 'give'));
73 73
 
74 74
 	return $tabs;
75 75
 }
76 76
 
77
-add_filter( 'give_customer_tabs', 'give_register_delete_customer_tab', PHP_INT_MAX, 1 );
77
+add_filter('give_customer_tabs', 'give_register_delete_customer_tab', PHP_INT_MAX, 1);
Please login to merge, or discard this patch.
includes/class-give-cron.php 1 patch
Spacing   +9 added lines, -9 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
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	 * @see   Give_Cron::weekly_events()
30 30
 	 */
31 31
 	public function __construct() {
32
-		add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
33
-		add_action( 'wp', array( $this, 'schedule_Events' ) );
32
+		add_filter('cron_schedules', array($this, 'add_schedules'));
33
+		add_action('wp', array($this, 'schedule_Events'));
34 34
 	}
35 35
 
36 36
 	/**
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return array
44 44
 	 */
45
-	public function add_schedules( $schedules = array() ) {
45
+	public function add_schedules($schedules = array()) {
46 46
 		// Adds once weekly to the existing schedules.
47 47
 		$schedules['weekly'] = array(
48 48
 			'interval' => 604800,
49
-			'display'  => esc_html__( 'Once Weekly', 'give' )
49
+			'display'  => esc_html__('Once Weekly', 'give')
50 50
 		);
51 51
 
52 52
 		return $schedules;
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 * @return void
73 73
 	 */
74 74
 	private function weekly_events() {
75
-		if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) {
76
-			wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' );
75
+		if ( ! wp_next_scheduled('give_weekly_scheduled_events')) {
76
+			wp_schedule_event(current_time('timestamp'), 'weekly', 'give_weekly_scheduled_events');
77 77
 		}
78 78
 	}
79 79
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 * @return void
86 86
 	 */
87 87
 	private function daily_events() {
88
-		if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) {
89
-			wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' );
88
+		if ( ! wp_next_scheduled('give_daily_scheduled_events')) {
89
+			wp_schedule_event(current_time('timestamp'), 'daily', 'give_daily_scheduled_events');
90 90
 		}
91 91
 	}
92 92
 
Please login to merge, or discard this patch.
includes/ajax-functions.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -408,30 +408,30 @@
 block discarded – undo
408 408
 		die( '-2' );
409 409
 	}
410 410
 
411
-    if ( ! give_has_variable_prices( $form_id ) ) {
412
-        esc_html_e( 'n/a', 'give' );
413
-    } else {
414
-        // Payment object.
415
-        $payment = new Give_Payment( $payment_id );
416
-
417
-        // Payment meta.
418
-        $payment_meta = $payment->get_meta();
419
-
420
-
421
-        // Variable price dropdown options.
422
-        $variable_price_dropdown_option =  array(
423
-            'id'                => $form_id,
424
-            'name'              => 'give-variable-price',
425
-            'chosen'            => true,
426
-            'show_option_all'   => '',
427
-            'selected'          => $payment_meta['price_id'],
428
-        );
429
-
430
-        // Render variable prices select tag html.
431
-        give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
432
-    }
433
-
434
-    give_die();
411
+	if ( ! give_has_variable_prices( $form_id ) ) {
412
+		esc_html_e( 'n/a', 'give' );
413
+	} else {
414
+		// Payment object.
415
+		$payment = new Give_Payment( $payment_id );
416
+
417
+		// Payment meta.
418
+		$payment_meta = $payment->get_meta();
419
+
420
+
421
+		// Variable price dropdown options.
422
+		$variable_price_dropdown_option =  array(
423
+			'id'                => $form_id,
424
+			'name'              => 'give-variable-price',
425
+			'chosen'            => true,
426
+			'show_option_all'   => '',
427
+			'selected'          => $payment_meta['price_id'],
428
+		);
429
+
430
+		// Render variable prices select tag html.
431
+		give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
432
+	}
433
+
434
+	give_die();
435 435
 }
436 436
 
437 437
 add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 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
 
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
 function give_test_ajax_works() {
27 27
 
28 28
 	// Check if the Airplane Mode plugin is installed
29
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
29
+	if (class_exists('Airplane_Mode_Core')) {
30 30
 
31 31
 		$airplane = Airplane_Mode_Core::getInstance();
32 32
 
33
-		if ( method_exists( $airplane, 'enabled' ) ) {
33
+		if (method_exists($airplane, 'enabled')) {
34 34
 
35
-			if ( $airplane->enabled() ) {
35
+			if ($airplane->enabled()) {
36 36
 				return true;
37 37
 			}
38 38
 
39 39
 		} else {
40 40
 
41
-			if ( $airplane->check_status() == 'on' ) {
41
+			if ($airplane->check_status() == 'on') {
42 42
 				return true;
43 43
 			}
44 44
 		}
45 45
 	}
46 46
 
47
-	add_filter( 'block_local_requests', '__return_false' );
47
+	add_filter('block_local_requests', '__return_false');
48 48
 
49
-	if ( get_transient( '_give_ajax_works' ) ) {
49
+	if (get_transient('_give_ajax_works')) {
50 50
 		return true;
51 51
 	}
52 52
 
@@ -58,35 +58,35 @@  discard block
 block discarded – undo
58 58
 		)
59 59
 	);
60 60
 
61
-	$ajax  = wp_remote_post( give_get_ajax_url(), $params );
61
+	$ajax  = wp_remote_post(give_get_ajax_url(), $params);
62 62
 	$works = true;
63 63
 
64
-	if ( is_wp_error( $ajax ) ) {
64
+	if (is_wp_error($ajax)) {
65 65
 
66 66
 		$works = false;
67 67
 
68 68
 	} else {
69 69
 
70
-		if ( empty( $ajax['response'] ) ) {
70
+		if (empty($ajax['response'])) {
71 71
 			$works = false;
72 72
 		}
73 73
 
74
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
74
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
75 75
 			$works = false;
76 76
 		}
77 77
 
78
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
78
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79 79
 			$works = false;
80 80
 		}
81 81
 
82
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
82
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
83 83
 			$works = false;
84 84
 		}
85 85
 
86 86
 	}
87 87
 
88
-	if ( $works ) {
89
-		set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS );
88
+	if ($works) {
89
+		set_transient('_give_ajax_works', '1', DAY_IN_SECONDS);
90 90
 	}
91 91
 
92 92
 	return $works;
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
  * @return string
102 102
  */
103 103
 function give_get_ajax_url() {
104
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
104
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
105 105
 
106 106
 	$current_url = give_get_current_page_url();
107
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
107
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
108 108
 
109
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
110
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
109
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
110
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
111 111
 	}
112 112
 
113
-	return apply_filters( 'give_ajax_url', $ajax_url );
113
+	return apply_filters('give_ajax_url', $ajax_url);
114 114
 }
115 115
 
116 116
 /**
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @since 1.7
128 128
 	 */
129
-	do_action( 'give_donation_form_login_fields' );
129
+	do_action('give_donation_form_login_fields');
130 130
 
131 131
 	give_die();
132 132
 }
133 133
 
134
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
134
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
135 135
 
136 136
 /**
137 137
  * Load Checkout Fields
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
  * @return void
142 142
  */
143 143
 function give_load_checkout_fields() {
144
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
144
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
145 145
 
146 146
 	ob_start();
147 147
 
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @since 1.7
152 152
 	 */
153
-	do_action( 'give_donation_form_register_login_fields', $form_id );
153
+	do_action('give_donation_form_register_login_fields', $form_id);
154 154
 
155 155
 	$fields = ob_get_clean();
156 156
 
157
-	wp_send_json( array(
158
-		'fields' => wp_json_encode( $fields ),
159
-		'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ),
160
-	) );
157
+	wp_send_json(array(
158
+		'fields' => wp_json_encode($fields),
159
+		'submit' => wp_json_encode(give_checkout_button_purchase($form_id)),
160
+	));
161 161
 }
162 162
 
163
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
164
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
163
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
164
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
165 165
 
166 166
 /**
167 167
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
  * @return void
172 172
  */
173 173
 function give_ajax_get_form_title() {
174
-	if ( isset( $_POST['form_id'] ) ) {
175
-		$title = get_the_title( $_POST['form_id'] );
176
-		if ( $title ) {
174
+	if (isset($_POST['form_id'])) {
175
+		$title = get_the_title($_POST['form_id']);
176
+		if ($title) {
177 177
 			echo $title;
178 178
 		} else {
179 179
 			echo 'fail';
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 	give_die();
183 183
 }
184 184
 
185
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
186
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
185
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
186
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
187 187
 
188 188
 /**
189 189
  * Retrieve a states drop down
@@ -194,23 +194,23 @@  discard block
 block discarded – undo
194 194
  */
195 195
 function give_ajax_get_states_field() {
196 196
 
197
-	if ( empty( $_POST['country'] ) ) {
197
+	if (empty($_POST['country'])) {
198 198
 		$_POST['country'] = give_get_country();
199 199
 	}
200
-	$states = give_get_states( $_POST['country'] );
200
+	$states = give_get_states($_POST['country']);
201 201
 
202
-	if ( ! empty( $states ) ) {
202
+	if ( ! empty($states)) {
203 203
 
204 204
 		$args = array(
205 205
 			'name'             => $_POST['field_name'],
206 206
 			'id'               => $_POST['field_name'],
207
-			'class'            => $_POST['field_name'] . '  give-select',
208
-			'options'          => give_get_states( $_POST['country'] ),
207
+			'class'            => $_POST['field_name'].'  give-select',
208
+			'options'          => give_get_states($_POST['country']),
209 209
 			'show_option_all'  => false,
210 210
 			'show_option_none' => false
211 211
 		);
212 212
 
213
-		$response = Give()->html->select( $args );
213
+		$response = Give()->html->select($args);
214 214
 
215 215
 	} else {
216 216
 
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	give_die();
223 223
 }
224 224
 
225
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
226
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
225
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
226
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
227 227
 
228 228
 /**
229 229
  * Retrieve a states drop down
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 function give_ajax_form_search() {
236 236
 	global $wpdb;
237 237
 
238
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
238
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
239 239
 	$results = array();
240
-	if ( current_user_can( 'edit_give_forms' ) ) {
241
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
240
+	if (current_user_can('edit_give_forms')) {
241
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
242 242
 	} else {
243
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
243
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
244 244
 	}
245 245
 
246
-	if ( $items ) {
246
+	if ($items) {
247 247
 
248
-		foreach ( $items as $item ) {
248
+		foreach ($items as $item) {
249 249
 
250 250
 			$results[] = array(
251 251
 				'id'   => $item->ID,
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$items[] = array(
259 259
 			'id'   => 0,
260
-			'name' => esc_html__( 'No forms found.', 'give' )
260
+			'name' => esc_html__('No forms found.', 'give')
261 261
 		);
262 262
 
263 263
 	}
264 264
 
265
-	echo json_encode( $results );
265
+	echo json_encode($results);
266 266
 
267 267
 	give_die();
268 268
 }
269 269
 
270
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
271
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
270
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
271
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
272 272
 
273 273
 /**
274 274
  * Search the donors database via Ajax
@@ -280,21 +280,21 @@  discard block
 block discarded – undo
280 280
 function give_ajax_donor_search() {
281 281
 	global $wpdb;
282 282
 
283
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
283
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
284 284
 	$results = array();
285
-	if ( ! current_user_can( 'view_give_reports' ) ) {
285
+	if ( ! current_user_can('view_give_reports')) {
286 286
 		$donors = array();
287 287
 	} else {
288
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
288
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
289 289
 	}
290 290
 
291
-	if ( $donors ) {
291
+	if ($donors) {
292 292
 
293
-		foreach ( $donors as $donor ) {
293
+		foreach ($donors as $donor) {
294 294
 
295 295
 			$results[] = array(
296 296
 				'id'   => $donor->id,
297
-				'name' => $donor->name . '(' . $donor->email . ')'
297
+				'name' => $donor->name.'('.$donor->email.')'
298 298
 			);
299 299
 		}
300 300
 
@@ -302,17 +302,17 @@  discard block
 block discarded – undo
302 302
 
303 303
 		$donors[] = array(
304 304
 			'id'   => 0,
305
-			'name' => esc_html__( 'No donors found.', 'give' )
305
+			'name' => esc_html__('No donors found.', 'give')
306 306
 		);
307 307
 
308 308
 	}
309 309
 
310
-	echo json_encode( $results );
310
+	echo json_encode($results);
311 311
 
312 312
 	give_die();
313 313
 }
314 314
 
315
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
315
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
316 316
 
317 317
 
318 318
 /**
@@ -324,42 +324,42 @@  discard block
 block discarded – undo
324 324
  */
325 325
 function give_ajax_search_users() {
326 326
 
327
-	if ( current_user_can( 'manage_give_settings' ) ) {
327
+	if (current_user_can('manage_give_settings')) {
328 328
 
329
-		$search_query = trim( $_POST['user_name'] );
330
-		$exclude      = trim( $_POST['exclude'] );
329
+		$search_query = trim($_POST['user_name']);
330
+		$exclude      = trim($_POST['exclude']);
331 331
 
332 332
 		$get_users_args = array(
333 333
 			'number' => 9999,
334
-			'search' => $search_query . '*'
334
+			'search' => $search_query.'*'
335 335
 		);
336 336
 
337
-		if ( ! empty( $exclude ) ) {
338
-			$exclude_array             = explode( ',', $exclude );
337
+		if ( ! empty($exclude)) {
338
+			$exclude_array             = explode(',', $exclude);
339 339
 			$get_users_args['exclude'] = $exclude_array;
340 340
 		}
341 341
 
342
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
342
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
343 343
 
344
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query );
344
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query);
345 345
 
346 346
 		$user_list = '<ul>';
347
-		if ( $found_users ) {
348
-			foreach ( $found_users as $user ) {
349
-				$user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>';
347
+		if ($found_users) {
348
+			foreach ($found_users as $user) {
349
+				$user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>';
350 350
 			}
351 351
 		} else {
352
-			$user_list .= '<li>' . esc_html__( 'No users found.', 'give' ) . '</li>';
352
+			$user_list .= '<li>'.esc_html__('No users found.', 'give').'</li>';
353 353
 		}
354 354
 		$user_list .= '</ul>';
355 355
 
356
-		echo json_encode( array( 'results' => $user_list ) );
356
+		echo json_encode(array('results' => $user_list));
357 357
 
358 358
 	}
359 359
 	die();
360 360
 }
361 361
 
362
-add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' );
362
+add_action('wp_ajax_give_search_users', 'give_ajax_search_users');
363 363
 
364 364
 
365 365
 /**
@@ -371,32 +371,32 @@  discard block
 block discarded – undo
371 371
  */
372 372
 function give_check_for_form_price_variations() {
373 373
 
374
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
375
-		die( '-1' );
374
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
375
+		die('-1');
376 376
 	}
377 377
 
378
-	$form_id = intval( $_POST['form_id'] );
379
-	$form    = get_post( $form_id );
378
+	$form_id = intval($_POST['form_id']);
379
+	$form    = get_post($form_id);
380 380
 
381
-	if ( 'give_forms' != $form->post_type ) {
382
-		die( '-2' );
381
+	if ('give_forms' != $form->post_type) {
382
+		die('-2');
383 383
 	}
384 384
 
385
-	if ( give_has_variable_prices( $form_id ) ) {
386
-		$variable_prices = give_get_variable_prices( $form_id );
385
+	if (give_has_variable_prices($form_id)) {
386
+		$variable_prices = give_get_variable_prices($form_id);
387 387
 
388
-		if ( $variable_prices ) {
388
+		if ($variable_prices) {
389 389
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
390 390
 
391
-			if ( isset( $_POST['all_prices'] ) ) {
392
-				$ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>';
391
+			if (isset($_POST['all_prices'])) {
392
+				$ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>';
393 393
 			}
394 394
 
395
-			foreach ( $variable_prices as $key => $price ) {
395
+			foreach ($variable_prices as $key => $price) {
396 396
 
397
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) );
397
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
398 398
 				
399
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
399
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
400 400
 			}
401 401
 			$ajax_response .= '</select>';
402 402
 			echo $ajax_response;
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	give_die();
408 408
 }
409 409
 
410
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
410
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
411 411
 
412 412
 
413 413
 /**
@@ -418,30 +418,30 @@  discard block
 block discarded – undo
418 418
  * @return void
419 419
  */
420 420
 function give_check_for_form_price_variations_html() {
421
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
421
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
422 422
 		wp_die();
423 423
 	}
424 424
 
425
-	$form_id = intval( $_POST['form_id'] );
426
-	$payment_id = intval( $_POST['payment_id'] );
427
-	$form    = get_post( $form_id );
425
+	$form_id = intval($_POST['form_id']);
426
+	$payment_id = intval($_POST['payment_id']);
427
+	$form    = get_post($form_id);
428 428
 
429
-	if ( 'give_forms' != $form->post_type ) {
429
+	if ('give_forms' != $form->post_type) {
430 430
 		wp_die();
431 431
 	}
432 432
 
433
-    if ( ! give_has_variable_prices( $form_id ) ) {
434
-        esc_html_e( 'n/a', 'give' );
433
+    if ( ! give_has_variable_prices($form_id)) {
434
+        esc_html_e('n/a', 'give');
435 435
     } else {
436 436
         // Payment object.
437
-        $payment = new Give_Payment( $payment_id );
437
+        $payment = new Give_Payment($payment_id);
438 438
 
439 439
         // Payment meta.
440 440
         $payment_meta = $payment->get_meta();
441 441
 
442 442
 
443 443
         // Variable price dropdown options.
444
-        $variable_price_dropdown_option =  array(
444
+        $variable_price_dropdown_option = array(
445 445
             'id'                => $form_id,
446 446
             'name'              => 'give-variable-price',
447 447
             'chosen'            => true,
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
         );
451 451
 
452 452
         // Render variable prices select tag html.
453
-        give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
453
+        give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
454 454
     }
455 455
 
456 456
     give_die();
457 457
 }
458 458
 
459
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
459
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
Please login to merge, or discard this patch.
includes/class-give-db-customer-meta.php 1 patch
Spacing   +25 added lines, -25 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
 
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		/* @var WPDB $wpdb */
32 32
 		global $wpdb;
33 33
 
34
-		$this->table_name  = $wpdb->prefix . 'give_customermeta';
34
+		$this->table_name  = $wpdb->prefix.'give_customermeta';
35 35
 		$this->primary_key = 'meta_id';
36 36
 		$this->version     = '1.0';
37 37
 
38
-		add_action( 'plugins_loaded', array( $this, 'register_table' ), 11 );
38
+		add_action('plugins_loaded', array($this, 'register_table'), 11);
39 39
 
40 40
 	}
41 41
 
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 	 * @access  private
80 80
 	 * @since   1.6
81 81
 	 */
82
-	public function get_meta( $customer_id = 0, $meta_key = '', $single = false ) {
83
-		$customer_id = $this->sanitize_customer_id( $customer_id );
84
-		if ( false === $customer_id ) {
82
+	public function get_meta($customer_id = 0, $meta_key = '', $single = false) {
83
+		$customer_id = $this->sanitize_customer_id($customer_id);
84
+		if (false === $customer_id) {
85 85
 			return false;
86 86
 		}
87 87
 
88
-		return get_metadata( 'customer', $customer_id, $meta_key, $single );
88
+		return get_metadata('customer', $customer_id, $meta_key, $single);
89 89
 	}
90 90
 
91 91
 	/**
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 	 * @access  private
104 104
 	 * @since   1.6
105 105
 	 */
106
-	public function add_meta( $customer_id = 0, $meta_key = '', $meta_value, $unique = false ) {
107
-		$customer_id = $this->sanitize_customer_id( $customer_id );
108
-		if ( false === $customer_id ) {
106
+	public function add_meta($customer_id = 0, $meta_key = '', $meta_value, $unique = false) {
107
+		$customer_id = $this->sanitize_customer_id($customer_id);
108
+		if (false === $customer_id) {
109 109
 			return false;
110 110
 		}
111 111
 
112
-		return add_metadata( 'customer', $customer_id, $meta_key, $meta_value, $unique );
112
+		return add_metadata('customer', $customer_id, $meta_key, $meta_value, $unique);
113 113
 	}
114 114
 
115 115
 	/**
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
 	 * @access  private
133 133
 	 * @since   1.6
134 134
 	 */
135
-	public function update_meta( $customer_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) {
136
-		$customer_id = $this->sanitize_customer_id( $customer_id );
137
-		if ( false === $customer_id ) {
135
+	public function update_meta($customer_id = 0, $meta_key = '', $meta_value, $prev_value = '') {
136
+		$customer_id = $this->sanitize_customer_id($customer_id);
137
+		if (false === $customer_id) {
138 138
 			return false;
139 139
 		}
140 140
 
141
-		return update_metadata( 'customer', $customer_id, $meta_key, $meta_value, $prev_value );
141
+		return update_metadata('customer', $customer_id, $meta_key, $meta_value, $prev_value);
142 142
 	}
143 143
 
144 144
 	/**
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 * @access  private
160 160
 	 * @since   1.6
161 161
 	 */
162
-	public function delete_meta( $customer_id = 0, $meta_key = '', $meta_value = '' ) {
163
-		return delete_metadata( 'customer', $customer_id, $meta_key, $meta_value );
162
+	public function delete_meta($customer_id = 0, $meta_key = '', $meta_value = '') {
163
+		return delete_metadata('customer', $customer_id, $meta_key, $meta_value);
164 164
 	}
165 165
 
166 166
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	public function create_table() {
173 173
 
174
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
174
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
175 175
 
176 176
 		$sql = "CREATE TABLE {$this->table_name} (
177 177
 			meta_id bigint(20) NOT NULL AUTO_INCREMENT,
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 			KEY meta_key (meta_key)
184 184
 			) CHARACTER SET utf8 COLLATE utf8_general_ci;";
185 185
 
186
-		dbDelta( $sql );
186
+		dbDelta($sql);
187 187
 
188
-		update_option( $this->table_name . '_db_version', $this->version );
188
+		update_option($this->table_name.'_db_version', $this->version);
189 189
 	}
190 190
 
191 191
 	/**
@@ -197,23 +197,23 @@  discard block
 block discarded – undo
197 197
 	 *
198 198
 	 * @return int|bool                The normalized customer ID or false if it's found to not be valid.
199 199
 	 */
200
-	private function sanitize_customer_id( $customer_id ) {
201
-		if ( ! is_numeric( $customer_id ) ) {
200
+	private function sanitize_customer_id($customer_id) {
201
+		if ( ! is_numeric($customer_id)) {
202 202
 			return false;
203 203
 		}
204 204
 
205 205
 		$customer_id = (int) $customer_id;
206 206
 
207 207
 		// We were given a non positive number
208
-		if ( absint( $customer_id ) !== $customer_id ) {
208
+		if (absint($customer_id) !== $customer_id) {
209 209
 			return false;
210 210
 		}
211 211
 
212
-		if ( empty( $customer_id ) ) {
212
+		if (empty($customer_id)) {
213 213
 			return false;
214 214
 		}
215 215
 
216
-		return absint( $customer_id );
216
+		return absint($customer_id);
217 217
 
218 218
 	}
219 219
 
Please login to merge, or discard this patch.