woocommerce_generate_(type)_html filter-hookWC 6.5.0

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.

Usage

add_filter( 'woocommerce_generate_(type)_html', 'wp_kama_woocommerce_generate_type_html_filter', 10, 4 );

/**
 * Function for `woocommerce_generate_(type)_html` filter-hook.
 * 
 * @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.
 *
 * @return string
 */
function wp_kama_woocommerce_generate_type_html_filter( $field_html, $key, $data, $wc_settings ){

	// filter...
	return $field_html;
}
$field_html(string)
The markup of the field being generated (initiated as an empty string).
$key(string)
The key of the field.
$data(array)
The attributes of the field as an associative array.
$wc_settings(object)
The current WC_Settings_API object.

Changelog

Since 6.5.0 Introduced.

Where the hook is called

WC_Settings_API::generate_settings_html()
woocommerce_generate_(type)_html
woocommerce/includes/abstracts/abstract-wc-settings-api.php 364
$html .= apply_filters( 'woocommerce_generate_' . $type . '_html', '', $k, $v, $this );

Where the hook is used in WooCommerce

Usage not found.