Test Failed
Push — release/1.8.12 ( b58a2f...d255b1 )
by Ravinder
375:09 queued 372:17
created

includes/admin/class-admin-settings.php (114 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Give Admin Settings Class
4
 *
5
 * @package     Give
6
 * @subpackage  Classes/Give_Admin_Settings
7
 * @copyright   Copyright (c) 2016, WordImpress
8
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
 * @since       1.8
10
 */
11
12
if ( ! defined( 'ABSPATH' ) ) {
13
	exit;
14
}
15
16
if ( ! class_exists( 'Give_Admin_Settings' ) ) :
17
18
	/**
19
	 * Give_Admin_Settings Class.
20
	 *
21
	 * @since 1.8
22
	 */
23
	class Give_Admin_Settings {
24
25
		/**
26
		 * Setting pages.
27
		 *
28
		 * @since 1.8
29
		 * @var   array List of settings.
30
		 */
31
		private static $settings = array();
32
33
		/**
34
		 * Setting filter and action prefix.
35
		 *
36
		 * @since 1.8
37
		 * @var   string setting fileter and action anme prefix.
38
		 */
39
		private static $setting_filter_prefix = '';
40
41
		/**
42
		 * Error messages.
43
		 *
44
		 * @since 1.8
45
		 * @var   array List of errors.
46
		 */
47
		private static $errors = array();
48
49
		/**
50
		 * Update messages.
51
		 *
52
		 * @since 1.8
53
		 * @var   array List of messages.
54
		 */
55
		private static $messages = array();
56
57
		/**
58
		 * Include the settings page classes.
59
		 *
60
		 * @since  1.8
61
		 * @return array
62
		 */
63
		public static function get_settings_pages() {
64
			/**
65
			 * Filter the setting page.
66
			 *
67
			 * Note: filter dynamically fire on basis of setting page slug.
68
			 * For example: if you register a setting page with give-settings menu slug
69
			 *              then filter will be give-settings_get_settings_pages
70
			 *
71
			 * @since 1.8
72
			 *
73
			 * @param array $settings Array of settings class object.
74
			 */
75
			self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() );
76
77
			return self::$settings;
78
		}
79
80
		/**
81
		 * Save the settings.
82
		 *
83
		 * @since  1.8
84
		 * @return void
85
		 */
86
		public static function save() {
87
			$current_tab = give_get_current_setting_tab();
88
89
			if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) {
0 ignored issues
show
Detected access of super global var $_REQUEST, probably need manual inspection.
Loading history...
Detected usage of a non-sanitized input variable: $_REQUEST
Loading history...
90
				echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>';
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw '__'
Loading history...
91
				die();
92
			}
93
94
			/**
95
			 * Trigger Action.
96
			 *
97
			 * Note: action dynamically fire on basis of setting page slug and current tab.
98
			 * For example: if you register a setting page with give-settings menu slug and general current tab name
99
			 *              then action will be give-settings_save_general
100
			 *
101
			 * @since 1.8
102
			 */
103
			do_action( self::$setting_filter_prefix . '_save_' . $current_tab );
104
105
			self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) );
106
107
			/**
108
			 * Trigger Action.
109
			 *
110
			 * Note: action dynamically fire on basis of setting page slug.
111
			 * For example: if you register a setting page with give-settings menu slug
112
			 *              then action will be give-settings_saved
113
			 *
114
			 * @since 1.8
115
			 */
116
			do_action( self::$setting_filter_prefix . '_saved' );
117
		}
118
119
		/**
120
		 * Add a message.
121
		 *
122
		 * @since  1.8
123
		 *
124
		 * @param  string $code    Message code (Note: This should be unique).
125
		 * @param  string $message Message text.
126
		 *
127
		 * @return void
128
		 */
129
		public static function add_message( $code, $message ) {
130
			self::$messages[ $code ] = $message;
131
		}
132
133
		/**
134
		 * Add an error.
135
		 *
136
		 * @since  1.8
137
		 *
138
		 * @param  string $code    Message code (Note: This should be unique).
139
		 * @param  string $message Message text.
140
		 *
141
		 * @return void
142
		 */
143
		public static function add_error( $code, $message ) {
144
			self::$errors[ $code ] = $message;
145
		}
146
147
		/**
148
		 * Output messages + errors.
149
		 *
150
		 * @since  1.8
151
		 * @return void
152
		 */
