/** * Get the title for a saved payment method, like * * <Amex logo> American Express ending in 6666 (expires 10/20) * * @since 4.0.0 * @param SV_WC_Payment_Gateway_Payment_Token $token payment token * @return string saved payment method title */ protected function get_saved_payment_method_title($token) { $image_url = $token->get_image_url(); $last_four = $token->get_last_four(); $type = $token->get_type_full(); if ($image_url) { // format like "<Amex logo image> American Express" $title = sprintf('<img src="%1$s" alt="%2$s" title="%2$s" width="30" height="20" style="width: 30px; height: 20px;" />%3$s', esc_url($image_url), esc_attr__($type, 'woocommerce-plugin-framework'), esc_html__($type, 'woocommerce-plugin-framework')); } else { // missing payment method image, format like "American Express" $title = esc_html__($type, 'woocommerce-plugin-framework'); } // add "ending in XXXX" if available if ($last_four) { /* translators: Placeholders: %s - last four digits of card/account */ $title .= ' ' . sprintf(esc_html__('ending in %s', 'woocommerce-plugin-framework'), $last_four); } // add "(expires MM/YY)" if available if ($token->get_exp_month() && $token->get_exp_year()) { /* translators: Placeholders: %s - expiry date */ $title .= ' ' . sprintf(esc_html__('(expires %s)', 'woocommerce-plugin-framework'), $token->get_exp_date()); } /** * Payment Gateway Payment Form Payment Method Title. * * Filters the text/HTML rendered for a saved payment method, like "Amex ending in 6666". * * @since 4.0.0 * @param string $title * @param \SV_WC_Payment_Gateway_Payment_Token $token * @param \SV_WC_Payment_Gateway_Payment_Form $this payment form instance */ return apply_filters('wc_' . $this->get_gateway()->get_id() . '_payment_form_payment_method_title', $title, $token, $this); }