Skip to content

Commit

Permalink
Merge pull request #210 from woocommerce/PCP-180-use-get_icon-for-cre…
Browse files Browse the repository at this point in the history
…dit-card-gat

Use `get_icon` to display credit card gateway icons
  • Loading branch information
Dinamiko authored Aug 4, 2021
2 parents ef4bdc7 + 00cc013 commit e158613
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,35 +236,31 @@ public function replace_credit_card_cvv_label( string $translation, string $text
}

/**
* Returns the title of the gateway.
* Returns the icons of the gateway.
*
* @return string
*/
public function get_title() {
public function get_icon() {
$icon = parent::get_icon();

//phpcs:disable WordPress.Security.NonceVerification.Recommended
if ( ! is_checkout() || ( is_ajax() && isset( $_GET['wc-ajax'] ) && 'update_order_review' !== $_GET['wc-ajax'] ) ) {
return parent::get_title();
}
//phpcs:enable WordPress.Security.NonceVerification.Recommended
$title = parent::get_title();
$icons = $this->config->has( 'card_icons' ) ? (array) $this->config->get( 'card_icons' ) : array();
if ( empty( $icons ) ) {
return $title;
return $icon;
}

$title_options = $this->card_labels();
$images = array_map(
function ( string $type ) use ( $title_options ): string {
return '<img
title="' . esc_attr( $title_options[ $type ] ) . '"
src="' . esc_url( $this->module_url ) . '/assets/images/' . esc_attr( $type ) . '.svg"
src="' . esc_url( $this->module_url ) . 'assets/images/' . esc_attr( $type ) . '.svg"
class="ppcp-card-icon"
> ';
},
$icons
);
return $title . implode( '', $images );

return implode( '', $images );
}

/**
Expand Down

0 comments on commit e158613

Please sign in to comment.