WooCommerce Square - Version 2.1.3

Version Description

  • 2020.04.30 =
  • Fix - Persistent caching of locations to prevent unnecessary refetching and rate limiting.
Download this release

Release Info

Developer automattic
Plugin Icon 128x128 WooCommerce Square
Version 2.1.3
Comparing to
See all releases

Code changes from version 2.1.2 to 2.1.3

includes/Plugin.php CHANGED
@@ -42,7 +42,7 @@ class Plugin extends Framework\SV_WC_Payment_Gateway_Plugin {
42
 
43
 
44
  /** plugin version number */
45
- const VERSION = '2.1.2';
46
 
47
  /** plugin ID */
48
  const PLUGIN_ID = 'square';
42
 
43
 
44
  /** plugin version number */
45
+ const VERSION = '2.1.3';
46
 
47
  /** plugin ID */
48
  const PLUGIN_ID = 'square';
includes/Settings.php CHANGED
@@ -609,6 +609,18 @@ class Settings extends \WC_Settings_API {
609
  */
610
  public function get_locations() {
611
 
 
 
 
 
 
 
 
 
 
 
 
 
612
  if ( ! is_array( $this->locations ) ) {
613
 
614
  $this->locations = [];
@@ -617,6 +629,7 @@ class Settings extends \WC_Settings_API {
617
 
618
  // cache the locations returned so they can be used elsewhere
619
  $this->locations = $this->get_plugin()->get_api( $this->get_access_token(), $this->is_sandbox() )->get_locations();
 
620
 
621
  // check the returned IDs against what's currently configured
622
  $stored_location_id = $this->get_location_id();
609
  */
610
  public function get_locations() {
611
 
612
+ // if locations have already been fetched, no need to fetch again
613
+ if ( is_array( $this->locations ) ) {
614
+
615
+ return $this->locations;
616
+ }
617
+
618
+ // don't always need to refetch when not on Settings screen
619
+ if ( ! ( isset( $_GET['page'], $_GET['tab'] ) && 'wc-settings' === $_GET['page'] && Plugin::PLUGIN_ID === $_GET['tab'] ) ) {
620
+
621
+ $this->locations = get_transient( 'wc_square_locations' );
622
+ }
623
+
624
  if ( ! is_array( $this->locations ) ) {
625
 
626
  $this->locations = [];
629
 
630
  // cache the locations returned so they can be used elsewhere
631
  $this->locations = $this->get_plugin()->get_api( $this->get_access_token(), $this->is_sandbox() )->get_locations();
632
+ set_transient( 'wc_square_locations', $this->locations, HOUR_IN_SECONDS );
633
 
634
  // check the returned IDs against what's currently configured
635
  $stored_location_id = $this->get_location_id();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: credit card, square, woocommerce, inventory sync
4
  Requires at least: 4.6
5
  Tested up to: 5.4
6
  Requires PHP: 5.6
7
- Stable tag: 2.1.1
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -72,6 +72,9 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
72
 
73
  == Changelog ==
74
 
 
 
 
75
  = 2.1.2 - 2020.04.29 =
76
  * Fix - INTENT_MISMATCH errors when guest customers save a card and registration is disabled.
77
  * Fix - Improve checkout compatibility with password managers such as 1Password. This also avoids payment for reload on address change.
4
  Requires at least: 4.6
5
  Tested up to: 5.4
6
  Requires PHP: 5.6
7
+ Stable tag: 2.1.3
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
72
 
73
  == Changelog ==
74
 
75
+ = 2.1.3 - 2020.04.30 =
76
+ * Fix - Persistent caching of locations to prevent unnecessary refetching and rate limiting.
77
+
78
  = 2.1.2 - 2020.04.29 =
79
  * Fix - INTENT_MISMATCH errors when guest customers save a card and registration is disabled.
80
  * Fix - Improve checkout compatibility with password managers such as 1Password. This also avoids payment for reload on address change.
woocommerce-square.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
- * Version: 2.1.2
5
  * Plugin URI: https://woocommerce.com/products/square/
6
  * Description: Adds ability to sync inventory between WooCommerce and Square POS. In addition, you can also make purchases through the Square payment gateway.
7
  * Author: WooCommerce
@@ -9,7 +9,7 @@
9
  * Text Domain: woocommerce-square
10
  * Domain Path: /i18n/languages/
11
  *
12
- * Copyright: (c) 2019, Automattic, Inc.
13
  *
14
  * License: GNU General Public License v3.0
15
  * License URI: http://www.gnu.org/licenses/gpl-3.0.html
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
+ * Version: 2.1.3
5
  * Plugin URI: https://woocommerce.com/products/square/
6
  * Description: Adds ability to sync inventory between WooCommerce and Square POS. In addition, you can also make purchases through the Square payment gateway.
7
  * Author: WooCommerce
9
  * Text Domain: woocommerce-square
10
  * Domain Path: /i18n/languages/
11
  *
12
+ * Copyright: © 2020 WooCommerce
13
  *
14
  * License: GNU General Public License v3.0
15
  * License URI: http://www.gnu.org/licenses/gpl-3.0.html