From e42103b75cca59f7cd360026915e64cbd6128afb Mon Sep 17 00:00:00 2001 From: Francesco Date: Mon, 4 Nov 2024 12:33:50 +0100 Subject: [PATCH] fix: payment method icon alt text (#9648) Co-authored-by: Brett Shumaker --- changelog/fix-payment-method-icon-alt-text | 4 ++++ includes/class-wc-payment-gateway-wcpay.php | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 changelog/fix-payment-method-icon-alt-text diff --git a/changelog/fix-payment-method-icon-alt-text b/changelog/fix-payment-method-icon-alt-text new file mode 100644 index 00000000000..9da0ead5e11 --- /dev/null +++ b/changelog/fix-payment-method-icon-alt-text @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +fix: payment method icon alt text diff --git a/includes/class-wc-payment-gateway-wcpay.php b/includes/class-wc-payment-gateway-wcpay.php index 2a60d9b64e2..2a50957df4d 100644 --- a/includes/class-wc-payment-gateway-wcpay.php +++ b/includes/class-wc-payment-gateway-wcpay.php @@ -3231,12 +3231,18 @@ public function update_fraud_rules_based_on_general_options() { } /** - * The get_icon() method from the WC_Payment_Gateway class wraps the icon URL into a prepared HTML element, but there are situations when this - * element needs to be rendered differently on the UI (e.g. additional styles or `display` property). + * Overriding the base method because the `alt` tag would otherwise output the markup returned by the `get_title()` method in this class - which we don't want. * - * This is why we need a usual getter like this to provide a raw icon URL to the UI, which will render it according to particular requirements. + * @return string + */ + public function get_icon() { + return '' . esc_attr( $this->payment_method->get_title() ) . ' payment method logo'; + } + + /** + * The URL for the current payment method's icon. * - * @return string Returns the payment method icon URL. + * @return string The payment method icon URL. */ public function get_icon_url() { return $this->payment_method->get_icon();