| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display select field. |
| 4 |
* |
| 5 |
* @author David Bisset |
| 6 |
* @package Charitable/Admin View/Settings |
| 7 |
* @copyright Copyright (c) 2022, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.0.0 |
| 10 |
* @version 1.6.25 |
| 11 |
*/ |
| 12 |
|
| 13 |
$value = charitable_get_option( $view_args['key'] ); |
| 14 |
|
| 15 |
if ( false === $value ) { |
| 16 |
$value = isset( $view_args['default'] ) ? $view_args['default'] : ''; |
| 17 |
} |
| 18 |
|
| 19 |
$form_action_url = isset( $view_args['form_action_url'] ) ? $view_args['form_action_url'] : ''; |
| 20 |
$form_action_method = isset( $view_args['form_action_method'] ) ? $view_args['form_action_method'] : 'POST'; |
| 21 |
$button_label = isset( $view_args['button_label'] ) ? $view_args['button_label'] : 'Submit'; |
| 22 |
$nonce_action_name = isset( $view_args['nonce_action_name'] ) ? $view_args['nonce_action_name'] : 'wpcharitable-action'; |
| 23 |
$nonce_field_name = isset( $view_args['nonce_field_name'] ) ? $view_args['nonce_field_name'] : false; |
| 24 |
$select_name = isset( $view_args['select_name'] ) ? $view_args['select_name'] : $view_args['name']; |
| 25 |
?> |
| 26 |
<form action="<?php echo $form_action_url; ?>" method="POST" enctype="multipart/form-data" class="form-contains-file"> |
| 27 |
|
| 28 |
<?php wp_nonce_field( $nonce_action_name, $nonce_field_name ); ?> |
| 29 |
|
| 30 |
<?php if ( isset( $view_args['options'] ) ) : ?> |
| 31 |
<p class="top-label">Select a campaign to import donations into:</p> |
| 32 |
<?php endif; ?> |
| 33 |
|
| 34 |
<?php if ( isset( $view_args['options'] ) ) : ?> |
| 35 |
<div class="charitable-setting-dropdown-container"> |
| 36 |
<select id="<?php printf( 'charitable_settings_%s', implode( '_', $view_args['key'] ) ); ?>" |
| 37 |
name="<?php printf( 'charitable_settings[%s]', $select_name ); ?>" |
| 38 |
class="<?php echo esc_attr( $view_args['classes'] ); ?>" |
| 39 |
<?php echo charitable_get_arbitrary_attributes( $view_args ); ?> |
| 40 |
> |
| 41 |
<?php |
| 42 |
foreach ( $view_args['options'] as $key => $option ) : |
| 43 |
if ( is_array( $option ) ) : |
| 44 |
$label = isset( $option['label'] ) ? $option['label'] : ''; |
| 45 |
?> |
| 46 |
<optgroup label="<?php echo $label; ?>"> |
| 47 |
<?php foreach ( $option['options'] as $k => $opt ) : ?> |
| 48 |
<option value="<?php echo $k; ?>" <?php selected( $k, $value ); ?>><?php echo $opt; ?></option> |
| 49 |
<?php endforeach ?> |
| 50 |
</optgroup> |
| 51 |
<?php else : ?> |
| 52 |
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $value ); ?>><?php echo $option; ?></option> |
| 53 |
<?php |
| 54 |
endif; |
| 55 |
endforeach |
| 56 |
?> |
| 57 |
</select> |
| 58 |
<?php endif; ?> |
| 59 |
</div> |
| 60 |
<div class="charitable-setting-file-container"> |
| 61 |
|
| 62 |
<input type="file" id="<?php printf( 'charitable_settings_%s', implode( '_', $view_args['key'] ) ); ?>" |
| 63 |
name="<?php printf( 'charitable_settings[%s]', $view_args['name'] ); ?>" |
| 64 |
class="<?php echo esc_attr( $view_args['classes'] ); ?>" |
| 65 |
<?php echo charitable_get_arbitrary_attributes( $view_args ); ?> |
| 66 |
accept=".jsn,.json" |
| 67 |
/> |
| 68 |
<input class="button button-primary" type="submit" value="<?php echo $button_label; ?>"> |
| 69 |
|
| 70 |
</div> |
| 71 |
</form> |
| 72 |
<?php if ( isset( $view_args['help'] ) ) : ?> |
| 73 |
<div class="charitable-help"><?php echo $view_args['help']; ?></div> |
| 74 |
<?php |
| 75 |
endif; |
| 76 |
|