Skip to content

Commit

Permalink
Remove unused method Core\Util::input_fields_html().
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdsteege committed Dec 7, 2022
1 parent 88844a1 commit 608597b
Showing 1 changed file with 0 additions and 63 deletions.
63 changes: 0 additions & 63 deletions src/Core/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,69 +260,6 @@ public static function get_remote_address() {
return null;
}

/**
* Convert input fields array to HTML.
*
* @param array $fields Array with fields data to convert to HTML.
*
* @return string
*/
public static function input_fields_html( array $fields ) {
$html = '';

foreach ( $fields as $field ) {
if ( ! isset( $field['type'], $field['name'] ) ) {
continue;
}

$field = \wp_parse_args(
$field,
[
'id' => $field['name'],
'type' => 'text',
'value' => ( \filter_has_var( INPUT_POST, $field['name'] ) ? \filter_input( INPUT_POST, $field['name'], FILTER_SANITIZE_STRING ) : null ),
'required' => false,
'max' => null,
]
);

// Field label.
$html .= sprintf(
'<label for="%s">%s</label> ',
esc_attr( $field['id'] ),
$field['label']
);

switch ( $field['type'] ) {
case 'select':
$html .= sprintf(
'<select id="%s" name="%s" %s>%s</select>',
esc_attr( $field['id'] ),
esc_attr( $field['name'] ),
( $field['required'] ? 'required' : null ),
Pay_Util::select_options_grouped( $field['choices'] )
);

break;
default:
$attributes = [
'type' => $field['type'],
'id' => $field['id'],
'name' => $field['name'],
'value' => $field['value'],
'max' => $field['max'],
'required' => $field['required'],
];

$html .= sprintf( '<input %s>', Pay_Util::array_to_html_attributes( $attributes ) );

break;
}
}

return $html;
}

/**
* Method exists
*
Expand Down

0 comments on commit 608597b

Please sign in to comment.