| @@ -14,10 +14,10 @@ | ||
| 14 | 14 | * |
| 15 | 15 | * @param string $id |
| 16 | 16 | * @param string $label |
| 17 | 17 | * @param string $description |
| 18 | - * @param mixed $default | |
| 19 | - * @param array $extra | |
| 18 | + * @param mixed $default | |
| 19 | + * @param array $extra | |
| 20 | 20 | */ |
| 21 | 21 | public function __construct( $label = '', $description = '', $default = '', $extra = array() ) { |
| 22 | 22 | parent::__construct( $label, $description, $default, $extra ); |
| 23 | 23 | } |
| @@ -23,9 +23,9 @@ | ||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function output( $thepostid ) { |
| 26 | 26 | if ( empty( $this->id ) ) { |
| 27 | - return; | |
| 27 | + return ''; | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $field = $this->extra; |
| 31 | 31 | $field['id'] = $this->id; |
| @@ -89,10 +89,12 @@ | ||
| 89 | 89 | public function save( $post_id ) { |
| 90 | 90 | $duration = learn_press_get_course_duration_support(); |
| 91 | 91 | $duration_keys = array_keys( $duration ); |
| 92 | 92 | $default_time = ! empty( $this->extra['default_time'] ) ? $this->extra['default_time'] : end( $duration_keys ); |
| 93 | + $data = LP_Request::get_param( $this->id, [] ); | |
| 94 | + $duration = isset( $data[0] ) && $data[0] !== '' ? absint( $data[0] ) . ' ' . trim( $data[1] ) : absint( $this->default ) . ' ' . trim( $default_time ); | |
| 93 | 95 | |
| 94 | - $duration = isset( $_POST[ $this->id ][0] ) && $_POST[ $this->id ][0] !== '' ? absint( wp_unslash( $_POST[ $this->id ][0] ) ) . ' ' . trim( wp_unslash( $_POST[ $this->id ][1] ) ) : absint( $this->default ) . ' ' . trim( $default_time ); | |
| 96 | + update_post_meta( $post_id, $this->id, $duration ); | |
| 95 | 97 | |
| 96 | - update_post_meta( $post_id, $this->id, $duration ); | |
| 98 | + return $duration; | |
| 97 | 99 | } |
| 98 | 100 | } |