register_block_from_metadata( 'email' ); } public function render( $atts ) { if ( ! $this->allow_render_now( $atts ) ) { return ''; } $label = isset( $atts['label'] ) ? $atts['label'] : 'Email'; $name = isset( $atts['name'] ) ? $atts['name'] : 'email'; $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_attr( $atts['defaultValue'] ) : ''; $acomp = isset( $atts['autocomplete'] ) && $atts['autocomplete'] !== '' ? 'autocomplete="'. esc_attr( $atts['autocomplete'] ) .'"' : 'autocomplete="email"'; $inputMode = isset( $atts['inputMode'] ) && $atts['inputMode'] !== '' ? 'inputmode="'. esc_attr( $atts['inputMode'] ) .'"' : 'inputmode="email"'; $multiple = ! empty( $atts['multiple'] ) ? 'multiple' : ''; $minLen = isset( $atts['minLength'] ) && is_numeric( $atts['minLength'] ) ? 'minlength="'. intval( $atts['minLength'] ) .'"' : ''; $maxLen = isset( $atts['maxLength'] ) && is_numeric( $atts['maxLength'] ) ? 'maxlength="'. intval( $atts['maxLength'] ) .'"' : ''; $pattern = isset( $atts['pattern'] ) && $atts['pattern'] !== '' ? 'pattern="'. esc_attr( $atts['pattern'] ) .'"' : ''; $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 ); $class = $this->build_field_wrapper_class( 'email', $atts ); $style_rules = $this->get_field_wrapper_style_rules( $atts ); $prefix = isset( $atts['prefix'] ) ? esc_html( $atts['prefix'] ) : ''; $suffix = isset( $atts['suffix'] ) ? esc_html( $atts['suffix'] ) : ''; $help_context = $this->get_field_help_context( $atts, $name ); $ariaLabel = $this->get_field_aria_label_attr( $atts ); $ariaDesc = $help_context['aria_describedby']; $id = 'stacklar-email-' . $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( ( $prefix !== '' ? ''. $prefix .'' : '' ) . '' . ( $suffix !== '' ? ''. $suffix .'' : '' ) ); $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' => 'input', ) ); $html .= $contentHtml; $html .= $this->render_wrapper_close(); return $html; } }