Test Failed
Push — master ( 9a7225...07651e )
by Ravinder
05:42
created
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/emails/class-email-access-email.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if access directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
18
-if ( ! class_exists( 'Give_Email_Access_Email' ) ) :
18
+if ( ! class_exists('Give_Email_Access_Email')) :
19 19
 
20 20
 	/**
21 21
 	 * Give_Email_Access_Email
@@ -31,31 +31,31 @@  discard block
 block discarded – undo
31 31
 		 * @since  2.0
32 32
 		 */
33 33
 		public function init() {
34
-			$this->load( array(
34
+			$this->load(array(
35 35
 				'id'                           => 'email-access',
36
-				'label'                        => __( 'Email access', 'give' ),
37
-				'description'                  => __( 'Sent when donors request access to their donation history using only their email as verification. (See Settings > General > Access Control)', 'give' ),
38
-				'notification_status'          => give_get_option( 'email_access', 'disabled' ),
36
+				'label'                        => __('Email access', 'give'),
37
+				'description'                  => __('Sent when donors request access to their donation history using only their email as verification. (See Settings > General > Access Control)', 'give'),
38
+				'notification_status'          => give_get_option('email_access', 'disabled'),
39 39
 				'form_metabox_setting'         => false,
40 40
 				'notification_status_editable' => false,
41 41
 				'email_tag_context'            => 'donor',
42
-				'recipient_group_name'         => __( 'Donor', 'give' ),
43
-				'default_email_subject'        => sprintf( __( 'Please confirm your email for %s', 'give' ), get_bloginfo( 'url' ) ),
42
+				'recipient_group_name'         => __('Donor', 'give'),
43
+				'default_email_subject'        => sprintf(__('Please confirm your email for %s', 'give'), get_bloginfo('url')),
44 44
 				'default_email_message'        => $this->get_default_email_message(),
45
-				'default_email_header'         => __( 'Confirm Email', 'give' ),
45
+				'default_email_header'         => __('Confirm Email', 'give'),
46 46
 				'notices' => array(
47 47
 					'non-notification-status-editable' => sprintf(
48 48
 						'%1$s <a href="%2$s">%3$s &raquo;</a>',
49
-						__( 'This notification is automatically toggled based on whether the email access is enabled or not.', 'give' ),
50
-						esc_url( admin_url('edit.php?post_type=give_forms&page=give-settings&tab=general&section=access-control') ),
51
-						__( 'Edit Setting', 'give' )
49
+						__('This notification is automatically toggled based on whether the email access is enabled or not.', 'give'),
50
+						esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=general&section=access-control')),
51
+						__('Edit Setting', 'give')
52 52
 					)
53 53
 				),
54
-			) );
54
+			));
55 55
 
56
-			add_filter( "give_{$this->config['id']}_email_notification", array( $this, 'setup_email_notification' ), 10, 2 );
57
-			add_action( 'give_save_settings_give_settings', array( $this, 'set_notification_status' ), 10, 2 );
58
-			add_filter( 'give_email_preview_header', array( $this, 'email_preview_header' ), 10, 2 );
56
+			add_filter("give_{$this->config['id']}_email_notification", array($this, 'setup_email_notification'), 10, 2);
57
+			add_action('give_save_settings_give_settings', array($this, 'set_notification_status'), 10, 2);
58
+			add_filter('give_email_preview_header', array($this, 'email_preview_header'), 10, 2);
59 59
 		}
60 60
 
61 61
 		/**
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 		 *
69 69
 		 * @return string
70 70
 		 */
