PluginProbe
Cool Timeline (Horizontal & Vertical Timeline) / trunk
Cool Timeline (Horizontal & Vertical Timeline) vtrunk
3.4.0 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 2.2.3 2.3.3 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.6.1 2.7.1 2.8.3 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 All 79 releases
cool-timeline / admin / codestar-framework / fields / datetime / datetime.php

datetime.php in Cool Timeline (Horizontal & Vertical Timeline) trunk, at admin/codestar-framework/fields/datetime/datetime.php

75 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) {
2 die;
3 } // Cannot access directly.
4 // phpcs:ignoreFile WordPress.Security.EscapeOutput.OutputNotEscaped
5 /**
6 *
7 * Field: datetime
8 *
9 * @since 1.0.0
10 * @version 1.0.0
11 */
12 if ( ! class_exists( 'CSF_Field_datetime' ) ) {
13 class CSF_Field_datetime extends CSF_Fields {
14
15
16 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
17
18 parent::__construct( $field, $value, $unique, $where, $parent );
19 }
20
21 public function render() {
22
23 $defaults = array(
24 'allowInput' => true,
25 );
26
27 $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
28
29 if ( ! isset( $settings['noCalendar'] ) ) {
30 $defaults['dateFormat'] = 'm/d/Y';
31 }
32
33 $settings = wp_parse_args( $settings, $defaults );
34
35 echo $this->field_before();
36
37 if ( ! empty( $this->field['from_to'] ) ) {
38
39 // phpcs:disable WordPress.WP.I18n.TextDomainMismatch
40 $args = wp_parse_args(
41 $this->field,
42 array(
43 'text_from' => esc_html__( 'From', 'csf' ),
44 'text_to' => esc_html__( 'To', 'csf' ),
45 )
46 );
47 // phpcs:enable WordPress.WP.I18n.TextDomainMismatch
48
49 $value = wp_parse_args(
50 $this->value,
51 array(
52 'from' => '',
53 'to' => '',
54 )
55 );
56
57 echo '<label class="csf--from">' . esc_attr( $args['text_from'] ) . ' <input type="text" name="' . esc_attr( $this->field_name( '[from]' ) ) . '" value="' . esc_attr( $value['from'] ) . '"' . $this->field_attributes() . ' data-type="from" /></label>';
58 echo '<label class="csf--to">' . esc_attr( $args['text_to'] ) . ' <input type="text" name="' . esc_attr( $this->field_name( '[to]' ) ) . '" value="' . esc_attr( $value['to'] ) . '"' . $this->field_attributes() . ' data-type="to" /></label>';
59
60 } else {
61
62 echo '<input type="text" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $this->value ) . '"' . $this->field_attributes() . '/>';
63
64 }
65
66 echo '<div class="csf-datetime-settings" data-settings="' . esc_attr( json_encode( $settings ) ) . '"></div>';
67
68 echo $this->field_after();
69
70 }
71
72 }
73 }
74
75