register_block_from_metadata( 'textarea' ); } public function render( $atts ) { if ( ! $this->allow_render_now( $atts ) ) { return ''; } $label = isset( $atts['label'] ) ? $atts['label'] : 'Message'; $name = isset( $atts['name'] ) ? $atts['name'] : 'message'; $name = sanitize_key( $name ); $ph = isset( $atts['placeholder'] ) ? esc_attr( $atts['placeholder'] ) : ''; $required = ! empty( $atts['required'] ); $reqAttr = $this->get_field_boolean_attr( $atts, 'required', 'required' ); $defVal = isset( $atts['defaultValue'] ) ? esc_textarea( $atts['defaultValue'] ) : ''; $acomp = isset( $atts['autocomplete'] ) && $atts['autocomplete'] !== '' ? 'autocomplete="'. esc_attr( $atts['autocomplete'] ) .'"' : ''; $minLen = isset( $atts['minLength'] ) && is_numeric( $atts['minLength'] ) ? 'minlength="'. intval( $atts['minLength'] ) .'"' : ''; $maxLen = isset( $atts['maxLength'] ) && is_numeric( $atts['maxLength'] ) ? 'maxlength="'. intval( $atts['maxLength'] ) .'"' : ''; $disabled= $this->get_field_boolean_attr( $atts, 'disabled', 'disabled' ); $readonly= $this->get_field_boolean_attr( $atts, 'readOnly', 'readonly' ); $labelPos= $this->get_field_label_position( $atts ); $rows = isset( $atts['rows'] ) && intval( $atts['rows'] ) > 0 ? intval( $atts['rows'] ) : 4; $class = $this->build_field_wrapper_class( 'textarea', $atts ); $style_rules = $this->get_field_wrapper_style_rules( $atts ); $help_context = $this->get_field_help_context( $atts, $name ); $ariaLabel = $this->get_field_aria_label_attr( $atts ); $ariaDesc = $help_context['aria_describedby']; $id = 'stacklar-textarea-' . $name . '-' . wp_generate_password( 6, false, false ); $input_rules = $this->get_input_style_rules( $atts ); $inputStyle = $this->build_style_attribute( $input_rules ); $labelHtml = $this->render_field_label( $id, $label, $required, $labelPos, $atts ); $inputHtml = $this->render_input_wrap( '' ); $contentHtml = $this->render_field_content( $labelHtml, $inputHtml, $labelPos, $help_context['help_html'] ); $html = $this->render_wrapper_open( $atts, $class, $style_rules, array( 'label' => '> label, .stacklar__inline > label', 'input' => 'textarea', ) ); $html .= $contentHtml; $html .= $this->render_wrapper_close(); return $html; } }