| @@ -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_Extra_Field extends LP_Meta_Box_Field { | |
| 11 | - | |
| 12 | - /** | |
| 13 | - * Constructor. | |
| 14 | - * | |
| 15 | - * @param string $label | |
| 16 | - * @param string $description | |
| 17 | - * @param mixed $default | |
| 18 | - * @param array $extra | |
| 19 | - */ | |
| 20 | - public function __construct( $label = '', $description = '', $default = '', $extra = array() ) { | |
| 21 | - parent::__construct( $label, $description, $default, $extra ); | |
| 22 | - } | |
| 23 | - | |
| 24 | - public function output( $thepostid ) { | |
| 25 | - $fields = $this->meta_value( $thepostid ); | |
| 26 | - ?> | |
| 27 | - | |
| 28 | - <div class="form-field lp_course_extra_meta_box"> | |
| 29 | - <label for="<?php echo esc_attr( $this->id ); ?>"> | |
| 30 | - <?php echo wp_kses_post( $this->label ); ?> | |
| 31 | - </label> | |
| 32 | - <div class="lp_course_extra_meta_box__content"> | |
| 33 | - <div class="lp_course_extra_meta_box__fields"> | |
| 34 | - <?php if ( is_array( $fields ) && ! empty( $fields[0][0] ) ) : ?> | |
| 35 | - <?php foreach ( $fields as $field ) : ?> | |
| 36 | - <div class="lp_course_extra_meta_box__field"> | |
| 37 | - <span class="sort"></span> | |
| 38 | - <input name="<?php echo esc_attr( $this->id ); ?>[]" | |
| 39 | - value="<?php echo esc_attr( $field ); ?>" | |
| 40 | - type="text" class="lp_course_extra_meta_box__input"> | |
| 41 | - <a href="#" class="delete"></a> | |
| 42 | - </div> | |
| 43 | - <?php endforeach; ?> | |
| 44 | - <?php endif; ?> | |
| 45 | - </div> | |
| 46 | - | |
| 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 | - ?>"> | |
| 57 | - <?php esc_html_e( '+ Add more', 'learnpress' ); ?> | |
| 58 | - </a> | |
| 59 | - </div> | |
| 60 | - </div> | |
| 61 | - <?php | |
| 62 | - } | |
| 63 | - | |
| 64 | - public function save( $post_id ) { | |
| 65 | - $fields = LP_Request::get_param( $this->id, $this->default ?? [], 'html' ); | |
| 66 | - | |
| 67 | - update_post_meta( $post_id, $this->id, $fields ); | |
| 68 | - | |
| 69 | - return $fields; | |
| 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_Extra_Field extends LP_Meta_Box_Field { | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * Constructor. | |
| 14 | + * | |
| 15 | + * @param string $label | |
| 16 | + * @param string $description | |
| 17 | + * @param mixed $default | |
| 18 | + * @param array $extra | |
| 19 | + */ | |
| 20 | + public function __construct( $label = '', $description = '', $default = '', $extra = array() ) { | |
| 21 | + parent::__construct( $label, $description, $default, $extra ); | |
| 22 | + } | |
| 23 | + | |
| 24 | + public function output( $thepostid ) { | |
| 25 | + $fields = $this->meta_value( $thepostid ); | |
| 26 | + ?> | |
| 27 | + | |
| 28 | + <div class="form-field lp_course_extra_meta_box"> | |
| 29 | + <label for="<?php echo esc_attr( $this->id ); ?>"> | |
| 30 | + <?php echo wp_kses_post( $this->label ); ?> | |
| 31 | + </label> | |
| 32 | + <div class="lp_course_extra_meta_box__content"> | |
| 33 | + <div class="lp_course_extra_meta_box__fields"> | |
| 34 | + <?php if ( is_array( $fields ) && ! empty( $fields[0][0] ) ) : ?> | |
| 35 | + <?php foreach ( $fields as $field ) : ?> | |
| 36 | + <div class="lp_course_extra_meta_box__field"> | |
| 37 | + <span class="sort"></span> | |
| 38 | + <input name="<?php echo esc_attr( $this->id ); ?>[]" | |
| 39 | + value="<?php echo esc_attr( $field ); ?>" | |
| 40 | + type="text" class="lp_course_extra_meta_box__input"> | |
| 41 | + <a href="#" class="delete"></a> | |
| 42 | + </div> | |
| 43 | + <?php endforeach; ?> | |
| 44 | + <?php endif; ?> | |
| 45 | + </div> | |
| 46 | + | |
| 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 | + ?>"> | |
| 57 | + <?php esc_html_e( '+ Add more', 'learnpress' ); ?> | |
| 58 | + </a> | |
| 59 | + </div> | |
| 60 | + </div> | |
| 61 | + <?php | |
| 62 | + } | |
| 63 | + | |
| 64 | + public function save( $post_id ) { | |
| 65 | + $fields = LP_Request::get_param( $this->id, $this->default ?? [], 'html' ); | |
| 66 | + | |
| 67 | + update_post_meta( $post_id, $this->id, $fields ); | |
| 68 | + | |
| 69 | + return $fields; | |
| 70 | + } | |
| 71 | +} | |