@@ -21,63 +21,63 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class Wl_Metabox_Field_Date extends Wl_Metabox_Field { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Attribute to distinguish between date formats, inferred from the schema property export type |
|
| 26 | - * |
|
| 27 | - * @since 3.2.0 |
|
| 28 | - * @access protected |
|
| 29 | - * @var string $date_format The date format. |
|
| 30 | - */ |
|
| 31 | - protected $date_format; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Boolean flag to decide if the calendar should include time or not |
|
| 35 | - * |
|
| 36 | - * @since 3.2.0 |
|
| 37 | - * @access protected |
|
| 38 | - * @var boolean $timepicker A boolean flag. |
|
| 39 | - */ |
|
| 40 | - protected $timepicker; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Whether the calendar should be displayed or not. |
|
| 44 | - * |
|
| 45 | - * @since 3.14.0 |
|
| 46 | - * @access protected |
|
| 47 | - * @var boolean $no_calendar Whether the calendar should be displayed or not. |
|
| 48 | - */ |
|
| 49 | - protected $no_calendar; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * {@inheritdoc} |
|
| 53 | - */ |
|
| 54 | - public function __construct( $args, $id, $type ) { |
|
| 55 | - parent::__construct( $args, $id, $type ); |
|
| 56 | - |
|
| 57 | - $this->no_calendar = false; |
|
| 58 | - |
|
| 59 | - // Distinguish between date and datetime |
|
| 60 | - if ( isset( $this->raw_custom_field['export_type'] ) && 'xsd:dateTime' === $this->raw_custom_field['export_type'] ) { |
|
| 61 | - $this->date_format = 'Y/m/d H:i'; |
|
| 62 | - $this->timepicker = true; |
|
| 63 | - } else { |
|
| 64 | - $this->date_format = 'Y/m/d'; |
|
| 65 | - $this->timepicker = false; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @param mixed $date |
|
| 72 | - * |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 75 | - public function html_input( $date ) { |
|
| 76 | - |
|
| 77 | - $this->log->debug( "Creating date input with date value $date..." ); |
|
| 78 | - |
|
| 79 | - ob_start(); |
|
| 80 | - ?> |
|
| 24 | + /** |
|
| 25 | + * Attribute to distinguish between date formats, inferred from the schema property export type |
|
| 26 | + * |
|
| 27 | + * @since 3.2.0 |
|
| 28 | + * @access protected |
|
| 29 | + * @var string $date_format The date format. |
|
| 30 | + */ |
|
| 31 | + protected $date_format; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Boolean flag to decide if the calendar should include time or not |
|
| 35 | + * |
|
| 36 | + * @since 3.2.0 |
|
| 37 | + * @access protected |
|
| 38 | + * @var boolean $timepicker A boolean flag. |
|
| 39 | + */ |
|
| 40 | + protected $timepicker; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Whether the calendar should be displayed or not. |
|
| 44 | + * |
|
| 45 | + * @since 3.14.0 |
|
| 46 | + * @access protected |
|
| 47 | + * @var boolean $no_calendar Whether the calendar should be displayed or not. |
|
| 48 | + */ |
|
| 49 | + protected $no_calendar; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * {@inheritdoc} |
|
| 53 | + */ |
|
| 54 | + public function __construct( $args, $id, $type ) { |
|
| 55 | + parent::__construct( $args, $id, $type ); |
|
| 56 | + |
|
| 57 | + $this->no_calendar = false; |
|
| 58 | + |
|
| 59 | + // Distinguish between date and datetime |
|
| 60 | + if ( isset( $this->raw_custom_field['export_type'] ) && 'xsd:dateTime' === $this->raw_custom_field['export_type'] ) { |
|
| 61 | + $this->date_format = 'Y/m/d H:i'; |
|
| 62 | + $this->timepicker = true; |
|
| 63 | + } else { |
|
| 64 | + $this->date_format = 'Y/m/d'; |
|
| 65 | + $this->timepicker = false; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @param mixed $date |
|
| 72 | + * |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | + public function html_input( $date ) { |
|
| 76 | + |
|
| 77 | + $this->log->debug( "Creating date input with date value $date..." ); |
|
| 78 | + |
|
| 79 | + ob_start(); |
|
| 80 | + ?> |
|
| 81 | 81 | <div class="wl-input-wrapper"> |
| 82 | 82 | <input |
| 83 | 83 | type="text" |
@@ -92,31 +92,31 @@ discard block |
||
| 92 | 92 | </button> |
| 93 | 93 | </div> |
| 94 | 94 | <?php |
| 95 | - $html = ob_get_clean(); |
|
| 95 | + $html = ob_get_clean(); |
|
| 96 | 96 | |
| 97 | - return $html; |
|
| 98 | - } |
|
| 97 | + return $html; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - public function html_wrapper_close() { |
|
| 100 | + public function html_wrapper_close() { |
|
| 101 | 101 | |
| 102 | - // Should the widget include time picker? |
|
| 102 | + // Should the widget include time picker? |
|
| 103 | 103 | |
| 104 | - // Set up the datetimepicker. |
|
| 105 | - // |
|
| 106 | - // See https://github.com/trentrichardson/jQuery-Timepicker-Addon |
|
| 107 | - // See in http://trentrichardson.com/examples/timepicker. |
|
| 104 | + // Set up the datetimepicker. |
|
| 105 | + // |
|
| 106 | + // See https://github.com/trentrichardson/jQuery-Timepicker-Addon |
|
| 107 | + // See in http://trentrichardson.com/examples/timepicker. |
|
| 108 | 108 | |
| 109 | - $js = |
|
| 110 | - array( |
|
| 111 | - 'enableTime' => $this->timepicker, |
|
| 112 | - 'noCalendar' => $this->no_calendar, |
|
| 113 | - 'time_24hr' => true, |
|
| 114 | - 'dateFormat' => $this->date_format, |
|
| 115 | - ); |
|
| 109 | + $js = |
|
| 110 | + array( |
|
| 111 | + 'enableTime' => $this->timepicker, |
|
| 112 | + 'noCalendar' => $this->no_calendar, |
|
| 113 | + 'time_24hr' => true, |
|
| 114 | + 'dateFormat' => $this->date_format, |
|
| 115 | + ); |
|
| 116 | 116 | |
| 117 | 117 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
| 118 | - @ob_start(); |
|
| 119 | - ?> |
|
| 118 | + @ob_start(); |
|
| 119 | + ?> |
|
| 120 | 120 | <script type='text/javascript'> |
| 121 | 121 | (function ($) { |
| 122 | 122 | $(function () { |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | })(jQuery); |
| 126 | 126 | </script> |
| 127 | 127 | <?php |
| 128 | - $html = ob_get_clean(); |
|
| 128 | + $html = ob_get_clean(); |
|
| 129 | 129 | |
| 130 | - $html .= parent::html_wrapper_close(); |
|
| 130 | + $html .= parent::html_wrapper_close(); |
|
| 131 | 131 | |
| 132 | - return $html; |
|
| 133 | - } |
|
| 132 | + return $html; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | } |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * {@inheritdoc} |
| 53 | 53 | */ |
| 54 | - public function __construct( $args, $id, $type ) { |
|
| 55 | - parent::__construct( $args, $id, $type ); |
|
| 54 | + public function __construct($args, $id, $type) { |
|
| 55 | + parent::__construct($args, $id, $type); |
|
| 56 | 56 | |
| 57 | 57 | $this->no_calendar = false; |
| 58 | 58 | |
| 59 | 59 | // Distinguish between date and datetime |
| 60 | - if ( isset( $this->raw_custom_field['export_type'] ) && 'xsd:dateTime' === $this->raw_custom_field['export_type'] ) { |
|
| 60 | + if (isset($this->raw_custom_field['export_type']) && 'xsd:dateTime' === $this->raw_custom_field['export_type']) { |
|
| 61 | 61 | $this->date_format = 'Y/m/d H:i'; |
| 62 | 62 | $this->timepicker = true; |
| 63 | 63 | } else { |
@@ -72,23 +72,23 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return string |
| 74 | 74 | */ |
| 75 | - public function html_input( $date ) { |
|
| 75 | + public function html_input($date) { |
|
| 76 | 76 | |
| 77 | - $this->log->debug( "Creating date input with date value $date..." ); |
|
| 77 | + $this->log->debug("Creating date input with date value $date..."); |
|
| 78 | 78 | |
| 79 | 79 | ob_start(); |
| 80 | 80 | ?> |
| 81 | 81 | <div class="wl-input-wrapper"> |
| 82 | 82 | <input |
| 83 | 83 | type="text" |
| 84 | - class="<?php echo esc_attr( $this->meta_name ); ?>" |
|
| 85 | - name="wl_metaboxes[<?php echo esc_attr( $this->meta_name ); ?>][]" |
|
| 86 | - value="<?php echo esc_attr( $date ); ?>" |
|
| 84 | + class="<?php echo esc_attr($this->meta_name); ?>" |
|
| 85 | + name="wl_metaboxes[<?php echo esc_attr($this->meta_name); ?>][]" |
|
| 86 | + value="<?php echo esc_attr($date); ?>" |
|
| 87 | 87 | style="width:88%" |
| 88 | 88 | /> |
| 89 | 89 | |
| 90 | 90 | <button class="button wl-remove-input wl-button" type="button"> |
| 91 | - <?php esc_html_e( 'Remove', 'wordlift' ); ?> |
|
| 91 | + <?php esc_html_e('Remove', 'wordlift'); ?> |
|
| 92 | 92 | </button> |
| 93 | 93 | </div> |
| 94 | 94 | <?php |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | <script type='text/javascript'> |
| 121 | 121 | (function ($) { |
| 122 | 122 | $(function () { |
| 123 | - $('.<?php echo esc_js( $this->meta_name ); ?>[type=text]').flatpickr(<?php echo wp_json_encode( $js ); ?>); |
|
| 123 | + $('.<?php echo esc_js($this->meta_name); ?>[type=text]').flatpickr(<?php echo wp_json_encode($js); ?>); |
|
| 124 | 124 | }); |
| 125 | 125 | })(jQuery); |
| 126 | 126 | </script> |