@automattic/newspack-blocks 3.0.3 → 3.0.4-alpha.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.
@@ -51,6 +51,8 @@ final class Modal_Checkout {
51
51
  add_filter( 'wcs_place_subscription_order_text', [ __CLASS__, 'order_button_text' ], 1 );
52
52
  add_filter( 'woocommerce_order_button_text', [ __CLASS__, 'order_button_text' ] );
53
53
  add_filter( 'option_woocommerce_subscriptions_order_button_text', [ __CLASS__, 'order_button_text' ] );
54
+ add_action( 'option_woocommerce_default_customer_address', [ __CLASS__, 'ensure_base_default_customer_address' ] );
55
+ add_action( 'default_option_woocommerce_default_customer_address', [ __CLASS__, 'ensure_base_default_customer_address' ] );
54
56
 
55
57
  /** Custom handling for registered users. */
56
58
  add_filter( 'woocommerce_checkout_customer_id', [ __CLASS__, 'associate_existing_user' ] );
@@ -996,6 +998,46 @@ final class Modal_Checkout {
996
998
  return $text;
997
999
  }
998
1000
 
1001
+ /**
1002
+ * Force option for base country for new customers if unset and billing country optional while state is required
1003
+ * unless the NEWSPACK_PREVENT_FORCE_BASE_DEFAULT_CUSTOMER_ADDRESS constant is set.
1004
+ *
1005
+ * If this option is empty AND billing state is set as a required field AND billing country is not,
1006
+ * validation of the state value will fail during modal checkout.
1007
+ *
1008
+ * See Default Customer Location in: https://woo.com/document/configuring-woocommerce-settings/#general-options
1009
+ *
1010
+ * @param string $option_value The value of the default customer address option.
1011
+ *
1012
+ * @return string Option value.
1013
+ */
1014
+ public static function ensure_base_default_customer_address( $option_value ) {
1015
+ // If the option is set, we're good.
1016
+ if ( ! empty( $option_value ) ) {
1017
+ return $option_value;
1018
+ }
1019
+
1020
+ // Only in modal checkout.
1021
+ if ( ! self::is_modal_checkout() ) {
1022
+ return $option_value;
1023
+ }
1024
+
1025
+ // Escape hatch in case we want the standard behavior even in modal checkout.
1026
+ if ( defined( 'NEWSPACK_PREVENT_FORCE_BASE_DEFAULT_CUSTOMER_ADDRESS' ) && NEWSPACK_PREVENT_FORCE_BASE_DEFAULT_CUSTOMER_ADDRESS ) {
1027
+ return $option_value;
1028
+ }
1029
+
1030
+ // If billing state is required but billing country is not, we need to ensure a default location is set.
1031
+ if ( defined( '\Newspack\Donations::DONATION_BILLING_FIELDS_OPTION' ) ) {
1032
+ $billing_fields = get_option( \Newspack\Donations::DONATION_BILLING_FIELDS_OPTION, [] );
1033
+ if ( ! in_array( 'billing_country', $billing_fields, true ) && in_array( 'billing_state', $billing_fields, true ) ) {
1034
+ return 'base';
1035
+ }
1036
+ }
1037
+
1038
+ return $option_value;
1039
+ }
1040
+
999
1041
  /**
1000
1042
  * If a reader tries to make a purchase with an email address that
1001
1043
  * has been previously registered, automatically associate the transaction
@@ -7,7 +7,7 @@
7
7
  * Author URI: https://newspack.com/
8
8
  * Text Domain: newspack-blocks
9
9
  * Domain Path: /languages
10
- * Version: 3.0.3
10
+ * Version: 3.0.4-alpha.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', '3.0.3' );
18
+ define( 'NEWSPACK_BLOCKS__VERSION', '3.0.4-alpha.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": "3.0.3",
3
+ "version": "3.0.4-alpha.1",
4
4
  "author": "Automattic",
5
5
  "devDependencies": {
6
6
  "@rushstack/eslint-patch": "^1.7.2",
@@ -10,7 +10,7 @@
10
10
  "@types/lodash.debounce": "^4.0.9",
11
11
  "eslint": "^7.32.0",
12
12
  "fetch-mock-jest": "^1.5.1",
13
- "html-entities": "^2.4.0",
13
+ "html-entities": "^2.5.2",
14
14
  "identity-obj-proxy": "^3.0.0",
15
15
  "lint-staged": "^15.2.2",
16
16
  "newspack-scripts": "^5.3.0",
@@ -250,8 +250,8 @@ class Edit extends Component {
250
250
  <Fragment>
251
251
  { autoplay && (
252
252
  <Fragment>
253
- <button ref={ this.btnPauseRef } />
254
- <button ref={ this.btnPlayRef } />
253
+ <button className="swiper-button swiper-button-pause" ref={ this.btnPauseRef } />
254
+ <button className="swiper-button swiper-button-play" ref={ this.btnPlayRef } />
255
255
  </Fragment>
256
256
  ) }
257
257
  <div className="swiper-wrapper">
@@ -339,8 +339,8 @@ class Edit extends Component {
339
339
  </div>
340
340
  { ! hasNoPosts && ! hasOnePost && (
341
341
  <>
342
- <button className="swiper-button-prev" ref={ this.btnPrevRef } />
343
- <button className="swiper-button-next" ref={ this.btnNextRef } />
342
+ <button className="swiper-button-prev swiper-button" ref={ this.btnPrevRef } />
343
+ <button className="swiper-button-next swiper-button" ref={ this.btnNextRef } />
344
344
  <div
345
345
  className="swiper-pagination swiper-pagination-bullets"
346
346
  ref={ this.paginationRef }
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
22
22
 
23
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
24
 
25
- return ComposerAutoloaderInit90b7aab6d3fee0e0d25f57e0e59b1d50::getLoader();
25
+ return ComposerAutoloaderInita79acdd5c7d41d18c52fcb779f35c2e9::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInit90b7aab6d3fee0e0d25f57e0e59b1d50
5
+ class ComposerAutoloaderInita79acdd5c7d41d18c52fcb779f35c2e9
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,12 +22,12 @@ class ComposerAutoloaderInit90b7aab6d3fee0e0d25f57e0e59b1d50
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInit90b7aab6d3fee0e0d25f57e0e59b1d50', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInita79acdd5c7d41d18c52fcb779f35c2e9', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27
- spl_autoload_unregister(array('ComposerAutoloaderInit90b7aab6d3fee0e0d25f57e0e59b1d50', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInita79acdd5c7d41d18c52fcb779f35c2e9', 'loadClassLoader'));
28
28
 
29
29
  require __DIR__ . '/autoload_static.php';
30
- call_user_func(\Composer\Autoload\ComposerStaticInit90b7aab6d3fee0e0d25f57e0e59b1d50::getInitializer($loader));
30
+ call_user_func(\Composer\Autoload\ComposerStaticInita79acdd5c7d41d18c52fcb779f35c2e9::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 ComposerStaticInit90b7aab6d3fee0e0d25f57e0e59b1d50
7
+ class ComposerStaticInita79acdd5c7d41d18c52fcb779f35c2e9
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInit90b7aab6d3fee0e0d25f57e0e59b1d50
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInit90b7aab6d3fee0e0d25f57e0e59b1d50::$classMap;
16
+ $loader->classMap = ComposerStaticInita79acdd5c7d41d18c52fcb779f35c2e9::$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' => 'd3fa078a30c1abed3ffdc4387ead1ec55798bc23',
6
+ 'reference' => '55968234f9b5a61f8d5bd0a494f3c45eaa12bc5b',
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' => 'd3fa078a30c1abed3ffdc4387ead1ec55798bc23',
16
+ 'reference' => '55968234f9b5a61f8d5bd0a494f3c45eaa12bc5b',
17
17
  'type' => 'wordpress-plugin',
18
18
  'install_path' => __DIR__ . '/../../',
19
19
  'aliases' => array(),