71
-		public function get_email_subject( $form_id = null ) {
71
+		public function get_email_subject($form_id = null) {
72 72
 			$subject = wp_strip_all_tags(
73 73
 				Give_Email_Notification_Util::get_value(
74 74
 					$this,
75
-					Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject',
75
+					Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject',
76 76
 					$form_id,
77 77
 					$this->config['default_email_subject']
78 78
 				)
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 			 *
85 85
 			 * @since 1.0
86 86
 			 */
87
-			$subject = apply_filters( 'give_email_access_token_subject', $subject );
87
+			$subject = apply_filters('give_email_access_token_subject', $subject);
88 88
 
89 89
 			/**
90 90
 			 * Filters the donation notification subject.
91 91
 			 *
92 92
 			 * @since 2.0
93 93
 			 */
94
-			$subject = apply_filters( "give_{$this->config['id']}_get_email_subject", $subject, $this, $form_id );
94
+			$subject = apply_filters("give_{$this->config['id']}_get_email_subject", $subject, $this, $form_id);
95 95
 
96 96
 			return $subject;
97 97
 		}
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 		 *
108 108
 		 * @return string
109 109
 		 */
110
-		public function get_email_message( $form_id = null ) {
110
+		public function get_email_message($form_id = null) {
111 111
 			$message = Give_Email_Notification_Util::get_value(
112 112
 				$this,
113
-				Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message',
113
+				Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message',
114 114
 				$form_id,
115 115
 				$this->config['default_email_message']
116 116
 			);
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
 			 *
122 122
 			 * @since 1.0
123 123
 			 */
124
-			$message = apply_filters( 'give_email_access_token_message', $message );
124
+			$message = apply_filters('give_email_access_token_message', $message);
125 125
 
126 126
 			/**
127 127
 			 * Filter the email message
128 128
 			 *
129 129
 			 * @since 2.0
130 130
 			 */
131
-			$message = apply_filters( "give_{$this->config['id']}_get_default_email_message", $message, $this, $form_id );
131
+			$message = apply_filters("give_{$this->config['id']}_get_default_email_message", $message, $this, $form_id);
132 132
 
133 133
 			return $message;
134 134
 		}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		 * @param int $form_id
144 144
 		 * @return array
145 145
 		 */
146
-		public function get_email_attachments( $form_id = null ) {
146
+		public function get_email_attachments($form_id = null) {
147 147
 			/**
148 148
 			 * Filters the donation notification email attachments.
149 149
 			 * By default, there is no attachment but plugins can hook in to provide one more multiple.
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 			 *
152 152
 			 * @since 1.0
153 153
 			 */
154
-			$attachments = apply_filters( 'give_admin_donation_notification_attachments', array() );
154
+			$attachments = apply_filters('give_admin_donation_notification_attachments', array());
155 155
 
156 156
 			/**
157 157
 			 * Filters the donation notification email attachments.
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			 *
160 160
 			 * @since 2.0
161 161
 			 */
162
-			$attachments = apply_filters( "give_{$this->config['id']}_get_email_attachments", $attachments, $this, $form_id );
162
+			$attachments = apply_filters("give_{$this->config['id']}_get_email_attachments", $attachments, $this, $form_id);
163 163
 
164 164
 			return $attachments;
165 165
 		}
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 		 * @return string
175 175
 		 */
176 176
 		public function get_default_email_message() {
177
-			$message = __( 'Please click the link to access your donation history on {site_url}. If you did not request this email, please contact {admin_email}.', 'give' ) . "\n\n";
178
-			$message .= '{email_access_link}' . "\n\n";
177
+			$message = __('Please click the link to access your donation history on {site_url}. If you did not request this email, please contact {admin_email}.', 'give')."\n\n";
178
+			$message .= '{email_access_link}'."\n\n";
179 179
 			$message .= "\n\n";
180
-			$message .= __( 'Sincerely,', 'give' ) . "\n";
181
-			$message .= get_bloginfo( 'name' ) . "\n";
180
+			$message .= __('Sincerely,', 'give')."\n";
181
+			$message .= get_bloginfo('name')."\n";
182 182
 
183 183
 			/**
184 184
 			 * Filter the new donation email message
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 			 *
188 188
 			 * @param string $message
189 189
 			 */
190
-			return apply_filters( "give_{$this->config['id']}_get_default_email_message", $message, $this );
190
+			return apply_filters("give_{$this->config['id']}_get_default_email_message", $message, $this);
191 191
 		}
192 192
 
193 193
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 			 *
204 204
 			 * @since 1.0
205 205
 			 */
206
-			$from_name = apply_filters( 'give_donation_from_name', Give()->emails->get_from_name() );
206
+			$from_name = apply_filters('give_donation_from_name', Give()->emails->get_from_name());
207 207
 
208 208
 			/**
209 209
 			 * Filters the from email.
@@ -211,19 +211,19 @@  discard block
 block discarded – undo
211 211
 			 *
212 212
 			 * @since 1.0
213 213
 			 */
214
-			$from_email = apply_filters( 'give_donation_from_address', Give()->emails->get_from_address() );
214
+			$from_email = apply_filters('give_donation_from_address', Give()->emails->get_from_address());
215 215
 
216
-			Give()->emails->__set( 'from_name', $from_name );
217
-			Give()->emails->__set( 'from_email', $from_email );
218
-			Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', $this->get_email_header() ) );
216
+			Give()->emails->__set('from_name', $from_name);
217
+			Give()->emails->__set('from_email', $from_email);
218
+			Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', $this->get_email_header()));
219 219
 			/**
220 220
 			 * Filters the donation notification email headers.
221 221
 			 *
222 222
 			 * @since 1.0
223 223
 			 */
224
-			$headers = apply_filters( 'give_admin_donation_notification_headers', Give()->emails->get_headers() );
224
+			$headers = apply_filters('give_admin_donation_notification_headers', Give()->emails->get_headers());
225 225
 
226
-			Give()->emails->__set( 'headers', $headers );
226
+			Give()->emails->__set('headers', $headers);
227 227
 		}
228 228
 
229 229
 		/**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 		 *
238 238
 		 * @return bool
239 239
 		 */
240
-		public function setup_email_notification( $donor_id, $email ) {
241
-			$donor = Give()->donors->get_donor_by( 'email', $email );
240
+		public function setup_email_notification($donor_id, $email) {
241
+			$donor = Give()->donors->get_donor_by('email', $email);
242 242
 			$this->recipient_email = $email;
243 243
 
244 244
 			// Set email data.
@@ -263,17 +263,17 @@  discard block
 block discarded – undo
263 263
 		 * @param $update_options
264 264
 		 * @param $option_name
265 265
 		 */
266
-		public function set_notification_status( $update_options, $option_name ) {
266
+		public function set_notification_status($update_options, $option_name) {
267 267
 			// Get updated settings.
268 268
 			$update_options = give_get_settings();
269 269
 
270 270
 			if (
271
-				! empty( $update_options['email_access'] )
272
-				&& ! empty( $update_options[ "{$this->config['id']}_notification" ] )
273
-				&& $update_options['email_access'] !== $update_options[ "{$this->config['id']}_notification" ]
271
+				! empty($update_options['email_access'])
272
+				&& ! empty($update_options["{$this->config['id']}_notification"])
273
+				&& $update_options['email_access'] !== $update_options["{$this->config['id']}_notification"]
274 274
 			) {
275
-				$update_options[ "{$this->config['id']}_notification" ] = $update_options['email_access'];
276
-				update_option( $option_name, $update_options, false );
275
+				$update_options["{$this->config['id']}_notification"] = $update_options['email_access'];
276
+				update_option($option_name, $update_options, false);
277 277
 			}
278 278
 		}
279 279
 
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 		 * @param Give_Email_Access_Email $email
289 289
 		 * @return string
290 290
 		 */
291
-		public function email_preview_header( $email_preview_header, $email ) {
292
-			if( $this->config['id'] === $email->config['id'] ) {
291
+		public function email_preview_header($email_preview_header, $email) {
292
+			if ($this->config['id'] === $email->config['id']) {
293 293
 				$email_preview_header = '';
294 294
 			}
295 295
 
Please login to merge, or discard this patch.
includes/admin/emails/class-new-offline-donation-email.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if access directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19
-if ( ! class_exists( 'Give_New_Offline_Donation_Email' ) ) :
19
+if ( ! class_exists('Give_New_Offline_Donation_Email')) :
20 20
 
21 21
 	/**
22 22
 	 * Give_New_Offline_Donation_Email
@@ -36,33 +36,33 @@  discard block
 block discarded – undo
36 36
 		 */
37 37
 		public function init() {
38 38
 			// Initialize empty payment.
39
-			$this->payment = new Give_Payment( 0 );
39
+			$this->payment = new Give_Payment(0);
40 40
 
41
-			$this->load( array(
41
+			$this->load(array(
42 42
 				'id'                           => 'new-offline-donation',
43
-				'label'                        => __( 'New Offline Donation', 'give' ),
44
-				'description'                  => __( 'Sent to designated recipient(s) for a new (pending) offline donation.', 'give' ),
43
+				'label'                        => __('New Offline Donation', 'give'),
44
+				'description'                  => __('Sent to designated recipient(s) for a new (pending) offline donation.', 'give'),
45 45
 				'has_recipient_field'          => true,
46
-				'notification_status'          => give_is_gateway_active( 'offline' ) ? 'enabled' : 'disabled',
46
+				'notification_status'          => give_is_gateway_active('offline') ? 'enabled' : 'disabled',
47 47
 				'notification_status_editable' => false,
48 48
 				'preview_email_tags_values'    => array(
49
-					'payment_method' => esc_html__( 'Offline', 'give' ),
49
+					'payment_method' => esc_html__('Offline', 'give'),
50 50
 				),
51 51
 				'default_email_subject'        => $this->get_default_email_subject(),
52 52
 				'default_email_message'        => $this->get_default_email_message(),
53
-				'default_email_header'         => __( 'New Offline Donation!', 'give' ),
53
+				'default_email_header'         => __('New Offline Donation!', 'give'),
54 54
 				'notices' => array(
55 55
 					'non-notification-status-editable' => sprintf(
56 56
 						'%1$s <a href="%2$s">%3$s &raquo;</a>',
57
-						__( 'This notification is automatically toggled based on whether the gateway is enabled or not.', 'give' ),
58
-						esc_url( admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=offline-donations') ),
59
-						__( 'Edit Setting', 'give' )
57
+						__('This notification is automatically toggled based on whether the gateway is enabled or not.', 'give'),
58
+						esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=offline-donations')),
59
+						__('Edit Setting', 'give')
60 60
 					)
61 61
 				),
62
-			) );
62
+			));
63 63
 
64
-			add_action( 'give_insert_payment', array( $this, 'setup_email_notification' ) );
65
-			add_action( 'give_save_settings_give_settings', array( $this, 'set_notification_status' ), 10, 2 );
64
+			add_action('give_insert_payment', array($this, 'setup_email_notification'));
65
+			add_action('give_save_settings_give_settings', array($this, 'set_notification_status'), 10, 2);
66 66
 		}
67 67
 
68 68
 		/**
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 			 */
82 82
 			$subject = apply_filters(
83 83
 				'give_offline_admin_donation_notification_subject',
84
-				__( 'New Pending Donation', 'give' )
84
+				__('New Pending Donation', 'give')
85 85
 			);
86 86
 
87 87
 			/**
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 		 * @return string
107 107
 		 */
108 108
 		public function get_default_email_message() {
109
-			$message = __( 'Dear Admin,', 'give' ) . "\n\n";
110
-			$message .= __( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' ';
111
-			$message .= __( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n";
109
+			$message = __('Dear Admin,', 'give')."\n\n";
110
+			$message .= __('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' ';
111
+			$message .= __('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n";
112 112
 
113
-			$message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
114
-			$message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n";
113
+			$message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n";
114
+			$message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n";
115 115
 
116 116
 			$message .= sprintf(
117 117
 				'<a href="%1$s">%2$s</a>',
118
-				admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $this->payment->ID ),
119
-				__( 'Click Here to View and/or Update Donation Details', 'give' )
120
-			) . "\n\n";
118
+				admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$this->payment->ID),
119
+				__('Click Here to View and/or Update Donation Details', 'give')
120
+			)."\n\n";
121 121
 
122 122
 			/**
123 123
 			 * Filter the donation receipt email message
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 		 *
156 156
 		 * @return string
157 157
 		 */
158
-		public function get_email_message( $form_id = null ) {
158
+		public function get_email_message($form_id = null) {
159 159
 			$message = Give_Email_Notification_Util::get_value(
160 160
 				$this,
161
-				Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message',
161
+				Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message',
162 162
 				$form_id,
163 163
 				$this->config['default_email_message']
164 164
 			);
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 		 *
199 199
 		 * @return array
200 200
 		 */
201
-		public function get_email_attachments( $form_id = null ) {
201
+		public function get_email_attachments($form_id = null) {
202 202
 			/**
203 203
 			 * Filter the attachments.
204 204
 			 * Note: This filter will deprecate soon.
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 				)
241 241
 			);
242 242
 
243
-			Give()->emails->__set( 'heading', $this->get_email_header() );
243
+			Give()->emails->__set('heading', $this->get_email_header());
244 244
 		}
245 245
 
246 246
 		/**
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
 		 *
252 252
 		 * @param int $payment_id
253 253
 		 */
254
-		public function setup_email_notification( $payment_id ) {
255
-			$this->payment = new Give_Payment( $payment_id );
254
+		public function setup_email_notification($payment_id) {
255
+			$this->payment = new Give_Payment($payment_id);
256 256
 
257 257
 			// Exit if not donation was not with offline donation.
258
-			if ( 'offline' !== $this->payment->gateway ) {
258
+			if ('offline' !== $this->payment->gateway) {
259 259
 				return;
260 260
 			}
261 261
 
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
 			$this->setup_email_data();
264 264
 
265 265
 			// Send email.
266
-			$this->send_email_notification( array(
266
+			$this->send_email_notification(array(
267 267
 				'payment_id' => $this->payment->ID,
268
-			) );
268
+			));
269 269
 		}
270 270
 
271 271
 		/**
@@ -277,18 +277,18 @@  discard block
 block discarded – undo
277 277
 		 * @param $update_options
278 278
 		 * @param $option_name
279 279
 		 */
280
-		public function set_notification_status( $update_options, $option_name ) {
280
+		public function set_notification_status($update_options, $option_name) {
281 281
 			// Get updated settings.
282 282
 			$update_options = give_get_settings();
283 283
 
284
-			$notification_status = isset( $update_options['gateways']['offline'] ) ? 'enabled' : 'disabled';
284
+			$notification_status = isset($update_options['gateways']['offline']) ? 'enabled' : 'disabled';
285 285
 
286 286
 			if (
287
-				empty( $update_options[ "{$this->config['id']}_notification" ] )
288
-				|| $notification_status !== $update_options[ "{$this->config['id']}_notification" ]
287
+				empty($update_options["{$this->config['id']}_notification"])
288
+				|| $notification_status !== $update_options["{$this->config['id']}_notification"]
289 289
 			) {
290
-				$update_options[ "{$this->config['id']}_notification" ] = $notification_status;
291
-				update_option( $option_name, $update_options, false );
290
+				$update_options["{$this->config['id']}_notification"] = $notification_status;
291
+				update_option($option_name, $update_options, false);
292 292
 			}
293 293
 		}
294 294
 
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 		 *
304 304
 		 * @return array
305 305
 		 */
306
-		public function add_metabox_setting_field( $settings, $form_id ) {
306
+		public function add_metabox_setting_field($settings, $form_id) {
307 307
 
308
-			if ( in_array( 'offline', array_keys( give_get_enabled_payment_gateways($form_id) ) ) ) {
308
+			if (in_array('offline', array_keys(give_get_enabled_payment_gateways($form_id)))) {
309 309
 				$settings[] = array(
310 310
 					'id'     => $this->config['id'],
311 311
 					'title'  => $this->config['label'],
312
-					'fields' => $this->get_setting_fields( $form_id ),
312
+					'fields' => $this->get_setting_fields($form_id),
313 313
 				);
314 314
 			}
315 315
 
Please login to merge, or discard this patch.
includes/admin/emails/class-offline-donation-instruction-email.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if access directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19
-if ( ! class_exists( 'Give_Offline_Donation_Instruction_Email' ) ) :
19
+if ( ! class_exists('Give_Offline_Donation_Instruction_Email')) :
20 20
 
21 21
 	/**
22 22
 	 * Give_Offline_Donation_Instruction_Email
@@ -36,33 +36,33 @@  discard block
 block discarded – undo
36 36
 		 */
37 37
 		public function init() {
38 38
 			// Initialize empty payment.
39
-			$this->payment = new Give_Payment( 0 );
39
+			$this->payment = new Give_Payment(0);
40 40
 
41
-			$this->load( array(
41
+			$this->load(array(
42 42
 				'id'                           => 'offline-donation-instruction',
43
-				'label'                        => __( 'Offline Donation Instructions', 'give' ),
44
-				'description'                  => __( 'Sent to the donor when they submit an offline donation.', 'give' ),
45
-				'notification_status'          => give_is_gateway_active( 'offline' ) ? 'enabled' : 'disabled',
43
+				'label'                        => __('Offline Donation Instructions', 'give'),
44
+				'description'                  => __('Sent to the donor when they submit an offline donation.', 'give'),
45
+				'notification_status'          => give_is_gateway_active('offline') ? 'enabled' : 'disabled',
46 46
 				'form_metabox_setting'         => true,
47 47
 				'notification_status_editable' => false,
48 48
 				'preview_email_tag_values'     => array(
49
-					'payment_method' => esc_html__( 'Offline', 'give' ),
49
+					'payment_method' => esc_html__('Offline', 'give'),
50 50
 				),
51
-				'default_email_subject'        => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ),
51
+				'default_email_subject'        => esc_attr__('{donation} - Offline Donation Instructions', 'give'),
52 52
 				'default_email_message'        => give_get_default_offline_donation_email_content(),
53
-				'default_email_header'         => __( 'Offline Donation Instructions', 'give' ),
53
+				'default_email_header'         => __('Offline Donation Instructions', 'give'),
54 54
 				'notices' => array(
55 55
 					'non-notification-status-editable' => sprintf(
56 56
 						'%1$s <a href="%2$s">%3$s &raquo;</a>',
57
-						__( 'This notification is automatically toggled based on whether the gateway is enabled or not.', 'give' ),
58
-						esc_url( admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=offline-donations') ),
59
-						__( 'Edit Setting', 'give' )
57
+						__('This notification is automatically toggled based on whether the gateway is enabled or not.', 'give'),
58
+						esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways&section=offline-donations')),
59
+						__('Edit Setting', 'give')
60 60
 					)
61 61
 				),
62
-			) );
62
+			));
63 63
 
64
-			add_action( 'give_insert_payment', array( $this, 'setup_email_notification' ) );
65
-			add_action( 'give_save_settings_give_settings', array( $this, 'set_notification_status' ), 10, 2 );
64
+			add_action('give_insert_payment', array($this, 'setup_email_notification'));
65
+			add_action('give_save_settings_give_settings', array($this, 'set_notification_status'), 10, 2);
66 66
 		}
67 67
 
68 68
 		/**
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 		 *
75 75
 		 * @return string
76 76
 		 */
77
-		public function get_email_message( $form_id = null ) {
77
+		public function get_email_message($form_id = null) {
78 78
 			$message = Give_Email_Notification_Util::get_value(
79 79
 				$this,
80
-				Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message',
80
+				Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message',
81 81
 				$form_id,
82 82
 				$this->config['default_email_message']
83 83
 			);
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @return string
108 108
 		 */
109
-		public function get_email_subject( $form_id = null ) {
109
+		public function get_email_subject($form_id = null) {
110 110
 			$subject = wp_strip_all_tags(
111 111
 				Give_Email_Notification_Util::get_value(
112 112
 					$this,
113
-					Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject',
113
+					Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject',
114 114
 					$form_id,
115 115
 					$this->config['default_email_subject']
116 116
 				)
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		 * @param int $form_id
140 140
 		 * @return array
141 141
 		 */
142
-		public function get_email_attachments( $form_id = null ) {
142
+		public function get_email_attachments($form_id = null) {
143 143
 			/**
144 144
 			 * Filter the attachments.
145 145
 			 * Note: This filter will deprecate soon.
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
 				$this->payment->payment_meta
203 203
 			);
204 204
 
205
-			Give()->emails->__set( 'from_name', $from_name );
206
-			Give()->emails->__set( 'from_email', $from_email );
207
-			Give()->emails->__set( 'heading', $this->get_email_header() );
208
-			Give()->emails->__set( 'headers', apply_filters( 'give_receipt_headers', Give()->emails->get_headers(), $this->payment->ID, $this->payment->payment_meta ) );
205
+			Give()->emails->__set('from_name', $from_name);
206
+			Give()->emails->__set('from_email', $from_email);
207
+			Give()->emails->__set('heading', $this->get_email_header());
208
+			Give()->emails->__set('headers', apply_filters('give_receipt_headers', Give()->emails->get_headers(), $this->payment->ID, $this->payment->payment_meta));
209 209
 		}
210 210
 
211 211
 		/**
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
 		 *
217 217
 		 * @param int $payment_id
218 218
 		 */
219
-		public function setup_email_notification( $payment_id ) {
220
-			$this->payment = new Give_Payment( $payment_id );
219
+		public function setup_email_notification($payment_id) {
220
+			$this->payment = new Give_Payment($payment_id);
221 221
 
222 222
 			// Exit if not donation was not with offline donation.
223
-			if ( 'offline' !== $this->payment->gateway ) {
223
+			if ('offline' !== $this->payment->gateway) {
224 224
 				return;
225 225
 			}
226 226
 
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 			$this->setup_email_data();
229 229
 
230 230
 			// Send email.
231
-			$this->send_email_notification( array(
231
+			$this->send_email_notification(array(
232 232
 				'payment_id' => $this->payment->ID,
233
-			) );
233
+			));
234 234
 		}
235 235
 
236 236
 		/**
@@ -242,18 +242,18 @@  discard block
 block discarded – undo
242 242
 		 * @param $update_options
243 243
 		 * @param $option_name
244 244
 		 */
245
-		public function set_notification_status( $update_options, $option_name ) {
245
+		public function set_notification_status($update_options, $option_name) {
246 246
 			// Get updated settings.
247 247
 			$update_options = give_get_settings();
248 248
 
249
-			$notification_status = isset( $update_options['gateways']['offline'] ) ? 'enabled' : 'disabled';
249
+			$notification_status = isset($update_options['gateways']['offline']) ? 'enabled' : 'disabled';
250 250
 
251 251
 			if (
252
-				empty( $update_options["{$this->config['id']}_notification"] )
252
+				empty($update_options["{$this->config['id']}_notification"])
253 253
 				|| $notification_status !== $update_options["{$this->config['id']}_notification"]
254 254
 			) {
255 255
 				$update_options["{$this->config['id']}_notification"] = $notification_status;
256
-				update_option( $option_name, $update_options, false );
256
+				update_option($option_name, $update_options, false);
257 257
 			}
258 258
 		}
259 259
 
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
 		 *
270 270
 		 * @return array
271 271
 		 */
272
-		public function add_metabox_setting_field( $settings, $form_id ) {
273
-			if ( in_array( 'offline', array_keys( give_get_enabled_payment_gateways($form_id) ) ) ) {
272
+		public function add_metabox_setting_field($settings, $form_id) {
273
+			if (in_array('offline', array_keys(give_get_enabled_payment_gateways($form_id)))) {
274 274
 				$settings[] = array(
275 275
 					'id'     => $this->config['id'],
276 276
 					'title'  => $this->config['label'],
277
-					'fields' => $this->get_setting_fields( $form_id ),
277
+					'fields' => $this->get_setting_fields($form_id),
278 278
 				);
279 279
 			}
280 280
 
Please login to merge, or discard this patch.
includes/admin/class-admin-settings.php 2 patches
Spacing   +258 added lines, -259 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
 			return $option_value;
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		 *
314 314
 		 * @return void
315 315
 		 */
316
-		public static function output_fields( $options, $option_name = '' ) {
316
+		public static function output_fields($options, $option_name = '') {
317 317
 			$current_tab = give_get_current_setting_tab();
318 318
 
319 319
 			// Field Default values.
@@ -325,62 +325,62 @@  discard block
 block discarded – undo
325 325
 				'desc'                => '',
326 326
 				'table_html'          => true,
327 327
 				'repeat'              => false,
328
-				'repeat_btn_title'    => __( 'Add Field', 'give' ),
328
+				'repeat_btn_title'    => __('Add Field', 'give'),
329 329
 			);
330 330
 
331
-			foreach ( $options as $value ) {
332
-				if ( ! isset( $value['type'] ) ) {
331
+			foreach ($options as $value) {
332
+				if ( ! isset($value['type'])) {
333 333
 					continue;
334 334
 				}
335 335
 
336 336
 				// Set title.
337
-				$defaults['title'] = isset( $value['name'] ) ? $value['name'] : '';
337
+				$defaults['title'] = isset($value['name']) ? $value['name'] : '';
338 338
 
339 339
 				// Set default setting.
340
-				$value = wp_parse_args( $value, $defaults );
340
+				$value = wp_parse_args($value, $defaults);
341 341
 
342 342
 				// Colorpicker field.
343
-				$value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] );
344
-				$value['type']  = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] );
343
+				$value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']);
344
+				$value['type']  = ('colorpicker' === $value['type'] ? 'text' : $value['type']);
345 345
 
346 346
 
347 347
 				// Custom attribute handling.
348 348
 				$custom_attributes = array();
349 349
 
350
-				if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) {
351
-					foreach ( $value['attributes'] as $attribute => $attribute_value ) {
352
-						$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
350
+				if ( ! empty($value['attributes']) && is_array($value['attributes'])) {
351
+					foreach ($value['attributes'] as $attribute => $attribute_value) {
352
+						$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"';
353 353
 					}
354 354
 				}
355 355
 
356 356
 				// Description handling.
357
-				$description = self::get_field_description( $value );
357
+				$description = self::get_field_description($value);
358 358
 
359 359
 				// Switch based on type.
360
-				switch ( $value['type'] ) {
360
+				switch ($value['type']) {
361 361
 
362 362
 					// Section Titles.
363 363
 					case 'title':
364
-						if ( ! empty( $value['title'] ) || ! empty( $value['desc'] ) ) {
364
+						if ( ! empty($value['title']) || ! empty($value['desc'])) {
365 365
 							?>
366 366
 							<div class="give-setting-tab-header give-setting-tab-header-<?php echo $current_tab; ?>">
367
-								<?php if ( ! empty( $value['title'] ) ) : ?>
368
-									<h2><?php echo self::get_field_title( $value ); ?></h2>
367
+								<?php if ( ! empty($value['title'])) : ?>
368
+									<h2><?php echo self::get_field_title($value); ?></h2>
369 369
 									<hr>
370 370
 								<?php endif; ?>
371 371
 
372
-								<?php if ( ! empty( $value['desc'] ) ) : ?>
373
-									<?php echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); ?>
372
+								<?php if ( ! empty($value['desc'])) : ?>
373
+									<?php echo wpautop(wptexturize(wp_kses_post($value['desc']))); ?>
374 374
 								<?php endif; ?>
375 375
 							</div>
376 376
 							<?php
377 377
 						}
378 378
 
379
-						if ( $value['table_html'] ) {
380
-							echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n";
379
+						if ($value['table_html']) {
380
+							echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n";
381 381
 						}
382 382
 
383
-						if ( ! empty( $value['id'] ) ) {
383
+						if ( ! empty($value['id'])) {
384 384
 
385 385
 							/**
386 386
 							 * Trigger Action.
@@ -389,14 +389,14 @@  discard block
 block discarded – undo
389 389
 							 *
390 390
 							 * @since 1.8
391 391
 							 */
392
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) );
392
+							do_action('give_settings_'.sanitize_title($value['id']));
393 393
 						}
394 394
 
395 395
 						break;
396 396
 
397 397
 					// Section Ends.
398 398
 					case 'sectionend':
399
-						if ( ! empty( $value['id'] ) ) {
399
+						if ( ! empty($value['id'])) {
400 400
 
401 401
 							/**
402 402
 							 * Trigger Action.
@@ -405,14 +405,14 @@  discard block
 block discarded – undo
405 405
 							 *
406 406
 							 * @since 1.8
407 407
 							 */
408
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' );
408
+							do_action('give_settings_'.sanitize_title($value['id']).'_end');
409 409
 						}
410 410
 
411
-						if ( $value['table_html'] ) {
411
+						if ($value['table_html']) {
412 412
 							echo '</table>';
413 413
 						}
414 414
 
415
-						if ( ! empty( $value['id'] ) ) {
415
+						if ( ! empty($value['id'])) {
416 416
 
417 417
 							/**
418 418
 							 * Trigger Action.
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 							 *
422 422
 							 * @since 1.8
423 423
 							 */
424
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' );
424
+							do_action('give_settings_'.sanitize_title($value['id']).'_after');
425 425
 						}
426 426
 
427 427
 						break;
@@ -429,51 +429,51 @@  discard block
 block discarded – undo
429 429
 					// Standard text inputs and subtypes like 'number'.
430 430
 					case 'colorpicker':
431 431
 					case 'hidden' :
432
-						$value['wrapper_class'] = empty( $value['wrapper_class'] ) ? 'give-hidden' : trim( $value['wrapper_class'] ) . ' give-hidden';
432
+						$value['wrapper_class'] = empty($value['wrapper_class']) ? 'give-hidden' : trim($value['wrapper_class']).' give-hidden';
433 433
 					case 'text':
434 434
 					case 'email':
435 435
 					case 'number':
436 436
 					case 'password' :
437 437
 						$type = $value['type'];
438
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
438
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
439 439
 
440 440
 						// Set default value for repeater field if not any value set yet.
441
-						if ( $value['repeat'] && is_string( $option_value ) ) {
442
-							$option_value = array( $value['default'] );
441
+						if ($value['repeat'] && is_string($option_value)) {
442
+							$option_value = array($value['default']);
443 443
 						}
444 444
 						?>
445
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
445
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
446 446
 						<th scope="row" class="titledesc">
447 447
 							<label
448
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
448
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
449 449
 						</th>
450
-						<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
451
-							<?php if ( $value['repeat'] ) : ?>
452
-								<?php foreach ( $option_value as $index => $field_value ) : ?>
450
+						<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
451
+							<?php if ($value['repeat']) : ?>
452
+								<?php foreach ($option_value as $index => $field_value) : ?>
453 453
 									<p>
454 454
 										<input
455
-												name="<?php echo esc_attr( $value['id'] ); ?>[]"
456
-												type="<?php echo esc_attr( $type ); ?>"
457
-												style="<?php echo esc_attr( $value['css'] ); ?>"
458
-												value="<?php echo esc_attr( $field_value ); ?>"
459
-												class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?> <?php echo esc_attr( $value['id'] ); ?>"
460
-											<?php echo implode( ' ', $custom_attributes ); ?>
455
+												name="<?php echo esc_attr($value['id']); ?>[]"
456
+												type="<?php echo esc_attr($type); ?>"
457
+												style="<?php echo esc_attr($value['css']); ?>"
458
+												value="<?php echo esc_attr($field_value); ?>"
459
+												class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?> <?php echo esc_attr($value['id']); ?>"
460
+											<?php echo implode(' ', $custom_attributes); ?>
461 461
 										/>
462 462
 										<span class="give-remove-setting-field"
463
-												title="<?php esc_html_e( 'Remove setting field', 'give' ); ?>">-</span>
463
+												title="<?php esc_html_e('Remove setting field', 'give'); ?>">-</span>
464 464
 									</p>
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 468
 							<?php else : ?>
469 469
 								<input
470
-										name="<?php echo esc_attr( $value['id'] ); ?>"
471
-										id="<?php echo esc_attr( $value['id'] ); ?>"
472
-										type="<?php echo esc_attr( $type ); ?>"
473
-										style="<?php echo esc_attr( $value['css'] ); ?>"
474
-										value="<?php echo esc_attr( $option_value ); ?>"
475
-										class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>"
476
-									<?php echo implode( ' ', $custom_attributes ); ?>
470
+										name="<?php echo esc_attr($value['id']); ?>"
471
+										id="<?php echo esc_attr($value['id']); ?>"
472
+										type="<?php echo esc_attr($type); ?>"
473
+										style="<?php echo esc_attr($value['css']); ?>"
474
+										value="<?php echo esc_attr($option_value); ?>"
475
+										class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>"
476
+									<?php echo implode(' ', $custom_attributes); ?>
477 477
 								/>
478 478
 							<?php endif; ?>
479 479
 							<?php echo $description; ?>
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
 					// Textarea.
485 485
 					case 'textarea':
486 486
 
487
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
487
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
488 488
 						$default_attributes = array(
489 489
 							'rows' => 10,
490 490
 							'cols' => 60
491 491
 						);
492
-						$textarea_attributes = isset( $value['attributes'] ) ? $value['attributes'] : array();
492
+						$textarea_attributes = isset($value['attributes']) ? $value['attributes'] : array();
493 493
 						?>
494
-						<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
494
+						<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
495 495
 							<th scope="row" class="titledesc">
496 496
 								<label
497
-										for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
497
+										for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
498 498
 							</th>
499
-							<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
499
+							<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
500 500
 										<textarea
501
-											name="<?php echo esc_attr( $value['id'] ); ?>"
502
-											id="<?php echo esc_attr( $value['id'] ); ?>"
503
-											style="<?php echo esc_attr( $value['css'] ); ?>"
504
-											class="<?php echo esc_attr( $value['class'] ); ?>"
505
-											<?php echo give_get_attribute_str( $textarea_attributes, $default_attributes ); ?>
506
-										><?php echo esc_textarea( $option_value ); ?></textarea>
501
+											name="<?php echo esc_attr($value['id']); ?>"
502
+											id="<?php echo esc_attr($value['id']); ?>"
503
+											style="<?php echo esc_attr($value['css']); ?>"
504
+											class="<?php echo esc_attr($value['class']); ?>"
505
+											<?php echo give_get_attribute_str($textarea_attributes, $default_attributes); ?>
506
+										><?php echo esc_textarea($option_value); ?></textarea>
507 507
 								<?php echo $description; ?>
508 508
 							</td>
509 509
 						</tr>
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 					// Select boxes.
514 514
 					case 'select' :
515 515
 					case 'multiselect' :
516
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
516
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
517 517
 
518 518
 						/**
519 519
 						 * Insert page in option if missing.
@@ -521,39 +521,39 @@  discard block
 block discarded – undo
521 521
 						 * Check success_page setting in general settings.
522 522
 						 */
523 523
 						if (
524
-							isset( $value['attributes'] ) &&
525
-							false !== strpos( $value['class'], 'give-select-chosen' ) &&
526
-							in_array( 'data-search-type', array_keys( $value['attributes' ] ) ) &&
527
-							'pages' === $value['attributes' ]['data-search-type'] &&
528
-							! in_array( $option_value, array_keys( $value['options'] ) )
524
+							isset($value['attributes']) &&
525
+							false !== strpos($value['class'], 'give-select-chosen') &&
526
+							in_array('data-search-type', array_keys($value['attributes'])) &&
527
+							'pages' === $value['attributes']['data-search-type'] &&
528
+							! in_array($option_value, array_keys($value['options']))
529 529
 						) {
530
-							$value['options'][ $option_value ] = get_the_title( $option_value );
530
+							$value['options'][$option_value] = get_the_title($option_value);
531 531
 						}
532 532
 						?>
533
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
533
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
534 534
 						<th scope="row" class="titledesc">
535
-							<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
535
+							<label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
536 536
 						</th>
537
-						<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
537
+						<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
538 538
 							<select
539
-									name="<?php echo esc_attr( $value['id'] ); ?><?php if ( 'multiselect' === $value['type'] ) echo '[]'; ?>"
540
-									id="<?php echo esc_attr( $value['id'] ); ?>"
541
-									style="<?php echo esc_attr( $value['css'] ); ?>"
542
-									class="<?php echo esc_attr( $value['class'] ); ?>"
543
-								<?php echo implode( ' ', $custom_attributes ); ?>
544
-								<?php echo ( 'multiselect' === $value['type'] ) ? 'multiple="multiple"' : ''; ?>
539
+									name="<?php echo esc_attr($value['id']); ?><?php if ('multiselect' === $value['type']) echo '[]'; ?>"
540
+									id="<?php echo esc_attr($value['id']); ?>"
541
+									style="<?php echo esc_attr($value['css']); ?>"
542
+									class="<?php echo esc_attr($value['class']); ?>"
543
+								<?php echo implode(' ', $custom_attributes); ?>
544
+								<?php echo ('multiselect' === $value['type']) ? 'multiple="multiple"' : ''; ?>
545 545
 							>
546 546
 
547 547
 								<?php
548
-								if ( ! empty( $value['options'] ) ) {
549
-									foreach ( $value['options'] as $key => $val ) {
548
+								if ( ! empty($value['options'])) {
549
+									foreach ($value['options'] as $key => $val) {
550 550
 										?>
551
-										<option value="<?php echo esc_attr( $key ); ?>" <?php
551
+										<option value="<?php echo esc_attr($key); ?>" <?php
552 552
 
553
-										if ( is_array( $option_value ) ) {
554
-											selected( in_array( $key, $option_value ), true );
553
+										if (is_array($option_value)) {
554
+											selected(in_array($key, $option_value), true);
555 555
 										} else {
556
-											selected( $option_value, $key );
556
+											selected($option_value, $key);
557 557
 										}
558 558
 
559 559
 										?>><?php echo $val ?></option>
@@ -569,29 +569,29 @@  discard block
 block discarded – undo
569 569
 
570 570
 					// Radio inputs.
571 571
 					case 'radio_inline' :
572
-						$value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline';
572
+						$value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline';
573 573
 					case 'radio' :
574
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
574
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
575 575
 						?>
576
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
576
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
577 577
 						<th scope="row" class="titledesc">
578 578
 							<label
579
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
579
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
580 580
 						</th>
581
-						<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>">
581
+						<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>">
582 582
 							<fieldset>
583 583
 								<ul>
584 584
 									<?php
585
-									foreach ( $value['options'] as $key => $val ) {
585
+									foreach ($value['options'] as $key => $val) {
586 586
 										?>
587 587
 										<li>
588 588
 											<label><input
589
-														name="<?php echo esc_attr( $value['id'] ); ?>"
589
+														name="<?php echo esc_attr($value['id']); ?>"
590 590
 														value="<?php echo $key; ?>"
591 591
 														type="radio"
592
-														style="<?php echo esc_attr( $value['css'] ); ?>"
593
-													<?php echo implode( ' ', $custom_attributes ); ?>
594
-													<?php checked( $key, $option_value ); ?>
592
+														style="<?php echo esc_attr($value['css']); ?>"
593
+													<?php echo implode(' ', $custom_attributes); ?>
594
+													<?php checked($key, $option_value); ?>
595 595
 												/> <?php echo $val ?></label>
596 596
 										</li>
597 597
 										<?php
@@ -605,22 +605,22 @@  discard block
 block discarded – undo
605 605
 
606 606
 					// Checkbox input.
607 607
 					case 'checkbox' :
608
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
608
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
609 609
 						?>
610
-						<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
610
+						<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
611 611
 							<th scope="row" class="titledesc">
612 612
 								<label
613
-										for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
613
+										for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
614 614
 							</th>
615 615
 							<td class="give-forminp">
616 616
 								<input
617
-										name="<?php echo esc_attr( $value['id'] ); ?>"
618
-										id="<?php echo esc_attr( $value['id'] ); ?>"
617
+										name="<?php echo esc_attr($value['id']); ?>"
618
+										id="<?php echo esc_attr($value['id']); ?>"
619 619
 										type="checkbox"
620
-										class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>"
620
+										class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>"
621 621
 										value="1"
622
-									<?php checked( $option_value, 'on' ); ?>
623
-									<?php echo implode( ' ', $custom_attributes ); ?>
622
+									<?php checked($option_value, 'on'); ?>
623
+									<?php echo implode(' ', $custom_attributes); ?>
624 624
 								/>
625 625
 								<?php echo $description; ?>
626 626
 							</td>
@@ -630,29 +630,29 @@  discard block
 block discarded – undo
630 630
 
631 631
 					// Multi Checkbox input.
632 632
 					case 'multicheck' :
633
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
634
-						$option_value = is_array( $option_value ) ? $option_value : array();
633
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
634
+						$option_value = is_array($option_value) ? $option_value : array();
635 635
 						?>
636
-						<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
636
+						<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
637 637
 							<th scope="row" class="titledesc">
638 638
 								<label
639
-										for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
639
+										for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
640 640
 							</th>
641
-							<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>">
641
+							<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>">
642 642
 								<fieldset>
643 643
 									<ul>
644 644
 										<?php
645
-										foreach ( $value['options'] as $key => $val ) {
645
+										foreach ($value['options'] as $key => $val) {
646 646
 											?>
647 647
 											<li>
648 648
 												<label>
649 649
 													<input
650
-															name="<?php echo esc_attr( $value['id'] ); ?>[]"
650
+															name="<?php echo esc_attr($value['id']); ?>[]"
651 651
 															value="<?php echo $key; ?>"
652 652
 															type="checkbox"
653
-															style="<?php echo esc_attr( $value['css'] ); ?>"
654
-														<?php echo implode( ' ', $custom_attributes ); ?>
655
-														<?php if ( in_array( $key, $option_value ) ) {
653
+															style="<?php echo esc_attr($value['css']); ?>"
654
+														<?php echo implode(' ', $custom_attributes); ?>
655
+														<?php if (in_array($key, $option_value)) {
656 656
 															echo 'checked="checked"';
657 657
 														} ?>
658 658
 													/> <?php echo $val ?>
@@ -671,31 +671,31 @@  discard block
 block discarded – undo
671 671
 					// File input field.
672 672
 					case 'file' :
673 673
 					case 'media' :
674
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
675
-						$button_label = sprintf( __( 'Add or Upload %s', 'give' ), ( 'file' === $value['type'] ? __( 'File', 'give' ) : __( 'Image', 'give' ) ) );
676
-						$fvalue       = empty( $value['fvalue'] ) ? 'url' : $value['fvalue'];
677
-
678
-						$allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' );
679
-						$preview_image_src        = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : '';
680
-						$preview_image_extension  = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : '';
681
-						$is_show_preview          = in_array( $preview_image_extension, $allow_media_preview_tags );
674
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
675
+						$button_label = sprintf(__('Add or Upload %s', 'give'), ('file' === $value['type'] ? __('File', 'give') : __('Image', 'give')));
676
+						$fvalue       = empty($value['fvalue']) ? 'url' : $value['fvalue'];
677
+
678
+						$allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico');
679
+						$preview_image_src        = $option_value ? ('id' === $fvalue ? wp_get_attachment_url($option_value) : $option_value) : '';
680
+						$preview_image_extension  = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : '';
681
+						$is_show_preview          = in_array($preview_image_extension, $allow_media_preview_tags);
682 682
 						?>
683
-						<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
683
+						<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
684 684
 							<th scope="row" class="titledesc">
685 685
 								<label
686
-										for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
686
+										for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
687 687
 							</th>
688 688
 							<td class="give-forminp">
689 689
 								<div class="give-field-wrap">
690 690
 									<label for="<?php echo $value['id'] ?>">
691 691
 										<input
692
-												name="<?php echo esc_attr( $value['id'] ); ?>"
693
-												id="<?php echo esc_attr( $value['id'] ); ?>"
692
+												name="<?php echo esc_attr($value['id']); ?>"
693
+												id="<?php echo esc_attr($value['id']); ?>"
694 694
 												type="text"
695
-												class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>"
695
+												class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>"
696 696
 												value="<?php echo $option_value; ?>"
697
-												style="<?php echo esc_attr( $value['css'] ); ?>"
698
-											<?php echo implode( ' ', $custom_attributes ); ?>
697
+												style="<?php echo esc_attr($value['css']); ?>"
698
+											<?php echo implode(' ', $custom_attributes); ?>
699 699
 										/>&nbsp;&nbsp;&nbsp;&nbsp;<input class="give-upload-button button" type="button"
700 700
 												data-fvalue="<?php echo $fvalue; ?>"
701 701
 												data-field-type="<?php echo $value['type']; ?>"
@@ -716,18 +716,18 @@  discard block
 block discarded – undo
716 716
 					// WordPress Editor.
717 717
 					case 'wysiwyg' :
718 718
 						// Get option value.
719
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
719
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
720 720
 
721 721
 						// Get editor settings.
722
-						$editor_settings = ! empty( $value['options'] ) ? $value['options'] : array();
722
+						$editor_settings = ! empty($value['options']) ? $value['options'] : array();
723 723
 						?>
724
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
724
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
725 725
 						<th scope="row" class="titledesc">
726 726
 							<label
727
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
727
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
728 728
 						</th>
729 729
 						<td class="give-forminp">
730
-							<?php wp_editor( $option_value, $value['id'], $editor_settings ); ?>
730
+							<?php wp_editor($option_value, $value['id'], $editor_settings); ?>
731 731
 							<?php echo $description; ?>
732 732
 						</td>
733 733
 						</tr><?php
@@ -735,15 +735,15 @@  discard block
 block discarded – undo
735 735
 
736 736
 					// Custom: Default gateways setting field.
737 737
 					case 'default_gateway' :
738
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
738
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
739 739
 						?>
740
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
740
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
741 741
 						<th scope="row" class="titledesc">
742 742
 							<label
743
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
743
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
744 744
 						</th>
745 745
 						<td class="give-forminp">
746
-							<?php give_default_gateway_callback( $value, $option_value ); ?>
746
+							<?php give_default_gateway_callback($value, $option_value); ?>
747 747
 							<?php echo $description; ?>
748 748
 						</td>
749 749
 						</tr><?php
@@ -752,13 +752,13 @@  discard block
 block discarded – undo
752 752
 					// Custom: Email preview buttons field.
753 753
 					case 'email_preview_buttons' :
754 754
 						?>
755
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
755
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
756 756
 						<th scope="row" class="titledesc">
757 757
 							<label
758
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
758
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
759 759
 						</th>
760 760
 						<td class="give-forminp">
761
-							<?php give_email_preview_buttons_callback( $value ); ?>
761
+							<?php give_email_preview_buttons_callback($value); ?>
762 762
 							<?php echo $description; ?>
763 763
 						</td>
764 764
 						</tr><?php
@@ -772,23 +772,23 @@  discard block
 block discarded – undo
772 772
 
773 773
 					// Custom: Gateway API key.
774 774
 					case 'api_key' :
775
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
776
-						$type         = ! empty( $option_value ) ? 'password' : 'text';
775
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
776
+						$type         = ! empty($option_value) ? 'password' : 'text';
777 777
 						?>
778
-					<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
778
+					<tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
779 779
 						<th scope="row" class="titledesc">
780 780
 							<label
781
-									for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
781
+									for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
782 782
 						</th>
783
-						<td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
783
+						<td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
784 784
 							<input
785
-									name="<?php echo esc_attr( $value['id'] ); ?>"
786
-									id="<?php echo esc_attr( $value['id'] ); ?>"
787
-									type="<?php echo esc_attr( $type ); ?>"
788
-									style="<?php echo esc_attr( $value['css'] ); ?>"
789
-									value="<?php echo esc_attr( trim( $option_value ) ); ?>"
790
-									class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>"
791
-								<?php echo implode( ' ', $custom_attributes ); ?>
785
+									name="<?php echo esc_attr($value['id']); ?>"
786
+									id="<?php echo esc_attr($value['id']); ?>"
787
+									type="<?php echo esc_attr($type); ?>"
788
+									style="<?php echo esc_attr($value['css']); ?>"
789
+									value="<?php echo esc_attr(trim($option_value)); ?>"
790
+									class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>"
791
+								<?php echo implode(' ', $custom_attributes); ?>
792 792
 							/> <?php echo $description; ?>
793 793
 						</td>
794 794
 						</tr><?php
@@ -798,54 +798,53 @@  discard block
 block discarded – undo
798 798
 					case 'chosen' :
799 799
 
800 800
 						// Get option value.
801
-						$option_value     = self::get_option( $option_name, $value['id'], $value['default'] );
802
-						$option_value     = is_array( $option_value ) ? array_fill_keys( $option_value, 'selected' ) : $option_value;
803
-						$wrapper_class    = ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '';
801
+						$option_value     = self::get_option($option_name, $value['id'], $value['default']);
802
+						$option_value     = is_array($option_value) ? array_fill_keys($option_value, 'selected') : $option_value;
803
+						$wrapper_class    = ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '';
804 804
 						$type             = '';
805 805
 						$allow_new_values = '';
806
-						$name             = give_get_field_name( $value );
806
+						$name             = give_get_field_name($value);
807 807
 
808 808
 						// Set attributes based on multiselect datatype.
809
-						if ( 'multiselect' === $value['data_type'] ) {
809
+						if ('multiselect' === $value['data_type']) {
810 810
 							$type             = 'multiple';
811 811
 							$allow_new_values = 'data-allows-new-values="true"';
812
-							$name             = $name . '[]';
813
-							$option_value     = empty( $option_value ) ? array() : $option_value;
812
+							$name             = $name.'[]';
813
+							$option_value     = empty($option_value) ? array() : $option_value;
814 814
 						}
815 815
 
816
-						$title_prefixes_value = ( is_array( $option_value ) && count( $option_value ) > 0 ) ?
817
-							array_merge( $value['options'], $option_value ) :
818
-							$value['options'];
816
+						$title_prefixes_value = (is_array($option_value) && count($option_value) > 0) ?
817
+							array_merge($value['options'], $option_value) : $value['options'];
819 818
 
820 819
 						?>
821 820
 						<tr valign="top" <?php echo $wrapper_class; ?>>
822 821
 							<th scope="row" class="titledesc">
823
-								<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_attr( self::get_field_title( $value ) ); ?></label>
822
+								<label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_attr(self::get_field_title($value)); ?></label>
824 823
 							</th>
825
-							<td class="give-forminp give-forminp-<?php echo esc_attr( $value['type'] ); ?>">
824
+							<td class="give-forminp give-forminp-<?php echo esc_attr($value['type']); ?>">
826 825
 								<select
827 826
 										class="give-select-chosen give-chosen-settings"
828
-										style="<?php echo esc_attr( $value['style'] ); ?>"
829
-										name="<?php echo esc_attr( $name ); ?>"
830
-										id="<?php echo esc_attr( $value['id'] ); ?>"
827
+										style="<?php echo esc_attr($value['style']); ?>"
828
+										name="<?php echo esc_attr($name); ?>"
829
+										id="<?php echo esc_attr($value['id']); ?>"
831 830
 									<?php
832 831
 									echo "{$type} {$allow_new_values}";
833
-									echo implode( ' ', $custom_attributes );
832
+									echo implode(' ', $custom_attributes);
834 833
 									?>
835 834
 								>
836 835
 									<?php
837
-									if ( is_array( $title_prefixes_value ) && count( $title_prefixes_value ) > 0 ) {
838
-										foreach ( $title_prefixes_value as $key => $item_value ) {
836
+									if (is_array($title_prefixes_value) && count($title_prefixes_value) > 0) {
837
+										foreach ($title_prefixes_value as $key => $item_value) {
839 838
 											echo sprintf(
840 839
 												'<option %1$s value="%2$s">%2$s</option>',
841
-												( 'selected' === $item_value ) ? 'selected="selected"' : '',
842
-												esc_attr( $key )
840
+												('selected' === $item_value) ? 'selected="selected"' : '',
841
+												esc_attr($key)
843 842
 											);
844 843
 										}
845 844
 									}
846 845
 									?>
847 846
 								</select>
848
-								<?php echo wp_kses_post( $description ); ?>
847
+								<?php echo wp_kses_post($description); ?>
849 848
 							</td>
850 849
 						</tr>
851 850
 						<?php
@@ -862,7 +861,7 @@  discard block
 block discarded – undo
862 861
 						 *
863 862
 						 * @since 1.0
864 863
 						 */
865
-						do_action( "give_logs_view_{$current_section}" );
864
+						do_action("give_logs_view_{$current_section}");
866 865
 
867 866
 						echo $description;
868 867
 						break;
@@ -870,24 +869,24 @@  discard block
 block discarded – undo
870 869
 					// Custom: Data field.
871 870
 					case 'data' :
872 871
 
873
-						include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php';
872
+						include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php';
874 873
 
875 874
 						echo $description;
876 875
 						break;
877 876
 
878 877
 					// Custom: Give Docs Link field type.
879 878
 					case 'give_docs_link' :
880
-						$wrapper_class = ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '';
879
+						$wrapper_class = ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '';
881 880
 						?>
882
-					<tr valign="top" <?php echo esc_html( $wrapper_class ); ?>>
881
+					<tr valign="top" <?php echo esc_html($wrapper_class); ?>>
883 882
 						<td class="give-docs-link" colspan="2">
884 883
 							<p class="give-docs-link">
885
-								<a href="<?php echo esc_url( $value['url'] ); ?>" target="_blank">
884
+								<a href="<?php echo esc_url($value['url']); ?>" target="_blank">
886 885
 									<?php
887 886
 									echo sprintf(
888 887
 										/* translators: %s Title */
889
-										esc_html__( 'Need Help? See docs on "%s"', 'give' ),
890
-										esc_html( $value['title'] )
888
+										esc_html__('Need Help? See docs on "%s"', 'give'),
889
+										esc_html($value['title'])
891 890
 									);
892 891
 									?>
893 892
 									<span class="dashicons dashicons-editor-help"></span>
@@ -901,8 +900,8 @@  discard block
 block discarded – undo
901 900
 					// You can add or handle your custom field action.
902 901
 					default:
903 902
 						// Get option value.
904
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
905
-						do_action( 'give_admin_field_' . $value['type'], $value, $option_value );
903
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
904
+						do_action('give_admin_field_'.$value['type'], $value, $option_value);
906 905
 						break;
907 906
 				}
908 907
 			}
@@ -918,15 +917,15 @@  discard block
 block discarded – undo
918 917
 		 *
919 918
 		 * @return string The HTML description of the field.
920 919
 		 */
921
-		public static function get_field_description( $value ) {
920
+		public static function get_field_description($value) {
922 921
 			$description = '';
923 922
 
924 923
 			// Support for both 'description' and 'desc' args.
925
-			$description_key = isset( $value['description'] ) ? 'description' : 'desc';
926
-			$value           = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : '';
924
+			$description_key = isset($value['description']) ? 'description' : 'desc';
925
+			$value           = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : '';
927 926
 
928
-			if ( ! empty( $value ) ) {
929
-				$description = '<div class="give-field-description">' . wp_kses_post( $value ) . '</div>';
927
+			if ( ! empty($value)) {
928
+				$description = '<div class="give-field-description">'.wp_kses_post($value).'</div>';
930 929
 			}
931 930
 
932 931
 			return $description;
@@ -943,11 +942,11 @@  discard block
 block discarded – undo
943 942
 		 *
944 943
 		 * @return array The description and tip as a 2 element array
945 944
 		 */
946
-		public static function get_field_title( $value ) {
947
-			$title = esc_html( $value['title'] );
945
+		public static function get_field_title($value) {
946
+			$title = esc_html($value['title']);
948 947
 
949 948
 			// If html tag detected then allow them to print.
950
-			if ( strip_tags( $title ) ) {
949
+			if (strip_tags($title)) {
951 950
 				$title = $value['title'];
952 951
 			}
953 952
 
@@ -966,8 +965,8 @@  discard block
 block discarded – undo
966 965
 		 *
967 966
 		 * @return bool
968 967
 		 */
969
-		public static function save_fields( $options, $option_name = '' ) {
970
-			if ( empty( $_POST ) ) {
968
+		public static function save_fields($options, $option_name = '') {
969
+			if (empty($_POST)) {
971 970
 				return false;
972 971
 			}
973 972
 
@@ -975,38 +974,38 @@  discard block
 block discarded – undo
975 974
 			$update_options = array();
976 975
 
977 976
 			// Loop options and get values to save.
978
-			foreach ( $options as $option ) {
979
-				if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) {
977
+			foreach ($options as $option) {
978
+				if ( ! isset($option['id']) || ! isset($option['type'])) {
980 979
 					continue;
981 980
 				}
982 981
 
983 982
 				// Get posted value.
984
-				if ( strstr( $option['id'], '[' ) ) {
985
-					parse_str( $option['id'], $option_name_array );
986
-					$field_option_name = current( array_keys( $option_name_array ) );
987
-					$setting_name      = key( $option_name_array[ $field_option_name ] );
988
-					$raw_value         = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null;
983
+				if (strstr($option['id'], '[')) {
984
+					parse_str($option['id'], $option_name_array);
985
+					$field_option_name = current(array_keys($option_name_array));
986
+					$setting_name      = key($option_name_array[$field_option_name]);
987
+					$raw_value         = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null;
989 988
 				} else {
990 989
 					$field_option_name = $option['id'];
991 990
 					$setting_name      = '';
992
-					$raw_value         = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null;
991
+					$raw_value         = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null;
993 992
 				}
994 993
 
995 994
 				// Format the value based on option type.
996
-				switch ( $option['type'] ) {
995
+				switch ($option['type']) {
997 996
 					case 'checkbox' :
998
-						$value = is_null( $raw_value ) ? '' : 'on';
997
+						$value = is_null($raw_value) ? '' : 'on';
999 998
 						break;
1000 999
 					case 'wysiwyg'  :
1001 1000
 					case 'textarea' :
1002
-						$value = wp_kses_post( trim( $raw_value ) );
1001
+						$value = wp_kses_post(trim($raw_value));
1003 1002
 						break;
1004 1003
 					case 'multiselect' :
1005 1004
 					case 'chosen' :
1006
-						$value = array_filter( array_map( 'give_clean', (array) $raw_value ) );
1005
+						$value = array_filter(array_map('give_clean', (array) $raw_value));
1007 1006
 						break;
1008 1007
 					default :
1009
-						$value = give_clean( $raw_value );
1008
+						$value = give_clean($raw_value);
1010 1009
 						break;
1011 1010
 				}
1012 1011
 
@@ -1015,37 +1014,37 @@  discard block
 block discarded – undo
1015 1014
 				 *
1016 1015
 				 * @since 1.8
1017 1016
 				 */
1018
-				$value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value );
1017
+				$value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value);
1019 1018
 
1020 1019
 				/**
1021 1020
 				 * Sanitize the value of an option by option name.
1022 1021
 				 *
1023 1022
 				 * @since 1.8
1024 1023
 				 */
1025
-				$value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value );
1024
+				$value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value);
1026 1025
 
1027
-				if ( is_null( $value ) ) {
1026
+				if (is_null($value)) {
1028 1027
 					continue;
1029 1028
 				}
1030 1029
 
1031 1030
 				// Check if option is an array and handle that differently to single values.
1032
-				if ( $field_option_name && $setting_name ) {
1033
-					if ( ! isset( $update_options[ $field_option_name ] ) ) {
1034
-						$update_options[ $field_option_name ] = get_option( $field_option_name, array() );
1031
+				if ($field_option_name && $setting_name) {
1032
+					if ( ! isset($update_options[$field_option_name])) {
1033
+						$update_options[$field_option_name] = get_option($field_option_name, array());
1035 1034
 					}
1036
-					if ( ! is_array( $update_options[ $field_option_name ] ) ) {
1037
-						$update_options[ $field_option_name ] = array();
1035
+					if ( ! is_array($update_options[$field_option_name])) {
1036
+						$update_options[$field_option_name] = array();
1038 1037
 					}
1039
-					$update_options[ $field_option_name ][ $setting_name ] = $value;
1038
+					$update_options[$field_option_name][$setting_name] = $value;
1040 1039
 				} else {
1041
-					$update_options[ $field_option_name ] = $value;
1040
+					$update_options[$field_option_name] = $value;
1042 1041
 				}
1043 1042
 			}
1044 1043
 
1045 1044
 			// Save all options in our array or there own option name i.e. option id.
1046
-			if ( empty( $option_name ) ) {
1047
-				foreach ( $update_options as $name => $value ) {
1048
-					update_option( $name, $value, false );
1045
+			if (empty($option_name)) {
1046
+				foreach ($update_options as $name => $value) {
1047
+					update_option($name, $value, false);
1049 1048
 
1050 1049
 					/**
1051 1050
 					 * Trigger action.
@@ -1054,13 +1053,13 @@  discard block
 block discarded – undo
1054 1053
 					 *
1055 1054
 					 * @since 1.8
1056 1055
 					 */
1057
-					do_action( "give_save_option_{$name}", $value, $name );
1056
+					do_action("give_save_option_{$name}", $value, $name);
1058 1057
 				}
1059 1058
 			} else {
1060
-				$old_options    = ( $old_options = get_option( $option_name ) ) ? $old_options : array();
1061
-				$update_options = array_merge( $old_options, $update_options );
1059
+				$old_options    = ($old_options = get_option($option_name)) ? $old_options : array();
1060
+				$update_options = array_merge($old_options, $update_options);
1062 1061
 
1063
-				update_option( $option_name, $update_options, false );
1062
+				update_option($option_name, $update_options, false);
1064 1063
 
1065 1064
 				/**
1066 1065
 				 * Trigger action.
@@ -1069,7 +1068,7 @@  discard block
 block discarded – undo
1069 1068
 				 *
1070 1069
 				 * @since 1.8
1071 1070
 				 */
1072
-				do_action( "give_save_settings_{$option_name}", $update_options, $option_name, $old_options );
1071
+				do_action("give_save_settings_{$option_name}", $update_options, $option_name, $old_options);
1073 1072
 			}
1074 1073
 
1075 1074
 			return true;
@@ -1098,21 +1097,21 @@  discard block
 block discarded – undo
1098 1097
 		 *
1099 1098
 		 * @return bool
1100 1099
 		 */
1101
-		public static function is_setting_page( $tab = '', $section = '' ) {
1100
+		public static function is_setting_page($tab = '', $section = '') {
1102 1101
 			$is_setting_page = false;
1103 1102
 
1104
-			if( ! is_admin() ) {
1103
+			if ( ! is_admin()) {
1105 1104
 				return $is_setting_page;
1106 1105
 			}
1107 1106
 
1108 1107
 			// Check fo setting tab.
1109
-			if ( ! empty( $tab ) ) {
1110
-				$is_setting_page = ( $tab === give_get_current_setting_tab() );
1108
+			if ( ! empty($tab)) {
1109
+				$is_setting_page = ($tab === give_get_current_setting_tab());
1111 1110
 			}
1112 1111
 
1113 1112
 			// Check fo setting section.
1114
-			if ( ! empty( $section ) ) {
1115
-				$is_setting_page = ( $section === give_get_current_setting_section() );
1113
+			if ( ! empty($section)) {
1114
+				$is_setting_page = ($section === give_get_current_setting_section());
1116 1115
 			}
1117 1116
 
1118 1117
 			return $is_setting_page;
Please login to merge, or discard this patch.
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.
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.