153
		public static function show_messages() {
154
			$notice_html = '';
155
			$classes     = 'give-notice settings-error notice is-dismissible';
156
157
			self::$errors   = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors );
158
			self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages );
159
160 View Code Duplication
			if ( 0 < count( self::$errors ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
161
				foreach ( self::$errors as $code => $message ) {
162
					$notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>';
163
				}
164
			}
165
166 View Code Duplication
			if ( 0 < count( self::$messages ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
167
				foreach ( self::$messages as $code => $message ) {
168
					$notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>';
169
				}
170
			}
171
172
			echo $notice_html;
0 ignored issues
show
Expected next thing to be a escaping function, not '$notice_html'
Loading history...
173
		}
174
175
		/**
176
		 * Settings page.
177
		 *
178
		 * Handles the display of the main give settings page in admin.
179
		 *
180
		 * @since  1.8
181
		 * @return void|bool
182
		 */
183
		public static function output() {
184
			// Get current setting page.
185
			self::$setting_filter_prefix = give_get_current_setting_page();
186
187
			// Bailout: Exit if setting page is not defined.
188
			if ( empty( self::$setting_filter_prefix ) ) {
189
				return false;
190
			}
191
192
			/**
193
			 * Trigger Action.
194
			 *
195
			 * Note: action dynamically fire on basis of setting page slug
196
			 * For example: if you register a setting page with give-settings menu slug
197
			 *              then action will be give-settings_start
198
			 *
199
			 * @since 1.8
200
			 */
201
			do_action( self::$setting_filter_prefix . '_start' );
202
203
			$current_tab = give_get_current_setting_tab();
204
205
			// Include settings pages.
206
			self::get_settings_pages();
207
208
			// Save settings if data has been posted.
209
			if ( ! empty( $_POST ) ) {
0 ignored issues
show
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
210
				self::save();
211
			}
212
213
			/**
214
			 * Filter the tabs for current setting page.
215
			 *
216
			 * Note: filter dynamically fire on basis of setting page slug.
217
			 * For example: if you register a setting page with give-settings menu slug and general current tab name
218
			 *              then action will be give-settings_tabs_array
219
			 *
220
			 * @since 1.8
221
			 */
222
			$tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() );
223
224
			include 'views/html-admin-settings.php';
225
226
			return true;
227
		}
228
229
		/**
230
		 * Get a setting from the settings API.
231
		 *
232
		 * @since  1.8
233
		 *
234
		 * @param  string $option_name
235
		 * @param  string $field_id
236
		 * @param  mixed  $default
237
		 *
238
		 * @return string|bool
239
		 */
240
		public static function get_option( $option_name = '', $field_id = '', $default = false ) {
241
			// Bailout.
242
			if ( empty( $option_name ) && empty( $field_id ) ) {
243
				return false;
244
			}
245
246
			if ( ! empty( $field_id ) && ! empty( $option_name ) ) {
247
				// Get field value if any.
248
				$option_value = get_option( $option_name );
249
250
				$option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) )
251
					? $option_value[ $field_id ]
252
					: $default;
253
			} else {
254
				// If option name is empty but not field name then this means, setting is direct store to option table under there field name.
255
				$option_name = ! $option_name ? $field_id : $option_name;
256
257
				// Get option value if any.
258
				$option_value = get_option( $option_name, $default );
259
			}
260
261
			return $option_value;
262
		}
263
264
		/**
265
		 * Output admin fields.
266
		 *
267
		 * Loops though the give options array and outputs each field.
268
		 *
269
		 * @since  1.8
270
		 *
271
		 * @param  array  $options     Opens array to output
272
		 * @param  string $option_name Opens array to output
273
		 *
274
		 * @return void
275
		 */
276
		public static function output_fields( $options, $option_name = '' ) {
277
			$current_tab = give_get_current_setting_tab();
278
279
			// Field Default values.
280
			$defaults = array(
281
				'id'         => '',
282
				'class'      => '',
283
				'css'        => '',
284
				'default'    => '',
285
				'desc'       => '',
286
				'table_html' => true,
287
			);
288
289
			foreach ( $options as $value ) {
290
				if ( ! isset( $value['type'] ) ) {
291
					continue;
292
				}
293
294
				// Set title.
295
				$defaults['title'] = isset( $value['name'] ) ? $value['name'] : '';
296
297
				// Set default setting.
298
				$value = wp_parse_args( $value, $defaults );
299
300
				// Colorpicker field.
301
				$value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] );
