Test Failed
Push — master ( 044ad2...ad363d )
by Devin
10:39 queued 05:12
created
includes/filters.php 1 patch
Spacing   +54 added lines, -56 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
 
@@ -26,34 +26,34 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_set_settings_with_disable_prefix( $old_settings, $settings ) {
29
+function give_set_settings_with_disable_prefix($old_settings, $settings) {
30 30
 	// Bailout.
31
-	if ( ! function_exists( 'give_v18_renamed_core_settings' ) ) {
31
+	if ( ! function_exists('give_v18_renamed_core_settings')) {
32 32
 		return;
33 33
 	}
34 34
 
35 35
 	// Get old setting names.
36
-	$old_settings   = array_flip( give_v18_renamed_core_settings() );
36
+	$old_settings   = array_flip(give_v18_renamed_core_settings());
37 37
 	$update_setting = false;
38 38
 
39
-	foreach ( $settings as $key => $value ) {
39
+	foreach ($settings as $key => $value) {
40 40
 
41 41
 		// Check 1. Check if new option is really updated or not.
42 42
 		// Check 2. Continue if key is not renamed.
43
-		if ( ! isset( $old_settings[ $key ] ) ) {
43
+		if ( ! isset($old_settings[$key])) {
44 44
 			continue;
45 45
 		}
46 46
 
47 47
 		// Set old setting.
48
-		$settings[ $old_settings[ $key ] ] = 'on';
48
+		$settings[$old_settings[$key]] = 'on';
49 49
 
50 50
 		// Do not need to set old setting if new setting is not set.
51 51
 		if (
52
-			( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) )
53
-			|| ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) )
52
+			(give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_')))
53
+			|| ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_')))
54 54
 
55 55
 		) {
56
-			unset( $settings[ $old_settings[ $key ] ] );
56
+			unset($settings[$old_settings[$key]]);
57 57
 		}
58 58
 
59 59
 		// Tell bot to update setting.
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 	}
62 62
 
63 63
 	// Update setting if any old setting set.
64
-	if ( $update_setting ) {
65
-		update_option( 'give_settings', $settings, false );
64
+	if ($update_setting) {
65
+		update_option('give_settings', $settings, false);
66 66
 	}
67 67
 }
68 68
 
69
-add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 );
69
+add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2);
70 70
 
71 71
 /**
72 72
  * Check spam through Akismet.
@@ -80,45 +80,45 @@  discard block
 block discarded – undo
80 80
  *
81 81
  * @return bool|mixed
82 82
  */
83
-function give_akismet( $spam ) {
83
+function give_akismet($spam) {
84 84
 
85 85
 	// Bail out, If spam.
86
-	if ( $spam ) {
86
+	if ($spam) {
87 87
 		return $spam;
88 88
 	}
89 89
 
90 90
 	// Bail out, if Akismet key not exist.
91
-	if ( ! give_check_akismet_key() ) {
91
+	if ( ! give_check_akismet_key()) {
92 92
 		return false;
93 93
 	}
94 94
 
95 95
 	// Build args array.
96 96
 	$args = array();
97 97
 
98
-	$args['comment_author']       = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
99
-	$args['comment_author_email'] = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
100
-	$args['blog']                 = get_option( 'home' );
98
+	$args['comment_author']       = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
99
+	$args['comment_author_email'] = isset($_POST['give_email']) ? $_POST['give_email'] : false;
100
+	$args['blog']                 = get_option('home');
101 101
 	$args['blog_lang']            = get_locale();
102
-	$args['blog_charset']         = get_option( 'blog_charset' );
102
+	$args['blog_charset']         = get_option('blog_charset');
103 103
 	$args['user_ip']              = $_SERVER['REMOTE_ADDR'];
104 104
 	$args['user_agent']           = $_SERVER['HTTP_USER_AGENT'];
105 105
 	$args['referrer']             = $_SERVER['HTTP_REFERER'];
106 106
 	$args['comment_type']         = 'contact-form';
107 107
 
108
-	$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
108
+	$ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
109 109
 
110
-	foreach ( $_SERVER as $key => $value ) {
111
-		if ( ! in_array( $key, (array) $ignore ) ) {
110
+	foreach ($_SERVER as $key => $value) {
111
+		if ( ! in_array($key, (array) $ignore)) {
112 112
 			$args["$key"] = $value;
113 113
 		}
114 114
 	}
115 115
 
116 116
 	// It will return Akismet spam detect API response.
117
-	return give_akismet_spam_check( $args );
117
+	return give_akismet_spam_check($args);
118 118
 
119 119
 }
120 120
 
121
-add_filter( 'give_spam', 'give_akismet' );
121
+add_filter('give_spam', 'give_akismet');
122 122
 
123 123
 /**
124 124
  * Check Akismet API Key.
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
  * @return bool
129 129
  */
130 130
 function give_check_akismet_key() {
131
-	if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { // Akismet v3.0+
131
+	if (is_callable(array('Akismet', 'get_api_key'))) { // Akismet v3.0+
132 132
 		return (bool) Akismet::get_api_key();
133 133
 	}
134 134
 
135
-	if ( function_exists( 'akismet_get_key' ) ) {
135
+	if (function_exists('akismet_get_key')) {
136 136
 		return (bool) akismet_get_key();
137 137
 	}
138 138
 
@@ -148,26 +148,26 @@  discard block
 block discarded – undo
148 148
  *
149 149
  * @return bool|mixed
150 150
  */
151
-function give_akismet_spam_check( $args ) {
151
+function give_akismet_spam_check($args) {
152 152
 	global $akismet_api_host, $akismet_api_port;
153 153
 
154 154
 	$spam         = false;
155
-	$query_string = http_build_query( $args );
155
+	$query_string = http_build_query($args);
156 156
 
157
-	if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { // Akismet v3.0+
158
-		$response = Akismet::http_post( $query_string, 'comment-check' );
157
+	if (is_callable(array('Akismet', 'http_post'))) { // Akismet v3.0+
158
+		$response = Akismet::http_post($query_string, 'comment-check');
159 159
 	} else {
160
-		$response = akismet_http_post( $query_string, $akismet_api_host,
161
-			'/1.1/comment-check', $akismet_api_port );
160
+		$response = akismet_http_post($query_string, $akismet_api_host,
161
+			'/1.1/comment-check', $akismet_api_port);
162 162
 	}
163 163
 
164 164
 	// It's spam if response status is true.
165
-	if ( 'true' === $response[1] ) {
165
+	if ('true' === $response[1]) {
166 166
 		$spam = true;
167 167
 	}
168 168
 
169 169
 	// Allow developer to modified Akismet spam detection response.
170
-	return apply_filters( 'give_akismet_spam_check', $spam, $args );
170
+	return apply_filters('give_akismet_spam_check', $spam, $args);
171 171
 }
172 172
 
173 173
 /**
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
  *
181 181
  * @return array
182 182
  */
183
-function give_bc_v1817_iranian_currency_code( $currencies ) {
184
-	if ( ! give_has_upgrade_completed( 'v1817_update_donation_iranian_currency_code' ) ) {
183
+function give_bc_v1817_iranian_currency_code($currencies) {
184
+	if ( ! give_has_upgrade_completed('v1817_update_donation_iranian_currency_code')) {
185 185
 		$currencies['RIAL'] = $currencies['IRR'];
186 186
 	}
187 187
 
188 188
 	return $currencies;
189 189
 }
190 190
 
191
-add_filter( 'give_currencies', 'give_bc_v1817_iranian_currency_code', 0 );
191
+add_filter('give_currencies', 'give_bc_v1817_iranian_currency_code', 0);
192 192
 
193 193
 
194 194
 /**
@@ -202,25 +202,23 @@  discard block
 block discarded – undo
202 202
  *
203 203
  * @return string
204 204
  */
205
-function give_format_price_for_right_to_left_supported_currency( $formatted_amount, $currency_args, $price ) {
206
-	if ( ! give_is_right_to_left_supported_currency( $currency_args['currency_code'] ) ) {
205
+function give_format_price_for_right_to_left_supported_currency($formatted_amount, $currency_args, $price) {
206
+	if ( ! give_is_right_to_left_supported_currency($currency_args['currency_code'])) {
207 207
 		return $formatted_amount;
208 208
 	}
209 209
 
210 210
 	$formatted_amount = (
211 211
 	'before' === (string) $currency_args['position'] ?
212
-		'‫' . $price . $currency_args['symbol'] . '‬' :
213
-		'‪' . $price . $currency_args['symbol'] . '‬'
212
+		'‫'.$price.$currency_args['symbol'].'‬' : '‪'.$price.$currency_args['symbol'].'‬'
214 213
 	);
215 214
 
216 215
 	$formatted_amount = $currency_args['decode_currency'] ?
217
-		html_entity_decode( $formatted_amount, ENT_COMPAT, 'UTF-8' ) :
218
-		$formatted_amount;
216
+		html_entity_decode($formatted_amount, ENT_COMPAT, 'UTF-8') : $formatted_amount;
219 217
 
220 218
 	return $formatted_amount;
221 219
 }
222 220
 
223
-add_filter( 'give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3 );
221
+add_filter('give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3);
224 222
 
225 223
 /**
226 224
  * Validate active gateway value before returning result.
@@ -231,31 +229,31 @@  discard block
 block discarded – undo
231 229
  *
232 230
  * @return array
233 231
  */
234
-function __give_validate_active_gateways( $value ) {
235
-	$gateways = array_keys( give_get_payment_gateways() );
236
-	$active_gateways = is_array( $value ) ? array_keys( $value ) : array();
232
+function __give_validate_active_gateways($value) {
233
+	$gateways = array_keys(give_get_payment_gateways());
234
+	$active_gateways = is_array($value) ? array_keys($value) : array();
237 235
 
238 236
 	// Remove deactivated payment gateways.
239
-	if( ! empty( $active_gateways ) ) {
240
-		foreach ( $active_gateways as $index => $gateway_id ) {
241
-			if( ! in_array( $gateway_id, $gateways ) ) {
242
-				unset( $value[$gateway_id] );
237
+	if ( ! empty($active_gateways)) {
238
+		foreach ($active_gateways as $index => $gateway_id) {
239
+			if ( ! in_array($gateway_id, $gateways)) {
240
+				unset($value[$gateway_id]);
243 241
 			}
244 242
 		}
245 243
 	}
246 244
 
247
-	if ( empty( $value ) ) {
245
+	if (empty($value)) {
248 246
 		/**
249 247
 		 * Filter the default active gateway
250 248
 		 *
251 249
 		 * @since 2.1.0
252 250
 		 */
253
-		$value = apply_filters( 'give_default_active_gateways', array(
251
+		$value = apply_filters('give_default_active_gateways', array(
254 252
 			'manual' => 1,
255
-		) );
253
+		));
256 254
 	}
257 255
 
258 256
 	return $value;
259 257
 }
260 258
 
261
-add_filter( 'give_get_option_gateways', '__give_validate_active_gateways', 10, 1 );
259
+add_filter('give_get_option_gateways', '__give_validate_active_gateways', 10, 1);
Please login to merge, or discard this patch.
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.