WC_Settings_API::generate_settings_html( array $form_fields = array(), bool $echo = true )
Generate Settings HTML.
Description Description
Generate the HTML for the fields on the "settings" screen.
Parameters Parameters
- $form_fields
-
(Optional) (default: array()) Array of form fields.
Default value: array()
- $echo
-
(Optional) Echo or return.
Default value: true
Return Return
(string) the html for the settings
Source Source
File: includes/abstracts/abstract-wc-settings-api.php
public function generate_settings_html( $form_fields = array(), $echo = true ) {
if ( empty( $form_fields ) ) {
$form_fields = $this->get_form_fields();
}
$html = '';
foreach ( $form_fields as $k => $v ) {
$type = $this->get_field_type( $v );
if ( method_exists( $this, 'generate_' . $type . '_html' ) ) {
$html .= $this->{'generate_' . $type . '_html'}( $k, $v );
} else {
$html .= $this->generate_text_html( $k, $v );
}
}
if ( $echo ) {
echo $html; // WPCS: XSS ok.
} else {
return $html;
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |