PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.4.8
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.4.8
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
← All changes | includes/fields/class-field-textarea.php +139 -150 1.6.151.4.8 View file →
@@ -1,150 +1,139 @@
1 -<?php
2 -
3 -/**
4 - * Text Field Class
5 - */
6 -class WeForms_Form_Field_Textarea extends WeForms_Field_Contract {
7 -
8 - public function __construct() {
9 - $this->name = __( 'Textarea', 'weforms' );
10 - $this->input_type = 'textarea_field';
11 - $this->icon = 'paragraph';
12 - }
13 -
14 - /**
15 - * Render the text field
16 - *
17 - * @param array $field_settings
18 - * @param int $form_id
19 - *
20 - * @return void
21 - */
22 - public function render( $field_settings, $form_id ) {
23 - $req_class = ( $field_settings['required'] == 'yes' ) ? 'required' : 'rich-editor';
24 - $value = $field_settings['default'];
25 - $textarea_id = $field_settings['name'] ? $field_settings['name'] . '_' . $form_id : 'textarea_';
26 - $form_settings = weforms()->form->get( $form_id )->get_settings();
27 - $use_theme_css = isset( $form_settings['use_theme_css'] ) ? $form_settings['use_theme_css'] : 'wpuf-style';
28 - ?>
29 - <li <?php $this->print_list_attributes( $field_settings ); ?>>
30 - <?php $this->print_label( $field_settings, $form_id ); ?>
31 - <?php if ( in_array( $field_settings['rich'], array( 'yes', 'teeny' ) ) ) { ?>
32 - <div
33 - class="wpuf-fields wpuf-rich-validation <?php printf( wp_kses_post( 'wpuf_%s_%s', $field_settings['name'], $form_id ) ); ?>"
34 - data-type="rich"
35 - data-required="<?php echo esc_attr( $field_settings['required'] ); ?>"
36 - data-id="<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>"
37 - data-name="<?php echo esc_attr( $field_settings['name'] ); ?>"
38 - data-style="<?php echo esc_attr( $use_theme_css ); ?>"
39 - >
40 - <?php } else { ?>
41 - <div class="wpuf-fields">
42 - <?php } ?>
43 -
44 - <?php
45 -
46 - if ( $field_settings['rich'] == 'yes' ) {
47 - $editor_settings = [
48 - 'textarea_rows' => $field_settings['rows'],
49 - 'quicktags' => false,
50 - 'media_buttons' => false,
51 - 'editor_class' => $req_class,
52 - 'textarea_name' => $field_settings['name'],
53 - ];
54 -
55 - $editor_settings = apply_filters( 'wpuf_textarea_editor_args', $editor_settings );
56 - wp_editor( $value, $textarea_id, $editor_settings );
57 - } elseif ( $field_settings['rich'] == 'teeny' ) {
58 - $editor_settings = [
59 - 'textarea_rows' => $field_settings['rows'],
60 - 'quicktags' => false,
61 - 'media_buttons' => false,
62 - 'teeny' => true,
63 - 'editor_class' => $req_class,
64 - 'textarea_name' => $field_settings['name'],
65 - ];
66 -
67 - $editor_settings = apply_filters( 'wpuf_textarea_editor_args', $editor_settings );
68 - wp_editor( $value, $textarea_id, $editor_settings );
69 - } else {
70 - ?>
71 - <textarea
72 - class="textareafield <?php echo ' wpuf_'. esc_attr( $field_settings['name'] ).'_'. esc_attr( $form_id ); ?>"
73 - id="<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>"
74 - name="<?php echo esc_attr( $field_settings['name'] ); ?>"
75 - data-required="<?php echo esc_attr( $field_settings['required'] ) ?>"
76 - data-type="textarea"
77 - placeholder="<?php echo esc_attr( $field_settings['placeholder'] ); ?>"
78 - rows="<?php echo esc_attr($field_settings['rows']); ?>"
79 - cols="<?php echo esc_attr($field_settings['cols']); ?>"
80 - data-style="<?php echo esc_attr( $use_theme_css ); ?>"
81 - ><?php echo esc_textarea( $value ) ?></textarea>
82 - <span class="wpuf-wordlimit-message wpuf-help"></span>
83 -
84 - <?php
85 - } ?>
86 -
87 - <?php
88 - $this->help_text( $field_settings );
89 -
90 - if ( isset( $field_settings['word_restriction'] ) && $field_settings['word_restriction'] ) {
91 - $this->check_word_restriction_func(
92 - $field_settings['word_restriction'],
93 - $field_settings['rich'],
94 - $field_settings['name'] . '_' . $form_id
95 - );
96 - } ?>
97 - </li>
98 - <?php
99 - }
100 -
101 - /**
102 - * Get field options setting
103 - *
104 - * @return array
105 - */
106 - public function get_options_settings() {
107 - $default_options = $this->get_default_option_settings();
108 - $default_text_options = $this->get_default_textarea_option_settings();
109 -
110 - return array_merge( $default_options, $default_text_options );
111 - }
112 -
113 - /**
114 - * Get the field props
115 - *
116 - * @return array
117 - */
118 - public function get_field_props() {
119 - $defaults = $this->default_attributes();
120 - $props = [
121 - 'word_restriction' => '',
122 - 'rows' => 5,
123 - 'cols' => 25,
124 - 'rich' => 'no',
125 - ];
126 -
127 - return array_merge( $defaults, $props );
128 - }
129 -
130 - /**
131 - * Prepare entry
132 - *
133 - * @param $field
134 - *
135 - * @return mixed
136 - */
137 - public function prepare_entry( $field, $args = [] ) {
138 - if( empty( $_POST['_wpnonce'] ) ) {
139 - wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
140 - }
141 -
142 - if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'wpuf_form_add' ) ) {
143 - wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
144 - }
145 -
146 - $args = ! empty( $args ) ? $args : weforms_clean( $_POST );
147 -
148 - return wp_kses_post( $args[$field['name']] );
149 - }
150 -}
1 +<?php
2 +
3 +/**
4 + * Text Field Class
5 + */
6 +class WeForms_Form_Field_Textarea extends WeForms_Field_Contract {
7 +
8 + public function __construct() {
9 + $this->name = __( 'Textarea', 'weforms' );
10 + $this->input_type = 'textarea_field';
11 + $this->icon = 'paragraph';
12 + }
13 +
14 + /**
15 + * Render the text field
16 + *
17 + * @param array $field_settings
18 + * @param int $form_id
19 + *
20 + * @return void
21 + */
22 + public function render( $field_settings, $form_id ) {
23 + $req_class = ( $field_settings['required'] == 'yes' ) ? 'required' : 'rich-editor';
24 + $value = $field_settings['default'];
25 + $textarea_id = $field_settings['name'] ? $field_settings['name'] . '_' . $form_id : 'textarea_'; ?>
26 + <li <?php $this->print_list_attributes( $field_settings ); ?>>
27 + <?php $this->print_label( $field_settings, $form_id ); ?>
28 + <?php if ( in_array( $field_settings['rich'], array( 'yes', 'teeny' ) ) ) { ?>
29 + <div class="wpuf-fields wpuf-rich-validation <?php printf( wp_kses_post( 'wpuf_%s_%s', $field_settings['name'], $form_id ) ); ?>" data-type="rich" data-required="<?php echo esc_attr( $field_settings['required'] ); ?>" data-id="<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>" data-name="<?php echo esc_attr( $field_settings['name'] ); ?>">
30 + <?php } else { ?>
31 + <div class="wpuf-fields">
32 + <?php } ?>
33 +
34 + <?php
35 +
36 + if ( $field_settings['rich'] == 'yes' ) {
37 + $editor_settings = [
38 + 'textarea_rows' => $field_settings['rows'],
39 + 'quicktags' => false,
40 + 'media_buttons' => false,
41 + 'editor_class' => $req_class,
42 + 'textarea_name' => $field_settings['name'],
43 + ];
44 +
45 + $editor_settings = apply_filters( 'wpuf_textarea_editor_args', $editor_settings );
46 + wp_editor( $value, $textarea_id, $editor_settings );
47 + } elseif ( $field_settings['rich'] == 'teeny' ) {
48 + $editor_settings = [
49 + 'textarea_rows' => $field_settings['rows'],
50 + 'quicktags' => false,
51 + 'media_buttons' => false,
52 + 'teeny' => true,
53 + 'editor_class' => $req_class,
54 + 'textarea_name' => $field_settings['name'],
55 + ];
56 +
57 + $editor_settings = apply_filters( 'wpuf_textarea_editor_args', $editor_settings );
58 + wp_editor( $value, $textarea_id, $editor_settings );
59 + } else {
60 + ?>
61 + <textarea
62 + class="textareafield <?php echo ' wpuf_'. esc_attr( $field_settings['name'] ).'_'. esc_attr( $form_id ); ?>"
63 + id="<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>"
64 + name="<?php echo esc_attr( $field_settings['name'] ); ?>"
65 + data-required="<?php echo esc_attr( $field_settings['required'] ) ?>"
66 + data-type="textarea"
67 + placeholder="<?php echo esc_attr( $field_settings['placeholder'] ); ?>"
68 + rows="<?php echo esc_attr($field_settings['rows']); ?>"
69 + cols="<?php echo esc_attr($field_settings['cols']); ?>"
70 + ><?php echo esc_textarea( $value ) ?></textarea>
71 + <span class="wpuf-wordlimit-message wpuf-help"></span>
72 +
73 + <?php
74 + } ?>
75 +
76 + <?php
77 + $this->help_text( $field_settings );
78 +
79 + if ( isset( $field_settings['word_restriction'] ) && $field_settings['word_restriction'] ) {
80 + $this->check_word_restriction_func(
81 + $field_settings['word_restriction'],
82 + $field_settings['rich'],
83 + $field_settings['name'] . '_' . $form_id
84 + );
85 + } ?>
86 + </li>
87 + <?php
88 + }
89 +
90 + /**
91 + * Get field options setting
92 + *
93 + * @return array
94 + */
95 + public function get_options_settings() {
96 + $default_options = $this->get_default_option_settings();
97 + $default_text_options = $this->get_default_textarea_option_settings();
98 +
99 + return array_merge( $default_options, $default_text_options );
100 + }
101 +
102 + /**
103 + * Get the field props
104 + *
105 + * @return array
106 + */
107 + public function get_field_props() {
108 + $defaults = $this->default_attributes();
109 + $props = [
110 + 'word_restriction' => '',
111 + 'rows' => 5,
112 + 'cols' => 25,
113 + 'rich' => 'no',
114 + ];
115 +
116 + return array_merge( $defaults, $props );
117 + }
118 +
119 + /**
120 + * Prepare entry
121 + *
122 + * @param $field
123 + *
124 + * @return mixed
125 + */
126 + public function prepare_entry( $field, $args = [] ) {
127 + if( empty( $_POST['_wpnonce'] ) ) {
128 + wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
129 + }
130 +
131 + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'wpuf_form_add' ) ) {
132 + wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
133 + }
134 +
135 + $args = ! empty( $args ) ? $args : weforms_clean( $_POST );
136 +
137 + return wp_kses_post( $args[$field['name']] );
138 + }
139 +}