| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Display date field. |
| 10 |
* |
| 11 |
* @author David Bisset |
| 12 |
* @package Charitable/Admin View/Settings |
| 13 |
* @copyright Copyright (c) 2023, WP Charitable LLC |
| 14 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 15 |
* @since 1.8.9 |
| 16 |
* @version 1.8.9 |
| 17 |
*/ |
| 18 |
|
| 19 |
// Determine if this is a tools field or settings field. |
| 20 |
$charitable_is_tools_field = charitable_is_tools_view(); |
| 21 |
|
| 22 |
if ( $charitable_is_tools_field ) { |
| 23 |
$charitable_tools_options = get_option( 'charitable_tools', array() ); |
| 24 |
$charitable_value = ''; |
| 25 |
if ( isset( $view_args['key'] ) && is_array( $view_args['key'] ) ) { |
| 26 |
$charitable_value_path = $charitable_tools_options; |
| 27 |
foreach ( $view_args['key'] as $charitable_key_part ) { |
| 28 |
if ( isset( $charitable_value_path[ $charitable_key_part ] ) ) { |
| 29 |
$charitable_value_path = $charitable_value_path[ $charitable_key_part ]; |
| 30 |
} else { |
| 31 |
$charitable_value_path = ''; |
| 32 |
break; |
| 33 |
} |
| 34 |
} |
| 35 |
$charitable_value = $charitable_value_path; |
| 36 |
} |
| 37 |
if ( empty( $charitable_value ) ) { |
| 38 |
$charitable_value = isset( $view_args['default'] ) ? $view_args['default'] : ''; |
| 39 |
} |
| 40 |
$charitable_field_id = sprintf( 'charitable_tools_%s', implode( '_', $view_args['key'] ) ); |
| 41 |
$charitable_field_name = sprintf( 'charitable_tools[%s]', $view_args['name'] ); |
| 42 |
} else { |
| 43 |
$charitable_value = charitable_get_option( $view_args['key'] ); |
| 44 |
if ( empty( $charitable_value ) ) { |
| 45 |
$charitable_value = isset( $view_args['default'] ) ? $view_args['default'] : ''; |
| 46 |
} |
| 47 |
$charitable_field_id = sprintf( 'charitable_settings_%s', implode( '_', $view_args['key'] ) ); |
| 48 |
$charitable_field_name = sprintf( 'charitable_settings[%s]', $view_args['name'] ); |
| 49 |
} |
| 50 |
|
| 51 |
?> |
| 52 |
<input type="date" |
| 53 |
id="<?php echo esc_attr( $charitable_field_id ); ?>" |
| 54 |
name="<?php echo esc_attr( $charitable_field_name ); ?>" |
| 55 |
value="<?php echo esc_attr( $charitable_value ); ?>" |
| 56 |
class="<?php echo esc_attr( $view_args['classes'] ); ?>" |
| 57 |
<?php echo charitable_get_arbitrary_attributes( $view_args ); // phpcs:ignore ?> /> |
| 58 |
<?php if ( isset( $view_args['help'] ) ) : ?> |
| 59 |
<div class="charitable-help"><?php echo $view_args['help']; // phpcs:ignore ?></div> |
| 60 |
<?php |
| 61 |
endif; |
| 62 |
|
| 63 |
|