302
				$value['type']  = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] );
303
0 ignored issues
show
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
304
305
				// Custom attribute handling.
306
				$custom_attributes = array();
307
308 View Code Duplication
				if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
309
					foreach ( $value['attributes'] as $attribute => $attribute_value ) {
310
						$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
311
					}
312
				}
313
314
				// Description handling.
315
				$description          = self::get_field_description( $value );
316
317
				// Switch based on type.
318
				switch ( $value['type'] ) {
319
320
					// Section Titles
321
					case 'title':
322
						if ( ! empty( $value['title'] ) ) {
323
							echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>';
0 ignored issues
show
Expected next thing to be a escaping function, not '$current_tab'
Loading history...
Expected next thing to be a escaping function, not 'self'
Loading history...
324
						}
325
326
						if ( ! empty( $value['desc'] ) ) {
327
							echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) );
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'wpautop'
Loading history...
328
						}
329
330
						if ( $value['table_html'] ) {
331
							echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n";
0 ignored issues
show
Expected next thing to be a escaping function, not '$current_tab'
Loading history...
332
						}
333
334
						if ( ! empty( $value['id'] ) ) {
335
336
							/**
337
							 * Trigger Action.
338
							 *
339
							 * Note: action dynamically fire on basis of field id.
340
							 *
341
							 * @since 1.8
342
							 */
343
							do_action( 'give_settings_' . sanitize_title( $value['id'] ) );
344
						}
345
346
						break;
347
348
					// Section Ends.
349
					case 'sectionend':
