From fc59fa5d5b669862a163f40f2dec50f8b51ab9a4 Mon Sep 17 00:00:00 2001 From: Luigi Pulcini Date: Sat, 19 Mar 2022 00:00:31 +0100 Subject: [PATCH] converted action into filter --- .../abstracts/abstract-wc-settings-api.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/woocommerce/includes/abstracts/abstract-wc-settings-api.php b/plugins/woocommerce/includes/abstracts/abstract-wc-settings-api.php index c03698bd32c..258bb2adcb2 100644 --- a/plugins/woocommerce/includes/abstracts/abstract-wc-settings-api.php +++ b/plugins/woocommerce/includes/abstracts/abstract-wc-settings-api.php @@ -329,10 +329,16 @@ abstract class WC_Settings_API { if ( method_exists( $this, 'generate_' . $type . '_html' ) ) { $html .= $this->{'generate_' . $type . '_html'}( $k, $v ); - } elseif ( has_action( 'woocommerce_generate_' . $type . '_html' ) ) { - ob_start(); - do_action( 'woocommerce_generate_' . $type . '_html', $k, $v, $this ); - $html .= ob_get_clean(); + } elseif ( has_filter( 'woocommerce_generate_' . $type . '_html' ) ) { + /** + * Allow the generation of custom field types on the settings screen + * + * @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 ); }