Test Failed
Pull Request — master (#3647)
by Ravinder
10:22
created
includes/class-give-db-sessions.php 1 patch
Spacing   +18 added lines, -18 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
 
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 		// Set cache group id.
55 55
 		$current_blog_id        = get_current_blog_id();
56 56
 		$this->incrementer_name = "give-cache-incrementer-sessions-{$current_blog_id}";
57
-		$incrementer_value      = wp_cache_get( $this->incrementer_name );
58
-		$incrementer_value      = ! empty( $incrementer_value ) ? $incrementer_value : microtime( true );
57
+		$incrementer_value      = wp_cache_get($this->incrementer_name);
58
+		$incrementer_value      = ! empty($incrementer_value) ? $incrementer_value : microtime(true);
59 59
 		$this->cache_group      = "{$this->cache_group}_{$current_blog_id}_{$incrementer_value}";
60 60
 
61 61
 		$this->register_table();
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
   				UNIQUE KEY session_id (session_id)
102 102
 			) {$charset_collate};";
103 103
 
104
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
105
-		dbDelta( $sql );
104
+		require_once ABSPATH.'wp-admin/includes/upgrade.php';
105
+		dbDelta($sql);
106 106
 
107
-		update_option( $this->table_name . '_db_version', $this->version, false );
107
+		update_option($this->table_name.'_db_version', $this->version, false);
108 108
 	}
109 109
 
110 110
 
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return mixed
120 120
 	 */