350 View Code Duplication
						if ( ! empty( $value['id'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
351
352
							/**
353
							 * Trigger Action.
354
							 *
355
							 * Note: action dynamically fire on basis of field id.
356
							 *
357
							 * @since 1.8
358
							 */
359
							do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' );
360
						}
361
362
						if ( $value['table_html'] ) {
363
							echo '</table>';
364
						}
365
366 View Code Duplication
						if ( ! empty( $value['id'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
367
368
							/**
369
							 * Trigger Action.
370
							 *
371
							 * Note: action dynamically fire on basis of field id.
372
							 *
373
							 * @since 1.8
374
							 */
375
							do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' );
376
						}
377
378
						break;
379
380
					// Standard text inputs and subtypes like 'number'.
381
					case 'colorpicker':
382
					case 'text':
383
					case 'email':
384
					case 'number':
385 View Code Duplication
					case 'password' :
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
386
387
						$type = $value['type'];
388
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
389
390
						?>
391
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
392
                        <th scope="row" class="titledesc">
393
                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
394
                        </th>
395
                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
396
                            <input
397
                                    name="<?php echo esc_attr( $value['id'] ); ?>"
398
                                    id="<?php echo esc_attr( $value['id'] ); ?>"
399
                                    type="<?php echo esc_attr( $type ); ?>"
400
                                    style="<?php echo esc_attr( $value['css'] ); ?>"
401
                                    value="<?php echo esc_attr( $option_value ); ?>"
402
                                    class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>"
0 ignored issues
show
Expected next thing to be a escaping function, not '('
Loading history...
403
								<?php echo implode( ' ', $custom_attributes ); ?>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'implode'
Loading history...
404
                            /> <?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
405
                        </td>
406
                        </tr><?php
407
						break;
408
409
					// Textarea.
410
					case 'textarea':
411
412
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
413
414
						?>
415
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
416
                        <th scope="row" class="titledesc">
417
                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
418
                        </th>
419
                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
420
								<textarea
421
                                        name="<?php echo esc_attr( $value['id'] ); ?>"
422
                                        id="<?php echo esc_attr( $value['id'] ); ?>"
423
                                        style="<?php echo esc_attr( $value['css'] ); ?>"
424
                                        class="<?php echo esc_attr( $value['class'] ); ?>"
425
                                        rows="10"
426
                                        cols="60"
427
									<?php echo implode( ' ', $custom_attributes ); ?>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'implode'
Loading history...
428
                                ><?php echo esc_textarea( $option_value ); ?></textarea>
429
							<?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
430
                        </td>
431
                        </tr><?php
432
						break;
433
434
					// Select boxes.
435
					case 'select' :
436
					case 'multiselect' :
437
438
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
439
440
						?>
441
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
442
                        <th scope="row" class="titledesc">
443
                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
444
                        </th>
445
                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
446
                            <select
447
                                    name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) {
0 ignored issues
show
Found "== '". Use Yoda Condition checks, you must
Loading history...
448
										echo '[]';
449
									} ?>"
450
                                    id="<?php echo esc_attr( $value['id'] ); ?>"
451
                                    style="<?php echo esc_attr( $value['css'] ); ?>"
452
                                    class="<?php echo esc_attr( $value['class'] ); ?>"
453
								<?php echo implode( ' ', $custom_attributes ); ?>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'implode'
Loading history...
454
								<?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '('
Loading history...
455
                            >
456
457
								<?php
458
								if ( ! empty( $value['options'] ) ) {
459
									foreach ( $value['options'] as $key => $val ) {
460
										?>
461
                                        <option value="<?php echo esc_attr( $key ); ?>" <?php
462
463
										if ( is_array( $option_value ) ) {
464
											selected( in_array( $key, $option_value ), true );
465
										} else {
466
											selected( $option_value, $key );
467
										}
468
469
										?>><?php echo $val ?></option>
0 ignored issues
show
Expected next thing to be a escaping function, not '$val'
Loading history...
470
										<?php
471
									}
472
								}
473
								?>
474
475
                            </select> <?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
476
                        </td>
477
                        </tr><?php
478
						break;
479
480
					// Radio inputs.
481
					case 'radio_inline' :
482
						$value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline';
483
					case 'radio' :
484
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
485
						?>
486
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
487
                        <th scope="row" class="titledesc">
488
                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
489
                        </th>
490
                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>">
0 ignored issues
show
Expected next thing to be a escaping function, not '('
Loading history...
491
                            <fieldset>
492
                                <ul>
493
									<?php
494 View Code Duplication
									foreach ( $value['options'] as $key => $val ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
495
										?>
496
                                        <li>
497
                                            <label><input
498
                                                        name="<?php echo esc_attr( $value['id'] ); ?>"
499
                                                        value="<?php echo $key; ?>"
0 ignored issues
show
Expected next thing to be a escaping function, not '$key'
Loading history...
500
                                                        type="radio"
501
                                                        style="<?php echo esc_attr( $value['css'] ); ?>"
502
													<?php echo implode( ' ', $custom_attributes ); ?>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'implode'
Loading history...
503
													<?php checked( $key, $option_value ); ?>
504
                                                /> <?php echo $val ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not '$val'
Loading history...
505
                                        </li>
506
										<?php
507
									}
508
									?>
509
									<?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
510
                            </fieldset>
511
                        </td>
512
                        </tr><?php
513
						break;
514
515
					// Checkbox input.
516
					case 'checkbox' :
517
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
518
						?>
519
                        <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
520
                            <th scope="row" class="titledesc">
521
                                <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
522
                            </th>
523
                            <td class="give-forminp">
524
                                <input
525
                                        name="<?php echo esc_attr( $value['id'] ); ?>"
526
                                        id="<?php echo esc_attr( $value['id'] ); ?>"
527
                                        type="checkbox"
528
                                        class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>"
529
                                        value="1"
530
									<?php checked( $option_value, 'on' ); ?>
531
									<?php echo implode( ' ', $custom_attributes ); ?>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'implode'
Loading history...
532
                                />
533
								<?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
534
                            </td>
535
                        </tr>
536
						<?php
537
						break;
538
539
					// Multi Checkbox input.
540
					case 'multicheck' :
541
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
542
						$option_value = is_array( $option_value ) ? $option_value : array();
543
						?>
544
                        <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
545
                            <th scope="row" class="titledesc">
546
                                <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
547
                            </th>
548
                            <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>">
0 ignored issues
show
Expected next thing to be a escaping function, not '('
Loading history...
549
                                <fieldset>
550
                                    <ul>
551
										<?php
552 View Code Duplication
										foreach ( $value['options'] as $key => $val ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
553
											?>
554
                                            <li>
555
                                                <label>
556
                                                    <input
557
                                                            name="<?php echo esc_attr( $value['id'] ); ?>[]"
558
                                                            value="<?php echo $key; ?>"
0 ignored issues
show
Expected next thing to be a escaping function, not '$key'
Loading history...
559
                                                            type="checkbox"
560
                                                            style="<?php echo esc_attr( $value['css'] ); ?>"
561
														<?php echo implode( ' ', $custom_attributes ); ?>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'implode'
Loading history...
562
														<?php if ( in_array( $key, $option_value ) ) {
563
															echo 'checked="checked"';
564
														} ?>
565
                                                    /> <?php echo $val ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$val'
Loading history...
566
                                                </label>
567
                                            </li>
568
											<?php
569
										}
570
										?>
571
										<?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
572
                                </fieldset>
573
                            </td>
574
                        </tr>
575
						<?php
576
						break;
577
578
					// File input field.
579
					case 'file' :
580
					case 'media' :
581
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
582
						$button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $value['type'] ? 'File' : 'Image' ) ), 'give' );
