PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.9
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
learnpress / inc / admin / views / meta-boxes / fields / textarea.php

textarea.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.3.9, at inc/admin/views/meta-boxes/fields/textarea.php

93 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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_Textarea_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 if ( empty( $this->id ) ) {
26 return;
27 }
28
29 $field = $this->extra;
30 $field['id'] = $this->id;
31 $field['default'] = $this->default;
32 $field['description'] = $this->description;
33 $field['label'] = $this->label;
34
35 $field['placeholder'] = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
36 $field['class'] = isset( $field['class'] ) ? $field['class'] : 'short';
37 $field['style'] = isset( $field['style'] ) ? $field['style'] : '';
38 $field['default'] = ( ! $this->meta_value( $thepostid ) && isset( $field['default'] ) ) ? $field['default'] : $this->meta_value( $thepostid );
39 $field['value'] = isset( $field['value'] ) ? $field['value'] : $field['default'];
40 $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false;
41 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
42 $wrapper_attr = $field['wrapper_attr'] ?? [];
43 $wrapper_class = $this->extra['wrapper_class'] ?? '';
44
45 // Custom attribute handling
46 $custom_attributes = array();
47 if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) {
48 foreach ( $field['custom_attributes'] as $attribute => $custom_attribute ) {
49 $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $custom_attribute ) . '"';
50 }
51 }
52
53 $dependency_check = $this->extra['dependency'] ?? [];
54 if ( ! empty( $dependency_check ) ) {
55 if ( $dependency_check['is_disable'] ) {
56 $wrapper_class .= ' lp-option-disabled';
57 }
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
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(
71 ' ',
72 $custom_attributes
73 ) . '>' . esc_textarea( $field['value'] ) . '</textarea> ';
74
75 if ( ! empty( $field['description'] ) ) {
76 echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>';
77
78 if ( ! empty( $field['desc_tip'] ) ) {
79 learn_press_quick_tip( $field['desc_tip'] );
80 }
81 }
82
83 echo '</div>';
84 }
85
86 public function save( $post_id ) {
87 $value = LP_Request::get_param( $this->id, $this->default ?? '', 'html' );
88 update_post_meta( $post_id, $this->id, $value );
89
90 return $value;
91 }
92 }
93