WooCommerce Square - Version 3.0.2

Version Description

  • 2022-05-17 =
  • Fix - Prevent fatal error caused by stale transient (cached location data from previous Square API). #788
  • Fix - Disable all plugin features if server requirements are not met, to prevent fatal errors. #793
Download this release

Release Info

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

Code changes from version 3.0.1 to 3.0.2

changelog.txt CHANGED
@@ -1,7 +1,12 @@
1
  *** WooCommerce Square Changelog ***
2
 
 
 
 
 
3
  = 3.0.1 - 2022-05-09 =
4
  * Fix - Checkout stuck processing when using a card that doesn't require a postal code. #782
 
5
 
6
  = 3.0.0 - 2022-05-04 =
7
  * New - Upgrade the payment form on checkout to use the latest Square Web Payments SDK. PR#668
1
  *** WooCommerce Square Changelog ***
2
 
3
+ = 3.0.2 - 2022-05-17 =
4
+ * Fix - Prevent fatal error caused by stale transient (cached location data from previous Square API). #788
5
+ * Fix - Disable all plugin features if server requirements are not met, to prevent fatal errors. #793
6
+
7
  = 3.0.1 - 2022-05-09 =
8
  * Fix - Checkout stuck processing when using a card that doesn't require a postal code. #782
9
+ * Dev - Update minimum PHP version requirement to 7.2. #787
10
 
11
  = 3.0.0 - 2022-05-04 =
12
  * New - Upgrade the payment form on checkout to use the latest Square Web Payments SDK. PR#668
i18n/languages/woocommerce-square.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WooCommerce Square 3.0.1\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-square\n"
8
- "POT-Creation-Date: 2022-05-09 06:03:13+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -69,7 +69,7 @@ msgid "Stock must be fetched from Square before editing stock quantity"
69
  msgstr ""
70
 
71
  #: includes/Admin/Privacy.php:43 includes/Admin/Settings_Page.php:54
72
- #: includes/Gateway.php:82 includes/Settings.php:221 includes/Settings.php:755
73
  msgid "Square"
74
  msgstr ""
75
 
@@ -434,11 +434,11 @@ msgstr ""
434
  msgid "The sync job has failed. Check sync records, or %s."
435
  msgstr ""
436
 
437
- #: includes/Framework/Lifecycle.php:303 includes/Lifecycle.php:183
438
  msgid "Awesome"
439
  msgstr ""
440
 
441
- #: includes/Framework/Lifecycle.php:304 includes/Lifecycle.php:186
442
  msgid "Fantastic"
443
  msgstr ""
444
 
@@ -446,7 +446,7 @@ msgstr ""
446
  msgid "Cowabunga"
447
  msgstr ""
448
 
449
- #: includes/Framework/Lifecycle.php:306 includes/Lifecycle.php:184
450
  msgid "Congratulations"
451
  msgstr ""
452
 
@@ -454,7 +454,7 @@ msgstr ""
454
  msgid "Hot dog"
455
  msgstr ""
456
 
457
- #: includes/Framework/Lifecycle.php:314 includes/Lifecycle.php:193
458
  #. translators: Placeholders: %1$s - plugin name, %2$s - <a> tag, %3$s - </a>
459
  #. tag, %4$s - <a> tag, %5$s - </a> tag
460
  msgid ""
@@ -2199,7 +2199,7 @@ msgid_plural "Updated data for %d products."
2199
  msgstr[0] ""
2200
  msgstr[1] ""
2201
 
2202
- #: includes/Lifecycle.php:185
2203
  msgid "Great"
2204
  msgstr ""
2205
 
@@ -3236,6 +3236,26 @@ msgstr[1] ""
3236
  msgid "Migrated action with ID %1$d in %2$s to ID %3$d in %4$s"
3237
  msgstr ""
3238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3239
  #. Plugin URI of the plugin/theme
3240
  msgid "https://woocommerce.com/products/square/"
3241
  msgstr ""
2
  # This file is distributed under the GNU General Public License v3.0.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce Square 3.0.2\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/woocommerce-square\n"
8
+ "POT-Creation-Date: 2022-05-17 02:42:33+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
69
  msgstr ""
70
 
71
  #: includes/Admin/Privacy.php:43 includes/Admin/Settings_Page.php:54
72
+ #: includes/Gateway.php:82 includes/Settings.php:221 includes/Settings.php:757
73
  msgid "Square"
74
  msgstr ""
75
 
434
  msgid "The sync job has failed. Check sync records, or %s."
435
  msgstr ""
436
 
437
+ #: includes/Framework/Lifecycle.php:303 includes/Lifecycle.php:184
438
  msgid "Awesome"
439
  msgstr ""
440
 
441
+ #: includes/Framework/Lifecycle.php:304 includes/Lifecycle.php:187
442
  msgid "Fantastic"
443
  msgstr ""
444
 
446
  msgid "Cowabunga"
447
  msgstr ""
448
 
449
+ #: includes/Framework/Lifecycle.php:306 includes/Lifecycle.php:185
450
  msgid "Congratulations"
451
  msgstr ""
452
 
454
  msgid "Hot dog"
455
  msgstr ""
456
 
457
+ #: includes/Framework/Lifecycle.php:314 includes/Lifecycle.php:194
458
  #. translators: Placeholders: %1$s - plugin name, %2$s - <a> tag, %3$s - </a>
459
  #. tag, %4$s - <a> tag, %5$s - </a> tag
460
  msgid ""
2199
  msgstr[0] ""
2200
  msgstr[1] ""
2201
 
2202
+ #: includes/Lifecycle.php:186
2203
  msgid "Great"
2204
  msgstr ""
2205
 
3236
  msgid "Migrated action with ID %1$d in %2$s to ID %3$d in %4$s"
3237
  msgstr ""
3238
 
