Skip to content

Commit c82bd75

Browse files
committed
added date range from to option
1 parent 96bb277 commit c82bd75

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

fields/date/date.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,30 @@ public function render() {
2424
$settings = wp_parse_args( $settings, $default_settings );
2525

2626
echo $this->field_before();
27-
echo '<input type="text" name="'. $this->field_name() .'" value="'. $this->value .'" data-settings="'. esc_attr( json_encode( $settings ) ) .'"'. $this->field_attributes() .'/>';
27+
28+
if( ! empty( $this->field['from_to'] ) ) {
29+
30+
$args = wp_parse_args( $this->field, array(
31+
'text_from' => 'From',
32+
'text_to' => 'To',
33+
) );
34+
35+
$value = wp_parse_args( $this->value, array(
36+
'from' => '',
37+
'to' => '',
38+
) );
39+
40+
echo '<label class="csf--from">'. $args['text_from'] .' <input type="text" name="'. $this->field_name('[from]') .'" value="'. $value['from'] .'"'. $this->field_attributes() .'/></label>';
41+
echo '<label class="csf--to">'. $args['text_to'] .' <input type="text" name="'. $this->field_name('[to]') .'" value="'. $value['to'] .'"'. $this->field_attributes() .'/></label>';
42+
43+
} else {
44+
45+
echo '<input type="text" name="'. $this->field_name() .'" value="'. $this->value .'"'. $this->field_attributes() .'/>';
46+
47+
}
48+
49+
echo '<div class="csf-date-settings" data-settings="'. esc_attr( json_encode( $settings ) ) .'"></div>';
50+
2851
echo $this->field_after();
2952

3053
}

0 commit comments

Comments
 (0)