| 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 |
?> |
| 28 |
|
| 29 |
<div class="lp_sale_dates_fields"> |
| 30 |
<p class="form-field <?php echo esc_attr( $this->extra['wrapper_class'] ); ?>"> |
| 31 |
<label for="_lp_sale_start"><?php echo wp_kses_post( $this->label ); ?></label> |
| 32 |
<input type="text" class="short" name="<?php echo esc_attr( $this->id ); ?>" |
| 33 |
id="<?php echo esc_attr( $this->id ); ?>" |
| 34 |
value="<?php echo esc_attr( $date ); ?>" |
| 35 |
placeholder="<?php echo esc_attr( $this->extra['placeholder'] ); ?>" |
| 36 |
style="width:320px;" /> |
| 37 |
|
| 38 |
<?php if ( ! empty( $this->extra['cancel'] ) ) : ?> |
| 39 |
<a href="#" class="description lp_cancel_sale_schedule"><?php esc_html_e( 'Cancel', 'learnpress' ); ?></a> |
| 40 |
<?php endif; ?> |
| 41 |
</p> |
| 42 |
</div> |
| 43 |
|
| 44 |
<?php |
| 45 |
} |
| 46 |
|
| 47 |
public function save( $post_id ) { |
| 48 |
$value = LP_Helper::sanitize_params_submitted( $_POST[ $this->id ] ?? '' ); |
| 49 |
update_post_meta( $post_id, $this->id, $value ); |
| 50 |
} |
| 51 |
} |
| 52 |
|