Skip to content

Commit

Permalink
fix: account for more payment gateway assets
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenn00dle committed Dec 17, 2024
1 parent 905a4c7 commit 8ac649d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions includes/class-modal-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,14 +804,17 @@ public static function dequeue_scripts() {
global $wp_scripts, $wp_styles;

$payment_gateways = \WC()->payment_gateways->get_available_payment_gateways();
$allowed_gateway_assets = [];
$allowed_gateway_assets = array_keys( $payment_gateways );
if ( ! empty( $payment_gateways ) ) {
// Payment gateway id doesn't always match the plugin slug, so account for these cases.
foreach ( array_keys( $payment_gateways ) as $gateway ) {
$class = get_class( $payment_gateways[ $gateway ] );
$plugin_file = ( new \ReflectionClass( $class ) )->getFileName();
$plugin_base = \plugin_basename( $plugin_file );
$plugin_slug = explode( '/', $plugin_base )[0];
$allowed_gateway_assets[] = $plugin_slug;
$class = get_class( $payment_gateways[ $gateway ] );
$plugin_file = ( new \ReflectionClass( $class ) )->getFileName();
$plugin_base = \plugin_basename( $plugin_file );
$plugin_slug = explode( '/', $plugin_base )[0];
if ( ! in_array( $plugin_slug, $allowed_gateway_assets, true ) ) {
$allowed_gateway_assets[] = $plugin_slug;
}
}
}

Expand All @@ -831,7 +834,7 @@ public static function dequeue_scripts() {
}
if ( ! empty( $payment_gateways ) ) {
foreach ( $allowed_gateway_assets as $gateway ) {
if ( false !== strpos( $wp_style->src, $gateway ) ) {
if ( false !== strpos( $handle, $gateway ) || false !== strpos( $wp_script->src, $gateway ) ) {
$allowed = true;
break;
}
Expand Down

0 comments on commit 8ac649d

Please sign in to comment.