Skip to content

Commit

Permalink
fix: correctly check gateway styles
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenn00dle committed Dec 19, 2024
1 parent 1b3a045 commit 93392a5
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions includes/class-modal-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,20 +827,12 @@ public static function dequeue_scripts() {
$allowed_styles = apply_filters( 'newspack_blocks_modal_checkout_allowed_styles', self::$allowed_styles );
foreach ( $wp_styles->registered as $handle => $wp_style ) {
$allowed = false;
foreach ( $allowed_styles as $allowed_style ) {
if ( 0 === strpos( $handle, $allowed_style ) ) {
foreach ( array_merge( $allowed_styles, $allowed_gateway_assets ) as $allowed_style ) {
if ( 0 === strpos( $handle, $allowed_style ) || false !== strpos( $wp_style->src, $allowed_style ) ) {
$allowed = true;
break;
}
}
if ( ! empty( $payment_gateways ) ) {
foreach ( $allowed_gateway_assets as $gateway ) {
if ( false !== strpos( $handle, $gateway ) || false !== strpos( $wp_script->src, $gateway ) ) {
$allowed = true;
break;
}
}
}
if ( ! $allowed ) {
wp_dequeue_style( $handle );
}
Expand All @@ -854,14 +846,8 @@ public static function dequeue_scripts() {
$allowed_scripts = apply_filters( 'newspack_blocks_modal_checkout_allowed_scripts', self::$allowed_scripts );
foreach ( $wp_scripts->registered as $handle => $wp_script ) {
$allowed = false;
foreach ( $allowed_scripts as $allowed_script ) {
if ( 0 === strpos( $handle, $allowed_script ) ) {
$allowed = true;
break;
}
}
foreach ( $allowed_gateway_assets as $gateway ) {
if ( false !== strpos( $wp_script->src, $gateway ) ) {
foreach ( array_merge( $allowed_scripts, $allowed_gateway_assets ) as $allowed_script ) {
if ( 0 === strpos( $handle, $allowed_script ) || false !== strpos( $wp_script->src, $allowed_script ) ) {
$allowed = true;
break;
}
Expand Down

0 comments on commit 93392a5

Please sign in to comment.