@automattic/newspack-blocks 4.14.0 → 4.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [4.14.1](https://github.com/Automattic/newspack-blocks/compare/v4.14.0...v4.14.1) (2025-07-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update supported gateway check to improve accuracy ([#2135](https://github.com/Automattic/newspack-blocks/issues/2135)) ([bca370e](https://github.com/Automattic/newspack-blocks/commit/bca370e64ecf0003e4e83213e393a9389518fef4))
7
+
1
8
  # [4.14.0](https://github.com/Automattic/newspack-blocks/compare/v4.13.1...v4.14.0) (2025-06-30)
2
9
 
3
10
 
@@ -125,6 +125,13 @@ final class Modal_Checkout {
125
125
  'woocommerce_payments',
126
126
  ];
127
127
 
128
+ /**
129
+ * Cached result of payment gateway check.
130
+ *
131
+ * @var bool|null
132
+ */
133
+ private static $payment_gateway_check_result = null;
134
+
128
135
  /**
129
136
  * Initialize hooks.
130
137
  */
@@ -136,6 +143,9 @@ final class Modal_Checkout {
136
143
  add_action( 'wp_ajax_abandon_modal_checkout', [ __CLASS__, 'process_abandon_checkout' ] );
137
144
  add_action( 'wp_ajax_nopriv_abandon_modal_checkout', [ __CLASS__, 'process_abandon_checkout' ] );
138
145
 
146
+ // Perform payment gateway check after WooCommerce is fully initialized.
147
+ add_action( 'woocommerce_init', [ __CLASS__, 'has_unsupported_payment_gateway' ] );
148
+
139
149
  add_filter( 'wp_redirect', [ __CLASS__, 'pass_url_param_on_redirect' ] );
140
150
  add_filter( 'woocommerce_cart_product_cannot_be_purchased_message', [ __CLASS__, 'woocommerce_cart_product_cannot_be_purchased_message' ], 10, 2 );
141
151
  add_filter( 'woocommerce_add_error', [ __CLASS__, 'hide_expiry_message_shop_link' ] );
@@ -269,16 +279,38 @@ final class Modal_Checkout {
269
279
  * @return boolean
270
280
  */
271
281
  public static function has_unsupported_payment_gateway() {
272
- $supported_gateways = self::get_supported_payment_gateways();
273
- $available_gateways = function_exists( 'WC' ) ? \WC()->payment_gateways->get_available_payment_gateways() : [];
274
- $unsupported_payment_gateway = false;
282
+ // Return saved result if available.
283
+ if ( null !== self::$payment_gateway_check_result ) {
284
+ return self::$payment_gateway_check_result;
285
+ }
286
+
287
+ // Only perform check if WooCommerce is fully initialized.
288
+ if ( ! function_exists( 'WC' ) || ! WC() || ! WC()->payment_gateways ) {
289
+ return false;
290
+ }
291
+
292
+ $supported_gateways = self::get_supported_payment_gateways();
293
+ $available_gateways = WC()->payment_gateways->get_available_payment_gateways();
294
+
295
+ // If no gateways are available yet, assume that they are not supported.
296
+ if ( empty( $available_gateways ) ) {
297
+ return true;
298
+ }
299
+
300
+ $unsupported_gateways = [];
275
301
  foreach ( $available_gateways as $id => $gateway ) {
276
302
  if ( ! in_array( $id, $supported_gateways, true ) ) {
277
- $unsupported_payment_gateway = true;
278
- break;
303
+ $unsupported_gateways[] = $id;
279
304
  }
280
305
  }
281
- return $unsupported_payment_gateway;
306
+
307
+ if ( ! empty( $unsupported_gateways ) ) {
308
+ self::$payment_gateway_check_result = true;
309
+ return true;
310
+ }
311
+
312
+ self::$payment_gateway_check_result = false;
313
+ return false;
282
314
  }
283
315
 
284
316
  /**
@@ -7,7 +7,7 @@
7
7
  * Author URI: https://newspack.com/
8
8
  * Text Domain: newspack-blocks
9
9
  * Domain Path: /languages
10
- * Version: 4.14.0
10
+ * Version: 4.14.1
11
11
  *
12
12
  * @package Newspack_Blocks
13
13
  */
@@ -15,7 +15,7 @@
15
15
  define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
16
16
  define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
17
17
  define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
18
- define( 'NEWSPACK_BLOCKS__VERSION', '4.14.0' );
18
+ define( 'NEWSPACK_BLOCKS__VERSION', '4.14.1' );
19
19
 
20
20
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
21
21
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/newspack-blocks",
3
- "version": "4.14.0",
3
+ "version": "4.14.1",
4
4
  "author": "Automattic",
5
5
  "devDependencies": {
6
6
  "@rushstack/eslint-patch": "^1.11.0",
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
22
22
 
23
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
24
 
25
- return ComposerAutoloaderInita8e97776bb525c564ca0ab59f24065c8::getLoader();
25
+ return ComposerAutoloaderInit7395ea5d9613c557e99a3d5567d4cb9d::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInita8e97776bb525c564ca0ab59f24065c8
5
+ class ComposerAutoloaderInit7395ea5d9613c557e99a3d5567d4cb9d
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,12 +22,12 @@ class ComposerAutoloaderInita8e97776bb525c564ca0ab59f24065c8
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInita8e97776bb525c564ca0ab59f24065c8', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInit7395ea5d9613c557e99a3d5567d4cb9d', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27
- spl_autoload_unregister(array('ComposerAutoloaderInita8e97776bb525c564ca0ab59f24065c8', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInit7395ea5d9613c557e99a3d5567d4cb9d', 'loadClassLoader'));
28
28
 
29
29
  require __DIR__ . '/autoload_static.php';
30
- call_user_func(\Composer\Autoload\ComposerStaticInita8e97776bb525c564ca0ab59f24065c8::getInitializer($loader));
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit7395ea5d9613c557e99a3d5567d4cb9d::getInitializer($loader));
31
31
 
32
32
  $loader->register(true);
33
33
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  namespace Composer\Autoload;
6
6
 
7
- class ComposerStaticInita8e97776bb525c564ca0ab59f24065c8
7
+ class ComposerStaticInit7395ea5d9613c557e99a3d5567d4cb9d
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInita8e97776bb525c564ca0ab59f24065c8
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInita8e97776bb525c564ca0ab59f24065c8::$classMap;
16
+ $loader->classMap = ComposerStaticInit7395ea5d9613c557e99a3d5567d4cb9d::$classMap;
17
17
 
18
18
  }, null, ClassLoader::class);
19
19
  }
@@ -3,7 +3,7 @@
3
3
  'name' => 'automattic/newspack-blocks',
4
4
  'pretty_version' => 'dev-trunk',
5
5
  'version' => 'dev-trunk',
6
- 'reference' => '199853bd8a399adb0d80fdeb841a96c1d673ccec',
6
+ 'reference' => 'bca370e64ecf0003e4e83213e393a9389518fef4',
7
7
  'type' => 'wordpress-plugin',
8
8
  'install_path' => __DIR__ . '/../../',
9
9
  'aliases' => array(),
@@ -13,7 +13,7 @@
13
13
  'automattic/newspack-blocks' => array(
14
14
  'pretty_version' => 'dev-trunk',
15
15
  'version' => 'dev-trunk',
16
- 'reference' => '199853bd8a399adb0d80fdeb841a96c1d673ccec',
16
+ 'reference' => 'bca370e64ecf0003e4e83213e393a9389518fef4',
17
17
  'type' => 'wordpress-plugin',
18
18
  'install_path' => __DIR__ . '/../../',
19
19
  'aliases' => array(),