| @@ -1,71 +1,71 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * LP_Meta_Box_Duration_Attribute | |
| 5 | - * | |
| 6 | - * @author tungnx | |
| 7 | - * @version 1.0.0 | |
| 8 | - * @since 4.0.0 | |
| 9 | - */ | |
| 10 | -class LP_Meta_Box_Date_Field extends LP_Meta_Box_Field { | |
| 11 | - | |
| 12 | - /** | |
| 13 | - * Constructor. | |
| 14 | - * | |
| 15 | - * @param string $id | |
| 16 | - * @param string $label | |
| 17 | - * @param string $description | |
| 18 | - * @param mixed $default | |
| 19 | - * @param array $extra | |
| 20 | - */ | |
| 21 | - public function __construct( $label = '', $description = '', $default = '', $extra = array() ) { | |
| 22 | - parent::__construct( $label, $description, $default, $extra ); | |
| 23 | - } | |
| 24 | - | |
| 25 | - public function output( $thepostid ) { | |
| 26 | - $date = $this->meta_value( $thepostid ); | |
| 27 | - if ( ! empty( $date ) ) { | |
| 28 | - $dateObj = new LP_Datetime( $date ); | |
| 29 | - $date = $dateObj->format( 'mysql' ); | |
| 30 | - } | |
| 31 | - | |
| 32 | - $wrapper_attr = $this->extra['wrapper_attr'] ?? []; | |
| 33 | - $dependency_check = $this->extra['dependency'] ?? []; | |
| 34 | - if ( ! empty( $dependency_check ) ) { | |
| 35 | - if ( $dependency_check['is_disable'] ) { | |
| 36 | - $this->extra['wrapper_class'] .= ' lp-option-disabled'; | |
| 37 | - } | |
| 38 | - | |
| 39 | - $wrapper_attr[] = 'data-dependency=' . $dependency_check['name']; | |
| 40 | - } | |
| 41 | - ?> | |
| 42 | - | |
| 43 | - <div class="lp_sale_dates_fields"> | |
| 44 | - <p class="form-field <?php echo esc_attr( $this->extra['wrapper_class'] ); ?>" | |
| 45 | - <?php echo esc_attr( implode( ' ', $wrapper_attr ) ) ?>> | |
| 46 | - <label for="_lp_sale_start"><?php echo wp_kses_post( $this->label ); ?></label> | |
| 47 | - <input type="datetime-local" class="short" name="<?php echo esc_attr( $this->id ); ?>" | |
| 48 | - step=1 | |
| 49 | - id="<?php echo esc_attr( $this->id ); ?>" | |
| 50 | - value="<?php echo esc_attr( $date ); ?>" | |
| 51 | - placeholder="<?php echo esc_attr( $this->extra['placeholder'] ); ?>" | |
| 52 | - style="width:320px;"/> | |
| 53 | - | |
| 54 | - <?php if ( ! empty( $this->extra['cancel'] ) ) : ?> | |
| 55 | - <a href="#" class="description lp_cancel_sale_schedule"> | |
| 56 | - <?php esc_html_e( 'Cancel', 'learnpress' ); ?> | |
| 57 | - </a> | |
| 58 | - <?php endif; ?> | |
| 59 | - </p> | |
| 60 | - </div> | |
| 61 | - | |
| 62 | - <?php | |
| 63 | - } | |
| 64 | - | |
| 65 | - public function save( $post_id ) { | |
| 66 | - $value = LP_Request::get_param( $this->id, $this->default ?? '' ); | |
| 67 | - update_post_meta( $post_id, $this->id, $value ); | |
| 68 | - | |
| 69 | - return $value; | |
| 70 | - } | |
| 71 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * LP_Meta_Box_Duration_Attribute | |
| 5 | + * | |
| 6 | + * @author tungnx | |
| 7 | + * @version 1.0.0 | |
| 8 | + * @since 4.0.0 | |
| 9 | + */ | |
| 10 | +class LP_Meta_Box_Date_Field extends LP_Meta_Box_Field { | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * Constructor. | |
| 14 | + * | |
| 15 | + * @param string $id | |
| 16 | + * @param string $label | |
| 17 | + * @param string $description | |
| 18 | + * @param mixed $default | |
| 19 | + * @param array $extra | |
| 20 | + */ | |
| 21 | + public function __construct( $label = '', $description = '', $default = '', $extra = array() ) { | |
| 22 | + parent::__construct( $label, $description, $default, $extra ); | |
| 23 | + } | |
| 24 | + | |
| 25 | + public function output( $thepostid ) { | |
| 26 | + $date = $this->meta_value( $thepostid ); | |
| 27 | + if ( ! empty( $date ) ) { | |
| 28 | + $dateObj = new LP_Datetime( $date ); | |
| 29 | + $date = $dateObj->format( 'mysql' ); | |
| 30 | + } | |
| 31 | + | |
| 32 | + $wrapper_attr = $this->extra['wrapper_attr'] ?? []; | |
| 33 | + $dependency_check = $this->extra['dependency'] ?? []; | |
| 34 | + if ( ! empty( $dependency_check ) ) { | |
| 35 | + if ( $dependency_check['is_disable'] ) { | |
| 36 | + $this->extra['wrapper_class'] .= ' lp-option-disabled'; | |
| 37 | + } | |
| 38 | + | |
| 39 | + $wrapper_attr[] = 'data-dependency=' . $dependency_check['name']; | |
| 40 | + } | |
| 41 | + ?> | |
| 42 | + | |
| 43 | + <div class="lp_sale_dates_fields"> | |
| 44 | + <p class="form-field <?php echo esc_attr( $this->extra['wrapper_class'] ); ?>" | |
| 45 | + <?php echo esc_attr( implode( ' ', $wrapper_attr ) ) ?>> | |
| 46 | + <label for="_lp_sale_start"><?php echo wp_kses_post( $this->label ); ?></label> | |
| 47 | + <input type="datetime-local" class="short" name="<?php echo esc_attr( $this->id ); ?>" | |
| 48 | + step=1 | |
| 49 | + id="<?php echo esc_attr( $this->id ); ?>" | |
| 50 | + value="<?php echo esc_attr( $date ); ?>" | |
| 51 | + placeholder="<?php echo esc_attr( $this->extra['placeholder'] ); ?>" | |
| 52 | + style="width:320px;"/> | |
| 53 | + | |
| 54 | + <?php if ( ! empty( $this->extra['cancel'] ) ) : ?> | |
| 55 | + <a href="#" class="description lp_cancel_sale_schedule"> | |
| 56 | + <?php esc_html_e( 'Cancel', 'learnpress' ); ?> | |
| 57 | + </a> | |
| 58 | + <?php endif; ?> | |
| 59 | + </p> | |
| 60 | + </div> | |
| 61 | + | |
| 62 | + <?php | |
| 63 | + } | |
| 64 | + | |
| 65 | + public function save( $post_id ) { | |
| 66 | + $value = LP_Request::get_param( $this->id, $this->default ?? '' ); | |
| 67 | + update_post_meta( $post_id, $this->id, $value ); | |
| 68 | + | |
| 69 | + return $value; | |
| 70 | + } | |
| 71 | +} | |