| @@ -13,10 +13,10 @@ | ||
| 13 | 13 | * Constructor. |
| 14 | 14 | * |
| 15 | 15 | * @param string $label |
| 16 | 16 | * @param string $description |
| 17 | - * @param mixed $default | |
| 18 | - * @param array $extra | |
| 17 | + * @param mixed $default | |
| 18 | + * @param array $extra | |
| 19 | 19 | */ |
| 20 | 20 | public function __construct( $label = '', $description = '', $default = '', $extra = array() ) { |
| 21 | 21 | parent::__construct( $label, $description, $default, $extra ); |
| 22 | 22 | } |
| @@ -30,9 +30,9 @@ | ||
| 30 | 30 | <?php echo wp_kses_post( $this->label ); ?> |
| 31 | 31 | </label> |
| 32 | 32 | <div class="lp_course_extra_meta_box__content"> |
| 33 | 33 | <div class="lp_course_extra_meta_box__fields"> |
| 34 | - <?php if ( ! empty( $fields[0][0] ) ) : ?> | |
| 34 | + <?php if ( is_array( $fields ) && ! empty( $fields[0][0] ) ) : ?> | |
| 35 | 35 | <?php foreach ( $fields as $field ) : ?> |
| 36 | 36 | <div class="lp_course_extra_meta_box__field"> |
| 37 | 37 | <span class="sort"></span> |
| 38 | 38 | <input name="<?php echo esc_attr( $this->id ); ?>[]" |
| @@ -43,9 +43,18 @@ | ||
| 43 | 43 | <?php endforeach; ?> |
| 44 | 44 | <?php endif; ?> |
| 45 | 45 | </div> |
| 46 | 46 | |
| 47 | - <a href="#" class="button button-primary lp_course_extra_meta_box__add" data-add="<?php echo esc_attr( '<div class="lp_course_extra_meta_box__field"><span class="sort"></span></a><input name="' . $this->id . '[]" value="" type="text" class="lp_course_extra_meta_box__input"><a href="#" class="delete"></a></div>' ); ?>"> | |
| 47 | + <a href="#" class="button button-primary lp_course_extra_meta_box__add" | |
| 48 | + data-add=" | |
| 49 | + <?php echo esc_attr( | |
| 50 | + '<div class="lp_course_extra_meta_box__field"> | |
| 51 | + <span class="sort"></span> | |
| 52 | + <input name="' . $this->id . '[]" value="" type="text" class="lp_course_extra_meta_box__input"> | |
| 53 | + <a href="#" class="delete"></a> | |
| 54 | + </div>' | |
| 55 | + ); | |
| 56 | + ?>"> | |
| 48 | 57 | <?php esc_html_e( '+ Add more', 'learnpress' ); ?> |
| 49 | 58 | </a> |
| 50 | 59 | </div> |
| 51 | 60 | </div> |
| @@ -52,9 +61,11 @@ | ||
| 52 | 61 | <?php |
| 53 | 62 | } |
| 54 | 63 | |
| 55 | 64 | public function save( $post_id ) { |
| 56 | - $fields = isset( $_POST[ $this->id ] ) ? LP_Helper::sanitize_params_submitted( $_POST[ $this->id ], 'html' ) : array(); | |
| 65 | + $fields = LP_Request::get_param( $this->id, $this->default ?? [], 'html' ); | |
| 57 | 66 | |
| 58 | 67 | update_post_meta( $post_id, $this->id, $fields ); |
| 68 | + | |
| 69 | + return $fields; | |
| 59 | 70 | } |
| 60 | 71 | } |