3239
+ #: woocommerce-square.php:344
3240
+ msgid ""
3241
+ "<strong>All features in %1$s have been disabled</strong> due to unsupported "
3242
+ "settings:<br>"
3243
+ msgstr ""
3244
+
3245
+ #: woocommerce-square.php:351
3246
+ msgid ""
3247
+ "&bull;&nbsp;<strong>Invalid PHP version: </strong>The minimum PHP version "
3248
+ "required is %1$s. You are running %2$s.<br>"
3249
+ msgstr ""
3250
+
3251
+ #: woocommerce-square.php:359
3252
+ msgid ""
3253
+ "&bull;&nbsp;<strong>Invalid OPcache config: </strong><a href=\"%s\" "
3254
+ "target=\"_blank\">Please ensure the <code>save_comments</code> PHP option "
3255
+ "is enabled.</a> You may need to contact your hosting provider to change "
3256
+ "caching options."
3257
+ msgstr ""
3258
+
3259
  #. Plugin URI of the plugin/theme
3260
  msgid "https://woocommerce.com/products/square/"
3261
  msgstr ""
includes/Lifecycle.php CHANGED
@@ -54,6 +54,7 @@ class Lifecycle extends \WooCommerce\Square\Framework\Lifecycle {
54
  '2.1.5',
55
  '2.2.0',
56
  '2.3.0',
 
57
  );
58
  }
59
 
@@ -232,6 +233,17 @@ class Lifecycle extends \WooCommerce\Square\Framework\Lifecycle {
232
  update_option( 'woocommerce_square_credit_card_settings', $gateway_settings );
233
  }
234
 
 
 
 
 
 
 
 
 
 
 
 
235
  /**
236
  * Migrates plugin settings from v1 to v2.
237
  *
54
  '2.1.5',
55
  '2.2.0',
56
  '2.3.0',
57
+ '3.0.2',
58
  );
59
  }
60
 
233
  update_option( 'woocommerce_square_credit_card_settings', $gateway_settings );
234
  }
235
 
236
+ /**
237
+ * Deletes the transient that holds locations data.
238
+ *
239
+ * @see https://github.com/woocommerce/woocommerce-square/issues/786#issuecomment-1121388650
240
+ *
241
+ * @since 3.0.2
242
+ */
243
+ protected function upgrade_to_3_0_2() {
244
+ delete_transient( 'wc_square_locations' );
245
+ }
246
+
247
  /**
248
  * Migrates plugin settings from v1 to v2.
249
  *
includes/Plugin.php CHANGED
@@ -43,7 +43,7 @@ class Plugin extends Payment_Gateway_Plugin {
43
 
44
 
45
  /** plugin version number */
46
- const VERSION = '3.0.1';
47
 
48
  /** plugin ID */
49
  const PLUGIN_ID = 'square';
43
 
44
 
45
  /** plugin version number */
46
+ const VERSION = '3.0.2';
47
 
48
  /** plugin ID */
49
  const PLUGIN_ID = 'square';
includes/Settings.php CHANGED
@@ -685,10 +685,12 @@ class Settings extends \WC_Settings_API {
685
  return $this->locations;
686
  }
687
 
 
 
688
  // don't always need to refetch when not on Settings screen.
689
  if ( ! $this->is_admin_settings_screen() ) {
690
 
691
- $this->locations = get_transient( 'wc_square_locations' );
692
  }
693
 
694
  if ( ! is_array( $this->locations ) && did_action( 'wc_square_initialized' ) ) {
@@ -699,7 +701,7 @@ class Settings extends \WC_Settings_API {
699
 
700
  // cache the locations returned so they can be used elsewhere.
701
  $this->locations = $this->get_plugin()->get_api( $this->get_access_token(), $this->is_sandbox() )->get_locations();
702
- set_transient( 'wc_square_locations', $this->locations, HOUR_IN_SECONDS );
703
 
704
  // check the returned IDs against what's currently configured.
705
  $stored_location_id = $this->get_location_id();
685
  return $this->locations;
686
  }
687
 
688
+ $locations_transient_key = 'wc_square_locations_' . $this->get_plugin()->get_version();
689
+
690
  // don't always need to refetch when not on Settings screen.
691
  if ( ! $this->is_admin_settings_screen() ) {
692
 
693
+ $this->locations = get_transient( $locations_transient_key );
694
  }
695
 
696
  if ( ! is_array( $this->locations ) && did_action( 'wc_square_initialized' ) ) {
701
 
702
  // cache the locations returned so they can be used elsewhere.
703
  $this->locations = $this->get_plugin()->get_api( $this->get_access_token(), $this->is_sandbox() )->get_locations();
704
+ set_transient( $locations_transient_key, $this->locations, HOUR_IN_SECONDS );
705
 
706
  // check the returned IDs against what's currently configured.
707
  $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.9
6
  Requires PHP: 7.2
7
- Stable tag: 3.0.1
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -71,8 +71,13 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
71
  2. The payment gateway settings.
72
 
73
  == Changelog ==
 
 
 
 
74
  = 3.0.1 - 2022-05-09 =
75
  * Fix - Checkout stuck processing when using a card that doesn't require a postal code. #782
 
76
 
77
  = 3.0.0 - 2022-05-04 =
78
  * New - Upgrade the payment form on checkout to use the latest Square Web Payments SDK. PR#668
4
  Requires at least: 4.6
5
  Tested up to: 5.9
6
  Requires PHP: 7.2
7
+ Stable tag: 3.0.2
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
71
  2. The payment gateway settings.
72
 
73
  == Changelog ==
74
+ = 3.0.2 - 2022-05-17 =
75
+ * Fix - Prevent fatal error caused by stale transient (cached location data from previous Square API). #788
76
+ * Fix - Disable all plugin features if server requirements are not met, to prevent fatal errors. #793
77
+
78
  = 3.0.1 - 2022-05-09 =
79
  * Fix - Checkout stuck processing when using a card that doesn't require a postal code. #782
80
+ * Dev - Update minimum PHP version requirement to 7.2. #787
81
 
82
  = 3.0.0 - 2022-05-04 =
83
  * New - Upgrade the payment form on checkout to use the latest Square Web Payments SDK. PR#668
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit42c48ceaa986e1554a68107e2a17949b::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit7072728371f354d13d3ec661f551a552::getLoader();
vendor/composer/ClassLoader.php CHANGED
@@ -338,7 +338,7 @@ class ClassLoader
338
  * Loads the given class or interface.
339
  *
340
  * @param string $class The name of the class
341
- * @return true|null True if loaded, null otherwise
342
  */
343
  public function loadClass($class)
344
  {
@@ -347,8 +347,6 @@ class ClassLoader
347
 
348
  return true;
349
  }
350
-
351
- return null;
352
  }
353
 
354
  /**
338
  * Loads the given class or interface.
339
  *
340
  * @param string $class The name of the class
341
+ * @return bool|null True if loaded, null otherwise
342
  */
343
  public function loadClass($class)
344
  {
347
 
348
  return true;
349
  }
 
 
350
  }
