type = $atts['type']; // Input type: text, email, password, button.
$this->id = $id; // Id
$this->name = $name; // Name
$this->label = isset( $atts['label'] ) && !empty( $atts['label'] ) ? $atts['label'] : ''; // Label
$this->placeholder = isset( $atts['placeholder'] ) && !empty( $atts['placeholder'] ) ? $atts['placeholder'] : ''; // Placeholder
$this->default = isset( $atts['default'] ) && !empty( $atts['default'] ) ? $atts['default'] : ''; // Default
$this->value = $value; // Value
}
/**
* Output admin form field
*
* @since 1.0.0
* @return string Field output
*/
public function field() {
$html = '';
if ( empty( $this->name ) ) {
return $html;
}
if ( $this->label ) {
$html .= '';
}
// If value NULL (only first time before save) set default value if passed
$value = NULL === $this->value && '' !== $this->default ? $this->default : $this->value;
$html .= 'id ) . '" '
. 'name="' . esc_attr( $this->name ) . '" '
. 'type="' . esc_attr( $this->type ) . '" '
. 'value="' . esc_attr( $value ) . '" ';
if ( !empty( $this->placeholder ) ) {
$html .= 'placeholder="' . esc_attr( $this->placeholder ) . '" ';
}
$html .= '/>';
return $html;
}
}