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


Top ↑

Return Return

(string) the html for the settings


Top ↑

Source Source

File: includes/abstracts/abstract-wc-settings-api.php

319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
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;
    }
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.