← All changes
|
frameworks/codestar-framework/fields/datetime/datetime.php
+61
-61
2.3.4
→
2.4.0
View file →
| @@ -1,61 +1,61 @@ | ||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly. | |
| 2 | -/** | |
| 3 | - * | |
| 4 | - * Field: datetime | |
| 5 | - * | |
| 6 | - * @since 1.0.0 | |
| 7 | - * @version 1.0.0 | |
| 8 | - * | |
| 9 | - */ | |
| 10 | -if ( ! class_exists( 'CSF_Field_datetime' ) ) { | |
| 11 | - class CSF_Field_datetime extends CSF_Fields { | |
| 12 | - | |
| 13 | - public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { | |
| 14 | - parent::__construct( $field, $value, $unique, $where, $parent ); | |
| 15 | - } | |
| 16 | - | |
| 17 | - public function render() { | |
| 18 | - | |
| 19 | - $defaults = array( | |
| 20 | - 'allowInput' => true, | |
| 21 | - ); | |
| 22 | - | |
| 23 | - $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array(); | |
| 24 | - | |
| 25 | - if ( ! isset( $settings['noCalendar'] ) ) { | |
| 26 | - $defaults['dateFormat'] = 'm/d/Y'; | |
| 27 | - } | |
| 28 | - | |
| 29 | - $settings = wp_parse_args( $settings, $defaults ); | |
| 30 | - | |
| 31 | - echo $this->field_before(); | |
| 32 | - | |
| 33 | - if ( ! empty( $this->field['from_to'] ) ) { | |
| 34 | - | |
| 35 | - $args = wp_parse_args( $this->field, array( | |
| 36 | - 'text_from' => esc_html__( 'From', 'csf' ), | |
| 37 | - 'text_to' => esc_html__( 'To', 'csf' ), | |
| 38 | - ) ); | |
| 39 | - | |
| 40 | - $value = wp_parse_args( $this->value, array( | |
| 41 | - 'from' => '', | |
| 42 | - 'to' => '', | |
| 43 | - ) ); | |
| 44 | - | |
| 45 | - 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>'; | |
| 46 | - 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>'; | |
| 47 | - | |
| 48 | - } else { | |
| 49 | - | |
| 50 | - echo '<input type="text" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .'/>'; | |
| 51 | - | |
| 52 | - } | |
| 53 | - | |
| 54 | - echo '<div class="csf-datetime-settings" data-settings="'. esc_attr( json_encode( $settings ) ) .'"></div>'; | |
| 55 | - | |
| 56 | - echo $this->field_after(); | |
| 57 | - | |
| 58 | - } | |
| 59 | - | |
| 60 | - } | |
| 61 | -} | |
| 1 | +<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly. | |
| 2 | +/** | |
| 3 | + * | |
| 4 | + * Field: datetime | |
| 5 | + * | |
| 6 | + * @since 1.0.0 | |
| 7 | + * @version 1.0.0 | |
| 8 | + * | |
| 9 | + */ | |
| 10 | +if ( ! class_exists( 'CSF_Field_datetime' ) ) { | |
| 11 | + class CSF_Field_datetime extends CSF_Fields { | |
| 12 | + | |
| 13 | + public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { | |
| 14 | + parent::__construct( $field, $value, $unique, $where, $parent ); | |
| 15 | + } | |
| 16 | + | |
| 17 | + public function render() { | |
| 18 | + | |
| 19 | + $defaults = array( | |
| 20 | + 'allowInput' => true, | |
| 21 | + ); | |
| 22 | + | |
| 23 | + $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array(); | |
| 24 | + | |
| 25 | + if ( ! isset( $settings['noCalendar'] ) ) { | |
| 26 | + $defaults['dateFormat'] = 'm/d/Y'; | |
| 27 | + } | |
| 28 | + | |
| 29 | + $settings = wp_parse_args( $settings, $defaults ); | |
| 30 | + | |
| 31 | + echo wp_kses_post( $this->field_before() ); | |
| 32 | + | |
| 33 | + if ( ! empty( $this->field['from_to'] ) ) { | |
| 34 | + | |
| 35 | + $args = wp_parse_args( $this->field, array( | |
| 36 | + 'text_from' => esc_html__( 'From', 'streamcast' ), | |
| 37 | + 'text_to' => esc_html__( 'To', 'streamcast' ), | |
| 38 | + ) ); | |
| 39 | + | |
| 40 | + $value = wp_parse_args( $this->value, array( | |
| 41 | + 'from' => '', | |
| 42 | + 'to' => '', | |
| 43 | + ) ); | |
| 44 | + | |
| 45 | + echo '<label class="csf--from">'. esc_html( $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>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 46 | + echo '<label class="csf--to">'. esc_html( $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>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 47 | + | |
| 48 | + } else { | |
| 49 | + | |
| 50 | + echo '<input type="text" name="'. esc_attr( $this->field_name() ) .'" value="'. esc_attr( $this->value ) .'"'. $this->field_attributes() .'/>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 51 | + | |
| 52 | + } | |
| 53 | + | |
| 54 | + echo '<div class="csf-datetime-settings" data-settings="'. esc_attr( json_encode( $settings ) ) .'"></div>'; | |
| 55 | + | |
| 56 | + echo wp_kses_post( $this->field_after() ); | |
| 57 | + | |
| 58 | + } | |
| 59 | + | |
| 60 | + } | |
| 61 | +} | |