583
						$fvalue       = empty( $value['fvalue'] ) ? 'url' : $value['fvalue'];
584
585
						$allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' );
586
						$preview_image_src        = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : '#';
587
						$preview_image_extension  = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : '';
588
						$is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags );
589
						?>
590
						<tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
591
							<th scope="row" class="titledesc">
592
								<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
593
							</th>
594
							<td class="give-forminp">
595
								<div class="give-field-wrap">
596
									<label for="<?php echo $value['id'] ?>">
0 ignored issues
show
Expected next thing to be a escaping function, not '$value'
Loading history...
597
										<input
598
												name="<?php echo esc_attr( $value['id'] ); ?>"
599
												id="<?php echo esc_attr( $value['id'] ); ?>"
600
												type="text"
601
												class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>"
602
												value="<?php echo $option_value; ?>"
0 ignored issues
show
Expected next thing to be a escaping function, not '$option_value'
Loading history...
603
												style="<?php echo esc_attr( $value['css'] ); ?>"
604
											<?php echo implode( ' ', $custom_attributes ); ?>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'implode'
Loading history...
605
										/>&nbsp;&nbsp;&nbsp;&nbsp;<input class="give-upload-button button" type="button" data-fvalue="<?php echo $fvalue; ?>" data-field-type="<?php echo $value['type']; ?>" value="<?php echo $button_label; ?>">
0 ignored issues
show
Expected next thing to be a escaping function, not '$fvalue'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
Expected next thing to be a escaping function, not '$button_label'
Loading history...
606
										<?php echo $description ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
607
										<div class="give-image-thumb<?php echo ! $option_value || ! $is_show_preview ? ' give-hidden' : ''; ?>">
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
608
											<span class="give-delete-image-thumb dashicons dashicons-no-alt"></span>
609
											<img src="<?php echo $preview_image_src ; ?>" alt="">
0 ignored issues
show
Expected next thing to be a escaping function, not '$preview_image_src'
Loading history...
610
										</div>
611
									</label>
612
								</div>
613
							</td>
614
							</tr>
615
						<?php
616
						break;
617
618
					// WordPress Editor.
619
					case 'wysiwyg' :
620
						// Get option value.
621
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
622
623
						// Get editor settings.
624
						$editor_settings = ! empty( $value['options'] ) ? $value['options'] : array();
625
						?>
626
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
627
                        <th scope="row" class="titledesc">
628
                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
629
                        </th>
630
                        <td class="give-forminp">
631
							<?php wp_editor( $option_value, $value['id'], $editor_settings ); ?>
632
							<?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
633
                        </td>
634
                        </tr><?php
635
						break;
636
637
					// Custom: System setting field.
638 View Code Duplication
					case 'system_info' :
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
639
						?>
640
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
641
                        <th scope="row" class="titledesc">
642
                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
643
                        </th>
644
                        <td class="give-forminp">
645
							<?php give_system_info_callback(); ?>
646
							<?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
647
                        </td>
648
                        </tr><?php
649
						break;
650
651
					// Custom: Default gateways setting field.
652 View Code Duplication
					case 'default_gateway' :
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
653
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
654
						?>
655
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
656
                        <th scope="row" class="titledesc">
657
                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
658
                        </th>
659
                        <td class="give-forminp">
660
							<?php give_default_gateway_callback( $value, $option_value ); ?>
0 ignored issues
show
$option_value is of type string|boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
661
							<?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
662
                        </td>
663
                        </tr><?php
664
						break;
665
666
					// Custom: Enable gateways setting field.
667 View Code Duplication
					case 'enabled_gateways' :
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
668
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
669
						?>
670
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
671
                        <th scope="row" class="titledesc">
672
                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
673
                        </th>
