' . esc_html( $message ) . '
' . $after . '' . esc_html( $message ) . '
'; if ( array() !== $errors ) { $html .= '' . esc_html( $field['help'] ) . '
' : ''; $fault = '' !== $error ? '' . esc_html( $error ) . '
' : ''; /** * Filters extra attributes of the element around a field (name => value, escaped here). * * @param array $attributes Attributes. * @param array $field Field. */ $open = '' . esc_html( $field['help'] ) . '
' : '' ) . '' . $help . $fault . ''; } $html = $open . '' . $help; if ( 'textarea' === $type ) { $html .= ''; } elseif ( 'select' === $type ) { $html .= ''; } elseif ( 'range' === $type ) { $min = '' !== $field['min'] ? $field['min'] : '0'; $max = '' !== $field['max'] ? $field['max'] : '10'; $step = '' !== $field['step'] ? $field['step'] : '1'; $start = '' !== $value ? $value : $min; $html .= ''; } else { $input_type = in_array( $type, array( 'number', 'url' ), true ) ? 'text' : $type; $autocomplete = array( 'email' => 'email', 'tel' => 'tel', 'url' => 'url', ); $html .= ''; } return $html . $fault . ''; } /** * Attributes as markup. Names are limited to lowercase letters, digits and dashes. * * @param mixed $attributes Name => value. */ private static function attributes( $attributes ): string { $html = ''; foreach ( is_array( $attributes ) ? $attributes : array() as $name => $value ) { // Event handlers (on...) are never accepted; scripts belong in enqueued files. if ( 1 === preg_match( '/^[a-z][a-z0-9-]*$/', (string) $name ) && 0 !== strpos( (string) $name, 'on' ) && is_scalar( $value ) ) { $html .= ' ' . $name . '="' . esc_attr( (string) $value ) . '"'; } } return $html; } }