351
 
352
  /**
vendor/composer/InstalledVersions.php CHANGED
@@ -1,337 +1,335 @@
1
  <?php
2
 
3
- /*
4
- * This file is part of Composer.
5
- *
6
- * (c) Nils Adermann <naderman@naderman.de>
7
- * Jordi Boggiano <j.boggiano@seld.be>
8
- *
9
- * For the full copyright and license information, please view the LICENSE
10
- * file that was distributed with this source code.
11
- */
12
 
13
  namespace Composer;
14
 
15
  use Composer\Autoload\ClassLoader;
16
  use Composer\Semver\VersionParser;
17
 
18
- /**
19
- * This class is copied in every Composer installed project and available to all
20
- *
21
- * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
22
- *
23
- * To require it's presence, you can require `composer-runtime-api ^2.0`
24
- */
25
  class InstalledVersions
26
  {
27
- private static $installed;
28
- private static $canGetVendors;
29
- private static $installedByVendor = array();
30
-
31
- /**
32
- * Returns a list of all package names which are present, either by being installed, replaced or provided
33
- *
34
- * @return string[]
35
- * @psalm-return list<string>
36
- */
37
- public static function getInstalledPackages()
38
- {
39
- $packages = array();
40
- foreach (self::getInstalled() as $installed) {
41
- $packages[] = array_keys($installed['versions']);
42
- }
43
-
44
- if (1 === \count($packages)) {
45
- return $packages[0];
46
- }
47
-
48
- return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
49
- }
50
-
51
- /**
52
- * Returns a list of all package names with a specific type e.g. 'library'
53
- *
54
- * @param string $type
55
- * @return string[]
56
- * @psalm-return list<string>
57
- */
58
- public static function getInstalledPackagesByType($type)
59
- {
60
- $packagesByType = array();
61
-
62
- foreach (self::getInstalled() as $installed) {
63
- foreach ($installed['versions'] as $name => $package) {
64
- if (isset($package['type']) && $package['type'] === $type) {
65
- $packagesByType[] = $name;
66
- }
67
- }
68
- }
69
-
70
- return $packagesByType;
71
- }
72
-
73
- /**
74
- * Checks whether the given package is installed
75
- *
76
- * This also returns true if the package name is provided or replaced by another package
77
- *
78
- * @param string $packageName
79
- * @param bool $includeDevRequirements
80
- * @return bool
81
- */
82
- public static function isInstalled($packageName, $includeDevRequirements = true)
83
- {
84
- foreach (self::getInstalled() as $installed) {
85
- if (isset($installed['versions'][$packageName])) {
86
- return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
87
- }
88
- }
89
-
90
- return false;
91
- }
92
-
93
- /**
94
- * Checks whether the given package satisfies a version constraint
95
- *
96
- * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
97
- *
98
- * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
99
- *
100
- * @param VersionParser $parser Install composer/semver to have access to this class and functionality
101
- * @param string $packageName
102
- * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
103
- * @return bool
104
- */
105
- public static function satisfies(VersionParser $parser, $packageName, $constraint)
106
- {
107
- $constraint = $parser->parseConstraints($constraint);
108
- $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
109
-
110
- return $provided->matches($constraint);
111
- }
112
-
113
- /**
114
- * Returns a version constraint representing all the range(s) which are installed for a given package
115
- *
116
- * It is easier to use this via isInstalled() with the $constraint argument if you need to check
117
- * whether a given version of a package is installed, and not just whether it exists
118
- *
119
- * @param string $packageName
120
- * @return string Version constraint usable with composer/semver
121
- */
122
- public static function getVersionRanges($packageName)
123
- {
124
- foreach (self::getInstalled() as $installed) {
125
- if (!isset($installed['versions'][$packageName])) {
126
- continue;
127
- }
128
-
129
- $ranges = array();
130
- if (isset($installed['versions'][$packageName]['pretty_version'])) {
131
- $ranges[] = $installed['versions'][$packageName]['pretty_version'];
132
- }
133
- if (array_key_exists('aliases', $installed['versions'][$packageName])) {
134
- $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
135
- }
136
- if (array_key_exists('replaced', $installed['versions'][$packageName])) {
137
- $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
138
- }
139
- if (array_key_exists('provided', $installed['versions'][$packageName])) {
140
- $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
141
- }
142
-
143
- return implode(' || ', $ranges);
144
- }
145
-
146
- throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
147
- }
148
-
149
- /**
150
- * @param string $packageName
151
- * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
152
- */
153
- public static function getVersion($packageName)
154
- {
155
- foreach (self::getInstalled() as $installed) {
156
- if (!isset($installed['versions'][$packageName])) {
157
- continue;
158
- }
159
-
160
- if (!isset($installed['versions'][$packageName]['version'])) {
161
- return null;
162
- }
163
-
164
- return $installed['versions'][$packageName]['version'];
165
- }
166
-
167
- throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
168
- }
169
-
170
- /**
171
- * @param string $packageName
172
- * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
173
- */
174
- public static function getPrettyVersion($packageName)
175
- {
176
- foreach (self::getInstalled() as $installed) {
177
- if (!isset($installed['versions'][$packageName])) {
178
- continue;
179
- }
180
-
181
- if (!isset($installed['versions'][$packageName]['pretty_version'])) {
182
- return null;
183
- }
184
-
185
- return $installed['versions'][$packageName]['pretty_version'];
186
- }
187
-
188
- throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
189
- }
190
-
191
- /**
192
- * @param string $packageName
193
- * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
194
- */
195
- public static function getReference($packageName)
196
- {
197
- foreach (self::getInstalled() as $installed) {
198
- if (!isset($installed['versions'][$packageName])) {
199
- continue;
200
- }
201
-
202
- if (!isset($installed['versions'][$packageName]['reference'])) {
203
- return null;
204
- }
205
-
206
- return $installed['versions'][$packageName]['reference'];
207
- }
208
-
209
- throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
210
- }
211
-
212
- /**
213
- * @param string $packageName
214
- * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
215
- */
216
- public static function getInstallPath($packageName)
217
- {
218
- foreach (self::getInstalled() as $installed) {
219
- if (!isset($installed['versions'][$packageName])) {
220
- continue;
221
- }
222
-
223
- return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
224
- }
225
-
226
- throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
227
- }
228
-
229
- /**
230
- * @return array
231
- * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}
232
- */
233
- public static function getRootPackage()
234
- {
235
- $installed = self::getInstalled();
236
-
237
- return $installed[0]['root'];
238
- }
239
-
240
- /**
241
- * Returns the raw installed.php data for custom implementations
242
- *
243
- * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
244
- * @return array[]
245
- * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}
246
- */
247
- public static function getRawData()
248
- {
249
- @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
250
-
251
- if (null === self::$installed) {
252
- // only require the installed.php file if this file is loaded from its dumped location,
253
- // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
254
- if (substr(__DIR__, -8, 1) !== 'C') {
255
- self::$installed = include __DIR__ . '/installed.php';
256
- } else {
257
- self::$installed = array();
258
- }
259
- }
260
-
261
- return self::$installed;
262
- }
263
-
264
- /**
265
- * Returns the raw data of all installed.php which are currently loaded for custom implementations
266
- *
267
- * @return array[]
268
- * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}>
269
- */
270
- public static function getAllRawData()
271
- {
272
- return self::getInstalled();
273
- }
274
-
275
- /**
276
- * Lets you reload the static array from another file
277
- *
278
- * This is only useful for complex integrations in which a project needs to use
279
- * this class but then also needs to execute another project's autoloader in process,
280
- * and wants to ensure both projects have access to their version of installed.php.
281
- *
282
- * A typical case would be PHPUnit, where it would need to make sure it reads all
283
- * the data it needs from this class, then call reload() with
284
- * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
285
- * the project in which it runs can then also use this class safely, without
286
- * interference between PHPUnit's dependencies and the project's dependencies.
287
- *
288
- * @param array[] $data A vendor/composer/installed.php data set
289
- * @return void
290
- *
291
- * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>} $data
292
- */
293
- public static function reload($data)
294
- {
295
- self::$installed = $data;
296
- self::$installedByVendor = array();
297
- }
298
-
299
- /**
300
- * @return array[]
301
- * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}>
302
- */
303
- private static function getInstalled()
304
- {
305
- if (null === self::$canGetVendors) {
306
- self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
307
- }
308
-
309
- $installed = array();
310
-
311
- if (self::$canGetVendors) {
312
- foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
313
- if (isset(self::$installedByVendor[$vendorDir])) {
314
- $installed[] = self::$installedByVendor[$vendorDir];
315
- } elseif (is_file($vendorDir.'/composer/installed.php')) {
316
- $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
317
- if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
318
- self::$installed = $installed[count($installed) - 1];
319
- }
320
- }
321
- }
322
- }
323
-
324
- if (null === self::$installed) {
325
- // only require the installed.php file if this file is loaded from its dumped location,
326
- // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
327
- if (substr(__DIR__, -8, 1) !== 'C') {
328
- self::$installed = require __DIR__ . '/installed.php';
329
- } else {
330
- self::$installed = array();
331
- }
332
- }
333
- $installed[] = self::$installed;
334
-
335
- return $installed;
336
- }
337
  }