674
                        <td class="give-forminp">
675
							<?php give_enabled_gateways_callback( $value, $option_value ); ?>
0 ignored issues
show
$option_value is of type string|boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
676
							<?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
677
                        </td>
678
                        </tr><?php
679
						break;
680
681
					// Custom: Email preview buttons field.
682 View Code Duplication
					case 'email_preview_buttons' :
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
683
						?>
684
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
685
                        <th scope="row" class="titledesc">
686
                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
687
                        </th>
688
                        <td class="give-forminp">
689
							<?php give_email_preview_buttons_callback(); ?>
690
							<?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
691
                        </td>
692
                        </tr><?php
693
						break;
694
695
					// Custom: API field.
696
					case 'api' :
697
						give_api_callback();
698
						echo $description;
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
699
						break;
700
701
					// Custom: Gateway API key.
702 View Code Duplication
					case 'api_key' :
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
703
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
704
						$type         = ! empty( $option_value ) ? 'password' : 'text';
705
						?>
706
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
707
                        <th scope="row" class="titledesc">
708
                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
0 ignored issues
show
Expected next thing to be a escaping function, not 'self'
Loading history...
709
                        </th>
710
                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
711
                            <input
712
                                    name="<?php echo esc_attr( $value['id'] ); ?>"
713
                                    id="<?php echo esc_attr( $value['id'] ); ?>"
714
                                    type="<?php echo esc_attr( $type ); ?>"
715
                                    style="<?php echo esc_attr( $value['css'] ); ?>"
716
                                    value="<?php echo esc_attr( trim( $option_value ) ); ?>"
717
                                    class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>"
0 ignored issues
show
Expected next thing to be a escaping function, not '('
Loading history...
718
								<?php echo implode( ' ', $custom_attributes ); ?>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'implode'
Loading history...
719
                            /> <?php echo $description; ?>
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
720
                        </td>
721
                        </tr><?php
722
						break;
723
724
					// Custom: Log field.
725
					case 'logs' :
726
727
						// Get current section.
728
						$current_section = $_GET['section'] = give_get_current_setting_section();
729
730
						/**
731
						 * Fires for each tab of logs view.
732
						 *
733
						 * @since 1.0
734
						 */
735
						do_action( "give_logs_view_{$current_section}" );
736
737
						echo $description;
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
738
						break;
739
740
					// Custom: Data field.
741
					case 'data' :
742
743
						include  GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php';
744
745
						echo $description;
0 ignored issues
show
Expected next thing to be a escaping function, not '$description'
Loading history...
746
						break;
747
748
					// Custom: Give Docs Link field type.
749
					case 'give_docs_link' :
750
						?>
751
                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
0 ignored issues
show
Expected next thing to be a escaping function, not '!'
Loading history...
Expected next thing to be a escaping function, not '$value'
Loading history...
752
                        <td class="give-docs-link" colspan="2">
753
							<?php
754
							echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] )
755
							     . '" target="_blank">'
756
							     . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] )
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'sprintf'
Loading history...
757
							     . '<span class="dashicons dashicons-editor-help"></span></a></p>';
758
							?>
759
                        </td>
760
                        </tr><?php
761
						break;
762
763
					// Default: run an action
764
					// You can add or handle your custom field action.
765
					default:
766
						// Get option value.
767
						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
768
						do_action( 'give_admin_field_' . $value['type'], $value, $option_value );
769
						break;
770
				}
771
			}
772
		}
773
774
		/**
775
		 * Helper function to get the formatted description for a given form field.
776
		 * Plugins can call this when implementing their own custom settings types.
777
		 *
778
		 * @since  1.8
779
		 *
780
		 * @param  array $value The form field value array
781
		 *
782
		 * @return string The HTML description of the field.
783
		 */
784
		public static function get_field_description( $value ) {
785
			$description = '';
786
787
			// Support for both 'description' and 'desc' args.
788
			$description_key = isset( $value['description'] ) ? 'description' : 'desc';
789
			$value           = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : '';
790
791
			if ( ! empty( $value ) ) {
792
				$description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>';
793
			}
794
795
			return $description;
796
		}
797
798
799
		/**
800
		 * Helper function to get the formated title.
801
		 * Plugins can call this when implementing their own custom settings types.
802
		 *
803
		 * @since  1.8
804
		 *
805
		 * @param  array $value The form field value array
806
		 *
807
		 * @return array The description and tip as a 2 element array
808
		 */