121
-	public function get_session( $donor_id, $default = false ) {
121
+	public function get_session($donor_id, $default = false) {
122 122
 		global $wpdb;
123 123
 
124
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
124
+		if (defined('WP_SETUP_CONFIG')) {
125 125
 			return false;
126 126
 		}
127 127
 
128
-		if ( ! ( $value = wp_cache_get( $donor_id, $this->cache_group ) ) ) { // @codingStandardsIgnoreLine
128
+		if ( ! ($value = wp_cache_get($donor_id, $this->cache_group))) { // @codingStandardsIgnoreLine
129 129
 
130 130
 			// @codingStandardsIgnoreStart
131 131
 			$value = $wpdb->get_var(
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
 			);
141 141
 			// @codingStandardsIgnoreEnd
142 142
 
143
-			if ( is_null( $value ) ) {
143
+			if (is_null($value)) {
144 144
 				$value = $default;
145 145
 			}
146 146
 
147
-			wp_cache_add( $donor_id, $value, $this->cache_group );
147
+			wp_cache_add($donor_id, $value, $this->cache_group);
148 148
 		}
149 149
 
150
-		return maybe_unserialize( $value );
150
+		return maybe_unserialize($value);
151 151
 	}
152 152
 
153 153
 	/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param string $donor_id  Donor ID.
157 157
 	 * @param int    $timestamp Timestamp to expire the cookie.
158 158
 	 */
159
-	public function update_session_timestamp( $donor_id, $timestamp ) {
159
+	public function update_session_timestamp($donor_id, $timestamp) {
160 160
 		global $wpdb;
161 161
 
162 162
 		// @codingStandardsIgnoreStart.
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @param int $donor_id Customer ID.
185 185
 	 */
186
-	public function delete_session( $donor_id ) {
186
+	public function delete_session($donor_id) {
187 187
 		global $wpdb;
188 188
 
189
-		wp_cache_delete( $donor_id, $this->cache_group );
189
+		wp_cache_delete($donor_id, $this->cache_group);
190 190
 
191 191
 		// @codingStandardsIgnoreStart
192 192
 		$wpdb->delete(
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	public function delete_expired_sessions() {
210 210
 		global $wpdb;
211 211
 
212
-		wp_cache_set( $this->incrementer_name, microtime( true ) );
212
+		wp_cache_set($this->incrementer_name, microtime(true));
213 213
 
214 214
 		// @codingStandardsIgnoreStart
215 215
 		$wpdb->query(
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
 	 * @param array  $data       Data.
233 233
 	 * @param array  $format     Array for data format of each key:value in data.
234 234
 	 */
235
-	public function __replace( $table_name, $data, $format = null ) {
235
+	public function __replace($table_name, $data, $format = null) {
236 236
 		global $wpdb;
237 237
 
238
-		wp_cache_set( $data['session_key'], $data['session_value'], $this->cache_group, $data['session_expiry'] - time() );
238
+		wp_cache_set($data['session_key'], $data['session_value'], $this->cache_group, $data['session_expiry'] - time());
239 239
 
240 240
 
241 241
 		// @codingStandardsIgnoreStart
Please login to merge, or discard this patch.
includes/class-give-session.php 1 patch
Spacing   +67 added lines, -67 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
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return Give_Session
136 136
 	 */
137 137
 	public static function get_instance() {
138
-		if ( null === static::$instance ) {
138
+		if (null === static::$instance) {
139 139
 			self::$instance = new static();
140 140
 			self::$instance->__setup();
141 141
 		}
@@ -150,25 +150,25 @@  discard block
 block discarded – undo
150 150
 	 * @access public
151 151
 	 */
152 152
 	private function __setup() {  // @codingStandardsIgnoreLine
153
-		$this->exp_option = give_get_option( 'session_lifetime' );
154
-		$this->exp_option = ! empty( $this->exp_option )
153
+		$this->exp_option = give_get_option('session_lifetime');
154
+		$this->exp_option = ! empty($this->exp_option)
155 155
 			? $this->exp_option
156 156
 			: 30 * 60 * 24; // Default expiration time is 12 hours
157 157
 
158 158
 		$this->set_cookie_name();
159
-		$this->cookie_name = $this->get_cookie_name( 'session' );
159
+		$this->cookie_name = $this->get_cookie_name('session');
160 160
 		$cookie            = $this->get_session_cookie();
161 161
 
162
-		if ( ! empty( $cookie ) ) {
162
+		if ( ! empty($cookie)) {
163 163
 			$this->donor_id           = $cookie[0];
164 164
 			$this->session_expiration = $cookie[1];
165 165
 			$this->session_expiring   = $cookie[2];
166 166
 			$this->has_cookie         = true;
167 167
 
168 168
 			// Update session if its close to expiring.
169
-			if ( time() > $this->session_expiring ) {
169
+			if (time() > $this->session_expiring) {
170 170
 				$this->set_expiration_time();
171
-				Give()->session_db->update_session_timestamp( $this->donor_id, $this->session_expiration );
171
+				Give()->session_db->update_session_timestamp($this->donor_id, $this->session_expiration);
172 172
 			}
173 173
 
174 174
 			// Load session.
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 			$this->generate_donor_id();
179 179
 		}
180 180
 
181
-		add_action( 'give_process_donation_after_validation', array( $this, 'maybe_start_session' ) );
181
+		add_action('give_process_donation_after_validation', array($this, 'maybe_start_session'));
182 182
 
183
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
184
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
183
+		add_action('shutdown', array($this, 'save_data'), 20);
184
+		add_action('wp_logout', array($this, 'destroy_session'));
185 185
 
186
-		if ( ! is_user_logged_in() ) {
187
-			add_filter( 'nonce_user_logged_out', array( $this, '__nonce_user_logged_out' ) );
186
+		if ( ! is_user_logged_in()) {
187
+			add_filter('nonce_user_logged_out', array($this, '__nonce_user_logged_out'));
188 188
 		}
189 189
 
190 190
 		// Remove old sessions.
191
-		Give_Cron::add_daily_event( array( $this, '__cleanup_sessions' ) );
191
+		Give_Cron::add_daily_event(array($this, '__cleanup_sessions'));
192 192
 	}
193 193
 
194 194
 	/**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @return array
201 201
 	 */
202 202
 	public function get_session_data() {
203
-		return $this->has_session() ? (array) Give()->session_db->get_session( $this->donor_id, array() ) : array();
203
+		return $this->has_session() ? (array) Give()->session_db->get_session($this->donor_id, array()) : array();
204 204
 	}
205 205
 
206 206
 
@@ -214,27 +214,27 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function get_session_cookie() {
216 216
 		$session      = array();
217
-		$cookie_value = isset( $_COOKIE[ $this->cookie_name ] ) ? give_clean( $_COOKIE[ $this->cookie_name ] ) : false; // @codingStandardsIgnoreLine.
217
+		$cookie_value = isset($_COOKIE[$this->cookie_name]) ? give_clean($_COOKIE[$this->cookie_name]) : false; // @codingStandardsIgnoreLine.
218 218
 
219
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
219
+		if (empty($cookie_value) || ! is_string($cookie_value)) {
220 220
 			return $session;
221 221
 		}
222 222
 
223
-		list( $donor_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
223
+		list($donor_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value);
224 224
 
225
-		if ( empty( $donor_id ) ) {
225
+		if (empty($donor_id)) {
226 226
 			return $session;
227 227
 		}
228 228
 
229 229
 		// Validate hash.
230
-		$to_hash = $donor_id . '|' . $session_expiration;
231
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
230
+		$to_hash = $donor_id.'|'.$session_expiration;
231
+		$hash    = hash_hmac('md5', $to_hash, wp_hash($to_hash));
232 232
 
233
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
233
+		if (empty($cookie_hash) || ! hash_equals($hash, $cookie_hash)) {
234 234
 			return $session;
235 235
 		}
236 236
 
237
-		return array( $donor_id, $session_expiration, $session_expiring, $cookie_hash );
237
+		return array($donor_id, $session_expiration, $session_expiring, $cookie_hash);
238 238
 	}
239 239
 
240 240
 
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @return string Cookie name.
260 260
 	 */
261 261
 	private function set_cookie_name() {
262
-		$this->cookie_name       = apply_filters( 'give_session_cookie', 'wp_give_session_' . COOKIEHASH );
263
-		$this->nonce_cookie_name = 'wp_give_session_reset_nonce_' . COOKIEHASH;
262
+		$this->cookie_name       = apply_filters('give_session_cookie', 'wp_give_session_'.COOKIEHASH);
263
+		$this->nonce_cookie_name = 'wp_give_session_reset_nonce_'.COOKIEHASH;
264 264
 	}
265 265
 
266 266
 	/**
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return string|array      Session variable.
278 278
 	 */
279
-	public function get( $key, $default = false ) {
280
-		$key = sanitize_key( $key );
279
+	public function get($key, $default = false) {
280
+		$key = sanitize_key($key);
281 281
 
282
-		return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : $default;
282
+		return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : $default;
283 283
 	}
284 284
 
285 285
 	/**
@@ -293,13 +293,13 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return string        Session variable.
295 295
 	 */
296
-	public function set( $key, $value ) {
297
-		if ( $value !== $this->get( $key ) ) {
298
-			$this->session[ sanitize_key( $key ) ] = maybe_serialize( $value );
296
+	public function set($key, $value) {
297
+		if ($value !== $this->get($key)) {
298
+			$this->session[sanitize_key($key)] = maybe_serialize($value);
299 299
 			$this->session_data_changed            = true;
300 300
 		}
301 301
 
302
-		return $this->session[ $key ];
302
+		return $this->session[$key];
303 303
 	}
304 304
 
305 305
 	/**
@@ -313,17 +313,17 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @param bool $set Flag to check if set cookie or not.
315 315
 	 */
316
-	public function set_session_cookies( $set ) {
317
-		if ( $set ) {
316
+	public function set_session_cookies($set) {
317
+		if ($set) {
318 318
 			$this->set_expiration_time();
319 319
 
320
-			$to_hash          = $this->donor_id . '|' . $this->session_expiration;
321
-			$cookie_hash      = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
322
-			$cookie_value     = $this->donor_id . '||' . $this->session_expiration . '||' . $this->session_expiring . '||' . $cookie_hash;
320
+			$to_hash          = $this->donor_id.'|'.$this->session_expiration;
321
+			$cookie_hash      = hash_hmac('md5', $to_hash, wp_hash($to_hash));
322
+			$cookie_value     = $this->donor_id.'||'.$this->session_expiration.'||'.$this->session_expiring.'||'.$cookie_hash;
323 323
 			$this->has_cookie = true;
324 324
 
325
-			give_setcookie( $this->cookie_name, $cookie_value, $this->session_expiration, apply_filters( 'give_session_use_secure_cookie', false ) );
326
-			give_setcookie( $this->nonce_cookie_name, '1', $this->session_expiration, apply_filters( 'give_session_use_secure_cookie', false ) );
325
+			give_setcookie($this->cookie_name, $cookie_value, $this->session_expiration, apply_filters('give_session_use_secure_cookie', false));
326
+			give_setcookie($this->nonce_cookie_name, '1', $this->session_expiration, apply_filters('give_session_use_secure_cookie', false));
327 327
 		}
328 328
 	}
329 329
 
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 	 * @return int
339 339
 	 */
340 340
 	public function set_expiration_time() {
341
-		$this->session_expiring   = time() + intval( apply_filters( 'give_session_expiring', ( $this->exp_option - 3600 ) ) ); // Default 11 Hours.
342
-		$this->session_expiration = time() + intval( apply_filters( 'give_session_expiration', $this->exp_option ) ); // Default 12 Hours.
341
+		$this->session_expiring   = time() + intval(apply_filters('give_session_expiring', ($this->exp_option - 3600))); // Default 11 Hours.
342
+		$this->session_expiration = time() + intval(apply_filters('give_session_expiration', $this->exp_option)); // Default 12 Hours.
343 343
 
344 344
 		return $this->session_expiration;
345 345
 	}
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
 	public function maybe_start_session() {
372 372
 		if (
373 373
 			! headers_sent()
374
-			&& empty( $this->session )
374
+			&& empty($this->session)
375 375
 			&& ! $this->has_cookie
376 376
 		) {
377
-			$this->set_session_cookies( true );
377
+			$this->set_session_cookies(true);
378 378
 		}
379 379
 	}
380 380
 
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
 	 * @access public
388 388
 	 */
389 389
 	public function generate_donor_id() {
390
-		require_once ABSPATH . 'wp-includes/class-phpass.php';
390
+		require_once ABSPATH.'wp-includes/class-phpass.php';
391 391
 
392
-		$hasher         = new PasswordHash( 8, false );
393
-		$this->donor_id = md5( $hasher->get_random_bytes( 32 ) );
392
+		$hasher         = new PasswordHash(8, false);
393
+		$this->donor_id = md5($hasher->get_random_bytes(32));
394 394
 	}
395 395
 
396 396
 	/**
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
 	 */
402 402
 	public function save_data() {
403 403
 		// Dirty if something changed - prevents saving nothing new.
404
-		if ( $this->session_data_changed && $this->has_session() ) {
404
+		if ($this->session_data_changed && $this->has_session()) {
405 405
 			global $wpdb;
406 406
 
407 407
 			Give()->session_db->__replace(
408 408
 				Give()->session_db->table_name,
409 409
 				array(
410 410
 					'session_key'    => $this->donor_id,
411
-					'session_value'  => maybe_serialize( $this->session ),
411
+					'session_value'  => maybe_serialize($this->session),
412 412
 					'session_expiry' => $this->session_expiration,
413 413
 				),
414 414
 				array(
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
 	 * @access public
430 430
 	 */
431 431
 	public function destroy_session() {
432
-		give_setcookie( $this->cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters( 'give_session_use_secure_cookie', false ) );
433
-		give_setcookie( $this->nonce_cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters( 'give_session_use_secure_cookie', false ) );
432
+		give_setcookie($this->cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters('give_session_use_secure_cookie', false));
433
+		give_setcookie($this->nonce_cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters('give_session_use_secure_cookie', false));
434 434
 
435
-		Give()->session_db->delete_session( $this->donor_id );
435
+		Give()->session_db->delete_session($this->donor_id);
436 436
 
437 437
 		$this->session              = array();
438 438
 		$this->session_data_changed = false;
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @return bool
450 450
 	 */
451
-	public function is_delete_nonce_cookie(){
451
+	public function is_delete_nonce_cookie() {
452 452
 		$value = false;
453 453
 
454
-		if ( Give()->session->has_session() ) {
454
+		if (Give()->session->has_session()) {
455 455
 			$value = true;
456 456
 		}
457 457
 
@@ -468,10 +468,10 @@  discard block
 block discarded – undo
468 468
 	 *
469 469
 	 * @return string Cookie name
470 470
 	 */
471
-	public function get_cookie_name( $type = '' ) {
471
+	public function get_cookie_name($type = '') {
472 472
 		$name = '';
473 473
 
474
-		switch ( $type ) {
474
+		switch ($type) {
475 475
 			case 'nonce':
476 476
 				$name = $this->nonce_cookie_name;
477 477
 				break;
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	 *
496 496
 	 * @return string
497 497
 	 */
498
-	public function __nonce_user_logged_out( $uid ) {
498
+	public function __nonce_user_logged_out($uid) {
499 499
 		return $this->has_session() && $this->donor_id ? $this->donor_id : $uid;
500 500
 	}
501 501
 
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 	 */
542 542
 	public function set_expiration_variant_time() {
543 543
 
544
-		return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 );
544
+		return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23);
545 545
 	}
546 546
 
547 547
 	/**
@@ -558,9 +558,9 @@  discard block
 block discarded – undo
558 558
 	public function use_php_sessions() {
559 559
 		$ret = false;
560 560
 
561
-		give_doing_it_wrong( __FUNCTION__, __( 'We are using database session logic instead of PHP session', 'give' ), '2.2.0' );
561
+		give_doing_it_wrong(__FUNCTION__, __('We are using database session logic instead of PHP session', 'give'), '2.2.0');
562 562
 
563
-		return (bool) apply_filters( 'give_use_php_sessions', $ret );
563
+		return (bool) apply_filters('give_use_php_sessions', $ret);
564 564
 	}
565 565
 
566 566
 	/**
@@ -578,10 +578,10 @@  discard block
 block discarded – undo
578 578
 
579 579
 		$start_session = true;
580 580
 
581
-		give_doing_it_wrong( __FUNCTION__, __( 'We are using database session logic instead of PHP session', 'give' ), '2.2.0' );
581
+		give_doing_it_wrong(__FUNCTION__, __('We are using database session logic instead of PHP session', 'give'), '2.2.0');
582 582
 
583 583
 
584
-		if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {  // @codingStandardsIgnoreLine
584
+		if ( ! empty($_SERVER['REQUEST_URI'])) {  // @codingStandardsIgnoreLine
585 585
 
586 586
 			$blacklist = apply_filters(
587 587
 				'give_session_start_uri_blacklist', array(
@@ -594,19 +594,19 @@  discard block
 block discarded – undo
594 594
 					'comments/feed/',
595 595
 				)
596 596
 			);
597
-			$uri       = ltrim( $_SERVER['REQUEST_URI'], '/' ); // // @codingStandardsIgnoreLine
598
-			$uri       = untrailingslashit( $uri );
599
-			if ( in_array( $uri, $blacklist, true ) ) {
597
+			$uri       = ltrim($_SERVER['REQUEST_URI'], '/'); // // @codingStandardsIgnoreLine
598
+			$uri       = untrailingslashit($uri);
599
+			if (in_array($uri, $blacklist, true)) {
600 600
 				$start_session = false;
601 601
 			}
602
-			if ( false !== strpos( $uri, 'feed=' ) ) {
602
+			if (false !== strpos($uri, 'feed=')) {
603 603
 				$start_session = false;
604 604
 			}
605
-			if ( is_admin() ) {
605
+			if (is_admin()) {
606 606
 				$start_session = false;
607 607
 			}
608 608
 		}
609 609
 
610
-		return apply_filters( 'give_start_session', $start_session );
610
+		return apply_filters('give_start_session', $start_session);
611 611
 	}
612 612
 }
Please login to merge, or discard this patch.
includes/class-give-db-logs.php 1 patch
Spacing   +71 added lines, -73 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_logs';
38
+		$this->table_name  = $wpdb->prefix.'give_logs';
39 39
 		$this->primary_key = 'ID';
40 40
 		$this->version     = '1.0';
41 41
 
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 * @return array  Default column values.
75 75
 	 */
76 76
 	public function get_column_defaults() {
77
-		$log_create_date     = current_time( 'mysql', 0 );
78
-		$log_create_date_gmt = get_gmt_from_date( $log_create_date );
77
+		$log_create_date     = current_time('mysql', 0);
78
+		$log_create_date_gmt = get_gmt_from_date($log_create_date);
79 79
 
80 80
 		return array(
81 81
 			'ID'           => 0,
@@ -98,39 +98,39 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return bool|int
100 100
 	 */
101
-	public function add( $data = array() ) {
101
+	public function add($data = array()) {
102 102
 		// Valid table columns.
103
-		$table_columns = array_keys( $this->get_columns() );
103
+		$table_columns = array_keys($this->get_columns());
104 104
 
105 105
 		// Filter data.
106
-		foreach ( $data as $table_column => $column_data ) {
107
-			if ( ! in_array( $table_column, $table_columns ) ) {
108
-				unset( $data[ $table_column ] );
106
+		foreach ($data as $table_column => $column_data) {
107
+			if ( ! in_array($table_column, $table_columns)) {
108
+				unset($data[$table_column]);
109 109
 			}
110 110
 		}
111 111
 
112 112
 		// Set default values.
113
-		$current_log_data = wp_parse_args( $data, $this->get_column_defaults() );
113
+		$current_log_data = wp_parse_args($data, $this->get_column_defaults());
114 114
 
115 115
 		// Log parent should be an int.
116
-		$current_log_data['log_parent'] = absint( $current_log_data['log_parent'] );
116
+		$current_log_data['log_parent'] = absint($current_log_data['log_parent']);
117 117
 
118 118
 		// Get log.
119
-		$existing_log = $this->get_log_by( $current_log_data['ID'] );
119
+		$existing_log = $this->get_log_by($current_log_data['ID']);
120 120
 
121 121
 		// Update an existing log.
122
-		if ( $existing_log ) {
122
+		if ($existing_log) {
123 123
 
124 124
 			// Create new log data from existing and new log data.
125
-			$current_log_data = array_merge( $current_log_data, $existing_log );
125
+			$current_log_data = array_merge($current_log_data, $existing_log);
126 126
 
127 127
 			// Update log data.
128
-			$this->update( $current_log_data['ID'], $current_log_data );
128
+			$this->update($current_log_data['ID'], $current_log_data);
129 129
 
130 130
 			$log_id = $current_log_data['ID'];
131 131
 
132 132
 		} else {
133
-			$log_id = $this->insert( $current_log_data, 'log' );
133
+			$log_id = $this->insert($current_log_data, 'log');
134 134
 		}
135 135
 
136 136
 		return $log_id;
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return bool|null|array
150 150
 	 */
151
-	public function get_log_by( $log_id = 0, $by = 'id' ) {
151
+	public function get_log_by($log_id = 0, $by = 'id') {
152 152
 		/* @var WPDB $wpdb */
153 153
 		global $wpdb;
154 154
 		$log = null;
155 155
 
156 156
 		// Make sure $log_id is int.
157
-		$log_id = absint( $log_id );
157
+		$log_id = absint($log_id);
158 158
 
159 159
 		// Bailout.
160
-		if ( empty( $log_id ) ) {
160
+		if (empty($log_id)) {
161 161
 			return null;
162 162
 		}
163 163
 
164
-		switch ( $by ) {
164
+		switch ($by) {
165 165
 			case 'id':
166 166
 				$log = $wpdb->get_row(
167 167
 					$wpdb->prepare(
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 				break;
174 174
 
175 175
 			default:
176
-				$log = apply_filters( "give_get_log_by_{$by}", $log, $log_id );
176
+				$log = apply_filters("give_get_log_by_{$by}", $log, $log_id);
177 177
 		}
178 178
 
179 179
 		return $log;
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return mixed
191 191
 	 */
192
-	public function get_logs( $args = array() ) {
192
+	public function get_logs($args = array()) {
193 193
 		global $wpdb;
194
-		$sql_query = $this->get_sql( $args );
194
+		$sql_query = $this->get_sql($args);
195 195
 
196 196
 		// Get log.
197
-		if ( ! ( $logs = Give_Cache::get( 'give_logs', true, $sql_query ) ) ) {
198
-			$logs = $wpdb->get_results( $sql_query );
199
-			Give_Cache::set( 'give_logs', $logs, 3600, true, $sql_query );
197
+		if ( ! ($logs = Give_Cache::get('give_logs', true, $sql_query))) {
198
+			$logs = $wpdb->get_results($sql_query);
199
+			Give_Cache::set('give_logs', $logs, 3600, true, $sql_query);
200 200
 		}
201 201
 
202 202
 		return $logs;
@@ -213,21 +213,21 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @return int
215 215
 	 */
216
-	public function count( $args = array() ) {
216
+	public function count($args = array()) {
217 217
 		/* @var WPDB $wpdb */
218 218
 		global $wpdb;
219 219
 		$args['number'] = - 1;
220 220
 		$args['fields'] = 'ID';
221 221
 		$args['count']  = true;
222 222
 
223
-		$sql_query = $this->get_sql( $args );
223
+		$sql_query = $this->get_sql($args);
224 224
 
225
-		if ( ! ( $count = Give_Cache::get( 'give_logs_count', true, $sql_query ) ) ) {
226
-			$count = $wpdb->get_var( $sql_query );
227
-			Give_Cache::set( 'give_logs_count', $count, 3600, true, $args );
225
+		if ( ! ($count = Give_Cache::get('give_logs_count', true, $sql_query))) {
226
+			$count = $wpdb->get_var($sql_query);
227
+			Give_Cache::set('give_logs_count', $count, 3600, true, $args);
228 228
 		}
229 229
 
230
-		return absint( $count );
230
+		return absint($count);
231 231
 	}
232 232
 
233 233
 	/**
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
         PRIMARY KEY  (ID)
254 254
         ) {$charset_collate};";
255 255
 
256
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
257
-		dbDelta( $sql );
256
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
257
+		dbDelta($sql);
258 258
 
259
-		update_option( $this->table_name . '_db_version', $this->version, false );
259
+		update_option($this->table_name.'_db_version', $this->version, false);
260 260
 	}
261 261
 
262 262
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return string
272 272
 	 */
273
-	public function get_sql( $args = array() ) {
273
+	public function get_sql($args = array()) {
274 274
 		/* @var WPDB $wpdb */
275 275
 		global $wpdb;
276 276
 
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 			'count'   => false,
285 285
 		);
286 286
 
287
-		$args = wp_parse_args( $args, $defaults );
287
+		$args = wp_parse_args($args, $defaults);
288 288
 
289 289
 		// validate params.
290
-		$this->validate_params( $args );
290
+		$this->validate_params($args);
291 291
 
292
-		if ( $args['number'] < 1 ) {
292
+		if ($args['number'] < 1) {
293 293
 			$args['number'] = 99999999999;
294 294
 		}
295 295
 
@@ -297,78 +297,78 @@  discard block
 block discarded – undo
297 297
 		$where = '';
298 298
 
299 299
 		// Get sql query for meta.
300
-		if ( ! empty( $args['meta_query'] ) ) {
301
-			$meta_query_object = new WP_Meta_Query( $args['meta_query'] );
302
-			$meta_query        = $meta_query_object->get_sql( 'log', $this->table_name, 'id' );
303
-			$where             = implode( '', $meta_query );
300
+		if ( ! empty($args['meta_query'])) {
301
+			$meta_query_object = new WP_Meta_Query($args['meta_query']);
302
+			$meta_query        = $meta_query_object->get_sql('log', $this->table_name, 'id');
303
+			$where             = implode('', $meta_query);
304 304
 		}
305 305
 
306 306
 		$where .= ' WHERE 1=1 ';
307 307
 
308 308
 		// Set offset.
309
-		if ( empty( $args['offset'] ) && ( 0 < $args['paged'] ) ) {
310
-			$args['offset'] = $args['number'] * ( $args['paged'] - 1 );
309
+		if (empty($args['offset']) && (0 < $args['paged'])) {
310
+			$args['offset'] = $args['number'] * ($args['paged'] - 1);
311 311
 		}
312 312
 
313 313
 		// Set fields.
314 314
 		$fields = "{$this->table_name}.*";
315
-		if ( is_string( $args['fields'] ) && ( 'all' !== $args['fields'] ) ) {
315
+		if (is_string($args['fields']) && ('all' !== $args['fields'])) {
316 316
 			$fields = "{$this->table_name}.{$args['fields']}";
317 317
 		}
318 318
 
319 319
 		// Set count.
320
-		if ( $args['count'] ) {
320
+		if ($args['count']) {
321 321
 			$fields = "COUNT({$fields})";
322 322
 		}
323 323
 
324 324
 		// Specific logs.
325
-		if ( ! empty( $args['ID'] ) ) {
325
+		if ( ! empty($args['ID'])) {
326 326
 
327
-			if ( ! is_array( $args['ID'] ) ) {
328
-				$args['ID'] = explode( ',', $args['ID'] );
327
+			if ( ! is_array($args['ID'])) {
328
+				$args['ID'] = explode(',', $args['ID']);
329 329
 			}
330
-			$log_ids = implode( ',', array_map( 'intval', $args['ID'] ) );
330
+			$log_ids = implode(',', array_map('intval', $args['ID']));
331 331
 
332 332
 			$where .= " AND {$this->table_name}.ID IN( {$log_ids} ) ";
333 333
 		}
334 334
 
335 335
 		// Logs created for a specific date or in a date range
336
-		if ( ! empty( $args['date_query'] ) ) {
337
-			$date_query_object = new WP_Date_Query( $args['date_query'], "{$this->table_name}.log_date" );
338
-			$where             .= $date_query_object->get_sql();
336
+		if ( ! empty($args['date_query'])) {
337
+			$date_query_object = new WP_Date_Query($args['date_query'], "{$this->table_name}.log_date");
338
+			$where .= $date_query_object->get_sql();
339 339
 		}
340 340
 
341 341
 		// Logs create for specific parent.
342
-		if ( ! empty( $args['log_parent'] ) ) {
343
-			if ( ! is_array( $args['log_parent'] ) ) {
344
-				$args['log_parent'] = explode( ',', $args['log_parent'] );
342
+		if ( ! empty($args['log_parent'])) {
343
+			if ( ! is_array($args['log_parent'])) {
344
+				$args['log_parent'] = explode(',', $args['log_parent']);
345 345
 			}
346
-			$parent_ids = implode( ',', array_map( 'intval', $args['log_parent'] ) );
346
+			$parent_ids = implode(',', array_map('intval', $args['log_parent']));
347 347
 
348 348
 			$where .= " AND {$this->table_name}.log_parent IN( {$parent_ids} ) ";
349 349
 		}
350 350
 
351 351
 		// Logs create for specific type.
352 352
 		// is_array check is for backward compatibility.
353
-		if ( ! empty( $args['log_type'] ) && ! is_array( $args['log_type'] ) ) {
354
-			if ( ! is_array( $args['log_type'] ) ) {
355
-				$args['log_type'] = explode( ',', $args['log_type'] );
353
+		if ( ! empty($args['log_type']) && ! is_array($args['log_type'])) {
354
+			if ( ! is_array($args['log_type'])) {
355
+				$args['log_type'] = explode(',', $args['log_type']);
356 356
 			}
357 357
 
358
-			$log_types = implode( '\',\'', array_map( 'trim', $args['log_type'] ) );
358
+			$log_types = implode('\',\'', array_map('trim', $args['log_type']));
359 359
 
360 360
 			$where .= " AND {$this->table_name}.log_type IN( '{$log_types}' ) ";
361 361
 		}
362 362
 
363
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'log_date' : $args['orderby'];
363
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'log_date' : $args['orderby'];
364 364
 
365
-		$args['orderby'] = esc_sql( $args['orderby'] );
366
-		$args['order']   = esc_sql( $args['order'] );
365
+		$args['orderby'] = esc_sql($args['orderby']);
366
+		$args['order']   = esc_sql($args['order']);
367 367
 
368 368
 		return $wpdb->prepare(
369 369
 			"SELECT {$fields} FROM {$this->table_name} {$where} ORDER BY {$this->table_name}.{$args['orderby']} {$args['order']} LIMIT %d,%d;",
370
-			absint( $args['offset'] ),
371
-			absint( $args['number'] )
370
+			absint($args['offset']),
371
+			absint($args['number'])
372 372
 		);
373 373
 	}
374 374
 
@@ -383,13 +383,11 @@  discard block
 block discarded – undo
383 383
 	 *
384 384
 	 * @return mixed
385 385
 	 */
386
-	private function validate_params( &$args ) {
386
+	private function validate_params(&$args) {
387 387
 		// fields params
388 388
 		$args['fields'] = 'ids' === $args['fields'] ?
389
-			'ID' :
390
-			$args['fields'];
391
-		$args['fields'] = array_key_exists( $args['fields'], $this->get_columns() ) ?
392
-			$args['fields'] :
393
-			'all';
389
+			'ID' : $args['fields'];
390
+		$args['fields'] = array_key_exists($args['fields'], $this->get_columns()) ?
391
+			$args['fields'] : 'all';
394 392
 	}
395 393
 }
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +136 added lines, -136 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
 
@@ -30,54 +30,54 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|array List of all user donations.
32 32
  */
33
-function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43
-	$status = ( 'complete' === $status ) ? 'publish' : $status;
43
+	$status = ('complete' === $status) ? 'publish' : $status;
44 44
 	$paged = 1;
45 45
 
46
-	if ( $pagination ) {
47
-		if ( get_query_var( 'paged' ) ) {
48
-			$paged = get_query_var( 'paged' );
49
-		} elseif ( get_query_var( 'page' ) ) {
50
-			$paged = get_query_var( 'page' );
46
+	if ($pagination) {
47
+		if (get_query_var('paged')) {
48
+			$paged = get_query_var('paged');
49
+		} elseif (get_query_var('page')) {
50
+			$paged = get_query_var('page');
51 51
 		}
52 52
 	}
53 53
 
54
-	$args = apply_filters( 'give_get_users_donations_args', array(
54
+	$args = apply_filters('give_get_users_donations_args', array(
55 55
 		'user'    => $user,
56 56
 		'number'  => $number,
57 57
 		'status'  => $status,
58 58
 		'orderby' => 'date',
59
-	) );
59
+	));
60 60
 
61
-	if ( $pagination ) {
61
+	if ($pagination) {
62 62
 		$args['page'] = $paged;
63 63
 	} else {
64 64
 		$args['nopaging'] = true;
65 65
 	}
66 66
 
67
-	$by_user_id = is_numeric( $user ) ? true : false;
68
-	$donor   = new Give_Donor( $user, $by_user_id );
67
+	$by_user_id = is_numeric($user) ? true : false;
68
+	$donor = new Give_Donor($user, $by_user_id);
69 69
 
70
-	if ( ! empty( $donor->payment_ids ) ) {
70
+	if ( ! empty($donor->payment_ids)) {
71 71
 
72
-		unset( $args['user'] );
73
-		$args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) );
72
+		unset($args['user']);
73
+		$args['post__in'] = array_map('absint', explode(',', $donor->payment_ids));
74 74
 
75 75
 	}
76 76
 
77
-	$donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
77
+	$donations = give_get_payments(apply_filters('give_get_users_donations_args', $args));
78 78
 
79 79
 	// No donations.
80
-	if ( ! $donations ) {
80
+	if ( ! $donations) {
81 81
 		return false;
82 82
 	}
83 83
 
@@ -96,65 +96,65 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return bool|object List of unique forms donated by user
98 98
  */
99
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
100
-	if ( empty( $user ) ) {
99
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
100
+	if (empty($user)) {
101 101
 		$user = get_current_user_id();
102 102
 	}
103 103
 
104
-	if ( empty( $user ) ) {
104
+	if (empty($user)) {
105 105
 		return false;
106 106
 	}
107 107
 
108
-	$by_user_id = is_numeric( $user ) ? true : false;
108
+	$by_user_id = is_numeric($user) ? true : false;
109 109
 
110
-	$donor = new Give_Donor( $user, $by_user_id );
110
+	$donor = new Give_Donor($user, $by_user_id);
111 111
 
112
-	if ( empty( $donor->payment_ids ) ) {
112
+	if (empty($donor->payment_ids)) {
113 113
 		return false;
114 114
 	}
115 115
 
116 116
 	// Get all the items donated.
117
-	$payment_ids    = array_reverse( explode( ',', $donor->payment_ids ) );
118
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
119
-	if ( ! empty( $limit_payments ) ) {
120
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
117
+	$payment_ids    = array_reverse(explode(',', $donor->payment_ids));
118
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
119
+	if ( ! empty($limit_payments)) {
120
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
121 121
 	}
122 122
 	$donation_data = array();
123
-	foreach ( $payment_ids as $payment_id ) {
124
-		$donation_data[] = give_get_payment_meta( $payment_id );
123
+	foreach ($payment_ids as $payment_id) {
124
+		$donation_data[] = give_get_payment_meta($payment_id);
125 125
 	}
126 126
 
127
-	if ( empty( $donation_data ) ) {
127
+	if (empty($donation_data)) {
128 128
 		return false;
129 129
 	}
130 130
 
131 131
 	// Grab only the post ids "form_id" of the forms donated on this order.
132 132
 	$completed_donations_ids = array();
133
-	foreach ( $donation_data as $donation_meta ) {
134
-		$completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : '';
133
+	foreach ($donation_data as $donation_meta) {
134
+		$completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : '';
135 135
 	}
136 136
 
137
-	if ( empty( $completed_donations_ids ) ) {
137
+	if (empty($completed_donations_ids)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	// Only include each donation once.
142
-	$form_ids = array_unique( $completed_donations_ids );
142
+	$form_ids = array_unique($completed_donations_ids);
143 143
 
144 144
 	// Make sure we still have some products and a first item.
145
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
145
+	if (empty($form_ids) || ! isset($form_ids[0])) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$post_type = get_post_type( $form_ids[0] );
149
+	$post_type = get_post_type($form_ids[0]);
150 150
 
151
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
151
+	$args = apply_filters('give_get_users_completed_donations_args', array(
152 152
 		'include'        => $form_ids,
153 153
 		'post_type'      => $post_type,
154
-		'posts_per_page' => - 1,
155
-	) );
154
+		'posts_per_page' => -1,
155
+	));
156 156
 
157
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
157
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
158 158
 }
159 159
 
160 160
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return bool True if has donated, false other wise.
172 172
  */
173
-function give_has_donations( $user_id = null ) {
174
-	if ( empty( $user_id ) ) {
173
+function give_has_donations($user_id = null) {
174
+	if (empty($user_id)) {
175 175
 		$user_id = get_current_user_id();
176 176
 	}
177 177
 
178
-	if ( give_get_users_donations( $user_id, 1 ) ) {
178
+	if (give_get_users_donations($user_id, 1)) {
179 179
 		return true; // User has at least one donation.
180 180
 	}
181 181
 
@@ -196,23 +196,23 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return array
198 198
  */
199
-function give_get_donation_stats_by_user( $user = '' ) {
199
+function give_get_donation_stats_by_user($user = '') {
200 200
 
201 201
 	$field = '';
202 202
 
203
-	if ( is_email( $user ) ) {
203
+	if (is_email($user)) {
204 204
 		$field = 'email';
205
-	} elseif ( is_numeric( $user ) ) {
205
+	} elseif (is_numeric($user)) {
206 206
 		$field = 'user_id';
207 207
 	}
208 208
 
209
-	$stats    = array();
210
-	$donor = Give()->donors->get_donor_by( $field, $user );
209
+	$stats = array();
210
+	$donor = Give()->donors->get_donor_by($field, $user);
211 211
 
212
-	if ( $donor ) {
213
-		$donor = new Give_Donor( $donor->id );
214
-		$stats['purchases']   = absint( $donor->purchase_count );
215
-		$stats['total_spent'] = give_maybe_sanitize_amount( $donor->get_total_donation_amount() );
212
+	if ($donor) {
213
+		$donor = new Give_Donor($donor->id);
214
+		$stats['purchases']   = absint($donor->purchase_count);
215
+		$stats['total_spent'] = give_maybe_sanitize_amount($donor->get_total_donation_amount());
216 216
 	}
217 217
 
218 218
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @since 1.7
222 222
 	 */
223
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
223
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
224 224
 
225 225
 	return $stats;
226 226
 }
@@ -238,21 +238,21 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return int The total number of donations.
240 240
  */
241
-function give_count_donations_of_donor( $user = null ) {
241
+function give_count_donations_of_donor($user = null) {
242 242
 
243 243
 	// Logged in?
244
-	if ( empty( $user ) ) {
244
+	if (empty($user)) {
245 245
 		$user = get_current_user_id();
246 246
 	}
247 247
 
248 248
 	// Email access?
249
-	if ( empty( $user ) && Give()->email_access->token_email ) {
249
+	if (empty($user) && Give()->email_access->token_email) {
250 250
 		$user = Give()->email_access->token_email;
251 251
 	}
252 252
 
253
-	$stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false;
253
+	$stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false;
254 254
 
255
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
255
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
256 256
 }
257 257
 
258 258
 /**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return float The total amount the user has spent
267 267
  */
268
-function give_donation_total_of_user( $user = null ) {
268
+function give_donation_total_of_user($user = null) {
269 269
 
270
-	$stats = give_get_donation_stats_by_user( $user );
270
+	$stats = give_get_donation_stats_by_user($user);
271 271
 
272 272
 	return $stats['total_spent'];
273 273
 }
@@ -283,40 +283,40 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * @return bool
285 285
  */
286
-function give_validate_username( $username, $form_id = 0 ) {
286
+function give_validate_username($username, $form_id = 0) {
287 287
 	$valid = true;
288 288
 
289 289
 	// Validate username.
290
-	if ( ! empty( $username ) ) {
290
+	if ( ! empty($username)) {
291 291
 
292 292
 		// Sanitize username.
293
-		$sanitized_user_name = sanitize_user( $username, false );
293
+		$sanitized_user_name = sanitize_user($username, false);
294 294
 
295 295
 		// We have an user name, check if it already exists.
296
-		if ( username_exists( $username ) ) {
296
+		if (username_exists($username)) {
297 297
 			// Username already registered.
298
-			give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) );
298
+			give_set_error('username_unavailable', __('Username already taken.', 'give'));
299 299
 			$valid = false;
300 300
 
301 301
 			// Check if it's valid.
302
-		} elseif ( $sanitized_user_name !== $username ) {
302
+		} elseif ($sanitized_user_name !== $username) {
303 303
 			// Invalid username.
304
-			if ( is_multisite() ) {
305
-				give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
304
+			if (is_multisite()) {
305
+				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
306 306
 				$valid = false;
307 307
 			} else {
308
-				give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) );
308
+				give_set_error('username_invalid', __('Invalid username.', 'give'));
309 309
 				$valid = false;
310 310
 			}
311 311
 		}
312 312
 	} else {
313 313
 		// Username is empty.
314
-		give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) );
314
+		give_set_error('username_empty', __('Enter a username.', 'give'));
315 315
 		$valid = false;
316 316
 
317 317
 		// Check if guest checkout is disable for form.
318
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
319
-			give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) );
318
+		if ($form_id && give_logged_in_only($form_id)) {
319
+			give_set_error('registration_required', __('You must register or login to complete your donation.', 'give'));
320 320
 			$valid = false;
321 321
 		}
322 322
 	}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @since 1.8
332 332
 	 */
333
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
333
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
334 334
 
335 335
 	return $valid;
336 336
 }
@@ -346,30 +346,30 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return bool
348 348
  */
349
-function give_validate_user_email( $email, $registering_new_user = false ) {
349
+function give_validate_user_email($email, $registering_new_user = false) {
350 350
 	$valid = true;
351 351
 
352
-	if ( empty( $email ) ) {
352
+	if (empty($email)) {
353 353
 		// No email.
354
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
354
+		give_set_error('email_empty', __('Enter an email.', 'give'));
355 355
 		$valid = false;
356 356
 
357
-	} elseif ( email_exists( $email ) ) {
357
+	} elseif (email_exists($email)) {
358 358
 		// Email already exists.
359
-		give_set_error( 'email_exists', __( 'Email already exists.', 'give' ) );
359
+		give_set_error('email_exists', __('Email already exists.', 'give'));
360 360
 		$valid = false;
361 361
 
362
-	} elseif ( ! is_email( $email ) ) {
362
+	} elseif ( ! is_email($email)) {
363 363
 		// Validate email.
364
-		give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
364
+		give_set_error('email_invalid', __('Invalid email.', 'give'));
365 365
 		$valid = false;
366 366
 
367
-	} elseif ( $registering_new_user ) {
367
+	} elseif ($registering_new_user) {
368 368
 
369 369
 		// If donor email is not primary.
370
-		if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) {
370
+		if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) {
371 371
 			// Check if email exists.
372
-			give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) );
372
+			give_set_error('email_used', __('The email address provided is already active for another user.', 'give'));
373 373
 			$valid = false;
374 374
 		}
375 375
 	}
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 *
384 384
 	 * @since 1.8
385 385
 	 */
386
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
386
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
387 387
 
388 388
 	return $valid;
389 389
 }
@@ -399,34 +399,34 @@  discard block
 block discarded – undo
399 399
  *
400 400
  * @return bool
401 401
  */
402
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
402
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
403 403
 	$valid = true;
404 404
 
405 405
 	// Passwords Validation For New Donors Only.
406
-	if ( $registering_new_user ) {
406
+	if ($registering_new_user) {
407 407
 		// Password or confirmation missing.
408
-		if ( ! $password ) {
408
+		if ( ! $password) {
409 409
 			// The password is invalid.
410
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
410
+			give_set_error('password_empty', __('Enter a password.', 'give'));
411 411
 			$valid = false;
412
-		} elseif ( ! $confirm_password ) {
412
+		} elseif ( ! $confirm_password) {
413 413
 			// Confirmation password is invalid.
414
-			give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) );
414
+			give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give'));
415 415
 			$valid = false;
416 416
 		}
417 417
 	}
418 418
 	// Passwords Validation For New Donors as well as Existing Donors.
419
-	if ( $password || $confirm_password ) {
420
-		if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) {
419
+	if ($password || $confirm_password) {
420
+		if (strlen($password) < 6 || strlen($confirm_password) < 6) {
421 421
 			// Seems Weak Password.
422
-			give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) );
422
+			give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give'));
423 423
 			$valid = false;
424 424
 		}
425
-		if ( $password && $confirm_password ) {
425
+		if ($password && $confirm_password) {
426 426
 			// Verify confirmation matches.
427
-			if ( $password !== $confirm_password ) {
427
+			if ($password !== $confirm_password) {
428 428
 				// Passwords do not match.
429
-				give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) );
429
+				give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give'));
430 430
 				$valid = false;
431 431
 			}
432 432
 		}
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	 *
443 443
 	 * @since 1.8
444 444
 	 */
445
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
445
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
446 446
 
447 447
 	return $valid;
448 448
 }
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
  *
471 471
  * @return array The donor's address, if any
472 472
  */
473
-function give_get_donor_address( $donor_id = null, $args = array() ) {
474
-	if ( empty( $donor_id ) ) {
473
+function give_get_donor_address($donor_id = null, $args = array()) {
474
+	if (empty($donor_id)) {
475 475
 		$donor_id = get_current_user_id();
476 476
 	}
477 477
 
@@ -493,33 +493,33 @@  discard block
 block discarded – undo
493 493
 
494 494
 
495 495
 	// Backward compatibility for user id param.
496
-	$by_user_id = get_user_by( 'id', $donor_id ) ? true : false;
496
+	$by_user_id = get_user_by('id', $donor_id) ? true : false;
497 497
 
498 498
 	// Backward compatibility.
499
-	if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) && $by_user_id ) {
499
+	if ( ! give_has_upgrade_completed('v20_upgrades_user_address') && $by_user_id) {
500 500
 		return wp_parse_args(
501
-			(array) get_user_meta( $donor_id, '_give_user_address', true ),
501
+			(array) get_user_meta($donor_id, '_give_user_address', true),
502 502
 			$default_address
503 503
 		);
504 504
 	}
505 505
 
506
-	$donor = new Give_Donor( $donor_id, $by_user_id );
506
+	$donor = new Give_Donor($donor_id, $by_user_id);
507 507
 
508 508
 	if (
509 509
 		! $donor->id ||
510
-		empty( $donor->address ) ||
511
-		! array_key_exists( $args['address_type'], $donor->address )
510
+		empty($donor->address) ||
511
+		! array_key_exists($args['address_type'], $donor->address)
512 512
 	) {
513 513
 		return $default_address;
514 514
 	}
515 515
 
516
-	switch ( true ) {
517
-		case is_string( end( $donor->address[ $args['address_type'] ] ) ):
518
-			$address = wp_parse_args( $donor->address[ $args['address_type'] ], $default_address );
516
+	switch (true) {
517
+		case is_string(end($donor->address[$args['address_type']])):
518
+			$address = wp_parse_args($donor->address[$args['address_type']], $default_address);
519 519
 			break;
520 520
 
521
-		case is_array( end( $donor->address[ $args['address_type'] ] ) ):
522
-			$address = wp_parse_args( array_shift( $donor->address[ $args['address_type'] ] ), $default_address );
521
+		case is_array(end($donor->address[$args['address_type']])):
522
+			$address = wp_parse_args(array_shift($donor->address[$args['address_type']]), $default_address);
523 523
 			break;
524 524
 	}
525 525
 
@@ -539,19 +539,19 @@  discard block
 block discarded – undo
539 539
  *
540 540
  * @return void
541 541
  */
542
-function give_new_user_notification( $donation_id = 0, $donation_data = array() ) {
542
+function give_new_user_notification($donation_id = 0, $donation_data = array()) {
543 543
 	// Bailout.
544 544
 	if (
545
-		empty( $donation_id )
546
-		|| empty( $donation_data )
547
-		|| ! isset( $_POST['give_create_account'] )
548
-		|| 'on' !== give_clean( $_POST['give_create_account'] )
545
+		empty($donation_id)
546
+		|| empty($donation_data)
547
+		|| ! isset($_POST['give_create_account'])
548
+		|| 'on' !== give_clean($_POST['give_create_account'])
549 549
 	) {
550 550
 		return;
551 551
 	}
552 552
 
553 553
 	// For backward compatibility
554
-	$user = get_user_by( 'ID', $donation_data['user_info']['id'] );
554
+	$user = get_user_by('ID', $donation_data['user_info']['id']);
555 555
 
556 556
 	$donation_data['user_info'] = array_merge(
557 557
 		$donation_data['user_info'],
@@ -564,11 +564,11 @@  discard block
 block discarded – undo
564 564
 		)
565 565
 	);
566 566
 
567
-	do_action( 'give_new-donor-register_email_notification', $donation_data['user_info']['id'], $donation_data['user_info'], $donation_id );
568
-	do_action( 'give_donor-register_email_notification', $donation_data['user_info']['id'], $donation_data['user_info'], $donation_id );
567
+	do_action('give_new-donor-register_email_notification', $donation_data['user_info']['id'], $donation_data['user_info'], $donation_id);
568
+	do_action('give_donor-register_email_notification', $donation_data['user_info']['id'], $donation_data['user_info'], $donation_id);
569 569
 }
570 570
 
571
-add_action( 'give_insert_payment', 'give_new_user_notification', 10, 2 );
571
+add_action('give_insert_payment', 'give_new_user_notification', 10, 2);
572 572
 
573 573
 
574 574
 /**
@@ -584,37 +584,37 @@  discard block
 block discarded – undo
584 584
  *
585 585
  * @return string
586 586
  */
587
-function give_get_donor_name_by( $id = 0, $from = 'donation' ) {
587
+function give_get_donor_name_by($id = 0, $from = 'donation') {
588 588
 
589 589
 	// ID shouldn't be empty.
590
-	if ( empty( $id ) ) {
590
+	if (empty($id)) {
591 591
 		return '';
592 592
 	}
593 593
 
594 594
 	$name         = '';
595 595
 	$title_prefix = '';
596 596
 
597
-	switch ( $from ) {
597
+	switch ($from) {
598 598
 
599 599
 		case 'donation':
600
-			$title_prefix  = give_get_meta( $id, '_give_payment_donor_title_prefix', true );
601
-			$first_name    = give_get_meta( $id, '_give_donor_billing_first_name', true );
602
-			$last_name     = give_get_meta( $id, '_give_donor_billing_last_name', true );
600
+			$title_prefix  = give_get_meta($id, '_give_payment_donor_title_prefix', true);
601
+			$first_name    = give_get_meta($id, '_give_donor_billing_first_name', true);
602
+			$last_name     = give_get_meta($id, '_give_donor_billing_last_name', true);
603 603
 
604 604
 			$name = "{$first_name} {$last_name}";
605 605
 
606 606
 			break;
607 607
 
608 608
 		case 'donor':
609
-			$name         = Give()->donors->get_column( 'name', $id );
610
-			$title_prefix = Give()->donor_meta->get_meta( $id, '_give_donor_title_prefix', true );
609
+			$name         = Give()->donors->get_column('name', $id);
610
+			$title_prefix = Give()->donor_meta->get_meta($id, '_give_donor_title_prefix', true);
611 611
 
612 612
 			break;
613 613
 
614 614
 	}
615 615
 
616 616
 	// If title prefix is set then prepend it to name.
617
-	$name = give_get_donor_name_with_title_prefixes( $title_prefix, $name );
617
+	$name = give_get_donor_name_with_title_prefixes($title_prefix, $name);
618 618
 
619 619
 	return $name;
620 620
 
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
  *
630 630
  * @return boolean  The user's ID on success, and false on failure.
631 631
  */
632
-function give_donor_email_exists( $email ) {
633
-	if ( Give()->donors->get_donor_by( 'email', $email ) ) {
632
+function give_donor_email_exists($email) {
633
+	if (Give()->donors->get_donor_by('email', $email)) {
634 634
 		return true;
635 635
 	}
636 636
 	return false;
@@ -645,14 +645,14 @@  discard block
 block discarded – undo
645 645
  *
646 646
  * @return bool
647 647
  */
648
-function give_is_additional_email( $email ) {
648
+function give_is_additional_email($email) {
649 649
 	global $wpdb;
650 650
 
651 651
 	$meta_table = Give()->donor_meta->table_name;
652 652
 	$meta_type  = Give()->donor_meta->meta_type;
653
-	$donor_id   = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) );
653
+	$donor_id   = $wpdb->get_var($wpdb->prepare("SELECT {$meta_type}_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email));
654 654
 
655
-	if ( empty( $donor_id ) ) {
655
+	if (empty($donor_id)) {
656 656
 		return false;
657 657
 	}
658 658
 
Please login to merge, or discard this patch.
includes/price-functions.php 1 patch
Spacing   +21 added lines, -21 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,13 +23,13 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return bool true if has variable prices, false otherwise
25 25
  */
26
-function give_has_variable_prices( $form_id = 0 ) {
26
+function give_has_variable_prices($form_id = 0) {
27 27
 
28
-	if ( empty( $form_id ) ) {
28
+	if (empty($form_id)) {
29 29
 		return false;
30 30
 	}
31 31
 
32
-	$form = new Give_Donate_Form( $form_id );
32
+	$form = new Give_Donate_Form($form_id);
33 33
 
34 34
 	return $form->has_variable_prices();
35 35
 }
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return array|bool Variable prices
46 46
  */
47
-function give_get_variable_prices( $form_id = 0 ) {
47
+function give_get_variable_prices($form_id = 0) {
48 48
 
49
-	if ( empty( $form_id ) ) {
49
+	if (empty($form_id)) {
50 50
 		return false;
51 51
 	}
52 52
 
53
-	$form = new Give_Donate_Form( $form_id );
53
+	$form = new Give_Donate_Form($form_id);
54 54
 
55 55
 	return $form->prices;
56 56
 
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
  *
66 66
  * @return array Variable prices
67 67
  */
68
-function give_get_variable_price_ids( $form_id = 0 ) {
69
-	if( ! ( $prices = give_get_variable_prices( $form_id ) ) ) {
68
+function give_get_variable_price_ids($form_id = 0) {
69
+	if ( ! ($prices = give_get_variable_prices($form_id))) {
70 70
 		return array();
71 71
 	}
72 72
 
73 73
 	$price_ids = array();
74
-	foreach ( $prices as $price ){
74
+	foreach ($prices as $price) {
75 75
 		$price_ids[] = $price['_give_id']['level_id'];
76 76
 	}
77 77
 
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
  *
90 90
  * @return string $default_price
91 91
  */
92
-function give_get_default_multilevel_amount( $form_id ) {
92
+function give_get_default_multilevel_amount($form_id) {
93 93
 	$default_price = '1.00';
94 94
 
95 95
 	// Get default level price data.
96
-	$default_level = give_form_get_default_level( $form_id );
97
-	$default_price = isset( $default_level['_give_amount'] ) ? $default_level['_give_amount'] : $default_price;
96
+	$default_level = give_form_get_default_level($form_id);
97
+	$default_price = isset($default_level['_give_amount']) ? $default_level['_give_amount'] : $default_price;
98 98
 
99 99
 	return $default_price;
100 100
 }
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
  * @return string $default_price
111 111
  * @since      1.0
112 112
  */
113
-function give_get_default_form_amount( $form_id ) {
113
+function give_get_default_form_amount($form_id) {
114 114
 
115
-	if ( give_has_variable_prices( $form_id ) ) {
115
+	if (give_has_variable_prices($form_id)) {
116 116
 
117
-		$default_amount = give_get_default_multilevel_amount( $form_id );
117
+		$default_amount = give_get_default_multilevel_amount($form_id);
118 118
 
119 119
 	} else {
120 120
 
121
-		$default_amount = give_get_meta( $form_id, '_give_set_price', true );
121
+		$default_amount = give_get_meta($form_id, '_give_set_price', true);
122 122
 
123 123
 	}
124 124
 
125
-	return apply_filters( 'give_default_form_amount', $default_amount, $form_id );
125
+	return apply_filters('give_default_form_amount', $default_amount, $form_id);
126 126
 
127 127
 }
128 128
 
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
  *
141 141
  * @return bool
142 142
  */
143
-function give_is_custom_price_mode( $form_id = 0 ) {
143
+function give_is_custom_price_mode($form_id = 0) {
144 144
 
145
-	if ( empty( $form_id ) ) {
145
+	if (empty($form_id)) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$form = new Give_Donate_Form( $form_id );
149
+	$form = new Give_Donate_Form($form_id);
150 150
 
151 151
 	return $form->is_custom_price_mode();
152 152
 }
Please login to merge, or discard this patch.
includes/class-give-db-sequential-ordering.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
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_sequential_ordering';
38
+		$this->table_name  = $wpdb->prefix.'give_sequential_ordering';
39 39
 		$this->primary_key = 'id';
40 40
 		$this->version     = '1.0';
41 41
 
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
         PRIMARY KEY  (id)
109 109
         ) {$charset_collate};";
110 110
 
111
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
112
-		dbDelta( $sql );
111
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
112
+		dbDelta($sql);
113 113
 
114
-		if ( ! empty( $payment_ID ) ) {
114
+		if ( ! empty($payment_ID)) {
115 115
 			$auto_increment = $payment_ID + 1;
116
-			$wpdb->query( "ALTER TABLE {$this->table_name} AUTO_INCREMENT={$auto_increment};" );
117
-			give_update_option( 'sequential-ordering_number', $auto_increment );
116
+			$wpdb->query("ALTER TABLE {$this->table_name} AUTO_INCREMENT={$auto_increment};");
117
+			give_update_option('sequential-ordering_number', $auto_increment);
118 118
 		} else {
119
-			give_update_option( 'sequential-ordering_number', 1 );
119
+			give_update_option('sequential-ordering_number', 1);
120 120
 		}
121 121
 
122
-		update_option( $this->table_name . '_db_version', $this->version, false );
122
+		update_option($this->table_name.'_db_version', $this->version, false);
123 123
 	}
124 124
 
125 125
 
Please login to merge, or discard this patch.
includes/admin/class-admin-settings.php 2 patches
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -465,9 +465,12 @@  discard block
 block discarded – undo
465 465
 								<?php endforeach; ?>
466 466
 								<a href="#" data-id="<?php echo $value['id']; ?>"
467 467
 										class="give-repeat-setting-field button-secondary"><?php echo $value['repeat_btn_title']; ?></a>
468
-							<?php else : ?>
468
+							<?php else {
469
+	: ?>
469 470
 								<input
470
-										name="<?php echo esc_attr( $value['id'] ); ?>"
471
+										name="<?php echo esc_attr( $value['id'] );
472
+}
473
+?>"
471 474
 										id="<?php echo esc_attr( $value['id'] ); ?>"
472 475
 										type="<?php echo esc_attr( $type ); ?>"
473 476
 										style="<?php echo esc_attr( $value['css'] ); ?>"
@@ -536,7 +539,10 @@  discard block
 block discarded – undo
536 539
 						</th>
537 540
 						<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
538 541
 							<select
539
-									name="<?php echo esc_attr( $value['id'] ); ?><?php if ( 'multiselect' === $value['type'] ) echo '[]'; ?>"
542
+									name="<?php echo esc_attr( $value['id'] ); ?><?php if ( 'multiselect' === $value['type'] ) {
543
+	echo '[]';
544
+}
545
+?>"
540 546
 									id="<?php echo esc_attr( $value['id'] ); ?>"
541 547
 									style="<?php echo esc_attr( $value['css'] ); ?>"
542 548
 									class="<?php echo esc_attr( $value['class'] ); ?>"
Please login to merge, or discard this patch.
Spacing   +259 added lines, -260 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Admin_Settings' ) ) :
16
+if ( ! class_exists('Give_Admin_Settings')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Admin_Settings Class.
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			 *
73 73
 			 * @param array $settings Array of settings class object.
74 74
 			 */
75
-			self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() );
75
+			self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array());
76 76
 
77 77
 			return self::$settings;
78 78
 		}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		 * @return bool
87 87
 		 */
88 88
 		public static function verify_nonce() {
89
-			if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) {
89
+			if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) {
90 90
 				return false;
91 91
 			}
92 92
 
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		public static function save() {
103 103
 			$current_tab = give_get_current_setting_tab();
104 104
 
105
-			if ( ! self::verify_nonce() ) {
106
-				echo '<div class="notice error"><p>' . esc_attr__( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>';
105
+			if ( ! self::verify_nonce()) {
106
+				echo '<div class="notice error"><p>'.esc_attr__('Action failed. Please refresh the page and retry.', 'give').'</p></div>';
107 107
 				die();
108 108
 			}
109 109
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 			 *
117 117
 			 * @since 1.8
118 118
 			 */
119
-			do_action( self::$setting_filter_prefix . '_save_' . $current_tab );
119
+			do_action(self::$setting_filter_prefix.'_save_'.$current_tab);
120 120
 
121
-			self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) );
121
+			self::add_message('give-setting-updated', __('Your settings have been saved.', 'give'));
122 122
 
123 123
 			/**
124 124
 			 * Trigger Action.
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 			 *
130 130
 			 * @since 1.8
131 131
 			 */
132
-			do_action( self::$setting_filter_prefix . '_saved' );
132
+			do_action(self::$setting_filter_prefix.'_saved');
133 133
 		}
134 134
 
135 135
 		/**
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 		 *
143 143
 		 * @return void
144 144
 		 */
145
-		public static function add_message( $code, $message ) {
146
-			self::$messages[ $code ] = $message;
145
+		public static function add_message($code, $message) {
146
+			self::$messages[$code] = $message;
147 147
 		}
148 148
 
149 149
 		/**
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 		 *
157 157
 		 * @return void
158 158
 		 */
159
-		public static function add_error( $code, $message ) {
160
-			self::$errors[ $code ] = $message;
159
+		public static function add_error($code, $message) {
160
+			self::$errors[$code] = $message;
161 161
 		}
162 162
 
163 163
 		/**
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 			$notice_html = '';
171 171
 			$classes     = 'give-notice settings-error notice is-dismissible';
172 172
 
173
-			self::$errors   = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors );
174
-			self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages );
173
+			self::$errors   = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors);
174
+			self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages);
175 175
 
176
-			if ( 0 < count( self::$errors ) ) {
177
-				foreach ( self::$errors as $code => $message ) {
176
+			if (0 < count(self::$errors)) {
177
+				foreach (self::$errors as $code => $message) {
178 178
 					$notice_html .= sprintf(
179 179
 						'<div id="setting-error-%1$s" class="%2$s error" style="display: none"><p><strong>%3$s</strong></p></div>',
180 180
 						$code,
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 				}
185 185
 			}
186 186
 
187
-			if ( 0 < count( self::$messages ) ) {
188
-				foreach ( self::$messages as $code => $message ) {
187
+			if (0 < count(self::$messages)) {
188
+				foreach (self::$messages as $code => $message) {
189 189
 					$notice_html .= sprintf(
190 190
 						'<div id="setting-error-%1$s" class="%2$s updated" style="display: none"><p><strong>%3$s</strong></p></div>',
191 191
 						$code,
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 			self::$setting_filter_prefix = give_get_current_setting_page();
212 212
 
213 213
 			// Bailout: Exit if setting page is not defined.
214
-			if ( empty( self::$setting_filter_prefix ) ) {
214
+			if (empty(self::$setting_filter_prefix)) {
215 215
 				return false;
216 216
 			}
217 217
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 			 *
225 225
 			 * @since 1.8
226 226
 			 */
227
-			do_action( self::$setting_filter_prefix . '_start' );
227
+			do_action(self::$setting_filter_prefix.'_start');
228 228
 
229 229
 			$current_tab = give_get_current_setting_tab();
230 230
 
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 			/* @var object $current_setting_obj */
235 235
 			$current_setting_obj = new StdClass;
236 236
 
237
-			foreach ( $all_setting as $setting ) {
237
+			foreach ($all_setting as $setting) {
238 238
 				if (
239
-					method_exists( $setting, 'get_id' ) &&
239
+					method_exists($setting, 'get_id') &&
240 240
 					$current_tab === $setting->get_id()
241 241
 				) {
242 242
 					$current_setting_obj = $setting;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 			}
246 246
 
247 247
 			// Save settings if data has been posted.
248
-			if ( isset( $_POST['_give-save-settings'] ) ) {
248
+			if (isset($_POST['_give-save-settings'])) {
249 249
 				self::save();
250 250
 			}
251 251
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			 *
259 259
 			 * @since 1.8
260 260
 			 */
261
-			$tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() );
261
+			$tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array());
262 262
 
263 263
 			include 'views/html-admin-settings.php';
264 264
 
@@ -276,25 +276,25 @@  discard block
 block discarded – undo
276 276
 		 *
277 277
 		 * @return string|bool
278 278
 		 */
279
-		public static function get_option( $option_name = '', $field_id = '', $default = false ) {
279
+		public static function get_option($option_name = '', $field_id = '', $default = false) {
280 280
 			// Bailout.
281
-			if ( empty( $option_name ) && empty( $field_id ) ) {
281
+			if (empty($option_name) && empty($field_id)) {
282 282
 				return false;
283 283
 			}
284 284
 
285
-			if ( ! empty( $field_id ) && ! empty( $option_name ) ) {
285
+			if ( ! empty($field_id) && ! empty($option_name)) {
286 286
 				// Get field value if any.
287
-				$option_value = get_option( $option_name );
287
+				$option_value = get_option($option_name);
288 288
 
289
-				$option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) )
290
-					? $option_value[ $field_id ]
289
+				$option_value = (is_array($option_value) && array_key_exists($field_id, $option_value))
290
+					? $option_value[$field_id]
291 291
 					: $default;
292 292
 			} else {
293 293
 				// If option name is empty but not field name then this means, setting is direct store to option table under there field name.
294 294
 				$option_name = ! $option_name ? $field_id : $option_name;
295 295
 
296 296
 				// Get option value if any.
297
-				$option_value = get_option( $option_name, $default );
297
+				$option_value = get_option($option_name, $default);
298 298
 			}
299 299
 
300 300
 			/**
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 			 * @param string $field_id
308 308
 			 * @param mixed  $default
309 309
 			 */
310
-			return apply_filters( 'give_admin_field_get_value', $option_value, $option_name, $field_id, $default );
310
+			return apply_filters('give_admin_field_get_value', $option_value, $option_name, $field_id, $default);
311 311
 		}
312 312
 
313 313
 		/**
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		 *
324 324
 		 * @return void
325 325
 		 */
326
-		public static function output_fields( $options, $option_name = '' ) {
326
+		public static function output_fields($options, $option_name = '') {
327 327
 			$current_tab = give_get_current_setting_tab();
328 328
 
329 329
 			// Field Default values.
@@ -335,62 +335,62 @@  discard block
 block discarded – undo
335 335
 				'desc'                => '',
336 336
 				'table_html'          => true,
337 337
 				'repeat'              => false,
338
-				'repeat_btn_title'    => __( 'Add Field', 'give' ),
338
+				'repeat_btn_title'    => __('Add Field', 'give'),
339 339
 			);
340 340
 
341
-			foreach ( $options as $value ) {
342
-				if ( ! isset( $value['type'] ) ) {
341
+			foreach ($options as $value) {
342
+				if ( ! isset($value['type'])) {
343 343
 					continue;
344 344
 				}
345 345
 
346 346
 				// Set title.
347
-				$defaults['title'] = isset( $value['name'] ) ? $value['name'] : '';
347
+				$defaults['title'] = isset($value['name']) ? $value['name'] : '';
348 348
 
349 349
 				// Set default setting.
350
-				$value = wp_parse_args( $value, $defaults );
350
+				$value = wp_parse_args($value, $defaults);
351 351
 
352 352
 				// Colorpicker field.
353
-				$value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] );
354
-				$value['type']  = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] );
353
+				$value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']);
354
+				$value['type']  = ('colorpicker' === $value['type'] ? 'text' : $value['type']);
355 355
 
356 356
 
357 357
 				// Custom attribute handling.
358 358
 				$custom_attributes = array();
359 359
 
360
-				if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) {
361
-					foreach ( $value['attributes'] as $attribute => $attribute_value ) {
362
-						$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
360
+				if ( ! empty($value['attributes']) && is_array($value['attributes'])) {
361
+					foreach ($value['attributes'] as $attribute => $attribute_value) {
362
+						$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"';
363 363
 					}
364 364
 				}
365 365
 
366 366
 				// Description handling.
367
-				$description = self::get_field_description( $value );
367
+				$description = self::get_field_description($value);
368 368
 
369 369
 				// Switch based on type.
370
-				switch ( $value['type'] ) {
370
+				switch ($value['type']) {
371 371
 
372 372
 					// Section Titles.
373 373
 					case 'title':
374
-						if ( ! empty( $value['title'] ) || ! empty( $value['desc'] ) ) {
374
+						if ( ! empty($value['title']) || ! empty($value['desc'])) {
375 375
 							?>
376 376
 							<div class="give-setting-tab-header give-setting-tab-header-<?php echo $current_tab; ?>">
377
-								<?php if ( ! empty( $value['title'] ) ) : ?>
378
-									<h2><?php echo self::get_field_title( $value ); ?></h2>
377
+								<?php if ( ! empty($value['title'])) : ?>
378
+									<h2><?php echo self::get_field_title($value); ?></h2>
379 379
 									<hr>
380 380
 								<?php endif; ?>
381 381
 
382
-								<?php if ( ! empty( $value['desc'] ) ) : ?>
383
-									<?php echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); ?>
382
+								<?php if ( ! empty($value['desc'])) : ?>
383
+									<?php echo wpautop(wptexturize(wp_kses_post($value['desc']))); ?>
384 384
 								<?php endif; ?>
385 385
 							</div>
386 386
 							<?php
387 387
 						}
388 388
 
389
-						if ( $value['table_html'] ) {
390
-							echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n";
389
+						if ($value['table_html']) {
390
+							echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n";
391 391
 						}
392 392
 
393
-						if ( ! empty( $value['id'] ) ) {
393
+						if ( ! empty($value['id'])) {
394 394
 
395 395
 							/**
396 396
 							 * Trigger Action.
@@ -399,14 +399,14 @@  discard block
 block discarded – undo
399 399
 							 *
400 400
 							 * @since 1.8
401 401
 							 */
402
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) );
402
+							do_action('give_settings_'.sanitize_title($value['id']));
403 403
 						}
404 404
 
405 405
 						break;
406 406
 
407 407
 					// Section Ends.
408 408
 					case 'sectionend':
409
-						if ( ! empty( $value['id'] ) ) {
409
+						if ( ! empty($value['id'])) {
410 410
 
411 411
 							/**
412 412
 							 * Trigger Action.
@@ -415,14 +415,14 @@  discard block
 block discarded – undo
415 415
 							 *
416 416
 							 * @since 1.8
417 417
 							 */
418
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' );
418
+							do_action('give_settings_'.sanitize_title($value['id']).'_end');
419 419
 						}
420 420
 
421
-						if ( $value['table_html'] ) {
421
+						if ($value['table_html']) {
422 422
 							echo '</table>';
423 423
 						}
424 424
 
425
-						if ( ! empty( $value['id'] ) ) {
425
+						if ( ! empty($value['id'])) {
426 426
 
427 427
 							/**
428 428
 							 * Trigger Action.
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 							 *
432 432
 							 * @since 1.8
433 433
 							 */
434
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' );
434
+							do_action('give_settings_'.sanitize_title($value['id']).'_after');
435 435
 						}
436 436
 
437 437
 						break;
@@ -439,51 +439,51 @@  discard block
 block discarded – undo
439 439
 					// Standard text inputs and subtypes like 'number'.
440 440
 					case 'colorpicker':
441 441
 					case 'hidden' :
442
-						$value['wrapper_class'] = empty( $value['wrapper_class'] ) ? 'give-hidden' : trim( $value['wrapper_class'] ) . ' give-hidden';
442
+						$value['wrapper_class'] = empty($value['wrapper_class']) ? 'give-hidden' : trim($value['wrapper_class']).' give-hidden';
443 443
 					case 'text':
444 444
 					case 'email':
445 445
 					case 'number':
446 446
 					case 'password' :
447 447
 						$type = $value['type'];
448
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
448
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
449 449
 
450 450
 						// Set default value for repeater field if not any value set yet.
451
-						if ( $value['repeat'] && is_string( $option_value ) ) {
452
-							$option_value = array( $value['default'] );
451
+						if ($value['repeat'] && is_string($option_value)) {
452
+							$option_value = array($value['default']);
453 453
 						}
454 454
 						?>
455
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
455
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
456 456
 						<th scope="row" class="titledesc">
457 457
 							<label
458
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
458
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
459 459
 						</th>
460
-						<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
461
-							<?php if ( $value['repeat'] ) : ?>
462
-								<?php foreach ( $option_value as $index => $field_value ) : ?>
460
+						<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
461
+							<?php if ($value['repeat']) : ?>
462
+								<?php foreach ($option_value as $index => $field_value) : ?>
463 463
 									<p>
464 464
 										<input
465
-												name="<?php echo esc_attr( $value['id'] ); ?>[]"
466
-												type="<?php echo esc_attr( $type ); ?>"
467
-												style="<?php echo esc_attr( $value['css'] ); ?>"
468
-												value="<?php echo esc_attr( $field_value ); ?>"
469
-												class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?> <?php echo esc_attr( $value['id'] ); ?>"
470
-											<?php echo implode( ' ', $custom_attributes ); ?>
465
+												name="<?php echo esc_attr($value['id']); ?>[]"
466
+												type="<?php echo esc_attr($type); ?>"
467
+												style="<?php echo esc_attr($value['css']); ?>"
468
+												value="<?php echo esc_attr($field_value); ?>"
469
+												class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?> <?php echo esc_attr($value['id']); ?>"
470
+											<?php echo implode(' ', $custom_attributes); ?>
471 471
 										/>
472 472
 										<span class="give-remove-setting-field"
473
-												title="<?php esc_html_e( 'Remove setting field', 'give' ); ?>">-</span>
473
+												title="<?php esc_html_e('Remove setting field', 'give'); ?>">-</span>
474 474
 									</p>
475 475
 								<?php endforeach; ?>
476 476
 								<a href="#" data-id="<?php echo $value['id']; ?>"
477 477
 										class="give-repeat-setting-field button-secondary"><?php echo $value['repeat_btn_title']; ?></a>
478 478
 							<?php else : ?>
479 479
 								<input
480
-										name="<?php echo esc_attr( $value['id'] ); ?>"
481
-										id="<?php echo esc_attr( $value['id'] ); ?>"
482
-										type="<?php echo esc_attr( $type ); ?>"
483
-										style="<?php echo esc_attr( $value['css'] ); ?>"
484
-										value="<?php echo esc_attr( $option_value ); ?>"
485
-										class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>"
486
-									<?php echo implode( ' ', $custom_attributes ); ?>
480
+										name="<?php echo esc_attr($value['id']); ?>"
481
+										id="<?php echo esc_attr($value['id']); ?>"
482
+										type="<?php echo esc_attr($type); ?>"
483
+										style="<?php echo esc_attr($value['css']); ?>"
484
+										value="<?php echo esc_attr($option_value); ?>"
485
+										class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>"
486
+									<?php echo implode(' ', $custom_attributes); ?>
487 487
 								/>
488 488
 							<?php endif; ?>
489 489
 							<?php echo $description; ?>
@@ -494,26 +494,26 @@  discard block
 block discarded – undo
494 494
 					// Textarea.
495 495
 					case 'textarea':
496 496
 
497
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
497
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
498 498
 						$default_attributes = array(
499 499
 							'rows' => 10,
500 500
 							'cols' => 60
501 501
 						);
502
-						$textarea_attributes = isset( $value['attributes'] ) ? $value['attributes'] : array();
502
+						$textarea_attributes = isset($value['attributes']) ? $value['attributes'] : array();
503 503
 						?>
504
-						<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
504
+						<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
505 505
 							<th scope="row" class="titledesc">
506 506
 								<label
507
-										for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
507
+										for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
508 508
 							</th>
509
-							<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
509
+							<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
510 510
 										<textarea
511
-											name="<?php echo esc_attr( $value['id'] ); ?>"
512
-											id="<?php echo esc_attr( $value['id'] ); ?>"
513
-											style="<?php echo esc_attr( $value['css'] ); ?>"
514
-											class="<?php echo esc_attr( $value['class'] ); ?>"
515
-											<?php echo give_get_attribute_str( $textarea_attributes, $default_attributes ); ?>
516
-										><?php echo esc_textarea( $option_value ); ?></textarea>
511
+											name="<?php echo esc_attr($value['id']); ?>"
512
+											id="<?php echo esc_attr($value['id']); ?>"
513
+											style="<?php echo esc_attr($value['css']); ?>"
514
+											class="<?php echo esc_attr($value['class']); ?>"
515
+											<?php echo give_get_attribute_str($textarea_attributes, $default_attributes); ?>
516
+										><?php echo esc_textarea($option_value); ?></textarea>
517 517
 								<?php echo $description; ?>
518 518
 							</td>
519 519
 						</tr>
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 					// Select boxes.
524 524
 					case 'select' :
525 525
 					case 'multiselect' :
526
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
526
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
527 527
 
528 528
 						/**
529 529
 						 * Insert page in option if missing.
@@ -531,39 +531,39 @@  discard block
 block discarded – undo
531 531
 						 * Check success_page setting in general settings.
532 532
 						 */
533 533
 						if (
534
-							isset( $value['attributes'] ) &&
535
-							false !== strpos( $value['class'], 'give-select-chosen' ) &&
536
-							in_array( 'data-search-type', array_keys( $value['attributes' ] ) ) &&
537
-							'pages' === $value['attributes' ]['data-search-type'] &&
538
-							! in_array( $option_value, array_keys( $value['options'] ) )
534
+							isset($value['attributes']) &&
535
+							false !== strpos($value['class'], 'give-select-chosen') &&
536
+							in_array('data-search-type', array_keys($value['attributes'])) &&
537
+							'pages' === $value['attributes']['data-search-type'] &&
538
+							! in_array($option_value, array_keys($value['options']))
539 539
 						) {
540
-							$value['options'][ $option_value ] = get_the_title( $option_value );
540
+							$value['options'][$option_value] = get_the_title($option_value);
541 541
 						}
542 542
 						?>
543
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
543
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
544 544
 						<th scope="row" class="titledesc">
545
-							<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
545
+							<label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
546 546
 						</th>
547
-						<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
547
+						<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
548 548
 							<select
549
-									name="<?php echo esc_attr( $value['id'] ); ?><?php if ( 'multiselect' === $value['type'] ) echo '[]'; ?>"
550
-									id="<?php echo esc_attr( $value['id'] ); ?>"
551
-									style="<?php echo esc_attr( $value['css'] ); ?>"
552
-									class="<?php echo esc_attr( $value['class'] ); ?>"
553
-								<?php echo implode( ' ', $custom_attributes ); ?>
554
-								<?php echo ( 'multiselect' === $value['type'] ) ? 'multiple="multiple"' : ''; ?>
549
+									name="<?php echo esc_attr($value['id']); ?><?php if ('multiselect' === $value['type']) echo '[]'; ?>"
550
+									id="<?php echo esc_attr($value['id']); ?>"
551
+									style="<?php echo esc_attr($value['css']); ?>"
552
+									class="<?php echo esc_attr($value['class']); ?>"
553
+								<?php echo implode(' ', $custom_attributes); ?>
554
+								<?php echo ('multiselect' === $value['type']) ? 'multiple="multiple"' : ''; ?>
555 555
 							>
556 556
 
557 557
 								<?php
558
-								if ( ! empty( $value['options'] ) ) {
559
-									foreach ( $value['options'] as $key => $val ) {
558
+								if ( ! empty($value['options'])) {
559
+									foreach ($value['options'] as $key => $val) {
560 560
 										?>
561
-										<option value="<?php echo esc_attr( $key ); ?>" <?php
561
+										<option value="<?php echo esc_attr($key); ?>" <?php
562 562
 
563
-										if ( is_array( $option_value ) ) {
564
-											selected( in_array( $key, $option_value ), true );
563
+										if (is_array($option_value)) {
564
+											selected(in_array($key, $option_value), true);
565 565
 										} else {
566
-											selected( $option_value, $key );
566
+											selected($option_value, $key);
567 567
 										}
568 568
 
569 569
 										?>><?php echo $val ?></option>
@@ -579,29 +579,29 @@  discard block
 block discarded – undo
579 579
 
580 580
 					// Radio inputs.
581 581
 					case 'radio_inline' :
582
-						$value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline';
582
+						$value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline';
583 583
 					case 'radio' :
584
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
584
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
585 585
 						?>
586
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
586
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
587 587
 						<th scope="row" class="titledesc">
588 588
 							<label
589
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
589
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
590 590
 						</th>
591
-						<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>">
591
+						<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>">
592 592
 							<fieldset>
593 593
 								<ul>
594 594
 									<?php
595
-									foreach ( $value['options'] as $key => $val ) {
595
+									foreach ($value['options'] as $key => $val) {
596 596
 										?>
597 597
 										<li>
598 598
 											<label><input
599
-														name="<?php echo esc_attr( $value['id'] ); ?>"
599
+														name="<?php echo esc_attr($value['id']); ?>"
600 600
 														value="<?php echo $key; ?>"
601 601
 														type="radio"
602
-														style="<?php echo esc_attr( $value['css'] ); ?>"
603
-													<?php echo implode( ' ', $custom_attributes ); ?>
604
-													<?php checked( $key, $option_value ); ?>
602
+														style="<?php echo esc_attr($value['css']); ?>"
603
+													<?php echo implode(' ', $custom_attributes); ?>
604
+													<?php checked($key, $option_value); ?>
605 605
 												/> <?php echo $val ?></label>
606 606
 										</li>
607 607
 										<?php
@@ -615,22 +615,22 @@  discard block
 block discarded – undo
615 615
 
616 616
 					// Checkbox input.
617 617
 					case 'checkbox' :
618
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
618
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
619 619
 						?>
620
-						<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
620
+						<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
621 621
 							<th scope="row" class="titledesc">
622 622
 								<label
623
-										for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
623
+										for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
624 624
 							</th>
625 625
 							<td class="give-forminp">
626 626
 								<input
627
-										name="<?php echo esc_attr( $value['id'] ); ?>"
628
-										id="<?php echo esc_attr( $value['id'] ); ?>"
627
+										name="<?php echo esc_attr($value['id']); ?>"
628
+										id="<?php echo esc_attr($value['id']); ?>"
629 629
 										type="checkbox"
630
-										class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>"
630
+										class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>"
631 631
 										value="1"
632
-									<?php checked( $option_value, 'on' ); ?>
633
-									<?php echo implode( ' ', $custom_attributes ); ?>
632
+									<?php checked($option_value, 'on'); ?>
633
+									<?php echo implode(' ', $custom_attributes); ?>
634 634
 								/>
635 635
 								<?php echo $description; ?>
636 636
 							</td>
@@ -640,29 +640,29 @@  discard block
 block discarded – undo
640 640
 
641 641
 					// Multi Checkbox input.
642 642
 					case 'multicheck' :
643
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
644
-						$option_value = is_array( $option_value ) ? $option_value : array();
643
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
644
+						$option_value = is_array($option_value) ? $option_value : array();
645 645
 						?>
646
-						<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
646
+						<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
647 647
 							<th scope="row" class="titledesc">
648 648
 								<label
649
-										for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
649
+										for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
650 650
 							</th>
651
-							<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>">
651
+							<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>">
652 652
 								<fieldset>
653 653
 									<ul>
654 654
 										<?php
655
-										foreach ( $value['options'] as $key => $val ) {
655
+										foreach ($value['options'] as $key => $val) {
656 656
 											?>
657 657
 											<li>
658 658
 												<label>
659 659
 													<input
660
-															name="<?php echo esc_attr( $value['id'] ); ?>[]"
660
+															name="<?php echo esc_attr($value['id']); ?>[]"
661 661
 															value="<?php echo $key; ?>"
662 662
 															type="checkbox"
663
-															style="<?php echo esc_attr( $value['css'] ); ?>"
664
-														<?php echo implode( ' ', $custom_attributes ); ?>
665
-														<?php if ( in_array( $key, $option_value ) ) {
663
+															style="<?php echo esc_attr($value['css']); ?>"
664
+														<?php echo implode(' ', $custom_attributes); ?>
665
+														<?php if (in_array($key, $option_value)) {
666 666
 															echo 'checked="checked"';
667 667
 														} ?>
668 668
 													/> <?php echo $val ?>
@@ -681,31 +681,31 @@  discard block
 block discarded – undo
681 681
 					// File input field.
682 682
 					case 'file' :
683 683
 					case 'media' :
684
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
685
-						$button_label = sprintf( __( 'Add or Upload %s', 'give' ), ( 'file' === $value['type'] ? __( 'File', 'give' ) : __( 'Image', 'give' ) ) );
686
-						$fvalue       = empty( $value['fvalue'] ) ? 'url' : $value['fvalue'];
687
-
688
-						$allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' );
689
-						$preview_image_src        = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : '';
690
-						$preview_image_extension  = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : '';
691
-						$is_show_preview          = in_array( $preview_image_extension, $allow_media_preview_tags );
684
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
685
+						$button_label = sprintf(__('Add or Upload %s', 'give'), ('file' === $value['type'] ? __('File', 'give') : __('Image', 'give')));
686
+						$fvalue       = empty($value['fvalue']) ? 'url' : $value['fvalue'];
687
+
688
+						$allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico');
689
+						$preview_image_src        = $option_value ? ('id' === $fvalue ? wp_get_attachment_url($option_value) : $option_value) : '';
690
+						$preview_image_extension  = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : '';
691
+						$is_show_preview          = in_array($preview_image_extension, $allow_media_preview_tags);
692 692
 						?>
693
-						<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
693
+						<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
694 694
 							<th scope="row" class="titledesc">
695 695
 								<label
696
-										for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
696
+										for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
697 697
 							</th>
698 698
 							<td class="give-forminp">
699 699
 								<div class="give-field-wrap">
700 700
 									<label for="<?php echo $value['id'] ?>">
701 701
 										<input
702
-												name="<?php echo esc_attr( $value['id'] ); ?>"
703
-												id="<?php echo esc_attr( $value['id'] ); ?>"
702
+												name="<?php echo esc_attr($value['id']); ?>"
703
+												id="<?php echo esc_attr($value['id']); ?>"
704 704
 												type="text"
705
-												class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>"
705
+												class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>"
706 706
 												value="<?php echo $option_value; ?>"
707
-												style="<?php echo esc_attr( $value['css'] ); ?>"
708
-											<?php echo implode( ' ', $custom_attributes ); ?>
707
+												style="<?php echo esc_attr($value['css']); ?>"
708
+											<?php echo implode(' ', $custom_attributes); ?>
709 709
 										/>&nbsp;&nbsp;&nbsp;&nbsp;<input class="give-upload-button button" type="button"
710 710
 												data-fvalue="<?php echo $fvalue; ?>"
711 711
 												data-field-type="<?php echo $value['type']; ?>"
@@ -726,18 +726,18 @@  discard block
 block discarded – undo
726 726
 					// WordPress Editor.
727 727
 					case 'wysiwyg' :
728 728
 						// Get option value.
729
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
729
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
730 730
 
731 731
 						// Get editor settings.
732
-						$editor_settings = ! empty( $value['options'] ) ? $value['options'] : array();
732
+						$editor_settings = ! empty($value['options']) ? $value['options'] : array();
733 733
 						?>
734
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
734
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
735 735
 						<th scope="row" class="titledesc">
736 736
 							<label
737
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
737
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
738 738
 						</th>
739 739
 						<td class="give-forminp">
740
-							<?php wp_editor( $option_value, $value['id'], $editor_settings ); ?>
740
+							<?php wp_editor($option_value, $value['id'], $editor_settings); ?>
741 741
 							<?php echo $description; ?>
742 742
 						</td>
743 743
 						</tr><?php
@@ -745,15 +745,15 @@  discard block
 block discarded – undo
745 745
 
746 746
 					// Custom: Default gateways setting field.
747 747
 					case 'default_gateway' :
748
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
748
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
749 749
 						?>
750
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
750
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
751 751
 						<th scope="row" class="titledesc">
752 752
 							<label
753
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
753
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
754 754
 						</th>
755 755
 						<td class="give-forminp">
756
-							<?php give_default_gateway_callback( $value, $option_value ); ?>
756
+							<?php give_default_gateway_callback($value, $option_value); ?>
757 757
 							<?php echo $description; ?>
758 758
 						</td>
759 759
 						</tr><?php
@@ -762,13 +762,13 @@  discard block
 block discarded – undo
762 762
 					// Custom: Email preview buttons field.
763 763
 					case 'email_preview_buttons' :
764 764
 						?>
765
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
765
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
766 766
 						<th scope="row" class="titledesc">
767 767
 							<label
768
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
768
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
769 769
 						</th>
770 770
 						<td class="give-forminp">
771
-							<?php give_email_preview_buttons_callback( $value ); ?>
771
+							<?php give_email_preview_buttons_callback($value); ?>
772 772
 							<?php echo $description; ?>
773 773
 						</td>
774 774
 						</tr><?php
@@ -782,23 +782,23 @@  discard block
 block discarded – undo
782 782
 
783 783
 					// Custom: Gateway API key.
784 784
 					case 'api_key' :
785
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
786
-						$type         = ! empty( $option_value ) ? 'password' : 'text';
785
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
786
+						$type         = ! empty($option_value) ? 'password' : 'text';
787 787
 						?>
788
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
788
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
789 789
 						<th scope="row" class="titledesc">
790 790
 							<label
791
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
791
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
792 792
 						</th>
793
-						<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
793
+						<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
794 794
 							<input
795
-									name="<?php echo esc_attr( $value['id'] ); ?>"
796
-									id="<?php echo esc_attr( $value['id'] ); ?>"
797
-									type="<?php echo esc_attr( $type ); ?>"
798
-									style="<?php echo esc_attr( $value['css'] ); ?>"
799
-									value="<?php echo esc_attr( trim( $option_value ) ); ?>"
800
-									class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>"
801
-								<?php echo implode( ' ', $custom_attributes ); ?>
795
+									name="<?php echo esc_attr($value['id']); ?>"
796
+									id="<?php echo esc_attr($value['id']); ?>"
797
+									type="<?php echo esc_attr($type); ?>"
798
+									style="<?php echo esc_attr($value['css']); ?>"
799
+									value="<?php echo esc_attr(trim($option_value)); ?>"
800
+									class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>"
801
+								<?php echo implode(' ', $custom_attributes); ?>
802 802
 							/> <?php echo $description; ?>
803 803
 						</td>
804 804
 						</tr><?php
@@ -808,54 +808,53 @@  discard block
 block discarded – undo
808 808
 					case 'chosen' :
809 809
 
810 810
 						// Get option value.
811
-						$option_value     = self::get_option( $option_name, $value['id'], $value['default'] );
812
-						$option_value     = is_array( $option_value ) ? array_fill_keys( $option_value, 'selected' ) : $option_value;
813
-						$wrapper_class    = ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '';
811
+						$option_value     = self::get_option($option_name, $value['id'], $value['default']);
812
+						$option_value     = is_array($option_value) ? array_fill_keys($option_value, 'selected') : $option_value;
813
+						$wrapper_class    = ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '';
814 814
 						$type             = '';
815 815
 						$allow_new_values = '';
816
-						$name             = give_get_field_name( $value );
816
+						$name             = give_get_field_name($value);
817 817
 
818 818
 						// Set attributes based on multiselect datatype.
819
-						if ( 'multiselect' === $value['data_type'] ) {
819
+						if ('multiselect' === $value['data_type']) {
820 820
 							$type             = 'multiple';
821 821
 							$allow_new_values = 'data-allows-new-values="true"';
822
-							$name             = $name . '[]';
823
-							$option_value     = empty( $option_value ) ? array() : $option_value;
822
+							$name             = $name.'[]';
823
+							$option_value     = empty($option_value) ? array() : $option_value;
824 824
 						}
825 825
 
826
-						$title_prefixes_value = ( is_array( $option_value ) && count( $option_value ) > 0 ) ?
827
-							array_merge( $value['options'], $option_value ) :
828
-							$value['options'];
826
+						$title_prefixes_value = (is_array($option_value) && count($option_value) > 0) ?
827
+							array_merge($value['options'], $option_value) : $value['options'];
829 828
 
830 829
 						?>
831 830
 						<tr valign="top" <?php echo $wrapper_class; ?>>
832 831
 							<th scope="row" class="titledesc">
833
-								<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_attr( self::get_field_title( $value ) ); ?></label>
832
+								<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_attr(self::get_field_title($value)); ?></label>
834 833
 							</th>
835
-							<td class="give-forminp give-forminp-<?php echo esc_attr( $value['type'] ); ?>">
834
+							<td class="give-forminp give-forminp-<?php echo esc_attr($value['type']); ?>">
836 835
 								<select
837 836
 										class="give-select-chosen give-chosen-settings"
838
-										style="<?php echo esc_attr( $value['style'] ); ?>"
839
-										name="<?php echo esc_attr( $name ); ?>"
840
-										id="<?php echo esc_attr( $value['id'] ); ?>"
837
+										style="<?php echo esc_attr($value['style']); ?>"
838
+										name="<?php echo esc_attr($name); ?>"
839
+										id="<?php echo esc_attr($value['id']); ?>"
841 840
 									<?php
842 841
 									echo "{$type} {$allow_new_values}";
843
-									echo implode( ' ', $custom_attributes );
842
+									echo implode(' ', $custom_attributes);
844 843
 									?>
845 844
 								>
846 845
 									<?php
847
-									if ( is_array( $title_prefixes_value ) && count( $title_prefixes_value ) > 0 ) {
848
-										foreach ( $title_prefixes_value as $key => $item_value ) {
846
+									if (is_array($title_prefixes_value) && count($title_prefixes_value) > 0) {
847
+										foreach ($title_prefixes_value as $key => $item_value) {
849 848
 											echo sprintf(
850 849
 												'<option %1$s value="%2$s">%2$s</option>',
851
-												( 'selected' === $item_value ) ? 'selected="selected"' : '',
852
-												esc_attr( $key )
850
+												('selected' === $item_value) ? 'selected="selected"' : '',
851
+												esc_attr($key)
853 852
 											);
854 853
 										}
855 854
 									}
856 855
 									?>
857 856
 								</select>
858
-								<?php echo wp_kses_post( $description ); ?>
857
+								<?php echo wp_kses_post($description); ?>
859 858
 							</td>
860 859
 						</tr>
861 860
 						<?php
@@ -872,7 +871,7 @@  discard block
 block discarded – undo
872 871
 						 *
873 872
 						 * @since 1.0
874 873
 						 */
875
-						do_action( "give_logs_view_{$current_section}" );
874
+						do_action("give_logs_view_{$current_section}");
876 875
 
877 876
 						echo $description;
878 877
 						break;
@@ -880,24 +879,24 @@  discard block
 block discarded – undo
880 879
 					// Custom: Data field.
881 880
 					case 'data' :
882 881
 
883
-						include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php';
882
+						include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php';
884 883
 
885 884
 						echo $description;
886 885
 						break;
887 886
 
888 887
 					// Custom: Give Docs Link field type.
889 888
 					case 'give_docs_link' :
890
-						$wrapper_class = ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '';
889
+						$wrapper_class = ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '';
891 890
 						?>
892
-					<tr valign="top" <?php echo esc_html( $wrapper_class ); ?>>
891
+					<tr valign="top" <?php echo esc_html($wrapper_class); ?>>
893 892
 						<td class="give-docs-link" colspan="2">
894 893
 							<p class="give-docs-link">
895
-								<a href="<?php echo esc_url( $value['url'] ); ?>" target="_blank">
894
+								<a href="<?php echo esc_url($value['url']); ?>" target="_blank">
896 895
 									<?php
897 896
 									echo sprintf(
898 897
 										/* translators: %s Title */
899
-										esc_html__( 'Need Help? See docs on "%s"', 'give' ),
900
-										esc_html( $value['title'] )
898
+										esc_html__('Need Help? See docs on "%s"', 'give'),
899
+										esc_html($value['title'])
901 900
 									);
902 901
 									?>
903 902
 									<span class="dashicons dashicons-editor-help"></span>
@@ -911,8 +910,8 @@  discard block
 block discarded – undo
911 910
 					// You can add or handle your custom field action.
912 911
 					default:
913 912
 						// Get option value.
914
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
915
-						do_action( 'give_admin_field_' . $value['type'], $value, $option_value );
913
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
914
+						do_action('give_admin_field_'.$value['type'], $value, $option_value);
916 915
 						break;
917 916
 				}
918 917
 			}
@@ -928,15 +927,15 @@  discard block
 block discarded – undo
928 927
 		 *
929 928
 		 * @return string The HTML description of the field.
930 929
 		 */
931
-		public static function get_field_description( $value ) {
930
+		public static function get_field_description($value) {
932 931
 			$description = '';
933 932
 
934 933
 			// Support for both 'description' and 'desc' args.
935
-			$description_key = isset( $value['description'] ) ? 'description' : 'desc';
936
-			$value           = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : '';
934
+			$description_key = isset($value['description']) ? 'description' : 'desc';
935
+			$value           = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : '';
937 936
 
938
-			if ( ! empty( $value ) ) {
939
-				$description = '<div class="give-field-description">' . wp_kses_post( $value ) . '</div>';
937
+			if ( ! empty($value)) {
938
+				$description = '<div class="give-field-description">'.wp_kses_post($value).'</div>';
940 939
 			}
941 940
 
942 941
 			return $description;
@@ -953,11 +952,11 @@  discard block
 block discarded – undo
953 952
 		 *
954 953
 		 * @return array The description and tip as a 2 element array
955 954
 		 */
956
-		public static function get_field_title( $value ) {
957
-			$title = esc_html( $value['title'] );
955
+		public static function get_field_title($value) {
956
+			$title = esc_html($value['title']);
958 957
 
959 958
 			// If html tag detected then allow them to print.
960
-			if ( strip_tags( $title ) ) {
959
+			if (strip_tags($title)) {
961 960
 				$title = $value['title'];
962 961
 			}
963 962
 
@@ -976,8 +975,8 @@  discard block
 block discarded – undo
976 975
 		 *
977 976
 		 * @return bool
978 977
 		 */
979
-		public static function save_fields( $options, $option_name = '' ) {
980
-			if ( empty( $_POST ) ) {
978
+		public static function save_fields($options, $option_name = '') {
979
+			if (empty($_POST)) {
981 980
 				return false;
982 981
 			}
983 982
 
@@ -985,38 +984,38 @@  discard block
 block discarded – undo
985 984
 			$update_options = array();
986 985
 
987 986
 			// Loop options and get values to save.
988
-			foreach ( $options as $option ) {
989
-				if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) {
987
+			foreach ($options as $option) {
988
+				if ( ! isset($option['id']) || ! isset($option['type'])) {
990 989
 					continue;
991 990
 				}
992 991
 
993 992
 				// Get posted value.
994
-				if ( strstr( $option['id'], '[' ) ) {
995
-					parse_str( $option['id'], $option_name_array );
996
-					$field_option_name = current( array_keys( $option_name_array ) );
997
-					$setting_name      = key( $option_name_array[ $field_option_name ] );
998
-					$raw_value         = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null;
993
+				if (strstr($option['id'], '[')) {
994
+					parse_str($option['id'], $option_name_array);
995
+					$field_option_name = current(array_keys($option_name_array));
996
+					$setting_name      = key($option_name_array[$field_option_name]);
997
+					$raw_value         = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null;
999 998
 				} else {
1000 999
 					$field_option_name = $option['id'];
1001 1000
 					$setting_name      = '';
1002
-					$raw_value         = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null;
1001
+					$raw_value         = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null;
1003 1002
 				}
1004 1003
 
1005 1004
 				// Format the value based on option type.
1006
-				switch ( $option['type'] ) {
1005
+				switch ($option['type']) {
1007 1006
 					case 'checkbox' :
1008
-						$value = is_null( $raw_value ) ? '' : 'on';
1007
+						$value = is_null($raw_value) ? '' : 'on';
1009 1008
 						break;
1010 1009
 					case 'wysiwyg'  :
1011 1010
 					case 'textarea' :
1012
-						$value = wp_kses_post( trim( $raw_value ) );
1011
+						$value = wp_kses_post(trim($raw_value));
1013 1012
 						break;
1014 1013
 					case 'multiselect' :
1015 1014
 					case 'chosen' :
1016
-						$value = array_filter( array_map( 'give_clean', (array) $raw_value ) );
1015
+						$value = array_filter(array_map('give_clean', (array) $raw_value));
1017 1016
 						break;
1018 1017
 					default :
1019
-						$value = give_clean( $raw_value );
1018
+						$value = give_clean($raw_value);
1020 1019
 						break;
1021 1020
 				}
1022 1021
 
@@ -1025,37 +1024,37 @@  discard block
 block discarded – undo
1025 1024
 				 *
1026 1025
 				 * @since 1.8
1027 1026
 				 */
1028
-				$value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value );
1027
+				$value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value);
1029 1028
 
1030 1029
 				/**
1031 1030
 				 * Sanitize the value of an option by option name.
1032 1031
 				 *
1033 1032
 				 * @since 1.8
1034 1033
 				 */
1035
-				$value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value );
1034
+				$value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value);
1036 1035
 
1037
-				if ( is_null( $value ) ) {
1036
+				if (is_null($value)) {
1038 1037
 					continue;
1039 1038
 				}
1040 1039
 
1041 1040
 				// Check if option is an array and handle that differently to single values.
1042
-				if ( $field_option_name && $setting_name ) {
1043
-					if ( ! isset( $update_options[ $field_option_name ] ) ) {
1044
-						$update_options[ $field_option_name ] = get_option( $field_option_name, array() );
1041
+				if ($field_option_name && $setting_name) {
1042
+					if ( ! isset($update_options[$field_option_name])) {
1043
+						$update_options[$field_option_name] = get_option($field_option_name, array());
1045 1044
 					}
1046
-					if ( ! is_array( $update_options[ $field_option_name ] ) ) {
1047
-						$update_options[ $field_option_name ] = array();
1045
+					if ( ! is_array($update_options[$field_option_name])) {
1046
+						$update_options[$field_option_name] = array();
1048 1047
 					}
1049
-					$update_options[ $field_option_name ][ $setting_name ] = $value;
1048
+					$update_options[$field_option_name][$setting_name] = $value;
1050 1049
 				} else {
1051
-					$update_options[ $field_option_name ] = $value;
1050
+					$update_options[$field_option_name] = $value;
1052 1051
 				}
1053 1052
 			}
1054 1053
 
1055 1054
 			// Save all options in our array or there own option name i.e. option id.
1056
-			if ( empty( $option_name ) ) {
1057
-				foreach ( $update_options as $name => $value ) {
1058
-					update_option( $name, $value, false );
1055
+			if (empty($option_name)) {
1056
+				foreach ($update_options as $name => $value) {
1057
+					update_option($name, $value, false);
1059 1058
 
1060 1059
 					/**
1061 1060
 					 * Trigger action.
@@ -1064,13 +1063,13 @@  discard block
 block discarded – undo
1064 1063
 					 *
1065 1064
 					 * @since 1.8
1066 1065
 					 */
1067
-					do_action( "give_save_option_{$name}", $value, $name );
1066
+					do_action("give_save_option_{$name}", $value, $name);
1068 1067
 				}
1069 1068
 			} else {
1070
-				$old_options    = ( $old_options = get_option( $option_name ) ) ? $old_options : array();
1071
-				$update_options = array_merge( $old_options, $update_options );
1069
+				$old_options    = ($old_options = get_option($option_name)) ? $old_options : array();
1070
+				$update_options = array_merge($old_options, $update_options);
1072 1071
 
1073
-				update_option( $option_name, $update_options, false );
1072
+				update_option($option_name, $update_options, false);
1074 1073
 
1075 1074
 				/**
1076 1075
 				 * Trigger action.
@@ -1079,7 +1078,7 @@  discard block
 block discarded – undo
1079 1078
 				 *
1080 1079
 				 * @since 1.8
1081 1080
 				 */
1082
-				do_action( "give_save_settings_{$option_name}", $update_options, $option_name, $old_options );
1081
+				do_action("give_save_settings_{$option_name}", $update_options, $option_name, $old_options);
1083 1082
 			}
1084 1083
 
1085 1084
 			return true;
@@ -1108,21 +1107,21 @@  discard block
 block discarded – undo
1108 1107
 		 *
1109 1108
 		 * @return bool
1110 1109
 		 */
1111
-		public static function is_setting_page( $tab = '', $section = '' ) {
1110
+		public static function is_setting_page($tab = '', $section = '') {
1112 1111
 			$is_setting_page = false;
1113 1112
 
1114
-			if( ! is_admin() ) {
1113
+			if ( ! is_admin()) {
1115 1114
 				return $is_setting_page;
1116 1115
 			}
1117 1116
 
1118 1117
 			// Check fo setting tab.
1119
-			if ( ! empty( $tab ) ) {
1120
-				$is_setting_page = ( $tab === give_get_current_setting_tab() );
1118
+			if ( ! empty($tab)) {
1119
+				$is_setting_page = ($tab === give_get_current_setting_tab());
1121 1120
 			}
1122 1121
 
1123 1122
 			// Check fo setting section.
1124
-			if ( ! empty( $section ) ) {
1125
-				$is_setting_page = ( $section === give_get_current_setting_section() );
1123
+			if ( ! empty($section)) {
1124
+				$is_setting_page = ($section === give_get_current_setting_section());
1126 1125
 			}
1127 1126
 
1128 1127
 			return $is_setting_page;
Please login to merge, or discard this patch.
includes/admin/forms/class-give-form-duplicator.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       2.2.0
10 10
  */
11 11
 
12
-if ( ! class_exists( 'Give_Form_Duplicator' ) ) {
12
+if ( ! class_exists('Give_Form_Duplicator')) {
13 13
 
14 14
 	/**
15 15
 	 * Give_Form_Duplicator class
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 		public function __construct() {
23 23
 
24 24
 			// Add the 'Clone Form' to Row Actions.
25
-			add_filter( 'post_row_actions', array( $this, 'row_action' ), 10, 2 );
25
+			add_filter('post_row_actions', array($this, 'row_action'), 10, 2);
26 26
 
27 27
 			// Run admin_action hook.
28
-			add_action( 'admin_action_give_duplicate_form', array( $this, 'handler' ) );
28
+			add_action('admin_action_give_duplicate_form', array($this, 'handler'));
29 29
 		}
30 30
 
31 31
 
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
 		 *
40 40
 		 * @return array
41 41
 		 */
42
-		public function row_action( $actions, $post ) {
42
+		public function row_action($actions, $post) {
43 43
 
44 44
 			// @codingStandardsIgnoreStart
45 45
 
46
-			if ( isset( $_GET['post_type'] ) && 'give_forms' === give_clean( $_GET['post_type'] ) ) { // WPCS: input var ok.
47
-				if ( current_user_can( 'edit_posts' ) ) {
46
+			if (isset($_GET['post_type']) && 'give_forms' === give_clean($_GET['post_type'])) { // WPCS: input var ok.
47
+				if (current_user_can('edit_posts')) {
48 48
 					$actions['duplicate_form'] = sprintf(
49 49
 						'<a href="%1$s">%2$s</a>',
50
-						wp_nonce_url( add_query_arg(
50
+						wp_nonce_url(add_query_arg(
51 51
 							array(
52 52
 								'action'  => 'give_duplicate_form',
53 53
 								'form_id' => $post->ID,
54 54
 							),
55
-							admin_url( 'admin.php' )
56
-						), 'give-duplicate-form' ),
57
-						__( 'Duplicate', 'give' )
55
+							admin_url('admin.php')
56
+						), 'give-duplicate-form'),
57
+						__('Duplicate', 'give')
58 58
 					);
59 59
 				}
60 60
 			}
@@ -76,28 +76,28 @@  discard block
 block discarded – undo
76 76
 			// Validate action.
77 77
 			// @codingStandardsIgnoreStart
78 78
 			if (
79
-				! isset( $_REQUEST['form_id'] )
80
-				|| ! isset( $_REQUEST['action'] )
81
-				|| ( 'give_duplicate_form' !== $_REQUEST['action'] )
79
+				! isset($_REQUEST['form_id'])
80
+				|| ! isset($_REQUEST['action'])
81
+				|| ('give_duplicate_form' !== $_REQUEST['action'])
82 82
 			) {
83
-				wp_die( esc_html__( 'Form ID not found in the query string', 'give' ) );
83
+				wp_die(esc_html__('Form ID not found in the query string', 'give'));
84 84
 
85
-			} elseif ( ! wp_verify_nonce( give_clean( $_REQUEST['_wpnonce'] ), 'give-duplicate-form' ) ) {
85
+			} elseif ( ! wp_verify_nonce(give_clean($_REQUEST['_wpnonce']), 'give-duplicate-form')) {
86 86
 
87
-				wp_die( esc_html__( 'Nonce verification failed', 'give' ) );
87
+				wp_die(esc_html__('Nonce verification failed', 'give'));
88 88
 			}
89 89
 			// @codingStandardsIgnoreEnd
90 90
 
91
-			$form_id      = give_clean( $_REQUEST['form_id'] ); // @codingStandardsIgnoreLine
92
-			$post_data    = get_post( $form_id );
91
+			$form_id      = give_clean($_REQUEST['form_id']); // @codingStandardsIgnoreLine
92
+			$post_data    = get_post($form_id);
93 93
 			$current_user = wp_get_current_user();
94 94
 			$error_notice = sprintf(
95 95
 				/* translators: %s: Form ID */
96
-				esc_html__( 'Cloning failed. Form with ID %s does not exist.', 'give' ),
97
-				absint( $form_id )
96
+				esc_html__('Cloning failed. Form with ID %s does not exist.', 'give'),
97
+				absint($form_id)
98 98
 			);
99 99
 
100
-			if ( isset( $post_data ) && null !== $post_data ) {
100
+			if (isset($post_data) && null !== $post_data) {
101 101
 
102 102
 				$args = array(
103 103
 					'comment_status' => $post_data->comment_status,
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 				);
117 117
 
118 118
 				// Get the ID of the cloned post.
119
-				$duplicate_form_id = wp_insert_post( $args );
119
+				$duplicate_form_id = wp_insert_post($args);
120 120
 
121
-				$this->duplicate_taxonomies( $duplicate_form_id, $post_data );
122
-				$this->duplicate_meta_data( $duplicate_form_id, $post_data );
123
-				$this->reset_stats( $duplicate_form_id );
121
+				$this->duplicate_taxonomies($duplicate_form_id, $post_data);
122
+				$this->duplicate_meta_data($duplicate_form_id, $post_data);
123
+				$this->reset_stats($duplicate_form_id);
124 124
 
125 125
 				/**
126 126
 				 * Fire the action
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 				 * @param int $duplicate_form_id Duplicated form ID.
131 131
 				 * @param int $form_id           Form ID.
132 132
 				 */
133
-				do_action( 'give_form_duplicated', $duplicate_form_id, $form_id );
133
+				do_action('give_form_duplicated', $duplicate_form_id, $form_id);
134 134
 
135
-				if ( ! is_wp_error( $duplicate_form_id ) ) {
135
+				if ( ! is_wp_error($duplicate_form_id)) {
136 136
 					// Redirect to the cloned form editor page.
137 137
 					wp_safe_redirect(
138 138
 						add_query_arg(
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
 								'action' => 'edit',
141 141
 								'post'   => $duplicate_form_id,
142 142
 							),
143
-							admin_url( 'post.php' )
143
+							admin_url('post.php')
144 144
 						)
145 145
 					);
146 146
 				} else {
147
-					wp_die( $error_notice ); // @codingStandardsIgnoreLine
147
+					wp_die($error_notice); // @codingStandardsIgnoreLine
148 148
 				}
149 149
 
150 150
 				exit;
151 151
 
152 152
 			} else {
153 153
 
154
-				wp_die( $error_notice ); // @codingStandardsIgnoreLine
154
+				wp_die($error_notice); // @codingStandardsIgnoreLine
155 155
 			}
156 156
 		}
157 157
 
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 		 * @param int     $new_form_id New form ID.
166 166
 		 * @param WP_Post $old_form    Old form object.
167 167
 		 */
168
-		private function duplicate_taxonomies( $new_form_id, $old_form ) {
168
+		private function duplicate_taxonomies($new_form_id, $old_form) {
169 169
 			// Get the taxonomies of the post type `give_forms`.
170
-			$taxonomies = get_object_taxonomies( $old_form->post_type );
170
+			$taxonomies = get_object_taxonomies($old_form->post_type);
171 171
 
172
-			foreach ( $taxonomies as $taxonomy ) {
172
+			foreach ($taxonomies as $taxonomy) {
173 173
 
174 174
 				$post_terms = wp_get_object_terms(
175 175
 					$old_form->ID,
@@ -198,28 +198,28 @@  discard block
 block discarded – undo
198 198
 		 * @param int     $new_form_id New Form ID.
199 199
 		 * @param WP_Post $old_form    Old form object.
200 200
 		 */
201
-		private function duplicate_meta_data( $new_form_id, $old_form ) {
201
+		private function duplicate_meta_data($new_form_id, $old_form) {
202 202
 			global $wpdb;
203 203
 
204 204
 			// Clone the metadata of the form.
205
-			$post_meta_query = $wpdb->prepare( "SELECT meta_key, meta_value FROM {$wpdb->formmeta} WHERE form_id=%s", $old_form->ID );
205
+			$post_meta_query = $wpdb->prepare("SELECT meta_key, meta_value FROM {$wpdb->formmeta} WHERE form_id=%s", $old_form->ID);
206 206
 
207
-			$post_meta_data = $wpdb->get_results( $post_meta_query ); // WPCS: db call ok. WPCS: cache ok. WPCS: unprepared SQL OK.
207
+			$post_meta_data = $wpdb->get_results($post_meta_query); // WPCS: db call ok. WPCS: cache ok. WPCS: unprepared SQL OK.
208 208
 
209
-			if ( ! empty( $post_meta_data ) ) {
209
+			if ( ! empty($post_meta_data)) {
210 210
 
211 211
 				$duplicate_query        = "INSERT INTO {$wpdb->formmeta} (form_id, meta_key, meta_value) ";
212 212
 				$duplicate_query_select = array();
213 213
 
214
-				foreach ( $post_meta_data as $meta_data ) {
214
+				foreach ($post_meta_data as $meta_data) {
215 215
 					$meta_key                 = $meta_data->meta_key;
216 216
 					$meta_value               = $meta_data->meta_value;
217
-					$duplicate_query_select[] = $wpdb->prepare( 'SELECT %s, %s, %s', $new_form_id, $meta_key, $meta_value );
217
+					$duplicate_query_select[] = $wpdb->prepare('SELECT %s, %s, %s', $new_form_id, $meta_key, $meta_value);
218 218
 				}
219 219
 
220
-				$duplicate_query .= implode( ' UNION ALL ', $duplicate_query_select );
220
+				$duplicate_query .= implode(' UNION ALL ', $duplicate_query_select);
221 221
 
222
-				$wpdb->query( $duplicate_query ); // WPCS: db call ok. WPCS: cache ok. WPCS: unprepared SQL OK.
222
+				$wpdb->query($duplicate_query); // WPCS: db call ok. WPCS: cache ok. WPCS: unprepared SQL OK.
223 223
 			}
224 224
 		}
225 225
 
@@ -231,18 +231,18 @@  discard block
 block discarded – undo
231 231
 		 *
232 232
 		 * @param int $new_form_id New Form ID.
233 233
 		 */
234
-		private function reset_stats( $new_form_id ) {
234
+		private function reset_stats($new_form_id) {
235 235
 			global $wpdb;
236 236
 
237
-			$meta_keys = array( '_give_form_sales', '_give_form_earnings' );
237
+			$meta_keys = array('_give_form_sales', '_give_form_earnings');
238 238
 
239 239
 			/**
240 240
 			 * Fire the filter
241 241
 			 *
242 242
 			 * @since  2.2.0
243 243
 			 */
244
-			$meta_keys = apply_filters( 'give_duplicate_form_reset_stat_meta_keys', $meta_keys );
245
-			$meta_keys = 'meta_key=\'' . implode( '\' OR meta_key=\'', $meta_keys ) . '\'';
244
+			$meta_keys = apply_filters('give_duplicate_form_reset_stat_meta_keys', $meta_keys);
245
+			$meta_keys = 'meta_key=\''.implode('\' OR meta_key=\'', $meta_keys).'\'';
246 246
 
247 247
 			$wpdb->query(
248 248
 				$wpdb->prepare(
Please login to merge, or discard this patch.
includes/admin/forms/class-metabox-form-data.php 2 patches
Spacing   +349 added lines, -353 removed lines patch added patch discarded remove patch
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	function __construct() {
48 48
 		$this->metabox_id    = 'give-metabox-form-data';
49
-		$this->metabox_label = __( 'Donation Form Options', 'give' );
49
+		$this->metabox_label = __('Donation Form Options', 'give');
50 50
 
51 51
 		// Setup.
52
-		add_action( 'admin_init', array( $this, 'setup' ) );
52
+		add_action('admin_init', array($this, 'setup'));
53 53
 
54 54
 		// Add metabox.
55
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 10 );
55
+		add_action('add_meta_boxes', array($this, 'add_meta_box'), 10);
56 56
 
57 57
 		// Save form meta.
58
-		add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 );
58
+		add_action('save_post_give_forms', array($this, 'save'), 10, 2);
59 59
 
60 60
 		// cmb2 old setting loaders.
61 61
 		// add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) );
62 62
 		// Add offline donations options.
63
-		add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 );
63
+		add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1);
64 64
 
65 65
 		// Maintain active tab query parameter after save.
66
-		add_filter( 'redirect_post_location', array( $this, 'maintain_active_tab' ), 10, 2 );
66
+		add_filter('redirect_post_location', array($this, 'maintain_active_tab'), 10, 2);
67 67
 	}
68 68
 
69 69
 	/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	function get_settings() {
89 89
 		$post_id           = give_get_admin_post_id();
90
-		$price_placeholder = give_format_decimal( '1.00', false, false );
90
+		$price_placeholder = give_format_decimal('1.00', false, false);
91 91
 
92 92
 		// Start with an underscore to hide fields from custom fields list
93 93
 		$prefix = '_give_';
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
 			/**
97 97
 			 * Repeatable Field Groups
98 98
 			 */
99
-			'form_field_options'    => apply_filters( 'give_forms_field_options', array(
99
+			'form_field_options'    => apply_filters('give_forms_field_options', array(
100 100
 				'id'        => 'form_field_options',
101
-				'title'     => __( 'Donation Options', 'give' ),
101
+				'title'     => __('Donation Options', 'give'),
102 102
 				'icon-html' => '<span class="give-icon give-icon-heart"></span>',
103
-				'fields'    => apply_filters( 'give_forms_donation_form_metabox_fields', array(
103
+				'fields'    => apply_filters('give_forms_donation_form_metabox_fields', array(
104 104
 					// Donation Option.
105 105
 					array(
106
-						'name'        => __( 'Donation Option', 'give' ),
107
-						'description' => __( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ),
108
-						'id'          => $prefix . 'price_option',
106
+						'name'        => __('Donation Option', 'give'),
107
+						'description' => __('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'),
108
+						'id'          => $prefix.'price_option',
109 109
 						'type'        => 'radio_inline',
110 110
 						'default'     => 'multi',
111
-						'options'     => apply_filters( 'give_forms_price_options', array(
112
-							'multi' => __( 'Multi-level Donation', 'give' ),
113
-							'set'   => __( 'Set Donation', 'give' ),
114
-						) ),
111
+						'options'     => apply_filters('give_forms_price_options', array(
112
+							'multi' => __('Multi-level Donation', 'give'),
113
+							'set'   => __('Set Donation', 'give'),
114
+						)),
115 115
 					),
116 116
 					array(
117
-						'name'        => __( 'Set Donation', 'give' ),
118
-						'description' => __( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ),
119
-						'id'          => $prefix . 'set_price',
117
+						'name'        => __('Set Donation', 'give'),
118
+						'description' => __('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'),
119
+						'id'          => $prefix.'set_price',
120 120
 						'type'        => 'text_small',
121 121
 						'data_type'   => 'price',
122 122
 						'attributes'  => array(
@@ -126,34 +126,34 @@  discard block
 block discarded – undo
126 126
 					),
127 127
 					// Display Style.
128 128
 					array(
129
-						'name'          => __( 'Display Style', 'give' ),
130
-						'description'   => __( 'Set how the donations levels will display on the form.', 'give' ),
131
-						'id'            => $prefix . 'display_style',
129
+						'name'          => __('Display Style', 'give'),
130
+						'description'   => __('Set how the donations levels will display on the form.', 'give'),
131
+						'id'            => $prefix.'display_style',
132 132
 						'type'          => 'radio_inline',
133 133
 						'default'       => 'buttons',
134 134
 						'options'       => array(
135
-							'buttons'  => __( 'Buttons', 'give' ),
136
-							'radios'   => __( 'Radios', 'give' ),
137
-							'dropdown' => __( 'Dropdown', 'give' ),
135
+							'buttons'  => __('Buttons', 'give'),
136
+							'radios'   => __('Radios', 'give'),
137
+							'dropdown' => __('Dropdown', 'give'),
138 138
 						),
139 139
 						'wrapper_class' => 'give-hidden',
140 140
 					),
141 141
 					// Custom Amount.
142 142
 					array(
143
-						'name'        => __( 'Custom Amount', 'give' ),
144
-						'description' => __( 'Do you want the user to be able to input their own donation amount?', 'give' ),
145
-						'id'          => $prefix . 'custom_amount',
143
+						'name'        => __('Custom Amount', 'give'),
144
+						'description' => __('Do you want the user to be able to input their own donation amount?', 'give'),
145
+						'id'          => $prefix.'custom_amount',
146 146
 						'type'        => 'radio_inline',
147 147
 						'default'     => 'disabled',
148 148
 						'options'     => array(
149
-							'enabled'  => __( 'Enabled', 'give' ),
150
-							'disabled' => __( 'Disabled', 'give' ),
149
+							'enabled'  => __('Enabled', 'give'),
150
+							'disabled' => __('Disabled', 'give'),
151 151
 						),
152 152
 					),
153 153
 					array(
154
-						'name'          => __( 'Donation Limit', 'give' ),
155
-						'description'   => __( 'Set the minimum and maximum amount for all gateways.', 'give' ),
156
-						'id'            => $prefix . 'custom_amount_range',
154
+						'name'          => __('Donation Limit', 'give'),
155
+						'description'   => __('Set the minimum and maximum amount for all gateways.', 'give'),
156
+						'id'            => $prefix.'custom_amount_range',
157 157
 						'type'          => 'donation_limit',
158 158
 						'wrapper_class' => 'give-hidden',
159 159
 						'data_type'     => 'price',
@@ -162,43 +162,43 @@  discard block
 block discarded – undo
162 162
 							'class'       => 'give-money-field',
163 163
 						),
164 164
 						'options'       => array(
165
-							'display_label' => __( 'Donation Limits: ', 'give' ),
166
-							'minimum'       => give_format_decimal( '1.00', false, false ),
167
-							'maximum'       => give_format_decimal( '999999.99', false, false ),
165
+							'display_label' => __('Donation Limits: ', 'give'),
166
+							'minimum'       => give_format_decimal('1.00', false, false),
167
+							'maximum'       => give_format_decimal('999999.99', false, false),
168 168
 						),
169 169
 					),
170 170
 					array(
171
-						'name'          => __( 'Custom Amount Text', 'give' ),
172
-						'description'   => __( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ),
173
-						'id'            => $prefix . 'custom_amount_text',
171
+						'name'          => __('Custom Amount Text', 'give'),
172
+						'description'   => __('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'),
173
+						'id'            => $prefix.'custom_amount_text',
174 174
 						'type'          => 'text_medium',
175 175
 						'attributes'    => array(
176 176
 							'rows'        => 3,
177
-							'placeholder' => __( 'Give a Custom Amount', 'give' ),
177
+							'placeholder' => __('Give a Custom Amount', 'give'),
178 178
 						),
179 179
 						'wrapper_class' => 'give-hidden',
180 180
 					),
181 181
 					// Donation Levels.
182 182
 					array(
183
-						'id'            => $prefix . 'donation_levels',
183
+						'id'            => $prefix.'donation_levels',
184 184
 						'type'          => 'group',
185 185
 						'options'       => array(
186
-							'add_button'    => __( 'Add Level', 'give' ),
187
-							'header_title'  => __( 'Donation Level', 'give' ),
186
+							'add_button'    => __('Add Level', 'give'),
187
+							'header_title'  => __('Donation Level', 'give'),
188 188
 							'remove_button' => '<span class="dashicons dashicons-no"></span>',
189 189
 						),
190 190
 						'wrapper_class' => 'give-hidden',
191 191
 						// Fields array works the same, except id's only need to be unique for this group.
192 192
 						// Prefix is not needed.
193
-						'fields'        => apply_filters( 'give_donation_levels_table_row', array(
193
+						'fields'        => apply_filters('give_donation_levels_table_row', array(
194 194
 							array(
195
-								'name' => __( 'ID', 'give' ),
196
-								'id'   => $prefix . 'id',
195
+								'name' => __('ID', 'give'),
196
+								'id'   => $prefix.'id',
197 197
 								'type' => 'levels_id',
198 198
 							),
199 199
 							array(
200
-								'name'       => __( 'Amount', 'give' ),
201
-								'id'         => $prefix . 'amount',
200
+								'name'       => __('Amount', 'give'),
201
+								'id'         => $prefix.'amount',
202 202
 								'type'       => 'text_small',
203 203
 								'data_type'  => 'price',
204 204
 								'attributes' => array(
@@ -207,95 +207,95 @@  discard block
 block discarded – undo
207 207
 								),
208 208
 							),
209 209
 							array(
210
-								'name'       => __( 'Text', 'give' ),
211
-								'id'         => $prefix . 'text',
210
+								'name'       => __('Text', 'give'),
211
+								'id'         => $prefix.'text',
212 212
 								'type'       => 'text',
213 213
 								'attributes' => array(
214
-									'placeholder' => __( 'Donation Level', 'give' ),
214
+									'placeholder' => __('Donation Level', 'give'),
215 215
 									'class'       => 'give-multilevel-text-field',
216 216
 								),
217 217
 							),
218 218
 							array(
219
-								'name' => __( 'Default', 'give' ),
220
-								'id'   => $prefix . 'default',
219
+								'name' => __('Default', 'give'),
220
+								'id'   => $prefix.'default',
221 221
 								'type' => 'give_default_radio_inline',
222 222
 							),
223
-						) ),
223
+						)),
224 224
 					),
225 225
 					array(
226 226
 						'name'  => 'donation_options_docs',
227 227
 						'type'  => 'docs_link',
228 228
 						'url'   => 'http://docs.givewp.com/form-donation-options',
229
-						'title' => __( 'Donation Options', 'give' ),
229
+						'title' => __('Donation Options', 'give'),
230 230
 					),
231 231
 				),
232 232
 					$post_id
233 233
 				),
234
-			) ),
234
+			)),
235 235
 
236 236
 			/**
237 237
 			 * Display Options
238 238
 			 */
239
-			'form_display_options'  => apply_filters( 'give_form_display_options', array(
239
+			'form_display_options'  => apply_filters('give_form_display_options', array(
240 240
 					'id'        => 'form_display_options',
241
-					'title'     => __( 'Form Display', 'give' ),
241
+					'title'     => __('Form Display', 'give'),
242 242
 					'icon-html' => '<span class="give-icon give-icon-display"></span>',
243
-					'fields'    => apply_filters( 'give_forms_display_options_metabox_fields', array(
243
+					'fields'    => apply_filters('give_forms_display_options_metabox_fields', array(
244 244
 						array(
245
-							'name'    => __( 'Display Options', 'give' ),
246
-							'desc'    => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ),
247
-							'id'      => $prefix . 'payment_display',
245
+							'name'    => __('Display Options', 'give'),
246
+							'desc'    => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'),
247
+							'id'      => $prefix.'payment_display',
248 248
 							'type'    => 'radio_inline',
249 249
 							'options' => array(
250
-								'onpage' => __( 'All Fields', 'give' ),
251
-								'modal'  => __( 'Modal', 'give' ),
252
-								'reveal' => __( 'Reveal', 'give' ),
253
-								'button' => __( 'Button', 'give' ),
250
+								'onpage' => __('All Fields', 'give'),
251
+								'modal'  => __('Modal', 'give'),
252
+								'reveal' => __('Reveal', 'give'),
253
+								'button' => __('Button', 'give'),
254 254
 							),
255 255
 							'default' => 'onpage',
256 256
 						),
257 257
 						array(
258
-							'id'            => $prefix . 'reveal_label',
259
-							'name'          => __( 'Continue Button', 'give' ),
260
-							'desc'          => __( 'The button label for displaying the additional payment fields.', 'give' ),
258
+							'id'            => $prefix.'reveal_label',
259
+							'name'          => __('Continue Button', 'give'),
260
+							'desc'          => __('The button label for displaying the additional payment fields.', 'give'),
261 261
 							'type'          => 'text_small',
262 262
 							'attributes'    => array(
263
-								'placeholder' => __( 'Donate Now', 'give' ),
263
+								'placeholder' => __('Donate Now', 'give'),
264 264
 							),
265 265
 							'wrapper_class' => 'give-hidden',
266 266
 						),
267 267
 						array(
268
-							'id'         => $prefix . 'checkout_label',
269
-							'name'       => __( 'Submit Button', 'give' ),
270
-							'desc'       => __( 'The button label for completing a donation.', 'give' ),
268
+							'id'         => $prefix.'checkout_label',
269
+							'name'       => __('Submit Button', 'give'),
270
+							'desc'       => __('The button label for completing a donation.', 'give'),
271 271
 							'type'       => 'text_small',
272 272
 							'attributes' => array(
273
-								'placeholder' => __( 'Donate Now', 'give' ),
273
+								'placeholder' => __('Donate Now', 'give'),
274 274
 							),
275 275
 						),
276 276
 						array(
277
-							'name' => __( 'Default Gateway', 'give' ),
278
-							'desc' => __( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ),
279
-							'id'   => $prefix . 'default_gateway',
277
+							'name' => __('Default Gateway', 'give'),
278
+							'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'),
279
+							'id'   => $prefix.'default_gateway',
280 280
 							'type' => 'default_gateway',
281 281
 						),
282 282
 						array(
283
-							'name'    => __( 'Name Title Prefix', 'give' ),
284
-							'desc'    => __( 'Do you want to add a name title prefix dropdown field before the donor\'s first name field? This will display a dropdown with options such as Mrs, Miss, Ms, Sir, and Dr for donor to choose from.', 'give' ),
285
-							'id'      => $prefix . 'name_title_prefix',
283
+							'name'    => __('Name Title Prefix', 'give'),
284
+							'desc'    => __('Do you want to add a name title prefix dropdown field before the donor\'s first name field? This will display a dropdown with options such as Mrs, Miss, Ms, Sir, and Dr for donor to choose from.', 'give'),
285
+							'id'      => $prefix.'name_title_prefix',
286 286
 							'type'    => 'radio_inline',
287 287
 							'options' => array(
288
-								'global' => __( 'Global Option', 'give' ),
289
-								'required' => __( 'Required', 'give' ),
290
-								'optional' => __( 'Optional', 'give' ),
291
-								'disabled' => __( 'Disabled', 'give' ),
288
+								'global' => __('Global Option', 'give'),
289
+								'required' => __('Required', 'give'),
290
+								'optional' => __('Optional', 'give'),
291
+								'disabled' => __('Disabled', 'give'),
292 292
 							),
293 293
 							'default' => 'global',
294 294
 						),
295 295
 						array(
296
-							'name'          => __( 'Title Prefixes', 'give' ),
297
-							'desc'          => __( 'Add or remove salutations from the dropdown using the field above.', 'give' ),
298
-							'id'            => $prefix . 'title_prefixes',
296
+							'name'          => __('Title Prefixes', 'give'),
297
+							'desc'          => __('Add or remove salutations from the dropdown using the field above.', 'give'),
298
+							'id'            => $prefix.'title_prefixes',
299 299
 							'type'          => 'chosen',
300 300
 							'data_type'     => 'multiselect',
301 301
 							'style'         => 'width: 100%',
@@ -303,77 +303,77 @@  discard block
 block discarded – undo
303 303
 							'options'       => give_get_default_title_prefixes(),
304 304
 						),
305 305
 						array(
306
-							'name'    => __( 'Company Donations', 'give' ),
307
-							'desc'    => __( 'Do you want a Company field to appear after First Name and Last Name?', 'give' ),
308
-							'id'      => $prefix . 'company_field',
306
+							'name'    => __('Company Donations', 'give'),
307
+							'desc'    => __('Do you want a Company field to appear after First Name and Last Name?', 'give'),
308
+							'id'      => $prefix.'company_field',
309 309
 							'type'    => 'radio_inline',
310 310
 							'default' => 'global',
311 311
 							'options' => array(
312
-								'global'   => __( 'Global Option', 'give' ),
313
-								'required' => __( 'Required', 'give' ),
314
-								'optional' => __( 'Optional', 'give' ),
315
-								'disabled' => __( 'Disabled', 'give' ),
312
+								'global'   => __('Global Option', 'give'),
313
+								'required' => __('Required', 'give'),
314
+								'optional' => __('Optional', 'give'),
315
+								'disabled' => __('Disabled', 'give'),
316 316
 
317 317
 							),
318 318
 						),
319 319
 						array(
320
-							'name'    => __( 'Anonymous Donations', 'give' ),
321
-							'desc'    => __( 'Do you want to provide donors the ability mark himself/herself anonymous while giving. This will prevent their information from appearing publicly on your website but you will still receive their information for your records in the admin panel.', 'give' ),
320
+							'name'    => __('Anonymous Donations', 'give'),
321
+							'desc'    => __('Do you want to provide donors the ability mark himself/herself anonymous while giving. This will prevent their information from appearing publicly on your website but you will still receive their information for your records in the admin panel.', 'give'),
322 322
 							'id'      => "{$prefix}anonymous_donation",
323 323
 							'type'    => 'radio_inline',
324 324
 							'default' => 'global',
325 325
 							'options' => array(
326
-								'global'   => __( 'Global Option', 'give' ),
327
-								'enabled'  => __( 'Enabled', 'give' ),
328
-								'disabled' => __( 'Disabled', 'give' ),
326
+								'global'   => __('Global Option', 'give'),
327
+								'enabled'  => __('Enabled', 'give'),
328
+								'disabled' => __('Disabled', 'give'),
329 329
 							),
330 330
 						),
331 331
 						array(
332
-							'name'    => __( 'Donor Comment', 'give' ),
333
-							'desc'    => __( 'Would you like donors to give option to add his/her thought while donaitng.', 'give' ),
332
+							'name'    => __('Donor Comment', 'give'),
333
+							'desc'    => __('Would you like donors to give option to add his/her thought while donaitng.', 'give'),
334 334
 							'id'      => "{$prefix}donor_comment",
335 335
 							'type'    => 'radio_inline',
336 336
 							'default' => 'global',
337 337
 							'options' => array(
338
-								'global'   => __( 'Global Option', 'give' ),
339
-								'enabled'  => __( 'Enabled', 'give' ),
340
-								'disabled' => __( 'Disabled', 'give' ),
338
+								'global'   => __('Global Option', 'give'),
339
+								'enabled'  => __('Enabled', 'give'),
340
+								'disabled' => __('Disabled', 'give'),
341 341
 							),
342 342
 						),
343 343
 						array(
344
-							'name'    => __( 'Guest Donations', 'give' ),
345
-							'desc'    => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ),
346
-							'id'      => $prefix . 'logged_in_only',
344
+							'name'    => __('Guest Donations', 'give'),
345
+							'desc'    => __('Do you want to allow non-logged-in users to make donations?', 'give'),
346
+							'id'      => $prefix.'logged_in_only',
347 347
 							'type'    => 'radio_inline',
348 348
 							'default' => 'enabled',
349 349
 							'options' => array(
350
-								'enabled'  => __( 'Enabled', 'give' ),
351
-								'disabled' => __( 'Disabled', 'give' ),
350
+								'enabled'  => __('Enabled', 'give'),
351
+								'disabled' => __('Disabled', 'give'),
352 352
 							),
353 353
 						),
354 354
 						array(
355
-							'name'    => __( 'Registration', 'give' ),
356
-							'desc'    => __( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ),
357
-							'id'      => $prefix . 'show_register_form',
355
+							'name'    => __('Registration', 'give'),
356
+							'desc'    => __('Display the registration and login forms in the payment section for non-logged-in users.', 'give'),
357
+							'id'      => $prefix.'show_register_form',
358 358
 							'type'    => 'radio',
359 359
 							'options' => array(
360
-								'none'         => __( 'None', 'give' ),
361
-								'registration' => __( 'Registration', 'give' ),
362
-								'login'        => __( 'Login', 'give' ),
363
-								'both'         => __( 'Registration + Login', 'give' ),
360
+								'none'         => __('None', 'give'),
361
+								'registration' => __('Registration', 'give'),
362
+								'login'        => __('Login', 'give'),
363
+								'both'         => __('Registration + Login', 'give'),
364 364
 							),
365 365
 							'default' => 'none',
366 366
 						),
367 367
 						array(
368
-							'name'    => __( 'Floating Labels', 'give' ),
368
+							'name'    => __('Floating Labels', 'give'),
369 369
 							/* translators: %s: forms http://docs.givewp.com/form-floating-labels */
370
-							'desc'    => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ),
371
-							'id'      => $prefix . 'form_floating_labels',
370
+							'desc'    => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')),
371
+							'id'      => $prefix.'form_floating_labels',
372 372
 							'type'    => 'radio_inline',
373 373
 							'options' => array(
374
-								'global'   => __( 'Global Option', 'give' ),
375
-								'enabled'  => __( 'Enabled', 'give' ),
376
-								'disabled' => __( 'Disabled', 'give' ),
374
+								'global'   => __('Global Option', 'give'),
375
+								'enabled'  => __('Enabled', 'give'),
376
+								'disabled' => __('Disabled', 'give'),
377 377
 							),
378 378
 							'default' => 'global',
379 379
 						),
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 							'name'  => 'form_display_docs',
382 382
 							'type'  => 'docs_link',
383 383
 							'url'   => 'http://docs.givewp.com/form-display-options',
384
-							'title' => __( 'Form Display', 'give' ),
384
+							'title' => __('Form Display', 'give'),
385 385
 						),
386 386
 					),
387 387
 						$post_id
@@ -392,42 +392,42 @@  discard block
 block discarded – undo
392 392
 			/**
393 393
 			 * Donation Goals
394 394
 			 */
395
-			'donation_goal_options' => apply_filters( 'give_donation_goal_options', array(
395
+			'donation_goal_options' => apply_filters('give_donation_goal_options', array(
396 396
 				'id'        => 'donation_goal_options',
397
-				'title'     => __( 'Donation Goal', 'give' ),
397
+				'title'     => __('Donation Goal', 'give'),
398 398
 				'icon-html' => '<span class="give-icon give-icon-target"></span>',
399
-				'fields'    => apply_filters( 'give_forms_donation_goal_metabox_fields', array(
399
+				'fields'    => apply_filters('give_forms_donation_goal_metabox_fields', array(
400 400
 					// Goals
401 401
 					array(
402
-						'name'        => __( 'Donation Goal', 'give' ),
403
-						'description' => __( 'Do you want to set a donation goal for this form?', 'give' ),
404
-						'id'          => $prefix . 'goal_option',
402
+						'name'        => __('Donation Goal', 'give'),
403
+						'description' => __('Do you want to set a donation goal for this form?', 'give'),
404
+						'id'          => $prefix.'goal_option',
405 405
 						'type'        => 'radio_inline',
406 406
 						'default'     => 'disabled',
407 407
 						'options'     => array(
408
-							'enabled'  => __( 'Enabled', 'give' ),
409
-							'disabled' => __( 'Disabled', 'give' ),
408
+							'enabled'  => __('Enabled', 'give'),
409
+							'disabled' => __('Disabled', 'give'),
410 410
 						),
411 411
 					),
412 412
 
413 413
 					array(
414
-						'name'        => __( 'Goal Format', 'give' ),
415
-						'description' => __( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded" or "1 of 5 donations". You can also display a donor-based goal, such as "100 of 1,000 donors have given".', 'give' ),
416
-						'id'          => $prefix . 'goal_format',
414
+						'name'        => __('Goal Format', 'give'),
415
+						'description' => __('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded" or "1 of 5 donations". You can also display a donor-based goal, such as "100 of 1,000 donors have given".', 'give'),
416
+						'id'          => $prefix.'goal_format',
417 417
 						'type'        => 'donation_form_goal',
418 418
 						'default'     => 'amount',
419 419
 						'options'     => array(
420
-							'amount'     => __( 'Amount Raised', 'give' ),
421
-							'percentage' => __( 'Percentage Raised', 'give' ),
422
-							'donation'   => __( 'Number of Donations', 'give' ),
423
-							'donors'     => __( 'Number of Donors', 'give' ),
420
+							'amount'     => __('Amount Raised', 'give'),
421
+							'percentage' => __('Percentage Raised', 'give'),
422
+							'donation'   => __('Number of Donations', 'give'),
423
+							'donors'     => __('Number of Donors', 'give'),
424 424
 						),
425 425
 					),
426 426
 
427 427
 					array(
428
-						'name'          => __( 'Goal Amount', 'give' ),
429
-						'description'   => __( 'This is the monetary goal amount you want to reach for this form.', 'give' ),
430
-						'id'            => $prefix . 'set_goal',
428
+						'name'          => __('Goal Amount', 'give'),
429
+						'description'   => __('This is the monetary goal amount you want to reach for this form.', 'give'),
430
+						'id'            => $prefix.'set_goal',
431 431
 						'type'          => 'text_small',
432 432
 						'data_type'     => 'price',
433 433
 						'attributes'    => array(
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 						'wrapper_class' => 'give-hidden',
438 438
 					),
439 439
 					array(
440
-						'id'         => $prefix . 'number_of_donation_goal',
441
-						'name'       => __( 'Donation Goal', 'give' ),
442
-						'desc'       => __( 'Set the total number of donations as a goal.', 'give' ),
440
+						'id'         => $prefix.'number_of_donation_goal',
441
+						'name'       => __('Donation Goal', 'give'),
442
+						'desc'       => __('Set the total number of donations as a goal.', 'give'),
443 443
 						'type'       => 'number',
444 444
 						'default'    => 1,
445 445
 						'attributes' => array(
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 						),
448 448
 					),
449 449
 					array(
450
-						'id'         => $prefix . 'number_of_donor_goal',
451
-						'name'       => __( 'Donor Goal', 'give' ),
452
-						'desc'       => __( 'Set the total number of donors as a goal.', 'give' ),
450
+						'id'         => $prefix.'number_of_donor_goal',
451
+						'name'       => __('Donor Goal', 'give'),
452
+						'desc'       => __('Set the total number of donors as a goal.', 'give'),
453 453
 						'type'       => 'number',
454 454
 						'default'    => 1,
455 455
 						'attributes' => array(
@@ -457,85 +457,85 @@  discard block
 block discarded – undo
457 457
 						),
458 458
 					),
459 459
 					array(
460
-						'name'          => __( 'Progress Bar Color', 'give' ),
461
-						'desc'          => __( 'Customize the color of the goal progress bar.', 'give' ),
462
-						'id'            => $prefix . 'goal_color',
460
+						'name'          => __('Progress Bar Color', 'give'),
461
+						'desc'          => __('Customize the color of the goal progress bar.', 'give'),
462
+						'id'            => $prefix.'goal_color',
463 463
 						'type'          => 'colorpicker',
464 464
 						'default'       => '#2bc253',
465 465
 						'wrapper_class' => 'give-hidden',
466 466
 					),
467 467
 
468 468
 					array(
469
-						'name'          => __( 'Close Form', 'give' ),
470
-						'desc'          => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ),
471
-						'id'            => $prefix . 'close_form_when_goal_achieved',
469
+						'name'          => __('Close Form', 'give'),
470
+						'desc'          => __('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'),
471
+						'id'            => $prefix.'close_form_when_goal_achieved',
472 472
 						'type'          => 'radio_inline',
473 473
 						'default'       => 'disabled',
474 474
 						'options'       => array(
475
-							'enabled'  => __( 'Enabled', 'give' ),
476
-							'disabled' => __( 'Disabled', 'give' ),
475
+							'enabled'  => __('Enabled', 'give'),
476
+							'disabled' => __('Disabled', 'give'),
477 477
 						),
478 478
 						'wrapper_class' => 'give-hidden',
479 479
 					),
480 480
 					array(
481
-						'name'          => __( 'Goal Achieved Message', 'give' ),
482
-						'desc'          => __( 'Do you want to display a custom message when the goal is closed?', 'give' ),
483
-						'id'            => $prefix . 'form_goal_achieved_message',
481
+						'name'          => __('Goal Achieved Message', 'give'),
482
+						'desc'          => __('Do you want to display a custom message when the goal is closed?', 'give'),
483
+						'id'            => $prefix.'form_goal_achieved_message',
484 484
 						'type'          => 'wysiwyg',
485
-						'default'       => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ),
485
+						'default'       => __('Thank you to all our donors, we have met our fundraising goal.', 'give'),
486 486
 						'wrapper_class' => 'give-hidden',
487 487
 					),
488 488
 					array(
489 489
 						'name'  => 'donation_goal_docs',
490 490
 						'type'  => 'docs_link',
491 491
 						'url'   => 'http://docs.givewp.com/form-donation-goal',
492
-						'title' => __( 'Donation Goal', 'give' ),
492
+						'title' => __('Donation Goal', 'give'),
493 493
 					),
494 494
 				),
495 495
 					$post_id
496 496
 				),
497
-			) ),
497
+			)),
498 498
 
499 499
 			/**
500 500
 			 * Content Field
501 501
 			 */
502
-			'form_content_options'  => apply_filters( 'give_forms_content_options', array(
502
+			'form_content_options'  => apply_filters('give_forms_content_options', array(
503 503
 				'id'        => 'form_content_options',
504
-				'title'     => __( 'Form Content', 'give' ),
504
+				'title'     => __('Form Content', 'give'),
505 505
 				'icon-html' => '<span class="give-icon give-icon-edit"></span>',
506
-				'fields'    => apply_filters( 'give_forms_content_options_metabox_fields', array(
506
+				'fields'    => apply_filters('give_forms_content_options_metabox_fields', array(
507 507
 
508 508
 					// Donation content.
509 509
 					array(
510
-						'name'        => __( 'Display Content', 'give' ),
511
-						'description' => __( 'Do you want to add custom content to this form?', 'give' ),
512
-						'id'          => $prefix . 'display_content',
510
+						'name'        => __('Display Content', 'give'),
511
+						'description' => __('Do you want to add custom content to this form?', 'give'),
512
+						'id'          => $prefix.'display_content',
513 513
 						'type'        => 'radio_inline',
514 514
 						'options'     => array(
515
-							'enabled'  => __( 'Enabled', 'give' ),
516
-							'disabled' => __( 'Disabled', 'give' ),
515
+							'enabled'  => __('Enabled', 'give'),
516
+							'disabled' => __('Disabled', 'give'),
517 517
 						),
518 518
 						'default'     => 'disabled',
519 519
 					),
520 520
 
521 521
 					// Content placement.
522 522
 					array(
523
-						'name'          => __( 'Content Placement', 'give' ),
524
-						'description'   => __( 'This option controls where the content appears within the donation form.', 'give' ),
525
-						'id'            => $prefix . 'content_placement',
523
+						'name'          => __('Content Placement', 'give'),
524
+						'description'   => __('This option controls where the content appears within the donation form.', 'give'),
525
+						'id'            => $prefix.'content_placement',
526 526
 						'type'          => 'radio_inline',
527
-						'options'       => apply_filters( 'give_forms_content_options_select', array(
528
-								'give_pre_form'  => __( 'Above fields', 'give' ),
529
-								'give_post_form' => __( 'Below fields', 'give' ),
527
+						'options'       => apply_filters('give_forms_content_options_select', array(
528
+								'give_pre_form'  => __('Above fields', 'give'),
529
+								'give_post_form' => __('Below fields', 'give'),
530 530
 							)
531 531
 						),
532 532
 						'default'       => 'give_pre_form',
533 533
 						'wrapper_class' => 'give-hidden',
534 534
 					),
535 535
 					array(
536
-						'name'          => __( 'Content', 'give' ),
537
-						'description'   => __( 'This content will display on the single give form page.', 'give' ),
538
-						'id'            => $prefix . 'form_content',
536
+						'name'          => __('Content', 'give'),
537
+						'description'   => __('This content will display on the single give form page.', 'give'),
538
+						'id'            => $prefix.'form_content',
539 539
 						'type'          => 'wysiwyg',
540 540
 						'wrapper_class' => 'give-hidden',
541 541
 					),
@@ -543,51 +543,51 @@  discard block
 block discarded – undo
543 543
 						'name'  => 'form_content_docs',
544 544
 						'type'  => 'docs_link',
545 545
 						'url'   => 'http://docs.givewp.com/form-content',
546
-						'title' => __( 'Form Content', 'give' ),
546
+						'title' => __('Form Content', 'give'),
547 547
 					),
548 548
 				),
549 549
 					$post_id
550 550
 				),
551
-			) ),
551
+			)),
552 552
 
553 553
 			/**
554 554
 			 * Terms & Conditions
555 555
 			 */
556
-			'form_terms_options'    => apply_filters( 'give_forms_terms_options', array(
556
+			'form_terms_options'    => apply_filters('give_forms_terms_options', array(
557 557
 				'id'        => 'form_terms_options',
558
-				'title'     => __( 'Terms & Conditions', 'give' ),
558
+				'title'     => __('Terms & Conditions', 'give'),
559 559
 				'icon-html' => '<span class="give-icon give-icon-checklist"></span>',
560
-				'fields'    => apply_filters( 'give_forms_terms_options_metabox_fields', array(
560
+				'fields'    => apply_filters('give_forms_terms_options_metabox_fields', array(
561 561
 					// Donation Option
562 562
 					array(
563
-						'name'        => __( 'Terms and Conditions', 'give' ),
564
-						'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ),
565
-						'id'          => $prefix . 'terms_option',
563
+						'name'        => __('Terms and Conditions', 'give'),
564
+						'description' => __('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'),
565
+						'id'          => $prefix.'terms_option',
566 566
 						'type'        => 'radio_inline',
567
-						'options'     => apply_filters( 'give_forms_content_options_select', array(
568
-								'global'   => __( 'Global Option', 'give' ),
569
-								'enabled'  => __( 'Customize', 'give' ),
570
-								'disabled' => __( 'Disable', 'give' ),
567
+						'options'     => apply_filters('give_forms_content_options_select', array(
568
+								'global'   => __('Global Option', 'give'),
569
+								'enabled'  => __('Customize', 'give'),
570
+								'disabled' => __('Disable', 'give'),
571 571
 							)
572 572
 						),
573 573
 						'default'     => 'global',
574 574
 					),
575 575
 					array(
576
-						'id'            => $prefix . 'agree_label',
577
-						'name'          => __( 'Agreement Label', 'give' ),
578
-						'desc'          => __( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ),
576
+						'id'            => $prefix.'agree_label',
577
+						'name'          => __('Agreement Label', 'give'),
578
+						'desc'          => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'),
579 579
 						'type'          => 'textarea',
580 580
 						'attributes'    => array(
581
-							'placeholder' => __( 'Agree to Terms?', 'give' ),
581
+							'placeholder' => __('Agree to Terms?', 'give'),
582 582
 							'rows'        => 1
583 583
 						),
584 584
 						'wrapper_class' => 'give-hidden',
585 585
 					),
586 586
 					array(
587
-						'id'            => $prefix . 'agree_text',
588
-						'name'          => __( 'Agreement Text', 'give' ),
589
-						'desc'          => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ),
590
-						'default'       => give_get_option( 'agreement_text' ),
587
+						'id'            => $prefix.'agree_text',
588
+						'name'          => __('Agreement Text', 'give'),
589
+						'desc'          => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'),
590
+						'default'       => give_get_option('agreement_text'),
591 591
 						'type'          => 'wysiwyg',
592 592
 						'wrapper_class' => 'give-hidden',
593 593
 					),
@@ -595,18 +595,18 @@  discard block
 block discarded – undo
595 595
 						'name'  => 'terms_docs',
596 596
 						'type'  => 'docs_link',
597 597
 						'url'   => 'http://docs.givewp.com/form-terms',
598
-						'title' => __( 'Terms and Conditions', 'give' ),
598
+						'title' => __('Terms and Conditions', 'give'),
599 599
 					),
600 600
 				),
601 601
 					$post_id
602 602
 				),
603
-			) ),
603
+			)),
604 604
 		);
605 605
 
606 606
 		/**
607 607
 		 * Filter the metabox tabbed panel settings.
608 608
 		 */
609
-		$settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id );
609
+		$settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id);
610 610
 
611 611
 		// Output.
612 612
 		return $settings;
@@ -623,19 +623,19 @@  discard block
 block discarded – undo
623 623
 		add_meta_box(
624 624
 			$this->get_metabox_ID(),
625 625
 			$this->get_metabox_label(),
626
-			array( $this, 'output' ),
627
-			array( 'give_forms' ),
626
+			array($this, 'output'),
627
+			array('give_forms'),
628 628
 			'normal',
629 629
 			'high'
630 630
 		);
631 631
 
632 632
 		// Show Goal Metabox only if goal is enabled.
633
-		if ( give_is_setting_enabled( give_get_meta( give_get_admin_post_id(), '_give_goal_option', true ) ) ) {
633
+		if (give_is_setting_enabled(give_get_meta(give_get_admin_post_id(), '_give_goal_option', true))) {
634 634
 			add_meta_box(
635 635
 				'give-form-goal-stats',
636
-				__( 'Goal Statistics', 'give' ),
637
-				array( $this, 'output_goal' ),
638
-				array( 'give_forms' ),
636
+				__('Goal Statistics', 'give'),
637
+				array($this, 'output_goal'),
638
+				array('give_forms'),
639 639
 				'side',
640 640
 				'low'
641 641
 			);
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 	function enqueue_script() {
655 655
 		global $post;
656 656
 
657
-		if ( is_object( $post ) && 'give_forms' === $post->post_type ) {
657
+		if (is_object($post) && 'give_forms' === $post->post_type) {
658 658
 
659 659
 		}
660 660
 	}
@@ -692,32 +692,32 @@  discard block
 block discarded – undo
692 692
 	public function get_tabs() {
693 693
 		$tabs = array();
694 694
 
695
-		if ( ! empty( $this->settings ) ) {
696
-			foreach ( $this->settings as $setting ) {
697
-				if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) {
695
+		if ( ! empty($this->settings)) {
696
+			foreach ($this->settings as $setting) {
697
+				if ( ! isset($setting['id']) || ! isset($setting['title'])) {
698 698
 					continue;
699 699
 				}
700 700
 				$tab = array(
701 701
 					'id'        => $setting['id'],
702 702
 					'label'     => $setting['title'],
703
-					'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ),
703
+					'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''),
704 704
 				);
705 705
 
706
-				if ( $this->has_sub_tab( $setting ) ) {
707
-					if ( empty( $setting['sub-fields'] ) ) {
706
+				if ($this->has_sub_tab($setting)) {
707
+					if (empty($setting['sub-fields'])) {
708 708
 						$tab = array();
709 709
 					} else {
710
-						foreach ( $setting['sub-fields'] as $sub_fields ) {
710
+						foreach ($setting['sub-fields'] as $sub_fields) {
711 711
 							$tab['sub-fields'][] = array(
712 712
 								'id'        => $sub_fields['id'],
713 713
 								'label'     => $sub_fields['title'],
714
-								'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ),
714
+								'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''),
715 715
 							);
716 716
 						}
717 717
 					}
718 718
 				}
719 719
 
720
-				if ( ! empty( $tab ) ) {
720
+				if ( ! empty($tab)) {
721 721
 					$tabs[] = $tab;
722 722
 				}
723 723
 			}
@@ -735,35 +735,35 @@  discard block
 block discarded – undo
735 735
 	 */
736 736
 	public function output() {
737 737
 		// Bailout.
738
-		if ( $form_data_tabs = $this->get_tabs() ) :
739
-			$active_tab = ! empty( $_GET['give_tab'] ) ? give_clean( $_GET['give_tab'] ) : 'form_field_options';
740
-			wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' );
738
+		if ($form_data_tabs = $this->get_tabs()) :
739
+			$active_tab = ! empty($_GET['give_tab']) ? give_clean($_GET['give_tab']) : 'form_field_options';
740
+			wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce');
741 741
 			?>
742 742
 			<input id="give_form_active_tab" type="hidden" name="give_form_active_tab">
743 743
 			<div class="give-metabox-panel-wrap">
744 744
 				<ul class="give-form-data-tabs give-metabox-tabs">
745
-					<?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?>
745
+					<?php foreach ($form_data_tabs as $index => $form_data_tab) : ?>
746 746
 						<?php
747 747
 						// Determine if current tab is active.
748 748
 						$is_active = $active_tab === $form_data_tab['id'] ? true : false;
749 749
 						?>
750
-						<li class="<?php echo "{$form_data_tab['id']}_tab" . ( $is_active ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>">
750
+						<li class="<?php echo "{$form_data_tab['id']}_tab".($is_active ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>">
751 751
 							<a href="#<?php echo $form_data_tab['id']; ?>"
752 752
 							   data-tab-id="<?php echo $form_data_tab['id']; ?>">
753
-								<?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?>
753
+								<?php if ( ! empty($form_data_tab['icon-html'])) : ?>
754 754
 									<?php echo $form_data_tab['icon-html']; ?>
755 755
 								<?php else : ?>
756 756
 									<span class="give-icon give-icon-default"></span>
757 757
 								<?php endif; ?>
758 758
 								<span class="give-label"><?php echo $form_data_tab['label']; ?></span>
759 759
 							</a>
760
-							<?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?>
760
+							<?php if ($this->has_sub_tab($form_data_tab)) : ?>
761 761
 								<ul class="give-metabox-sub-tabs give-hidden">
762
-									<?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?>
762
+									<?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?>
763 763
 										<li class="<?php echo "{$sub_tab['id']}_tab"; ?>">
764 764
 											<a href="#<?php echo $sub_tab['id']; ?>"
765 765
 											   data-tab-id="<?php echo $sub_tab['id']; ?>">
766
-												<?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?>
766
+												<?php if ( ! empty($sub_tab['icon-html'])) : ?>
767 767
 													<?php echo $sub_tab['icon-html']; ?>
768 768
 												<?php else : ?>
769 769
 													<span class="give-icon give-icon-default"></span>
@@ -778,30 +778,30 @@  discard block
 block discarded – undo
778 778
 					<?php endforeach; ?>
779 779
 				</ul>
780 780
 
781
-				<?php foreach ( $this->settings as $setting ) : ?>
782
-					<?php do_action( "give_before_{$setting['id']}_settings" ); ?>
781
+				<?php foreach ($this->settings as $setting) : ?>
782
+					<?php do_action("give_before_{$setting['id']}_settings"); ?>
783 783
 					<?php
784 784
 					// Determine if current panel is active.
785 785
 					$is_active = $active_tab === $setting['id'] ? true : false;
786 786
 					?>
787 787
 					<div id="<?php echo $setting['id']; ?>"
788
-						 class="panel give_options_panel<?php echo( $is_active ? ' active' : '' ); ?>">
789
-						<?php if ( ! empty( $setting['fields'] ) ) : ?>
790
-							<?php foreach ( $setting['fields'] as $field ) : ?>
791
-								<?php give_render_field( $field ); ?>
788
+						 class="panel give_options_panel<?php echo($is_active ? ' active' : ''); ?>">
789
+						<?php if ( ! empty($setting['fields'])) : ?>
790
+							<?php foreach ($setting['fields'] as $field) : ?>
791
+								<?php give_render_field($field); ?>
792 792
 							<?php endforeach; ?>
793 793
 						<?php endif; ?>
794 794
 					</div>
795
-					<?php do_action( "give_after_{$setting['id']}_settings" ); ?>
795
+					<?php do_action("give_after_{$setting['id']}_settings"); ?>
796 796
 
797 797
 
798
-					<?php if ( $this->has_sub_tab( $setting ) ) : ?>
799
-						<?php if ( ! empty( $setting['sub-fields'] ) ) : ?>
800
-							<?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?>
798
+					<?php if ($this->has_sub_tab($setting)) : ?>
799
+						<?php if ( ! empty($setting['sub-fields'])) : ?>
800
+							<?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?>
801 801
 								<div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden">
802
-									<?php if ( ! empty( $sub_fields['fields'] ) ) : ?>
803
-										<?php foreach ( $sub_fields['fields'] as $sub_field ) : ?>
804
-											<?php give_render_field( $sub_field ); ?>
802
+									<?php if ( ! empty($sub_fields['fields'])) : ?>
803
+										<?php foreach ($sub_fields['fields'] as $sub_field) : ?>
804
+											<?php give_render_field($sub_field); ?>
805 805
 										<?php endforeach; ?>
806 806
 									<?php endif; ?>
807 807
 								</div>
@@ -824,9 +824,9 @@  discard block
 block discarded – undo
824 824
 	 *
825 825
 	 * @return void
826 826
 	 */
827
-	public function output_goal( $post ) {
827
+	public function output_goal($post) {
828 828
 
829
-		echo give_admin_form_goal_stats( $post->ID );
829
+		echo give_admin_form_goal_stats($post->ID);
830 830
 
831 831
 	}
832 832
 
@@ -839,9 +839,9 @@  discard block
 block discarded – undo
839 839
 	 *
840 840
 	 * @return bool
841 841
 	 */
842
-	private function has_sub_tab( $field_setting ) {
842
+	private function has_sub_tab($field_setting) {
843 843
 		$has_sub_tab = false;
844
-		if ( array_key_exists( 'sub-fields', $field_setting ) ) {
844
+		if (array_key_exists('sub-fields', $field_setting)) {
845 845
 			$has_sub_tab = true;
846 846
 		}
847 847
 
@@ -856,13 +856,13 @@  discard block
 block discarded – undo
856 856
 	 * @return array
857 857
 	 */
858 858
 	function cmb2_metabox_settings() {
859
-		$all_cmb2_settings   = apply_filters( 'cmb2_meta_boxes', array() );
859
+		$all_cmb2_settings   = apply_filters('cmb2_meta_boxes', array());
860 860
 		$give_forms_settings = $all_cmb2_settings;
861 861
 
862 862
 		// Filter settings: Use only give forms related settings.
863
-		foreach ( $all_cmb2_settings as $index => $setting ) {
864
-			if ( ! in_array( 'give_forms', $setting['object_types'] ) ) {
865
-				unset( $give_forms_settings[ $index ] );
863
+		foreach ($all_cmb2_settings as $index => $setting) {
864
+			if ( ! in_array('give_forms', $setting['object_types'])) {
865
+				unset($give_forms_settings[$index]);
866 866
 			}
867 867
 		}
868 868
 
@@ -880,100 +880,100 @@  discard block
 block discarded – undo
880 880
 	 *
881 881
 	 * @return void
882 882
 	 */
883
-	public function save( $post_id, $post ) {
883
+	public function save($post_id, $post) {
884 884
 
885 885
 		// $post_id and $post are required.
886
-		if ( empty( $post_id ) || empty( $post ) ) {
886
+		if (empty($post_id) || empty($post)) {
887 887
 			return;
888 888
 		}
889 889
 
890 890
 		// Don't save meta boxes for revisions or autosaves.
891
-		if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
891
+		if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
892 892
 			return;
893 893
 		}
894 894
 
895 895
 		// Check the nonce.
896
-		if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) {
896
+		if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) {
897 897
 			return;
898 898
 		}
899 899
 
900 900
 		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
901
-		if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) {
901
+		if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) {
902 902
 			return;
903 903
 		}
904 904
 
905 905
 		// Check user has permission to edit.
906
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
906
+		if ( ! current_user_can('edit_post', $post_id)) {
907 907
 			return;
908 908
 		}
909 909
 
910 910
 		// Fire action before saving form meta.
911
-		do_action( 'give_pre_process_give_forms_meta', $post_id, $post );
911
+		do_action('give_pre_process_give_forms_meta', $post_id, $post);
912 912
 
913 913
 		/**
914 914
 		 * Filter the meta key to save.
915 915
 		 * Third party addon developer can remove there meta keys from this array to handle saving data on there own.
916 916
 		 */
917
-		$form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() );
917
+		$form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings());
918 918
 
919 919
 		// Save form meta data.
920
-		if ( ! empty( $form_meta_keys ) ) {
921
-			foreach ( $form_meta_keys as $form_meta_key ) {
920
+		if ( ! empty($form_meta_keys)) {
921
+			foreach ($form_meta_keys as $form_meta_key) {
922 922
 
923 923
 				// Set default value for checkbox fields.
924 924
 				if (
925
-					! isset( $_POST[ $form_meta_key ] ) &&
926
-					in_array( $this->get_field_type( $form_meta_key ), array( 'checkbox', 'chosen' ) )
925
+					! isset($_POST[$form_meta_key]) &&
926
+					in_array($this->get_field_type($form_meta_key), array('checkbox', 'chosen'))
927 927
 				) {
928
-					$_POST[ $form_meta_key ] = '';
928
+					$_POST[$form_meta_key] = '';
929 929
 				}
930 930
 
931
-				if ( isset( $_POST[ $form_meta_key ] ) ) {
932
-					$setting_field = $this->get_setting_field( $form_meta_key );
933
-					if ( ! empty( $setting_field['type'] ) ) {
934
-						switch ( $setting_field['type'] ) {
931
+				if (isset($_POST[$form_meta_key])) {
932
+					$setting_field = $this->get_setting_field($form_meta_key);
933
+					if ( ! empty($setting_field['type'])) {
934
+						switch ($setting_field['type']) {
935 935
 							case 'textarea':
936 936
 							case 'wysiwyg':
937
-								$form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] );
937
+								$form_meta_value = wp_kses_post($_POST[$form_meta_key]);
938 938
 								break;
939 939
 
940 940
 							case 'donation_limit' :
941
-								$form_meta_value = $_POST[ $form_meta_key ];
941
+								$form_meta_value = $_POST[$form_meta_key];
942 942
 								break;
943 943
 
944 944
 							case 'group':
945 945
 								$form_meta_value = array();
946 946
 
947
-								foreach ( $_POST[ $form_meta_key ] as $index => $group ) {
947
+								foreach ($_POST[$form_meta_key] as $index => $group) {
948 948
 
949 949
 									// Do not save template input field values.
950
-									if ( '{{row-count-placeholder}}' === $index ) {
950
+									if ('{{row-count-placeholder}}' === $index) {
951 951
 										continue;
952 952
 									}
953 953
 
954 954
 									$group_meta_value = array();
955
-									foreach ( $group as $field_id => $field_value ) {
956
-										switch ( $this->get_field_type( $field_id, $form_meta_key ) ) {
955
+									foreach ($group as $field_id => $field_value) {
956
+										switch ($this->get_field_type($field_id, $form_meta_key)) {
957 957
 											case 'wysiwyg':
958
-												$group_meta_value[ $field_id ] = wp_kses_post( $field_value );
958
+												$group_meta_value[$field_id] = wp_kses_post($field_value);
959 959
 												break;
960 960
 
961 961
 											default:
962
-												$group_meta_value[ $field_id ] = give_clean( $field_value );
962
+												$group_meta_value[$field_id] = give_clean($field_value);
963 963
 										}
964 964
 									}
965 965
 
966
-									if ( ! empty( $group_meta_value ) ) {
967
-										$form_meta_value[ $index ] = $group_meta_value;
966
+									if ( ! empty($group_meta_value)) {
967
+										$form_meta_value[$index] = $group_meta_value;
968 968
 									}
969 969
 								}
970 970
 
971 971
 								// Arrange repeater field keys in order.
972
-								$form_meta_value = array_values( $form_meta_value );
972
+								$form_meta_value = array_values($form_meta_value);
973 973
 								break;
974 974
 
975 975
 							default:
976
-								$form_meta_value = give_clean( $_POST[ $form_meta_key ] );
976
+								$form_meta_value = give_clean($_POST[$form_meta_key]);
977 977
 						}// End switch().
978 978
 
979 979
 						/**
@@ -983,38 +983,38 @@  discard block
 block discarded – undo
983 983
 						 */
984 984
 						$form_meta_value = apply_filters(
985 985
 							'give_pre_save_form_meta_value',
986
-							$this->sanitize_form_meta( $form_meta_value, $setting_field ),
986
+							$this->sanitize_form_meta($form_meta_value, $setting_field),
987 987
 							$form_meta_key,
988 988
 							$this,
989 989
 							$post_id
990 990
 						);
991 991
 
992 992
 						// Range slider.
993
-						if ( 'donation_limit' === $setting_field['type'] ) {
993
+						if ('donation_limit' === $setting_field['type']) {
994 994
 
995 995
 							// Sanitize amount for db.
996
-							$form_meta_value = array_map( 'give_sanitize_amount_for_db', $form_meta_value );
996
+							$form_meta_value = array_map('give_sanitize_amount_for_db', $form_meta_value);
997 997
 
998 998
 							// Store it to form meta.
999
-							give_update_meta( $post_id, $form_meta_key . '_minimum', $form_meta_value['minimum'] );
1000
-							give_update_meta( $post_id, $form_meta_key . '_maximum', $form_meta_value['maximum'] );
999
+							give_update_meta($post_id, $form_meta_key.'_minimum', $form_meta_value['minimum']);
1000
+							give_update_meta($post_id, $form_meta_key.'_maximum', $form_meta_value['maximum']);
1001 1001
 						} else {
1002 1002
 							// Save data.
1003
-							give_update_meta( $post_id, $form_meta_key, $form_meta_value );
1003
+							give_update_meta($post_id, $form_meta_key, $form_meta_value);
1004 1004
 						}
1005 1005
 
1006 1006
 						// Verify and delete form meta based on the form status.
1007
-						give_set_form_closed_status( $post_id );
1007
+						give_set_form_closed_status($post_id);
1008 1008
 
1009 1009
 						// Fire after saving form meta key.
1010
-						do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post );
1010
+						do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post);
1011 1011
 					}// End if().
1012 1012
 				}// End if().
1013 1013
 			}// End foreach().
1014 1014
 		}// End if().
1015 1015
 
1016 1016
 		// Fire action after saving form meta.
1017
-		do_action( 'give_post_process_give_forms_meta', $post_id, $post );
1017
+		do_action('give_post_process_give_forms_meta', $post_id, $post);
1018 1018
 	}
1019 1019
 
1020 1020
 
@@ -1027,10 +1027,10 @@  discard block
 block discarded – undo
1027 1027
 	 *
1028 1028
 	 * @return string
1029 1029
 	 */
1030
-	private function get_field_id( $field ) {
1030
+	private function get_field_id($field) {
1031 1031
 		$field_id = '';
1032 1032
 
1033
-		if ( array_key_exists( 'id', $field ) ) {
1033
+		if (array_key_exists('id', $field)) {
1034 1034
 			$field_id = $field['id'];
1035 1035
 
1036 1036
 		}
@@ -1047,16 +1047,16 @@  discard block
 block discarded – undo
1047 1047
 	 *
1048 1048
 	 * @return array
1049 1049
 	 */
1050
-	private function get_fields_id( $setting ) {
1050
+	private function get_fields_id($setting) {
1051 1051
 		$meta_keys = array();
1052 1052
 
1053 1053
 		if (
1054
-			! empty( $setting )
1055
-			&& array_key_exists( 'fields', $setting )
1056
-			&& ! empty( $setting['fields'] )
1054
+			! empty($setting)
1055
+			&& array_key_exists('fields', $setting)
1056
+			&& ! empty($setting['fields'])
1057 1057
 		) {
1058
-			foreach ( $setting['fields'] as $field ) {
1059
-				if ( $field_id = $this->get_field_id( $field ) ) {
1058
+			foreach ($setting['fields'] as $field) {
1059
+				if ($field_id = $this->get_field_id($field)) {
1060 1060
 					$meta_keys[] = $field_id;
1061 1061
 				}
1062 1062
 			}
@@ -1074,14 +1074,14 @@  discard block
 block discarded – undo
1074 1074
 	 *
1075 1075
 	 * @return array
1076 1076
 	 */
1077
-	private function get_sub_fields_id( $setting ) {
1077
+	private function get_sub_fields_id($setting) {
1078 1078
 		$meta_keys = array();
1079 1079
 
1080
-		if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) {
1081
-			foreach ( $setting['sub-fields'] as $fields ) {
1082
-				if ( ! empty( $fields['fields'] ) ) {
1083
-					foreach ( $fields['fields'] as $field ) {
1084
-						if ( $field_id = $this->get_field_id( $field ) ) {
1080
+		if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) {
1081
+			foreach ($setting['sub-fields'] as $fields) {
1082
+				if ( ! empty($fields['fields'])) {
1083
+					foreach ($fields['fields'] as $field) {
1084
+						if ($field_id = $this->get_field_id($field)) {
1085 1085
 							$meta_keys[] = $field_id;
1086 1086
 						}
1087 1087
 					}
@@ -1103,14 +1103,14 @@  discard block
 block discarded – undo
1103 1103
 	private function get_meta_keys_from_settings() {
1104 1104
 		$meta_keys = array();
1105 1105
 
1106
-		foreach ( $this->settings as $setting ) {
1107
-			$meta_key = $this->get_fields_id( $setting );
1106
+		foreach ($this->settings as $setting) {
1107
+			$meta_key = $this->get_fields_id($setting);
1108 1108
 
1109
-			if ( $this->has_sub_tab( $setting ) ) {
1110
-				$meta_key = array_merge( $meta_key, $this->get_sub_fields_id( $setting ) );
1109
+			if ($this->has_sub_tab($setting)) {
1110
+				$meta_key = array_merge($meta_key, $this->get_sub_fields_id($setting));
1111 1111
 			}
1112 1112
 
1113
-			$meta_keys = array_merge( $meta_keys, $meta_key );
1113
+			$meta_keys = array_merge($meta_keys, $meta_key);
1114 1114
 		}
1115 1115
 
1116 1116
 		return $meta_keys;
@@ -1127,10 +1127,10 @@  discard block
 block discarded – undo
1127 1127
 	 *
1128 1128
 	 * @return string
1129 1129
 	 */
1130
-	function get_field_type( $field_id, $group_id = '' ) {
1131
-		$field = $this->get_setting_field( $field_id, $group_id );
1130
+	function get_field_type($field_id, $group_id = '') {
1131
+		$field = $this->get_setting_field($field_id, $group_id);
1132 1132
 
1133
-		$type = array_key_exists( 'type', $field )
1133
+		$type = array_key_exists('type', $field)
1134 1134
 			? $field['type']
1135 1135
 			: '';
1136 1136
 
@@ -1148,12 +1148,12 @@  discard block
 block discarded – undo
1148 1148
 	 *
1149 1149
 	 * @return array
1150 1150
 	 */
1151
-	private function get_field( $setting, $field_id ) {
1151
+	private function get_field($setting, $field_id) {
1152 1152
 		$setting_field = array();
1153 1153
 
1154
-		if ( ! empty( $setting['fields'] ) ) {
1155
-			foreach ( $setting['fields'] as $field ) {
1156
-				if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) {
1154
+		if ( ! empty($setting['fields'])) {
1155
+			foreach ($setting['fields'] as $field) {
1156
+				if (array_key_exists('id', $field) && $field['id'] === $field_id) {
1157 1157
 					$setting_field = $field;
1158 1158
 					break;
1159 1159
 				}
@@ -1173,12 +1173,12 @@  discard block
 block discarded – undo
1173 1173
 	 *
1174 1174
 	 * @return array
1175 1175
 	 */
1176
-	private function get_sub_field( $setting, $field_id ) {
1176
+	private function get_sub_field($setting, $field_id) {
1177 1177
 		$setting_field = array();
1178 1178
 
1179
-		if ( ! empty( $setting['sub-fields'] ) ) {
1180
-			foreach ( $setting['sub-fields'] as $fields ) {
1181
-				if ( $field = $this->get_field( $fields, $field_id ) ) {
1179
+		if ( ! empty($setting['sub-fields'])) {
1180
+			foreach ($setting['sub-fields'] as $fields) {
1181
+				if ($field = $this->get_field($fields, $field_id)) {
1182 1182
 					$setting_field = $field;
1183 1183
 					break;
1184 1184
 				}
@@ -1198,17 +1198,17 @@  discard block
 block discarded – undo
1198 1198
 	 *
1199 1199
 	 * @return array
1200 1200
 	 */
1201
-	function get_setting_field( $field_id, $group_id = '' ) {
1201
+	function get_setting_field($field_id, $group_id = '') {
1202 1202
 		$setting_field = array();
1203 1203
 
1204 1204
 		$_field_id = $field_id;
1205
-		$field_id  = empty( $group_id ) ? $field_id : $group_id;
1205
+		$field_id  = empty($group_id) ? $field_id : $group_id;
1206 1206
 
1207
-		if ( ! empty( $this->settings ) ) {
1208
-			foreach ( $this->settings as $setting ) {
1207
+		if ( ! empty($this->settings)) {
1208
+			foreach ($this->settings as $setting) {
1209 1209
 				if (
1210
-					( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) )
1211
-					|| ( $setting_field = $this->get_field( $setting, $field_id ) )
1210
+					($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id)))
1211
+					|| ($setting_field = $this->get_field($setting, $field_id))
1212 1212
 				) {
1213 1213
 					break;
1214 1214
 				}
@@ -1216,9 +1216,9 @@  discard block
 block discarded – undo
1216 1216
 		}
1217 1217
 
1218 1218
 		// Get field from group.
1219
-		if ( ! empty( $group_id ) ) {
1220
-			foreach ( $setting_field['fields'] as $field ) {
1221
-				if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) {
1219
+		if ( ! empty($group_id)) {
1220
+			foreach ($setting_field['fields'] as $field) {
1221
+				if (array_key_exists('id', $field) && $field['id'] === $_field_id) {
1222 1222
 					$setting_field = $field;
1223 1223
 				}
1224 1224
 			}
@@ -1237,14 +1237,14 @@  discard block
 block discarded – undo
1237 1237
 	 *
1238 1238
 	 * @return mixed
1239 1239
 	 */
1240
-	function add_offline_donations_setting_tab( $settings ) {
1241
-		if ( give_is_gateway_active( 'offline' ) ) {
1242
-			$settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array(
1240
+	function add_offline_donations_setting_tab($settings) {
1241
+		if (give_is_gateway_active('offline')) {
1242
+			$settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array(
1243 1243
 				'id'        => 'offline_donations_options',
1244
-				'title'     => __( 'Offline Donations', 'give' ),
1244
+				'title'     => __('Offline Donations', 'give'),
1245 1245
 				'icon-html' => '<span class="give-icon give-icon-purse"></span>',
1246
-				'fields'    => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ),
1247
-			) );
1246
+				'fields'    => apply_filters('give_forms_offline_donations_metabox_fields', array()),
1247
+			));
1248 1248
 		}
1249 1249
 
1250 1250
 		return $settings;
@@ -1262,41 +1262,37 @@  discard block
 block discarded – undo
1262 1262
 	 *
1263 1263
 	 * @return mixed
1264 1264
 	 */
1265
-	function sanitize_form_meta( $meta_value, $setting_field ) {
1266
-		switch ( $setting_field['type'] ) {
1265
+	function sanitize_form_meta($meta_value, $setting_field) {
1266
+		switch ($setting_field['type']) {
1267 1267
 			case 'group':
1268
-				if ( ! empty( $setting_field['fields'] ) ) {
1269
-					foreach ( $setting_field['fields'] as $field ) {
1270
-						if ( empty( $field['data_type'] ) || 'price' !== $field['data_type'] ) {
1268
+				if ( ! empty($setting_field['fields'])) {
1269
+					foreach ($setting_field['fields'] as $field) {
1270
+						if (empty($field['data_type']) || 'price' !== $field['data_type']) {
1271 1271
 							continue;
1272 1272
 						}
1273 1273
 
1274
-						foreach ( $meta_value as $index => $meta_data ) {
1275
-							if ( ! isset( $meta_value[ $index ][ $field['id'] ] ) ) {
1274
+						foreach ($meta_value as $index => $meta_data) {
1275
+							if ( ! isset($meta_value[$index][$field['id']])) {
1276 1276
 								continue;
1277 1277
 							}
1278 1278
 
1279
-							$meta_value[ $index ][ $field['id'] ] = ! empty( $meta_value[ $index ][ $field['id'] ] ) ?
1280
-								give_sanitize_amount_for_db( $meta_value[ $index ][ $field['id'] ] ) :
1281
-								( ( '_give_amount' === $field['id'] && empty( $field_value ) ) ?
1282
-									give_sanitize_amount_for_db( '1.00' ) :
1283
-									0 );
1279
+							$meta_value[$index][$field['id']] = ! empty($meta_value[$index][$field['id']]) ?
1280
+								give_sanitize_amount_for_db($meta_value[$index][$field['id']]) : (('_give_amount' === $field['id'] && empty($field_value)) ?
1281
+									give_sanitize_amount_for_db('1.00') : 0);
1284 1282
 						}
1285 1283
 					}
1286 1284
 				}
1287 1285
 				break;
1288 1286
 
1289 1287
 			default:
1290
-				if ( ! empty( $setting_field['data_type'] ) && 'price' === $setting_field['data_type'] ) {
1288
+				if ( ! empty($setting_field['data_type']) && 'price' === $setting_field['data_type']) {
1291 1289
 					$meta_value = $meta_value ?
1292
-						give_sanitize_amount_for_db( $meta_value ) :
1293
-						( in_array( $setting_field['id'], array(
1290
+						give_sanitize_amount_for_db($meta_value) : (in_array($setting_field['id'], array(
1294 1291
 							'_give_set_price',
1295 1292
 							'_give_custom_amount_minimum',
1296 1293
 							'_give_set_goal'
1297
-						) ) ?
1298
-							give_sanitize_amount_for_db( '1.00' ) :
1299
-							0 );
1294
+						)) ?
1295
+							give_sanitize_amount_for_db('1.00') : 0);
1300 1296
 				}
1301 1297
 		}
1302 1298
 
@@ -1314,12 +1310,12 @@  discard block
 block discarded – undo
1314 1310
 	 *
1315 1311
 	 * @return string The URL after redirect.
1316 1312
 	 */
1317
-	public function maintain_active_tab( $location, $post_id ) {
1313
+	public function maintain_active_tab($location, $post_id) {
1318 1314
 		if (
1319
-			'give_forms' === get_post_type( $post_id ) &&
1320
-			! empty( $_POST['give_form_active_tab'] )
1315
+			'give_forms' === get_post_type($post_id) &&
1316
+			! empty($_POST['give_form_active_tab'])
1321 1317
 		) {
1322
-			$location = add_query_arg( 'give_tab', give_clean( $_POST['give_form_active_tab'] ), $location );
1318
+			$location = add_query_arg('give_tab', give_clean($_POST['give_form_active_tab']), $location);
1323 1319
 		}
1324 1320
 
1325 1321
 		return $location;
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -752,9 +752,12 @@  discard block
 block discarded – undo
752 752
 							   data-tab-id="<?php echo $form_data_tab['id']; ?>">
753 753
 								<?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?>
754 754
 									<?php echo $form_data_tab['icon-html']; ?>
755
-								<?php else : ?>
755
+								<?php else {
756
+	: ?>
756 757
 									<span class="give-icon give-icon-default"></span>
757
-								<?php endif; ?>
758
+								<?php endif;
759
+}
760
+?>
758 761
 								<span class="give-label"><?php echo $form_data_tab['label']; ?></span>
759 762
 							</a>
760 763
 							<?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?>
@@ -765,9 +768,12 @@  discard block
 block discarded – undo
765 768
 											   data-tab-id="<?php echo $sub_tab['id']; ?>">
766 769
 												<?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?>
767 770
 													<?php echo $sub_tab['icon-html']; ?>
768
-												<?php else : ?>
771
+												<?php else {
772
+	: ?>
769 773
 													<span class="give-icon give-icon-default"></span>
770
-												<?php endif; ?>
774
+												<?php endif;
775
+}
776
+?>
771 777
 												<span class="give-label"><?php echo $sub_tab['label']; ?></span>
772 778
 											</a>
773 779
 										</li>
Please login to merge, or discard this patch.