Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

44 use ideal svg images from pronamicwp pay logos #45

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"pronamic/wp-gravityforms-nl": "^3.0",
"pronamic/wp-money": "^2.4",
"pronamic/wp-number": "^1.3",
"pronamic/wp-pay-logos": "^2.2",
"woocommerce/action-scheduler": "^3.7",
"wp-pay-gateways/mollie": "^4.10",
"wp-pay/core": "dev-main as 4.18"
Expand Down
50 changes: 22 additions & 28 deletions src/IssuersField.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Pronamic\WordPress\Pay\Fields\IDealIssuerSelectField;
use Pronamic\WordPress\Pay\Core\PaymentMethods;
use Pronamic\WordPress\Pay\Plugin;
use Pronamic\WpPayLogos\ImageService;

/**
* Title: WordPress pay extension Gravity Forms issuers field
Expand Down Expand Up @@ -294,19 +295,25 @@
// Icon file and size.
switch ( $this->pronamicPayDisplayMode ) {
case 'icons-24':
$dimensions = [ 24, 24 ];
$display_width = 24;

Check warning on line 298 in src/IssuersField.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 4 spaces
$display_height = 24;

Check warning on line 299 in src/IssuersField.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

Equals sign not aligned with surrounding assignments; expected 2 spaces but found 3 spaces
$image_variation = 'icon-512x512.svg';

break;
case 'icons-64':
$dimensions = [ 64, 64 ];
$display_width = 64;

Check warning on line 304 in src/IssuersField.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 4 spaces
$display_height = 64;

Check warning on line 305 in src/IssuersField.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

Equals sign not aligned with surrounding assignments; expected 2 spaces but found 3 spaces
$image_variation = 'icon-512x512.svg';

break;
case 'icons-125':
default:
$dimensions = [ 125, 60 ];
$display_width = 125;

Check warning on line 311 in src/IssuersField.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 4 spaces
$display_height = 70;

Check warning on line 312 in src/IssuersField.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

Equals sign not aligned with surrounding assignments; expected 2 spaces but found 3 spaces
$image_variation = '640x360.svg';
}

$images_path = plugin_dir_path( Plugin::$file ) . 'images/';
$image_service = new ImageService();

// Loop issuers.
foreach ( $this->choices as $choice ) {
Expand All @@ -322,29 +329,21 @@
$issuer = 'test';
}

if ( ! is_dir( $images_path . $issuer ) && is_dir( $images_path . $issuer . '-bank' ) ) {
$issuer .= '-bank';
}

$icon_path = sprintf(
'%s/icon-%s.png',
$issuer,
implode( 'x', $dimensions )
);

// Radio input.
$label_content = sprintf( '<span>%s</span>', esc_html( $choice['text'] ) );

if ( file_exists( plugin_dir_path( Plugin::$file ) . 'images/' . $icon_path ) ) {
$icon_url = plugins_url( 'images/' . $icon_path, Plugin::$file );
$image_path = $image_service->get_path( "ideal-issuers/$issuer/ideal-issuer-$issuer-$image_variation" );

$label_content = sprintf(
'<img src="%2$s" alt="%1$s" srcset="%3$s 2x, %4$s 3x, %5$s 4x" /><span>%1$s</span>',
esc_html( $choice['text'] ),
esc_url( $icon_url ),
esc_url( str_replace( '.png', '@2x.png', $icon_url ) ),
esc_url( str_replace( '.png', '@3x.png', $icon_url ) ),
esc_url( str_replace( '.png', '@4x.png', $icon_url ) )
if ( file_exists( $image_path ) ) {
$image_url = \plugins_url( \basename( $image_path ), $image_path );

$label_content = \sprintf(
'<img src="%s" alt="%s" width="%s" height="%s" /><span>%s</span>',
\esc_url( $image_url ),
\esc_attr( $choice['text'] ),
\esc_attr( $display_width ),
\esc_attr( $display_height ),
\esc_html( $choice['text'] )
);
}

Expand Down Expand Up @@ -373,9 +372,6 @@

.gform_wrapper <?php echo esc_html( $field_css_id ); ?> .gfield_radio li img {
display: block;

width: <?php echo esc_html( $dimensions[0] ); ?>px;
height: <?php echo esc_html( $dimensions[1] ); ?>px;
}

.gform_wrapper <?php echo esc_html( $field_css_id ); ?> .gfield_radio li label {
Expand Down Expand Up @@ -499,8 +495,6 @@
.gform_wrapper <?php echo esc_html( $field_css_id ); ?> .gfield_radio li label {
display: block;

height: 68px;

padding: 3px;

border: 1px solid #bbb;
Expand Down
Loading