Test Failed
Push — master ( f5256c...25a383 )
by Devin
07:02
created
includes/class-give-html-elements.php 1 patch
Spacing   +159 added lines, -159 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
 	 *
36 36
 	 * @return string       Donations dropdown.
37 37
 	 */
38
-	public function donations_dropdown( $args = array() ) {
38
+	public function donations_dropdown($args = array()) {
39 39
 
40 40
 		$defaults = array(
41 41
 			'name'        => 'donations',
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
 			'selected'    => 0,
46 46
 			'chosen'      => false,
47 47
 			'number'      => 30,
48
-			'placeholder' => __( 'Select a donation', 'give' ),
48
+			'placeholder' => __('Select a donation', 'give'),
49 49
 		);
50 50
 
51
-		$args = wp_parse_args( $args, $defaults );
51
+		$args = wp_parse_args($args, $defaults);
52 52
 
53
-		$payments = new Give_Payments_Query( array(
53
+		$payments = new Give_Payments_Query(array(
54 54
 			'number' => $args['number'],
55
-		) );
55
+		));
56 56
 
57 57
 		$payments = $payments->get_payments();
58 58
 
59 59
 		$options = array();
60 60
 
61 61
 		// Provide nice human readable options.
62
-		if ( $payments ) {
62
+		if ($payments) {
63 63
 			$options[0] = $args['placeholder'];
64
-			foreach ( $payments as $payment ) {
64
+			foreach ($payments as $payment) {
65 65
 
66
-				$options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
66
+				$options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
67 67
 
68 68
 			}
69 69
 		} else {
70
-			$options[0] = __( 'No donations found.', 'give' );
70
+			$options[0] = __('No donations found.', 'give');
71 71
 		}
72 72
 
73
-		$output = $this->select( array(
73
+		$output = $this->select(array(
74 74
 			'name'             => $args['name'],
75 75
 			'selected'         => $args['selected'],
76 76
 			'id'               => $args['id'],
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			'select_atts'      => $args['select_atts'],
83 83
 			'show_option_all'  => false,
84 84
 			'show_option_none' => false,
85
-		) );
85
+		));
86 86
 
87 87
 		return $output;
88 88
 	}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return string      Give forms dropdown.
101 101
 	 */
102
-	public function forms_dropdown( $args = array() ) {
102
+	public function forms_dropdown($args = array()) {
103 103
 
104 104
 		$defaults = array(
105 105
 			'name'        => 'forms',
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
 			'selected'    => 0,
110 110
 			'chosen'      => false,
111 111
 			'number'      => 30,
112
-			'placeholder' => esc_attr__( 'All Forms', 'give' ),
112
+			'placeholder' => esc_attr__('All Forms', 'give'),
113 113
 			'data'        => array(
114 114
 				'search-type' => 'form',
115 115
 			),
116 116
 			'query_args' => array()
117 117
 		);
118 118
 
119
-		$args = wp_parse_args( $args, $defaults );
119
+		$args = wp_parse_args($args, $defaults);
120 120
 
121 121
 		$form_args = wp_parse_args(
122 122
 			$args['query_args'],
@@ -128,37 +128,37 @@  discard block
 block discarded – undo
128 128
 			)
129 129
 		);
130 130
 
131
-		$cache_key   = Give_Cache::get_key( 'give_forms', $form_args, false );
131
+		$cache_key = Give_Cache::get_key('give_forms', $form_args, false);
132 132
 
133 133
 		// Get forms from cache.
134
-		$forms = Give_Cache::get_db_query( $cache_key );
134
+		$forms = Give_Cache::get_db_query($cache_key);
135 135
 
136
-		if ( is_null( $forms ) ) {
137
-			$forms = new WP_Query( $form_args );
136
+		if (is_null($forms)) {
137
+			$forms = new WP_Query($form_args);
138 138
 			$forms = $forms->posts;
139
-			Give_Cache::set_db_query( $cache_key, $forms );
139
+			Give_Cache::set_db_query($cache_key, $forms);
140 140
 		}
141 141
 
142 142
 		$options = array();
143 143
 
144 144
 		// Ensure the selected.
145
-		if ( false !== $args['selected'] && $args['selected'] !== 0 ) {
146
-			$options[ $args['selected'] ] = get_the_title( $args['selected'] );
145
+		if (false !== $args['selected'] && $args['selected'] !== 0) {
146
+			$options[$args['selected']] = get_the_title($args['selected']);
147 147
 		}
148 148
 
149
-		$options[0] = esc_html__( 'No forms found.', 'give' );
150
-		if ( ! empty( $forms ) ) {
149
+		$options[0] = esc_html__('No forms found.', 'give');
150
+		if ( ! empty($forms)) {
151 151
 			$options[0] = $args['placeholder'];
152
-			foreach ( $forms as $form ) {
153
-				$form_title = empty( $form->post_title )
154
-					? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID )
152
+			foreach ($forms as $form) {
153
+				$form_title = empty($form->post_title)
154
+					? sprintf(__('Untitled (#%s)', 'give'), $form->ID)
155 155
 					: $form->post_title;
156 156
 
157
-				$options[ absint( $form->ID ) ] = esc_html( $form_title );
157
+				$options[absint($form->ID)] = esc_html($form_title);
158 158
 			}
159 159
 		}
160 160
 
161
-		$output = $this->select( array(
161
+		$output = $this->select(array(
162 162
 			'name'             => $args['name'],
163 163
 			'selected'         => $args['selected'],
164 164
 			'id'               => $args['id'],
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 			'show_option_all'  => false,
171 171
 			'show_option_none' => false,
172 172
 			'data'             => $args['data'],
173
-		) );
173
+		));
174 174
 
175 175
 		return $output;
176 176
 	}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @return string      Donors dropdown.
189 189
 	 */
190
-	public function donor_dropdown( $args = array() ) {
190
+	public function donor_dropdown($args = array()) {
191 191
 
192 192
 		$defaults = array(
193 193
 			'name'        => 'donors',
@@ -196,58 +196,58 @@  discard block
 block discarded – undo
196 196
 			'multiple'    => false,
197 197
 			'selected'    => 0,
198 198
 			'chosen'      => true,
199
-			'placeholder' => esc_attr__( 'Select a Donor', 'give' ),
199
+			'placeholder' => esc_attr__('Select a Donor', 'give'),
200 200
 			'number'      => 30,
201 201
 			'data'        => array(
202 202
 				'search-type' => 'donor',
203 203
 			),
204 204
 		);
205 205
 
206
-		$args = wp_parse_args( $args, $defaults );
206
+		$args = wp_parse_args($args, $defaults);
207 207
 
208
-		$donors = Give()->donors->get_donors( array(
208
+		$donors = Give()->donors->get_donors(array(
209 209
 			'number' => $args['number'],
210
-		) );
210
+		));
211 211
 
212 212
 		$options = array();
213 213
 
214
-		if ( $donors ) {
215
-			$options[0] = esc_html__( 'No donor attached', 'give' );
216
-			foreach ( $donors as $donor ) {
217
-				$donor = give_get_name_with_title_prefixes( $donor );
218
-				$options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' );
214
+		if ($donors) {
215
+			$options[0] = esc_html__('No donor attached', 'give');
216
+			foreach ($donors as $donor) {
217
+				$donor = give_get_name_with_title_prefixes($donor);
218
+				$options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')');
219 219
 			}
220 220
 		} else {
221
-			$options[0] = esc_html__( 'No donors found.', 'give' );
221
+			$options[0] = esc_html__('No donors found.', 'give');
222 222
 		}
223 223
 
224
-		if ( ! empty( $args['selected'] ) ) {
224
+		if ( ! empty($args['selected'])) {
225 225
 
226 226
 			// If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed.
227
-			if ( ! array_key_exists( $args['selected'], $options ) ) {
227
+			if ( ! array_key_exists($args['selected'], $options)) {
228 228
 
229
-				$donor = new Give_Donor( $args['selected'] );
229
+				$donor = new Give_Donor($args['selected']);
230 230
 
231
-				if ( $donor ) {
232
-					$donor = give_get_name_with_title_prefixes( $donor );
233
-					$options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' );
231
+				if ($donor) {
232
+					$donor = give_get_name_with_title_prefixes($donor);
233
+					$options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')');
234 234
 
235 235
 				}
236 236
 			}
237 237
 		}
238 238
 
239
-		$output = $this->select( array(
239
+		$output = $this->select(array(
240 240
 			'name'             => $args['name'],
241 241
 			'selected'         => $args['selected'],
242 242
 			'id'               => $args['id'],
243
-			'class'            => $args['class'] . ' give-customer-select',
243
+			'class'            => $args['class'].' give-customer-select',
244 244
 			'options'          => $options,
245 245
 			'multiple'         => $args['multiple'],
246 246
 			'chosen'           => $args['chosen'],
247 247
 			'show_option_all'  => false,
248 248
 			'show_option_none' => false,
249 249
 			'data'             => $args['data'],
250
-		) );
250
+		));
251 251
 
252 252
 		return $output;
253 253
 	}
@@ -266,22 +266,22 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return string           Categories dropdown.
268 268
 	 */
269
-	public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) {
270
-		$categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) );
269
+	public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) {
270
+		$categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array()));
271 271
 
272 272
 		$options = array();
273 273
 
274
-		foreach ( $categories as $category ) {
275
-			$options[ absint( $category->term_id ) ] = esc_html( $category->name );
274
+		foreach ($categories as $category) {
275
+			$options[absint($category->term_id)] = esc_html($category->name);
276 276
 		}
277 277
 
278
-		$output = $this->select( wp_parse_args( $args, array(
278
+		$output = $this->select(wp_parse_args($args, array(
279 279
 			'name'             => $name,
280 280
 			'selected'         => $selected,
281 281
 			'options'          => $options,
282
-			'show_option_all'  => esc_html__( 'All Categories', 'give' ),
282
+			'show_option_all'  => esc_html__('All Categories', 'give'),
283 283
 			'show_option_none' => false,
284
-		) ) );
284
+		)));
285 285
 
286 286
 		return $output;
287 287
 	}
@@ -300,22 +300,22 @@  discard block
 block discarded – undo
300 300
 	 *
301 301
 	 * @return string           Tags dropdown.
302 302
 	 */
303
-	public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) {
304
-		$tags    = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
303
+	public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) {
304
+		$tags    = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
305 305
 
306 306
 		$options = array();
307 307
 
308
-		foreach ( $tags as $tag ) {
309
-			$options[ absint( $tag->term_id ) ] = esc_html( $tag->name );
308
+		foreach ($tags as $tag) {
309
+			$options[absint($tag->term_id)] = esc_html($tag->name);
310 310
 		}
311 311
 
312
-		$output = $this->select( wp_parse_args( $args, array(
312
+		$output = $this->select(wp_parse_args($args, array(
313 313
 			'name'             => $name,
314 314
 			'selected'         => $selected,
315 315
 			'options'          => $options,
316
-			'show_option_all'  => esc_html__( 'All Tags', 'give' ),
316
+			'show_option_all'  => esc_html__('All Tags', 'give'),
317 317
 			'show_option_none' => false,
318
-		) ) );
318
+		)));
319 319
 
320 320
 		return $output;
321 321
 	}
@@ -335,25 +335,25 @@  discard block
 block discarded – undo
335 335
 	 *
336 336
 	 * @return string               Years dropdown.
337 337
 	 */
338
-	public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
339
-		$current    = date( 'Y' );
340
-		$start_year = $current - absint( $years_before );
341
-		$end_year   = $current + absint( $years_after );
342
-		$selected   = empty( $selected ) ? date( 'Y' ) : $selected;
338
+	public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
339
+		$current    = date('Y');
340
+		$start_year = $current - absint($years_before);
341
+		$end_year   = $current + absint($years_after);
342
+		$selected   = empty($selected) ? date('Y') : $selected;
343 343
 		$options    = array();
344 344
 
345
-		while ( $start_year <= $end_year ) {
346
-			$options[ absint( $start_year ) ] = $start_year;
347
-			$start_year ++;
345
+		while ($start_year <= $end_year) {
346
+			$options[absint($start_year)] = $start_year;
347
+			$start_year++;
348 348
 		}
349 349
 
350
-		$output = $this->select( array(
350
+		$output = $this->select(array(
351 351
 			'name'             => $name,
352 352
 			'selected'         => $selected,
353 353
 			'options'          => $options,
354 354
 			'show_option_all'  => false,
355 355
 			'show_option_none' => false,
356
-		) );
356
+		));
357 357
 
358 358
 		return $output;
359 359
 	}
@@ -371,23 +371,23 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return string           Months dropdown.
373 373
 	 */
374
-	public function month_dropdown( $name = 'month', $selected = 0 ) {
374
+	public function month_dropdown($name = 'month', $selected = 0) {
375 375
 		$month    = 1;
376 376
 		$options  = array();
377
-		$selected = empty( $selected ) ? date( 'n' ) : $selected;
377
+		$selected = empty($selected) ? date('n') : $selected;
378 378
 
379
-		while ( $month <= 12 ) {
380
-			$options[ absint( $month ) ] = give_month_num_to_name( $month );
381
-			$month ++;
379
+		while ($month <= 12) {
380
+			$options[absint($month)] = give_month_num_to_name($month);
381
+			$month++;
382 382
 		}
383 383
 
384
-		$output = $this->select( array(
384
+		$output = $this->select(array(
385 385
 			'name'             => $name,
386 386
 			'selected'         => $selected,
387 387
 			'options'          => $options,
388 388
 			'show_option_all'  => false,
389 389
 			'show_option_none' => false,
390
-		) );
390
+		));
391 391
 
392 392
 		return $output;
393 393
 	}
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	 *
405 405
 	 * @return string      The dropdown.
406 406
 	 */
407
-	public function select( $args = array() ) {
407
+	public function select($args = array()) {
408 408
 		$defaults = array(
409 409
 			'options'          => array(),
410 410
 			'name'             => null,
@@ -415,74 +415,74 @@  discard block
 block discarded – undo
415 415
 			'placeholder'      => null,
416 416
 			'multiple'         => false,
417 417
 			'select_atts'      => false,
418
-			'show_option_all'  => __( 'All', 'give' ),
419
-			'show_option_none' => __( 'None', 'give' ),
418
+			'show_option_all'  => __('All', 'give'),
419
+			'show_option_none' => __('None', 'give'),
420 420
 			'data'             => array(),
421 421
 			'readonly'         => false,
422 422
 			'disabled'         => false,
423 423
 		);
424 424
 
425
-		$args = wp_parse_args( $args, $defaults );
425
+		$args = wp_parse_args($args, $defaults);
426 426
 
427 427
 		$data_elements = '';
428
-		foreach ( $args['data'] as $key => $value ) {
429
-			$data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
428
+		foreach ($args['data'] as $key => $value) {
429
+			$data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"';
430 430
 		}
431 431
 
432 432
 		$multiple = '';
433
-		if ( $args['multiple'] ) {
433
+		if ($args['multiple']) {
434 434
 			$multiple = 'MULTIPLE';
435 435
 		}
436 436
 
437
-		if ( $args['chosen'] ) {
437
+		if ($args['chosen']) {
438 438
 			$args['class'] .= ' give-select-chosen';
439 439
 		}
440 440
 
441 441
 		$placeholder = '';
442
-		if ( $args['placeholder'] ) {
442
+		if ($args['placeholder']) {
443 443
 			$placeholder = $args['placeholder'];
444 444
 		}
445 445
 
446 446
 		$output = sprintf(
447 447
 			'<select name="%1$s" id="%2$s" autocomplete="address-level4" class="give-select %3$s" %4$s %5$s placeholder="%6$s" data-placeholder="%6$s" %7$s>',
448
-			esc_attr( $args['name'] ),
449
-			esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ),
450
-			esc_attr( $args['class'] ),
448
+			esc_attr($args['name']),
449
+			esc_attr(sanitize_key(str_replace('-', '_', $args['id']))),
450
+			esc_attr($args['class']),
451 451
 			$multiple,
452 452
 			$args['select_atts'],
453 453
 			$placeholder,
454 454
 			$data_elements
455 455
 		);
456 456
 
457
-		if ( $args['show_option_all'] ) {
458
-			if ( $args['multiple'] ) {
459
-				$selected = selected( true, in_array( 0, $args['selected'] ), false );
457
+		if ($args['show_option_all']) {
458
+			if ($args['multiple']) {
459
+				$selected = selected(true, in_array(0, $args['selected']), false);
460 460
 			} else {
461
-				$selected = selected( $args['selected'], 0, false );
461
+				$selected = selected($args['selected'], 0, false);
462 462
 			}
463
-			$output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
463
+			$output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>';
464 464
 		}
465 465
 
466
-		if ( ! empty( $args['options'] ) ) {
466
+		if ( ! empty($args['options'])) {
467 467
 
468
-			if ( $args['show_option_none'] ) {
469
-				if ( $args['multiple'] ) {
470
-					$selected = selected( true, in_array( - 1, $args['selected'] ), false );
468
+			if ($args['show_option_none']) {
469
+				if ($args['multiple']) {
470
+					$selected = selected(true, in_array( -1, $args['selected'] ), false);
471 471
 				} else {
472
-					$selected = selected( $args['selected'], - 1, false );
472
+					$selected = selected($args['selected'], - 1, false);
473 473
 				}
474
-				$output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
474
+				$output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>';
475 475
 			}
476 476
 
477
-			foreach ( $args['options'] as $key => $option ) {
477
+			foreach ($args['options'] as $key => $option) {
478 478
 
479
-				if ( $args['multiple'] && is_array( $args['selected'] ) ) {
480
-					$selected = selected( true, in_array( $key, $args['selected'] ), false );
479
+				if ($args['multiple'] && is_array($args['selected'])) {
480
+					$selected = selected(true, in_array($key, $args['selected']), false);
481 481
 				} else {
482
-					$selected = selected( $args['selected'], $key, false );
482
+					$selected = selected($args['selected'], $key, false);
483 483
 				}
484 484
 
485
-				$output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
485
+				$output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>';
486 486
 			}
487 487
 		}
488 488
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 	 *
504 504
 	 * @return string      The checkbox.
505 505
 	 */
506
-	public function checkbox( $args = array() ) {
506
+	public function checkbox($args = array()) {
507 507
 		$defaults = array(
508 508
 			'name'    => null,
509 509
 			'current' => null,
@@ -514,16 +514,16 @@  discard block
 block discarded – undo
514 514
 			),
515 515
 		);
516 516
 
517
-		$args = wp_parse_args( $args, $defaults );
517
+		$args = wp_parse_args($args, $defaults);
518 518
 
519 519
 		$options = '';
520
-		if ( ! empty( $args['options']['disabled'] ) ) {
520
+		if ( ! empty($args['options']['disabled'])) {
521 521
 			$options .= ' disabled="disabled"';
522
-		} elseif ( ! empty( $args['options']['readonly'] ) ) {
522
+		} elseif ( ! empty($args['options']['readonly'])) {
523 523
 			$options .= ' readonly';
524 524
 		}
525 525
 
526
-		$output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
526
+		$output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />';
527 527
 
528 528
 		return $output;
529 529
 	}
@@ -540,22 +540,22 @@  discard block
 block discarded – undo
540 540
 	 *
541 541
 	 * @return string      The text field.
542 542
 	 */
543
-	public function text( $args = array() ) {
543
+	public function text($args = array()) {
544 544
 		// Backwards compatibility.
545
-		if ( func_num_args() > 1 ) {
545
+		if (func_num_args() > 1) {
546 546
 			$args = func_get_args();
547 547
 
548 548
 			$name  = $args[0];
549
-			$value = isset( $args[1] ) ? $args[1] : '';
550
-			$label = isset( $args[2] ) ? $args[2] : '';
551
-			$desc  = isset( $args[3] ) ? $args[3] : '';
549
+			$value = isset($args[1]) ? $args[1] : '';
550
+			$label = isset($args[2]) ? $args[2] : '';
551
+			$desc  = isset($args[3]) ? $args[3] : '';
552 552
 		}
553 553
 
554 554
 		$defaults = array(
555
-			'name'         => isset( $name ) ? $name : 'text',
556
-			'value'        => isset( $value ) ? $value : null,
557
-			'label'        => isset( $label ) ? $label : null,
558
-			'desc'         => isset( $desc ) ? $desc : null,
555
+			'name'         => isset($name) ? $name : 'text',
556
+			'value'        => isset($value) ? $value : null,
557
+			'label'        => isset($label) ? $label : null,
558
+			'desc'         => isset($desc) ? $desc : null,
559 559
 			'placeholder'  => '',
560 560
 			'class'        => 'regular-text',
561 561
 			'disabled'     => false,
@@ -563,29 +563,29 @@  discard block
 block discarded – undo
563 563
 			'data'         => false,
564 564
 		);
565 565
 
566
-		$args = wp_parse_args( $args, $defaults );
566
+		$args = wp_parse_args($args, $defaults);
567 567
 
568 568
 		$disabled = '';
569
-		if ( $args['disabled'] ) {
569
+		if ($args['disabled']) {
570 570
 			$disabled = ' disabled="disabled"';
571 571
 		}
572 572
 
573 573
 		$data = '';
574
-		if ( ! empty( $args['data'] ) ) {
575
-			foreach ( $args['data'] as $key => $value ) {
576
-				$data .= 'data-' . $key . '="' . $value . '" ';
574
+		if ( ! empty($args['data'])) {
575
+			foreach ($args['data'] as $key => $value) {
576
+				$data .= 'data-'.$key.'="'.$value.'" ';
577 577
 			}
578 578
 		}
579 579
 
580
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
580
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
581 581
 
582
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
582
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
583 583
 
584
-		if ( ! empty( $args['desc'] ) ) {
585
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
584
+		if ( ! empty($args['desc'])) {
585
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
586 586
 		}
587 587
 
588
-		$output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>';
588
+		$output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>';
589 589
 
590 590
 		$output .= '</span>';
591 591
 
@@ -604,15 +604,15 @@  discard block
 block discarded – undo
604 604
 	 *
605 605
 	 * @return string      The date picker.
606 606
 	 */
607
-	public function date_field( $args = array() ) {
607
+	public function date_field($args = array()) {
608 608
 
609
-		if ( empty( $args['class'] ) ) {
609
+		if (empty($args['class'])) {
610 610
 			$args['class'] = 'give_datepicker';
611
-		} elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) {
611
+		} elseif ( ! strpos($args['class'], 'give_datepicker')) {
612 612
 			$args['class'] .= ' give_datepicker';
613 613
 		}
614 614
 
615
-		return $this->text( $args );
615
+		return $this->text($args);
616 616
 	}
617 617
 
618 618
 	/**
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 	 *
628 628
 	 * @return string      The textarea.
629 629
 	 */
630
-	public function textarea( $args = array() ) {
630
+	public function textarea($args = array()) {
631 631
 		$defaults = array(
632 632
 			'name'     => 'textarea',
633 633
 			'value'    => null,
@@ -637,21 +637,21 @@  discard block
 block discarded – undo
637 637
 			'disabled' => false,
638 638
 		);
639 639
 
640
-		$args = wp_parse_args( $args, $defaults );
640
+		$args = wp_parse_args($args, $defaults);
641 641
 
642 642
 		$disabled = '';
643
-		if ( $args['disabled'] ) {
643
+		if ($args['disabled']) {
644 644
 			$disabled = ' disabled="disabled"';
645 645
 		}
646 646
 
647
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
647
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
648 648
 
649
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
649
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
650 650
 
651
-		$output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
651
+		$output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>';
652 652
 
653
-		if ( ! empty( $args['desc'] ) ) {
654
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
653
+		if ( ! empty($args['desc'])) {
654
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
655 655
 		}
656 656
 
657 657
 		$output .= '</span>';
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	 *
672 672
 	 * @return string      The text field with ajax search.
673 673
 	 */
674
-	public function ajax_user_search( $args = array() ) {
674
+	public function ajax_user_search($args = array()) {
675 675
 
676 676
 		$defaults = array(
677 677
 			'name'        => 'users',
@@ -682,13 +682,13 @@  discard block
 block discarded – undo
682 682
 			'chosen'      => true,
683 683
 			'number'      => 30,
684 684
 			'select_atts' => '',
685
-			'placeholder' => __( 'Select a user', 'give' ),
685
+			'placeholder' => __('Select a user', 'give'),
686 686
 			'data'        => array(
687 687
 				'search-type' => 'user',
688 688
 			),
689 689
 		);
690 690
 
691
-		$args = wp_parse_args( $args, $defaults );
691
+		$args = wp_parse_args($args, $defaults);
692 692
 
693 693
 		// Set initial args.
694 694
 		$get_users_args = array(
@@ -697,31 +697,31 @@  discard block
 block discarded – undo
697 697
 
698 698
 		// Ensure selected user is not included in initial query.
699 699
 		// This is because sites with many users, it's not a guarantee the selected user will be returned.
700
-		if ( ! empty( $args['selected'] ) ) {
700
+		if ( ! empty($args['selected'])) {
701 701
 			$get_users_args['exclude'] = $args['selected'];
702 702
 		}
703 703
 
704 704
 		// Initial users array.
705
-		$users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args );
705
+		$users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args);
706 706
 
707 707
 		// Now add the selected user to the $users array if the arg is present.
708
-		if ( ! empty( $args['selected'] ) ) {
709
-			$selected_user =  apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );;
710
-			$users         = array_merge( $users, $selected_user );
708
+		if ( ! empty($args['selected'])) {
709
+			$selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ;
710
+			$users         = array_merge($users, $selected_user);
711 711
 		}
712 712
 
713 713
 		$options = array();
714 714
 
715
-		if ( $users ) {
715
+		if ($users) {
716 716
 			$options[0] = $args['placeholder'];
717
-			foreach ( $users as $user ) {
718
-				$options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' );
717
+			foreach ($users as $user) {
718
+				$options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')');
719 719
 			}
720 720
 		} else {
721
-			$options[0] = __( 'No users found.', 'give' );
721
+			$options[0] = __('No users found.', 'give');
722 722
 		}
723 723
 
724
-		$output = $this->select( array(
724
+		$output = $this->select(array(
725 725
 			'name'             => $args['name'],
726 726
 			'selected'         => $args['selected'],
727 727
 			'id'               => $args['id'],
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 			'show_option_all'  => false,
735 735
 			'show_option_none' => false,
736 736
 			'data'             => $args['data'],
737
-		) );
737
+		));
738 738
 
739 739
 		return $output;
740 740
 
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load Give file.
18
-include_once( 'give.php' );
18
+include_once('give.php');
19 19
 
20 20
 global $wpdb, $wp_roles;
21 21
 
22 22
 
23
-if ( give_is_setting_enabled( give_get_option( 'uninstall_on_delete' ) ) ) {
23
+if (give_is_setting_enabled(give_get_option('uninstall_on_delete'))) {
24 24
 
25 25
 	// Delete All the Custom Post Types.
26
-	$give_taxonomies = array( 'form_category', 'form_tag' );
27
-	$give_post_types = array( 'give_forms', 'give_payment' );
28
-	foreach ( $give_post_types as $post_type ) {
26
+	$give_taxonomies = array('form_category', 'form_tag');
27
+	$give_post_types = array('give_forms', 'give_payment');
28
+	foreach ($give_post_types as $post_type) {
29 29
 
30
-		$give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) );
31
-		$items           = get_posts( array(
30
+		$give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type));
31
+		$items           = get_posts(array(
32 32
 			'post_type'   => $post_type,
33 33
 			'post_status' => 'any',
34
-			'numberposts' => - 1,
34
+			'numberposts' => -1,
35 35
 			'fields'      => 'ids',
36
-		) );
36
+		));
37 37
 
38
-		if ( $items ) {
39
-			foreach ( $items as $item ) {
40
-				wp_delete_post( $item, true );
38
+		if ($items) {
39
+			foreach ($items as $item) {
40
+				wp_delete_post($item, true);
41 41
 			}
42 42
 		}
43 43
 	}
44 44
 
45 45
 	// Delete All the Terms & Taxonomies.
46
-	foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) {
46
+	foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) {
47 47
 
48
-		$terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) );
48
+		$terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy));
49 49
 
50 50
 		// Delete Terms.
51
-		if ( $terms ) {
52
-			foreach ( $terms as $term ) {
53
-				$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) );
54
-				$wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) );
51
+		if ($terms) {
52
+			foreach ($terms as $term) {
53
+				$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id));
54
+				$wpdb->delete($wpdb->terms, array('term_id' => $term->term_id));
55 55
 			}
56 56
 		}
57 57
 
58 58
 		// Delete Taxonomies.
59
-		$wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) );
59
+		$wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s'));
60 60
 	}
61 61
 
62 62
 	// Delete the Plugin Pages.
63
-	$give_created_pages = array( 'success_page', 'failure_page', 'history_page' );
64
-	foreach ( $give_created_pages as $p ) {
65
-		$page = give_get_option( $p, false );
66
-		if ( $page ) {
67
-			wp_delete_post( $page, true );
63
+	$give_created_pages = array('success_page', 'failure_page', 'history_page');
64
+	foreach ($give_created_pages as $p) {
65
+		$page = give_get_option($p, false);
66
+		if ($page) {
67
+			wp_delete_post($page, true);
68 68
 		}
69 69
 	}
70 70
 
@@ -73,28 +73,28 @@  discard block
 block discarded – undo
73 73
 	Give()->roles->remove_caps();
74 74
 
75 75
 	// Delete the Roles.
76
-	$give_roles = array( 'give_manager', 'give_accountant', 'give_worker', 'give_donor' );
77
-	foreach ( $give_roles as $role ) {
78
-		remove_role( $role );
76
+	$give_roles = array('give_manager', 'give_accountant', 'give_worker', 'give_donor');
77
+	foreach ($give_roles as $role) {
78
+		remove_role($role);
79 79
 	}
80 80
 
81 81
 	// Remove all database tables.
82
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' );
83
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donormeta' );
84
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' );
85
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' );
86
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_paymentmeta' );
87
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_formmeta' );
88
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_logs' );
89
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_logmeta' );
90
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_sequential_ordering' );
91
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_sessions' );
82
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors');
83
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donormeta');
84
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers');
85
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta');
86
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_paymentmeta');
87
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_formmeta');
88
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_logs');
89
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_logmeta');
90
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_sequential_ordering');
91
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_sessions');
92 92
 
93 93
 	// Cleanup Cron Events.
94
-	wp_clear_scheduled_hook( 'give_daily_scheduled_events' );
95
-	wp_clear_scheduled_hook( 'give_weekly_scheduled_events' );
96
-	wp_clear_scheduled_hook( 'give_daily_cron' );
97
-	wp_clear_scheduled_hook( 'give_weekly_cron' );
94
+	wp_clear_scheduled_hook('give_daily_scheduled_events');
95
+	wp_clear_scheduled_hook('give_weekly_scheduled_events');
96
+	wp_clear_scheduled_hook('give_daily_cron');
97
+	wp_clear_scheduled_hook('give_weekly_cron');
98 98
 
99 99
 	// Get all options.
100 100
 	$give_option_names = $wpdb->get_col(
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
 		)
105 105
 	);
106 106
 
107
-	if ( ! empty( $give_option_names ) ) {
107
+	if ( ! empty($give_option_names)) {
108 108
 		// Convert option name to transient or option name.
109 109
 		$new_give_option_names = array();
110 110
 
111 111
 		// Delete all the Plugin Options.
112
-		foreach ( $give_option_names as $option ) {
113
-			if ( false !== strpos( $option, 'give_cache' ) ) {
114
-				Give_Cache::delete( $option );
112
+		foreach ($give_option_names as $option) {
113
+			if (false !== strpos($option, 'give_cache')) {
114
+				Give_Cache::delete($option);
115 115
 			} else {
116
-				delete_option( $option );
116
+				delete_option($option);
117 117
 			}
118 118
 		}
119 119
 	}
Please login to merge, or discard this patch.