WC_Settings_API::generate_settings_html
Generate Settings HTML.
Generate the HTML for the fields on the "settings" screen.
Метод класса: WC_Settings_API{}
Хуки из метода
Возвращает
Строку. the html for the settings
Использование
$WC_Settings_API = new WC_Settings_API(); $WC_Settings_API->generate_settings_html( $form_fields, $echo );
- $form_fields(массив)
- .
По умолчанию:array()) Array of form fields - $echo(true|false)
- Echo or return.
По умолчанию:true
Список изменений
| С версии 1.0.0 | Введена. |
Код WC_Settings_API::generate_settings_html() WC Settings API::generate settings html WC 10.7.0
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 );
} elseif ( has_filter( 'woocommerce_generate_' . $type . '_html' ) ) {
/**
* Allow the generation of custom field types on the settings screen.
*
* The dynamic portion of the hook name refers to the slug of the custom field type.
* For instance, to introduce a new field type `fancy_lazy_dropdown` you would use
* the hook `woocommerce_generate_fancy_lazy_dropdown_html`.
*
* @since 6.5.0
*
* @param string $field_html The markup of the field being generated (initiated as an empty string).
* @param string $key The key of the field.
* @param array $data The attributes of the field as an associative array.
* @param object $wc_settings The current WC_Settings_API object.
*/
$html .= apply_filters( 'woocommerce_generate_' . $type . '_html', '', $k, $v, $this );
} else {
$html .= $this->generate_text_html( $k, $v );
}
}
if ( $echo ) {
echo $html; // WPCS: XSS ok.
} else {
return $html;
}
}