PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
← All changes | inc/admin/views/meta-boxes/fields/textarea.php +27 -11 4.2.04.4.8 View file →
@@ -11,13 +11,12 @@
11 11
12 12 /**
13 13 * Constructor.
14 14 *
15 - * @param string $id
16 15 * @param string $label
17 16 * @param string $description
18 - * @param mixed $default
19 - * @param array $extra
17 + * @param mixed $default
18 + * @param array $extra
20 19 */
21 20 public function __construct( $label = '', $description = '', $default = '', $extra = array() ) {
22 21 parent::__construct( $label, $description, $default, $extra );
23 22 }
@@ -39,8 +38,10 @@
39 38 $field['default'] = ( ! $this->meta_value( $thepostid ) && isset( $field['default'] ) ) ? $field['default'] : $this->meta_value( $thepostid );
40 39 $field['value'] = isset( $field['value'] ) ? $field['value'] : $field['default'];
41 40 $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false;
42 41 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
42 + $wrapper_attr = $field['wrapper_attr'] ?? [];
43 + $wrapper_class = $this->extra['wrapper_class'] ?? '';
43 44
44 45 // Custom attribute handling
45 46 $custom_attributes = array();
46 47 if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
@@ -48,15 +49,29 @@
48 49 $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $custom_attribute ) . '"';
49 50 }
50 51 }
51 52
52 - echo '<p class="form-field ' . esc_attr( $field['id'] ) . '_field ' . '">
53 - <label for="' . esc_attr( $field['id'] ) . '">' . wp_kses_post( $field['label'] ) . '</label>';
53 + $dependency_check = $this->extra['dependency'] ?? [];
54 + if ( ! empty( $dependency_check ) ) {
55 + if ( $dependency_check['is_disable'] ) {
56 + $wrapper_class .= ' lp-option-disabled';
57 + }
54 58
59 + $wrapper_attr[] = 'data-dependency=' . $dependency_check['name'];
60 + }
61 +
62 + printf(
63 + '<div class="form-field %s" %s><label for="%s">%s</label>',
64 + esc_attr( $this->id . '_field ' . $wrapper_class ),
65 + implode( ' ', $wrapper_attr ),
66 + esc_attr( $this->id ),
67 + wp_kses_post( $this->label )
68 + );
69 +
55 70 echo '<textarea class="' . esc_attr( $field['class'] ) . '" style="' . esc_attr( $field['style'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" rows="5" ' . implode(
56 - ' ',
57 - $custom_attributes
58 - ) . '>' . esc_textarea( $field['value'] ) . '</textarea> ';
71 + ' ',
72 + $custom_attributes
73 + ) . '>' . esc_textarea( $field['value'] ) . '</textarea> ';
59 74
60 75 if ( ! empty( $field['description'] ) ) {
61 76 echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
62 77
@@ -64,13 +79,14 @@
64 79 learn_press_quick_tip( $field['desc_tip'] );
65 80 }
66 81 }
67 82
68 - echo '</p>';
83 + echo '</div>';
69 84 }
70 85
71 86 public function save( $post_id ) {
72 - $value = ! empty( $_POST[ $this->id ] ) ? wp_kses_post( wp_unslash( $_POST[ $this->id ] ) ) : '';
87 + $value = LP_Request::get_param( $this->id, $this->default ?? '', 'html' );
88 + update_post_meta( $post_id, $this->id, $value );
73 89
74 - update_post_meta( $post_id, $this->id, $value );
90 + return $value;
75 91 }
76 92 }