809
		public static function get_field_title( $value ) {
810
			$title = esc_html( $value['title'] );
811
812
			// If html tag detected then allow them to print.
813
			if ( strip_tags( $title ) ) {
814
				$title = $value['title'];
815
			}
816
817
			return $title;
818
		}
819
820
		/**
821
		 * Save admin fields.
822
		 *
823
		 * Loops though the give options array and outputs each field.
824
		 *
825
		 * @since  1.8
826
		 *
827
		 * @param  array  $options     Options array to output
828
		 * @param  string $option_name Option name to save output. If empty then option will be store in there own option name i.e option id.
829
		 *
830
		 * @return bool
831
		 */
832
		public static function save_fields( $options, $option_name = '' ) {
833
			if ( empty( $_POST ) ) {
0 ignored issues
show
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
834
				return false;
835
			}
836
837
			// Options to update will be stored here and saved later.
838
			$update_options = array();
839
840
			// Loop options and get values to save.
841
			foreach ( $options as $option ) {
842
				if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) {
843
					continue;
844
				}
845
846
				// Get posted value.
847
				if ( strstr( $option['id'], '[' ) ) {
848
					parse_str( $option['id'], $option_name_array );
849
					$field_option_name = current( array_keys( $option_name_array ) );
850
					$setting_name      = key( $option_name_array[ $field_option_name ] );
851
					$raw_value         = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null;
0 ignored issues
show
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
Detected usage of a non-sanitized input variable: $_POST
Loading history...
852
				} else {
853
					$field_option_name = $option['id'];
854
					$setting_name      = '';
855
					$raw_value         = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null;
0 ignored issues
show
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
Detected usage of a non-sanitized input variable: $_POST
Loading history...
856
				}
857
858
				// Format the value based on option type.
859
				switch ( $option['type'] ) {
860
					case 'checkbox' :
861
						$value = is_null( $raw_value ) ? '' : 'on';
862
						break;
863
					case 'wysiwyg'  :
864
					case 'textarea' :
865
						$value = wp_kses_post( trim( $raw_value ) );
866
						break;
867
					case 'multiselect' :
868
						$value = array_filter( array_map( 'give_clean', (array) $raw_value ) );
869
						break;
870
					default :
871
						$value = give_clean( $raw_value );
872
						break;
873
				}
874
875
				/**
876
				 * Sanitize the value of an option.
877
				 *
878
				 * @since 1.8
879
				 */
880
				$value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value );
881
882
				/**
883
				 * Sanitize the value of an option by option name.
884
				 *
885
				 * @since 1.8
886
				 */
887
				$value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value );
888
889
				if ( is_null( $value ) ) {
890
					continue;
891
				}
892
893
				// Check if option is an array and handle that differently to single values.
894
				if ( $field_option_name && $setting_name ) {
895
					if ( ! isset( $update_options[ $field_option_name ] ) ) {
896
						$update_options[ $field_option_name ] = get_option( $field_option_name, array() );
897
					}
898
					if ( ! is_array( $update_options[ $field_option_name ] ) ) {
899
						$update_options[ $field_option_name ] = array();
900
					}
901
					$update_options[ $field_option_name ][ $setting_name ] = $value;
902
				} else {
903
					$update_options[ $field_option_name ] = $value;
904
				}
905
			}
906
907
			// Save all options in our array or there own option name i.e. option id.
908
			if ( empty( $option_name ) ) {
909
				foreach ( $update_options as $name => $value ) {
910
					update_option( $name, $value );
911
912
					/**
913
					 * Trigger action.
914
					 *
915
					 * Note: This is dynamically fire on basis of option name.
916
					 *
917
					 * @since 1.8
918
					 */
919
					do_action( "give_save_option_{$name}", $value, $name );
920
				}
921
			} else {
922
				$old_options    = ( $old_options = get_option( $option_name ) ) ? $old_options : array();
923
				$update_options = array_merge( $old_options, $update_options );
924
925
				update_option( $option_name, $update_options );
926
927
				/**
928
				 * Trigger action.
929
				 *
930
				 * Note: This is dynamically fire on basis of setting name.
931
				 *
932
				 * @since 1.8
933
				 */
934
				do_action( "give_save_settings_{$option_name}", $update_options, $option_name );
935
			}
936
937
			return true;
938
		}
939
	}
940
941
endif;
942