1
  <?php
2
 
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
 
13
  namespace Composer;
14
 
15
  use Composer\Autoload\ClassLoader;
16
  use Composer\Semver\VersionParser;
17
 
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
  class InstalledVersions
26
  {
27
+ private static $installed = array (
28
+ 'root' =>
29
+ array (
30
+ 'pretty_version' => 'dev-release/3.0.2',
31
+ 'version' => 'dev-release/3.0.2',
32
+ 'aliases' =>
33
+ array (
34
+ ),
35
+ 'reference' => 'ba3fd54c620278723f9131d85393b924dc692f5e',
36
+ 'name' => 'woocommerce/woocommerce-square',
37
+ ),
38
+ 'versions' =>
39
+ array (
40
+ 'apimatic/jsonmapper' =>
41
+ array (
42
+ 'pretty_version' => 'v2.0.3',
43
+ 'version' => '2.0.3.0',
44
+ 'aliases' =>
45
+ array (
46
+ ),
47
+ 'reference' => 'f7588f1ab692c402a9118e65cb9fd42b74e5e0db',
48
+ ),
49
+ 'apimatic/unirest-php' =>
50
+ array (
51
+ 'pretty_version' => '2.0.0',
52
+ 'version' => '2.0.0.0',
53
+ 'aliases' =>
54
+ array (
55
+ ),
56
+ 'reference' => 'b4e399a8970c3a5c611f734282f306381f9d1eee',
57
+ ),
58
+ 'square/square' =>
59
+ array (
60
+ 'pretty_version' => '15.0.0.20211020',
61
+ 'version' => '15.0.0.20211020',
62
+ 'aliases' =>
63
+ array (
64
+ ),
65
+ 'reference' => 'a31e7fbb6cd458095b2f09543d799a06c35fd2a7',
66
+ ),
67
+ 'woocommerce/action-scheduler' =>
68
+ array (
69
+ 'pretty_version' => '3.4.0',
70
+ 'version' => '3.4.0.0',
71
+ 'aliases' =>
72
+ array (
73
+ ),
74
+ 'reference' => '3218a33ff14b968f8cb05de9656c2efa1eeb1330',
75
+ ),
76
+ 'woocommerce/woocommerce-square' =>
77
+ array (
78
+ 'pretty_version' => 'dev-release/3.0.2',
79
+ 'version' => 'dev-release/3.0.2',
80
+ 'aliases' =>
81
+ array (
82
+ ),
83
+ 'reference' => 'ba3fd54c620278723f9131d85393b924dc692f5e',
84
+ ),
85
+ ),
86
+ );
87
+ private static $canGetVendors;
88
+ private static $installedByVendor = array();
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ public static function getInstalledPackages()
97
+ {
98
+ $packages = array();
99
+ foreach (self::getInstalled() as $installed) {
100
+ $packages[] = array_keys($installed['versions']);
101
+ }
102
+
103
+ if (1 === \count($packages)) {
104
+ return $packages[0];
105
+ }
106
+
107
+ return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
108
+ }
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ public static function isInstalled($packageName)
119
+ {
120
+ foreach (self::getInstalled() as $installed) {
121
+ if (isset($installed['versions'][$packageName])) {
122
+ return true;
123
+ }
124
+ }
125
+
126
+ return false;
127
+ }
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ public static function satisfies(VersionParser $parser, $packageName, $constraint)
143
+ {
144
+ $constraint = $parser->parseConstraints($constraint);
145
+ $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
146
+
147
+ return $provided->matches($constraint);
148
+ }
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+ public static function getVersionRanges($packageName)
160
+ {
161
+ foreach (self::getInstalled() as $installed) {
162
+ if (!isset($installed['versions'][$packageName])) {
163
+ continue;
164
+ }
165
+
166
+ $ranges = array();
167
+ if (isset($installed['versions'][$packageName]['pretty_version'])) {
168
+ $ranges[] = $installed['versions'][$packageName]['pretty_version'];
169
+ }
170
+ if (array_key_exists('aliases', $installed['versions'][$packageName])) {
171
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
172
+ }
173
+ if (array_key_exists('replaced', $installed['versions'][$packageName])) {
174
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
175
+ }
176
+ if (array_key_exists('provided', $installed['versions'][$packageName])) {
177
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
178
+ }
179
+
180
+ return implode(' || ', $ranges);
181
+ }
182
+
183
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
184
+ }
185
+
186
+
187
+
188
+
189
+
190
+ public static function getVersion($packageName)
191
+ {
192
+ foreach (self::getInstalled() as $installed) {
193
+ if (!isset($installed['versions'][$packageName])) {
194
+ continue;
195
+ }
196
+
197
+ if (!isset($installed['versions'][$packageName]['version'])) {
198
+ return null;
199
+ }
200
+
201
+ return $installed['versions'][$packageName]['version'];
202
+ }
203
+
204
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
205
+ }
206
+
207
+
208
+
209
+
210
+
211
+ public static function getPrettyVersion($packageName)
212
+ {
213
+ foreach (self::getInstalled() as $installed) {
214
+ if (!isset($installed['versions'][$packageName])) {
215
+ continue;
216
+ }
217
+
218
+ if (!isset($installed['versions'][$packageName]['pretty_version'])) {
219
+ return null;
220
+ }
221
+
222
+ return $installed['versions'][$packageName]['pretty_version'];
223
+ }
224
+
225
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
226
+ }
227
+
228
+
229
+
230
+
231
+
232
+ public static function getReference($packageName)
233
+ {
234
+ foreach (self::getInstalled() as $installed) {
235
+ if (!isset($installed['versions'][$packageName])) {
236
+ continue;
237
+ }
238
+
239
+ if (!isset($installed['versions'][$packageName]['reference'])) {
240
+ return null;
241
+ }
242
+
243
+ return $installed['versions'][$packageName]['reference'];
244
+ }
245
+
246
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
247
+ }
248
+
249
+
250
+
251
+
252
+
253
+ public static function getRootPackage()
254
+ {
255
+ $installed = self::getInstalled();
256
+
257
+ return $installed[0]['root'];
258
+ }
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+ public static function getRawData()
268
+ {
269
+ @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
270
+
271
+ return self::$installed;
272
+ }
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+ public static function getAllRawData()
281
+ {
282
+ return self::getInstalled();
283
+ }
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+ public static function reload($data)
304
+ {
305
+ self::$installed = $data;
306
+ self::$installedByVendor = array();
307
+ }
308
+
309
+
310
+
311
+
312
+
313
+ private static function getInstalled()
314
+ {
315
+ if (null === self::$canGetVendors) {
316
+ self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
317
+ }
318
+
319
+ $installed = array();
320
+
321
+ if (self::$canGetVendors) {
322
+ foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
323
+ if (isset(self::$installedByVendor[$vendorDir])) {
324
+ $installed[] = self::$installedByVendor[$vendorDir];
325
+ } elseif (is_file($vendorDir.'/composer/installed.php')) {
326
+ $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
327
+ }
328
+ }
329
+ }
330
+
331
+ $installed[] = self::$installed;
332
+
333
+ return $installed;
334
+ }
 
 
335
  }
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit42c48ceaa986e1554a68107e2a17949b
6
  {
7
  private static $loader;
8
 
@@ -24,15 +24,15 @@ class ComposerAutoloaderInit42c48ceaa986e1554a68107e2a17949b
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
- spl_autoload_register(array('ComposerAutoloaderInit42c48ceaa986e1554a68107e2a17949b', 'loadClassLoader'), true, true);
28
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
29
- spl_autoload_unregister(array('ComposerAutoloaderInit42c48ceaa986e1554a68107e2a17949b', 'loadClassLoader'));
30
 
31
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
32
  if ($useStaticLoader) {
33
  require __DIR__ . '/autoload_static.php';
34
 
35
- call_user_func(\Composer\Autoload\ComposerStaticInit42c48ceaa986e1554a68107e2a17949b::getInitializer($loader));
36
  } else {
37
  $map = require __DIR__ . '/autoload_namespaces.php';
38
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit7072728371f354d13d3ec661f551a552
6
  {
7
  private static $loader;
8
 
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
+ spl_autoload_register(array('ComposerAutoloaderInit7072728371f354d13d3ec661f551a552', 'loadClassLoader'), true, true);
28
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
29
+ spl_autoload_unregister(array('ComposerAutoloaderInit7072728371f354d13d3ec661f551a552', 'loadClassLoader'));
30
 
31
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
32
  if ($useStaticLoader) {
33
  require __DIR__ . '/autoload_static.php';
34
 
35
+ call_user_func(\Composer\Autoload\ComposerStaticInit7072728371f354d13d3ec661f551a552::getInitializer($loader));
36
  } else {
37
  $map = require __DIR__ . '/autoload_namespaces.php';
38
  foreach ($map as $namespace => $path) {
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit42c48ceaa986e1554a68107e2a17949b
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'a' =>
@@ -45,10 +45,10 @@ class ComposerStaticInit42c48ceaa986e1554a68107e2a17949b
45
  public static function getInitializer(ClassLoader $loader)
46
  {
47
  return \Closure::bind(function () use ($loader) {
48
- $loader->prefixLengthsPsr4 = ComposerStaticInit42c48ceaa986e1554a68107e2a17949b::$prefixLengthsPsr4;
49
- $loader->prefixDirsPsr4 = ComposerStaticInit42c48ceaa986e1554a68107e2a17949b::$prefixDirsPsr4;
50
- $loader->prefixesPsr0 = ComposerStaticInit42c48ceaa986e1554a68107e2a17949b::$prefixesPsr0;
51
- $loader->classMap = ComposerStaticInit42c48ceaa986e1554a68107e2a17949b::$classMap;
52
 
53
  }, null, ClassLoader::class);
54
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit7072728371f354d13d3ec661f551a552
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'a' =>
45
  public static function getInitializer(ClassLoader $loader)
46
  {
47
  return \Closure::bind(function () use ($loader) {
48
+ $loader->prefixLengthsPsr4 = ComposerStaticInit7072728371f354d13d3ec661f551a552::$prefixLengthsPsr4;
49
+ $loader->prefixDirsPsr4 = ComposerStaticInit7072728371f354d13d3ec661f551a552::$prefixDirsPsr4;
50
+ $loader->prefixesPsr0 = ComposerStaticInit7072728371f354d13d3ec661f551a552::$prefixesPsr0;
51
+ $loader->classMap = ComposerStaticInit7072728371f354d13d3ec661f551a552::$classMap;
52
 
53
  }, null, ClassLoader::class);
54
  }
vendor/composer/installed.php CHANGED
@@ -1,59 +1,60 @@
1
- <?php return array(
2
- 'root' => array(
3
- 'pretty_version' => 'dev-release/3.0.1',
4
- 'version' => 'dev-release/3.0.1',
5
- 'type' => 'library',
6
- 'install_path' => __DIR__ . '/../../',
7
- 'aliases' => array(),
8
- 'reference' => 'd273dbddced207edeeaf078ce1eabc4c13fb3131',
9
- 'name' => 'woocommerce/woocommerce-square',
10
- 'dev' => false,
11
  ),
12
- 'versions' => array(
13
- 'apimatic/jsonmapper' => array(
14
- 'pretty_version' => 'v2.0.3',
15
- 'version' => '2.0.3.0',
16
- 'type' => 'library',
17
- 'install_path' => __DIR__ . '/../apimatic/jsonmapper',
18
- 'aliases' => array(),
19
- 'reference' => 'f7588f1ab692c402a9118e65cb9fd42b74e5e0db',
20
- 'dev_requirement' => false,
21
- ),
22
- 'apimatic/unirest-php' => array(
23
- 'pretty_version' => '2.0.0',
24
- 'version' => '2.0.0.0',
25
- 'type' => 'library',
26
- 'install_path' => __DIR__ . '/../apimatic/unirest-php',
27
- 'aliases' => array(),
28
- 'reference' => 'b4e399a8970c3a5c611f734282f306381f9d1eee',
29
- 'dev_requirement' => false,
30
- ),
31
- 'square/square' => array(
32
- 'pretty_version' => '15.0.0.20211020',
33
- 'version' => '15.0.0.20211020',
34
- 'type' => 'library',
35
- 'install_path' => __DIR__ . '/../square/square',
36
- 'aliases' => array(),
37
- 'reference' => 'a31e7fbb6cd458095b2f09543d799a06c35fd2a7',
38
- 'dev_requirement' => false,
39
- ),
40
- 'woocommerce/action-scheduler' => array(
41
- 'pretty_version' => '3.4.0',
42
- 'version' => '3.4.0.0',
43
- 'type' => 'wordpress-plugin',
44
- 'install_path' => __DIR__ . '/../woocommerce/action-scheduler',
45
- 'aliases' => array(),
46
- 'reference' => '3218a33ff14b968f8cb05de9656c2efa1eeb1330',
47
- 'dev_requirement' => false,
48
- ),
49
- 'woocommerce/woocommerce-square' => array(
50
- 'pretty_version' => 'dev-release/3.0.1',
51
- 'version' => 'dev-release/3.0.1',
52
- 'type' => 'library',
53
- 'install_path' => __DIR__ . '/../../',
54
- 'aliases' => array(),
55
- 'reference' => 'd273dbddced207edeeaf078ce1eabc4c13fb3131',
56
- 'dev_requirement' => false,
57
- ),
58
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  );
1
+ <?php return array (
2
+ 'root' =>
3
+ array (
4
+ 'pretty_version' => 'dev-release/3.0.2',
5
+ 'version' => 'dev-release/3.0.2',
6
+ 'aliases' =>
7
+ array (
 
 
 
8
  ),
9
+ 'reference' => 'ba3fd54c620278723f9131d85393b924dc692f5e',
10
+ 'name' => 'woocommerce/woocommerce-square',
11
+ ),
12
+ 'versions' =>
13
+ array (
14
+ 'apimatic/jsonmapper' =>
15
+ array (
16
+ 'pretty_version' => 'v2.0.3',
17
+ 'version' => '2.0.3.0',
18
+ 'aliases' =>
19
+ array (
20
+ ),
21
+ 'reference' => 'f7588f1ab692c402a9118e65cb9fd42b74e5e0db',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  ),
23
+ 'apimatic/unirest-php' =>
24
+ array (
25
+ 'pretty_version' => '2.0.0',
26
+ 'version' => '2.0.0.0',
27
+ 'aliases' =>
28
+ array (
29
+ ),
30
+ 'reference' => 'b4e399a8970c3a5c611f734282f306381f9d1eee',
31
+ ),
32
+ 'square/square' =>
33
+ array (
34
+ 'pretty_version' => '15.0.0.20211020',
35
+ 'version' => '15.0.0.20211020',
36
+ 'aliases' =>
37
+ array (
38
+ ),
39
+ 'reference' => 'a31e7fbb6cd458095b2f09543d799a06c35fd2a7',
40
+ ),
41
+ 'woocommerce/action-scheduler' =>
42
+ array (
43
+ 'pretty_version' => '3.4.0',
44
+ 'version' => '3.4.0.0',
45
+ 'aliases' =>
46
+ array (
47
+ ),
48
+ 'reference' => '3218a33ff14b968f8cb05de9656c2efa1eeb1330',
49
+ ),
50
+ 'woocommerce/woocommerce-square' =>
51
+ array (
52
+ 'pretty_version' => 'dev-release/3.0.2',
53
+ 'version' => 'dev-release/3.0.2',
54
+ 'aliases' =>
55
+ array (
56
+ ),
57
+ 'reference' => 'ba3fd54c620278723f9131d85393b924dc692f5e',
58
+ ),
59
+ ),
60
  );
woocommerce-square.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
- * Version: 3.0.1
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
@@ -59,7 +59,7 @@ class WooCommerce_Square_Loader {
59
  const FRAMEWORK_VERSION = '5.4.0';
60
 
61
  /** the plugin name, for displaying notices */
62
- const PLUGIN_NAME = 'WooCommerce Square';
63
 
64
 
65
  /** @var WooCommerce_Square_Loader single instance of this class */
@@ -75,20 +75,14 @@ class WooCommerce_Square_Loader {
75
  * @since 2.0.0
76
  */
77
  protected function __construct() {
78
-
79
- register_activation_hook( __FILE__, array( $this, 'activation_check' ) );
80
-
81
- add_action( 'admin_init', array( $this, 'check_environment' ) );
82
  add_action( 'admin_init', array( $this, 'add_plugin_notices' ) );
83
-
84
  add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 );
85
 
86
- // if the environment check fails, initialize the plugin
87
  if ( $this->is_environment_compatible() ) {
88
  add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
 
89
  }
90
-
91
- add_action( 'woocommerce_blocks_payment_method_type_registration', array( $this, 'register_payment_method_block_integrations' ), 5, 1 );
92
  }
93
 
94
 
@@ -176,40 +170,6 @@ class WooCommerce_Square_Loader {
176
  return self::FRAMEWORK_VERSION;
177
  }
178
 
179
-
180
- /**
181
- * Checks the server environment and other factors and deactivates plugins as necessary.
182
- *
183
- * Based on http://wptavern.com/how-to-prevent-wordpress-plugins-from-activating-on-sites-with-incompatible-hosting-environments
184
- *
185
- * @since 2.0.0
186
- */
187
- public function activation_check() {
188
-
189
- if ( ! $this->is_environment_compatible() ) {
190
-
191
- $this->deactivate_plugin();
192
-
193
- wp_die( self::PLUGIN_NAME . ' could not be activated. ' . $this->get_environment_message() );
194
- }
195
- }
196
-
197
- /**
198
- * Checks the environment on loading WordPress, just in case the environment changes after activation.
199
- *
200
- * @since 2.0.0
201
- */
202
- public function check_environment() {
203
-
204
- if ( ! $this->is_environment_compatible() && is_plugin_active( plugin_basename( __FILE__ ) ) ) {
205
-
206
- $this->deactivate_plugin();
207
-
208
- $this->add_admin_notice( 'bad_environment', 'error', self::PLUGIN_NAME . ' has been deactivated. ' . $this->get_environment_message() );
209
- }
210
- }
211
-
212
-
213
  /**
214
  * Adds notices for out-of-date WordPress and/or WooCommerce versions.
215
  *
@@ -344,7 +304,20 @@ class WooCommerce_Square_Loader {
344
  ?>
345
  <div class="<?php echo esc_attr( $notice['class'] ); ?>">
346
  <p>
347
- <?php echo wp_kses( $notice['message'], array( 'a' => array( 'href' => array() ) ) ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  </p>
349
  </div>
350
  <?php
@@ -361,26 +334,69 @@ class WooCommerce_Square_Loader {
361
  *
362
  * @return bool
363
  */
364
- protected function is_environment_compatible() {
 
 
 
 
 
 
 
 
 
 
365
 
366
- return version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '>=' );
367
- }
 
 
 
 
 
368
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
 
370
  /**
371
- * Gets the message for display when the environment is incompatible with this plugin.
372
  *
373
- * @since 2.0.0
374
  *
375
- * @return string
376
  */
377
- protected function get_environment_message() {
378
-
379
- $message = sprintf( 'The minimum PHP version required for this plugin is %1$s. You are running %2$s.', self::MINIMUM_PHP_VERSION, PHP_VERSION );
380
 
381
- return $message;
382
  }
383
 
 
 
 
 
 
 
 
 
 
 
 
384
 
385
  /**
386
  * Register the Square Credit Card checkout block integration class
1
  <?php
2
  /**
3
  * Plugin Name: WooCommerce Square
4
+ * Version: 3.0.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
59
  const FRAMEWORK_VERSION = '5.4.0';
60
 
61
  /** the plugin name, for displaying notices */
62
+ const PLUGIN_NAME = 'Square for WooCommerce';
63
 
64
 
65
  /** @var WooCommerce_Square_Loader single instance of this class */
75
  * @since 2.0.0
76
  */
77
  protected function __construct() {
 
 
 
 
78
  add_action( 'admin_init', array( $this, 'add_plugin_notices' ) );
 
79
  add_action( 'admin_notices', array( $this, 'admin_notices' ), 15 );
80
 
81
+ // if the environment check fails, don't initialize the plugin.
82
  if ( $this->is_environment_compatible() ) {
83
  add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
84
+ add_action( 'woocommerce_blocks_payment_method_type_registration', array( $this, 'register_payment_method_block_integrations' ), 5, 1 );
85
  }
 
 
86
  }
87
 
88
 
170
  return self::FRAMEWORK_VERSION;
171
  }
172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  /**
174
  * Adds notices for out-of-date WordPress and/or WooCommerce versions.
175
  *
304
  ?>
305
  <div class="<?php echo esc_attr( $notice['class'] ); ?>">
306
  <p>
307
+ <?php
308
+ echo wp_kses(
309
+ $notice['message'],
310
+ array(
311
+ 'a' => array(
312
+ 'href' => array(),
313
+ 'target' => array(),
314
+ ),
315
+ 'code' => array(),
316
+ 'strong' => array(),
317
+ 'br' => array(),
318
+ )
319
+ );
320
+ ?>
321
  </p>
322
  </div>
323
  <?php
334
  *
335
  * @return bool
336
  */
337
+ public function is_environment_compatible() {
338
+ $is_php_valid = $this->is_php_version_valid();
339
+ $is_opcache_config_valid = $this->is_opcache_save_message_enabled();
340
+ $error_message = '';
341
+
342
+ if ( ! $is_php_valid || ! $is_opcache_config_valid ) {
343
+ $error_message .= sprintf(
344
+ __( '<strong>All features in %1$s have been disabled</strong> due to unsupported settings:<br>', 'woocommerce-square' ),
345
+ self::PLUGIN_NAME
346
+ );
347
+ }
348
 
349
+ if ( ! $is_php_valid ) {
350
+ $error_message .= sprintf(
351
+ __( '&bull;&nbsp;<strong>Invalid PHP version: </strong>The minimum PHP version required is %1$s. You are running %2$s.<br>', 'woocommerce-square' ),
352
+ self::MINIMUM_PHP_VERSION,
353
+ PHP_VERSION
354
+ );
355
+ }
356
 
357
+ if ( ! $is_opcache_config_valid ) {
358
+ $error_message .= sprintf(
359
+ __( '&bull;&nbsp;<strong>Invalid OPcache config: </strong><a href="%s" target="_blank">Please ensure the <code>save_comments</code> PHP option is enabled.</a> You may need to contact your hosting provider to change caching options.', 'woocommerce-square' ),
360
+ 'https://woocommerce.com/document/woocommerce-square/#section-43'
361
+ );
362
+ }
363
+
364
+ if ( ! empty( $error_message ) ) {
365
+ $this->add_admin_notice(
366
+ 'bad_environment',
367
+ 'error',
368
+ $error_message
369
+ );
370
+ }
371
+
372
+ return $is_php_valid && $is_opcache_config_valid;
373
+ }
374
 
375
  /**
376
+ * Returns true if opcache.save_comments is enabled.
377
  *
378
+ * @since 3.0.2
379
  *
380
+ * @return boolean
381
  */
382
+ protected function is_opcache_save_message_enabled() {
383
+ $zend_optimizer_plus = extension_loaded( 'Zend Optimizer+' ) && '0' === ( ini_get( 'zend_optimizerplus.save_comments' ) || '0' === ini_get( 'opcache.save_comments' ) );
384
+ $zend_opcache = extension_loaded( 'Zend OPcache' ) && '0' === ini_get( 'opcache.save_comments' );
385
 
386
+ return ! ( $zend_optimizer_plus || $zend_opcache );
387
  }
388
 
389
+ /**
390
+ * Returns true if the PHP version of the environment
391
+ * meets the requirement.
392
+ *
393
+ * @since 3.0.2
394
+ *
395
+ * @return boolean
396
+ */
397
+ protected function is_php_version_valid() {
398
+ return version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '>=' );
399
+ }
400
 
401
  /**
402
  * Register the Square Credit Card checkout block integration class